macroape 3.3.6 → 3.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +18 -18
  2. data/Gemfile +4 -4
  3. data/LICENSE +21 -21
  4. data/README.md +69 -67
  5. data/TODO.txt +1 -1
  6. data/benchmark/benchmark_helper.rb +5 -0
  7. data/benchmark/similarity_benchmark.rb +1 -4
  8. data/bin/align_motifs +1 -1
  9. data/bin/eval_alignment +1 -1
  10. data/bin/eval_similarity +1 -1
  11. data/bin/find_pvalue +1 -1
  12. data/bin/find_threshold +1 -1
  13. data/bin/preprocess_collection +1 -1
  14. data/bin/scan_collection +1 -1
  15. data/lib/macroape/aligned_pair_intersection.rb +1 -1
  16. data/lib/macroape/cli/align_motifs.rb +4 -4
  17. data/lib/macroape/cli/eval_alignment.rb +9 -6
  18. data/lib/macroape/cli/eval_similarity.rb +9 -6
  19. data/lib/macroape/cli/find_pvalue.rb +3 -3
  20. data/lib/macroape/cli/find_threshold.rb +3 -3
  21. data/lib/macroape/cli/preprocess_collection.rb +37 -13
  22. data/lib/macroape/cli/scan_collection.rb +28 -21
  23. data/lib/macroape/counting.rb +7 -13
  24. data/lib/macroape/pwm_compare.rb +8 -15
  25. data/lib/macroape/pwm_compare_aligned.rb +11 -38
  26. data/lib/macroape/version.rb +1 -1
  27. data/lib/macroape.rb +6 -7
  28. data/macroape.gemspec +1 -1
  29. data/spec/count_distribution_spec.rb +2 -3
  30. data/spec/spec_helper.rb +2 -2
  31. data/test/align_motifs_test.rb +1 -1
  32. data/test/data/KLF4_f2_scan_results_all.txt +4 -4
  33. data/test/data/KLF4_f2_scan_results_precise_mode.txt +4 -4
  34. data/test/data/collection_pcm_without_thresholds.yaml +185 -0
  35. data/test/data/collection_without_thresholds.yaml +185 -0
  36. data/test/data/medium_motif.pat +8 -0
  37. data/test/data/short_motif.pat +7 -0
  38. data/test/data/test_collection.yaml +27 -18
  39. data/test/eval_alignment_test.rb +1 -1
  40. data/test/eval_similarity_test.rb +1 -1
  41. data/test/find_pvalue_test.rb +1 -1
  42. data/test/find_threshold_test.rb +1 -1
  43. data/test/preprocess_collection_test.rb +59 -37
  44. data/test/scan_collection_test.rb +10 -1
  45. data/test/test_helper.rb +13 -9
  46. metadata +15 -6
@@ -0,0 +1,7 @@
1
+ short_motif_name
2
+ 0.30861857265872605 -2.254321000121579 0.13505703522674192 0.3285194224375633
3
+ -1.227018967707036 -4.814127713368663 1.3059890687390967 -4.908681463544344
4
+ -2.443469374521196 -4.648238485031404 1.3588686548279805 -4.441801801188402
5
+ -2.7177827948276123 -3.8073538975356565 1.356272809724262 -3.504104725510225
6
+ -0.5563232977367343 0.5340697765121405 -3.61417723090579 0.5270259776377405
7
+ -1.8687622060887386 -4.381483976582316 1.337932245336098 -3.815629658877517
@@ -1,6 +1,17 @@
1
- --- &18156900 !ruby/object:Bioinform::Collection
1
+ --- &19230696 !ruby/object:Bioinform::Collection
2
2
  collection:
3
3
  - - !ruby/object:Bioinform::PWM
4
+ parameters: !ruby/object:OpenStruct
5
+ table:
6
+ :name: GABPA_f1
7
+ :tags:
8
+ - *19230696
9
+ :background: &19231104
10
+ - 1
11
+ - 1
12
+ - 1
13
+ - 1
14
+ modifiable: true
4
15
  matrix:
5
16
  - - -0.1106670158341858
6
17
  - 0.013801606113892391
@@ -54,14 +65,6 @@ collection:
54
65
  - -0.01814819455289191
55
66
  - 0.4381106695354074
56
67
  - -1.0304105539540915
57
- name: GABPA_f1
58
- tags:
59
- - *18156900
60
- background: &18124572
61
- - 1
62
- - 1
63
- - 1
64
- - 1
65
68
  max_hash_size: 1000000
66
69
  - !ruby/object:OpenStruct
67
70
  table:
@@ -74,6 +77,13 @@ collection:
74
77
  0.0001: 7.609999999999999
75
78
  0.0005: 4.51
76
79
  - - !ruby/object:Bioinform::PWM
80
+ parameters: !ruby/object:OpenStruct
81
+ table:
82
+ :name: KLF4_f2
83
+ :tags:
84
+ - *19230696
85
+ :background: *19231104
86
+ modifiable: true
77
87
  matrix:
78
88
  - - 0.30861857265872605
79
89
  - -2.254321000121579
@@ -115,10 +125,6 @@ collection:
115
125
  - 0.8982415633049462
116
126
  - -0.8080773665408135
117
127
  - -0.18161647647456935
118
- name: KLF4_f2
119
- tags:
120
- - *18156900
121
- background: *18124572
122
128
  max_hash_size: 1000000
123
129
  - !ruby/object:OpenStruct
124
130
  table:
@@ -131,6 +137,13 @@ collection:
131
137
  0.0001: 7.909999999999999
132
138
  0.0005: 5.8100000000000005
133
139
  - - !ruby/object:Bioinform::PWM
140
+ parameters: !ruby/object:OpenStruct
141
+ table:
142
+ :name: SP1_f1
143
+ :tags:
144
+ - *19230696
145
+ :background: *19231104
146
+ modifiable: true
134
147
  matrix:
135
148
  - - -0.24435707885585292
136
149
  - -0.674823404693731
@@ -176,10 +189,6 @@ collection:
176
189
  - 0.7641033353626657
177
190
  - -0.2862677570028208
178
191
  - -0.68254820978656
179
- name: SP1_f1
180
- tags:
181
- - *18156900
182
- background: *18124572
183
192
  max_hash_size: 1000000
184
193
  - !ruby/object:OpenStruct
185
194
  table:
@@ -195,7 +204,7 @@ parameters: !ruby/object:OpenStruct
195
204
  table:
196
205
  :rough_discretization: 1
197
206
  :precise_discretization: 10
198
- :background: *18124572
207
+ :background: *19231104
199
208
  :pvalues:
200
209
  - 0.0005
201
210
  - 0.0001
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
 
3
3
  class TestEvalAlignment < Test::Unit::TestCase
4
4
  def test_process_pcm_files
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
 
3
3
  class TestEvalSimilarity < Test::Unit::TestCase
4
4
  def test_process_pair_of_pcms
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
 
3
3
  class FindPvalueTest < Test::Unit::TestCase
4
4
  def test_process_pcm
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
 
3
3
  class FindThresholdTest < Test::Unit::TestCase
4
4
  def test_process_several_pvalues
@@ -1,48 +1,70 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
  require 'yaml'
3
- require 'macroape'
3
+
4
+ # Don't use YAML.load_file() instead of YAML.load(File.read()) because in ruby before v1.93 p194
5
+ # it doesn't immediately release file descriptor (if I understood error right way) so File.delete fails
4
6
 
5
7
  class TestPreprocessCollection < Test::Unit::TestCase
6
- def test_multipvalue_preproceessing
7
- Helpers.run_preprocess_collection('test/data/test_collection -o test/data/test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
8
- # Don't use YAML.load_file() instead of YAML.load(File.read()) because in ruby before v1.93 p194
9
- # it doesn't immediately release file descriptor (if I understood error right way) so File.delete fails
10
- assert_equal YAML.load(File.read('test/data/test_collection.yaml')), YAML.load(File.read('test/data/test_collection.yaml.tmp'))
11
- File.delete 'test/data/test_collection.yaml.tmp'
12
- end
13
-
14
- def test_preproceessing_collection_from_a_single_file
15
- Helpers.run_preprocess_collection('test/data/test_collection_single_file.txt -o test/data/test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
16
- assert_equal YAML.load(File.read('test/data/test_collection.yaml')), YAML.load(File.read('test/data/test_collection.yaml.tmp'))
17
- File.delete 'test/data/test_collection.yaml.tmp'
18
- end
19
-
20
- def test_preproceessing_collection_from_stdin
21
- Helpers.provide_stdin(File.read('test/data/test_collection_single_file.txt')){
22
- Helpers.run_preprocess_collection('.stdin -o test/data/test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
8
+ def setup
9
+ @start_dir = Dir.pwd
10
+ Dir.chdir File.join(File.dirname(__FILE__), 'data')
11
+ end
12
+ def teardown
13
+ File.delete('test_collection.yaml.tmp') if File.exist? 'test_collection.yaml.tmp'
14
+ Dir.chdir(@start_dir)
15
+ end
16
+
17
+ def test_multipvalue_preprocessing
18
+ Helpers.run_preprocess_collection('test_collection -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
19
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
20
+ end
21
+
22
+ def test_preprocessing_collection_from_a_single_file
23
+ Helpers.run_preprocess_collection('test_collection_single_file.txt -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
24
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
25
+ end
26
+
27
+ def test_preprocessing_collection_from_stdin
28
+ Helpers.provide_stdin('test_collection/GABPA_f1.pat test_collection/KLF4_f2.pat test_collection/SP1_f1.pat'){
29
+ Helpers.run_preprocess_collection('.stdin -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
23
30
  }
24
- assert_equal YAML.load(File.read('test/data/test_collection.yaml')), YAML.load(File.read('test/data/test_collection.yaml.tmp'))
25
- File.delete 'test/data/test_collection.yaml.tmp'
31
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
26
32
  end
27
33
 
28
- def test_preproceessing_folder_pcm
29
- Helpers.run_preprocess_collection('test/data/test_collection_pcm -o test/data/test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent --pcm')
30
- assert_equal YAML.load(File.read('test/data/test_collection.yaml')), YAML.load(File.read('test/data/test_collection.yaml.tmp'))
31
- File.delete 'test/data/test_collection.yaml.tmp'
34
+ def test_preprocessing_folder_pcm
35
+ Helpers.run_preprocess_collection('test_collection_pcm -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent --pcm')
36
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
32
37
  end
33
-
34
- def test_preproceessing_collection_from_a_single_file_pcm
35
- Helpers.run_preprocess_collection('test/data/test_collection_single_file_pcm.txt -o test/data/test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent --pcm')
36
- assert_equal YAML.load(File.read('test/data/test_collection.yaml')), YAML.load(File.read('test/data/test_collection.yaml.tmp'))
37
- File.delete 'test/data/test_collection.yaml.tmp'
38
+
39
+ def test_preprocessing_collection_from_a_single_file_pcm
40
+ Helpers.run_preprocess_collection('test_collection_single_file_pcm.txt -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent --pcm')
41
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
42
+ end
43
+
44
+ def test_preprocessing_collection_from_a_collection
45
+ Helpers.run_preprocess_collection('collection_without_thresholds.yaml -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
46
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
47
+ end
48
+ def test_preprocessing_collection_from_a_pcm_collection
49
+ Helpers.run_preprocess_collection('collection_pcm_without_thresholds.yaml -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent --pcm')
50
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
38
51
  end
39
-
40
- def test_preproceessing_collection_from_stdin_pcm
41
- Helpers.provide_stdin(File.read('test/data/test_collection_single_file_pcm.txt')){
42
- Helpers.run_preprocess_collection('.stdin -o test/data/test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent --pcm')
52
+
53
+ def test_preprocessing_collection_from_stdin_pcm
54
+ Helpers.provide_stdin('test_collection_pcm/GABPA_f1.pcm test_collection_pcm/KLF4_f2.pcm test_collection_pcm/SP1_f1.pcm'){
55
+ Helpers.run_preprocess_collection('.stdin -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent --pcm')
43
56
  }
44
- assert_equal YAML.load(File.read('test/data/test_collection.yaml')), YAML.load(File.read('test/data/test_collection.yaml.tmp'))
45
- File.delete 'test/data/test_collection.yaml.tmp'
57
+ assert_equal YAML.load(File.read('test_collection.yaml')), YAML.load(File.read('test_collection.yaml.tmp'))
58
+ end
59
+
60
+ def test_with_name_specified
61
+ Helpers.run_preprocess_collection('test_collection -n my_collection -p 0.0005 0.0001 0.00005 --silent')
62
+ assert_equal YAML.load(File.read('test_collection.yaml')).set_parameters(name:'my_collection'), YAML.load(File.read('my_collection.yaml'))
63
+ File.delete('my_collection.yaml')
46
64
  end
47
65
 
48
- end
66
+ def test_with_name_and_output_specified
67
+ Helpers.run_preprocess_collection('test_collection -n my_collection -o test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent')
68
+ assert_equal YAML.load(File.read('test_collection.yaml')).set_parameters(name:'my_collection'), YAML.load(File.read('test_collection.yaml.tmp'))
69
+ end
70
+ end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require_relative 'test_helper'
2
2
 
3
3
  class TestScanCollection < Test::Unit::TestCase
4
4
  def test_scan_pcm
@@ -24,4 +24,13 @@ class TestScanCollection < Test::Unit::TestCase
24
24
  Helpers.scan_collection_output('.stdin test/data/test_collection.yaml --silent')
25
25
  }
26
26
  end
27
+
28
+ def test_scan_medium_length_motif
29
+ assert_match /Query motif medium_motif_name gives 0 recognized words for a given P-value of 0\.0005 with the rough discretization level of 1. Forcing precise discretization level of 10/,
30
+ Helpers.scan_collection_stderr('test/data/medium_motif.pat test/data/test_collection.yaml --precise --all --silent').gsub("\r\n", "\n")
31
+ end
32
+ def test_scan_short_length_motif
33
+ assert_match /Query motif short_motif_name gives 0 recognized words for a given P-value of 0\.0005 with the precise discretization level of 10\. It.s impossible to scan collection for this motif/,
34
+ Helpers.scan_collection_stderr('test/data/short_motif.pat test/data/test_collection.yaml --precise --all --silent').gsub("\r\n", "\n")
35
+ end
27
36
  end
data/test/test_helper.rb CHANGED
@@ -1,16 +1,17 @@
1
- $lib_folder = File.dirname(__FILE__) + '/../lib'
2
- $LOAD_PATH.unshift $lib_folder
1
+ $bioinform_folder = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bioinform', 'lib'))
2
+ $LOAD_PATH.unshift $bioinform_folder
3
+
3
4
  require 'test/unit'
4
5
  require 'stringio'
5
6
  require 'shellwords'
6
7
 
7
- require 'macroape/cli/find_threshold'
8
- require 'macroape/cli/find_pvalue'
9
- require 'macroape/cli/eval_similarity'
10
- require 'macroape/cli/eval_alignment'
11
- require 'macroape/cli/preprocess_collection'
12
- require 'macroape/cli/scan_collection'
13
- require 'macroape/cli/align_motifs'
8
+ require_relative '../lib/macroape/cli/find_threshold'
9
+ require_relative '../lib/macroape/cli/find_pvalue'
10
+ require_relative '../lib/macroape/cli/eval_similarity'
11
+ require_relative '../lib/macroape/cli/eval_alignment'
12
+ require_relative '../lib/macroape/cli/preprocess_collection'
13
+ require_relative '../lib/macroape/cli/scan_collection'
14
+ require_relative '../lib/macroape/cli/align_motifs'
14
15
 
15
16
  module Helpers
16
17
  # from minitest
@@ -65,6 +66,9 @@ module Helpers
65
66
  def self.scan_collection_output(param_list)
66
67
  capture_output{ Macroape::CLI::ScanCollection.main(param_list.shellsplit) }
67
68
  end
69
+ def self.scan_collection_stderr(param_list)
70
+ capture_stderr{ Macroape::CLI::ScanCollection.main(param_list.shellsplit) }
71
+ end
68
72
  def self.run_preprocess_collection(param_list)
69
73
  Macroape::CLI::PreprocessCollection.main(param_list.shellsplit)
70
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macroape
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.6
4
+ version: 3.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
12
+ date: 2012-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bioinform
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.1.7
21
+ version: 0.1.8
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.1.7
29
+ version: 0.1.8
30
30
  description: Macroape is an abbreviation for MAtrix CompaRisOn by Approximate P-value
31
31
  Estimation. It's a bioinformatic tool for evaluating similarity measure and best
32
32
  alignment between a pair of Position Weight Matrices(PWM), finding thresholds by
@@ -51,6 +51,7 @@ files:
51
51
  - README.md
52
52
  - Rakefile.rb
53
53
  - TODO.txt
54
+ - benchmark/benchmark_helper.rb
54
55
  - benchmark/similarity_benchmark.rb
55
56
  - bin/align_motifs
56
57
  - bin/eval_alignment
@@ -89,6 +90,10 @@ files:
89
90
  - test/data/SP1_f1.pcm
90
91
  - test/data/SP1_f1_revcomp.pat
91
92
  - test/data/SP1_f1_revcomp.pcm
93
+ - test/data/collection_pcm_without_thresholds.yaml
94
+ - test/data/collection_without_thresholds.yaml
95
+ - test/data/medium_motif.pat
96
+ - test/data/short_motif.pat
92
97
  - test/data/test_collection.yaml
93
98
  - test/data/test_collection/GABPA_f1.pat
94
99
  - test/data/test_collection/KLF4_f2.pat
@@ -145,6 +150,10 @@ test_files:
145
150
  - test/data/SP1_f1.pcm
146
151
  - test/data/SP1_f1_revcomp.pat
147
152
  - test/data/SP1_f1_revcomp.pcm
153
+ - test/data/collection_pcm_without_thresholds.yaml
154
+ - test/data/collection_without_thresholds.yaml
155
+ - test/data/medium_motif.pat
156
+ - test/data/short_motif.pat
148
157
  - test/data/test_collection.yaml
149
158
  - test/data/test_collection/GABPA_f1.pat
150
159
  - test/data/test_collection/KLF4_f2.pat