Class: MS::Sequest::Pepxml::Modifications
- Inherits:
-
Object
- Object
- MS::Sequest::Pepxml::Modifications
- Defined in:
- lib/ms/sequest/pepxml/modifications.rb
Instance Attribute Summary collapse
-
#aa_mod_to_tot_mass ⇒ Object
a hash of all differential modifications present by aa_one_letter_symbol and special_symbol.
-
#aa_mods ⇒ Object
array holding AAModifications.
-
#mod_symbols_hash ⇒ Object
a hash, key is [AA_one_letter_symbol.to_sym, difference.to_f] values are the special_symbols.
-
#params ⇒ Object
sequest params object.
-
#term_mods ⇒ Object
array holding TerminalModifications.
Instance Method Summary collapse
-
#create_static_mods(params) ⇒ Object
returns an array of static mod objects and static terminal mod objects.
-
#initialize(params = nil, modification_symbols_string = '') ⇒ Modifications
constructor
The modification symbols string looks like this: (M* 15.90000) (M# 29.00000) (S@ 80.00000) (C^ 12.00000) (ct[ 12.33000) (nt] 14.20000) ct is cterminal peptide (differential) nt is nterminal peptide (differential) the C is just cysteine will set_modifications and aa_mod_to_tot_mass hash.
-
#modification_info(mod_peptide) ⇒ Object
takes a peptide sequence with modifications but no preceding or trailing amino acids.
-
#modifications ⇒ Object
returns an array of all modifications (aa_mods, then term_mods).
-
#set_hashes(modification_symbols_string) ⇒ Object
set the aa_mod_to_tot_mass and mod_symbols_hash from.
-
#set_modifications(params, modification_symbols_string) ⇒ Object
1.
Constructor Details
#initialize(params = nil, modification_symbols_string = '') ⇒ Modifications
The modification symbols string looks like this: (M* 15.90000) (M# 29.00000) (S@ 80.00000) (C^ 12.00000) (ct[ 12.33000) (nt] 14.20000) ct is cterminal peptide (differential) nt is nterminal peptide (differential) the C is just cysteine will set_modifications and aa_mod_to_tot_mass hash
36 37 38 39 40 41 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 36 def initialize(params=nil, modification_symbols_string='') @params = params if @params set_modifications(params, modification_symbols_string) end end |
Instance Attribute Details
#aa_mod_to_tot_mass ⇒ Object
a hash of all differential modifications present by aa_one_letter_symbol and special_symbol. This is NOT the mass difference but the total mass { ‘M*’ => 155.5, ‘S@’ => 190.3 }. NOTE: Since the termini are dependent on the amino acid sequence, they are give the differential mass. The termini are given the special symbol as in sequest e.g. ‘[’ => 12.22, # cterminus ‘]’ => 14.55 # nterminus
20 21 22 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 20 def aa_mod_to_tot_mass @aa_mod_to_tot_mass end |
#aa_mods ⇒ Object
array holding AAModifications
11 12 13 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 11 def aa_mods @aa_mods end |
#mod_symbols_hash ⇒ Object
a hash, key is [AA_one_letter_symbol.to_sym, difference.to_f] values are the special_symbols
23 24 25 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 23 def mod_symbols_hash @mod_symbols_hash end |
#params ⇒ Object
sequest params object
9 10 11 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 9 def params @params end |
#term_mods ⇒ Object
array holding TerminalModifications
13 14 15 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 13 def term_mods @term_mods end |
Instance Method Details
#create_static_mods(params) ⇒ Object
returns an array of static mod objects and static terminal mod objects
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 73 def create_static_mods(params) #################################### ## static mods #################################### static_mods = [] # [[one_letter_amino_acid.to_sym, add_amount.to_f], ...] static_terminal_mods = [] # e.g. [add_Cterm_peptide, amount.to_f] params.mods.each do |k,v| v_to_f = v.to_f if v_to_f != 0.0 if k =~ /add_(\w)_/ static_mods << [$1.to_sym, v_to_f] else static_terminal_mods << [k, v_to_f] end end end aa_hash = params.mass_index(:precursor) ## Create the static_mods objects static_mods.map! do |mod| hash = { :aminoacid => mod[0].to_s, :massdiff => mod[1], :mass => aa_hash[mod[0]] + mod[1], :variable => 'N', :binary => 'Y', } MS::Ident::Pepxml::AminoacidModification.new(hash) end ## Create the static_terminal_mods objects static_terminal_mods.map! do |mod| terminus = if mod[0] =~ /Cterm/ ; 'c' else ; 'n' # only two possible termini end protein_terminus = case mod[0] when /Nterm_protein/ ; 'n' when /Cterm_protein/ ; 'c' else nil end # create the hash hash = { :terminus => terminus, :massdiff => mod[1], :variable => 'N', :description => mod[0], } hash[:protein_terminus] = protein_terminus if protein_terminus MS::Ident::Pepxml::TerminalModification.new(hash) end [static_mods, static_terminal_mods] end |
#modification_info(mod_peptide) ⇒ Object
takes a peptide sequence with modifications but no preceding or trailing amino acids. (e.g. expects “]PEPT*IDE” but not ‘K.PEPTIDE.R’) returns a ModificationInfo object
if there are no modifications, returns nil
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 203 def modification_info(mod_peptide) return nil if @aa_mod_to_tot_mass.size == 0 mod_info = MS::Ident::Pepxml::SearchHit::ModificationInfo.new( mod_peptide.dup ) mass_table = @params.mass_index(:precursor) # TERMINI: ## only the termini can match a single char if @aa_mod_to_tot_mass.key? mod_peptide[0,1] # AA + H + differential_mod mod_info.mod_nterm_mass = mass_table[mod_peptide[1,1].to_sym] + mass_table['h+'] + @aa_mod_to_tot_mass[mod_peptide[0,1]] mod_peptide = mod_peptide[1...(mod_peptide.size)] end if @aa_mod_to_tot_mass.key? mod_peptide[(mod_peptide.size-1),1] # AA + OH + differential_mod mod_info.mod_cterm_mass = mass_table[mod_peptide[(mod_peptide.size-2),1].to_sym] + mass_table['oh'] + @aa_mod_to_tot_mass[mod_peptide[-1,1]] mod_peptide = mod_peptide[0...(mod_peptide.size-1)] end # OTHER DIFFERENTIAL MODS: mod_array = [] mod_cnt = 1 = 1 last_normal_aa = mod_peptide[0,1] (1...mod_peptide.size).each do |i| if @aa_mod_to_tot_mass.key?( last_normal_aa + mod_peptide[i,1] ) # we don't save the result because most amino acids will not be # modified mod_array << MS::Ident::Pepxml::SearchHit::ModificationInfo::ModAminoacidMass.new(, @aa_mod_to_tot_mass[last_normal_aa + mod_peptide[i,1]]) else last_normal_aa = mod_peptide[i,1] += 1 end mod_cnt += 1 end if mod_cnt == nil else mod_info.mod_aminoacid_masses = mod_array if mod_array.size > 0 mod_info end end |
#modifications ⇒ Object
returns an array of all modifications (aa_mods, then term_mods)
26 27 28 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 26 def modifications aa_mods + term_mods end |
#set_hashes(modification_symbols_string) ⇒ Object
set the aa_mod_to_tot_mass and mod_symbols_hash from
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 69 70 71 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 44 def set_hashes(modification_symbols_string) @mod_symbols_hash = {} @aa_mod_to_tot_mass = {} if (modification_symbols_string == nil || modification_symbols_string == '') return nil end table = @params.mass_index(:precursor) modification_symbols_string.split(/\)\s+\(/).each do |mod| if mod =~ /\(?(\w+)(.) (.[\d\.]+)\)?/ if $1 == 'ct' || $1 == 'nt' mass_diff = $3.to_f @aa_mod_to_tot_mass[$2] = mass_diff @mod_symbols_hash[[$1.to_sym, mass_diff]] = $2.dup # changed from below to match tests, is this right? # @mod_symbols_hash[[$1, mass_diff]] = $2.dup else symbol_string = $2.dup mass_diff = $3.to_f $1.split('').each do |aa| aa_as_sym = aa.to_sym @aa_mod_to_tot_mass[aa+symbol_string] = mass_diff + table[aa_as_sym] @mod_symbols_hash[[aa_as_sym, mass_diff]] = symbol_string end end end end end |
#set_modifications(params, modification_symbols_string) ⇒ Object
-
sets aa_mods and term_mods from a sequest params object
-
sets @params
-
sets @aa_mod_to_tot_mass
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/ms/sequest/pepxml/modifications.rb', line 133 def set_modifications(params, modification_symbols_string) @params = params set_hashes(modification_symbols_string) (static_mods, static_terminal_mods) = create_static_mods(params) aa_hash = params.mass_index(:precursor) ################################# # Variable Mods: ################################# arr = params..rstrip.split(/\s+/) # [aa.to_sym, diff.to_f] variable_mods = [] (0...arr.size).step(2) do |i| if arr[i].to_f != 0.0 variable_mods << [arr[i+1], arr[i].to_f] end end mod_objects = [] variable_mods.each do |mod| mod[0].split('').each do |aa| hash = { :aminoacid => aa, :massdiff => mod[1], :mass => aa_hash[aa.to_sym] + mod[1], :variable => 'Y', :binary => 'N', :symbol => @mod_symbols_hash[[aa.to_sym, mod[1]]], } mod_objects << MS::Ident::Pepxml::AminoacidModification.new(hash) end end variable_mods = mod_objects ################################# # TERMINAL Variable Mods: ################################# # These are always peptide, not protein termini (for sequest) (nterm_diff, cterm_diff) = params..rstrip.split(/\s+/).map{|v| v.to_f } to_add = [] if nterm_diff != 0.0 to_add << ['n',nterm_diff.to_plus_minus_string, @mod_symbols_hash[:nt, nterm_diff]] end if cterm_diff != 0.0 to_add << ['c', cterm_diff.to_plus_minus_string, @mod_symbols_hash[:ct, cterm_diff]] end variable_terminal_mods = to_add.map do |term, mssdiff, symb| hash = { :terminus => term, :massdiff => mssdiff, :variable => 'Y', :symbol => symb, } MS::Ident::Pepxml::TerminalModification.new(hash) end ######################### # COLLECT THEM ######################### @aa_mods = static_mods + variable_mods @term_mods = static_terminal_mods + variable_terminal_mods end |