bioinform 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -17
- data/Gemfile +16 -16
- data/LICENSE +21 -21
- data/README.md +35 -35
- data/Rakefile +4 -4
- data/TODO.txt +37 -37
- data/bin/merge_into_collection +3 -3
- data/bin/pcm2pwm +3 -3
- data/bin/split_motifs +3 -3
- data/bioinform.gemspec +19 -19
- data/lib/bioinform/cli/convert_motif.rb +107 -107
- data/lib/bioinform/cli/merge_into_collection.rb +79 -79
- data/lib/bioinform/cli/pcm2pwm.rb +46 -46
- data/lib/bioinform/cli/split_motifs.rb +46 -46
- data/lib/bioinform/cli.rb +29 -29
- data/lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb +18 -18
- data/lib/bioinform/conversion_algorithms/pcm2pwm_converter.rb +19 -19
- data/lib/bioinform/data_models/collection.rb +74 -74
- data/lib/bioinform/data_models/motif.rb +55 -55
- data/lib/bioinform/data_models/pcm.rb +23 -23
- data/lib/bioinform/data_models/pm.rb +169 -169
- data/lib/bioinform/data_models/ppm.rb +9 -9
- data/lib/bioinform/data_models/pwm.rb +55 -55
- data/lib/bioinform/data_models.rb +10 -10
- data/lib/bioinform/formatters/raw_formatter.rb +40 -40
- data/lib/bioinform/formatters/transfac_formatter.rb +38 -38
- data/lib/bioinform/formatters.rb +1 -1
- data/lib/bioinform/parsers/jaspar_parser.rb +34 -34
- data/lib/bioinform/parsers/parser.rb +87 -87
- data/lib/bioinform/parsers/splittable_parser.rb +56 -56
- data/lib/bioinform/parsers/string_fantom_parser.rb +34 -34
- data/lib/bioinform/parsers/string_parser.rb +71 -71
- data/lib/bioinform/parsers/trivial_parser.rb +33 -33
- data/lib/bioinform/parsers/yaml_parser.rb +34 -34
- data/lib/bioinform/parsers.rb +6 -6
- data/lib/bioinform/support/array_product.rb +5 -5
- data/lib/bioinform/support/array_zip.rb +5 -5
- data/lib/bioinform/support/collect_hash.rb +6 -6
- data/lib/bioinform/support/deep_dup.rb +4 -4
- data/lib/bioinform/support/delete_many.rb +13 -13
- data/lib/bioinform/support/inverf.rb +12 -12
- data/lib/bioinform/support/multiline_squish.rb +5 -5
- data/lib/bioinform/support/parameters.rb +27 -27
- data/lib/bioinform/support/partial_sums.rb +15 -15
- data/lib/bioinform/support/same_by.rb +12 -12
- data/lib/bioinform/support/strip_doc.rb +8 -8
- data/lib/bioinform/support/third_part/active_support/hash_with_indifferent_access.rb +3 -0
- data/lib/bioinform/support.rb +17 -17
- data/lib/bioinform/version.rb +3 -3
- data/lib/bioinform.rb +10 -10
- data/spec/cli/cli_spec.rb +13 -13
- data/spec/cli/convert_motif_spec.rb +106 -106
- data/spec/cli/data/merge_into_collection/GABPA_f1.pwm +14 -14
- data/spec/cli/data/merge_into_collection/KLF4_f2.pwm +11 -11
- data/spec/cli/data/merge_into_collection/SP1_f1.pwm +12 -12
- data/spec/cli/data/merge_into_collection/collection.txt.result +40 -40
- data/spec/cli/data/merge_into_collection/collection.yaml.result +188 -188
- data/spec/cli/data/merge_into_collection/collection_pwm.yaml.result +188 -188
- data/spec/cli/data/merge_into_collection/pwm_folder/GABPA_f1.pwm +14 -14
- data/spec/cli/data/merge_into_collection/pwm_folder/KLF4_f2.pwm +11 -11
- data/spec/cli/data/merge_into_collection/pwm_folder/SP1_f1.pwm +12 -12
- data/spec/cli/data/pcm2pwm/KLF4 f2 spaced name.pcm +11 -11
- data/spec/cli/data/pcm2pwm/KLF4_f2.pcm +11 -11
- data/spec/cli/data/pcm2pwm/KLF4_f2.pwm.result +11 -11
- data/spec/cli/data/pcm2pwm/SP1_f1.pcm +12 -12
- data/spec/cli/data/pcm2pwm/SP1_f1.pwm.result +12 -12
- data/spec/cli/data/split_motifs/GABPA_f1.mat.result +14 -14
- data/spec/cli/data/split_motifs/KLF4_f2.mat.result +11 -11
- data/spec/cli/data/split_motifs/SP1_f1.mat.result +12 -12
- data/spec/cli/data/split_motifs/collection.yaml +188 -188
- data/spec/cli/data/split_motifs/plain_collection.txt +38 -38
- data/spec/cli/merge_into_collection_spec.rb +99 -99
- data/spec/cli/pcm2pwm_spec.rb +79 -79
- data/spec/cli/shared_examples/convert_motif/motif_list_empty.rb +17 -17
- data/spec/cli/shared_examples/convert_motif/several_motifs_specified.rb +14 -14
- data/spec/cli/shared_examples/convert_motif/single_motif_specified.rb +49 -49
- data/spec/cli/shared_examples/convert_motif/yield_help_string.rb +4 -4
- data/spec/cli/shared_examples/convert_motif/yield_motif_conversion_error.rb +3 -3
- data/spec/cli/split_motifs_spec.rb +76 -76
- data/spec/data_models/collection_spec.rb +97 -97
- data/spec/data_models/motif_spec.rb +223 -223
- data/spec/data_models/pcm_spec.rb +55 -55
- data/spec/data_models/pm_spec.rb +359 -359
- data/spec/data_models/ppm_spec.rb +7 -7
- data/spec/data_models/pwm_spec.rb +82 -82
- data/spec/fabricators/collection_fabricator.rb +7 -7
- data/spec/fabricators/motif_fabricator.rb +32 -32
- data/spec/fabricators/motif_formats_fabricator.rb +124 -124
- data/spec/fabricators/pcm_fabricator.rb +24 -24
- data/spec/fabricators/pm_fabricator.rb +51 -51
- data/spec/fabricators/ppm_fabricator.rb +13 -13
- data/spec/fabricators/pwm_fabricator.rb +16 -16
- data/spec/parsers/parser_spec.rb +152 -152
- data/spec/parsers/string_fantom_parser_spec.rb +69 -69
- data/spec/parsers/string_parser_spec.rb +76 -76
- data/spec/parsers/trivial_parser_spec.rb +63 -63
- data/spec/parsers/yaml_parser_spec.rb +50 -50
- data/spec/spec_helper.rb +10 -10
- data/spec/spec_helper_source.rb +59 -59
- data/spec/support/advanced_scan_spec.rb +31 -31
- data/spec/support/array_product_spec.rb +14 -14
- data/spec/support/array_zip_spec.rb +14 -14
- data/spec/support/collect_hash_spec.rb +14 -14
- data/spec/support/delete_many_spec.rb +43 -43
- data/spec/support/inverf_spec.rb +18 -18
- data/spec/support/multiline_squish_spec.rb +24 -24
- data/spec/support/partial_sums_spec.rb +30 -30
- data/spec/support/same_by_spec.rb +35 -35
- metadata +3 -3
@@ -1,15 +1,15 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require_relative '../../lib/bioinform/support/array_zip'
|
3
|
-
|
4
|
-
describe Array do
|
5
|
-
context '::zip' do
|
6
|
-
it 'should take any number of arrays and zip them as if #zip was made to first and others' do
|
7
|
-
Array.zip([1,2,3]).should == [1,2,3].zip()
|
8
|
-
Array.zip([1,2,3],[4,5,6]).should == [1,2,3].zip([4,5,6])
|
9
|
-
Array.zip([1,2,3],[4,5,6],[7,8,9]).should == [1,2,3].zip([4,5,6],[7,8,9])
|
10
|
-
end
|
11
|
-
it 'should return empty array if no arrays\'re given' do
|
12
|
-
Array.zip().should == []
|
13
|
-
end
|
14
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/bioinform/support/array_zip'
|
3
|
+
|
4
|
+
describe Array do
|
5
|
+
context '::zip' do
|
6
|
+
it 'should take any number of arrays and zip them as if #zip was made to first and others' do
|
7
|
+
Array.zip([1,2,3]).should == [1,2,3].zip()
|
8
|
+
Array.zip([1,2,3],[4,5,6]).should == [1,2,3].zip([4,5,6])
|
9
|
+
Array.zip([1,2,3],[4,5,6],[7,8,9]).should == [1,2,3].zip([4,5,6],[7,8,9])
|
10
|
+
end
|
11
|
+
it 'should return empty array if no arrays\'re given' do
|
12
|
+
Array.zip().should == []
|
13
|
+
end
|
14
|
+
end
|
15
15
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require_relative '../../lib/bioinform/support/collect_hash'
|
3
|
-
|
4
|
-
describe Enumerable do
|
5
|
-
# %w{A C G T}.collect_hash{|k| [k*2, k*3] }
|
6
|
-
# # ==> {"AA" => "AAA", "CC" => "CCC", "GG" => "GGG", "TT" => "TTT"}
|
7
|
-
context '#collect_hash' do
|
8
|
-
it 'should take a block and create a hash from collected [k,v] pairs' do
|
9
|
-
%w{A C G T}.collect_hash{|k| [k*2, k*3] }.should == {"AA" => "AAA", "CC" => "CCC", "GG" => "GGG", "TT" => "TTT"}
|
10
|
-
end
|
11
|
-
it 'should create a hash from yielded [k,v] pairs if block not given' do
|
12
|
-
%w{A C G T}.each_with_index.collect_hash.should == {"A" => 0, "C" => 1, "G" => 2, "T" => 3}
|
13
|
-
end
|
14
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/bioinform/support/collect_hash'
|
3
|
+
|
4
|
+
describe Enumerable do
|
5
|
+
# %w{A C G T}.collect_hash{|k| [k*2, k*3] }
|
6
|
+
# # ==> {"AA" => "AAA", "CC" => "CCC", "GG" => "GGG", "TT" => "TTT"}
|
7
|
+
context '#collect_hash' do
|
8
|
+
it 'should take a block and create a hash from collected [k,v] pairs' do
|
9
|
+
%w{A C G T}.collect_hash{|k| [k*2, k*3] }.should == {"AA" => "AAA", "CC" => "CCC", "GG" => "GGG", "TT" => "TTT"}
|
10
|
+
end
|
11
|
+
it 'should create a hash from yielded [k,v] pairs if block not given' do
|
12
|
+
%w{A C G T}.each_with_index.collect_hash.should == {"A" => 0, "C" => 1, "G" => 2, "T" => 3}
|
13
|
+
end
|
14
|
+
end
|
15
15
|
end
|
@@ -1,44 +1,44 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require_relative '../../lib/bioinform/support/delete_many'
|
3
|
-
|
4
|
-
describe Array do
|
5
|
-
before :each do
|
6
|
-
@arr = %w{a b c d e f g h i j b b}
|
7
|
-
end
|
8
|
-
describe '#delete_at_many' do
|
9
|
-
it 'should delete elements at specified indices when indices in ascending order' do
|
10
|
-
@arr.delete_at_many(1,3,7)
|
11
|
-
@arr.should == %w{a c e f g i j b b}
|
12
|
-
end
|
13
|
-
it 'should delete elements at specified indices when indices in descending order' do
|
14
|
-
@arr.delete_at_many(7,3,1)
|
15
|
-
@arr.should == %w{a c e f g i j b b}
|
16
|
-
end
|
17
|
-
it 'should delete elements at specified indices when indices in arbitrary order' do
|
18
|
-
@arr.delete_at_many(3,1,7)
|
19
|
-
@arr.should == %w{a c e f g i j b b}
|
20
|
-
end
|
21
|
-
it 'should delete at each index once' do
|
22
|
-
@arr.delete_at_many(0,0,0,2,0)
|
23
|
-
@arr.should == %w{b d e f g h i j b b}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
describe '#delete_many' do
|
27
|
-
it 'should delete multiple elements with specified values' do
|
28
|
-
@arr.delete_many('b', 'd', 'h', 'b')
|
29
|
-
@arr.should == %w{a c e f g i j}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe Hash do
|
35
|
-
before :each do
|
36
|
-
@arr = {A: 3, T: 6, G: 4, C: 5}
|
37
|
-
end
|
38
|
-
describe '#delete_many' do
|
39
|
-
it 'should delete specified keys' do
|
40
|
-
@arr.delete_many(:T, :C, :F, :T, :T)
|
41
|
-
@arr.should == {A: 3, G: 4}
|
42
|
-
end
|
43
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/bioinform/support/delete_many'
|
3
|
+
|
4
|
+
describe Array do
|
5
|
+
before :each do
|
6
|
+
@arr = %w{a b c d e f g h i j b b}
|
7
|
+
end
|
8
|
+
describe '#delete_at_many' do
|
9
|
+
it 'should delete elements at specified indices when indices in ascending order' do
|
10
|
+
@arr.delete_at_many(1,3,7)
|
11
|
+
@arr.should == %w{a c e f g i j b b}
|
12
|
+
end
|
13
|
+
it 'should delete elements at specified indices when indices in descending order' do
|
14
|
+
@arr.delete_at_many(7,3,1)
|
15
|
+
@arr.should == %w{a c e f g i j b b}
|
16
|
+
end
|
17
|
+
it 'should delete elements at specified indices when indices in arbitrary order' do
|
18
|
+
@arr.delete_at_many(3,1,7)
|
19
|
+
@arr.should == %w{a c e f g i j b b}
|
20
|
+
end
|
21
|
+
it 'should delete at each index once' do
|
22
|
+
@arr.delete_at_many(0,0,0,2,0)
|
23
|
+
@arr.should == %w{b d e f g h i j b b}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
describe '#delete_many' do
|
27
|
+
it 'should delete multiple elements with specified values' do
|
28
|
+
@arr.delete_many('b', 'd', 'h', 'b')
|
29
|
+
@arr.should == %w{a c e f g i j}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe Hash do
|
35
|
+
before :each do
|
36
|
+
@arr = {A: 3, T: 6, G: 4, C: 5}
|
37
|
+
end
|
38
|
+
describe '#delete_many' do
|
39
|
+
it 'should delete specified keys' do
|
40
|
+
@arr.delete_many(:T, :C, :F, :T, :T)
|
41
|
+
@arr.should == {A: 3, G: 4}
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
data/spec/support/inverf_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require_relative '../../lib/bioinform/support/inverf'
|
3
|
-
|
4
|
-
describe 'Math#inverf' do
|
5
|
-
it 'should be erf(inverf(x)) == x' do
|
6
|
-
rng = (-0.9..0.9).step(0.1)
|
7
|
-
arr = rng.to_a
|
8
|
-
arr2 = rng.map{|x| Math.inverf(x)}.map{|x| Math.erf(x)}
|
9
|
-
delta = arr.each_index.map{|i| (arr[i] - arr2[i]).abs }
|
10
|
-
delta.each{|el| el.should <= 0.001}
|
11
|
-
end
|
12
|
-
it 'should be erf(inverf(x)) == x' do
|
13
|
-
rng = (-5..5).step(1)
|
14
|
-
arr = rng.to_a
|
15
|
-
arr2 = rng.map{|x| Math.erf(x)}.map{|x| Math.inverf(x)}
|
16
|
-
delta = arr.each_index.map{|i| (arr[i] - arr2[i]).abs }
|
17
|
-
delta.each{|el| el.should <= 0.01}
|
18
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/bioinform/support/inverf'
|
3
|
+
|
4
|
+
describe 'Math#inverf' do
|
5
|
+
it 'should be erf(inverf(x)) == x' do
|
6
|
+
rng = (-0.9..0.9).step(0.1)
|
7
|
+
arr = rng.to_a
|
8
|
+
arr2 = rng.map{|x| Math.inverf(x)}.map{|x| Math.erf(x)}
|
9
|
+
delta = arr.each_index.map{|i| (arr[i] - arr2[i]).abs }
|
10
|
+
delta.each{|el| el.should <= 0.001}
|
11
|
+
end
|
12
|
+
it 'should be erf(inverf(x)) == x' do
|
13
|
+
rng = (-5..5).step(1)
|
14
|
+
arr = rng.to_a
|
15
|
+
arr2 = rng.map{|x| Math.erf(x)}.map{|x| Math.inverf(x)}
|
16
|
+
delta = arr.each_index.map{|i| (arr[i] - arr2[i]).abs }
|
17
|
+
delta.each{|el| el.should <= 0.01}
|
18
|
+
end
|
19
19
|
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require_relative '../../lib/bioinform/support/multiline_squish'
|
3
|
-
|
4
|
-
describe String do
|
5
|
-
describe '#multiline_squish' do
|
6
|
-
it 'should replace multiple spaces with one space' do
|
7
|
-
"abc def ghi\n jk lmn".multiline_squish.should == "abc def ghi\njk lmn"
|
8
|
-
end
|
9
|
-
it 'should replace tabs with a space' do
|
10
|
-
"abc\tdef ghi \t jk".multiline_squish.should == 'abc def ghi jk'
|
11
|
-
end
|
12
|
-
it 'should replace \r\n with \n' do
|
13
|
-
"abc def ghi\r\njk lmn".multiline_squish.should == "abc def ghi\njk lmn"
|
14
|
-
end
|
15
|
-
it 'should preserve rows pagination' do
|
16
|
-
"abc def ghi\njk lmn".multiline_squish.should == "abc def ghi\njk lmn"
|
17
|
-
end
|
18
|
-
it 'should preserve empty lines in the middle of text' do
|
19
|
-
"abc def\n\nghi\n \t \njk lmn \n\n\n zzz".multiline_squish.should == "abc def\n\nghi\n\njk lmn\n\n\nzzz"
|
20
|
-
end
|
21
|
-
it 'should drop empty lines at begin and at end of string' do
|
22
|
-
"\n \t\n\nabc def\n\nghi\n \t \njk lmn \n\n\n zzz\n\n \t \n".multiline_squish.should == "abc def\n\nghi\n\njk lmn\n\n\nzzz"
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/bioinform/support/multiline_squish'
|
3
|
+
|
4
|
+
describe String do
|
5
|
+
describe '#multiline_squish' do
|
6
|
+
it 'should replace multiple spaces with one space' do
|
7
|
+
"abc def ghi\n jk lmn".multiline_squish.should == "abc def ghi\njk lmn"
|
8
|
+
end
|
9
|
+
it 'should replace tabs with a space' do
|
10
|
+
"abc\tdef ghi \t jk".multiline_squish.should == 'abc def ghi jk'
|
11
|
+
end
|
12
|
+
it 'should replace \r\n with \n' do
|
13
|
+
"abc def ghi\r\njk lmn".multiline_squish.should == "abc def ghi\njk lmn"
|
14
|
+
end
|
15
|
+
it 'should preserve rows pagination' do
|
16
|
+
"abc def ghi\njk lmn".multiline_squish.should == "abc def ghi\njk lmn"
|
17
|
+
end
|
18
|
+
it 'should preserve empty lines in the middle of text' do
|
19
|
+
"abc def\n\nghi\n \t \njk lmn \n\n\n zzz".multiline_squish.should == "abc def\n\nghi\n\njk lmn\n\n\nzzz"
|
20
|
+
end
|
21
|
+
it 'should drop empty lines at begin and at end of string' do
|
22
|
+
"\n \t\n\nabc def\n\nghi\n \t \njk lmn \n\n\n zzz\n\n \t \n".multiline_squish.should == "abc def\n\nghi\n\njk lmn\n\n\nzzz"
|
23
|
+
end
|
24
|
+
end
|
25
25
|
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require_relative '../../lib/bioinform/support/partial_sums'
|
3
|
-
|
4
|
-
describe 'Array#partial_sums' do
|
5
|
-
context 'when no initial value given' do
|
6
|
-
it 'should return an array of the same size with partial sums of elements 0..ind inclusive with float elements' do
|
7
|
-
[2,3,4,5].partial_sums.should == [2, 5, 9, 14]
|
8
|
-
[2,3,4,5].partial_sums.last.should be_kind_of(Float)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
it 'should start counting from argument when it\'s given. Type of values depends on type of initial value' do
|
12
|
-
[2,3,4,5].partial_sums(100).should == [102,105,109,114]
|
13
|
-
[2,3,4,5].partial_sums(100).last.should be_kind_of(Integer)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
{1 => 5, 4 => 3, 3 => 2}.partial_sums == {1=>5, 3=>7, 4=>10}
|
18
|
-
|
19
|
-
describe 'Hash#partial_sums' do
|
20
|
-
context 'when no initial value given' do
|
21
|
-
it 'should return a hash with float values of the same size with partial sums of elements that has keys <= than argument' do
|
22
|
-
{1 => 5, 4 => 3, 3 => 2}.partial_sums.should == {1=>5, 3=>7, 4=>10}
|
23
|
-
{1 => 5, 4 => 3, 3 => 2}.partial_sums.values.last.should be_kind_of(Float)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
it 'should start counting from argument when it\'s given. Type of values depends on type of initial value' do
|
27
|
-
{1 => 5, 4 => 3, 3 => 2}.partial_sums(100).should == {1=>105, 3=>107, 4=>110}
|
28
|
-
{1 => 5, 4 => 3, 3 => 2}.partial_sums(100).values.last.should be_kind_of(Integer)
|
29
|
-
end
|
30
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/bioinform/support/partial_sums'
|
3
|
+
|
4
|
+
describe 'Array#partial_sums' do
|
5
|
+
context 'when no initial value given' do
|
6
|
+
it 'should return an array of the same size with partial sums of elements 0..ind inclusive with float elements' do
|
7
|
+
[2,3,4,5].partial_sums.should == [2, 5, 9, 14]
|
8
|
+
[2,3,4,5].partial_sums.last.should be_kind_of(Float)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
it 'should start counting from argument when it\'s given. Type of values depends on type of initial value' do
|
12
|
+
[2,3,4,5].partial_sums(100).should == [102,105,109,114]
|
13
|
+
[2,3,4,5].partial_sums(100).last.should be_kind_of(Integer)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
{1 => 5, 4 => 3, 3 => 2}.partial_sums == {1=>5, 3=>7, 4=>10}
|
18
|
+
|
19
|
+
describe 'Hash#partial_sums' do
|
20
|
+
context 'when no initial value given' do
|
21
|
+
it 'should return a hash with float values of the same size with partial sums of elements that has keys <= than argument' do
|
22
|
+
{1 => 5, 4 => 3, 3 => 2}.partial_sums.should == {1=>5, 3=>7, 4=>10}
|
23
|
+
{1 => 5, 4 => 3, 3 => 2}.partial_sums.values.last.should be_kind_of(Float)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
it 'should start counting from argument when it\'s given. Type of values depends on type of initial value' do
|
27
|
+
{1 => 5, 4 => 3, 3 => 2}.partial_sums(100).should == {1=>105, 3=>107, 4=>110}
|
28
|
+
{1 => 5, 4 => 3, 3 => 2}.partial_sums(100).values.last.should be_kind_of(Integer)
|
29
|
+
end
|
30
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require_relative '../../lib/bioinform/support/same_by'
|
3
|
-
|
4
|
-
describe Enumerable do
|
5
|
-
describe '#same_by?' do
|
6
|
-
it 'should be work with both hashes and arrays' do
|
7
|
-
['a','b','c'].same_by?{|k| k.length}
|
8
|
-
{'a'=>13,'b'=>12,'c'=>14}.same_by?{|k,v| v < 20}
|
9
|
-
end
|
10
|
-
it 'should be true for empty collections' do
|
11
|
-
[].same_by?(&:length).should be_true
|
12
|
-
[].same_by?.should be_true
|
13
|
-
end
|
14
|
-
context 'without block' do
|
15
|
-
it 'should compare if all elements of collection are the same' do
|
16
|
-
%w{cat cat cat}.same_by?.should be_true
|
17
|
-
%w{cat dog rat}.same_by?.should be_false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
context 'with a block' do
|
21
|
-
it 'should compare enumerables by a value of block' do
|
22
|
-
%w{cat dog rat}.same_by?(&:length).should be_true
|
23
|
-
%w{cat dog rabbit}.same_by?(&:length).should be_false
|
24
|
-
end
|
25
|
-
it 'should be true if all elements are true' do
|
26
|
-
[4,8,2,2].same_by?(&:even?).should be_true
|
27
|
-
end
|
28
|
-
it 'should be true if all elements are false' do
|
29
|
-
[1,3,9,7].same_by?(&:even?).should be_true
|
30
|
-
end
|
31
|
-
it 'should be false if some elements are true and some are false' do
|
32
|
-
[1,8,3,2].same_by?(&:even?).should be_false
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/bioinform/support/same_by'
|
3
|
+
|
4
|
+
describe Enumerable do
|
5
|
+
describe '#same_by?' do
|
6
|
+
it 'should be work with both hashes and arrays' do
|
7
|
+
['a','b','c'].same_by?{|k| k.length}
|
8
|
+
{'a'=>13,'b'=>12,'c'=>14}.same_by?{|k,v| v < 20}
|
9
|
+
end
|
10
|
+
it 'should be true for empty collections' do
|
11
|
+
[].same_by?(&:length).should be_true
|
12
|
+
[].same_by?.should be_true
|
13
|
+
end
|
14
|
+
context 'without block' do
|
15
|
+
it 'should compare if all elements of collection are the same' do
|
16
|
+
%w{cat cat cat}.same_by?.should be_true
|
17
|
+
%w{cat dog rat}.same_by?.should be_false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
context 'with a block' do
|
21
|
+
it 'should compare enumerables by a value of block' do
|
22
|
+
%w{cat dog rat}.same_by?(&:length).should be_true
|
23
|
+
%w{cat dog rabbit}.same_by?(&:length).should be_false
|
24
|
+
end
|
25
|
+
it 'should be true if all elements are true' do
|
26
|
+
[4,8,2,2].same_by?(&:even?).should be_true
|
27
|
+
end
|
28
|
+
it 'should be true if all elements are false' do
|
29
|
+
[1,3,9,7].same_by?(&:even?).should be_true
|
30
|
+
end
|
31
|
+
it 'should be false if some elements are true and some are false' do
|
32
|
+
[1,8,3,2].same_by?(&:even?).should be_false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bioinform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Vorontsov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
182
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.1.
|
183
|
+
rubygems_version: 2.1.11
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Classes for work with different input formats of positional matrices and
|