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,100 +1,100 @@
|
|
1
|
-
require 'shellwords'
|
2
|
-
require 'yaml'
|
3
|
-
require_relative '../spec_helper'
|
4
|
-
require_relative '../../lib/bioinform/cli/merge_into_collection'
|
5
|
-
require_relative '../../lib/bioinform/data_models/collection'
|
6
|
-
|
7
|
-
|
8
|
-
def run_merge_into_collection(cmd)
|
9
|
-
Bioinform::CLI::MergeIntoCollection.main(cmd.shellsplit)
|
10
|
-
end
|
11
|
-
|
12
|
-
describe Bioinform::CLI::MergeIntoCollection do
|
13
|
-
before :each do
|
14
|
-
@start_dir = Dir.pwd
|
15
|
-
Dir.chdir File.join(File.dirname(__FILE__), 'data', 'merge_into_collection')
|
16
|
-
end
|
17
|
-
after :each do
|
18
|
-
File.delete('collection.yaml') if File.exist?('collection.yaml')
|
19
|
-
File.delete('collection.txt') if File.exist?('collection.txt')
|
20
|
-
File.delete('my_collection.yaml') if File.exist?('my_collection.yaml')
|
21
|
-
File.delete('my_collection.txt') if File.exist?('my_collection.txt')
|
22
|
-
File.delete('result.out') if File.exist?('result.out')
|
23
|
-
Dir.chdir(@start_dir)
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'without --plain option' do
|
27
|
-
context 'when name not specified' do
|
28
|
-
it 'collects motifs into file collection.yaml' do
|
29
|
-
run_merge_into_collection('GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
30
|
-
File.exist?('collection.yaml').should be_true
|
31
|
-
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection.yaml.result'))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when name specified' do
|
36
|
-
it 'collects motifs into file <collection name>.yaml' do
|
37
|
-
run_merge_into_collection('--name my_collection GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
38
|
-
File.exist?('my_collection.yaml').should be_true
|
39
|
-
YAML.load(File.read('my_collection.yaml')).should == YAML.load(File.read('collection.yaml.result')).set_parameters(name: 'my_collection')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with --data-model option' do
|
44
|
-
it 'treat motifs as specified data model' do
|
45
|
-
run_merge_into_collection('--data-model pwm GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
46
|
-
File.exist?('collection.yaml').should be_true
|
47
|
-
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection_pwm.yaml.result'))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'with --plain option' do
|
53
|
-
context 'when name not specified' do
|
54
|
-
it 'should collect motifs into file collection.txt in plain-text format' do
|
55
|
-
run_merge_into_collection('--plain GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
56
|
-
File.exist?('collection.txt').should be_true
|
57
|
-
YAML.load(File.read('collection.txt')).should == YAML.load(File.read('collection.txt.result'))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when name specified' do
|
62
|
-
it 'should collect motifs into file <collection name>.txt in plain-text format' do
|
63
|
-
run_merge_into_collection('--name my_collection --plain GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
64
|
-
File.exist?('my_collection.txt').should be_true
|
65
|
-
YAML.load(File.read('my_collection.txt')).should == YAML.load(File.read('collection.txt.result'))
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'with --data-model option' do
|
70
|
-
it 'generate usual txt file' do
|
71
|
-
run_merge_into_collection('--data-model pwm --plain GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
72
|
-
File.exist?('collection.txt').should be_true
|
73
|
-
YAML.load(File.read('collection.txt')).should == YAML.load(File.read('collection.txt.result'))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'when --output-file specified' do
|
79
|
-
it 'collects motifs into specified file' do
|
80
|
-
run_merge_into_collection('--output-file result.out GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
81
|
-
File.exist?('result.out').should be_true
|
82
|
-
YAML.load(File.read('result.out')).should == YAML.load(File.read('collection.yaml.result'))
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'when filelist is empty' do
|
87
|
-
it 'takes filelist from stdin' do
|
88
|
-
provide_stdin('GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm'){ run_merge_into_collection('') }
|
89
|
-
File.exist?('collection.yaml').should be_true
|
90
|
-
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection.yaml.result'))
|
91
|
-
end
|
92
|
-
end
|
93
|
-
context 'when filelist contain folder name' do
|
94
|
-
it 'takes filelist as files from folder' do
|
95
|
-
run_merge_into_collection('pwm_folder')
|
96
|
-
File.exist?('collection.yaml').should be_true
|
97
|
-
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection.yaml.result'))
|
98
|
-
end
|
99
|
-
end
|
1
|
+
require 'shellwords'
|
2
|
+
require 'yaml'
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
require_relative '../../lib/bioinform/cli/merge_into_collection'
|
5
|
+
require_relative '../../lib/bioinform/data_models/collection'
|
6
|
+
|
7
|
+
|
8
|
+
def run_merge_into_collection(cmd)
|
9
|
+
Bioinform::CLI::MergeIntoCollection.main(cmd.shellsplit)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Bioinform::CLI::MergeIntoCollection do
|
13
|
+
before :each do
|
14
|
+
@start_dir = Dir.pwd
|
15
|
+
Dir.chdir File.join(File.dirname(__FILE__), 'data', 'merge_into_collection')
|
16
|
+
end
|
17
|
+
after :each do
|
18
|
+
File.delete('collection.yaml') if File.exist?('collection.yaml')
|
19
|
+
File.delete('collection.txt') if File.exist?('collection.txt')
|
20
|
+
File.delete('my_collection.yaml') if File.exist?('my_collection.yaml')
|
21
|
+
File.delete('my_collection.txt') if File.exist?('my_collection.txt')
|
22
|
+
File.delete('result.out') if File.exist?('result.out')
|
23
|
+
Dir.chdir(@start_dir)
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'without --plain option' do
|
27
|
+
context 'when name not specified' do
|
28
|
+
it 'collects motifs into file collection.yaml' do
|
29
|
+
run_merge_into_collection('GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
30
|
+
File.exist?('collection.yaml').should be_true
|
31
|
+
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection.yaml.result'))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when name specified' do
|
36
|
+
it 'collects motifs into file <collection name>.yaml' do
|
37
|
+
run_merge_into_collection('--name my_collection GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
38
|
+
File.exist?('my_collection.yaml').should be_true
|
39
|
+
YAML.load(File.read('my_collection.yaml')).should == YAML.load(File.read('collection.yaml.result')).set_parameters(name: 'my_collection')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with --data-model option' do
|
44
|
+
it 'treat motifs as specified data model' do
|
45
|
+
run_merge_into_collection('--data-model pwm GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
46
|
+
File.exist?('collection.yaml').should be_true
|
47
|
+
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection_pwm.yaml.result'))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'with --plain option' do
|
53
|
+
context 'when name not specified' do
|
54
|
+
it 'should collect motifs into file collection.txt in plain-text format' do
|
55
|
+
run_merge_into_collection('--plain GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
56
|
+
File.exist?('collection.txt').should be_true
|
57
|
+
YAML.load(File.read('collection.txt')).should == YAML.load(File.read('collection.txt.result'))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when name specified' do
|
62
|
+
it 'should collect motifs into file <collection name>.txt in plain-text format' do
|
63
|
+
run_merge_into_collection('--name my_collection --plain GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
64
|
+
File.exist?('my_collection.txt').should be_true
|
65
|
+
YAML.load(File.read('my_collection.txt')).should == YAML.load(File.read('collection.txt.result'))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with --data-model option' do
|
70
|
+
it 'generate usual txt file' do
|
71
|
+
run_merge_into_collection('--data-model pwm --plain GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
72
|
+
File.exist?('collection.txt').should be_true
|
73
|
+
YAML.load(File.read('collection.txt')).should == YAML.load(File.read('collection.txt.result'))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when --output-file specified' do
|
79
|
+
it 'collects motifs into specified file' do
|
80
|
+
run_merge_into_collection('--output-file result.out GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm')
|
81
|
+
File.exist?('result.out').should be_true
|
82
|
+
YAML.load(File.read('result.out')).should == YAML.load(File.read('collection.yaml.result'))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when filelist is empty' do
|
87
|
+
it 'takes filelist from stdin' do
|
88
|
+
provide_stdin('GABPA_f1.pwm KLF4_f2.pwm SP1_f1.pwm'){ run_merge_into_collection('') }
|
89
|
+
File.exist?('collection.yaml').should be_true
|
90
|
+
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection.yaml.result'))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
context 'when filelist contain folder name' do
|
94
|
+
it 'takes filelist as files from folder' do
|
95
|
+
run_merge_into_collection('pwm_folder')
|
96
|
+
File.exist?('collection.yaml').should be_true
|
97
|
+
YAML.load(File.read('collection.yaml')).should == YAML.load(File.read('collection.yaml.result'))
|
98
|
+
end
|
99
|
+
end
|
100
100
|
end
|
data/spec/cli/pcm2pwm_spec.rb
CHANGED
@@ -1,80 +1,80 @@
|
|
1
|
-
require 'shellwords'
|
2
|
-
require_relative '../spec_helper'
|
3
|
-
require_relative '../../lib/bioinform/cli/pcm2pwm'
|
4
|
-
|
5
|
-
|
6
|
-
def run_pcm2pwm(cmd)
|
7
|
-
Bioinform::CLI::PCM2PWM.main(cmd.shellsplit)
|
8
|
-
end
|
9
|
-
|
10
|
-
describe Bioinform::CLI::PCM2PWM do
|
11
|
-
before :each do
|
12
|
-
@start_dir = Dir.pwd
|
13
|
-
Dir.chdir File.join(File.dirname(__FILE__), 'data', 'pcm2pwm')
|
14
|
-
end
|
15
|
-
after :each do
|
16
|
-
File.delete('KLF4_f2.pwm') if File.exist?('KLF4_f2.pwm')
|
17
|
-
File.delete('SP1_f1.pwm') if File.exist?('SP1_f1.pwm')
|
18
|
-
File.delete('KLF4_f2.pat') if File.exist?('KLF4_f2.pat')
|
19
|
-
File.delete('KLF4 f2 spaced name.pwm') if File.exist?('KLF4 f2 spaced name.pwm')
|
20
|
-
FileUtils.rm_rf('pwm_folder') if Dir.exist?('pwm_folder')
|
21
|
-
Dir.chdir(@start_dir)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should transform single PCM to PWM' do
|
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')
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should transform multiple PCMs to PWMs' do
|
31
|
-
run_pcm2pwm('KLF4_f2.pcm SP1_f1.pcm')
|
32
|
-
|
33
|
-
File.exist?('KLF4_f2.pwm').should be_true
|
34
|
-
File.read('KLF4_f2.pwm').should == File.read('KLF4_f2.pwm.result')
|
35
|
-
|
36
|
-
File.exist?('SP1_f1.pwm').should be_true
|
37
|
-
File.read('SP1_f1.pwm').should == File.read('SP1_f1.pwm.result')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should transform extension to specified with --extension option' do
|
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')
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should save PWMs into folder specified with --folder option when folder exists' do
|
47
|
-
Dir.mkdir('pwm_folder') unless Dir.exist?('pwm_folder')
|
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')
|
51
|
-
end
|
52
|
-
it 'should save PWMs into folder specified with --folder option' do
|
53
|
-
FileUtils.rm_rf('pwm_folder') if Dir.exist?('pwm_folder')
|
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')
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should process PCMs with names obtained from STDIN' do
|
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')
|
63
|
-
|
64
|
-
File.exist?('SP1_f1.pwm').should be_true
|
65
|
-
File.read('SP1_f1.pwm').should == File.read('SP1_f1.pwm.result')
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should process PCMs with names obtained from STDIN when there are some options' do
|
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')
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should process PCMs having filename with spaces' do
|
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')
|
78
|
-
end
|
79
|
-
|
1
|
+
require 'shellwords'
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
require_relative '../../lib/bioinform/cli/pcm2pwm'
|
4
|
+
|
5
|
+
|
6
|
+
def run_pcm2pwm(cmd)
|
7
|
+
Bioinform::CLI::PCM2PWM.main(cmd.shellsplit)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Bioinform::CLI::PCM2PWM do
|
11
|
+
before :each do
|
12
|
+
@start_dir = Dir.pwd
|
13
|
+
Dir.chdir File.join(File.dirname(__FILE__), 'data', 'pcm2pwm')
|
14
|
+
end
|
15
|
+
after :each do
|
16
|
+
File.delete('KLF4_f2.pwm') if File.exist?('KLF4_f2.pwm')
|
17
|
+
File.delete('SP1_f1.pwm') if File.exist?('SP1_f1.pwm')
|
18
|
+
File.delete('KLF4_f2.pat') if File.exist?('KLF4_f2.pat')
|
19
|
+
File.delete('KLF4 f2 spaced name.pwm') if File.exist?('KLF4 f2 spaced name.pwm')
|
20
|
+
FileUtils.rm_rf('pwm_folder') if Dir.exist?('pwm_folder')
|
21
|
+
Dir.chdir(@start_dir)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should transform single PCM to PWM' do
|
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')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should transform multiple PCMs to PWMs' do
|
31
|
+
run_pcm2pwm('KLF4_f2.pcm SP1_f1.pcm')
|
32
|
+
|
33
|
+
File.exist?('KLF4_f2.pwm').should be_true
|
34
|
+
File.read('KLF4_f2.pwm').should == File.read('KLF4_f2.pwm.result')
|
35
|
+
|
36
|
+
File.exist?('SP1_f1.pwm').should be_true
|
37
|
+
File.read('SP1_f1.pwm').should == File.read('SP1_f1.pwm.result')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should transform extension to specified with --extension option' do
|
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')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should save PWMs into folder specified with --folder option when folder exists' do
|
47
|
+
Dir.mkdir('pwm_folder') unless Dir.exist?('pwm_folder')
|
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')
|
51
|
+
end
|
52
|
+
it 'should save PWMs into folder specified with --folder option' do
|
53
|
+
FileUtils.rm_rf('pwm_folder') if Dir.exist?('pwm_folder')
|
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')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should process PCMs with names obtained from STDIN' do
|
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')
|
63
|
+
|
64
|
+
File.exist?('SP1_f1.pwm').should be_true
|
65
|
+
File.read('SP1_f1.pwm').should == File.read('SP1_f1.pwm.result')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should process PCMs with names obtained from STDIN when there are some options' do
|
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')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should process PCMs having filename with spaces' do
|
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')
|
78
|
+
end
|
79
|
+
|
80
80
|
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require_relative '../../../spec_helper'
|
2
|
-
require_relative 'yield_help_string'
|
3
|
-
|
4
|
-
shared_examples 'motif list is empty' do
|
5
|
-
context 'motif list is empty' do
|
6
|
-
Given(:motif_list) { [] }
|
7
|
-
|
8
|
-
context 'with options' do
|
9
|
-
Given(:options) { '--formatter default --silent' }
|
10
|
-
include_examples 'yield help string'
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'without options' do
|
14
|
-
Given(:options){ '' }
|
15
|
-
include_examples 'yield help string'
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
require_relative 'yield_help_string'
|
3
|
+
|
4
|
+
shared_examples 'motif list is empty' do
|
5
|
+
context 'motif list is empty' do
|
6
|
+
Given(:motif_list) { [] }
|
7
|
+
|
8
|
+
context 'with options' do
|
9
|
+
Given(:options) { '--formatter default --silent' }
|
10
|
+
include_examples 'yield help string'
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'without options' do
|
14
|
+
Given(:options){ '' }
|
15
|
+
include_examples 'yield help string'
|
16
|
+
end
|
17
|
+
end
|
18
18
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require_relative '../../../spec_helper'
|
2
|
-
|
3
|
-
shared_examples 'several motifs specified' do
|
4
|
-
context 'several motifs specified' do
|
5
|
-
Given {
|
6
|
-
make_model_file(sp1_f1, 'pcm')
|
7
|
-
make_model_file(klf4_f2, 'pcm')
|
8
|
-
}
|
9
|
-
Given(:motif_list) { [sp1_f1, klf4_f2] }
|
10
|
-
Given(:model_from) { 'pcm' }
|
11
|
-
Given(:model_to) { 'pwm' }
|
12
|
-
Then { resulting_stdout.should == [sp1_f1.pwm, klf4_f2.pwm].join("\n") }
|
13
|
-
end
|
14
|
-
end
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
shared_examples 'several motifs specified' do
|
4
|
+
context 'several motifs specified' do
|
5
|
+
Given {
|
6
|
+
make_model_file(sp1_f1, 'pcm')
|
7
|
+
make_model_file(klf4_f2, 'pcm')
|
8
|
+
}
|
9
|
+
Given(:motif_list) { [sp1_f1, klf4_f2] }
|
10
|
+
Given(:model_from) { 'pcm' }
|
11
|
+
Given(:model_to) { 'pwm' }
|
12
|
+
Then { resulting_stdout.should == [sp1_f1.pwm, klf4_f2.pwm].join("\n") }
|
13
|
+
end
|
14
|
+
end
|
@@ -1,50 +1,50 @@
|
|
1
|
-
require_relative '../../../spec_helper'
|
2
|
-
|
3
|
-
shared_examples 'single motif specified' do
|
4
|
-
context 'single motif specified' do
|
5
|
-
Given {
|
6
|
-
make_model_file(sp1_f1, model_from)
|
7
|
-
}
|
8
|
-
Given(:motif_list) { [sp1_f1] }
|
9
|
-
|
10
|
-
context 'when input is a pcm' do
|
11
|
-
Given(:model_from) { 'pcm' }
|
12
|
-
|
13
|
-
context 'pwm conversion invoked' do
|
14
|
-
Given(:model_to) { 'pwm' }
|
15
|
-
Then { resulting_stdout.should == sp1_f1.pwm }
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'ppm conversion invoked' do
|
19
|
-
Given(:model_to) { 'ppm' }
|
20
|
-
Then { resulting_stdout.should == sp1_f1.ppm }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when input is a pwm' do
|
25
|
-
Given(:model_from) { 'pwm' }
|
26
|
-
|
27
|
-
context 'pcm conversion invoked' do
|
28
|
-
Given(:model_to) { 'pcm' }
|
29
|
-
include_examples 'yields motif conversion error'
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'ppm conversion invoked' do
|
33
|
-
Given(:model_to) { 'ppm' }
|
34
|
-
include_examples 'yields motif conversion error'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'if there exist other files in current folder' do
|
39
|
-
Given {
|
40
|
-
make_model_file(sp1_f1, model_from)
|
41
|
-
make_model_file(klf4_f2, model_from)
|
42
|
-
}
|
43
|
-
Given(:model_from) { 'pcm' }
|
44
|
-
Given(:model_to) { 'pwm' }
|
45
|
-
Then { resulting_stdout.should == sp1_f1.pwm }
|
46
|
-
Then { resulting_stdout.should_not match(klf4_f2.pwm) }
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
shared_examples 'single motif specified' do
|
4
|
+
context 'single motif specified' do
|
5
|
+
Given {
|
6
|
+
make_model_file(sp1_f1, model_from)
|
7
|
+
}
|
8
|
+
Given(:motif_list) { [sp1_f1] }
|
9
|
+
|
10
|
+
context 'when input is a pcm' do
|
11
|
+
Given(:model_from) { 'pcm' }
|
12
|
+
|
13
|
+
context 'pwm conversion invoked' do
|
14
|
+
Given(:model_to) { 'pwm' }
|
15
|
+
Then { resulting_stdout.should == sp1_f1.pwm }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'ppm conversion invoked' do
|
19
|
+
Given(:model_to) { 'ppm' }
|
20
|
+
Then { resulting_stdout.should == sp1_f1.ppm }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when input is a pwm' do
|
25
|
+
Given(:model_from) { 'pwm' }
|
26
|
+
|
27
|
+
context 'pcm conversion invoked' do
|
28
|
+
Given(:model_to) { 'pcm' }
|
29
|
+
include_examples 'yields motif conversion error'
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'ppm conversion invoked' do
|
33
|
+
Given(:model_to) { 'ppm' }
|
34
|
+
include_examples 'yields motif conversion error'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'if there exist other files in current folder' do
|
39
|
+
Given {
|
40
|
+
make_model_file(sp1_f1, model_from)
|
41
|
+
make_model_file(klf4_f2, model_from)
|
42
|
+
}
|
43
|
+
Given(:model_from) { 'pcm' }
|
44
|
+
Given(:model_to) { 'pwm' }
|
45
|
+
Then { resulting_stdout.should == sp1_f1.pwm }
|
46
|
+
Then { resulting_stdout.should_not match(klf4_f2.pwm) }
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
50
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require_relative '../../../spec_helper'
|
2
|
-
|
3
|
-
shared_examples 'yield help string' do
|
4
|
-
Then { resulting_stdout.should match(/Usage:.*Options:/m) }
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
shared_examples 'yield help string' do
|
4
|
+
Then { resulting_stdout.should match(/Usage:.*Options:/m) }
|
5
5
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples 'yields motif conversion error' do
|
2
|
-
Then { resulting_stderr.should match "One can't convert from #{model_from} data-model to #{model_to} data-model" }
|
3
|
-
Then { resulting_stderr.should match "Error! Conversion wasn't performed" }
|
1
|
+
shared_examples 'yields motif conversion error' do
|
2
|
+
Then { resulting_stderr.should match "One can't convert from #{model_from} data-model to #{model_to} data-model" }
|
3
|
+
Then { resulting_stderr.should match "Error! Conversion wasn't performed" }
|
4
4
|
end
|