bioinform 0.1.10 → 0.1.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8bc7b4338eb8a2d6cccf5871d7d85de1ad112f2
4
- data.tar.gz: db3c7503656a2e0696ebf12a1259a9765864c50b
3
+ metadata.gz: 981be4ea2c5a07809303b9d4ac6a43f5d816e2f9
4
+ data.tar.gz: 84aa6ce722f015b357c1ac87cbb0151c8f37a3d2
5
5
  SHA512:
6
- metadata.gz: b16199a16c56a35dff87e5a36b300d90a0bef49b09b1179d7fada64cbf4db3725ce57c2ae51efff730860af0f4cfc62efdb33d6b405a7583a476b8e2fa413e32
7
- data.tar.gz: 6ce68721c065e344f1da323a1c748f0e133c338f3c6f09b111b00fdb701dd49edcee2887fdaf3aef7e5c6b77044916944901ac91f0fd3387f842b798729de89a
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
- begin
27
- # Need support of N-letters and other IUPAC
28
- letter = word[pos]
26
+ letter = word[pos]
27
+ if IndexByLetter[letter]
29
28
  matrix[pos][IndexByLetter[letter]]
30
- rescue
31
- raise ArgumentError, 'word in PWM#score(word) should have only ACGT-letters'
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
@@ -1,3 +1,3 @@
1
1
  module Bioinform
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -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.10
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-29 00:00:00.000000000 Z
11
+ date: 2013-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport