Top Level Namespace

Defined Under Namespace

Modules: Enumerable, MS, RThelper Classes: CurveFit, Fit_plot, GenCurvefit, Merger, Modifications, Mzml_Wrapper, Mzml_reader, PepCharges, Progress, String

Constant Summary collapse

Precision =
0.001
ResidueTable =
{
  :K => [2.18,8.95,10.53], 
  :E => [2.19,9.67,4.25], 
  :D => [1.88,9.60,3.65], 
  :H => [1.82,9.17,6.00],
  :R => [2.17,9.04,12.48],
  :Q => [2.17,9.13,nil],
  :N => [2.02,8.80,nil],
  :C => [1.96,10.28,8.18],
  :T => [2.11,9.62,nil],
  :S => [2.21,9.15,nil],
  :W => [2.38,9.39,nil],
  :Y => [2.20,9.11,10.07],
  :F => [1.83,9.13,nil],
  :M => [2.28,9.21,nil],
  :I => [2.36,9.68,nil],
  :L => [2.36,9.60,nil],
  :V => [2.32,9.62,nil],
  :P => [1.99,10.96,nil],
  :A => [2.34,9.69,nil],
  :G => [2.34,9.60,nil],
  # These are the fringe cases... B and Z... Jerks, these are harder to calculate pIs
  :B => [1.95,9.20,3.65],
  :Z => [2.18,9.40,4.25],
  :X => [2.20,9.40,nil],
  :U => [1.96,10.28,5.20] # Unfortunately, I've only found the pKr for this... so I've used Cysteine's values.
}
VERBOSE =
false
@@avg_mz =
0
@@avg_rt =
0

Instance Method Summary collapse

Instance Method Details

#calc_PI(pep_charges) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/ms/isoelectric_calc.rb', line 85

def calc_PI(pep_charges)
  pH = 8; pH_prev = 0.0; pH_next = 14.0
  charge = charge_at_pH(pep_charges, pH)
  while pH-pH_prev > Precision and pH_next-pH > Precision
    if charge < 0.0
      tmp = pH
      pH = pH - ((pH-pH_prev)/2)
      charge = charge_at_pH(pep_charges, pH)
      pH_next = tmp
    else
      tmp = pH
      pH = pH + ((pH_next - pH)/2)
      charge = charge_at_pH(pep_charges, pH)
      pH_prev = tmp
    end
    #	puts "charge: #{charge.round(2)}\tpH: #{pH.round(2)}\tpH_next: #{pH_next.round(2)}\tpH_prev: #{pH_prev.round(2)}"
  end
  pH
end

#charge_at_pH(pep_charges, pH) ⇒ Object

Returns the PepCharges structure



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ms/isoelectric_calc.rb', line 70

def charge_at_pH(pep_charges, pH)
  charge = 0
  charge += -1/(1+10**(pep_charges.c_term-pH))
  charge += -pep_charges.d_num/(1+10**(ResidueTable[:D][2]-pH))
  charge += -pep_charges.e_num/(1+10**(ResidueTable[:E][2]-pH))
  charge += -pep_charges.c_num/(1+10**(ResidueTable[:C][2]-pH))
  charge += -pep_charges.y_num/(1+10**(ResidueTable[:Y][2]-pH))
  charge += 1/(1+10**(pH - pep_charges.n_term))
  charge += pep_charges.h_num/(1+10**(pH-ResidueTable[:H][2]))
  charge += pep_charges.k_num/(1+10**(pH-ResidueTable[:K][2]))
  charge += pep_charges.r_num/(1+10**(pH-ResidueTable[:R][2]))
  charge
end

#distribution_from_charge(charge, normalization = 100) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ms/isoelectric_calc.rb', line 104

def distribution_from_charge(charge, normalization=100)
  threshold = normalization.to_f
  f = charge.floor
  c = charge.ceil
  charge_ratio = charge - f
  num = charge_ratio*normalization
  denom = normalization
  while num + denom > threshold
    factor = threshold/(num+denom)
    num = num * factor
    denom = denom * factor 
  end
  [["+#{f}" + ", " + "%5f" % num],["+#{c}" + ", " + "%5f" % denom]]
end

#identify_potential_charges(str) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ms/isoelectric_calc.rb', line 34

def identify_potential_charges(str)
  string = str.upcase
  first = string[0]; last = string[-1]
  puts string if first.nil? or last.nil?
  begin
    out = PepCharges.new(string, ResidueTable[first.to_sym][0], ResidueTable[last.to_sym][1], 0, 0, 0 ,0 ,0 ,0, 0, 0, 0, 0, 0)
  rescue NoMethodError
    abort string
  end
  string.chars.each do |letter|
    case letter
    when "Y" 
      out.y_num += 1 
    when "C"
      out.c_num += 1
    when "K"
      out.k_num += 1 
    when "H"
      out.h_num += 1
    when "R"
      out.r_num += 1
    when "D"
      out.d_num += 1
    when "E"
      out.e_num += 1
    when "U"
      out.u_num += 1
    when "S", "T", "N", "Q"
      out.polar_num += 1
    when "A", "V", "I", "L", "M", "F", "W", "G", "P"
      out.hydrophobic_num += 1
    end
  end
  out
end

#out(line, object) ⇒ Object



126
127
128
# File 'lib/ms/isoelectric_calc.rb', line 126

def out(line, object)
  line + ":\t" + object.to_s
end

#putsv(object) ⇒ Object



123
124
125
# File 'lib/ms/isoelectric_calc.rb', line 123

def putsv(object)
  puts object if VERBOSE
end