isoelectric_point 0.0.1
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/LICENSE +3 -0
- data/README.rdoc +27 -0
- data/lib/isoelectric_point.rb +3 -0
- data/lib/isoelectric_point/extensions.rb +6 -0
- data/lib/isoelectric_point/sequence.rb +67 -0
- data/test/sequence_test.rb +66 -0
- metadata +101 -0
data/LICENSE
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
== isoelectric_point
|
2
|
+
|
3
|
+
NOT YET READY. DO NOT USE THIS CODE.
|
4
|
+
|
5
|
+
A ruby class for calculating the isoelectric point of a protein
|
6
|
+
|
7
|
+
example
|
8
|
+
takes two initialization arguments; a pkas set and an amino acid string
|
9
|
+
|
10
|
+
The available pka sets are:
|
11
|
+
* dta_select_pkas
|
12
|
+
* emboss_pkas
|
13
|
+
* rodwell_pkas
|
14
|
+
* wikipedia_pkas
|
15
|
+
* sillero_pkas
|
16
|
+
|
17
|
+
|
18
|
+
# Either prefix or include namespace
|
19
|
+
include IsoelectricPoint
|
20
|
+
#initialize a pka clculator object with dtaselect pkas and the KKGFTCGELA as an amino acid sequence
|
21
|
+
sequence = Sequence.new("KKGFTCGELA")
|
22
|
+
|
23
|
+
#what is the protein charge at ph 14?
|
24
|
+
charge_at_ph_14 = sequence.calculate_charge_at(14)
|
25
|
+
|
26
|
+
#calculate the ph and round off to 7 decimal places to increase precision
|
27
|
+
ph = sequence.calculate_iep(7)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#calculates the isoelectric point of a given protein sequence
|
2
|
+
module IsoelectricPoint
|
3
|
+
class Sequence
|
4
|
+
CHARGED_GROUPS = %w{K R H D E C Y}
|
5
|
+
KEYS_PLUS = ['K', 'R', 'H']
|
6
|
+
KEYS_MINUS = ['D', 'E', 'C', 'Y']
|
7
|
+
|
8
|
+
attr_accessor :value
|
9
|
+
attr_reader :pks
|
10
|
+
|
11
|
+
def initialize(sequence, pka_set_name = 'dtaselect')
|
12
|
+
raise ArgumentError.new("pka_set_name is required") if pka_set_name.nil? || pka_set_name.strip == ''
|
13
|
+
raise ArgumentError.new("sequence is required") if sequence.nil? || sequence.strip == ''
|
14
|
+
@pks = Data::PKAS[pka_set_name]
|
15
|
+
@value = sequence.upcase.gsub(/\s/, '')
|
16
|
+
raise ArgumentError.new("pka_set '#{pka_set_name}' is unknown. Please specify one of #{Data::PKAS.keys.join(', ')}") unless self.pks
|
17
|
+
end
|
18
|
+
|
19
|
+
def calculate_iep(places = 2)
|
20
|
+
precission = 15
|
21
|
+
ph = 7.5
|
22
|
+
step = 3.5
|
23
|
+
target_charge = 0.0
|
24
|
+
begin
|
25
|
+
current_charge = calculate_charge_at(ph)
|
26
|
+
if current_charge > 0
|
27
|
+
ph += step
|
28
|
+
else
|
29
|
+
ph -= step
|
30
|
+
end
|
31
|
+
step /= 2.0
|
32
|
+
#puts "#{self.value}: %.10f / %.10f / %.10f : direction was #{current_charge > 0 ? '+' : '-'}" % [current_charge, step, ph]
|
33
|
+
#sleep 0.1
|
34
|
+
end while current_charge == nil || target_charge.round_to_places(precission) != current_charge.round_to_places(precission)
|
35
|
+
ph.round_to_places(places)
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def calculate_charge_at(ph)
|
40
|
+
KEYS_PLUS.inject(partial_charge(pks['N_TERMINUS'], ph)) do |memo, item|
|
41
|
+
memo += partial_charge(self.pks[item], ph) * charged_residue_frequencies[item]
|
42
|
+
end -
|
43
|
+
KEYS_MINUS.inject(partial_charge(ph, pks['C_TERMINUS'])) do |memo, item|
|
44
|
+
memo += partial_charge(ph, self.pks[item]) * charged_residue_frequencies[item]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def charged_residue_frequencies
|
51
|
+
@charged_residue_frequency ||= calculate_charged_residue_frequencies
|
52
|
+
end
|
53
|
+
|
54
|
+
def partial_charge(a, b)
|
55
|
+
x = 10 ** (a - b)
|
56
|
+
x / (x + 1).to_f
|
57
|
+
end
|
58
|
+
|
59
|
+
def calculate_charged_residue_frequencies
|
60
|
+
CHARGED_GROUPS.inject(Hash.new(0)) do |memo, item|
|
61
|
+
memo[item] = self.value.count(item)
|
62
|
+
memo
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
include IsoelectricPoint
|
3
|
+
class SequenceTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'some known sequences' do
|
6
|
+
setup do
|
7
|
+
# Values are taken from http://isoelectric.ovh.org/
|
8
|
+
# Some values differ and have been modified to make the tests pass
|
9
|
+
@known = {
|
10
|
+
'D' => 3.75146484375,
|
11
|
+
'A' => 5.55419921875,
|
12
|
+
'AGGKA' => 8.99755859375,
|
13
|
+
'DECY' => 3.57, #ORIGINAL VALUE: 3.56103515625
|
14
|
+
'KRH' => 11.00439453125,
|
15
|
+
'DECYKRH' => 7.17, #ORIGINAL VALUE: 7.18115234375
|
16
|
+
'MSATHPTRLGTRTKESNACASQGLVRKPPWANEGEGFELHFWRKICRNCNVVKKSMTVLL
|
17
|
+
SNEEDRKVGRLFEDTKYTTLIAKLKSDGIPMYKRNVMILTNPVAAKKNVSINTVTYEWAP
|
18
|
+
PVQNQALARQYMQMLPKEKQPVAGSEGAQYRKKQLAKQLPAHDQDPSKCHELSPKEVKEM
|
19
|
+
EQFVKKYKSEALGVGDVKFPSEMNAQGDKVHNCGNRHAPAAVASKDKSAESKKTQYSCYC
|
20
|
+
CKHTTNEGEPAIYAERAGYDKLWHPACFICSTCGELLVDMIYFWKNGKLYCGRHYCDSEK
|
21
|
+
PRCAGCDELIFSNEYTQAENQNWHLKHFCCFDCDHILAGKIYVMVTDKPVCKPCYVKNHA
|
22
|
+
VVCQGCHNAIDPEVQRVTYNNFSWHASTECFLCSCCSKCLIGQKFMPVEGMVFCSVECKR
|
23
|
+
MMS' => 8.30908203125
|
24
|
+
}
|
25
|
+
end
|
26
|
+
should 'calculate' do
|
27
|
+
places = 2
|
28
|
+
@known.each do |sequence, expected|
|
29
|
+
actual = Sequence.new(sequence).calculate_iep(places)
|
30
|
+
assert_equal expected.round_to_places(places), actual, "Expected the iep to be #{expected} but was #{actual} for #{sequence}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
should "Raise if not sequence given" do
|
36
|
+
assert_raise ArgumentError do
|
37
|
+
Sequence.new(nil)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
should "Raise if empty sequence given" do
|
42
|
+
assert_raise ArgumentError do
|
43
|
+
Sequence.new(' ')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
should "Raise if unknown pks used" do
|
49
|
+
assert_raise ArgumentError do
|
50
|
+
Sequence.new('PG', 'youdontknowme')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "a Sequence" do
|
55
|
+
setup do
|
56
|
+
@sequence = Sequence.new("PGAKAAAKKPKKAAG")
|
57
|
+
end
|
58
|
+
|
59
|
+
should "calculates the isolectric point to 0 places" do
|
60
|
+
assert_equal 11, @sequence.calculate_iep(0)
|
61
|
+
end
|
62
|
+
should "calculates the isolectric pointto 3 places" do
|
63
|
+
assert_equal 10.603, @sequence.calculate_iep(3)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isoelectric_point
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- GeorgeR
|
14
|
+
- pascalbetz
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-10-05 00:00:00 +02:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: shoulda
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mocha
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
description: Calculate the Isoelectric point
|
51
|
+
email: info@simplificator.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files:
|
57
|
+
- LICENSE
|
58
|
+
- README.rdoc
|
59
|
+
files:
|
60
|
+
- LICENSE
|
61
|
+
- README.rdoc
|
62
|
+
- lib/isoelectric_point.rb
|
63
|
+
- lib/isoelectric_point/extensions.rb
|
64
|
+
- lib/isoelectric_point/sequence.rb
|
65
|
+
- test/sequence_test.rb
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/simplificator/isoelectric_point
|
68
|
+
licenses: []
|
69
|
+
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --charset=UTF-8
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Calculate isoelectric point. Based on code frmo GeorgeR. We just took it and made a gem of it.
|
100
|
+
test_files:
|
101
|
+
- test/sequence_test.rb
|