bioinform 0.1.17 → 0.2.0

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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/LICENSE +0 -1
  4. data/README.md +1 -1
  5. data/TODO.txt +23 -30
  6. data/bin/convert_motif +4 -0
  7. data/bin/pcm2pwm +1 -1
  8. data/bin/split_motifs +1 -1
  9. data/bioinform.gemspec +0 -2
  10. data/lib/bioinform.rb +54 -16
  11. data/lib/bioinform/alphabet.rb +85 -0
  12. data/lib/bioinform/background.rb +90 -0
  13. data/lib/bioinform/cli.rb +1 -2
  14. data/lib/bioinform/cli/convert_motif.rb +52 -17
  15. data/lib/bioinform/cli/pcm2pwm.rb +32 -26
  16. data/lib/bioinform/cli/split_motifs.rb +31 -30
  17. data/lib/bioinform/conversion_algorithms.rb +6 -0
  18. data/lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb +13 -11
  19. data/lib/bioinform/conversion_algorithms/pcm2pwm_converter.rb +39 -11
  20. data/lib/bioinform/conversion_algorithms/pcm2pwm_mara_converter.rb +26 -0
  21. data/lib/bioinform/conversion_algorithms/ppm2pcm_converter.rb +30 -0
  22. data/lib/bioinform/conversion_algorithms/pwm2iupac_pwm_converter.rb +23 -0
  23. data/lib/bioinform/conversion_algorithms/pwm2pcm_converter.rb +85 -0
  24. data/lib/bioinform/data_models.rb +1 -7
  25. data/lib/bioinform/data_models/named_model.rb +38 -0
  26. data/lib/bioinform/data_models/pcm.rb +18 -28
  27. data/lib/bioinform/data_models/pm.rb +73 -170
  28. data/lib/bioinform/data_models/ppm.rb +11 -24
  29. data/lib/bioinform/data_models/pwm.rb +30 -56
  30. data/lib/bioinform/errors.rb +17 -0
  31. data/lib/bioinform/formatters.rb +4 -2
  32. data/lib/bioinform/formatters/consensus_formatter.rb +35 -0
  33. data/lib/bioinform/formatters/motif_formatter.rb +69 -0
  34. data/lib/bioinform/formatters/pretty_matrix_formatter.rb +36 -0
  35. data/lib/bioinform/formatters/transfac_formatter.rb +29 -37
  36. data/lib/bioinform/parsers.rb +1 -8
  37. data/lib/bioinform/parsers/matrix_parser.rb +44 -36
  38. data/lib/bioinform/parsers/motif_splitter.rb +45 -0
  39. data/lib/bioinform/support.rb +46 -14
  40. data/lib/bioinform/support/strip_doc.rb +1 -1
  41. data/lib/bioinform/version.rb +1 -1
  42. data/spec/alphabet_spec.rb +79 -0
  43. data/spec/background_spec.rb +57 -0
  44. data/spec/cli/cli_spec.rb +6 -6
  45. data/spec/cli/convert_motif_spec.rb +88 -88
  46. data/spec/cli/data/pcm2pwm/KLF4_f2.pwm.result +9 -9
  47. data/spec/cli/data/pcm2pwm/SP1_f1.pwm.result +11 -11
  48. data/spec/cli/pcm2pwm_spec.rb +22 -23
  49. data/spec/cli/shared_examples/convert_motif/motif_list_empty.rb +1 -1
  50. data/spec/cli/shared_examples/convert_motif/several_motifs_specified.rb +1 -1
  51. data/spec/cli/shared_examples/convert_motif/single_motif_specified.rb +5 -5
  52. data/spec/cli/shared_examples/convert_motif/yield_help_string.rb +2 -2
  53. data/spec/cli/shared_examples/convert_motif/yield_motif_conversion_error.rb +3 -3
  54. data/spec/cli/split_motifs_spec.rb +6 -21
  55. data/spec/converters/pcm2ppm_converter_spec.rb +32 -0
  56. data/spec/converters/pcm2pwm_converter_spec.rb +71 -0
  57. data/spec/converters/ppm2pcm_converter_spec.rb +32 -0
  58. data/spec/converters/pwm2iupac_pwm_converter_spec.rb +65 -0
  59. data/spec/converters/pwm2pcm_converter_spec.rb +57 -0
  60. data/spec/data_models/named_model_spec.rb +41 -0
  61. data/spec/data_models/pcm_spec.rb +114 -45
  62. data/spec/data_models/pm_spec.rb +132 -333
  63. data/spec/data_models/ppm_spec.rb +47 -44
  64. data/spec/data_models/pwm_spec.rb +85 -77
  65. data/spec/fabricators/motif_formats_fabricator.rb +116 -116
  66. data/spec/formatters/consensus_formatter_spec.rb +26 -0
  67. data/spec/formatters/raw_formatter_spec.rb +169 -0
  68. data/spec/parsers/matrix_parser_spec.rb +216 -0
  69. data/spec/parsers/motif_splitter_spec.rb +87 -0
  70. data/spec/spec_helper.rb +2 -2
  71. data/spec/spec_helper_source.rb +25 -5
  72. data/spec/support_spec.rb +31 -0
  73. metadata +43 -124
  74. data/bin/merge_into_collection +0 -4
  75. data/lib/bioinform/cli/merge_into_collection.rb +0 -80
  76. data/lib/bioinform/conversion_algorithms/ppm2pwm_converter.rb +0 -0
  77. data/lib/bioinform/data_models/collection.rb +0 -75
  78. data/lib/bioinform/data_models/motif.rb +0 -56
  79. data/lib/bioinform/formatters/raw_formatter.rb +0 -41
  80. data/lib/bioinform/parsers/jaspar_parser.rb +0 -35
  81. data/lib/bioinform/parsers/parser.rb +0 -92
  82. data/lib/bioinform/parsers/splittable_parser.rb +0 -57
  83. data/lib/bioinform/parsers/string_fantom_parser.rb +0 -35
  84. data/lib/bioinform/parsers/string_parser.rb +0 -72
  85. data/lib/bioinform/parsers/trivial_parser.rb +0 -34
  86. data/lib/bioinform/parsers/yaml_parser.rb +0 -35
  87. data/lib/bioinform/support/advanced_scan.rb +0 -8
  88. data/lib/bioinform/support/array_product.rb +0 -6
  89. data/lib/bioinform/support/array_zip.rb +0 -6
  90. data/lib/bioinform/support/collect_hash.rb +0 -7
  91. data/lib/bioinform/support/deep_dup.rb +0 -5
  92. data/lib/bioinform/support/delete_many.rb +0 -14
  93. data/lib/bioinform/support/inverf.rb +0 -13
  94. data/lib/bioinform/support/multiline_squish.rb +0 -6
  95. data/lib/bioinform/support/parameters.rb +0 -28
  96. data/lib/bioinform/support/partial_sums.rb +0 -16
  97. data/lib/bioinform/support/same_by.rb +0 -12
  98. data/lib/bioinform/support/third_part/active_support/core_ext/array/extract_options.rb +0 -29
  99. data/lib/bioinform/support/third_part/active_support/core_ext/hash/indifferent_access.rb +0 -23
  100. data/lib/bioinform/support/third_part/active_support/core_ext/hash/keys.rb +0 -54
  101. data/lib/bioinform/support/third_part/active_support/core_ext/module/attribute_accessors.rb +0 -64
  102. data/lib/bioinform/support/third_part/active_support/core_ext/object/try.rb +0 -57
  103. data/lib/bioinform/support/third_part/active_support/core_ext/string/access.rb +0 -99
  104. data/lib/bioinform/support/third_part/active_support/core_ext/string/behavior.rb +0 -6
  105. data/lib/bioinform/support/third_part/active_support/core_ext/string/filters.rb +0 -49
  106. data/lib/bioinform/support/third_part/active_support/core_ext/string/multibyte.rb +0 -72
  107. data/lib/bioinform/support/third_part/active_support/hash_with_indifferent_access.rb +0 -181
  108. data/lib/bioinform/support/third_part/active_support/multibyte.rb +0 -44
  109. data/lib/bioinform/support/third_part/active_support/multibyte/chars.rb +0 -476
  110. data/lib/bioinform/support/third_part/active_support/multibyte/exceptions.rb +0 -8
  111. data/lib/bioinform/support/third_part/active_support/multibyte/unicode.rb +0 -393
  112. data/lib/bioinform/support/third_part/active_support/multibyte/utils.rb +0 -60
  113. data/spec/cli/data/merge_into_collection/GABPA_f1.pwm +0 -14
  114. data/spec/cli/data/merge_into_collection/KLF4_f2.pwm +0 -11
  115. data/spec/cli/data/merge_into_collection/SP1_f1.pwm +0 -12
  116. data/spec/cli/data/merge_into_collection/collection.txt.result +0 -40
  117. data/spec/cli/data/merge_into_collection/collection.yaml.result +0 -188
  118. data/spec/cli/data/merge_into_collection/collection_pwm.yaml.result +0 -188
  119. data/spec/cli/data/merge_into_collection/pwm_folder/GABPA_f1.pwm +0 -14
  120. data/spec/cli/data/merge_into_collection/pwm_folder/KLF4_f2.pwm +0 -11
  121. data/spec/cli/data/merge_into_collection/pwm_folder/SP1_f1.pwm +0 -12
  122. data/spec/cli/data/split_motifs/collection.yaml +0 -188
  123. data/spec/cli/merge_into_collection_spec.rb +0 -100
  124. data/spec/data_models/collection_spec.rb +0 -98
  125. data/spec/data_models/motif_spec.rb +0 -224
  126. data/spec/fabricators/collection_fabricator.rb +0 -8
  127. data/spec/fabricators/motif_fabricator.rb +0 -33
  128. data/spec/fabricators/pcm_fabricator.rb +0 -25
  129. data/spec/fabricators/pm_fabricator.rb +0 -52
  130. data/spec/fabricators/ppm_fabricator.rb +0 -14
  131. data/spec/fabricators/pwm_fabricator.rb +0 -16
  132. data/spec/parsers/parser_spec.rb +0 -152
  133. data/spec/parsers/string_fantom_parser_spec.rb +0 -70
  134. data/spec/parsers/string_parser_spec.rb +0 -77
  135. data/spec/parsers/trivial_parser_spec.rb +0 -64
  136. data/spec/parsers/yaml_parser_spec.rb +0 -50
  137. data/spec/support/advanced_scan_spec.rb +0 -32
  138. data/spec/support/array_product_spec.rb +0 -15
  139. data/spec/support/array_zip_spec.rb +0 -15
  140. data/spec/support/collect_hash_spec.rb +0 -15
  141. data/spec/support/delete_many_spec.rb +0 -44
  142. data/spec/support/inverf_spec.rb +0 -19
  143. data/spec/support/multiline_squish_spec.rb +0 -25
  144. data/spec/support/partial_sums_spec.rb +0 -30
  145. data/spec/support/same_by_spec.rb +0 -36
@@ -6,4 +6,4 @@ class String
6
6
  def strip_doc
7
7
  gsub(/^#{self[/\A +/]}/,'')
8
8
  end
9
- end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Bioinform
2
- VERSION = "0.1.17"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,79 @@
1
+ require 'bioinform/alphabet'
2
+
3
+ describe Bioinform::ComplementableAlphabet do
4
+ specify "should raise if complement's complement is not original letter" do
5
+ expect{ Bioinform::ComplementableAlphabet.new([:A,:B,:X,:Y], [:X,:Y,:B,:A]) }.to raise_error Bioinform::Error
6
+ expect{ Bioinform::ComplementableAlphabet.new([:A,:B,:B,:C], [:C,:B,:B,:A]) }.to raise_error Bioinform::Error
7
+ expect{ Bioinform::ComplementableAlphabet.new([:A,:B,:X,:Y], [:X,:Y,:B,:A,:C]) }.to raise_error Bioinform::Error
8
+ end
9
+
10
+ context 'usage with alphabet non-symbolized, non-upcased' do
11
+ let(:alphabet) { Bioinform::ComplementableAlphabet.new([:a,:B,'x','Y'], ['X',:y,:A,'B']) }
12
+
13
+ specify{ expect(alphabet.alphabet).to eq [:A,:B,:X,:Y] }
14
+ specify{ expect(alphabet.complement_letter(:A)).to eq :X }
15
+ specify{ expect(alphabet.complement_letter(:x)).to eq :a }
16
+ specify{ expect(alphabet.complement_letter('B')).to eq 'Y' }
17
+ specify{ expect(alphabet.complement_letter('b')).to eq 'y' }
18
+
19
+ specify{ expect(alphabet.index_by_letter(:B)).to eq 1 }
20
+ specify{ expect(alphabet.index_by_letter(:b)).to eq 1 }
21
+ specify{ expect(alphabet.index_by_letter('B')).to eq 1 }
22
+ specify{ expect(alphabet.index_by_letter('b')).to eq 1 }
23
+ end
24
+
25
+ context 'with correct alphabet' do
26
+ specify{ expect{ Bioinform::ComplementableAlphabet.new([:A,:B,:X,:Y], [:X,:Y,:A,:B]) }.not_to raise_error }
27
+ let(:alphabet) { Bioinform::ComplementableAlphabet.new([:A,:B,:X,:Y], [:X,:Y,:A,:B]) }
28
+
29
+ specify{ expect(alphabet).to eq Bioinform::ComplementableAlphabet.new([:A,:B,:X,:Y], [:X,:Y,:A,:B]) }
30
+ specify{ expect(alphabet).not_to eq Bioinform::ComplementableAlphabet.new([:A,:C,:X,:Y], [:X,:Y,:A,:C]) }
31
+ specify{ expect(alphabet).not_to eq Bioinform::ComplementableAlphabet.new([:A,:B,:X,:Y], [:Y,:X,:B,:A]) }
32
+ specify{ expect(alphabet).not_to eq Bioinform::ComplementableAlphabet.new([:B,:A,:Y,:X], [:X,:Y,:A,:B]) }
33
+
34
+ specify{ expect(alphabet.alphabet).to eq [:A,:B,:X,:Y] }
35
+ specify{ expect(alphabet.complement_alphabet).to eq [:X,:Y,:A,:B] }
36
+ specify{ expect(alphabet.letter_by_index(2)).to eq :X }
37
+
38
+ specify{ expect(alphabet.complement_index(1)).to eq 3 } # :B --> :Y
39
+
40
+ specify{ expect{|b| alphabet.each_letter(&b) }.to yield_successive_args(:A,:B,:X,:Y) }
41
+ specify{ expect{|b| alphabet.each_letter.each(&b) }.to yield_successive_args(:A,:B,:X,:Y) }
42
+ specify{ expect{|b| alphabet.each_letter_index(&b) }.to yield_successive_args(0,1,2,3) }
43
+ specify{ expect{|b| alphabet.each_letter_index.each(&b) }.to yield_successive_args(0,1,2,3) }
44
+ end
45
+ end
46
+
47
+ describe Bioinform::NucleotideAlphabet do
48
+ specify { expect( Bioinform::NucleotideAlphabet.size ).to eq 4 }
49
+ specify { expect( Bioinform::NucleotideAlphabet.complement_letter(:A) ).to eq :T }
50
+ specify { expect( Bioinform::NucleotideAlphabet.complement_letter(:C) ).to eq :G }
51
+ specify { expect{ Bioinform::NucleotideAlphabet.complement_letter(:N) }.to raise_error Bioinform::Error }
52
+
53
+ specify { expect(Bioinform::NucleotideAlphabet.complement_index(0)).to eq 3 }
54
+ specify { expect{Bioinform::NucleotideAlphabet.complement_index(4)}.to raise_error Bioinform::Error}
55
+ end
56
+
57
+ describe Bioinform::NucleotideAlphabetWithN do
58
+ specify { expect( Bioinform::NucleotideAlphabetWithN.size ).to eq 5 }
59
+ specify { expect( Bioinform::NucleotideAlphabetWithN.complement_letter(:A) ).to eq :T }
60
+ specify { expect( Bioinform::NucleotideAlphabetWithN.complement_letter(:C) ).to eq :G }
61
+ specify { expect( Bioinform::NucleotideAlphabetWithN.complement_letter(:N) ).to eq :N }
62
+
63
+ specify { expect( Bioinform::NucleotideAlphabetWithN.complement_index(0) ).to eq 3 }
64
+ specify { expect( Bioinform::NucleotideAlphabetWithN.complement_index(4) ).to eq 4 }
65
+ end
66
+
67
+ describe Bioinform::IUPACAlphabet do
68
+ specify { expect( Bioinform::IUPACAlphabet.size ).to eq 15 }
69
+ specify { expect( Bioinform::IUPACAlphabet.complement_letter(:A) ).to eq :T }
70
+ specify { expect( Bioinform::IUPACAlphabet.complement_letter(:N) ).to eq :N }
71
+ specify { expect( Bioinform::IUPACAlphabet.complement_letter(:R) ).to eq :Y } # R = AG; Y = CT
72
+ specify { expect( Bioinform::IUPACAlphabet.complement_letter(:Y) ).to eq :R }
73
+ specify { expect( Bioinform::IUPACAlphabet.complement_letter(:W) ).to eq :W } # W = AT
74
+ specify { expect( Bioinform::IUPACAlphabet.complement_letter(:V) ).to eq :B } # V = ACG; B = CGT
75
+
76
+ specify { expect(Bioinform::IUPACAlphabet.complement_index(0)).to eq 3 }
77
+ specify { expect(Bioinform::IUPACAlphabet.complement_index(14)).to eq 14 } # N --> 4
78
+ specify { expect(Bioinform::IUPACAlphabet.complement_index(5)).to eq 8 } # R --> 5; Y --> 8
79
+ end
@@ -0,0 +1,57 @@
1
+ require 'bioinform/background'
2
+
3
+ describe Bioinform::Frequencies do
4
+ specify { expect{Bioinform::Frequencies.new([1,1,1,1]) }.to raise_error Bioinform::Error }
5
+ specify { expect{Bioinform::Frequencies.new([0.3,0.3,0.3,0.3]) }.to raise_error Bioinform::Error }
6
+ specify { expect{Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }.not_to raise_error }
7
+ specify { expect{Bioinform::Frequencies.new([0.2,0.3,0.3,0.2]) }.not_to raise_error }
8
+
9
+ let(:frequencies) { Bioinform::Frequencies.new([0.2,0.3,0.3,0.2]) }
10
+ specify { expect(frequencies.frequencies).to eq [0.2,0.3,0.3,0.2] }
11
+ specify { expect(frequencies.counts).to eq [0.2,0.3,0.3,0.2] }
12
+ specify { expect(frequencies.volume).to eq 1 }
13
+ specify { expect(frequencies).not_to be_wordwise }
14
+ specify { expect(frequencies).to eq Bioinform::Frequencies.new([0.2,0.3,0.3,0.2]) }
15
+ specify { expect(frequencies).not_to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
16
+
17
+ specify { expect(Bioinform::Frequencies.new([0.2,0.3,0.3,0.2])).not_to eq Bioinform::WordwiseBackground.new }
18
+ specify { expect(Bioinform::Frequencies.new([0.25,0.25,0.25,0.25])).not_to eq Bioinform::WordwiseBackground.new }
19
+
20
+ specify { expect(frequencies.mean([1,2,3,-4])).to eq(0.2*1 + 0.3*2 + 0.3*3 + 0.2*(-4)) }
21
+ specify { expect(frequencies.mean_square([1,2,3,-4])).to eq(0.2*1*1 + 0.3*2*2 + 0.3*3*3 + 0.2*(-4)*(-4)) }
22
+
23
+ end
24
+
25
+ describe Bioinform::WordwiseBackground do
26
+ specify { expect{Bioinform::WordwiseBackground.new }.not_to raise_error }
27
+ let(:frequencies) { Bioinform::WordwiseBackground.new }
28
+ specify { expect(frequencies.frequencies).to eq [0.25,0.25,0.25,0.25] }
29
+ specify { expect(frequencies.counts).to eq [1,1,1,1] }
30
+ specify { expect(frequencies.volume).to eq 4 }
31
+ specify { expect(frequencies).to be_wordwise }
32
+ specify { expect(frequencies).to eq Bioinform::WordwiseBackground.new }
33
+ specify { expect(frequencies).not_to eq Bioinform::Frequencies.new([0.2,0.3,0.3,0.2]) }
34
+ specify { expect(frequencies).not_to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
35
+
36
+ specify { expect(frequencies.mean([1,2,3,-4])).to eq(0.25*1 + 0.25*2 + 0.25*3 + 0.25*(-4)) }
37
+ specify { expect(frequencies.mean_square([1,2,3,-4])).to eq(0.25*1*1 + 0.25*2*2 + 0.25*3*3 + 0.25*(-4)*(-4)) }
38
+ end
39
+
40
+ describe Bioinform::Background do
41
+ specify { expect(Bioinform::Background.wordwise).to eq Bioinform::WordwiseBackground.new }
42
+ specify { expect(Bioinform::Background::Wordwise).to eq Bioinform::WordwiseBackground.new }
43
+ specify { expect(Bioinform::Background.uniform).to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
44
+ specify { expect(Bioinform::Background::Uniform).to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
45
+
46
+ specify { expect(Bioinform::Background.from_gc_content(0.5)).to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
47
+ specify { expect(Bioinform::Background.from_gc_content(0.6)).to eq Bioinform::Frequencies.new([0.2,0.3,0.3,0.2]) }
48
+
49
+ specify { expect(Bioinform::Background.from_string('0.2,0.3,0.3,0.2')).to eq Bioinform::Frequencies.new([0.2,0.3,0.3,0.2]) }
50
+ specify { expect(Bioinform::Background.from_string('0.25,0.25,0.25,0.25')).to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
51
+ specify { expect(Bioinform::Background.from_string('1,1,1,1')).to eq Bioinform::WordwiseBackground.new }
52
+ specify { expect(Bioinform::Background.from_string('uniform')).to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
53
+ specify { expect(Bioinform::Background.from_string('UNIFORM')).to eq Bioinform::Frequencies.new([0.25,0.25,0.25,0.25]) }
54
+ specify { expect(Bioinform::Background.from_string('wordwise')).to eq Bioinform::WordwiseBackground.new }
55
+ specify { expect{Bioinform::Background.from_string('0.25,0.25,0.25')}.to raise_error Bioinform::Error }
56
+ specify { expect{Bioinform::Background.from_string('unifromm')}.to raise_error Bioinform::Error }
57
+ end
data/spec/cli/cli_spec.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require_relative '../spec_helper'
2
- require_relative '../../lib/bioinform/cli'
2
+ require 'bioinform/cli'
3
3
 
4
4
  describe Bioinform::CLI do
5
5
  describe '.change_folder_and_extension' do
6
6
  it 'should change extension and folder' do
7
7
  extend Bioinform::CLI::Helpers
8
- change_folder_and_extension('test.pcm', 'pwm', '.').should == './test.pwm'
9
- change_folder_and_extension('test.pcm', 'pat', 'pwm_folder').should == 'pwm_folder/test.pat'
10
- change_folder_and_extension('pcm/test.pcm', 'pat', 'pwm_folder').should == 'pwm_folder/test.pat'
11
- change_folder_and_extension('test.pcm', 'pat', '../pwm_folder').should == '../pwm_folder/test.pat'
8
+ expect( change_folder_and_extension('test.pcm', 'pwm', '.') ).to eq './test.pwm'
9
+ expect( change_folder_and_extension('test.pcm', 'pat', 'pwm_folder') ).to eq 'pwm_folder/test.pat'
10
+ expect( change_folder_and_extension('pcm/test.pcm', 'pat', 'pwm_folder') ).to eq 'pwm_folder/test.pat'
11
+ expect( change_folder_and_extension('test.pcm', 'pat', '../pwm_folder') ).to eq '../pwm_folder/test.pat'
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -1,107 +1,107 @@
1
- require 'shellwords'
2
- require_relative '../spec_helper'
3
- require_relative '../../lib/bioinform/cli/convert_motif'
4
- require_relative 'shared_examples/convert_motif/single_motif_specified'
5
- require_relative 'shared_examples/convert_motif/several_motifs_specified'
6
- require_relative 'shared_examples/convert_motif/motif_list_empty'
7
- require_relative 'shared_examples/convert_motif/yield_motif_conversion_error'
1
+ # require 'shellwords'
2
+ # require_relative '../spec_helper'
3
+ # require 'bioinform/cli/convert_motif'
4
+ # require_relative 'shared_examples/convert_motif/single_motif_specified'
5
+ # require_relative 'shared_examples/convert_motif/several_motifs_specified'
6
+ # require_relative 'shared_examples/convert_motif/motif_list_empty'
7
+ # require_relative 'shared_examples/convert_motif/yield_motif_conversion_error'
8
8
 
9
- def make_option_list(options = {})
10
- result = []
11
- result << '--from' << options[:model_from] if options[:model_from]
12
- result << '--to' << options[:model_to] if options[:model_to]
13
- result << '--parser' << options[:parser] if options[:parser]
14
- result << '--formatter' << options[:formatter] if options[:formatter]
15
- result << (options[:silent] ? '--silent' : '--no-silent') if options.has_key?(:silent)
16
- result << (options[:force] ? '--force' : '--no-force') if options.has_key?(:force)
17
- result << '--save' << options[:filename_format] if options[:filename_format]
18
- result << '--algorithm' << options[:algorithm] if options[:algorithm]
19
- result
20
- end
9
+ # def make_option_list(options = {})
10
+ # result = []
11
+ # result << '--from' << options[:model_from] if options[:model_from]
12
+ # result << '--to' << options[:model_to] if options[:model_to]
13
+ # result << '--parser' << options[:parser] if options[:parser]
14
+ # result << '--formatter' << options[:formatter] if options[:formatter]
15
+ # result << (options[:silent] ? '--silent' : '--no-silent') if options.has_key?(:silent)
16
+ # result << (options[:force] ? '--force' : '--no-force') if options.has_key?(:force)
17
+ # result << '--save' << options[:filename_format] if options[:filename_format]
18
+ # result << '--algorithm' << options[:algorithm] if options[:algorithm]
19
+ # result
20
+ # end
21
21
 
22
22
 
23
- shared_context 'most common options' do
24
- Given(:parser) { 'plain' }
25
- Given(:formatter) { 'plain' }
26
- Given(:silent) { true }
27
- Given(:force) { false }
28
- Given(:filename_format) { nil }
29
- Given(:algorithm) { nil }
30
- end
23
+ # shared_context 'most common options' do
24
+ # Given(:parser) { 'plain' }
25
+ # Given(:formatter) { 'plain' }
26
+ # Given(:silent) { true }
27
+ # Given(:force) { false }
28
+ # Given(:filename_format) { nil }
29
+ # Given(:algorithm) { nil }
30
+ # end
31
31
 
32
- shared_context 'completely specified option list' do
33
- Given(:options) {
34
- make_option_list( model_from: model_from, model_to: model_to,
35
- parser: parser, formatter: formatter,
36
- silent: silent, force: force,
37
- filename_format: filename_format,
38
- algorithm: algorithm ).shelljoin
39
- }
40
- end
32
+ # shared_context 'completely specified option list' do
33
+ # Given(:options) {
34
+ # make_option_list( model_from: model_from, model_to: model_to,
35
+ # parser: parser, formatter: formatter,
36
+ # silent: silent, force: force,
37
+ # filename_format: filename_format,
38
+ # algorithm: algorithm ).shelljoin
39
+ # }
40
+ # end
41
41
 
42
- shared_context 'input filenames are motif_name.motif_type' do
43
- Given(:input_filenames) { motif_list.map{|motif| motif_filename(motif, model_from) }.shelljoin }
44
- end
42
+ # shared_context 'input filenames are motif_name.motif_type' do
43
+ # Given(:input_filenames) { motif_list.map{|motif| motif_filename(motif, model_from) }.shelljoin }
44
+ # end
45
45
 
46
- ##################################
46
+ # ##################################
47
47
 
48
- describe Bioinform::CLI::ConvertMotif do
49
- include FakeFS::SpecHelpers
50
- Given(:resulting_stdout) { resulting_io[:stdout] }
51
- Given(:resulting_stderr) { resulting_io[:stderr] }
48
+ # describe Bioinform::CLI::ConvertMotif do
49
+ # include FakeFS::SpecHelpers
50
+ # Given(:resulting_stdout) { resulting_io[:stdout] }
51
+ # Given(:resulting_stderr) { resulting_io[:stderr] }
52
52
 
53
- Given(:command) { options.shellsplit + arguments.shellsplit }
53
+ # Given(:command) { options.shellsplit + arguments.shellsplit }
54
54
 
55
- Given(:sp1_f1){ Fabricate(:SP1_f1_plain_text) }
56
- Given(:klf4_f2){ Fabricate(:KLF4_f2_plain_text) }
55
+ # Given(:sp1_f1){ Fabricate(:SP1_f1_plain_text) }
56
+ # Given(:klf4_f2){ Fabricate(:KLF4_f2_plain_text) }
57
57
 
58
- ########################################################
58
+ # ########################################################
59
59
 
60
- context 'when program not piped' do
61
- Given(:arguments) { input_filenames }
62
- Given(:resulting_io) {
63
- capture_io{
64
- Bioinform::CLI::ConvertMotif.main(command)
65
- }
66
- }
67
- include_context 'input filenames are motif_name.motif_type'
60
+ # context 'when program not piped' do
61
+ # Given(:arguments) { input_filenames }
62
+ # Given(:resulting_io) {
63
+ # capture_io{
64
+ # Bioinform::CLI::ConvertMotif.main(command)
65
+ # }
66
+ # }
67
+ # include_context 'input filenames are motif_name.motif_type'
68
68
 
69
- context 'with most options specified' do
70
- include_context 'completely specified option list'
71
- include_context 'most common options'
69
+ # context 'with most options specified' do
70
+ # include_context 'completely specified option list'
71
+ # include_context 'most common options'
72
72
 
73
- include_examples 'single motif specified'
74
- include_examples 'several motifs specified'
75
- end
73
+ # include_examples 'single motif specified'
74
+ # include_examples 'several motifs specified'
75
+ # end
76
76
 
77
- include_examples 'motif list is empty'
78
- end
77
+ # include_examples 'motif list is empty'
78
+ # end
79
79
 
80
- ########################################################
80
+ # ########################################################
81
81
 
82
- context 'when program is piped' do
83
- # include_context 'completely specified option list'
84
- # include_context 'most common options'
85
- include_context 'input filenames are motif_name.motif_type'
82
+ # context 'when program is piped' do
83
+ # # include_context 'completely specified option list'
84
+ # # include_context 'most common options'
85
+ # include_context 'input filenames are motif_name.motif_type'
86
86
 
87
- Given(:tty){ false }
88
- Given(:stdin_data) { input_filenames }
89
- Given(:arguments) { '' }
90
- Given(:resulting_io) {
91
- capture_io{
92
- provide_stdin(stdin_data, tty) {
93
- Bioinform::CLI::ConvertMotif.main(command)
94
- }
95
- }
96
- }
87
+ # Given(:tty){ false }
88
+ # Given(:stdin_data) { input_filenames }
89
+ # Given(:arguments) { '' }
90
+ # Given(:resulting_io) {
91
+ # capture_io{
92
+ # provide_stdin(stdin_data, tty) {
93
+ # Bioinform::CLI::ConvertMotif.main(command)
94
+ # }
95
+ # }
96
+ # }
97
97
 
98
- include_examples 'motif list is empty'
99
- context 'with most options specified' do
100
- include_context 'completely specified option list'
101
- include_context 'most common options'
98
+ # include_examples 'motif list is empty'
99
+ # context 'with most options specified' do
100
+ # include_context 'completely specified option list'
101
+ # include_context 'most common options'
102
102
 
103
- include_examples 'single motif specified'
104
- include_examples 'several motifs specified'
105
- end
106
- end
107
- end
103
+ # include_examples 'single motif specified'
104
+ # include_examples 'several motifs specified'
105
+ # end
106
+ # end
107
+ # end
@@ -1,11 +1,11 @@
1
- KLF4_f2
1
+ >KLF4_f2
2
2
  0.30861857265872605 -2.254321000121579 0.13505703522674192 0.3285194224375633
3
- -1.227018967707036 -4.814127713368663 1.3059890687390967 -4.908681463544344
4
- -2.443469374521196 -4.648238485031404 1.3588686548279805 -4.441801801188402
5
- -2.7177827948276123 -3.8073538975356565 1.356272809724262 -3.504104725510225
6
- -0.5563232977367343 0.5340697765121405 -3.61417723090579 0.5270259776377405
3
+ -1.2270189677070362 -4.814127713368663 1.3059890687390965 -4.908681463544344
4
+ -2.4434693745211966 -4.648238485031404 1.3588686548279802 -4.441801801188402
5
+ -2.7177827948276128 -3.807353897535657 1.3562728097242616 -3.504104725510225
6
+ -0.5563232977367345 0.5340697765121402 -3.61417723090579 0.5270259776377402
7
7
  -1.8687622060887386 -4.381483976582316 1.337932245336098 -3.815629658877517
8
- -2.045671123823928 -2.384975142213679 0.7198551207724355 0.5449254135616948
9
- -1.373157530374372 -3.0063112097748217 1.285188335493552 -2.5026044231773543
10
- -2.1030513122772208 -1.8941348100402244 1.249265758393991 -1.4284210948906104
11
- -1.3277128628152939 0.8982415633049462 -0.8080773665408135 -0.18161647647456935
8
+ -2.0456711238239285 -2.3849751422136793 0.7198551207724353 0.5449254135616943
9
+ -1.3731575303743726 -3.006311209774822 1.2851883354935514 -2.5026044231773548
10
+ -2.103051312277221 -1.8941348100402247 1.249265758393991 -1.4284210948906106
11
+ -1.327712862815294 0.898241563304946 -0.8080773665408136 -0.1816164764745695
@@ -1,12 +1,12 @@
1
- SP1_f1
1
+ >SP1_f1
2
2
  -0.24435707885585292 -0.674823404693731 0.8657012535789866 -1.1060188862599287
3
- -1.0631255752097797 -2.111925969423868 1.0960627561110403 -0.6138563775211977
4
- -0.3872276234760535 -2.9739851913218045 1.1807800242010378 -4.338927525031566
5
- -4.563896055436894 -2.9161633002532277 1.3684371349982638 -5.077972423609655
6
- -2.2369752892820083 -3.7196436313301846 1.3510439136452734 -4.889930670508233
7
- -0.07473964149330865 0.944919654762011 -2.6246857648086044 -0.8510983487822436
8
- -1.9643526491643322 -2.978402770880115 1.3113096718240573 -2.324334259499025
9
- -4.0155484139655835 -3.1384268078096667 1.3387488589788057 -2.084673903537648
10
- -0.44509385828355363 -2.2510053061629702 1.1265431574368685 -1.7780413702431372
11
- -1.1896356092245048 -1.2251832285630027 1.1636760063747527 -1.6080243648157353
12
- -0.5166047365590571 0.7641033353626657 -0.2862677570028208 -0.68254820978656
3
+ -1.063125575209786 -2.111925969423874 1.096062756111034 -0.6138563775212038
4
+ -0.38722762347606526 -2.9739851913218165 1.180780024201026 -4.338927525031577
5
+ -4.563896055436912 -2.916163300253245 1.3684371349982463 -5.077972423609672
6
+ -2.2369752892820247 -3.7196436313302015 1.3510439136452568 -4.8899306705082495
7
+ -0.07473964149331284 0.9449196547620068 -2.6246857648086084 -0.8510983487822477
8
+ -1.9643526491643477 -2.9784027708801304 1.3113096718240418 -2.3243342594990404
9
+ -4.015548413965599 -3.138426807809682 1.3387488589787901 -2.0846739035376634
10
+ -0.44509385828356285 -2.2510053061629796 1.1265431574368594 -1.7780413702431463
11
+ -1.1896356092245128 -1.2251832285630104 1.1636760063747449 -1.608024364815743
12
+ -0.5166047365590577 0.7641033353626651 -0.28626775700282125 -0.6825482097865606
@@ -1,6 +1,6 @@
1
1
  require 'shellwords'
2
2
  require_relative '../spec_helper'
3
- require_relative '../../lib/bioinform/cli/pcm2pwm'
3
+ require 'bioinform/cli/pcm2pwm'
4
4
 
5
5
 
6
6
  def run_pcm2pwm(cmd)
@@ -23,58 +23,57 @@ describe Bioinform::CLI::PCM2PWM do
23
23
 
24
24
  it 'should transform single PCM to PWM' do
25
25
  run_pcm2pwm('KLF4_f2.pcm')
26
- File.exist?('KLF4_f2.pwm').should be_true
27
- File.read('KLF4_f2.pwm').should == File.read('KLF4_f2.pwm.result')
26
+ expect(File.exist?('KLF4_f2.pwm')).to be_truthy
27
+ expect(File.read('KLF4_f2.pwm')).to eq File.read('KLF4_f2.pwm.result')
28
28
  end
29
29
 
30
30
  it 'should transform multiple PCMs to PWMs' do
31
31
  run_pcm2pwm('KLF4_f2.pcm SP1_f1.pcm')
32
32
 
33
- File.exist?('KLF4_f2.pwm').should be_true
34
- File.read('KLF4_f2.pwm').should == File.read('KLF4_f2.pwm.result')
33
+ expect(File.exist?('KLF4_f2.pwm')).to be_truthy
34
+ expect(File.read('KLF4_f2.pwm')).to eq File.read('KLF4_f2.pwm.result')
35
35
 
36
- File.exist?('SP1_f1.pwm').should be_true
37
- File.read('SP1_f1.pwm').should == File.read('SP1_f1.pwm.result')
36
+ expect(File.exist?('SP1_f1.pwm')).to be_truthy
37
+ expect(File.read('SP1_f1.pwm')).to eq File.read('SP1_f1.pwm.result')
38
38
  end
39
39
 
40
40
  it 'should transform extension to specified with --extension option' do
41
41
  run_pcm2pwm('KLF4_f2.pcm --extension=pat')
42
- File.exist?('KLF4_f2.pat').should be_true
43
- File.read('KLF4_f2.pat').should == File.read('KLF4_f2.pwm.result')
42
+ expect(File.exist?('KLF4_f2.pat')).to be_truthy
43
+ expect(File.read('KLF4_f2.pat')).to eq File.read('KLF4_f2.pwm.result')
44
44
  end
45
45
 
46
46
  it 'should save PWMs into folder specified with --folder option when folder exists' do
47
47
  Dir.mkdir('pwm_folder') unless Dir.exist?('pwm_folder')
48
48
  run_pcm2pwm('KLF4_f2.pcm --folder=pwm_folder')
49
- File.exist?('pwm_folder/KLF4_f2.pwm').should be_true
50
- File.read('pwm_folder/KLF4_f2.pwm').should == File.read('KLF4_f2.pwm.result')
49
+ expect(File.exist?('pwm_folder/KLF4_f2.pwm')).to be_truthy
50
+ expect(File.read('pwm_folder/KLF4_f2.pwm')).to eq File.read('KLF4_f2.pwm.result')
51
51
  end
52
52
  it 'should save PWMs into folder specified with --folder option' do
53
53
  FileUtils.rm_rf('pwm_folder') if Dir.exist?('pwm_folder')
54
54
  run_pcm2pwm('KLF4_f2.pcm --folder=pwm_folder')
55
- File.exist?('pwm_folder/KLF4_f2.pwm').should be_true
56
- File.read('pwm_folder/KLF4_f2.pwm').should == File.read('KLF4_f2.pwm.result')
55
+ expect(File.exist?('pwm_folder/KLF4_f2.pwm')).to be_truthy
56
+ expect(File.read('pwm_folder/KLF4_f2.pwm')).to eq File.read('KLF4_f2.pwm.result')
57
57
  end
58
58
 
59
59
  it 'should process PCMs with names obtained from STDIN' do
60
60
  provide_stdin('KLF4_f2.pcm SP1_f1.pcm') { run_pcm2pwm('') }
61
- File.exist?('KLF4_f2.pwm').should be_true
62
- File.read('KLF4_f2.pwm').should == File.read('KLF4_f2.pwm.result')
61
+ expect(File.exist?('KLF4_f2.pwm')).to be_truthy
62
+ expect(File.read('KLF4_f2.pwm')).to eq File.read('KLF4_f2.pwm.result')
63
63
 
64
- File.exist?('SP1_f1.pwm').should be_true
65
- File.read('SP1_f1.pwm').should == File.read('SP1_f1.pwm.result')
64
+ expect(File.exist?('SP1_f1.pwm')).to be_truthy
65
+ expect(File.read('SP1_f1.pwm')).to eq File.read('SP1_f1.pwm.result')
66
66
  end
67
67
 
68
68
  it 'should process PCMs with names obtained from STDIN when there are some options' do
69
69
  provide_stdin('KLF4_f2.pcm') { run_pcm2pwm('-e pat') }
70
- File.exist?('KLF4_f2.pat').should be_true
71
- File.read('KLF4_f2.pat').should == File.read('KLF4_f2.pwm.result')
70
+ expect(File.exist?('KLF4_f2.pat')).to be_truthy
71
+ expect(File.read('KLF4_f2.pat')).to eq File.read('KLF4_f2.pwm.result')
72
72
  end
73
73
 
74
74
  it 'should process PCMs having filename with spaces' do
75
75
  run_pcm2pwm('"KLF4 f2 spaced name.pcm"')
76
- File.exist?('KLF4 f2 spaced name.pwm').should be_true
77
- File.read('KLF4 f2 spaced name.pwm').should == File.read('KLF4_f2.pwm.result')
76
+ expect(File.exist?('KLF4 f2 spaced name.pwm')).to be_truthy
77
+ expect(File.read('KLF4 f2 spaced name.pwm')).to eq File.read('KLF4_f2.pwm.result')
78
78
  end
79
-
80
- end
79
+ end