bioinform 0.1.8 → 0.1.9

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