bioinform 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +17 -17
  3. data/Gemfile +16 -16
  4. data/LICENSE +21 -21
  5. data/README.md +35 -35
  6. data/Rakefile +4 -4
  7. data/TODO.txt +37 -37
  8. data/bin/merge_into_collection +3 -3
  9. data/bin/pcm2pwm +3 -3
  10. data/bin/split_motifs +3 -3
  11. data/bioinform.gemspec +19 -19
  12. data/lib/bioinform/cli/convert_motif.rb +107 -107
  13. data/lib/bioinform/cli/merge_into_collection.rb +79 -79
  14. data/lib/bioinform/cli/pcm2pwm.rb +46 -46
  15. data/lib/bioinform/cli/split_motifs.rb +46 -46
  16. data/lib/bioinform/cli.rb +29 -29
  17. data/lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb +18 -18
  18. data/lib/bioinform/conversion_algorithms/pcm2pwm_converter.rb +19 -19
  19. data/lib/bioinform/data_models/collection.rb +74 -74
  20. data/lib/bioinform/data_models/motif.rb +55 -55
  21. data/lib/bioinform/data_models/pcm.rb +23 -23
  22. data/lib/bioinform/data_models/pm.rb +169 -169
  23. data/lib/bioinform/data_models/ppm.rb +9 -9
  24. data/lib/bioinform/data_models/pwm.rb +55 -55
  25. data/lib/bioinform/data_models.rb +10 -10
  26. data/lib/bioinform/formatters/raw_formatter.rb +40 -40
  27. data/lib/bioinform/formatters/transfac_formatter.rb +38 -38
  28. data/lib/bioinform/formatters.rb +1 -1
  29. data/lib/bioinform/parsers/jaspar_parser.rb +34 -34
  30. data/lib/bioinform/parsers/parser.rb +87 -87
  31. data/lib/bioinform/parsers/splittable_parser.rb +56 -56
  32. data/lib/bioinform/parsers/string_fantom_parser.rb +34 -34
  33. data/lib/bioinform/parsers/string_parser.rb +71 -71
  34. data/lib/bioinform/parsers/trivial_parser.rb +33 -33
  35. data/lib/bioinform/parsers/yaml_parser.rb +34 -34
  36. data/lib/bioinform/parsers.rb +6 -6
  37. data/lib/bioinform/support/array_product.rb +5 -5
  38. data/lib/bioinform/support/array_zip.rb +5 -5
  39. data/lib/bioinform/support/collect_hash.rb +6 -6
  40. data/lib/bioinform/support/deep_dup.rb +4 -4
  41. data/lib/bioinform/support/delete_many.rb +13 -13
  42. data/lib/bioinform/support/inverf.rb +12 -12
  43. data/lib/bioinform/support/multiline_squish.rb +5 -5
  44. data/lib/bioinform/support/parameters.rb +27 -27
  45. data/lib/bioinform/support/partial_sums.rb +15 -15
  46. data/lib/bioinform/support/same_by.rb +12 -12
  47. data/lib/bioinform/support/strip_doc.rb +8 -8
  48. data/lib/bioinform/support/third_part/active_support/hash_with_indifferent_access.rb +3 -0
  49. data/lib/bioinform/support.rb +17 -17
  50. data/lib/bioinform/version.rb +3 -3
  51. data/lib/bioinform.rb +10 -10
  52. data/spec/cli/cli_spec.rb +13 -13
  53. data/spec/cli/convert_motif_spec.rb +106 -106
  54. data/spec/cli/data/merge_into_collection/GABPA_f1.pwm +14 -14
  55. data/spec/cli/data/merge_into_collection/KLF4_f2.pwm +11 -11
  56. data/spec/cli/data/merge_into_collection/SP1_f1.pwm +12 -12
  57. data/spec/cli/data/merge_into_collection/collection.txt.result +40 -40
  58. data/spec/cli/data/merge_into_collection/collection.yaml.result +188 -188
  59. data/spec/cli/data/merge_into_collection/collection_pwm.yaml.result +188 -188
  60. data/spec/cli/data/merge_into_collection/pwm_folder/GABPA_f1.pwm +14 -14
  61. data/spec/cli/data/merge_into_collection/pwm_folder/KLF4_f2.pwm +11 -11
  62. data/spec/cli/data/merge_into_collection/pwm_folder/SP1_f1.pwm +12 -12
  63. data/spec/cli/data/pcm2pwm/KLF4 f2 spaced name.pcm +11 -11
  64. data/spec/cli/data/pcm2pwm/KLF4_f2.pcm +11 -11
  65. data/spec/cli/data/pcm2pwm/KLF4_f2.pwm.result +11 -11
  66. data/spec/cli/data/pcm2pwm/SP1_f1.pcm +12 -12
  67. data/spec/cli/data/pcm2pwm/SP1_f1.pwm.result +12 -12
  68. data/spec/cli/data/split_motifs/GABPA_f1.mat.result +14 -14
  69. data/spec/cli/data/split_motifs/KLF4_f2.mat.result +11 -11
  70. data/spec/cli/data/split_motifs/SP1_f1.mat.result +12 -12
  71. data/spec/cli/data/split_motifs/collection.yaml +188 -188
  72. data/spec/cli/data/split_motifs/plain_collection.txt +38 -38
  73. data/spec/cli/merge_into_collection_spec.rb +99 -99
  74. data/spec/cli/pcm2pwm_spec.rb +79 -79
  75. data/spec/cli/shared_examples/convert_motif/motif_list_empty.rb +17 -17
  76. data/spec/cli/shared_examples/convert_motif/several_motifs_specified.rb +14 -14
  77. data/spec/cli/shared_examples/convert_motif/single_motif_specified.rb +49 -49
  78. data/spec/cli/shared_examples/convert_motif/yield_help_string.rb +4 -4
  79. data/spec/cli/shared_examples/convert_motif/yield_motif_conversion_error.rb +3 -3
  80. data/spec/cli/split_motifs_spec.rb +76 -76
  81. data/spec/data_models/collection_spec.rb +97 -97
  82. data/spec/data_models/motif_spec.rb +223 -223
  83. data/spec/data_models/pcm_spec.rb +55 -55
  84. data/spec/data_models/pm_spec.rb +359 -359
  85. data/spec/data_models/ppm_spec.rb +7 -7
  86. data/spec/data_models/pwm_spec.rb +82 -82
  87. data/spec/fabricators/collection_fabricator.rb +7 -7
  88. data/spec/fabricators/motif_fabricator.rb +32 -32
  89. data/spec/fabricators/motif_formats_fabricator.rb +124 -124
  90. data/spec/fabricators/pcm_fabricator.rb +24 -24
  91. data/spec/fabricators/pm_fabricator.rb +51 -51
  92. data/spec/fabricators/ppm_fabricator.rb +13 -13
  93. data/spec/fabricators/pwm_fabricator.rb +16 -16
  94. data/spec/parsers/parser_spec.rb +152 -152
  95. data/spec/parsers/string_fantom_parser_spec.rb +69 -69
  96. data/spec/parsers/string_parser_spec.rb +76 -76
  97. data/spec/parsers/trivial_parser_spec.rb +63 -63
  98. data/spec/parsers/yaml_parser_spec.rb +50 -50
  99. data/spec/spec_helper.rb +10 -10
  100. data/spec/spec_helper_source.rb +59 -59
  101. data/spec/support/advanced_scan_spec.rb +31 -31
  102. data/spec/support/array_product_spec.rb +14 -14
  103. data/spec/support/array_zip_spec.rb +14 -14
  104. data/spec/support/collect_hash_spec.rb +14 -14
  105. data/spec/support/delete_many_spec.rb +43 -43
  106. data/spec/support/inverf_spec.rb +18 -18
  107. data/spec/support/multiline_squish_spec.rb +24 -24
  108. data/spec/support/partial_sums_spec.rb +30 -30
  109. data/spec/support/same_by_spec.rb +35 -35
  110. metadata +3 -3
@@ -1,77 +1,77 @@
1
- require_relative '../spec_helper'
2
- require_relative '../../lib/bioinform/cli/split_motifs'
3
-
4
- def run_split_motifs(cmd)
5
- Bioinform::CLI::SplitMotifs.main(cmd.shellsplit)
6
- end
7
-
8
- describe Bioinform::CLI::SplitMotifs do
9
- before :each do
10
- @start_dir = Dir.pwd
11
- @motifs_in_collection = %w[KLF4_f2 SP1_f1 GABPA_f1]
12
- Dir.chdir File.join(File.dirname(__FILE__), 'data', 'split_motifs')
13
- end
14
- after :each do
15
- @motifs_in_collection.each do |motif_name|
16
- File.delete("#{motif_name}.mat") if File.exist?("#{motif_name}.mat")
17
- File.delete("#{motif_name}.pwm") if File.exist?("#{motif_name}.pwm")
18
- File.delete("#{motif_name}.pat") if File.exist?("#{motif_name}.pat")
19
- end
20
- FileUtils.rm_rf('result_folder') if Dir.exist?('result_folder')
21
- Dir.chdir(@start_dir)
22
- end
23
- it 'splits plain text into separate files' do
24
- run_split_motifs('plain_collection.txt')
25
- @motifs_in_collection.each do |motif_name|
26
- File.exist?("#{motif_name}.mat").should be_true
27
- File.read("#{motif_name}.mat") == File.read("#{motif_name}.mat.result")
28
- end
29
- end
30
- it 'create files with specified extension' do
31
- run_split_motifs('plain_collection.txt -e pwm')
32
- @motifs_in_collection.each do |motif_name|
33
- File.exist?("#{motif_name}.pwm").should be_true
34
- File.read("#{motif_name}.pwm") == File.read("#{motif_name}.mat.result")
35
- end
36
- end
37
-
38
- context 'when specified folder exist' do
39
- before :each do
40
- Dir.mkdir('result_folder') unless Dir.exist?('result_folder')
41
- end
42
- it 'create files in specified folder' do
43
- run_split_motifs('plain_collection.txt -f result_folder')
44
- @motifs_in_collection.each do |motif_name|
45
- File.exist?(File.join('result_folder', "#{motif_name}.mat")).should be_true
46
- File.read(File.join('result_folder', "#{motif_name}.mat")) == File.read("#{motif_name}.mat.result")
47
- end
48
- end
49
- end
50
- context 'when specified folder not exist' do
51
- before :each do
52
- FileUtils.rm_rf('result_folder') if Dir.exist?('result_folder')
53
- end
54
- it 'create files in specified folder' do
55
- run_split_motifs('plain_collection.txt -f result_folder')
56
- @motifs_in_collection.each do |motif_name|
57
- File.exist?(File.join('result_folder', "#{motif_name}.mat")).should be_true
58
- File.read(File.join('result_folder', "#{motif_name}.mat")) == File.read("#{motif_name}.mat.result")
59
- end
60
- end
61
- end
62
-
63
- it 'splits motifs from Collections (yamled Bioinform::Collection instances) with appropriate extension' do
64
- run_split_motifs('collection.yaml')
65
- @motifs_in_collection.each do |motif_name|
66
- File.exist?("#{motif_name}.pwm").should be_true
67
- File.read("#{motif_name}.pwm") == File.read("#{motif_name}.mat.result")
68
- end
69
- end
70
- it 'splits motifs from Collections with specified extension' do
71
- run_split_motifs('collection.yaml -e pat')
72
- @motifs_in_collection.each do |motif_name|
73
- File.exist?("#{motif_name}.pat").should be_true
74
- File.read("#{motif_name}.pat") == File.read("#{motif_name}.mat.result")
75
- end
76
- end
1
+ require_relative '../spec_helper'
2
+ require_relative '../../lib/bioinform/cli/split_motifs'
3
+
4
+ def run_split_motifs(cmd)
5
+ Bioinform::CLI::SplitMotifs.main(cmd.shellsplit)
6
+ end
7
+
8
+ describe Bioinform::CLI::SplitMotifs do
9
+ before :each do
10
+ @start_dir = Dir.pwd
11
+ @motifs_in_collection = %w[KLF4_f2 SP1_f1 GABPA_f1]
12
+ Dir.chdir File.join(File.dirname(__FILE__), 'data', 'split_motifs')
13
+ end
14
+ after :each do
15
+ @motifs_in_collection.each do |motif_name|
16
+ File.delete("#{motif_name}.mat") if File.exist?("#{motif_name}.mat")
17
+ File.delete("#{motif_name}.pwm") if File.exist?("#{motif_name}.pwm")
18
+ File.delete("#{motif_name}.pat") if File.exist?("#{motif_name}.pat")
19
+ end
20
+ FileUtils.rm_rf('result_folder') if Dir.exist?('result_folder')
21
+ Dir.chdir(@start_dir)
22
+ end
23
+ it 'splits plain text into separate files' do
24
+ run_split_motifs('plain_collection.txt')
25
+ @motifs_in_collection.each do |motif_name|
26
+ File.exist?("#{motif_name}.mat").should be_true
27
+ File.read("#{motif_name}.mat") == File.read("#{motif_name}.mat.result")
28
+ end
29
+ end
30
+ it 'create files with specified extension' do
31
+ run_split_motifs('plain_collection.txt -e pwm')
32
+ @motifs_in_collection.each do |motif_name|
33
+ File.exist?("#{motif_name}.pwm").should be_true
34
+ File.read("#{motif_name}.pwm") == File.read("#{motif_name}.mat.result")
35
+ end
36
+ end
37
+
38
+ context 'when specified folder exist' do
39
+ before :each do
40
+ Dir.mkdir('result_folder') unless Dir.exist?('result_folder')
41
+ end
42
+ it 'create files in specified folder' do
43
+ run_split_motifs('plain_collection.txt -f result_folder')
44
+ @motifs_in_collection.each do |motif_name|
45
+ File.exist?(File.join('result_folder', "#{motif_name}.mat")).should be_true
46
+ File.read(File.join('result_folder', "#{motif_name}.mat")) == File.read("#{motif_name}.mat.result")
47
+ end
48
+ end
49
+ end
50
+ context 'when specified folder not exist' do
51
+ before :each do
52
+ FileUtils.rm_rf('result_folder') if Dir.exist?('result_folder')
53
+ end
54
+ it 'create files in specified folder' do
55
+ run_split_motifs('plain_collection.txt -f result_folder')
56
+ @motifs_in_collection.each do |motif_name|
57
+ File.exist?(File.join('result_folder', "#{motif_name}.mat")).should be_true
58
+ File.read(File.join('result_folder', "#{motif_name}.mat")) == File.read("#{motif_name}.mat.result")
59
+ end
60
+ end
61
+ end
62
+
63
+ it 'splits motifs from Collections (yamled Bioinform::Collection instances) with appropriate extension' do
64
+ run_split_motifs('collection.yaml')
65
+ @motifs_in_collection.each do |motif_name|
66
+ File.exist?("#{motif_name}.pwm").should be_true
67
+ File.read("#{motif_name}.pwm") == File.read("#{motif_name}.mat.result")
68
+ end
69
+ end
70
+ it 'splits motifs from Collections with specified extension' do
71
+ run_split_motifs('collection.yaml -e pat')
72
+ @motifs_in_collection.each do |motif_name|
73
+ File.exist?("#{motif_name}.pat").should be_true
74
+ File.read("#{motif_name}.pat") == File.read("#{motif_name}.mat.result")
75
+ end
76
+ end
77
77
  end
@@ -1,98 +1,98 @@
1
- require_relative '../spec_helper'
2
- require_relative '../../lib/bioinform/data_models/collection'
3
-
4
- module Bioinform
5
- describe Collection do
6
- before :each do
7
- @collection = Collection.new(name: 'Main collection')
8
- @pm_1 = Fabricate(:pm_1)
9
- @pm_2 = Fabricate(:pm_2)
10
- @pm_3 = Fabricate(:pm_3)
11
- end
12
- describe '#size' do
13
- it 'should return size of collection' do
14
- @collection << @pm_1 << @pm_2 << @pm_3
15
- @collection.size.should == 3
16
- end
17
- end
18
- describe '#<<' do
19
- it 'should add element to collection' do
20
- @collection << @pm_1
21
- @collection << @pm_2
22
- @collection << @pm_3
23
- @collection.should include(Motif.new(pm: @pm_1), Motif.new(pm: @pm_2), Motif.new(pm: @pm_3))
24
- end
25
- it 'should be chainable' do
26
- @collection << @pm_1 << @pm_2 << @pm_3
27
- @collection.should include(Motif.new(pm: @pm_1), Motif.new(pm: @pm_2), Motif.new(pm: @pm_3))
28
- end
29
- # it 'should mark motif with name' do
30
- # @collection << @pm_1 << @pm_2
31
- # @pm_1.should be_tagged('Main collection')
32
- # @pm_2.should be_tagged('Main collection')
33
- # end
34
- # it 'should mark motif with self' do
35
- # @collection << @pm_1 << @pm_2
36
- # @pm_1.should be_tagged(@collection)
37
- # @pm_2.should be_tagged(@collection)
38
- # end
39
- end
40
-
41
- describe '#each' do
42
- before :each do
43
- @collection << @pm_1 << @pm_2 << @pm_3
44
- end
45
- context 'with block given' do
46
- it 'should yield Motifs' do
47
- expect{|b| @collection.each(&b)}.to yield_successive_args(Motif,Motif,Motif)
48
- end
49
- end
50
- context 'with block given' do
51
- it 'return an Enumerator' do
52
- @collection.each.should be_kind_of(Enumerator)
53
- end
54
- end
55
- end
56
-
57
- describe '#each(:pcm)' do
58
- before :each do
59
- @collection << @pm_1.as_pcm << @pm_2 << @pm_3.as_pcm
60
- end
61
- context 'with block given' do
62
- it 'should yield elements of collecton converted to pcm' do
63
- expect{|b| @collection.each(:pcm, &b)}.to yield_successive_args(PCM, nil, PCM)
64
- end
65
- end
66
- context 'with block given' do
67
- it 'return an Enumerator' do
68
- @collection.each(:pcm).should be_kind_of(Enumerator)
69
- end
70
- end
71
- end
72
-
73
- describe '#+' do
74
- before :each do
75
- @collection << @pm_1 << @pm_2 << @pm_3
76
- @pm_sec_1 = Fabricate(:pm_4)
77
- @pm_sec_2 = Fabricate(:pm_5)
78
- @secondary_collection = Collection.new(name: 'Secondary collection')
79
- @secondary_collection << @pm_sec_1 << @pm_sec_2
80
- @summary_collection = @collection + @secondary_collection
81
- end
82
- it 'should create a collection consisting of all elements of both collections' do
83
- @summary_collection.should be_kind_of(Collection)
84
- @summary_collection.size.should == (@collection.size + @secondary_collection.size)
85
- @summary_collection.should include(Motif.new(pm: @pm_1), Motif.new(pm: @pm_2), Motif.new(pm: @pm_3),
86
- Motif.new(pm: @pm_sec_1), Motif.new(pm: @pm_sec_2))
87
- end
88
- # it 'should leave marks on motifs' do
89
- # @pm_1.should be_tagged('Main collection')
90
- # @pm_sec_1.should be_tagged('Secondary collection')
91
- # end
92
- # it 'should not mix marks of motifs in different collections' do
93
- # @pm_1.should_not be_tagged('Secondary collection')
94
- # @pm_sec_1.should_not be_tagged('Main collection')
95
- # end
96
- end
97
- end
1
+ require_relative '../spec_helper'
2
+ require_relative '../../lib/bioinform/data_models/collection'
3
+
4
+ module Bioinform
5
+ describe Collection do
6
+ before :each do
7
+ @collection = Collection.new(name: 'Main collection')
8
+ @pm_1 = Fabricate(:pm_1)
9
+ @pm_2 = Fabricate(:pm_2)
10
+ @pm_3 = Fabricate(:pm_3)
11
+ end
12
+ describe '#size' do
13
+ it 'should return size of collection' do
14
+ @collection << @pm_1 << @pm_2 << @pm_3
15
+ @collection.size.should == 3
16
+ end
17
+ end
18
+ describe '#<<' do
19
+ it 'should add element to collection' do
20
+ @collection << @pm_1
21
+ @collection << @pm_2
22
+ @collection << @pm_3
23
+ @collection.should include(Motif.new(pm: @pm_1), Motif.new(pm: @pm_2), Motif.new(pm: @pm_3))
24
+ end
25
+ it 'should be chainable' do
26
+ @collection << @pm_1 << @pm_2 << @pm_3
27
+ @collection.should include(Motif.new(pm: @pm_1), Motif.new(pm: @pm_2), Motif.new(pm: @pm_3))
28
+ end
29
+ # it 'should mark motif with name' do
30
+ # @collection << @pm_1 << @pm_2
31
+ # @pm_1.should be_tagged('Main collection')
32
+ # @pm_2.should be_tagged('Main collection')
33
+ # end
34
+ # it 'should mark motif with self' do
35
+ # @collection << @pm_1 << @pm_2
36
+ # @pm_1.should be_tagged(@collection)
37
+ # @pm_2.should be_tagged(@collection)
38
+ # end
39
+ end
40
+
41
+ describe '#each' do
42
+ before :each do
43
+ @collection << @pm_1 << @pm_2 << @pm_3
44
+ end
45
+ context 'with block given' do
46
+ it 'should yield Motifs' do
47
+ expect{|b| @collection.each(&b)}.to yield_successive_args(Motif,Motif,Motif)
48
+ end
49
+ end
50
+ context 'with block given' do
51
+ it 'return an Enumerator' do
52
+ @collection.each.should be_kind_of(Enumerator)
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#each(:pcm)' do
58
+ before :each do
59
+ @collection << @pm_1.as_pcm << @pm_2 << @pm_3.as_pcm
60
+ end
61
+ context 'with block given' do
62
+ it 'should yield elements of collecton converted to pcm' do
63
+ expect{|b| @collection.each(:pcm, &b)}.to yield_successive_args(PCM, nil, PCM)
64
+ end
65
+ end
66
+ context 'with block given' do
67
+ it 'return an Enumerator' do
68
+ @collection.each(:pcm).should be_kind_of(Enumerator)
69
+ end
70
+ end
71
+ end
72
+
73
+ describe '#+' do
74
+ before :each do
75
+ @collection << @pm_1 << @pm_2 << @pm_3
76
+ @pm_sec_1 = Fabricate(:pm_4)
77
+ @pm_sec_2 = Fabricate(:pm_5)
78
+ @secondary_collection = Collection.new(name: 'Secondary collection')
79
+ @secondary_collection << @pm_sec_1 << @pm_sec_2
80
+ @summary_collection = @collection + @secondary_collection
81
+ end
82
+ it 'should create a collection consisting of all elements of both collections' do
83
+ @summary_collection.should be_kind_of(Collection)
84
+ @summary_collection.size.should == (@collection.size + @secondary_collection.size)
85
+ @summary_collection.should include(Motif.new(pm: @pm_1), Motif.new(pm: @pm_2), Motif.new(pm: @pm_3),
86
+ Motif.new(pm: @pm_sec_1), Motif.new(pm: @pm_sec_2))
87
+ end
88
+ # it 'should leave marks on motifs' do
89
+ # @pm_1.should be_tagged('Main collection')
90
+ # @pm_sec_1.should be_tagged('Secondary collection')
91
+ # end
92
+ # it 'should not mix marks of motifs in different collections' do
93
+ # @pm_1.should_not be_tagged('Secondary collection')
94
+ # @pm_sec_1.should_not be_tagged('Main collection')
95
+ # end
96
+ end
97
+ end
98
98
  end