genomer-plugin-summary 0.0.3 → 0.0.4
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.
- data/VERSION +1 -1
- data/features/contigs.feature +347 -0
- data/features/gaps.feature +34 -0
- data/features/genome.feature +213 -0
- data/features/sequences.feature +39 -8
- data/lib/genomer-plugin-summary/contigs.rb +63 -0
- data/lib/genomer-plugin-summary/enumerators.rb +81 -0
- data/lib/genomer-plugin-summary/format.rb +87 -0
- data/lib/genomer-plugin-summary/gaps.rb +25 -33
- data/lib/genomer-plugin-summary/genome.rb +51 -0
- data/lib/genomer-plugin-summary/metrics.rb +23 -9
- data/lib/genomer-plugin-summary/sequences.rb +44 -70
- data/spec/genomer-plugin-summary_spec/contigs_spec.rb +211 -0
- data/spec/genomer-plugin-summary_spec/enumerators_spec.rb +383 -0
- data/spec/genomer-plugin-summary_spec/format_spec.rb +285 -0
- data/spec/genomer-plugin-summary_spec/gaps_spec.rb +32 -7
- data/spec/genomer-plugin-summary_spec/{scaffold_spec.rb → genome_spec.rb} +26 -7
- data/spec/genomer-plugin-summary_spec/metrics_spec.rb +64 -0
- data/spec/genomer-plugin-summary_spec/sequences_spec.rb +52 -85
- data/spec/spec_helper.rb +1 -1
- metadata +20 -9
- data/features/scaffold.feature +0 -122
- data/lib/genomer-plugin-summary/scaffold.rb +0 -56
@@ -0,0 +1,285 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'genomer-plugin-summary/format'
|
3
|
+
|
4
|
+
describe GenomerPluginSummary::Format do
|
5
|
+
|
6
|
+
subject do
|
7
|
+
o = Object.new
|
8
|
+
o.extend described_class
|
9
|
+
o.table(data,options.merge(:output => output))
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#table" do
|
13
|
+
|
14
|
+
let(:data) do
|
15
|
+
[['Contigs (#)',1.0],
|
16
|
+
:separator,
|
17
|
+
['Gaps (#)',0]]
|
18
|
+
end
|
19
|
+
|
20
|
+
context "passed no output option" do
|
21
|
+
|
22
|
+
let(:output) do
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
context "without any addtional options" do
|
27
|
+
|
28
|
+
let(:options) do
|
29
|
+
{}
|
30
|
+
end
|
31
|
+
|
32
|
+
it do
|
33
|
+
should ==<<-EOS.unindent!
|
34
|
+
+-------------+-----+
|
35
|
+
| Contigs (#) | 1.0 |
|
36
|
+
+-------------+-----+
|
37
|
+
| Gaps (#) | 0 |
|
38
|
+
+-------------+-----+
|
39
|
+
EOS
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "the header option" do
|
44
|
+
|
45
|
+
let(:options) do
|
46
|
+
{:title => 'Scaffold' }
|
47
|
+
end
|
48
|
+
|
49
|
+
it do
|
50
|
+
should ==<<-EOS.unindent!
|
51
|
+
+-------------+-----+
|
52
|
+
| Scaffold |
|
53
|
+
+-------------+-----+
|
54
|
+
| Contigs (#) | 1.0 |
|
55
|
+
+-------------+-----+
|
56
|
+
| Gaps (#) | 0 |
|
57
|
+
+-------------+-----+
|
58
|
+
EOS
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
context "with the justification option" do
|
64
|
+
|
65
|
+
let(:options) do
|
66
|
+
{:justification => {
|
67
|
+
0 => :left,
|
68
|
+
1 => :right
|
69
|
+
}}
|
70
|
+
end
|
71
|
+
|
72
|
+
it do
|
73
|
+
should ==<<-EOS.unindent!
|
74
|
+
+-------------+-----+
|
75
|
+
| Contigs (#) | 1.0 |
|
76
|
+
+-------------+-----+
|
77
|
+
| Gaps (#) | 0 |
|
78
|
+
+-------------+-----+
|
79
|
+
EOS
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with the width option" do
|
84
|
+
|
85
|
+
let(:options) do
|
86
|
+
{:width => { 0 => 15, 1 => 10 },
|
87
|
+
:justification => { 1 => :right }}
|
88
|
+
end
|
89
|
+
|
90
|
+
it do
|
91
|
+
should ==<<-EOS.unindent!
|
92
|
+
+-----------------+------------+
|
93
|
+
| Contigs (#) | 1.0 |
|
94
|
+
+-----------------+------------+
|
95
|
+
| Gaps (#) | 0 |
|
96
|
+
+-----------------+------------+
|
97
|
+
EOS
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
context "with the format option" do
|
103
|
+
|
104
|
+
let(:options) do
|
105
|
+
{:format => { 1 => '%#.2f'}}
|
106
|
+
end
|
107
|
+
|
108
|
+
it do
|
109
|
+
should ==<<-EOS.unindent!
|
110
|
+
+-------------+------+
|
111
|
+
| Contigs (#) | 1.00 |
|
112
|
+
+-------------+------+
|
113
|
+
| Gaps (#) | 0.00 |
|
114
|
+
+-------------+------+
|
115
|
+
EOS
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
context "with the format option as a lambda" do
|
121
|
+
|
122
|
+
let(:options) do
|
123
|
+
{:format => { 1 => lambda{|i| i.class == Float ? sprintf('%#.2f',i) : i }}}
|
124
|
+
end
|
125
|
+
|
126
|
+
it do
|
127
|
+
should ==<<-EOS.unindent!
|
128
|
+
+-------------+------+
|
129
|
+
| Contigs (#) | 1.00 |
|
130
|
+
+-------------+------+
|
131
|
+
| Gaps (#) | 0 |
|
132
|
+
+-------------+------+
|
133
|
+
EOS
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
context "with the header option" do
|
139
|
+
|
140
|
+
let(:options) do
|
141
|
+
{:headers => ['One','Two']}
|
142
|
+
end
|
143
|
+
|
144
|
+
it do
|
145
|
+
should ==<<-EOS.unindent!
|
146
|
+
+-------------+-----+
|
147
|
+
| One | Two |
|
148
|
+
+-------------+-----+
|
149
|
+
| Contigs (#) | 1.0 |
|
150
|
+
+-------------+-----+
|
151
|
+
| Gaps (#) | 0 |
|
152
|
+
+-------------+-----+
|
153
|
+
EOS
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
context "with the header and width options but no data" do
|
159
|
+
|
160
|
+
let(:options) do
|
161
|
+
{:headers => ['One','Two'],
|
162
|
+
:width => { 0 => 15, 1 => 10 }}
|
163
|
+
end
|
164
|
+
|
165
|
+
let(:data) do
|
166
|
+
[]
|
167
|
+
end
|
168
|
+
|
169
|
+
it do
|
170
|
+
should ==<<-EOS.unindent!
|
171
|
+
+-----------------+------------+
|
172
|
+
| One | Two |
|
173
|
+
+-----------------+------------+
|
174
|
+
+-----------------+------------+
|
175
|
+
EOS
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
context "passed the csv output option" do
|
183
|
+
|
184
|
+
let(:output) do
|
185
|
+
'csv'
|
186
|
+
end
|
187
|
+
|
188
|
+
context "without any additional options" do
|
189
|
+
|
190
|
+
let(:options) do
|
191
|
+
{}
|
192
|
+
end
|
193
|
+
|
194
|
+
it do
|
195
|
+
should ==<<-EOS.unindent!
|
196
|
+
contigs_#,1.0
|
197
|
+
gaps_#,0
|
198
|
+
EOS
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "with the justification option" do
|
203
|
+
|
204
|
+
let(:options) do
|
205
|
+
{:justification => {
|
206
|
+
0 => :left,
|
207
|
+
1 => :right
|
208
|
+
}}
|
209
|
+
end
|
210
|
+
|
211
|
+
it do
|
212
|
+
should ==<<-EOS.unindent!
|
213
|
+
contigs_#,1.0
|
214
|
+
gaps_#,0
|
215
|
+
EOS
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context "with the width option" do
|
220
|
+
|
221
|
+
let(:options) do
|
222
|
+
{:width => { 0 => 15, 1 => 10 },
|
223
|
+
:justification => { 1 => :right }}
|
224
|
+
end
|
225
|
+
|
226
|
+
it do
|
227
|
+
should ==<<-EOS.unindent!
|
228
|
+
contigs_#,1.0
|
229
|
+
gaps_#,0
|
230
|
+
EOS
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
context "with the header option" do
|
236
|
+
|
237
|
+
let(:options) do
|
238
|
+
{:headers => ['One','Two']}
|
239
|
+
end
|
240
|
+
|
241
|
+
it do
|
242
|
+
should ==<<-EOS.unindent!
|
243
|
+
one,two
|
244
|
+
contigs_#,1.0
|
245
|
+
gaps_#,0
|
246
|
+
EOS
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
context "with the format option" do
|
252
|
+
|
253
|
+
let(:options) do
|
254
|
+
{:format => { 1 => '%#.2f'}}
|
255
|
+
end
|
256
|
+
|
257
|
+
it do
|
258
|
+
should ==<<-EOS.unindent!
|
259
|
+
contigs_#,1.00
|
260
|
+
gaps_#,0.00
|
261
|
+
EOS
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
context "with the format option as a lambda" do
|
267
|
+
|
268
|
+
let(:options) do
|
269
|
+
{:format => { 1 => lambda{|i| i.class == Float ? sprintf('%#.2f',i) : i }}}
|
270
|
+
end
|
271
|
+
|
272
|
+
it do
|
273
|
+
should ==<<-EOS.unindent!
|
274
|
+
contigs_#,1.00
|
275
|
+
gaps_#,0
|
276
|
+
EOS
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
@@ -6,12 +6,16 @@ describe GenomerPluginSummary::Gaps do
|
|
6
6
|
describe "#tabulate" do
|
7
7
|
|
8
8
|
subject do
|
9
|
-
described_class.new([],{}).tabulate(
|
9
|
+
described_class.new([],{}).tabulate(sequences,flags)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:flags) do
|
13
|
+
{}
|
10
14
|
end
|
11
15
|
|
12
16
|
context "passed an empty array" do
|
13
17
|
|
14
|
-
let(:
|
18
|
+
let(:sequences) do
|
15
19
|
[]
|
16
20
|
end
|
17
21
|
|
@@ -30,7 +34,7 @@ describe GenomerPluginSummary::Gaps do
|
|
30
34
|
|
31
35
|
context "passed an array with one entry" do
|
32
36
|
|
33
|
-
let(:
|
37
|
+
let(:sequences) do
|
34
38
|
[{:number => 1, :length => 1, :start => 1, :end => 1, :type => :contig}]
|
35
39
|
end
|
36
40
|
|
@@ -50,7 +54,7 @@ describe GenomerPluginSummary::Gaps do
|
|
50
54
|
|
51
55
|
context "passed an array with two entries" do
|
52
56
|
|
53
|
-
let(:
|
57
|
+
let(:sequences) do
|
54
58
|
[{:number => 1, :length => 1, :start => 1, :end => 1, :type => :contig},
|
55
59
|
{:number => 2, :length => 2, :start => 2, :end => 2, :type => :unresolved}]
|
56
60
|
end
|
@@ -70,6 +74,27 @@ describe GenomerPluginSummary::Gaps do
|
|
70
74
|
|
71
75
|
end
|
72
76
|
|
77
|
+
context "passed the csv option" do
|
78
|
+
|
79
|
+
let(:flags) do
|
80
|
+
{:output => 'csv'}
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:sequences) do
|
84
|
+
[{:number => 1, :length => 1, :start => 1, :end => 1, :type => :contig},
|
85
|
+
{:number => 2, :length => 2, :start => 2, :end => 2, :type => :unresolved}]
|
86
|
+
end
|
87
|
+
|
88
|
+
it do
|
89
|
+
should ==<<-EOS.unindent!
|
90
|
+
number,length,start,end,type
|
91
|
+
1,1,1,1,contig
|
92
|
+
2,2,2,2,unresolved
|
93
|
+
EOS
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
73
98
|
end
|
74
99
|
|
75
100
|
describe "#determine_gaps" do
|
@@ -104,7 +129,7 @@ describe GenomerPluginSummary::Gaps do
|
|
104
129
|
end
|
105
130
|
end
|
106
131
|
|
107
|
-
context "a scaffold with a two
|
132
|
+
context "a scaffold with a two sequences containing gaps" do
|
108
133
|
let(:scaffold) do
|
109
134
|
[sequence('AANNTT'), sequence('AANNTT')]
|
110
135
|
end
|
@@ -116,7 +141,7 @@ describe GenomerPluginSummary::Gaps do
|
|
116
141
|
end
|
117
142
|
end
|
118
143
|
|
119
|
-
context "a scaffold with two
|
144
|
+
context "a scaffold with two sequences separated by an unresolved region" do
|
120
145
|
let(:scaffold) do
|
121
146
|
[sequence('AAT'),
|
122
147
|
unresolved('NNNNNNNNNN'),
|
@@ -129,7 +154,7 @@ describe GenomerPluginSummary::Gaps do
|
|
129
154
|
end
|
130
155
|
end
|
131
156
|
|
132
|
-
context "a scaffold with a mixture of gapped
|
157
|
+
context "a scaffold with a mixture of gapped sequences and unresolved regions" do
|
133
158
|
let(:scaffold) do
|
134
159
|
[sequence('AAANNNTTT'),
|
135
160
|
unresolved('NNNNNNNNNN'),
|
@@ -1,20 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'genomer-plugin-summary/
|
2
|
+
require 'genomer-plugin-summary/genome'
|
3
3
|
|
4
|
-
describe GenomerPluginSummary::
|
4
|
+
describe GenomerPluginSummary::Genome do
|
5
5
|
|
6
6
|
describe "#tabulate" do
|
7
7
|
|
8
8
|
subject do
|
9
|
-
described_class.new([],{}).tabulate(data)
|
9
|
+
described_class.new([],{}).tabulate(data,flags)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:data) do
|
13
|
+
[['Contigs (#)',1.0],
|
14
|
+
:separator,
|
15
|
+
['Gaps (#)',0]]
|
10
16
|
end
|
11
17
|
|
12
18
|
context "passed table data" do
|
13
19
|
|
14
|
-
let(:
|
15
|
-
|
16
|
-
:separator,
|
17
|
-
['Gaps (#)',0]]
|
20
|
+
let(:flags) do
|
21
|
+
{}
|
18
22
|
end
|
19
23
|
|
20
24
|
it do
|
@@ -28,6 +32,21 @@ describe GenomerPluginSummary::Scaffold do
|
|
28
32
|
+--------------+-----------+
|
29
33
|
EOS
|
30
34
|
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
context "passed table with the format option" do
|
39
|
+
|
40
|
+
let(:flags) do
|
41
|
+
{:output => 'csv'}
|
42
|
+
end
|
43
|
+
|
44
|
+
it do
|
45
|
+
should ==<<-EOS.unindent!
|
46
|
+
contigs_#,1.00
|
47
|
+
gaps_#,0
|
48
|
+
EOS
|
49
|
+
end
|
31
50
|
end
|
32
51
|
end
|
33
52
|
|
@@ -70,6 +70,7 @@ describe GenomerPluginSummary::Metrics do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
73
|
+
|
73
74
|
describe "#count" do
|
74
75
|
|
75
76
|
subject do
|
@@ -252,4 +253,67 @@ describe GenomerPluginSummary::Metrics do
|
|
252
253
|
|
253
254
|
end
|
254
255
|
|
256
|
+
describe "#sequence_total" do
|
257
|
+
|
258
|
+
def row(name,start,stop,percent,gc)
|
259
|
+
{:id => name,
|
260
|
+
:type => :sequence,
|
261
|
+
:start => start,
|
262
|
+
:stop => stop,
|
263
|
+
:size => (stop - start) + 1,
|
264
|
+
:percent => percent,
|
265
|
+
:gc => gc}
|
266
|
+
end
|
267
|
+
|
268
|
+
subject do
|
269
|
+
metric.sequence_total(sequences)
|
270
|
+
end
|
271
|
+
|
272
|
+
context "passed an empty array" do
|
273
|
+
let(:sequences) do
|
274
|
+
[]
|
275
|
+
end
|
276
|
+
|
277
|
+
it do
|
278
|
+
should == {
|
279
|
+
:start => 0,
|
280
|
+
:stop => 0,
|
281
|
+
:size => 0,
|
282
|
+
:percent => 0,
|
283
|
+
:gc => 0 }
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
context "passed one entry" do
|
288
|
+
let(:sequences) do
|
289
|
+
[row('contig1',1,6,100.0,50.0)]
|
290
|
+
end
|
291
|
+
|
292
|
+
it do
|
293
|
+
should == {
|
294
|
+
:start => 1,
|
295
|
+
:stop => 6,
|
296
|
+
:size => 6,
|
297
|
+
:percent => 100.0,
|
298
|
+
:gc => 50.0 }
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
context "passed two entries less than 100% of the scaffold" do
|
303
|
+
let(:sequences) do
|
304
|
+
[row('contig1', 1, 6, 30.0, 50.0),
|
305
|
+
row('contig2', 15, 20, 30.0, 50.0)]
|
306
|
+
end
|
307
|
+
|
308
|
+
it do
|
309
|
+
should == {
|
310
|
+
:start => 1,
|
311
|
+
:stop => 20,
|
312
|
+
:size => 12,
|
313
|
+
:percent => 60.0,
|
314
|
+
:gc => 50.0 }
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
255
319
|
end
|
@@ -4,9 +4,10 @@ require 'genomer-plugin-summary/sequences'
|
|
4
4
|
describe GenomerPluginSummary::Sequences do
|
5
5
|
|
6
6
|
def row(name,start,stop,percent,gc)
|
7
|
-
{:
|
7
|
+
{:id => name,
|
8
|
+
:type => :sequence,
|
8
9
|
:start => start,
|
9
|
-
:
|
10
|
+
:stop => stop,
|
10
11
|
:size => (stop - start) + 1,
|
11
12
|
:percent => percent,
|
12
13
|
:gc => gc}
|
@@ -15,7 +16,11 @@ describe GenomerPluginSummary::Sequences do
|
|
15
16
|
describe "#tabulate" do
|
16
17
|
|
17
18
|
subject do
|
18
|
-
described_class.new([],{}).tabulate(sequences,total)
|
19
|
+
described_class.new([],{}).tabulate(sequences,total,flags)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:flags) do
|
23
|
+
{}
|
19
24
|
end
|
20
25
|
|
21
26
|
context "passed an empty array" do
|
@@ -25,11 +30,11 @@ describe GenomerPluginSummary::Sequences do
|
|
25
30
|
end
|
26
31
|
|
27
32
|
let(:total) do
|
28
|
-
{:start =>
|
29
|
-
:
|
30
|
-
:size =>
|
31
|
-
:percent =>
|
32
|
-
:gc =>
|
33
|
+
{:start => 0,
|
34
|
+
:stop => 0,
|
35
|
+
:size => 0,
|
36
|
+
:percent => 0,
|
37
|
+
:gc => 0 }
|
33
38
|
end
|
34
39
|
|
35
40
|
it do
|
@@ -37,10 +42,10 @@ describe GenomerPluginSummary::Sequences do
|
|
37
42
|
+------------------+------------+------------+------------+----------+--------+
|
38
43
|
| Scaffold Sequences |
|
39
44
|
+------------------+------------+------------+------------+----------+--------+
|
40
|
-
|
|
45
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
41
46
|
+------------------+------------+------------+------------+----------+--------+
|
42
47
|
+------------------+------------+------------+------------+----------+--------+
|
43
|
-
| All |
|
48
|
+
| All | 0 | 0 | 0 | 0.00 | 0.00 |
|
44
49
|
+------------------+------------+------------+------------+----------+--------+
|
45
50
|
EOS
|
46
51
|
end
|
@@ -50,17 +55,12 @@ describe GenomerPluginSummary::Sequences do
|
|
50
55
|
context "passed an array with a single row" do
|
51
56
|
|
52
57
|
let(:sequences) do
|
53
|
-
[
|
54
|
-
:start => '1',
|
55
|
-
:end => '4',
|
56
|
-
:size => '4',
|
57
|
-
:percent => 100.0,
|
58
|
-
:gc => 50.0 }]
|
58
|
+
[row('contig1',1,4,100.0,50.0)]
|
59
59
|
end
|
60
60
|
|
61
61
|
let(:total) do
|
62
62
|
{:start => '1',
|
63
|
-
:
|
63
|
+
:stop => '4',
|
64
64
|
:size => '4',
|
65
65
|
:percent => 100.0,
|
66
66
|
:gc => 50.0 }
|
@@ -71,7 +71,7 @@ describe GenomerPluginSummary::Sequences do
|
|
71
71
|
+------------------+------------+------------+------------+----------+--------+
|
72
72
|
| Scaffold Sequences |
|
73
73
|
+------------------+------------+------------+------------+----------+--------+
|
74
|
-
|
|
74
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
75
75
|
+------------------+------------+------------+------------+----------+--------+
|
76
76
|
| contig1 | 1 | 4 | 4 | 100.00 | 50.00 |
|
77
77
|
+------------------+------------+------------+------------+----------+--------+
|
@@ -85,23 +85,13 @@ describe GenomerPluginSummary::Sequences do
|
|
85
85
|
context "passed a array with two rows" do
|
86
86
|
|
87
87
|
let(:sequences) do
|
88
|
-
[
|
89
|
-
|
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 }]
|
88
|
+
[row('contig1',1,4,100.0,50.0),
|
89
|
+
row('contig2',1,4,100.0,50.0)]
|
100
90
|
end
|
101
91
|
|
102
92
|
let(:total) do
|
103
93
|
{:start => '1',
|
104
|
-
:
|
94
|
+
:stop => '4',
|
105
95
|
:size => '4',
|
106
96
|
:percent => 100.0,
|
107
97
|
:gc => 50.0 }
|
@@ -112,7 +102,7 @@ describe GenomerPluginSummary::Sequences do
|
|
112
102
|
+------------------+------------+------------+------------+----------+--------+
|
113
103
|
| Scaffold Sequences |
|
114
104
|
+------------------+------------+------------+------------+----------+--------+
|
115
|
-
|
|
105
|
+
| Sequence | Start (bp) | End (bp) | Size (bp) | Size (%) | GC (%) |
|
116
106
|
+------------------+------------+------------+------------+----------+--------+
|
117
107
|
| contig1 | 1 | 4 | 4 | 100.00 | 50.00 |
|
118
108
|
| contig2 | 1 | 4 | 4 | 100.00 | 50.00 |
|
@@ -124,6 +114,36 @@ describe GenomerPluginSummary::Sequences do
|
|
124
114
|
|
125
115
|
end
|
126
116
|
|
117
|
+
context "passed the csv output option" do
|
118
|
+
|
119
|
+
let(:flags) do
|
120
|
+
{:output => 'csv'}
|
121
|
+
end
|
122
|
+
|
123
|
+
let(:sequences) do
|
124
|
+
[row('contig1',1,4,100.0,50.0),
|
125
|
+
row('contig2',1,4,100.0,50.0)]
|
126
|
+
end
|
127
|
+
|
128
|
+
let(:total) do
|
129
|
+
{:start => '1',
|
130
|
+
:stop => '4',
|
131
|
+
:size => '4',
|
132
|
+
:percent => 100.0,
|
133
|
+
:gc => 50.0 }
|
134
|
+
end
|
135
|
+
|
136
|
+
it do
|
137
|
+
should ==<<-EOS.unindent!
|
138
|
+
sequence,start_bp,end_bp,size_bp,size_%,gc_%
|
139
|
+
contig1,1,4,4,100.00,50.00
|
140
|
+
contig2,1,4,4,100.00,50.00
|
141
|
+
all,1,4,4,100.00,50.00
|
142
|
+
EOS
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
127
147
|
end
|
128
148
|
|
129
149
|
describe "#calculate" do
|
@@ -179,57 +199,4 @@ describe GenomerPluginSummary::Sequences do
|
|
179
199
|
|
180
200
|
end
|
181
201
|
|
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
202
|
end
|