bioinform 0.1.17 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/LICENSE +0 -1
- data/README.md +1 -1
- data/TODO.txt +23 -30
- data/bin/convert_motif +4 -0
- data/bin/pcm2pwm +1 -1
- data/bin/split_motifs +1 -1
- data/bioinform.gemspec +0 -2
- data/lib/bioinform.rb +54 -16
- data/lib/bioinform/alphabet.rb +85 -0
- data/lib/bioinform/background.rb +90 -0
- data/lib/bioinform/cli.rb +1 -2
- data/lib/bioinform/cli/convert_motif.rb +52 -17
- data/lib/bioinform/cli/pcm2pwm.rb +32 -26
- data/lib/bioinform/cli/split_motifs.rb +31 -30
- data/lib/bioinform/conversion_algorithms.rb +6 -0
- data/lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb +13 -11
- data/lib/bioinform/conversion_algorithms/pcm2pwm_converter.rb +39 -11
- data/lib/bioinform/conversion_algorithms/pcm2pwm_mara_converter.rb +26 -0
- data/lib/bioinform/conversion_algorithms/ppm2pcm_converter.rb +30 -0
- data/lib/bioinform/conversion_algorithms/pwm2iupac_pwm_converter.rb +23 -0
- data/lib/bioinform/conversion_algorithms/pwm2pcm_converter.rb +85 -0
- data/lib/bioinform/data_models.rb +1 -7
- data/lib/bioinform/data_models/named_model.rb +38 -0
- data/lib/bioinform/data_models/pcm.rb +18 -28
- data/lib/bioinform/data_models/pm.rb +73 -170
- data/lib/bioinform/data_models/ppm.rb +11 -24
- data/lib/bioinform/data_models/pwm.rb +30 -56
- data/lib/bioinform/errors.rb +17 -0
- data/lib/bioinform/formatters.rb +4 -2
- data/lib/bioinform/formatters/consensus_formatter.rb +35 -0
- data/lib/bioinform/formatters/motif_formatter.rb +69 -0
- data/lib/bioinform/formatters/pretty_matrix_formatter.rb +36 -0
- data/lib/bioinform/formatters/transfac_formatter.rb +29 -37
- data/lib/bioinform/parsers.rb +1 -8
- data/lib/bioinform/parsers/matrix_parser.rb +44 -36
- data/lib/bioinform/parsers/motif_splitter.rb +45 -0
- data/lib/bioinform/support.rb +46 -14
- data/lib/bioinform/support/strip_doc.rb +1 -1
- data/lib/bioinform/version.rb +1 -1
- data/spec/alphabet_spec.rb +79 -0
- data/spec/background_spec.rb +57 -0
- data/spec/cli/cli_spec.rb +6 -6
- data/spec/cli/convert_motif_spec.rb +88 -88
- data/spec/cli/data/pcm2pwm/KLF4_f2.pwm.result +9 -9
- data/spec/cli/data/pcm2pwm/SP1_f1.pwm.result +11 -11
- data/spec/cli/pcm2pwm_spec.rb +22 -23
- data/spec/cli/shared_examples/convert_motif/motif_list_empty.rb +1 -1
- data/spec/cli/shared_examples/convert_motif/several_motifs_specified.rb +1 -1
- data/spec/cli/shared_examples/convert_motif/single_motif_specified.rb +5 -5
- data/spec/cli/shared_examples/convert_motif/yield_help_string.rb +2 -2
- data/spec/cli/shared_examples/convert_motif/yield_motif_conversion_error.rb +3 -3
- data/spec/cli/split_motifs_spec.rb +6 -21
- data/spec/converters/pcm2ppm_converter_spec.rb +32 -0
- data/spec/converters/pcm2pwm_converter_spec.rb +71 -0
- data/spec/converters/ppm2pcm_converter_spec.rb +32 -0
- data/spec/converters/pwm2iupac_pwm_converter_spec.rb +65 -0
- data/spec/converters/pwm2pcm_converter_spec.rb +57 -0
- data/spec/data_models/named_model_spec.rb +41 -0
- data/spec/data_models/pcm_spec.rb +114 -45
- data/spec/data_models/pm_spec.rb +132 -333
- data/spec/data_models/ppm_spec.rb +47 -44
- data/spec/data_models/pwm_spec.rb +85 -77
- data/spec/fabricators/motif_formats_fabricator.rb +116 -116
- data/spec/formatters/consensus_formatter_spec.rb +26 -0
- data/spec/formatters/raw_formatter_spec.rb +169 -0
- data/spec/parsers/matrix_parser_spec.rb +216 -0
- data/spec/parsers/motif_splitter_spec.rb +87 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_source.rb +25 -5
- data/spec/support_spec.rb +31 -0
- metadata +43 -124
- data/bin/merge_into_collection +0 -4
- data/lib/bioinform/cli/merge_into_collection.rb +0 -80
- data/lib/bioinform/conversion_algorithms/ppm2pwm_converter.rb +0 -0
- data/lib/bioinform/data_models/collection.rb +0 -75
- data/lib/bioinform/data_models/motif.rb +0 -56
- data/lib/bioinform/formatters/raw_formatter.rb +0 -41
- data/lib/bioinform/parsers/jaspar_parser.rb +0 -35
- data/lib/bioinform/parsers/parser.rb +0 -92
- data/lib/bioinform/parsers/splittable_parser.rb +0 -57
- data/lib/bioinform/parsers/string_fantom_parser.rb +0 -35
- data/lib/bioinform/parsers/string_parser.rb +0 -72
- data/lib/bioinform/parsers/trivial_parser.rb +0 -34
- data/lib/bioinform/parsers/yaml_parser.rb +0 -35
- data/lib/bioinform/support/advanced_scan.rb +0 -8
- data/lib/bioinform/support/array_product.rb +0 -6
- data/lib/bioinform/support/array_zip.rb +0 -6
- data/lib/bioinform/support/collect_hash.rb +0 -7
- data/lib/bioinform/support/deep_dup.rb +0 -5
- data/lib/bioinform/support/delete_many.rb +0 -14
- data/lib/bioinform/support/inverf.rb +0 -13
- data/lib/bioinform/support/multiline_squish.rb +0 -6
- data/lib/bioinform/support/parameters.rb +0 -28
- data/lib/bioinform/support/partial_sums.rb +0 -16
- data/lib/bioinform/support/same_by.rb +0 -12
- data/lib/bioinform/support/third_part/active_support/core_ext/array/extract_options.rb +0 -29
- data/lib/bioinform/support/third_part/active_support/core_ext/hash/indifferent_access.rb +0 -23
- data/lib/bioinform/support/third_part/active_support/core_ext/hash/keys.rb +0 -54
- data/lib/bioinform/support/third_part/active_support/core_ext/module/attribute_accessors.rb +0 -64
- data/lib/bioinform/support/third_part/active_support/core_ext/object/try.rb +0 -57
- data/lib/bioinform/support/third_part/active_support/core_ext/string/access.rb +0 -99
- data/lib/bioinform/support/third_part/active_support/core_ext/string/behavior.rb +0 -6
- data/lib/bioinform/support/third_part/active_support/core_ext/string/filters.rb +0 -49
- data/lib/bioinform/support/third_part/active_support/core_ext/string/multibyte.rb +0 -72
- data/lib/bioinform/support/third_part/active_support/hash_with_indifferent_access.rb +0 -181
- data/lib/bioinform/support/third_part/active_support/multibyte.rb +0 -44
- data/lib/bioinform/support/third_part/active_support/multibyte/chars.rb +0 -476
- data/lib/bioinform/support/third_part/active_support/multibyte/exceptions.rb +0 -8
- data/lib/bioinform/support/third_part/active_support/multibyte/unicode.rb +0 -393
- data/lib/bioinform/support/third_part/active_support/multibyte/utils.rb +0 -60
- data/spec/cli/data/merge_into_collection/GABPA_f1.pwm +0 -14
- data/spec/cli/data/merge_into_collection/KLF4_f2.pwm +0 -11
- data/spec/cli/data/merge_into_collection/SP1_f1.pwm +0 -12
- data/spec/cli/data/merge_into_collection/collection.txt.result +0 -40
- data/spec/cli/data/merge_into_collection/collection.yaml.result +0 -188
- data/spec/cli/data/merge_into_collection/collection_pwm.yaml.result +0 -188
- data/spec/cli/data/merge_into_collection/pwm_folder/GABPA_f1.pwm +0 -14
- data/spec/cli/data/merge_into_collection/pwm_folder/KLF4_f2.pwm +0 -11
- data/spec/cli/data/merge_into_collection/pwm_folder/SP1_f1.pwm +0 -12
- data/spec/cli/data/split_motifs/collection.yaml +0 -188
- data/spec/cli/merge_into_collection_spec.rb +0 -100
- data/spec/data_models/collection_spec.rb +0 -98
- data/spec/data_models/motif_spec.rb +0 -224
- data/spec/fabricators/collection_fabricator.rb +0 -8
- data/spec/fabricators/motif_fabricator.rb +0 -33
- data/spec/fabricators/pcm_fabricator.rb +0 -25
- data/spec/fabricators/pm_fabricator.rb +0 -52
- data/spec/fabricators/ppm_fabricator.rb +0 -14
- data/spec/fabricators/pwm_fabricator.rb +0 -16
- data/spec/parsers/parser_spec.rb +0 -152
- data/spec/parsers/string_fantom_parser_spec.rb +0 -70
- data/spec/parsers/string_parser_spec.rb +0 -77
- data/spec/parsers/trivial_parser_spec.rb +0 -64
- data/spec/parsers/yaml_parser_spec.rb +0 -50
- data/spec/support/advanced_scan_spec.rb +0 -32
- data/spec/support/array_product_spec.rb +0 -15
- data/spec/support/array_zip_spec.rb +0 -15
- data/spec/support/collect_hash_spec.rb +0 -15
- data/spec/support/delete_many_spec.rb +0 -44
- data/spec/support/inverf_spec.rb +0 -19
- data/spec/support/multiline_squish_spec.rb +0 -25
- data/spec/support/partial_sums_spec.rb +0 -30
- data/spec/support/same_by_spec.rb +0 -36
@@ -9,6 +9,6 @@ shared_examples 'several motifs specified' do
|
|
9
9
|
Given(:motif_list) { [sp1_f1, klf4_f2] }
|
10
10
|
Given(:model_from) { 'pcm' }
|
11
11
|
Given(:model_to) { 'pwm' }
|
12
|
-
Then { resulting_stdout.
|
12
|
+
Then { expect(resulting_stdout).to eq [sp1_f1.pwm, klf4_f2.pwm].join("\n") }
|
13
13
|
end
|
14
14
|
end
|
@@ -12,12 +12,12 @@ shared_examples 'single motif specified' do
|
|
12
12
|
|
13
13
|
context 'pwm conversion invoked' do
|
14
14
|
Given(:model_to) { 'pwm' }
|
15
|
-
Then { resulting_stdout.
|
15
|
+
Then { expect(resulting_stdout).to eq sp1_f1.pwm }
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'ppm conversion invoked' do
|
19
19
|
Given(:model_to) { 'ppm' }
|
20
|
-
Then { resulting_stdout.
|
20
|
+
Then { expect(resulting_stdout).to eq sp1_f1.ppm }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -42,9 +42,9 @@ shared_examples 'single motif specified' do
|
|
42
42
|
}
|
43
43
|
Given(:model_from) { 'pcm' }
|
44
44
|
Given(:model_to) { 'pwm' }
|
45
|
-
Then { resulting_stdout.
|
46
|
-
Then { resulting_stdout.
|
45
|
+
Then { expect(resulting_stdout).to eq sp1_f1.pwm }
|
46
|
+
Then { expect(resulting_stdout).not_to match(klf4_f2.pwm) }
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
50
|
-
end
|
50
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
1
|
shared_examples 'yields motif conversion error' do
|
2
|
-
Then { resulting_stderr.
|
3
|
-
Then { resulting_stderr.
|
4
|
-
end
|
2
|
+
Then { expect(resulting_stderr).to match "One can't convert from #{model_from} data-model to #{model_to} data-model" }
|
3
|
+
Then { expect(resulting_stderr).to match "Error! Conversion wasn't performed" }
|
4
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative '../spec_helper'
|
2
|
-
|
2
|
+
require 'bioinform/cli/split_motifs'
|
3
3
|
|
4
4
|
def run_split_motifs(cmd)
|
5
5
|
Bioinform::CLI::SplitMotifs.main(cmd.shellsplit)
|
@@ -23,14 +23,14 @@ describe Bioinform::CLI::SplitMotifs do
|
|
23
23
|
it 'splits plain text into separate files' do
|
24
24
|
run_split_motifs('plain_collection.txt')
|
25
25
|
@motifs_in_collection.each do |motif_name|
|
26
|
-
File.exist?("#{motif_name}.mat").
|
26
|
+
expect(File.exist?("#{motif_name}.mat")).to be_truthy
|
27
27
|
File.read("#{motif_name}.mat") == File.read("#{motif_name}.mat.result")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
it 'create files with specified extension' do
|
31
31
|
run_split_motifs('plain_collection.txt -e pwm')
|
32
32
|
@motifs_in_collection.each do |motif_name|
|
33
|
-
File.exist?("#{motif_name}.pwm").
|
33
|
+
expect(File.exist?("#{motif_name}.pwm")).to be_truthy
|
34
34
|
File.read("#{motif_name}.pwm") == File.read("#{motif_name}.mat.result")
|
35
35
|
end
|
36
36
|
end
|
@@ -42,7 +42,7 @@ describe Bioinform::CLI::SplitMotifs do
|
|
42
42
|
it 'create files in specified folder' do
|
43
43
|
run_split_motifs('plain_collection.txt -f result_folder')
|
44
44
|
@motifs_in_collection.each do |motif_name|
|
45
|
-
File.exist?(File.join('result_folder', "#{motif_name}.mat")).
|
45
|
+
expect(File.exist?(File.join('result_folder', "#{motif_name}.mat"))).to be_truthy
|
46
46
|
File.read(File.join('result_folder', "#{motif_name}.mat")) == File.read("#{motif_name}.mat.result")
|
47
47
|
end
|
48
48
|
end
|
@@ -54,24 +54,9 @@ describe Bioinform::CLI::SplitMotifs do
|
|
54
54
|
it 'create files in specified folder' do
|
55
55
|
run_split_motifs('plain_collection.txt -f result_folder')
|
56
56
|
@motifs_in_collection.each do |motif_name|
|
57
|
-
File.exist?(File.join('result_folder', "#{motif_name}.mat")).
|
57
|
+
expect(File.exist?(File.join('result_folder', "#{motif_name}.mat"))).to be_truthy
|
58
58
|
File.read(File.join('result_folder', "#{motif_name}.mat")) == File.read("#{motif_name}.mat.result")
|
59
59
|
end
|
60
60
|
end
|
61
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
|
-
end
|
62
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'bioinform/conversion_algorithms/pcm2ppm_converter'
|
2
|
+
|
3
|
+
describe Bioinform::ConversionAlgorithms::PCM2PPMConverter do
|
4
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4]]) }
|
5
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new([[1,2,3,4],[2,2,2,4]]) }
|
6
|
+
let(:ppm) { Bioinform::MotifModel::PPM.new([[0.1,0.2,0.3,0.4],[0.2,0.2,0.2,0.4]]) }
|
7
|
+
let(:pcm_different_counts) { Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4],[3,3,3,4]]) }
|
8
|
+
|
9
|
+
let(:named_pcm) { Bioinform::MotifModel::NamedModel.new(pcm, 'motif name') }
|
10
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, 'motif name') }
|
11
|
+
|
12
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PCM2PPMConverter.new }
|
13
|
+
|
14
|
+
specify { expect(converter.convert(pcm)).to be_kind_of Bioinform::MotifModel::PPM }
|
15
|
+
|
16
|
+
specify do
|
17
|
+
expect(converter.convert(pcm).matrix).to eq [ [0.1,0.2,0.3,0.4],
|
18
|
+
[0.2,0.2,0.2,0.4] ]
|
19
|
+
end
|
20
|
+
specify do
|
21
|
+
expect(converter.convert(pcm_different_counts).matrix).to eq [ [0.1,0.2,0.3,0.4],
|
22
|
+
[0.2,0.2,0.2,0.4],
|
23
|
+
[3.0/13, 3.0/13, 3.0/13, 4.0/13] ]
|
24
|
+
end
|
25
|
+
|
26
|
+
specify { expect(converter.convert(named_pcm)).to be_kind_of Bioinform::MotifModel::NamedModel }
|
27
|
+
specify { expect(converter.convert(named_pcm).model).to be_kind_of Bioinform::MotifModel::PPM }
|
28
|
+
specify { expect(converter.convert(named_pcm).name).to eq 'motif name' }
|
29
|
+
specify { expect{ converter.convert(pwm) }.to raise_error Bioinform::Error }
|
30
|
+
specify { expect{ converter.convert(named_pwm) }.to raise_error Bioinform::Error }
|
31
|
+
specify { expect{ converter.convert(ppm) }.to raise_error Bioinform::Error }
|
32
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'bioinform/conversion_algorithms/pcm2pwm_converter'
|
2
|
+
|
3
|
+
describe Bioinform::ConversionAlgorithms::PCM2PWMConverter do
|
4
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4]]) }
|
5
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new([[1,2,3,4],[2,2,2,4]]) }
|
6
|
+
let(:ppm) { Bioinform::MotifModel::PPM.new([[0.1,0.2,0.3,0.4],[0.2,0.2,0.2,0.4]]) }
|
7
|
+
let(:pcm_different_counts) { Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4],[3,3,3,4]]) }
|
8
|
+
|
9
|
+
let(:named_pcm) { Bioinform::MotifModel::NamedModel.new(pcm, 'motif name') }
|
10
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, 'motif name') }
|
11
|
+
|
12
|
+
context 'with default converter' do
|
13
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PCM2PWMConverter.new }
|
14
|
+
|
15
|
+
specify { expect(converter.pseudocount).to eq :log }
|
16
|
+
specify { expect(converter.background).to eq Bioinform::Background::Uniform }
|
17
|
+
|
18
|
+
specify { expect(converter.convert(pcm)).to be_kind_of Bioinform::MotifModel::PWM }
|
19
|
+
specify { expect(converter.calculate_pseudocount(pcm)).to eq Math.log(10) }
|
20
|
+
|
21
|
+
specify do
|
22
|
+
cnt = 10
|
23
|
+
k = Math.log(cnt)
|
24
|
+
den = 0.25 * (cnt + k)
|
25
|
+
expect(converter.convert(pcm).matrix).to eq [
|
26
|
+
[Math.log((1+k*0.25)/den), Math.log((2+k*0.25)/den), Math.log((3+k*0.25)/den), Math.log((4+k*0.25)/den)],
|
27
|
+
[Math.log((2+k*0.25)/den), Math.log((2+k*0.25)/den), Math.log((2+k*0.25)/den), Math.log((4+k*0.25)/den)] ]
|
28
|
+
end
|
29
|
+
|
30
|
+
specify { expect{ converter.convert(pcm_different_counts) }.to raise_error Bioinform::Error }
|
31
|
+
|
32
|
+
specify { expect(converter.convert(named_pcm)).to be_kind_of Bioinform::MotifModel::NamedModel }
|
33
|
+
specify { expect(converter.convert(named_pcm).model).to be_kind_of Bioinform::MotifModel::PWM }
|
34
|
+
specify { expect(converter.convert(named_pcm).name).to eq 'motif name' }
|
35
|
+
specify { expect{ converter.convert(pwm) }.to raise_error Bioinform::Error }
|
36
|
+
specify { expect{ converter.convert(named_pwm) }.to raise_error Bioinform::Error }
|
37
|
+
specify { expect{ converter.convert(ppm) }.to raise_error Bioinform::Error }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with specified explicitly pseudocount' do
|
41
|
+
let(:specified_pseudocount) { 5 }
|
42
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PCM2PWMConverter.new(pseudocount: specified_pseudocount) }
|
43
|
+
|
44
|
+
specify { expect(converter.pseudocount).to eq 5 }
|
45
|
+
|
46
|
+
specify 'allows PCM-s with different column counts (because pseudocount specified, pcm\'s count not used for pseudocount calculation)' do
|
47
|
+
k = specified_pseudocount
|
48
|
+
den_1_2 = 0.25 * (10 + k)
|
49
|
+
den_3 = 0.25 * (13 + k)
|
50
|
+
expect(converter.convert(pcm_different_counts).matrix).to eq [
|
51
|
+
[Math.log((1+k*0.25)/den_1_2), Math.log((2+k*0.25)/den_1_2), Math.log((3+k*0.25)/den_1_2), Math.log((4+k*0.25)/den_1_2)],
|
52
|
+
[Math.log((2+k*0.25)/den_1_2), Math.log((2+k*0.25)/den_1_2), Math.log((2+k*0.25)/den_1_2), Math.log((4+k*0.25)/den_1_2)],
|
53
|
+
[Math.log((3+k*0.25)/den_3), Math.log((3+k*0.25)/den_3), Math.log((3+k*0.25)/den_3), Math.log((4+k*0.25)/den_3)] ]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'with specified explicitly background' do
|
58
|
+
let(:background_to_set) { Bioinform::Frequencies.new([0.1, 0.4, 0.4, 0.1]) }
|
59
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PCM2PWMConverter.new(background: background_to_set) }
|
60
|
+
|
61
|
+
specify { expect(converter.background).to eq background_to_set }
|
62
|
+
specify 'allows PCM-s with different column counts (because pseudocount specified, pcm\'s count not used for pseudocount calculation)' do
|
63
|
+
k = Math.log(10)
|
64
|
+
den_at = 0.1 * (10 + k)
|
65
|
+
den_cg = 0.4 * (10 + k)
|
66
|
+
expect(converter.convert(pcm).matrix).to eq [
|
67
|
+
[Math.log((1+k*0.1)/den_at), Math.log((2+k*0.4)/den_cg), Math.log((3+k*0.4)/den_cg), Math.log((4+k*0.1)/den_at)],
|
68
|
+
[Math.log((2+k*0.1)/den_at), Math.log((2+k*0.4)/den_cg), Math.log((2+k*0.4)/den_cg), Math.log((4+k*0.1)/den_at)] ]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'bioinform/conversion_algorithms/ppm2pcm_converter'
|
2
|
+
|
3
|
+
describe Bioinform::ConversionAlgorithms::PPM2PCMConverter do
|
4
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4]]) }
|
5
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new([[1,2,3,4],[2,2,2,4]]) }
|
6
|
+
let(:ppm) { Bioinform::MotifModel::PPM.new([[0.1,0.2,0.3,0.4],[0.2,0.2,0.2,0.4]]) }
|
7
|
+
|
8
|
+
let(:named_ppm) { Bioinform::MotifModel::NamedModel.new(ppm, 'motif name') }
|
9
|
+
let(:named_pcm) { Bioinform::MotifModel::NamedModel.new(pcm, 'motif name') }
|
10
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, 'motif name') }
|
11
|
+
|
12
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PPM2PCMConverter.new }
|
13
|
+
let(:converter_explicit_count) { Bioinform::ConversionAlgorithms::PPM2PCMConverter.new(count: 10) }
|
14
|
+
|
15
|
+
specify { expect(converter.count).to eq 100 }
|
16
|
+
specify { expect(converter_explicit_count.count).to eq 10 }
|
17
|
+
|
18
|
+
specify { expect(converter.convert(ppm)).to be_kind_of Bioinform::MotifModel::PCM }
|
19
|
+
|
20
|
+
specify { expect(converter.convert(ppm).matrix).to eq [[10,20,30,40],[20,20,20,40]] }
|
21
|
+
|
22
|
+
specify { expect(converter_explicit_count.convert(ppm).matrix).to eq [[1,2,3,4],[2,2,2,4]] }
|
23
|
+
|
24
|
+
specify { expect(converter.convert(named_ppm)).to be_kind_of Bioinform::MotifModel::NamedModel }
|
25
|
+
specify { expect(converter.convert(named_ppm).model).to be_kind_of Bioinform::MotifModel::PCM }
|
26
|
+
specify { expect(converter.convert(named_ppm).name).to eq 'motif name' }
|
27
|
+
|
28
|
+
specify { expect{ converter.convert(pcm) }.to raise_error Bioinform::Error }
|
29
|
+
specify { expect{ converter.convert(pwm) }.to raise_error Bioinform::Error }
|
30
|
+
specify { expect{ converter.convert(named_pcm) }.to raise_error Bioinform::Error }
|
31
|
+
specify { expect{ converter.convert(named_pwm) }.to raise_error Bioinform::Error }
|
32
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'bioinform/conversion_algorithms/pwm2iupac_pwm_converter'
|
2
|
+
|
3
|
+
describe Bioinform::ConversionAlgorithms::PWM2IupacPWMConverter do
|
4
|
+
let(:matrix) { [[1,2,3,1.567],[12,-11,12,0],[-1.1, 0.6, 0.4, 0.321]] }
|
5
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new(matrix) }
|
6
|
+
context 'with default parameters' do
|
7
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PWM2IupacPWMConverter.new }
|
8
|
+
specify{ expect(converter.iupac_alphabet).to eq Bioinform::NucleotideAlphabetWithN }
|
9
|
+
specify 'can convert only PWMs' do
|
10
|
+
pcm = Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4]])
|
11
|
+
expect { converter.convert(pcm) }.to raise_error Bioinform::Error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with A,C,G,T,N-alphabet' do
|
16
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PWM2IupacPWMConverter.new(alphabet: Bioinform::NucleotideAlphabetWithN) }
|
17
|
+
specify { expect( converter.convert(pwm) ).to be_kind_of Bioinform::MotifModel::PWM }
|
18
|
+
specify { expect( converter.convert(pwm).alphabet ).to eq Bioinform::NucleotideAlphabetWithN }
|
19
|
+
|
20
|
+
specify do
|
21
|
+
expect( converter.convert(pwm).matrix ).to eq [
|
22
|
+
[1,2,3,1.567, (1+2+3+1.567)/4.0],
|
23
|
+
[12,-11,12,0, (12-11+12+0)/4.0],
|
24
|
+
[-1.1, 0.6, 0.4, 0.321, (-1.1+0.6+0.4+0.321)/4.0]]
|
25
|
+
end
|
26
|
+
|
27
|
+
specify do
|
28
|
+
custom_alphabet = Bioinform::ComplementableAlphabet.new([:A,:C,:G,:T,:N], [:T,:G,:C,:A,:N])
|
29
|
+
custom_matrix = [[1,2,3,1.567, 0.1],[12,-11,12,0, 0.1],[-1.1, 0.6, 0.4, 0.321, 0.1]]
|
30
|
+
pwm_w_custom_alphabet = Bioinform::MotifModel::PWM.new(custom_matrix, alphabet: custom_alphabet)
|
31
|
+
expect { converter.convert(pwm_w_custom_alphabet) }.to raise_error Bioinform::Error
|
32
|
+
end
|
33
|
+
specify do
|
34
|
+
custom_alphabet = Bioinform::ComplementableAlphabet.new([:A,:X,:Y,:T], [:T,:Y,:X,:A])
|
35
|
+
pwm_w_custom_alphabet = Bioinform::MotifModel::PWM.new(matrix, alphabet: custom_alphabet)
|
36
|
+
expect { converter.convert(pwm_w_custom_alphabet) }.to raise_error Bioinform::Error
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with full-iupac alphabet' do
|
42
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PWM2IupacPWMConverter.new(alphabet: Bioinform::IUPACAlphabet) }
|
43
|
+
specify { expect( converter.convert(pwm) ).to be_kind_of Bioinform::MotifModel::PWM }
|
44
|
+
specify { expect( converter.convert(pwm).alphabet ).to eq Bioinform::IUPACAlphabet }
|
45
|
+
|
46
|
+
specify do
|
47
|
+
expect( converter.convert(pwm).matrix ).to eq [
|
48
|
+
[1,2,3,1.567, (1+2)/2.0, (1+3)/2.0, (1+1.567)/2.0, (2+3)/2.0, (2+1.567)/2.0, (3+1.567)/2.0, (1+2+3)/3.0, (1+2+1.567)/3.0, (1+3+1.567)/3.0, (2+3+1.567)/3.0, (1+2+3+1.567)/4.0],
|
49
|
+
[12,-11,12,0, (12-11)/2.0, (12+12)/2.0, (12+0)/2.0, (-11+12)/2.0, (-11+0)/2.0, (12+0)/2.0, (12-11+12)/3.0, (12-11+0)/3.0, (12+12+0)/3.0, (-11+12+0)/3.0, (12-11+12+0)/4.0],
|
50
|
+
[-1.1, 0.6, 0.4, 0.321, (-1.1+0.6)/2.0, (-1.1+0.4)/2.0, (-1.1+0.321)/2.0, (0.6+0.4)/2.0, (0.6+0.321)/2.0, (0.4+0.321)/2.0, (-1.1+0.6+0.4)/3.0, (-1.1+0.6+0.321)/3.0, (-1.1+0.4+0.321)/3.0, (0.6+0.4+0.321)/3.0, (-1.1+0.6+0.4+0.321)/4.0]]
|
51
|
+
end
|
52
|
+
|
53
|
+
specify do
|
54
|
+
custom_alphabet = Bioinform::ComplementableAlphabet.new([:A,:C,:G,:T,:N], [:T,:G,:C,:A,:N])
|
55
|
+
custom_matrix = [[1,2,3,1.567, 0.1],[12,-11,12,0, 0.1],[-1.1, 0.6, 0.4, 0.321, 0.1]]
|
56
|
+
pwm_w_custom_alphabet = Bioinform::MotifModel::PWM.new(custom_matrix, alphabet: custom_alphabet)
|
57
|
+
expect { converter.convert(pwm_w_custom_alphabet) }.to raise_error Bioinform::Error
|
58
|
+
end
|
59
|
+
specify do
|
60
|
+
custom_alphabet = Bioinform::ComplementableAlphabet.new([:A,:X,:Y,:T], [:T,:Y,:X,:A])
|
61
|
+
pwm_w_custom_alphabet = Bioinform::MotifModel::PWM.new(matrix, alphabet: custom_alphabet)
|
62
|
+
expect { converter.convert(pwm_w_custom_alphabet) }.to raise_error Bioinform::Error
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'bioinform/conversion_algorithms/pwm2pcm_converter'
|
2
|
+
|
3
|
+
describe Bioinform::ConversionAlgorithms::PWM2PCMConverter do
|
4
|
+
specify { expect(Bioinform::ConversionAlgorithms::PWM2PCMConverter.new(count: 137).count).to eq 137 }
|
5
|
+
specify { expect(Bioinform::ConversionAlgorithms::PWM2PCMConverter.new(pseudocount: 5).pseudocount).to eq 5 }
|
6
|
+
specify {
|
7
|
+
bckgr = Bioinform::Frequencies.new([0.1,0.4,0.4,0.1])
|
8
|
+
expect(Bioinform::ConversionAlgorithms::PWM2PCMConverter.new(background: bckgr).background).to eq bckgr
|
9
|
+
}
|
10
|
+
|
11
|
+
context 'from PWM converted by PCM2PWMConverter' do
|
12
|
+
let(:specified_pseudocount) { 5 }
|
13
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4]]) }
|
14
|
+
|
15
|
+
|
16
|
+
specify do
|
17
|
+
pwm = Bioinform::ConversionAlgorithms::PCM2PWMConverter.new(pseudocount: specified_pseudocount).convert(pcm)
|
18
|
+
expect(Bioinform::ConversionAlgorithms::PWM2PCMConverter.new(count: 10, pseudocount: specified_pseudocount).convert(pwm)).to be_within_range_from_matrix(pcm, 1e-10)
|
19
|
+
end
|
20
|
+
specify do
|
21
|
+
pwm = Bioinform::ConversionAlgorithms::PCM2PWMConverter.new.convert(pcm)
|
22
|
+
expect(Bioinform::ConversionAlgorithms::PWM2PCMConverter.new(count: 10).convert(pwm)).to be_within_range_from_matrix(pcm, 1e-10)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
specify do
|
27
|
+
pwm = Bioinform::MotifModel::PWM.new([[1,2,3,4],[2,2,2,4]])
|
28
|
+
pcm = Bioinform::ConversionAlgorithms::PWM2PCMConverter.new(count: 137).convert(pwm)
|
29
|
+
expect(pcm.count).to be_within(1e-10).of(137)
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with default converter' do
|
33
|
+
let(:converter) { Bioinform::ConversionAlgorithms::PWM2PCMConverter.new }
|
34
|
+
|
35
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new([[1,2,3,4],[2,2,2,4]]) }
|
36
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new([[1,2,3,4],[2,2,2,4]]) }
|
37
|
+
let(:ppm) { Bioinform::MotifModel::PPM.new([[0.1,0.2,0.3,0.4],[0.2,0.2,0.2,0.4]]) }
|
38
|
+
|
39
|
+
let(:named_pcm) { Bioinform::MotifModel::NamedModel.new(pcm, 'motif name') }
|
40
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, 'motif name') }
|
41
|
+
|
42
|
+
|
43
|
+
specify { expect(converter.count).to eq 100 }
|
44
|
+
specify { expect(converter.pseudocount).to eq :default }
|
45
|
+
specify { expect(converter.background).to eq Bioinform::Background::Uniform }
|
46
|
+
|
47
|
+
specify { expect(converter.convert(pwm)).to be_kind_of Bioinform::MotifModel::PCM }
|
48
|
+
|
49
|
+
specify { expect(converter.convert(named_pwm)).to be_kind_of Bioinform::MotifModel::NamedModel }
|
50
|
+
specify { expect(converter.convert(named_pwm).model).to be_kind_of Bioinform::MotifModel::PCM }
|
51
|
+
specify { expect(converter.convert(named_pwm).name).to eq 'motif name' }
|
52
|
+
|
53
|
+
specify { expect{ converter.convert(pcm) }.to raise_error Bioinform::Error }
|
54
|
+
specify { expect{ converter.convert(ppm) }.to raise_error Bioinform::Error }
|
55
|
+
specify { expect{ converter.convert(named_pcm) }.to raise_error Bioinform::Error }
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'bioinform/data_models/pwm'
|
2
|
+
require 'bioinform/data_models/named_model'
|
3
|
+
|
4
|
+
describe Bioinform::MotifModel::NamedModel do
|
5
|
+
context 'with PWM-model' do
|
6
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new([[1,2,3,4],[10,20,30,40]]) }
|
7
|
+
let(:name) { 'pwm name' }
|
8
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, name) }
|
9
|
+
specify { expect(named_pwm.model).to eq pwm }
|
10
|
+
specify { expect(named_pwm.name).to eq name }
|
11
|
+
|
12
|
+
context 'being sent a method returning a result of model type (class is Bioinform::MotifModel::*)' do
|
13
|
+
subject { named_pwm.reversed }
|
14
|
+
specify 'should return a named model' do
|
15
|
+
expect(subject).to be_kind_of Bioinform::MotifModel::NamedModel
|
16
|
+
end
|
17
|
+
specify 'resulting named model should wrap actual result' do
|
18
|
+
expect(subject.model).to eq pwm.reversed
|
19
|
+
end
|
20
|
+
specify 'resulting named model should have the same name as callee' do
|
21
|
+
expect(subject.name).to eq name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'being sent a method returning a result of common, non-model type (class is not Bioinform::MotifModel::*)' do
|
26
|
+
specify 'should return original result' do
|
27
|
+
expect(named_pwm.length).to eq pwm.length
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#==' do
|
32
|
+
let(:another_pwm) { Bioinform::MotifModel::PWM.new([[4,3,2,1],[-100,-500,-500,-100]]) }
|
33
|
+
specify { expect(named_pwm).to eq Bioinform::MotifModel::NamedModel.new(pwm, name) }
|
34
|
+
specify { expect(named_pwm).not_to eq Bioinform::MotifModel::NamedModel.new(pwm, 'Another name') }
|
35
|
+
specify { expect(named_pwm).not_to eq Bioinform::MotifModel::NamedModel.new(another_pwm, name) }
|
36
|
+
specify { expect(named_pwm).not_to eq Bioinform::MotifModel::NamedModel.new(another_pwm, 'Another name') }
|
37
|
+
end
|
38
|
+
|
39
|
+
specify { expect(named_pwm.to_s).to eq ">pwm name\n" + "1\t2\t3\t4\n" + "10\t20\t30\t40" }
|
40
|
+
end
|
41
|
+
end
|
@@ -1,56 +1,125 @@
|
|
1
|
-
|
2
|
-
require_relative '../../lib/bioinform/data_models/pcm'
|
3
|
-
|
4
|
-
module Bioinform
|
5
|
-
describe PCM do
|
6
|
-
describe '#count' do
|
7
|
-
it 'should be equal to sum of elements at position' do
|
8
|
-
Fabricate(:pcm).count.should == 7
|
9
|
-
Fabricate(:pcm_with_floats).count.should == 7.5
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require 'bioinform/data_models/pcm'
|
12
2
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
it 'should make transformation: el --> log( (el + p_i*pseudocount) / (p_i*(count + pseudocount)) )' do
|
19
|
-
subject.to_pwm(1).matrix.map{|line|line.map{|el| el.round(3)}}.should == Fabricate(:rounded_upto_3_digits_pwm_by_pcm_with_pseudocount_1).matrix
|
20
|
-
subject.to_pwm(10).matrix.map{|line|line.map{|el| el.round(3)}}.should == Fabricate(:rounded_upto_3_digits_pwm_by_pcm_with_pseudocount_10).matrix
|
21
|
-
end
|
22
|
-
it 'should use default pseudocount equal to log(count)' do
|
23
|
-
Fabricate(:pcm).to_pwm.should == Fabricate(:pcm).to_pwm(Math.log(7))
|
24
|
-
end
|
25
|
-
it 'should preserve name' do
|
26
|
-
Fabricate(:pcm, name: nil).to_pwm.name.should be_nil
|
27
|
-
Fabricate(:pcm, name: 'Stub name').to_pwm.name.should == 'Stub name'
|
28
|
-
end
|
3
|
+
describe Bioinform::MotifModel::PCM do
|
4
|
+
|
5
|
+
describe '.new' do
|
6
|
+
specify 'fails on matrix having negative elements' do
|
7
|
+
expect { Bioinform::MotifModel::PCM.new([[1,2,1,3],[3,3,0,1], [-2, 3, 3, 3]]) }.to raise_error (Bioinform::Error)
|
29
8
|
end
|
30
9
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
it 'should have matrix transformed with el --> el / count' do
|
37
|
-
subject.matrix.should == Fabricate(:ppm_pcm_divided_by_count).matrix
|
10
|
+
context 'with valid matrix' do
|
11
|
+
context 'with equal counts in different positions' do
|
12
|
+
let(:matrix) { [[1,2,1,3],[3,3,0,1], [1, 0, 3, 3]] }
|
13
|
+
specify do
|
14
|
+
expect { Bioinform::MotifModel::PCM.new(matrix) }.not_to raise_error
|
38
15
|
end
|
39
|
-
|
40
|
-
|
41
|
-
it 'should have no name' do
|
42
|
-
subject.name.should be_nil
|
43
|
-
end
|
16
|
+
specify do
|
17
|
+
expect( Bioinform::MotifModel::PCM.new(matrix).matrix ).to eq matrix
|
44
18
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with different counts in different positions' do
|
22
|
+
let(:matrix) { [[1,2,1,3],[30,10,100,11000], [1, 0, 3, 3]] }
|
23
|
+
specify do
|
24
|
+
expect { Bioinform::MotifModel::PCM.new(matrix) }.not_to raise_error
|
25
|
+
end
|
26
|
+
specify do
|
27
|
+
expect( Bioinform::MotifModel::PCM.new(matrix).matrix ).to eq matrix
|
50
28
|
end
|
51
29
|
end
|
52
30
|
end
|
31
|
+
end
|
53
32
|
|
33
|
+
describe '.from_string' do
|
34
|
+
specify {
|
35
|
+
expect( Bioinform::MotifModel::PCM.from_string("1 2 3 4\n4 2 2 2").model.class ).to eq Bioinform::MotifModel::PCM
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'valid PCM' do
|
40
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new(matrix) }
|
41
|
+
context 'with equal counts in different positions' do
|
42
|
+
let(:matrix) { [[1,2,1,3],[3,3,0,1], [1, 0, 3, 3]] }
|
43
|
+
specify{ expect(pcm.count).to eq 7 }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with different counts in different positions' do
|
47
|
+
let(:matrix) { [[1,2,1,3],[30,10,100,11000], [1, 0, 3, 3]] }
|
48
|
+
specify{ expect{ pcm.count }.to raise_error Bioinform::Error }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'valid PCM' do
|
53
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new(matrix) }
|
54
|
+
let(:matrix) { [[1,2,1,3],[3,3,0,1], [1, 0, 3, 3]] }
|
55
|
+
|
56
|
+
specify { expect(pcm).to eq Bioinform::MotifModel::PCM.new(matrix) }
|
57
|
+
specify { expect(pcm).not_to eq matrix }
|
58
|
+
specify { expect(pcm).not_to eq Bioinform::MotifModel::PM.new(matrix) }
|
59
|
+
specify { expect(pcm).not_to eq Bioinform::MotifModel::PWM.new(matrix) }
|
60
|
+
# specify { expect(pcm).not_to eq Bioinform::MotifModel::PPM.new(matrix) }
|
61
|
+
specify { expect(matrix).not_to eq pcm }
|
62
|
+
specify { expect(Bioinform::MotifModel::PM.new(matrix)).not_to eq pcm }
|
63
|
+
specify { expect(Bioinform::MotifModel::PWM.new(matrix)).not_to eq pcm }
|
64
|
+
# specify { expect(Bioinform::MotifModel::PPM.new(matrix)).not_to eq pcm }
|
65
|
+
|
66
|
+
specify { expect(pcm.named('motif name')).to be_kind_of Bioinform::MotifModel::NamedModel }
|
67
|
+
specify { expect(pcm.named('motif name').model).to eq pcm }
|
68
|
+
specify { expect(pcm.named('motif name').name).to eq 'motif name' }
|
69
|
+
|
70
|
+
describe '#reversed, #complemented, #reverse_complemented' do
|
71
|
+
specify { expect(pcm.reversed).to be_kind_of Bioinform::MotifModel::PCM }
|
72
|
+
specify { expect(pcm.complemented).to be_kind_of Bioinform::MotifModel::PCM }
|
73
|
+
specify { expect(pcm.reverse_complemented).to be_kind_of Bioinform::MotifModel::PCM }
|
74
|
+
specify { expect(pcm.revcomp).to be_kind_of Bioinform::MotifModel::PCM }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '.acts_as_pcm?' do
|
79
|
+
let(:matrix) { [[0.1,0.2,0.3,0.4],[0.3,0.3,0.3,0.1], [0.3,0,0.3,0.4]] }
|
80
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new(matrix) }
|
81
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new(matrix) }
|
82
|
+
let(:ppm) { Bioinform::MotifModel::PPM.new(matrix) }
|
83
|
+
let(:named_pcm) { Bioinform::MotifModel::NamedModel.new(pcm, 'motif name') }
|
84
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, 'motif name') }
|
85
|
+
let(:named_ppm) { Bioinform::MotifModel::NamedModel.new(ppm, 'motif name') }
|
86
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pcm?(pcm)).to be_truthy }
|
87
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pcm?(named_pcm)).to be_truthy }
|
88
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pcm?(pwm)).to be_falsy }
|
89
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pcm?(named_pwm)).to be_falsy }
|
90
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pcm?(ppm)).to be_falsy }
|
91
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pcm?(named_ppm)).to be_falsy }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '.acts_as_pwm?' do
|
95
|
+
let(:matrix) { [[0.1,0.2,0.3,0.4],[0.3,0.3,0.3,0.1], [0.3,0,0.3,0.4]] }
|
96
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new(matrix) }
|
97
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new(matrix) }
|
98
|
+
let(:ppm) { Bioinform::MotifModel::PPM.new(matrix) }
|
99
|
+
let(:named_pcm) { Bioinform::MotifModel::NamedModel.new(pcm, 'motif name') }
|
100
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, 'motif name') }
|
101
|
+
let(:named_ppm) { Bioinform::MotifModel::NamedModel.new(ppm, 'motif name') }
|
102
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pwm?(pcm)).to be_falsy }
|
103
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pwm?(named_pcm)).to be_falsy }
|
104
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pwm?(pwm)).to be_truthy }
|
105
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pwm?(named_pwm)).to be_truthy }
|
106
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pwm?(ppm)).to be_falsy }
|
107
|
+
specify{ expect(Bioinform::MotifModel.acts_as_pwm?(named_ppm)).to be_falsy }
|
108
|
+
end
|
54
109
|
|
110
|
+
describe '.acts_as_ppm?' do
|
111
|
+
let(:matrix) { [[0.1,0.2,0.3,0.4],[0.3,0.3,0.3,0.1], [0.3,0,0.3,0.4]] }
|
112
|
+
let(:pcm) { Bioinform::MotifModel::PCM.new(matrix) }
|
113
|
+
let(:pwm) { Bioinform::MotifModel::PWM.new(matrix) }
|
114
|
+
let(:ppm) { Bioinform::MotifModel::PPM.new(matrix) }
|
115
|
+
let(:named_pcm) { Bioinform::MotifModel::NamedModel.new(pcm, 'motif name') }
|
116
|
+
let(:named_pwm) { Bioinform::MotifModel::NamedModel.new(pwm, 'motif name') }
|
117
|
+
let(:named_ppm) { Bioinform::MotifModel::NamedModel.new(ppm, 'motif name') }
|
118
|
+
specify{ expect(Bioinform::MotifModel.acts_as_ppm?(pcm)).to be_falsy }
|
119
|
+
specify{ expect(Bioinform::MotifModel.acts_as_ppm?(named_pcm)).to be_falsy }
|
120
|
+
specify{ expect(Bioinform::MotifModel.acts_as_ppm?(pwm)).to be_falsy }
|
121
|
+
specify{ expect(Bioinform::MotifModel.acts_as_ppm?(named_pwm)).to be_falsy }
|
122
|
+
specify{ expect(Bioinform::MotifModel.acts_as_ppm?(ppm)).to be_truthy }
|
123
|
+
specify{ expect(Bioinform::MotifModel.acts_as_ppm?(named_ppm)).to be_truthy }
|
55
124
|
end
|
56
|
-
end
|
125
|
+
end
|