macroape 3.3.2 → 3.3.3

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.
@@ -1,3 +1,3 @@
1
1
  module Macroape
2
- VERSION = "3.3.2"
2
+ VERSION = "3.3.3"
3
3
  end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'bioinform'
3
+ require 'macroape/counting'
4
+
5
+ describe Bioinform::PWM do
6
+ let :matrix_first do [[1,2,3,4],[10,20,30,40],[100,200,300,400]] end
7
+ let :matrix_second do [[1,2,3,4],[2,3,4,5]] end
8
+ let :pwm_first do Bioinform::PWM.new(matrix_first) end
9
+ let :pwm_second do Bioinform::PWM.new(matrix_second) end
10
+
11
+ context '#count_distribution_after_threshold' do
12
+
13
+ it 'should return hash of score => count for all scores >= threshold' do
14
+ distribution_first = pwm_first.count_distribution_after_threshold(0)
15
+ distribution_first.keys.should == Array.product(*matrix_first).map{|score_row| score_row.inject(&:+)}
16
+ distribution_first.values.uniq.should == [1]
17
+
18
+ distribution_second = pwm_second.count_distribution_after_threshold(0)
19
+ distribution_second.should == { 3=>1, 4=>2, 5=>3, 6=>4, 7=>3, 8=>2, 9=>1 }
20
+
21
+ distribution_second = pwm_second.count_distribution_after_threshold(5)
22
+ distribution_second.should == { 5=>3, 6=>4, 7=>3, 8=>2, 9=>1 }
23
+ end
24
+
25
+ it 'should use existing precalculated hash @count_distribution if it exists' do
26
+ pwm = pwm_second;
27
+ pwm.instance_variable_set :@count_distribution, { 3=>10, 4=>20, 5=>30, 6=>40, 7=>30, 8=>20, 9=>10 }
28
+
29
+ distribution_second = pwm.count_distribution_after_threshold(0)
30
+ distribution_second.should == { 3=>10, 4=>20, 5=>30, 6=>40, 7=>30, 8=>20, 9=>10 }
31
+
32
+ distribution_second = pwm.count_distribution_after_threshold(5)
33
+ distribution_second.should == { 5=>30, 6=>40, 7=>30, 8=>20, 9=>10 }
34
+ end
35
+ end
36
+
37
+ context '#count_distribution' do
38
+ it 'should return hash of score => count for all available scores' do
39
+ pwm_second.count_distribution.should == { 3=>1, 4=>2, 5=>3, 6=>4, 7=>3, 8=>2, 9=>1 }
40
+ end
41
+
42
+ it 'should cache calculation in @count_distribution' do
43
+ pwm = pwm_second;
44
+ pwm.instance_variable_set :@count_distribution, { 3=>10, 4=>20, 5=>30, 6=>40, 7=>30, 8=>20, 9=>10 }
45
+ pwm.count_distribution.should == { 3=>10, 4=>20, 5=>30, 6=>40, 7=>30, 8=>20, 9=>10 }
46
+
47
+ pwm.instance_variable_set :@count_distribution, nil
48
+ pwm.count_distribution.should == { 3=>1, 4=>2, 5=>3, 6=>4, 7=>3, 8=>2, 9=>1 }
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,4 @@
1
+ $lib_folder = File.dirname(__FILE__) + '/../lib'
2
+ $LOAD_PATH.unshift $lib_folder
3
+
4
+ require 'rspec'
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
+ puts "\n\neval_alignment test:"
3
4
  class TestEvalAlignmentSimilarity < Test::Unit::TestCase
4
5
  def test_process_at_optimal_alignment
5
6
  IO.popen(Helpers.exec_cmd('eval_alignment','test/data/KLF4_f2.pat test/data/SP1_f1.pat -1 direct')){|f|
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
+ puts "\n\neval_similarity test:"
3
4
  class TestEvalSimilarity < Test::Unit::TestCase
4
5
  def test_process_pair_of_pwms
5
6
  IO.popen(Helpers.exec_cmd('eval_similarity','test/data/KLF4_f2.pat test/data/SP1_f1.pat')){|f|
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
+ puts "\n\nfind_pvalue test:"
3
4
  class FindPvalueTest < Test::Unit::TestCase
4
5
  def test_process_one_threshold
5
6
  IO.popen(Helpers.exec_cmd('find_pvalue', 'test/data/KLF4_f2.pat 4.1719')){|f|
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
+ puts "\n\nfind_threshold test:"
3
4
  class FindThresholdTest < Test::Unit::TestCase
4
5
  def test_process_several_pvalues
5
6
  pvalues = []
@@ -2,6 +2,7 @@ require 'test_helper'
2
2
  require 'yaml'
3
3
  require 'macroape'
4
4
 
5
+ puts "\n\npreprocess_collection test:"
5
6
  class TestPreprocessCollection < Test::Unit::TestCase
6
7
  def test_multipvalue_preproceessing
7
8
  system(Helpers.exec_cmd('preprocess_collection','test/data/test_collection -o test/data/test_collection.yaml.tmp -p 0.0005 0.0001 0.00005 --silent'))
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
+ puts "\n\nscan_collection test:"
3
4
  class TestScanCollection < Test::Unit::TestCase
4
5
  def test_scan_default_cutoff
5
6
  assert_equal File.read('test/data/KLF4_f2_scan_results_default_cutoff.txt').gsub("\r\n", "\n"),
data/test/test_helper.rb CHANGED
@@ -1,12 +1,12 @@
1
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
2
- $LOAD_PATH.unshift File.dirname(__FILE__)
1
+ $lib_folder = File.dirname(__FILE__) + '/../lib'
2
+ $LOAD_PATH.unshift $lib_folder
3
3
  require 'test/unit'
4
4
 
5
5
  module Helpers
6
6
  def self.obtain_pvalue_by_threshold(args)
7
- IO.popen("find_pvalue #{args}",&:read).strip.split.last
7
+ IO.popen("ruby -I #{$lib_folder} #{$lib_folder}/macroape/exec/find_pvalue.rb #{args}",&:read).strip.split.last
8
8
  end
9
9
  def self.exec_cmd(executable, param_list)
10
- "ruby #{File.dirname(File.absolute_path __FILE__)}/../lib/macroape/exec/#{executable}.rb #{param_list}"
10
+ "ruby -I #{$lib_folder} #{$lib_folder}/macroape/exec/#{executable}.rb #{param_list}"
11
11
  end
12
12
  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.2
4
+ version: 3.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
12
+ date: 2012-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bioinform
@@ -48,7 +48,9 @@ files:
48
48
  - Gemfile
49
49
  - LICENSE
50
50
  - README.md
51
- - Rakefile
51
+ - Rakefile.rb
52
+ - TODO.txt
53
+ - benchmark/similarity_benchmark.rb
52
54
  - bin/eval_alignment
53
55
  - bin/eval_similarity
54
56
  - bin/find_pvalue
@@ -58,7 +60,7 @@ files:
58
60
  - lib/macroape.rb
59
61
  - lib/macroape/aligned_pair_intersection.rb
60
62
  - lib/macroape/collection.rb
61
- - lib/macroape/count_by_threshold.rb
63
+ - lib/macroape/counting.rb
62
64
  - lib/macroape/exec/eval_alignment.rb
63
65
  - lib/macroape/exec/eval_similarity.rb
64
66
  - lib/macroape/exec/find_pvalue.rb
@@ -67,9 +69,10 @@ files:
67
69
  - lib/macroape/exec/scan_collection.rb
68
70
  - lib/macroape/pwm_compare.rb
69
71
  - lib/macroape/pwm_compare_aligned.rb
70
- - lib/macroape/threshold_by_pvalue.rb
71
72
  - lib/macroape/version.rb
72
73
  - macroape.gemspec
74
+ - spec/count_distribution_spec.rb
75
+ - spec/spec_helper.rb
73
76
  - test/data/AHR_si.pat
74
77
  - test/data/KLF4_f2.pat
75
78
  - test/data/KLF4_f2_scan_results_all.txt
@@ -113,6 +116,8 @@ signing_key:
113
116
  specification_version: 3
114
117
  summary: PWM comparison tool using MACROAPE approach
115
118
  test_files:
119
+ - spec/count_distribution_spec.rb
120
+ - spec/spec_helper.rb
116
121
  - test/data/AHR_si.pat
117
122
  - test/data/KLF4_f2.pat
118
123
  - test/data/KLF4_f2_scan_results_all.txt
data/Rakefile DELETED
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
-
4
- namespace :spec do
5
- task :find_threshold do
6
- system("ruby -I ./test test/find_threshold_test.rb")
7
- end
8
- task :find_pvalue do
9
- system("ruby -I ./test test/find_pvalue_test.rb")
10
- end
11
- task :eval_similarity do
12
- system("ruby -I ./test test/eval_similarity_test.rb")
13
- end
14
- task :eval_alignment_similarity do
15
- system("ruby -I ./test test/eval_alignment_similarity_test.rb")
16
- end
17
- task :preprocess_collection do
18
- system("ruby -I ./test test/preprocess_collection_test.rb")
19
- end
20
- task :scan_collection do
21
- system("ruby -I ./test test/scan_collection_test.rb")
22
- end
23
- task :all => [:find_threshold, :find_pvalue, :eval_similarity,
24
- :eval_alignment_similarity, :scan_collection, :preprocess_collection]
25
- end
26
-
27
- desc 'Test all functionality of gem executables'
28
- task :spec => ['spec:all']
@@ -1,16 +0,0 @@
1
- require 'macroape/threshold_by_pvalue'
2
-
3
- module Bioinform
4
- class PWM
5
- def counts_by_thresholds(*thresholds)
6
- scores = count_distribution_after_threshold(thresholds.min)
7
- thresholds.map{ |threshold|
8
- scores.inject(0.0){|sum,(score,count)| (score >= threshold) ? sum + count : sum}
9
- }
10
- end
11
-
12
- def pvalue_by_threshold(threshold)
13
- counts_by_thresholds(threshold).first / vocabulary_volume
14
- end
15
- end
16
- end