scaffolder-test-helpers 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/scaffolder/test/sequence.rb +31 -4
- data/scaffolder-test-helpers.gemspec +3 -8
- data/spec/scaffolder/test/sequence_spec.rb +86 -0
- metadata +4 -4
data/Rakefile
CHANGED
@@ -25,6 +25,7 @@ Jeweler::Tasks.new do |gem|
|
|
25
25
|
gem.description = %Q{Useful Helper methods and classes for testing scaffolder.}
|
26
26
|
gem.email = "mail@michaelbarton.me.uk"
|
27
27
|
gem.authors = ["Michael Barton"]
|
28
|
+
gem.test_files = Dir['spec/**/*.rb']
|
28
29
|
end
|
29
30
|
Jeweler::RubygemsDotOrgTasks.new
|
30
31
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -22,16 +22,43 @@ module Scaffolder::Test
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def inserts(arg = nil)
|
26
|
+
return @options[:inserts] if arg.nil?
|
27
|
+
@options[:inserts] ||= Array.new
|
28
|
+
if arg.instance_of?(Array)
|
29
|
+
arg.each {|a| @options[:inserts] << a}
|
30
|
+
else
|
31
|
+
@options[:inserts] << arg
|
32
|
+
end
|
33
|
+
return self
|
34
|
+
end
|
35
|
+
|
25
36
|
def to_hash
|
26
|
-
hash = {'source' => name}
|
27
|
-
[:
|
28
|
-
hash[
|
37
|
+
hash = {'source' => name}.merge stringify_keys(@options)
|
38
|
+
if @options[:inserts]
|
39
|
+
hash['inserts'] = Array.new
|
40
|
+
@options[:inserts].each_with_index do |insert,i|
|
41
|
+
hash['inserts'] << {'source' => "insert#{i+1}"}.merge(stringify_keys(insert))
|
42
|
+
end
|
29
43
|
end
|
30
44
|
{'sequence' => hash}
|
31
45
|
end
|
32
46
|
|
33
47
|
def to_fasta
|
34
|
-
Bio::Sequence.new(sequence).output(:fasta,:header => name)
|
48
|
+
fasta = Bio::Sequence.new(sequence).output(:fasta,:header => name)
|
49
|
+
inserts.each_with_index do |insert,i|
|
50
|
+
fasta << Bio::Sequence.new(insert[:sequence]).output(:fasta,:header => "insert#{i+1}")
|
51
|
+
end if inserts
|
52
|
+
fasta.strip
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def stringify_keys(hash)
|
58
|
+
[:start,:stop,:reverse,:open,:close].inject(Hash.new) do |stringified,key|
|
59
|
+
stringified[key.to_s] = hash[key] if hash[key]
|
60
|
+
stringified
|
61
|
+
end
|
35
62
|
end
|
36
63
|
|
37
64
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{scaffolder-test-helpers}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Barton"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-06-02}
|
13
13
|
s.description = %q{Useful Helper methods and classes for testing scaffolder.}
|
14
14
|
s.email = %q{mail@michaelbarton.me.uk}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -37,12 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.require_paths = ["lib"]
|
38
38
|
s.rubygems_version = %q{1.3.7}
|
39
39
|
s.summary = %q{Methods and classes for testing scaffolder.}
|
40
|
-
s.test_files = [
|
41
|
-
"spec/scaffolder/test/helpers_spec.rb",
|
42
|
-
"spec/scaffolder/test/sequence_spec.rb",
|
43
|
-
"spec/scaffolder/test/unresolved_spec.rb",
|
44
|
-
"spec/spec_helper.rb"
|
45
|
-
]
|
40
|
+
s.test_files = ["spec/scaffolder/test/helpers_spec.rb", "spec/scaffolder/test/sequence_spec.rb", "spec/scaffolder/test/unresolved_spec.rb", "spec/spec_helper.rb"]
|
46
41
|
|
47
42
|
if s.respond_to? :specification_version then
|
48
43
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -14,6 +14,92 @@ describe Scaffolder::Test::Sequence do
|
|
14
14
|
its(:to_hash) {should == {'sequence' => {'source' => 'contig1'}} }
|
15
15
|
end
|
16
16
|
|
17
|
+
describe "with an insert" do
|
18
|
+
|
19
|
+
describe "added as a hash at initialisation" do
|
20
|
+
|
21
|
+
subject do
|
22
|
+
described_class.new(:name => 'contig1',:sequence => 'ATGCCC',:inserts =>[{
|
23
|
+
:open => 3, :close => 4, :sequence => 'TTT'}])
|
24
|
+
end
|
25
|
+
|
26
|
+
its(:name) {should == 'contig1'}
|
27
|
+
its(:sequence){should == 'ATGCCC'}
|
28
|
+
|
29
|
+
its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"}
|
30
|
+
its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{
|
31
|
+
'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} }
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "added singularly to an existing contig" do
|
36
|
+
|
37
|
+
subject do
|
38
|
+
contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC')
|
39
|
+
contig.inserts({:open => 3, :close => 4, :sequence => 'TTT'})
|
40
|
+
end
|
41
|
+
|
42
|
+
its(:name) {should == 'contig1'}
|
43
|
+
its(:sequence){should == 'ATGCCC'}
|
44
|
+
|
45
|
+
its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"}
|
46
|
+
its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{
|
47
|
+
'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} }
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "added singularly to an existing contig" do
|
52
|
+
|
53
|
+
subject do
|
54
|
+
contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC')
|
55
|
+
contig.inserts({:open => 3, :close => 4, :sequence => 'TTT'})
|
56
|
+
end
|
57
|
+
|
58
|
+
its(:name) {should == 'contig1'}
|
59
|
+
its(:sequence){should == 'ATGCCC'}
|
60
|
+
|
61
|
+
its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"}
|
62
|
+
its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{
|
63
|
+
'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} }
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "added as an array to an existing contig" do
|
68
|
+
|
69
|
+
subject do
|
70
|
+
contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC')
|
71
|
+
contig.inserts([{:open => 3, :close => 4, :sequence => 'TTT'}])
|
72
|
+
end
|
73
|
+
|
74
|
+
its(:name) {should == 'contig1'}
|
75
|
+
its(:sequence){should == 'ATGCCC'}
|
76
|
+
|
77
|
+
its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT"}
|
78
|
+
its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [{
|
79
|
+
'open' => 3, 'close' => 4, 'source' => 'insert1'}]}} }
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "added to an existing contig with one insert" do
|
84
|
+
|
85
|
+
subject do
|
86
|
+
contig = described_class.new(:name => 'contig1',:sequence => 'ATGCCC',
|
87
|
+
:inserts =>[{:open => 3, :close => 4, :sequence => 'TTT'}])
|
88
|
+
contig.inserts([{:open => 3, :close => 4, :sequence => 'TTT'}])
|
89
|
+
end
|
90
|
+
|
91
|
+
its(:name) {should == 'contig1'}
|
92
|
+
its(:sequence){should == 'ATGCCC'}
|
93
|
+
|
94
|
+
its(:to_fasta){should == ">contig1\nATGCCC\n>insert1\nTTT\n>insert2\nTTT"}
|
95
|
+
its(:to_hash) {should == {'sequence' => {'source' => 'contig1','inserts' => [
|
96
|
+
{'open' => 3, 'close' => 4, 'source' => 'insert1'},
|
97
|
+
{'open' => 3, 'close' => 4, 'source' => 'insert2'}
|
98
|
+
]}}}
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
17
103
|
[:start,:stop,:reverse].each do |attribute|
|
18
104
|
|
19
105
|
describe "instance with #{attribute} attribute" do
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Barton
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-02 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|