genomer-plugin-summary 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/features/sequences.feature +246 -0
- data/lib/genomer-plugin-summary/gaps.rb +1 -1
- data/lib/genomer-plugin-summary/sequences.rb +95 -0
- data/spec/genomer-plugin-summary_spec/gaps_spec.rb +1 -15
- data/spec/genomer-plugin-summary_spec/sequences_spec.rb +235 -0
- data/spec/spec_helper.rb +16 -0
- metadata +9 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -0,0 +1,246 @@
|
|
1
|
+
Feature: Producing a summary of the scaffold sequences
|
2
|
+
In order to have an overview of the sequences in a scaffold
|
3
|
+
A user can use the "sequence" command
|
4
|
+
to generate the a tabular output of the scaffold sequences
|
5
|
+
|
6
|
+
@disable-bundler
|
7
|
+
Scenario: An empty scaffold
|
8
|
+
Given I create a new genomer project
|
9
|
+
And I write to "assembly/scaffold.yml" with:
|
10
|
+
"""
|
11
|
+
---
|
12
|
+
-
|
13
|
+
unresolved:
|
14
|
+
length: 50
|
15
|
+
"""
|
16
|
+
And I write to "assembly/sequence.fna" with:
|
17
|
+
"""
|
18
|
+
>contig0001
|
19
|
+
ATGC
|
20
|
+
"""
|
21
|
+
When I run `genomer summary sequences`
|
22
|
+
Then the exit status should be 0
|
23
|
+
And the output should contain:
|
24
|
+
"""
|
25
|
+
+------------------+------------+------------+------------+----------+--------+
|
26
|
+
| Scaffold Sequences |
|
27
|
+
+------------------+------------+------------+------------+----------+--------+
|
28
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
29
|
+
+------------------+------------+------------+------------+----------+--------+
|
30
|
+
+------------------+------------+------------+------------+----------+--------+
|
31
|
+
| All | NA | NA | NA | NA | NA |
|
32
|
+
+------------------+------------+------------+------------+----------+--------+
|
33
|
+
"""
|
34
|
+
|
35
|
+
Scenario: A scaffold with a single sequence
|
36
|
+
Given I create a new genomer project
|
37
|
+
And I write to "assembly/scaffold.yml" with:
|
38
|
+
"""
|
39
|
+
---
|
40
|
+
-
|
41
|
+
sequence:
|
42
|
+
source: contig0001
|
43
|
+
"""
|
44
|
+
And I write to "assembly/sequence.fna" with:
|
45
|
+
"""
|
46
|
+
>contig0001
|
47
|
+
ATGC
|
48
|
+
"""
|
49
|
+
When I run `genomer summary sequences`
|
50
|
+
Then the exit status should be 0
|
51
|
+
And the output should contain:
|
52
|
+
"""
|
53
|
+
+------------------+------------+------------+------------+----------+--------+
|
54
|
+
| Scaffold Sequences |
|
55
|
+
+------------------+------------+------------+------------+----------+--------+
|
56
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
57
|
+
+------------------+------------+------------+------------+----------+--------+
|
58
|
+
| contig0001 | 1 | 4 | 4 | 100.00 | 50.00 |
|
59
|
+
+------------------+------------+------------+------------+----------+--------+
|
60
|
+
| All | 1 | 4 | 4 | 100.00 | 50.00 |
|
61
|
+
+------------------+------------+------------+------------+----------+--------+
|
62
|
+
"""
|
63
|
+
|
64
|
+
Scenario: A scaffold with a two different sequences
|
65
|
+
Given I create a new genomer project
|
66
|
+
And I write to "assembly/scaffold.yml" with:
|
67
|
+
"""
|
68
|
+
---
|
69
|
+
-
|
70
|
+
sequence:
|
71
|
+
source: contig0001
|
72
|
+
-
|
73
|
+
sequence:
|
74
|
+
source: contig0002
|
75
|
+
"""
|
76
|
+
And I write to "assembly/sequence.fna" with:
|
77
|
+
"""
|
78
|
+
>contig0001
|
79
|
+
ATGCGC
|
80
|
+
>contig0002
|
81
|
+
ATATGC
|
82
|
+
"""
|
83
|
+
When I run `genomer summary sequences`
|
84
|
+
Then the exit status should be 0
|
85
|
+
And the output should contain:
|
86
|
+
"""
|
87
|
+
+------------------+------------+------------+------------+----------+--------+
|
88
|
+
| Scaffold Sequences |
|
89
|
+
+------------------+------------+------------+------------+----------+--------+
|
90
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
91
|
+
+------------------+------------+------------+------------+----------+--------+
|
92
|
+
| contig0001 | 1 | 6 | 6 | 50.00 | 66.67 |
|
93
|
+
| contig0002 | 7 | 12 | 6 | 50.00 | 33.33 |
|
94
|
+
+------------------+------------+------------+------------+----------+--------+
|
95
|
+
| All | 1 | 12 | 12 | 100.00 | 50.00 |
|
96
|
+
+------------------+------------+------------+------------+----------+--------+
|
97
|
+
"""
|
98
|
+
|
99
|
+
Scenario: A scaffold with a two repeated sequences
|
100
|
+
Given I create a new genomer project
|
101
|
+
And I write to "assembly/scaffold.yml" with:
|
102
|
+
"""
|
103
|
+
---
|
104
|
+
-
|
105
|
+
sequence:
|
106
|
+
source: contig0001
|
107
|
+
-
|
108
|
+
sequence:
|
109
|
+
source: contig0001
|
110
|
+
"""
|
111
|
+
And I write to "assembly/sequence.fna" with:
|
112
|
+
"""
|
113
|
+
>contig0001
|
114
|
+
ATGCGC
|
115
|
+
"""
|
116
|
+
When I run `genomer summary sequences`
|
117
|
+
Then the exit status should be 0
|
118
|
+
And the output should contain:
|
119
|
+
"""
|
120
|
+
+------------------+------------+------------+------------+----------+--------+
|
121
|
+
| Scaffold Sequences |
|
122
|
+
+------------------+------------+------------+------------+----------+--------+
|
123
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
124
|
+
+------------------+------------+------------+------------+----------+--------+
|
125
|
+
| contig0001 | 1 | 6 | 6 | 50.00 | 66.67 |
|
126
|
+
| contig0001 | 7 | 12 | 6 | 50.00 | 66.67 |
|
127
|
+
+------------------+------------+------------+------------+----------+--------+
|
128
|
+
| All | 1 | 12 | 12 | 100.00 | 66.67 |
|
129
|
+
+------------------+------------+------------+------------+----------+--------+
|
130
|
+
"""
|
131
|
+
|
132
|
+
Scenario: A scaffold with a two sequences separated by a gap
|
133
|
+
Given I create a new genomer project
|
134
|
+
And I write to "assembly/scaffold.yml" with:
|
135
|
+
"""
|
136
|
+
---
|
137
|
+
-
|
138
|
+
sequence:
|
139
|
+
source: contig0001
|
140
|
+
-
|
141
|
+
unresolved:
|
142
|
+
length: 8
|
143
|
+
-
|
144
|
+
sequence:
|
145
|
+
source: contig0002
|
146
|
+
"""
|
147
|
+
And I write to "assembly/sequence.fna" with:
|
148
|
+
"""
|
149
|
+
>contig0001
|
150
|
+
ATGCGC
|
151
|
+
>contig0002
|
152
|
+
ATATGC
|
153
|
+
"""
|
154
|
+
When I run `genomer summary sequences`
|
155
|
+
Then the exit status should be 0
|
156
|
+
And the output should contain:
|
157
|
+
"""
|
158
|
+
+------------------+------------+------------+------------+----------+--------+
|
159
|
+
| Scaffold Sequences |
|
160
|
+
+------------------+------------+------------+------------+----------+--------+
|
161
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
162
|
+
+------------------+------------+------------+------------+----------+--------+
|
163
|
+
| contig0001 | 1 | 6 | 6 | 30.00 | 66.67 |
|
164
|
+
| contig0002 | 15 | 20 | 6 | 30.00 | 33.33 |
|
165
|
+
+------------------+------------+------------+------------+----------+--------+
|
166
|
+
| All | 1 | 20 | 12 | 60.00 | 50.00 |
|
167
|
+
+------------------+------------+------------+------------+----------+--------+
|
168
|
+
"""
|
169
|
+
|
170
|
+
Scenario: A scaffold with a two sequences and a gap at the start
|
171
|
+
Given I create a new genomer project
|
172
|
+
And I write to "assembly/scaffold.yml" with:
|
173
|
+
"""
|
174
|
+
---
|
175
|
+
-
|
176
|
+
unresolved:
|
177
|
+
length: 8
|
178
|
+
-
|
179
|
+
sequence:
|
180
|
+
source: contig0001
|
181
|
+
-
|
182
|
+
sequence:
|
183
|
+
source: contig0002
|
184
|
+
"""
|
185
|
+
And I write to "assembly/sequence.fna" with:
|
186
|
+
"""
|
187
|
+
>contig0001
|
188
|
+
ATGCGC
|
189
|
+
>contig0002
|
190
|
+
ATATGC
|
191
|
+
"""
|
192
|
+
When I run `genomer summary sequences`
|
193
|
+
Then the exit status should be 0
|
194
|
+
And the output should contain:
|
195
|
+
"""
|
196
|
+
+------------------+------------+------------+------------+----------+--------+
|
197
|
+
| Scaffold Sequences |
|
198
|
+
+------------------+------------+------------+------------+----------+--------+
|
199
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
200
|
+
+------------------+------------+------------+------------+----------+--------+
|
201
|
+
| contig0001 | 9 | 14 | 6 | 30.00 | 66.67 |
|
202
|
+
| contig0002 | 15 | 20 | 6 | 30.00 | 33.33 |
|
203
|
+
+------------------+------------+------------+------------+----------+--------+
|
204
|
+
| All | 9 | 20 | 12 | 60.00 | 50.00 |
|
205
|
+
+------------------+------------+------------+------------+----------+--------+
|
206
|
+
"""
|
207
|
+
|
208
|
+
|
209
|
+
Scenario: A scaffold with a two sequences and a gap at the end
|
210
|
+
Given I create a new genomer project
|
211
|
+
And I write to "assembly/scaffold.yml" with:
|
212
|
+
"""
|
213
|
+
---
|
214
|
+
-
|
215
|
+
sequence:
|
216
|
+
source: contig0001
|
217
|
+
-
|
218
|
+
sequence:
|
219
|
+
source: contig0002
|
220
|
+
-
|
221
|
+
unresolved:
|
222
|
+
length: 8
|
223
|
+
"""
|
224
|
+
And I write to "assembly/sequence.fna" with:
|
225
|
+
"""
|
226
|
+
>contig0001
|
227
|
+
ATGCGC
|
228
|
+
>contig0002
|
229
|
+
ATATGC
|
230
|
+
"""
|
231
|
+
When I run `genomer summary sequences`
|
232
|
+
Then the exit status should be 0
|
233
|
+
And the output should contain:
|
234
|
+
"""
|
235
|
+
+------------------+------------+------------+------------+----------+--------+
|
236
|
+
| Scaffold Sequences |
|
237
|
+
+------------------+------------+------------+------------+----------+--------+
|
238
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
239
|
+
+------------------+------------+------------+------------+----------+--------+
|
240
|
+
| contig0001 | 1 | 6 | 6 | 30.00 | 66.67 |
|
241
|
+
| contig0002 | 7 | 12 | 6 | 30.00 | 33.33 |
|
242
|
+
+------------------+------------+------------+------------+----------+--------+
|
243
|
+
| All | 1 | 12 | 12 | 60.00 | 50.00 |
|
244
|
+
+------------------+------------+------------+------------+----------+--------+
|
245
|
+
"""
|
246
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'genomer'
|
2
|
+
require 'terminal-table'
|
3
|
+
|
4
|
+
class GenomerPluginSummary::Sequences < Genomer::Plugin
|
5
|
+
|
6
|
+
def run
|
7
|
+
sequences = calculate(scaffold)
|
8
|
+
total = total(sequences)
|
9
|
+
|
10
|
+
tabulate(sequences,total)
|
11
|
+
end
|
12
|
+
|
13
|
+
def headings
|
14
|
+
['Sequence'.left(16),
|
15
|
+
'Start (bp)'.center(10),
|
16
|
+
'End (bp)'.center(10),
|
17
|
+
'Size (bp)'.center(10),
|
18
|
+
'Size (%)'.center(8),
|
19
|
+
'GC (%)'.center(6)]
|
20
|
+
end
|
21
|
+
|
22
|
+
def title
|
23
|
+
'Scaffold Sequences'
|
24
|
+
end
|
25
|
+
|
26
|
+
def tabulate(rows,total)
|
27
|
+
table = Terminal::Table.new(:title => title) do |t|
|
28
|
+
t << headings
|
29
|
+
t << :separator
|
30
|
+
rows.each do |row|
|
31
|
+
t << table_array(row)
|
32
|
+
end
|
33
|
+
t << :separator
|
34
|
+
t << table_array(total.merge({:sequence => 'All'}))
|
35
|
+
end
|
36
|
+
|
37
|
+
table.align_column 0, :left
|
38
|
+
table.align_column 1, :right
|
39
|
+
table.align_column 2, :right
|
40
|
+
table.align_column 3, :right
|
41
|
+
table.align_column 4, :right
|
42
|
+
table.align_column 5, :right
|
43
|
+
|
44
|
+
table.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def table_array(hash)
|
48
|
+
[:sequence,:start,:end,:size,:percent,:gc].
|
49
|
+
map{|i| hash[i]}.
|
50
|
+
map{|i| i.class == Float ? sprintf('%#.2f',i) : i }
|
51
|
+
end
|
52
|
+
|
53
|
+
def calculate(scaffold)
|
54
|
+
total_length = scaffold.map(&:sequence).join.length.to_f
|
55
|
+
|
56
|
+
length = 0
|
57
|
+
scaffold.map do |entry|
|
58
|
+
i = nil
|
59
|
+
if entry.entry_type != :unresolved
|
60
|
+
entry_length = entry.sequence.length
|
61
|
+
i = { :sequence => entry.source,
|
62
|
+
:start => length + 1,
|
63
|
+
:end => length + entry_length,
|
64
|
+
:size => entry_length,
|
65
|
+
:percent => entry_length / total_length * 100,
|
66
|
+
:gc => gc_content(entry.sequence) }
|
67
|
+
end
|
68
|
+
|
69
|
+
length += entry.sequence.length
|
70
|
+
i
|
71
|
+
end.compact
|
72
|
+
end
|
73
|
+
|
74
|
+
def total(seqs)
|
75
|
+
return Hash[[:start, :end, :size, :percent, :gc].map{|i| [i, 'NA']}] if seqs.empty?
|
76
|
+
|
77
|
+
totals = seqs.inject({:size => 0, :percent => 0, :gc => 0}) do |hash,entry|
|
78
|
+
hash[:start] ||= entry[:start]
|
79
|
+
hash[:end] = entry[:end]
|
80
|
+
hash[:size] += entry[:size]
|
81
|
+
hash[:percent] += entry[:percent]
|
82
|
+
hash[:gc] += entry[:gc] * entry[:size]
|
83
|
+
|
84
|
+
hash
|
85
|
+
end
|
86
|
+
totals[:gc] /= totals[:size]
|
87
|
+
totals
|
88
|
+
end
|
89
|
+
|
90
|
+
def gc_content(sequence)
|
91
|
+
nucleotides = sequence.gsub(/[^ATGCatgc]/,'')
|
92
|
+
nucleotides.gsub(/[^GCgc]/,'').length.to_f / nucleotides.length * 100
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -6,7 +6,7 @@ describe GenomerPluginSummary::Gaps do
|
|
6
6
|
describe "#tabulate" do
|
7
7
|
|
8
8
|
subject do
|
9
|
-
described_class.new([],{}).tabulate(contigs)
|
9
|
+
described_class.new([],{}).tabulate(contigs) + "\n"
|
10
10
|
end
|
11
11
|
|
12
12
|
context "passed an empty array" do
|
@@ -74,20 +74,6 @@ describe GenomerPluginSummary::Gaps do
|
|
74
74
|
|
75
75
|
describe "#determine_gaps" do
|
76
76
|
|
77
|
-
def sequence(seq)
|
78
|
-
s = mock!
|
79
|
-
stub(s).sequence{ seq }
|
80
|
-
stub(s).entry_type{ :sequence }
|
81
|
-
s
|
82
|
-
end
|
83
|
-
|
84
|
-
def unresolved(seq)
|
85
|
-
s = mock!
|
86
|
-
stub(s).sequence{ seq }
|
87
|
-
stub(s).entry_type{ :unresolved }
|
88
|
-
s
|
89
|
-
end
|
90
|
-
|
91
77
|
subject do
|
92
78
|
described_class.new([],{}).determine_gaps(scaffold)
|
93
79
|
end
|
@@ -0,0 +1,235 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'genomer-plugin-summary/sequences'
|
3
|
+
|
4
|
+
describe GenomerPluginSummary::Sequences do
|
5
|
+
|
6
|
+
def row(name,start,stop,percent,gc)
|
7
|
+
{:sequence => name,
|
8
|
+
:start => start,
|
9
|
+
:end => stop,
|
10
|
+
:size => (stop - start) + 1,
|
11
|
+
:percent => percent,
|
12
|
+
:gc => gc}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#tabulate" do
|
16
|
+
|
17
|
+
subject do
|
18
|
+
described_class.new([],{}).tabulate(sequences,total) + "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
context "passed an empty array" do
|
22
|
+
|
23
|
+
let(:sequences) do
|
24
|
+
[]
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:total) do
|
28
|
+
{:start => 'NA',
|
29
|
+
:end => 'NA',
|
30
|
+
:size => 'NA',
|
31
|
+
:percent => 'NA',
|
32
|
+
:gc => 'NA' }
|
33
|
+
end
|
34
|
+
|
35
|
+
it do
|
36
|
+
should ==<<-EOS.unindent!
|
37
|
+
+------------------+------------+------------+------------+----------+--------+
|
38
|
+
| Scaffold Sequences |
|
39
|
+
+------------------+------------+------------+------------+----------+--------+
|
40
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
41
|
+
+------------------+------------+------------+------------+----------+--------+
|
42
|
+
+------------------+------------+------------+------------+----------+--------+
|
43
|
+
| All | NA | NA | NA | NA | NA |
|
44
|
+
+------------------+------------+------------+------------+----------+--------+
|
45
|
+
EOS
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
context "passed an array with a single row" do
|
51
|
+
|
52
|
+
let(:sequences) do
|
53
|
+
[{:sequence => 'contig1',
|
54
|
+
:start => '1',
|
55
|
+
:end => '4',
|
56
|
+
:size => '4',
|
57
|
+
:percent => 100.0,
|
58
|
+
:gc => 50.0 }]
|
59
|
+
end
|
60
|
+
|
61
|
+
let(:total) do
|
62
|
+
{:start => '1',
|
63
|
+
:end => '4',
|
64
|
+
:size => '4',
|
65
|
+
:percent => 100.0,
|
66
|
+
:gc => 50.0 }
|
67
|
+
end
|
68
|
+
|
69
|
+
it do
|
70
|
+
should ==<<-EOS.unindent!
|
71
|
+
+------------------+------------+------------+------------+----------+--------+
|
72
|
+
| Scaffold Sequences |
|
73
|
+
+------------------+------------+------------+------------+----------+--------+
|
74
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
75
|
+
+------------------+------------+------------+------------+----------+--------+
|
76
|
+
| contig1 | 1 | 4 | 4 | 100.00 | 50.00 |
|
77
|
+
+------------------+------------+------------+------------+----------+--------+
|
78
|
+
| All | 1 | 4 | 4 | 100.00 | 50.00 |
|
79
|
+
+------------------+------------+------------+------------+----------+--------+
|
80
|
+
EOS
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
context "passed a array with two rows" do
|
86
|
+
|
87
|
+
let(:sequences) do
|
88
|
+
[{:sequence => 'contig1',
|
89
|
+
:start => '1',
|
90
|
+
:end => '4',
|
91
|
+
:size => '4',
|
92
|
+
:percent => 100.0,
|
93
|
+
:gc => 50.0 },
|
94
|
+
{:sequence => 'contig2',
|
95
|
+
:start => '1',
|
96
|
+
:end => '4',
|
97
|
+
:size => '4',
|
98
|
+
:percent => 100.0,
|
99
|
+
:gc => 50.0 }]
|
100
|
+
end
|
101
|
+
|
102
|
+
let(:total) do
|
103
|
+
{:start => '1',
|
104
|
+
:end => '4',
|
105
|
+
:size => '4',
|
106
|
+
:percent => 100.0,
|
107
|
+
:gc => 50.0 }
|
108
|
+
end
|
109
|
+
|
110
|
+
it do
|
111
|
+
should ==<<-EOS.unindent!
|
112
|
+
+------------------+------------+------------+------------+----------+--------+
|
113
|
+
| Scaffold Sequences |
|
114
|
+
+------------------+------------+------------+------------+----------+--------+
|
115
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
116
|
+
+------------------+------------+------------+------------+----------+--------+
|
117
|
+
| contig1 | 1 | 4 | 4 | 100.00 | 50.00 |
|
118
|
+
| contig2 | 1 | 4 | 4 | 100.00 | 50.00 |
|
119
|
+
+------------------+------------+------------+------------+----------+--------+
|
120
|
+
| All | 1 | 4 | 4 | 100.00 | 50.00 |
|
121
|
+
+------------------+------------+------------+------------+----------+--------+
|
122
|
+
EOS
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#calculate" do
|
130
|
+
|
131
|
+
subject do
|
132
|
+
described_class.new([],{}).calculate(scaffold)
|
133
|
+
end
|
134
|
+
|
135
|
+
context "passed an empty array" do
|
136
|
+
let(:scaffold) do
|
137
|
+
[]
|
138
|
+
end
|
139
|
+
|
140
|
+
it do
|
141
|
+
should == []
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "passed one sequence" do
|
146
|
+
let(:scaffold) do
|
147
|
+
[sequence('AAAGGG','contig1')]
|
148
|
+
end
|
149
|
+
|
150
|
+
it do
|
151
|
+
should == [row('contig1',1,6,100.0,50.0)]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context "passed two sequences" do
|
156
|
+
let(:scaffold) do
|
157
|
+
[sequence('AAAGGG','contig1'),
|
158
|
+
sequence('AAAGGG','contig2')]
|
159
|
+
end
|
160
|
+
|
161
|
+
it do
|
162
|
+
should == [row('contig1', 1, 6, 50.0, 50.0),
|
163
|
+
row('contig2', 7, 12, 50.0, 50.0)]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context "passed two sequences separated by a gap" do
|
168
|
+
let(:scaffold) do
|
169
|
+
[sequence('AAAGGG','contig1'),
|
170
|
+
unresolved('NNNNNNNN'),
|
171
|
+
sequence('AAAGGG','contig2')]
|
172
|
+
end
|
173
|
+
|
174
|
+
it do
|
175
|
+
should == [row('contig1', 1, 6, 30.0, 50.0),
|
176
|
+
row('contig2', 15, 20, 30.0, 50.0)]
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "#total" do
|
183
|
+
|
184
|
+
subject do
|
185
|
+
described_class.new([],{}).total(sequences)
|
186
|
+
end
|
187
|
+
|
188
|
+
context "passed an empty array" do
|
189
|
+
let(:sequences) do
|
190
|
+
[]
|
191
|
+
end
|
192
|
+
|
193
|
+
it do
|
194
|
+
should == {
|
195
|
+
:start => 'NA',
|
196
|
+
:end => 'NA',
|
197
|
+
:size => 'NA',
|
198
|
+
:percent => 'NA',
|
199
|
+
:gc => 'NA' }
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context "passed one entry" do
|
204
|
+
let(:sequences) do
|
205
|
+
[row('contig1',1,6,100.0,50.0)]
|
206
|
+
end
|
207
|
+
|
208
|
+
it do
|
209
|
+
should == {
|
210
|
+
:start => 1,
|
211
|
+
:end => 6,
|
212
|
+
:size => 6,
|
213
|
+
:percent => 100.0,
|
214
|
+
:gc => 50.0 }
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context "passed two entries less than 100% of the scaffold" do
|
219
|
+
let(:sequences) do
|
220
|
+
[row('contig1', 1, 6, 30.0, 50.0),
|
221
|
+
row('contig2', 15, 20, 30.0, 50.0)]
|
222
|
+
end
|
223
|
+
|
224
|
+
it do
|
225
|
+
should == {
|
226
|
+
:start => 1,
|
227
|
+
:end => 20,
|
228
|
+
:size => 12,
|
229
|
+
:percent => 60.0,
|
230
|
+
:gc => 50.0 }
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,4 +12,20 @@ end
|
|
12
12
|
|
13
13
|
RSpec.configure do |config|
|
14
14
|
config.mock_with :rr
|
15
|
+
|
16
|
+
def sequence(seq, source=nil)
|
17
|
+
s = mock!
|
18
|
+
stub(s).sequence{ seq }
|
19
|
+
stub(s).source{ source } if source
|
20
|
+
stub(s).entry_type{ :sequence }
|
21
|
+
s
|
22
|
+
end
|
23
|
+
|
24
|
+
def unresolved(seq)
|
25
|
+
s = mock!
|
26
|
+
stub(s).sequence{ seq }
|
27
|
+
stub(s).entry_type{ :unresolved }
|
28
|
+
s
|
29
|
+
end
|
30
|
+
|
15
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genomer-plugin-summary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-
|
12
|
+
date: 2012-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: genomer
|
@@ -153,15 +153,18 @@ files:
|
|
153
153
|
- Rakefile
|
154
154
|
- VERSION
|
155
155
|
- features/gaps.feature
|
156
|
+
- features/sequences.feature
|
156
157
|
- features/support/env.rb
|
157
158
|
- features/support/genomer_steps.rb
|
158
159
|
- genomer-plugin-summary.gemspec
|
159
160
|
- lib/genomer-plugin-summary.rb
|
160
161
|
- lib/genomer-plugin-summary/gaps.rb
|
162
|
+
- lib/genomer-plugin-summary/sequences.rb
|
161
163
|
- man/genomer-summary-gaps.ronn
|
162
164
|
- man/genomer-summary.ronn
|
163
165
|
- spec/genomer-plugin-summary_spec.rb
|
164
166
|
- spec/genomer-plugin-summary_spec/gaps_spec.rb
|
167
|
+
- spec/genomer-plugin-summary_spec/sequences_spec.rb
|
165
168
|
- spec/spec_helper.rb
|
166
169
|
homepage: ''
|
167
170
|
licenses: []
|
@@ -177,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
180
|
version: '0'
|
178
181
|
segments:
|
179
182
|
- 0
|
180
|
-
hash:
|
183
|
+
hash: 1551182150525719363
|
181
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
185
|
none: false
|
183
186
|
requirements:
|
@@ -186,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
189
|
version: '0'
|
187
190
|
segments:
|
188
191
|
- 0
|
189
|
-
hash:
|
192
|
+
hash: 1551182150525719363
|
190
193
|
requirements: []
|
191
194
|
rubyforge_project:
|
192
195
|
rubygems_version: 1.8.23
|
@@ -195,8 +198,10 @@ specification_version: 3
|
|
195
198
|
summary: Generates reports on the status of the genomer project
|
196
199
|
test_files:
|
197
200
|
- features/gaps.feature
|
201
|
+
- features/sequences.feature
|
198
202
|
- features/support/env.rb
|
199
203
|
- features/support/genomer_steps.rb
|
200
204
|
- spec/genomer-plugin-summary_spec.rb
|
201
205
|
- spec/genomer-plugin-summary_spec/gaps_spec.rb
|
206
|
+
- spec/genomer-plugin-summary_spec/sequences_spec.rb
|
202
207
|
- spec/spec_helper.rb
|