scaffolder-tools 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,18 +17,20 @@ class Scaffolder::Tool::Sequence < Scaffolder::Tool
17
17
  private
18
18
 
19
19
  def sequence(scaffold)
20
- sequence = scaffold.inject(String.new) do |string,entry|
21
- string << entry.sequence
22
- end
20
+ scaffold.map{|entry| entry.sequence}.join
23
21
  end
24
22
 
25
23
  def header(sequence,opts={})
26
- header = String.new
27
- header << opts[:definition] + " " if opts[:definition]
28
- unless opts[:no] && opts[:no][:sequence] && opts[:no][:sequence][:hash]
29
- header << Digest::SHA1.hexdigest(sequence)
24
+ header = Array.new
25
+ header << opts[:definition] if opts[:definition]
26
+ if opts[:'with-sequence-digest']
27
+ digest = Digest::SHA1.hexdigest(sequence)
28
+ header << "[sha1=#{digest}]"
30
29
  end
31
- header
30
+
31
+
32
+
33
+ header * ' '
32
34
  end
33
35
 
34
36
  end
@@ -19,13 +19,6 @@ module Scaffolder::ToolIndex
19
19
  end
20
20
  end
21
21
 
22
- def determine_tool(settings)
23
- type = settings.rest.shift
24
- tool_class = self[type]
25
- settings[:unknown_tool] = type unless (tool_exists?(type) or type.nil?)
26
- [tool_class,settings]
27
- end
28
-
29
22
  private
30
23
 
31
24
  def tool_classes
@@ -0,0 +1,127 @@
1
+ scaffolder-format(7) -- scaffolder authoring format using YAML
2
+ ==============================================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ The scaffolder software allows the construction of genome scaffolds using text
7
+ files written in the YAML format. An example scaffold file with three entries
8
+ is as follows:
9
+
10
+ ---
11
+ -
12
+ sequence:
13
+ source: 'sequence1'
14
+ -
15
+ unresolved:
16
+ length: 20
17
+ -
18
+ sequence:
19
+ source: 'sequence2'
20
+ start: 3
21
+ stop: 100
22
+ reverse: true
23
+ inserts:
24
+ -
25
+ source: 'insert1'
26
+ open: 5
27
+ close: 20
28
+
29
+ ## DESCRIPTION
30
+
31
+ Scaffold files are written using the YAML format. The scaffold file along with
32
+ the fasta file for the corresponding nucleotide sequences is used by the
33
+ scaffolder software to generate the scaffold super sequence.
34
+
35
+ The scaffold file should begin with three dashes `---`. This identifies the
36
+ start of a YAML formatted document. The scaffold file is composed of a list of
37
+ entries where the sequence for each entries is joined together to create the
38
+ scaffold sequence. Each scaffold entry should should have a '-' dash line to
39
+ indicate the start of the entry. The first line of the entry should define the
40
+ type of entry. The entry types allowed are outlined in the section below.
41
+
42
+ ## SCAFFOLD ENTRY TYPES
43
+
44
+ ### SEQUENCE
45
+
46
+ Sequence entries are the main component of the scaffold and insert the
47
+ nucleotide sequences from the fasta file into the scaffold. The `sequence` tag
48
+ is used to specify a sequence entry in the scaffold. The following tags can be
49
+ used to modify how the sequence is inserted into the scaffold:
50
+
51
+ * `source:` <sequence-name>:
52
+ **Required.** Specify the source nucleotide sequence to insert into the
53
+ scaffold. The value <sequence-name> should match the first space delimited
54
+ word from the fasta header of the required sequence.
55
+
56
+ * `reverse:` <true|false>:
57
+ **Optional.** Specify whether sequence should be reverse completed in the
58
+ scaffold. Default value is false.
59
+
60
+ * `start:` <trim-position>:
61
+ **Optional.** Specify if the sequence should be trimmed from the start to
62
+ the specified coordinate position. Default value is 1 where no sequence is
63
+ removed.
64
+
65
+ * `stop:` <trim-position>:
66
+ **Optional.** Specify if the sequence should be trimmed from the end of the
67
+ sequence. Sequence onward of specified trim position is removed. Default
68
+ value is the length of the fasta sequence where no sequence is removed.
69
+
70
+ * `inserts:` <insert-list>:
71
+ **Optional.** Specify if additional insert sequences should be added to
72
+ replace regions in this sequence. Should be specified as a list of YAML
73
+ formatted [INSERT][] entries. Default value is an empty list.
74
+
75
+ ### UNRESOLVED
76
+
77
+ Unresolved regions add sequences of N nucleotide characters to the scaffold.
78
+ They define gaps in the scaffold and join separate sequence sequence regions
79
+ together. Unresolved regions are specified using the `unresolved` tag. A single
80
+ attribute tag is used to specify the length of an unresolved region.
81
+
82
+ * `length:` <length>:
83
+ **Required.** Specify the length of the unresolved region to add to the
84
+ scaffold.
85
+
86
+ ### INSERTS
87
+
88
+ Insert sequences are used to replace regions in encoding [SEQUENCE][] entries.
89
+ Each insert should correspond to a sequence in the fasta file. Inserts share
90
+ the same attributes tags as [SEQUENCE][] entries but define two additional
91
+ `open` and `close` attribute tags. These specify where the insert should be
92
+ added to the encoding sequence. Multiple inserts can be added as a list to the
93
+ encoding sequence entry using the `inserts` attribute tag. The following
94
+ attribute tags can be to modify how an insert is added to the scaffold.
95
+
96
+ * `source:` <sequence-name>:
97
+ **Required.** Specify the insert sequence to use. The value <sequence-name>
98
+ should match the first space delimited word from the fasta header of the
99
+ required insert sequence.
100
+
101
+ * `reverse:` <true|false>:
102
+ **Optional.** Specify whether the insert should be reverse complemented.
103
+ Default value is false.
104
+
105
+ * `start:` <trim-position>:
106
+ **Optional.** Specify if the insert should be trimmed from the start to the
107
+ specified trim position. Default value is 1 where no sequence is removed.
108
+
109
+ * `stop:` <trim-position>:
110
+ **Optional.** Specify if the insert should be trimmed from the end of the
111
+ sequence. Sequence onward of trim position is removed. Default value is the
112
+ length of the fasta sequence where no sequence is removed.
113
+
114
+ * `open:` <insert-start-coordinate>:
115
+ **Optional if close coordinate is specified.** Specify the start coordinate
116
+ where the insert is added to the encoding sequence. Default value is the
117
+ close coordinate position minus the length of the insert sequence.
118
+
119
+ * `close:` <insert-close-coordinate>:
120
+ **Optional if open coordinate is specified.** Specify the end coordinate
121
+ position for adding the insert to the encoding sequence. Default value is
122
+ the open coordinate position plus the length of the insert sequence.
123
+
124
+ ## COPYRIGHT
125
+
126
+ **Scaffolder** is Copyright (C) 2010 Michael Barton
127
+ <http://michaelbarton.me.uk>
@@ -23,9 +23,9 @@ each contig specified in the scaffold file.
23
23
  Fasta definition line added at the top of the assembled sequence. The
24
24
  default is to use the SHA1 hash of the sequence as the definition.
25
25
 
26
- * `--no-sequence-hash`:
27
- Do not append the SHA1 hash of the assembled sequence to the definition
28
- line.
26
+ * `--with-sequence-digest`:
27
+ Add an SHA1 digest of the assembled sequence to the definition line. This
28
+ may be useful for comparing large scaffold assemblies for identity.
29
29
 
30
30
  ## EXAMPLES
31
31
 
@@ -36,8 +36,6 @@ Pipe the assembly into another file.
36
36
 
37
37
  ## BUGS
38
38
 
39
- ## BUGS
40
-
41
39
  **Scaffolder-sequence** is written in Ruby and depends on the scaffolder,
42
40
  BioRuby, configliere and ronn gems. See the Gemfile in the scaffolder-tools gem
43
41
  install directory for version details.
@@ -5,15 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scaffolder-tools}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Michael Barton"]
12
- s.date = %q{2011-01-28}
13
- s.default_executable = %q{scaffolder}
11
+ s.authors = [%q{Michael Barton}]
12
+ s.date = %q{2011-08-13}
14
13
  s.description = %q{Binary to use with scaffolder genome scaffolds}
15
- s.email = %q{mail@michaelbarton.me.uk}
16
- s.executables = ["scaffolder"]
14
+ s.email = %q{mail@next.gs}
15
+ s.executables = [%q{scaffolder}]
17
16
  s.extra_rdoc_files = [
18
17
  "LICENSE.txt",
19
18
  "README.rdoc"
@@ -21,12 +20,14 @@ Gem::Specification.new do |s|
21
20
  s.files = [
22
21
  ".document",
23
22
  ".rspec",
23
+ ".travis.yml",
24
24
  "Gemfile",
25
25
  "LICENSE.txt",
26
26
  "README.rdoc",
27
27
  "Rakefile",
28
28
  "VERSION",
29
29
  "bin/scaffolder",
30
+ "features/error_checking.feature",
30
31
  "features/help.feature",
31
32
  "features/sequence.feature",
32
33
  "features/step_definitions/scaffolder-tools.rb",
@@ -38,6 +39,7 @@ Gem::Specification.new do |s|
38
39
  "lib/scaffolder/tool/sequence.rb",
39
40
  "lib/scaffolder/tool/validate.rb",
40
41
  "lib/scaffolder/tool_index.rb",
42
+ "man/scaffolder-format.7.ronn",
41
43
  "man/scaffolder-help.1.ronn",
42
44
  "man/scaffolder-sequence.1.ronn",
43
45
  "man/scaffolder-validate.1.ronn",
@@ -51,24 +53,14 @@ Gem::Specification.new do |s|
51
53
  "spec/spec_helper.rb",
52
54
  "spec/support/exit_code_matcher.rb"
53
55
  ]
54
- s.homepage = %q{http://www.michaelbarton.me.uk/projects/scaffolder/}
55
- s.licenses = ["MIT"]
56
- s.require_paths = ["lib"]
57
- s.rubygems_version = %q{1.3.7}
56
+ s.homepage = %q{http://next.gs}
57
+ s.licenses = [%q{MIT}]
58
+ s.require_paths = [%q{lib}]
59
+ s.rubygems_version = %q{1.8.6}
58
60
  s.summary = %q{Tools for manipulating genome scaffolds}
59
- s.test_files = [
60
- "spec/scaffolder/binary_helper_spec.rb",
61
- "spec/scaffolder/tool/help_spec.rb",
62
- "spec/scaffolder/tool/sequence_spec.rb",
63
- "spec/scaffolder/tool/validate_spec.rb",
64
- "spec/scaffolder/tool_index_spec.rb",
65
- "spec/scaffolder/tool_spec.rb",
66
- "spec/spec_helper.rb",
67
- "spec/support/exit_code_matcher.rb"
68
- ]
61
+ s.test_files = [%q{spec/scaffolder/binary_helper_spec.rb}, %q{spec/scaffolder/tool/help_spec.rb}, %q{spec/scaffolder/tool/sequence_spec.rb}, %q{spec/scaffolder/tool/validate_spec.rb}, %q{spec/scaffolder/tool_index_spec.rb}, %q{spec/scaffolder/tool_spec.rb}, %q{spec/spec_helper.rb}, %q{spec/support/exit_code_matcher.rb}]
69
62
 
70
63
  if s.respond_to? :specification_version then
71
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
72
64
  s.specification_version = 3
73
65
 
74
66
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -78,15 +70,13 @@ Gem::Specification.new do |s|
78
70
  s.add_runtime_dependency(%q<ronn>, ["~> 0.7"])
79
71
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
80
72
  s.add_development_dependency(%q<jeweler>, ["~> 1.5"])
81
- s.add_development_dependency(%q<gherkin>, ["~> 2.3.3"])
82
73
  s.add_development_dependency(%q<rspec>, ["~> 2.4"])
83
74
  s.add_development_dependency(%q<cucumber>, ["~> 0.10"])
84
75
  s.add_development_dependency(%q<fakefs>, ["~> 0.2"])
85
76
  s.add_development_dependency(%q<aruba>, ["~> 0.2"])
86
77
  s.add_development_dependency(%q<mocha>, ["~> 0.9"])
87
- s.add_development_dependency(%q<hashie>, ["~> 0.4"])
88
78
  s.add_development_dependency(%q<yard>, ["~> 0.6"])
89
- s.add_development_dependency(%q<scaffolder-test-helpers>, ["~> 0.1"])
79
+ s.add_development_dependency(%q<scaffolder-test-helpers>, ["~> 0.4"])
90
80
  else
91
81
  s.add_dependency(%q<configliere>, ["~> 0.1"])
92
82
  s.add_dependency(%q<bio>, ["~> 1.4"])
@@ -94,15 +84,13 @@ Gem::Specification.new do |s|
94
84
  s.add_dependency(%q<ronn>, ["~> 0.7"])
95
85
  s.add_dependency(%q<bundler>, ["~> 1.0"])
96
86
  s.add_dependency(%q<jeweler>, ["~> 1.5"])
97
- s.add_dependency(%q<gherkin>, ["~> 2.3.3"])
98
87
  s.add_dependency(%q<rspec>, ["~> 2.4"])
99
88
  s.add_dependency(%q<cucumber>, ["~> 0.10"])
100
89
  s.add_dependency(%q<fakefs>, ["~> 0.2"])
101
90
  s.add_dependency(%q<aruba>, ["~> 0.2"])
102
91
  s.add_dependency(%q<mocha>, ["~> 0.9"])
103
- s.add_dependency(%q<hashie>, ["~> 0.4"])
104
92
  s.add_dependency(%q<yard>, ["~> 0.6"])
105
- s.add_dependency(%q<scaffolder-test-helpers>, ["~> 0.1"])
93
+ s.add_dependency(%q<scaffolder-test-helpers>, ["~> 0.4"])
106
94
  end
107
95
  else
108
96
  s.add_dependency(%q<configliere>, ["~> 0.1"])
@@ -111,15 +99,13 @@ Gem::Specification.new do |s|
111
99
  s.add_dependency(%q<ronn>, ["~> 0.7"])
112
100
  s.add_dependency(%q<bundler>, ["~> 1.0"])
113
101
  s.add_dependency(%q<jeweler>, ["~> 1.5"])
114
- s.add_dependency(%q<gherkin>, ["~> 2.3.3"])
115
102
  s.add_dependency(%q<rspec>, ["~> 2.4"])
116
103
  s.add_dependency(%q<cucumber>, ["~> 0.10"])
117
104
  s.add_dependency(%q<fakefs>, ["~> 0.2"])
118
105
  s.add_dependency(%q<aruba>, ["~> 0.2"])
119
106
  s.add_dependency(%q<mocha>, ["~> 0.9"])
120
- s.add_dependency(%q<hashie>, ["~> 0.4"])
121
107
  s.add_dependency(%q<yard>, ["~> 0.6"])
122
- s.add_dependency(%q<scaffolder-test-helpers>, ["~> 0.1"])
108
+ s.add_dependency(%q<scaffolder-test-helpers>, ["~> 0.4"])
123
109
  end
124
110
  end
125
111
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__),'..','spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Scaffolder::BinaryHelper do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),'..','..','spec_helper'))
1
+ require 'spec_helper'
2
2
 
3
3
  describe Scaffolder::Tool::Help do
4
4
 
@@ -18,108 +18,98 @@ describe Scaffolder::Tool::Help do
18
18
  Commands:
19
19
  MSG
20
20
 
21
- before(:each) do
22
- @settings = Hash.new
23
- @settings.stubs(:rest).returns([])
24
- end
25
-
26
- describe "execution with no command and the version argument" do
21
+ describe "execution with" do
27
22
 
28
- subject do
29
- @settings[:version] = true
30
- @settings[:empty_args] = true
31
- described_class.new(@settings)
23
+ before(:each) do
24
+ @settings = Hash.new
25
+ @settings.stubs(:rest).returns([])
32
26
  end
33
27
 
34
- it "should not raise an error" do
35
- lambda{ subject.execute }.should_not raise_error
36
- end
28
+ describe "unknown command" do
37
29
 
38
- it "should return the version number" do
39
- version = File.read('VERSION').strip
40
- subject.execute.should == "scaffolder tool version " + version
41
- end
42
-
43
- end
30
+ subject do
31
+ @settings[:unknown_tool] = 'anything'
32
+ described_class.new(@settings)
33
+ end
44
34
 
45
- describe "execution with no command" do
35
+ it "should raise an error" do
36
+ lambda{ subject.execute }.should(raise_error(ArgumentError,
37
+ "Unknown command 'anything'.\nSee 'scaffolder help'."))
38
+ end
46
39
 
47
- subject do
48
- @settings[:empty_args] = true
49
- described_class.new(@settings)
50
40
  end
51
41
 
52
- it "should not raise an error" do
53
- lambda{ subject.execute }.should_not raise_error
54
- end
42
+ describe "no arguments" do
55
43
 
56
- it "should contain the usage information" do
57
- subject.execute.should include(USAGE)
58
- end
44
+ subject do
45
+ @settings[:empty_args] = true
46
+ described_class.new(@settings)
47
+ end
59
48
 
60
- it "should contain each tool information" do
61
- tool_subclasses.each do |cls|
62
- subject.execute.should include(cls.description)
49
+ it "should not raise an error" do
50
+ lambda{ subject.execute }.should_not raise_error
63
51
  end
64
- end
65
52
 
66
- end
53
+ it "should contain the usage information" do
54
+ subject.execute.should include(USAGE)
55
+ end
67
56
 
68
- describe "execution with an invalid command arguments" do
57
+ it "should contain each tool information" do
58
+ tool_subclasses.each do |cls|
59
+ subject.execute.should include(cls.description)
60
+ end
61
+ end
69
62
 
70
- subject do
71
- @settings[:unknown_tool] = 'unknown_command'
72
- described_class.new(@settings)
73
63
  end
74
64
 
75
- it "should raise an error" do
76
- lambda{ subject.execute }.should(raise_error(ArgumentError,
77
- "Unknown command 'unknown_command'.\nSee 'scaffolder help'."))
78
- end
65
+ describe "version argument" do
79
66
 
80
- end
67
+ subject do
68
+ @settings[:version] = true
69
+ @settings[:empty_args] = true
70
+ described_class.new(@settings)
71
+ end
81
72
 
82
- describe "execution with the name of a scaffolder tool command" do
73
+ it "should not raise an error" do
74
+ lambda{ subject.execute }.should_not raise_error
75
+ end
83
76
 
84
- before(:each) do
85
- @tool = Class.new(Scaffolder::Tool)
86
- described_class.superclass.const_set('Fake',@tool)
77
+ it "should return the version number" do
78
+ version = File.read('VERSION').strip
79
+ subject.execute.should == "scaffolder tool version " + version
80
+ end
87
81
 
88
- @man_dir = File.join(%W|#{File.dirname(__FILE__)} .. .. .. man| )
89
- @fake_man = File.join(@man_dir,'scaffolder-fake.1.ronn')
90
82
  end
91
83
 
92
- after(:each) do
93
- described_class.superclass.send(:remove_const,'Fake')
94
- end
84
+ describe "existing man page" do
95
85
 
96
- subject do
97
- @settings.stubs(:rest).returns(['fake'])
98
- described_class.new(@settings)
99
- end
86
+ before(:each) do
87
+ @tool = Class.new(Scaffolder::Tool)
88
+ described_class.superclass.const_set('Fake',@tool)
100
89
 
101
- it "should not raise an error" do
102
- Kernel.stubs(:system).with("ronn -m #{File.expand_path(@fake_man)}")
103
- lambda{ subject.execute }.should_not raise_error
104
- end
90
+ @man_dir = File.join(%W|#{File.dirname(__FILE__)} .. .. .. man| )
91
+ @fake_man = File.join(@man_dir,'scaffolder-fake.1.ronn')
92
+ end
105
93
 
106
- it "should call ronn on the command line with the man file location" do
107
- Kernel.expects(:system).with("ronn -m #{File.expand_path(@fake_man)}")
108
- subject.execute
109
- end
94
+ after(:each) do
95
+ described_class.superclass.send(:remove_const,'Fake')
96
+ end
110
97
 
111
- end
98
+ subject do
99
+ @settings.stubs(:rest).returns(['fake'])
100
+ described_class.new(@settings)
101
+ end
112
102
 
113
- describe "execution with the name of a unknown command" do
103
+ it "should not raise an error" do
104
+ Kernel.stubs(:system).with("ronn -m #{File.expand_path(@fake_man)}")
105
+ lambda{ subject.execute }.should_not raise_error
106
+ end
114
107
 
115
- subject do
116
- @settings.stubs(:rest).returns(['fake'])
117
- described_class.new(@settings)
118
- end
108
+ it "should call ronn on the command line with the man file location" do
109
+ Kernel.expects(:system).with("ronn -m #{File.expand_path(@fake_man)}")
110
+ subject.execute
111
+ end
119
112
 
120
- it "should raise an error" do
121
- lambda{ subject.execute }.should(raise_error(ArgumentError,
122
- "Unknown command 'fake'.\nSee 'scaffolder help'."))
123
113
  end
124
114
 
125
115
  end