class Object
Constants
- PepCharges
- Precision
isoelectric.ovh.org/files/practise-isoelectric-point.html#mozTocId496531 Taken from Ryan’s github repo
- ResidueTable
- VERBOSE
Public Instance Methods
calc_PI(pep_charges)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/ms/isoelectric_calc.rb, line 126 def out(line, object) line + ":\t" + object.to_s end
putsv(object)
click to toggle source
# File lib/ms/isoelectric_calc.rb, line 123 def putsv(object) puts object if VERBOSE end