bioinform 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bioinform/data_models/pwm.rb +7 -6
- data/lib/bioinform/version.rb +1 -1
- data/spec/data_models/pwm_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 981be4ea2c5a07809303b9d4ac6a43f5d816e2f9
|
4
|
+
data.tar.gz: 84aa6ce722f015b357c1ac87cbb0151c8f37a3d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b60eaa7651a2880354673d0e9f40e11407c76e76cb8ce526b60283049ca1e9e6dafdf16d258f77146987c507adfcc8d252485a38130278204015cbaaa31c4c3
|
7
|
+
data.tar.gz: 45d806ad0a1befd381da35381f42d0cfcc1acd361bc35efa7ce9dacb203ab820e38564f8d93134ede8f5c380b1efc34ccc70ab1ee60ff7b3291c5ecc8d4e6c60
|
@@ -23,14 +23,15 @@ module Bioinform
|
|
23
23
|
raise ArgumentError, 'word in PWM#score(word) should have the same length as matrix' unless word.length == length
|
24
24
|
#raise ArgumentError, 'word in PWM#score(word) should have only ACGT-letters' unless word.each_char.all?{|letter| %w{A C G T}.include? letter}
|
25
25
|
(0...length).map do |pos|
|
26
|
-
|
27
|
-
|
28
|
-
letter = word[pos]
|
26
|
+
letter = word[pos]
|
27
|
+
if IndexByLetter[letter]
|
29
28
|
matrix[pos][IndexByLetter[letter]]
|
30
|
-
|
31
|
-
|
29
|
+
elsif letter == 'N'
|
30
|
+
matrix[pos].zip(probability).map{|el, p| el * p}.inject(0.0, &:+)
|
31
|
+
else
|
32
|
+
raise ArgumentError, "word in PWM#score(#{word}) should have only ACGT or N letters"
|
32
33
|
end
|
33
|
-
end.inject(&:+)
|
34
|
+
end.inject(0.0, &:+)
|
34
35
|
end
|
35
36
|
|
36
37
|
def to_pwm
|
data/lib/bioinform/version.rb
CHANGED
@@ -29,6 +29,10 @@ module Bioinform
|
|
29
29
|
pwm.score('agata').should == 13141
|
30
30
|
pwm.score('CCGCT').should == 22324
|
31
31
|
end
|
32
|
+
it 'should give score average score(considering probabilities) for a position for a N-letter' do
|
33
|
+
pwm.score('AANAA').should == (11011 + 250)
|
34
|
+
pwm.set_parameters(background: [0.1,0.4,0.1,0.4]).score('AANAA').should == (11011 + 0.1*100 + 0.4*200 + 0.1*300 + 0.4*400)
|
35
|
+
end
|
32
36
|
it 'should raise an ArgumentError if word contain bad letter' do
|
33
37
|
expect{ pwm.score('AAAAV') }.to raise_error(ArgumentError)
|
34
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bioinform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Vorontsov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|