genomer-plugin-view 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,217 @@
1
+ Feature: Producing a gff3 view of a scaffold's annotations
2
+ In order to view scaffold annotations
3
+ A user can use the "gff" command
4
+ to generate gff3 view of scaffold annotations
5
+
6
+ @disable-bundler
7
+ Scenario: A single annotation on a single contig
8
+ Given I successfully run `genomer init project`
9
+ And I cd to "project"
10
+ And I write to "assembly/scaffold.yml" with:
11
+ """
12
+ ---
13
+ - sequence:
14
+ source: contig1
15
+ """
16
+ And I write to "assembly/sequence.fna" with:
17
+ """
18
+ >contig1
19
+ AAAAATTTTTGGGGGCCCCC
20
+ """
21
+ And I write to "assembly/annotations.gff" with:
22
+ """
23
+ ##gff-version 3
24
+ contig1 . gene 1 3 . + 1 .
25
+ """
26
+ And I append to "Gemfile" with:
27
+ """
28
+ gem 'genomer-plugin-view', :path => '../../../'
29
+ """
30
+ When I run `genomer view gff --identifier=genome`
31
+ Then the exit status should be 0
32
+ And the output should contain:
33
+ """
34
+ ##gff-version 3
35
+ genome . gene 1 3 . + 1 .
36
+
37
+ """
38
+
39
+ @disable-bundler
40
+ Scenario: Two annotations on a single contig
41
+ Given I successfully run `genomer init project`
42
+ And I cd to "project"
43
+ And I write to "assembly/scaffold.yml" with:
44
+ """
45
+ ---
46
+ - sequence:
47
+ source: contig1
48
+ """
49
+ And I write to "assembly/sequence.fna" with:
50
+ """
51
+ >contig1
52
+ AAAAATTTTTGGGGGCCCCC
53
+ """
54
+ And I write to "assembly/annotations.gff" with:
55
+ """
56
+ ##gff-version 3
57
+ contig1 . gene 1 3 . + 1 .
58
+ contig1 . gene 4 6 . + 1 .
59
+ """
60
+ And I append to "Gemfile" with:
61
+ """
62
+ gem 'genomer-plugin-view', :path => '../../../'
63
+ """
64
+ When I run `genomer view gff --identifier=genome`
65
+ Then the exit status should be 0
66
+ And the output should contain:
67
+ """
68
+ ##gff-version 3
69
+ genome . gene 1 3 . + 1 .
70
+ genome . gene 4 6 . + 1 .
71
+
72
+ """
73
+
74
+ @disable-bundler
75
+ Scenario: Reseting locus tag numbering at the scaffold origin
76
+ Given I successfully run `genomer init project`
77
+ And I cd to "project"
78
+ And I write to "assembly/scaffold.yml" with:
79
+ """
80
+ ---
81
+ - sequence:
82
+ source: contig1
83
+ """
84
+ And I write to "assembly/sequence.fna" with:
85
+ """
86
+ >contig1
87
+ AAAAATTTTTGGGGGCCCCC
88
+ """
89
+ And I write to "assembly/annotations.gff" with:
90
+ """
91
+ ##gff-version 3
92
+ contig1 . gene 1 3 . + 1 ID=gene1
93
+ contig1 . gene 4 6 . + 1 ID=gene2
94
+ """
95
+ And I append to "Gemfile" with:
96
+ """
97
+ gem 'genomer-plugin-view', :path => '../../../'
98
+ """
99
+ When I run `genomer view gff --identifier=genome --reset_locus_numbering`
100
+ Then the exit status should be 0
101
+ And the output should contain:
102
+ """
103
+ ##gff-version 3
104
+ genome . gene 1 3 . + 1 ID=000001
105
+ genome . gene 4 6 . + 1 ID=000002
106
+
107
+ """
108
+ @disable-bundler
109
+ Scenario: Reseting locus tag numbering at specified start value
110
+ Given I successfully run `genomer init project`
111
+ And I cd to "project"
112
+ And I write to "assembly/scaffold.yml" with:
113
+ """
114
+ ---
115
+ - sequence:
116
+ source: contig1
117
+ """
118
+ And I write to "assembly/sequence.fna" with:
119
+ """
120
+ >contig1
121
+ AAAAATTTTTGGGGGCCCCC
122
+ """
123
+ And I write to "assembly/annotations.gff" with:
124
+ """
125
+ ##gff-version 3
126
+ contig1 . gene 1 3 . + 1 ID=gene1
127
+ contig1 . gene 4 6 . + 1 ID=gene2
128
+ """
129
+ And I append to "Gemfile" with:
130
+ """
131
+ gem 'genomer-plugin-view', :path => '../../../'
132
+ """
133
+ When I run `genomer view gff --identifier=genome --reset_locus_numbering=5`
134
+ Then the exit status should be 0
135
+ And the output should contain:
136
+ """
137
+ ##gff-version 3
138
+ genome . gene 1 3 . + 1 ID=000005
139
+ genome . gene 4 6 . + 1 ID=000006
140
+
141
+ """
142
+
143
+ @disable-bundler
144
+ Scenario: Reseting locus tag at the scaffold origin with unordered annotations
145
+ Given I successfully run `genomer init project`
146
+ And I cd to "project"
147
+ And I write to "assembly/scaffold.yml" with:
148
+ """
149
+ ---
150
+ - sequence:
151
+ source: contig1
152
+ """
153
+ And I write to "assembly/sequence.fna" with:
154
+ """
155
+ >contig1
156
+ AAAAATTTTTGGGGGCCCCC
157
+ """
158
+ And I write to "assembly/annotations.gff" with:
159
+ """
160
+ ##gff-version 3
161
+ contig1 . gene 10 12 . + 1 ID=gene4
162
+ contig1 . gene 4 6 . + 1 ID=gene2
163
+ contig1 . gene 1 3 . + 1 ID=gene1
164
+ contig1 . gene 7 9 . + 1 ID=gene3
165
+ """
166
+ And I append to "Gemfile" with:
167
+ """
168
+ gem 'genomer-plugin-view', :path => '../../../'
169
+ """
170
+ When I run `genomer view gff --identifier=genome --reset_locus_numbering`
171
+ Then the exit status should be 0
172
+ And the output should contain:
173
+ """
174
+ ##gff-version 3
175
+ genome . gene 1 3 . + 1 ID=000001
176
+ genome . gene 4 6 . + 1 ID=000002
177
+ genome . gene 7 9 . + 1 ID=000003
178
+ genome . gene 10 12 . + 1 ID=000004
179
+
180
+ """
181
+
182
+ @disable-bundler
183
+ Scenario: Adding a prefix to annotation locus tags
184
+ Given I successfully run `genomer init project`
185
+ And I cd to "project"
186
+ And I write to "assembly/scaffold.yml" with:
187
+ """
188
+ ---
189
+ - sequence:
190
+ source: contig1
191
+ """
192
+ And I write to "assembly/sequence.fna" with:
193
+ """
194
+ >contig1
195
+ AAAAATTTTTGGGGGCCCCC
196
+ """
197
+ And I write to "assembly/annotations.gff" with:
198
+ """
199
+ ##gff-version 3
200
+ contig1 . gene 1 3 . + 1 ID=gene1
201
+ contig1 . gene 4 6 . + 1 ID=gene2
202
+ """
203
+ And I append to "Gemfile" with:
204
+ """
205
+ gem 'genomer-plugin-view', :path => '../../../'
206
+ """
207
+ When I run `genomer view gff --identifier=genome --prefix=pre_`
208
+ Then the exit status should be 0
209
+ And the output should contain:
210
+ """
211
+ ##gff-version 3
212
+ genome . gene 1 3 . + 1 ID=pre_gene1
213
+ genome . gene 4 6 . + 1 ID=pre_gene2
214
+
215
+ """
216
+
217
+
@@ -0,0 +1,17 @@
1
+ require 'genomer'
2
+
3
+ class GenomerPluginView::Gff < Genomer::Plugin
4
+
5
+ DEFAULT = '.'
6
+
7
+ def run
8
+ options = GenomerPluginView.convert_command_line_flags(flags)
9
+ annotations(options).
10
+ map{|i| i.seqname = options[:identifier] || DEFAULT; i}.
11
+ map(&:to_s).
12
+ map(&:strip).
13
+ unshift("##gff-version 3").
14
+ join("\n") + "\n"
15
+ end
16
+
17
+ end
@@ -1,3 +1,3 @@
1
1
  class GenomerViewPlugin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+ require 'genomer-plugin-view/gff'
3
+
4
+ describe GenomerPluginView::Gff do
5
+
6
+ describe "#run" do
7
+
8
+ let(:annotations){ [] }
9
+
10
+ let(:flags){ {} }
11
+
12
+ before(:each) do
13
+ stub(subject).annotations do
14
+ annotations
15
+ end
16
+ stub(subject).flags do
17
+ flags
18
+ end
19
+ end
20
+
21
+ subject do
22
+ described_class.new([],{})
23
+ end
24
+
25
+ describe "with no annotations or flags" do
26
+
27
+ it "should return the header line" do
28
+ subject.run.should == "##gff-version 3\n"
29
+ end
30
+
31
+ end
32
+
33
+ describe "with one gene annotation" do
34
+
35
+ let(:annotations){ [gene] }
36
+
37
+ it "should return a single gene gff entry " do
38
+ subject.run.should == <<-EOS.unindent
39
+ ##gff-version 3
40
+ .\t.\tgene\t1\t3\t.\t+\t1\t.
41
+ EOS
42
+ end
43
+
44
+ end
45
+
46
+ describe "with two gene annotations" do
47
+
48
+ let(:annotations) do
49
+ [
50
+ gene,
51
+ gene(:start => 4, :end => 6)
52
+ ]
53
+ end
54
+
55
+ it "should return a single gene gff entry " do
56
+ subject.run.should == <<-EOS.unindent
57
+ ##gff-version 3
58
+ .\t.\tgene\t1\t3\t.\t+\t1\t.
59
+ .\t.\tgene\t4\t6\t.\t+\t1\t.
60
+ EOS
61
+ end
62
+
63
+ end
64
+
65
+ describe "with the identifier flag" do
66
+
67
+ let(:flags){ {:identifier => 'genome'} }
68
+
69
+ let(:annotations){ [gene] }
70
+
71
+ it "should return a single gene gff entry " do
72
+ subject.run.should == <<-EOS.unindent
73
+ ##gff-version 3
74
+ genome\t.\tgene\t1\t3\t.\t+\t1\t.
75
+ EOS
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+
82
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genomer-plugin-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-28 00:00:00.000000000 Z
12
+ date: 2012-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: genomer
@@ -139,6 +139,7 @@ files:
139
139
  - features/agp/generation.feature
140
140
  - features/fasta/contigs.feature
141
141
  - features/fasta/single_sequence.feature
142
+ - features/gff/core.feature
142
143
  - features/mappings/core.feature
143
144
  - features/support/env.rb
144
145
  - features/table/cds_entries.feature
@@ -148,6 +149,7 @@ files:
148
149
  - lib/genomer-plugin-view.rb
149
150
  - lib/genomer-plugin-view/agp.rb
150
151
  - lib/genomer-plugin-view/fasta.rb
152
+ - lib/genomer-plugin-view/gff.rb
151
153
  - lib/genomer-plugin-view/gff_record_helper.rb
152
154
  - lib/genomer-plugin-view/mapping.rb
153
155
  - lib/genomer-plugin-view/table.rb
@@ -157,6 +159,7 @@ files:
157
159
  - spec/genomer-view-plugin/agp_spec.rb
158
160
  - spec/genomer-view-plugin/fasta_spec.rb
159
161
  - spec/genomer-view-plugin/gff_record_helper_spec.rb
162
+ - spec/genomer-view-plugin/gff_spec.rb
160
163
  - spec/genomer-view-plugin/mapping_spec.rb
161
164
  - spec/genomer-view-plugin/table_spec.rb
162
165
  - spec/genomer-view-plugin_spec.rb
@@ -176,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
179
  version: '0'
177
180
  segments:
178
181
  - 0
179
- hash: 3613905158544904544
182
+ hash: -3689932046879280024
180
183
  required_rubygems_version: !ruby/object:Gem::Requirement
181
184
  none: false
182
185
  requirements: