macroape 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/Rakefile.rb +65 -0
- data/TODO.txt +20 -0
- data/benchmark/similarity_benchmark.rb +56 -0
- data/lib/macroape.rb +1 -2
- data/lib/macroape/aligned_pair_intersection.rb +43 -116
- data/lib/macroape/collection.rb +4 -4
- data/lib/macroape/{threshold_by_pvalue.rb → counting.rb} +28 -18
- data/lib/macroape/exec/eval_alignment.rb +19 -22
- data/lib/macroape/exec/eval_similarity.rb +13 -13
- data/lib/macroape/exec/find_pvalue.rb +7 -7
- data/lib/macroape/exec/find_threshold.rb +8 -8
- data/lib/macroape/exec/preprocess_collection.rb +8 -8
- data/lib/macroape/exec/scan_collection.rb +16 -16
- data/lib/macroape/pwm_compare.rb +2 -3
- data/lib/macroape/pwm_compare_aligned.rb +34 -26
- data/lib/macroape/version.rb +1 -1
- data/spec/count_distribution_spec.rb +52 -0
- data/spec/spec_helper.rb +4 -0
- data/test/eval_alignment_similarity_test.rb +1 -0
- data/test/eval_similarity_test.rb +1 -0
- data/test/find_pvalue_test.rb +1 -0
- data/test/find_threshold_test.rb +1 -0
- data/test/preprocess_collection_test.rb +1 -0
- data/test/scan_collection_test.rb +1 -0
- data/test/test_helper.rb +4 -4
- metadata +10 -5
- data/Rakefile +0 -28
- data/lib/macroape/count_by_threshold.rb +0 -16
data/lib/macroape/version.rb
CHANGED
@@ -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
|
data/spec/spec_helper.rb
ADDED
data/test/find_pvalue_test.rb
CHANGED
data/test/find_threshold_test.rb
CHANGED
@@ -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'))
|
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
$
|
2
|
-
$LOAD_PATH.unshift
|
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 #{
|
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.
|
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-
|
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/
|
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
|