bio-hmmer_model 0.0.1 → 0.0.2

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.
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ source "http://rubygems.org"
8
8
  group :development do
9
9
  gem "shoulda", ">= 0"
10
10
  gem "rdoc", "~> 3.12"
11
- gem "bundler", "~> 1.0.0"
11
+ gem "bundler", "> 1.0.0"
12
12
  gem "jeweler", "~> 1.8.3"
13
13
  gem "bio", ">= 1.4.2"
14
14
  gem "rdoc", "~> 3.12"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,39 +1,40 @@
1
- ## Example HMM model file, taken from PFAM 26.
2
-
3
- # HMMER3/b [3.0 | March 2010]
4
- # NAME 1-cysPrx_C
5
- # ACC PF10417.4
6
- # DESC C-terminal domain of 1-Cys peroxiredoxin
7
- # LENG 40
8
- # ALPH amino
9
- # RF no
10
- # CS yes
11
- # MAP yes
12
- # DATE Mon Sep 26 01:36:52 2011
13
- # NSEQ 86
14
- # EFFN 26.221497
15
- # CKSUM 2893062708
16
- # GA 20.40 20.40;
17
- # TC 20.40 20.50;
18
- # NC 20.30 20.30;
19
- # BM hmmbuild HMM.ann SEED.ann
20
- # SM hmmsearch -Z 15929002 -E 1000 --cpu 4 HMM pfamseq
21
- # STATS LOCAL MSV -7.4458 0.71948
22
- # STATS LOCAL VITERBI -7.8857 0.71948
23
- # STATS LOCAL FORWARD -4.3017 0.71948
24
- # HMM A C D E F G H I K L M N P Q R S T V W Y
25
- # m->m m->i m->d i->m i->i d->m d->d
26
- # COMPO 2.25274 4.33630 2.74834 2.65826 3.87771 2.70273 3.95751 3.25125 2.56848 2.82101 4.06536 3.21194 2.50202 2.97228 3.39798 2.99665 2.70159 2.62185 3.52465 3.78187
27
- # 2.68618 4.42225 2.77519 2.73123 3.46354 2.40513 3.72494 3.29354 2.67741 2.69355 4.24690 2.90347 2.73739 3.18146 2.89801 2.37887 2.77519 2.98518 4.58477 3.61503
28
- # 0.00153 6.88065 7.60300 0.61958 0.77255 0.00000 *
29
- # 1 0.35002 6.53529 7.25102 7.30399 7.52698 2.51105 7.66616 7.05965 7.14684 6.75377 3.79371 6.32251 6.23186 7.14685 7.02553 1.76469 5.22656 6.02391 8.86510 7.90937 1 - H
30
- # 2.68618 4.42225 2.77519 2.73123 3.46354 2.40513 3.72494 3.29354 2.67741 2.69355 4.24690 2.90347 2.73739 3.18146 2.89801 2.37887 2.77519 2.98518 4.58477 3.61503
31
- # 0.00153 6.88065 7.60300 0.61958 0.77255 0.48576 0.95510
32
- # 2 3.84702 5.95842 6.58626 5.97181 2.06407 5.79758 6.11757 2.43011 5.76033 0.58540 3.17079 5.96610 6.11889 5.84497 5.74893 5.11667 4.83456 2.97676 3.47925 3.13829 2 - H
33
- # 2.68618 4.42225 2.77519 2.73123 3.46354 2.40513 3.72494 3.29354 2.67741 2.69355 4.24690 2.90347 2.73739 3.18146 2.89801 2.37887 2.77519 2.98518 4.58477 3.61503
34
- # 0.00153 6.88065 7.60300 0.61958 0.77255 0.48576 0.95510
1
+
35
2
  module Bio
36
3
  class HMMER
4
+ ## Example HMM model file, taken from PFAM 26.
5
+ #
6
+ # HMMER3/b [3.0 | March 2010]
7
+ # NAME 1-cysPrx_C
8
+ # ACC PF10417.4
9
+ # DESC C-terminal domain of 1-Cys peroxiredoxin
10
+ # LENG 40
11
+ # ALPH amino
12
+ # RF no
13
+ # CS yes
14
+ # MAP yes
15
+ # DATE Mon Sep 26 01:36:52 2011
16
+ # NSEQ 86
17
+ # EFFN 26.221497
18
+ # CKSUM 2893062708
19
+ # GA 20.40 20.40;
20
+ # TC 20.40 20.50;
21
+ # NC 20.30 20.30;
22
+ # BM hmmbuild HMM.ann SEED.ann
23
+ # SM hmmsearch -Z 15929002 -E 1000 --cpu 4 HMM pfamseq
24
+ # STATS LOCAL MSV -7.4458 0.71948
25
+ # STATS LOCAL VITERBI -7.8857 0.71948
26
+ # STATS LOCAL FORWARD -4.3017 0.71948
27
+ # HMM A C D E F G H I K L M N P Q R S T V W Y
28
+ # m->m m->i m->d i->m i->i d->m d->d
29
+ # COMPO 2.25274 4.33630 2.74834 2.65826 3.87771 2.70273 3.95751 3.25125 2.56848 2.82101 4.06536 3.21194 2.50202 2.97228 3.39798 2.99665 2.70159 2.62185 3.52465 3.78187
30
+ # 2.68618 4.42225 2.77519 2.73123 3.46354 2.40513 3.72494 3.29354 2.67741 2.69355 4.24690 2.90347 2.73739 3.18146 2.89801 2.37887 2.77519 2.98518 4.58477 3.61503
31
+ # 0.00153 6.88065 7.60300 0.61958 0.77255 0.00000 *
32
+ # 1 0.35002 6.53529 7.25102 7.30399 7.52698 2.51105 7.66616 7.05965 7.14684 6.75377 3.79371 6.32251 6.23186 7.14685 7.02553 1.76469 5.22656 6.02391 8.86510 7.90937 1 - H
33
+ # 2.68618 4.42225 2.77519 2.73123 3.46354 2.40513 3.72494 3.29354 2.67741 2.69355 4.24690 2.90347 2.73739 3.18146 2.89801 2.37887 2.77519 2.98518 4.58477 3.61503
34
+ # 0.00153 6.88065 7.60300 0.61958 0.77255 0.48576 0.95510
35
+ # 2 3.84702 5.95842 6.58626 5.97181 2.06407 5.79758 6.11757 2.43011 5.76033 0.58540 3.17079 5.96610 6.11889 5.84497 5.74893 5.11667 4.83456 2.97676 3.47925 3.13829 2 - H
36
+ # 2.68618 4.42225 2.77519 2.73123 3.46354 2.40513 3.72494 3.29354 2.67741 2.69355 4.24690 2.90347 2.73739 3.18146 2.89801 2.37887 2.77519 2.98518 4.58477 3.61503
37
+ # 0.00153 6.88065 7.60300 0.61958 0.77255 0.48576 0.95510
37
38
  class Model
38
39
  class ParseException<Exception; end
39
40
 
@@ -52,7 +53,14 @@ module Bio
52
53
  attr_accessor :transitions
53
54
 
54
55
  # Probabilities for matches in the model (first line of each position in the main model part of the HMMER3/b file format)
55
- # You probably want to use #match_probability not read this variable directly
56
+ # You probably want to use #match_probability not read this variable directly.
57
+ #
58
+ # For speed reasons, you may want to use this data directly, however.
59
+ #
60
+ # #match_emissions is an Array of Array objects:
61
+ # model#[position][amino_acid_index] => Probability of match
62
+ #
63
+ # amino_acid_index is an index of #alphabet
56
64
  attr_accessor :match_emissions
57
65
 
58
66
  # Probabilities for inserts in the model (second line of each position in the main model part of the HMMER3/b file format)
@@ -92,7 +100,7 @@ module Bio
92
100
  # Assumes that the letter supplied is in the HMM's alphabet
93
101
  def match_probability(hmm_position, letter)
94
102
  index = @alphabet.index(letter)
95
- match_emissions[hmm_position+1][index]
103
+ match_emissions[hmm_position-1][index]
96
104
  end
97
105
 
98
106
  # Parse a HMM file fed in through some IO, and return an instantiated
@@ -183,7 +191,7 @@ module Bio
183
191
  # All probability parameters are all stored as negative natural log probabilities with
184
192
  # five digits of precision to the right of the decimal point, rounded. For example,
185
193
  # a probability of 0.25 is stored as − log 0.25 = 1.38629.
186
- 10.0**-(s.to_f)
194
+ Math.exp(-(s.to_f))
187
195
  end
188
196
  model.match_emissions.push probabilities
189
197
  lineno += 1
@@ -5,13 +5,13 @@ class TestBioHmmerModel < Test::Unit::TestCase
5
5
  hmm = Bio::HMMER::Model.parse(File.open('test/data/PF10417.4.hmm'))
6
6
  assert_equal 86, hmm.nseq
7
7
  assert_equal 40, hmm.leng
8
- assert_in_delta 0.00000005, hmm.match_emissions[0][3], 1e-8
8
+ assert_in_delta 0.000672849, hmm.match_emissions[0][3], 0.000672849/10000
9
9
  assert_equal "hmmsearch -Z 15929002 -E 1000 --cpu 4 HMM pfamseq", hmm.sm
10
10
  assert_equal ['LOCAL','FORWARD',-4.3017,0.71948], hmm.stats[2]
11
11
  end
12
12
 
13
13
  should "give the correct match probability" do
14
14
  hmm = Bio::HMMER::Model.parse(File.open('test/data/PF10417.4.hmm'))
15
- assert_in_delta 0.000204904, hmm.match_probability(3, 'I'), 1e-4
15
+ assert_in_delta 0.025010739, hmm.match_probability(3, 'I'), 0.025010739/10000
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-hmmer_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-18 00:00:00.000000000 Z
12
+ date: 2012-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &77172790 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *77172790
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rdoc
27
- requirement: &77172310 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,21 +37,31 @@ dependencies:
32
37
  version: '3.12'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *77172310
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.12'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: bundler
38
- requirement: &77187640 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
- - - ~>
51
+ - - ! '>'
42
52
  - !ruby/object:Gem::Version
43
53
  version: 1.0.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *77187640
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>'
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: jeweler
49
- requirement: &77187000 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 1.8.3
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *77187000
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.3
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: bio
60
- requirement: &77186340 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 1.4.2
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *77186340
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.4.2
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: rdoc
71
- requirement: &77185790 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '3.12'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *77185790
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '3.12'
80
110
  description: Parse PFAM HMM definition files so that the models can be accessible
81
111
  programmatically
82
112
  email: donttrustben near gmail.com
@@ -115,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
145
  version: '0'
116
146
  segments:
117
147
  - 0
118
- hash: -141514351
148
+ hash: 67884365
119
149
  required_rubygems_version: !ruby/object:Gem::Requirement
120
150
  none: false
121
151
  requirements:
@@ -124,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
154
  version: '0'
125
155
  requirements: []
126
156
  rubyforge_project:
127
- rubygems_version: 1.8.17
157
+ rubygems_version: 1.8.24
128
158
  signing_key:
129
159
  specification_version: 3
130
160
  summary: Parse PFAM HMM definition files