bioinform 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +12 -0
- data/Guardfile +9 -0
- data/README.md +7 -1
- data/TODO.txt +8 -0
- data/bioinform.gemspec +7 -5
- data/lib/bioinform.rb +1 -0
- data/lib/bioinform/cli.rb +12 -3
- data/lib/bioinform/cli/convert_motif.rb +108 -0
- data/lib/bioinform/cli/merge_into_collection.rb +6 -2
- data/lib/bioinform/cli/pcm2pwm.rb +1 -1
- data/lib/bioinform/cli/split_motifs.rb +1 -1
- data/lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb +19 -0
- data/lib/bioinform/conversion_algorithms/pcm2pwm_converter.rb +20 -0
- data/lib/bioinform/conversion_algorithms/pcm2pwm_mara_converter.rb +0 -0
- data/lib/bioinform/conversion_algorithms/ppm2pcm_converter.rb +0 -0
- data/lib/bioinform/conversion_algorithms/ppm2pwm_converter.rb +0 -0
- data/lib/bioinform/data_models/collection.rb +21 -35
- data/lib/bioinform/data_models/motif.rb +56 -0
- data/lib/bioinform/data_models/pcm.rb +4 -8
- data/lib/bioinform/data_models/pm.rb +19 -48
- data/lib/bioinform/data_models/pwm.rb +16 -0
- data/lib/bioinform/formatters.rb +2 -0
- data/lib/bioinform/formatters/raw_formatter.rb +41 -0
- data/lib/bioinform/formatters/transfac_formatter.rb +39 -0
- data/lib/bioinform/parsers.rb +2 -1
- data/lib/bioinform/parsers/jaspar_parser.rb +35 -0
- data/lib/bioinform/parsers/string_parser.rb +1 -1
- data/lib/bioinform/parsers/trivial_parser.rb +2 -1
- data/lib/bioinform/parsers/yaml_parser.rb +1 -1
- data/lib/bioinform/support.rb +2 -1
- data/lib/bioinform/support/parameters.rb +27 -18
- data/lib/bioinform/support/strip_doc.rb +9 -0
- data/lib/bioinform/version.rb +1 -1
- data/spec/cli/convert_motif_spec.rb +107 -0
- data/spec/cli/data/merge_into_collection/collection.yaml.result +186 -183
- data/spec/cli/data/merge_into_collection/collection_pwm.yaml.result +186 -183
- data/spec/cli/data/split_motifs/collection.yaml +184 -193
- data/spec/cli/shared_examples/convert_motif/motif_list_empty.rb +18 -0
- data/spec/cli/shared_examples/convert_motif/several_motifs_specified.rb +14 -0
- data/spec/cli/shared_examples/convert_motif/single_motif_specified.rb +50 -0
- data/spec/cli/shared_examples/convert_motif/yield_help_string.rb +5 -0
- data/spec/cli/shared_examples/convert_motif/yield_motif_conversion_error.rb +4 -0
- data/spec/data_models/collection_spec.rb +36 -34
- data/spec/data_models/motif_spec.rb +224 -0
- data/spec/data_models/pcm_spec.rb +28 -17
- data/spec/data_models/pm_spec.rb +83 -121
- data/spec/data_models/pwm_spec.rb +38 -0
- data/spec/fabricators/collection_fabricator.rb +2 -2
- data/spec/fabricators/motif_fabricator.rb +33 -0
- data/spec/fabricators/motif_formats_fabricator.rb +125 -0
- data/spec/fabricators/pcm_fabricator.rb +25 -0
- data/spec/fabricators/pm_fabricator.rb +10 -1
- data/spec/fabricators/ppm_fabricator.rb +14 -0
- data/spec/fabricators/pwm_fabricator.rb +16 -0
- data/spec/parsers/trivial_parser_spec.rb +12 -12
- data/spec/parsers/yaml_parser_spec.rb +11 -11
- data/spec/spec_helper.rb +19 -49
- data/spec/spec_helper_source.rb +59 -0
- metadata +78 -7
data/lib/bioinform/version.rb
CHANGED
@@ -0,0 +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'
|
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
|
21
|
+
|
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
|
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
|
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
|
45
|
+
|
46
|
+
##################################
|
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] }
|
52
|
+
|
53
|
+
Given(:command) { options.shellsplit + arguments.shellsplit }
|
54
|
+
|
55
|
+
Given(:sp1_f1){ Fabricate(:SP1_f1_plain_text) }
|
56
|
+
Given(:klf4_f2){ Fabricate(:KLF4_f2_plain_text) }
|
57
|
+
|
58
|
+
########################################################
|
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'
|
68
|
+
|
69
|
+
context 'with most options specified' do
|
70
|
+
include_context 'completely specified option list'
|
71
|
+
include_context 'most common options'
|
72
|
+
|
73
|
+
include_examples 'single motif specified'
|
74
|
+
include_examples 'several motifs specified'
|
75
|
+
end
|
76
|
+
|
77
|
+
include_examples 'motif list is empty'
|
78
|
+
end
|
79
|
+
|
80
|
+
########################################################
|
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'
|
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
|
+
}
|
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'
|
102
|
+
|
103
|
+
include_examples 'single motif specified'
|
104
|
+
include_examples 'several motifs specified'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -1,185 +1,188 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
- -
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
1
|
+
--- !ruby/object:Bioinform::Collection
|
2
|
+
container:
|
3
|
+
- !ruby/object:Bioinform::Motif
|
4
|
+
parameters: !ruby/object:OpenStruct
|
5
|
+
table:
|
6
|
+
:original_data_model: :pm
|
7
|
+
:pm: !ruby/object:Bioinform::PM
|
8
|
+
parameters: !ruby/object:OpenStruct
|
9
|
+
table:
|
10
|
+
:name: GABPA_f1
|
11
|
+
:background:
|
12
|
+
- 1
|
13
|
+
- 1
|
14
|
+
- 1
|
15
|
+
- 1
|
16
|
+
modifiable: true
|
17
|
+
matrix:
|
18
|
+
- - -0.1106670158341858
|
19
|
+
- 0.013801606113892391
|
20
|
+
- 0.6054596108973699
|
21
|
+
- -1.3518085041421573
|
22
|
+
- - 0.37030668921643345
|
23
|
+
- 0.15761121480429963
|
24
|
+
- 0.009069314183831202
|
25
|
+
- -0.9888619717703562
|
26
|
+
- - 0.47526546359546684
|
27
|
+
- -0.3011678534572083
|
28
|
+
- 0.4031522994412777
|
29
|
+
- -1.8638752827041059
|
30
|
+
- - -1.5544255540164373
|
31
|
+
- 1.1082369687811506
|
32
|
+
- -0.2814091552834454
|
33
|
+
- -5.30708531823271
|
34
|
+
- - -0.6362037835776368
|
35
|
+
- 1.235338189985594
|
36
|
+
- -3.5801322928552253
|
37
|
+
- -5.717323067092849
|
38
|
+
- - -5.852906870733575
|
39
|
+
- -5.852906870733575
|
40
|
+
- 1.3841383838057746
|
41
|
+
- -5.852906870733575
|
42
|
+
- - -5.852906870733575
|
43
|
+
- -5.852906870733575
|
44
|
+
- 1.3841383838057746
|
45
|
+
- -5.852906870733575
|
46
|
+
- - 1.3835219739184708
|
47
|
+
- -5.2341956006430985
|
48
|
+
- -5.852906870733575
|
49
|
+
- -5.852906870733575
|
50
|
+
- - 1.3756340514956562
|
51
|
+
- -5.394962755562375
|
52
|
+
- -5.394962755562375
|
53
|
+
- -3.401117964959733
|
54
|
+
- - -1.2176198315414444
|
55
|
+
- -3.109079898175411
|
56
|
+
- 1.2964067931472216
|
57
|
+
- -5.717323067092849
|
58
|
+
- - -1.3716559438167257
|
59
|
+
- -0.2761401935045069
|
60
|
+
- -1.8504445165866068
|
61
|
+
- 1.0404320473626856
|
62
|
+
- - -0.5440863133031895
|
63
|
+
- -0.48103682561971345
|
64
|
+
- 0.907381908447086
|
65
|
+
- -1.1280642594012078
|
66
|
+
- - 0.10557340209290218
|
67
|
+
- -0.01814819455289191
|
68
|
+
- 0.4381106695354074
|
69
|
+
- -1.0304105539540915
|
70
|
+
modifiable: true
|
71
|
+
- !ruby/object:Bioinform::Motif
|
72
|
+
parameters: !ruby/object:OpenStruct
|
73
|
+
table:
|
74
|
+
:original_data_model: :pm
|
75
|
+
:pm: !ruby/object:Bioinform::PM
|
76
|
+
parameters: !ruby/object:OpenStruct
|
77
|
+
table:
|
78
|
+
:name: KLF4_f2
|
79
|
+
:background:
|
80
|
+
- 1
|
81
|
+
- 1
|
82
|
+
- 1
|
83
|
+
- 1
|
84
|
+
modifiable: true
|
85
|
+
matrix:
|
86
|
+
- - 0.30861857265872605
|
87
|
+
- -2.254321000121579
|
88
|
+
- 0.13505703522674192
|
89
|
+
- 0.3285194224375633
|
90
|
+
- - -1.227018967707036
|
91
|
+
- -4.814127713368663
|
92
|
+
- 1.3059890687390967
|
93
|
+
- -4.908681463544344
|
94
|
+
- - -2.443469374521196
|
95
|
+
- -4.648238485031404
|
96
|
+
- 1.3588686548279805
|
97
|
+
- -4.441801801188402
|
98
|
+
- - -2.7177827948276123
|
99
|
+
- -3.8073538975356565
|
100
|
+
- 1.356272809724262
|
101
|
+
- -3.504104725510225
|
102
|
+
- - -0.5563232977367343
|
103
|
+
- 0.5340697765121405
|
104
|
+
- -3.61417723090579
|
105
|
+
- 0.5270259776377405
|
106
|
+
- - -1.8687622060887386
|
107
|
+
- -4.381483976582316
|
108
|
+
- 1.337932245336098
|
109
|
+
- -3.815629658877517
|
110
|
+
- - -2.045671123823928
|
111
|
+
- -2.384975142213679
|
112
|
+
- 0.7198551207724355
|
113
|
+
- 0.5449254135616948
|
114
|
+
- - -1.373157530374372
|
115
|
+
- -3.0063112097748217
|
116
|
+
- 1.285188335493552
|
117
|
+
- -2.5026044231773543
|
118
|
+
- - -2.1030513122772208
|
119
|
+
- -1.8941348100402244
|
120
|
+
- 1.249265758393991
|
121
|
+
- -1.4284210948906104
|
122
|
+
- - -1.3277128628152939
|
123
|
+
- 0.8982415633049462
|
124
|
+
- -0.8080773665408135
|
125
|
+
- -0.18161647647456935
|
126
|
+
modifiable: true
|
127
|
+
- !ruby/object:Bioinform::Motif
|
128
|
+
parameters: !ruby/object:OpenStruct
|
129
|
+
table:
|
130
|
+
:original_data_model: :pm
|
131
|
+
:pm: !ruby/object:Bioinform::PM
|
132
|
+
parameters: !ruby/object:OpenStruct
|
133
|
+
table:
|
134
|
+
:name: SP1_f1
|
135
|
+
:background:
|
136
|
+
- 1
|
137
|
+
- 1
|
138
|
+
- 1
|
139
|
+
- 1
|
140
|
+
modifiable: true
|
141
|
+
matrix:
|
142
|
+
- - -0.24435707885585292
|
143
|
+
- -0.674823404693731
|
144
|
+
- 0.8657012535789866
|
145
|
+
- -1.1060188862599287
|
146
|
+
- - -1.0631255752097797
|
147
|
+
- -2.111925969423868
|
148
|
+
- 1.0960627561110403
|
149
|
+
- -0.6138563775211977
|
150
|
+
- - -0.3872276234760535
|
151
|
+
- -2.9739851913218045
|
152
|
+
- 1.1807800242010378
|
153
|
+
- -4.338927525031566
|
154
|
+
- - -4.563896055436894
|
155
|
+
- -2.9161633002532277
|
156
|
+
- 1.3684371349982638
|
157
|
+
- -5.077972423609655
|
158
|
+
- - -2.2369752892820083
|
159
|
+
- -3.7196436313301846
|
160
|
+
- 1.3510439136452734
|
161
|
+
- -4.889930670508233
|
162
|
+
- - -0.07473964149330865
|
163
|
+
- 0.944919654762011
|
164
|
+
- -2.6246857648086044
|
165
|
+
- -0.8510983487822436
|
166
|
+
- - -1.9643526491643322
|
167
|
+
- -2.978402770880115
|
168
|
+
- 1.3113096718240573
|
169
|
+
- -2.324334259499025
|
170
|
+
- - -4.0155484139655835
|
171
|
+
- -3.1384268078096667
|
172
|
+
- 1.3387488589788057
|
173
|
+
- -2.084673903537648
|
174
|
+
- - -0.44509385828355363
|
175
|
+
- -2.2510053061629702
|
176
|
+
- 1.1265431574368685
|
177
|
+
- -1.7780413702431372
|
178
|
+
- - -1.1896356092245048
|
179
|
+
- -1.2251832285630027
|
180
|
+
- 1.1636760063747527
|
181
|
+
- -1.6080243648157353
|
182
|
+
- - -0.5166047365590571
|
183
|
+
- 0.7641033353626657
|
184
|
+
- -0.2862677570028208
|
185
|
+
- -0.68254820978656
|
186
|
+
modifiable: true
|
184
187
|
parameters: !ruby/object:OpenStruct
|
185
188
|
table: {}
|