Class: Sequest::PepXML::Modifications
- Inherits:
-
Object
- Object
- Sequest::PepXML::Modifications
- Includes:
- SpecIDXML
- Defined in:
- lib/ms/sequest/pepxml.rb
Instance Attribute Summary collapse
-
#aa_mods ⇒ Object
array holding AAModifications.
-
#masses_by_diff_mod_hash ⇒ Object
a hash of all differential modifications present by aa_one_letter_symbol and special_symbol.
-
#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 masses_by_diff_mod hash.
-
#modification_info(peptide) ⇒ Object
given a bare peptide (no end pieces) returns a ModificationInfo object e.g.
-
#set_hashes(modification_symbols_string) ⇒ Object
set the masses_by_diff_mod and mod_symbols_hash from.
-
#set_modifications(params, modification_symbols_string) ⇒ Object
1.
-
#to_pepxml ⇒ Object
Generates the pepxml for static and differential amino acid mods based on sequest object.
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 masses_by_diff_mod hash
890 891 892 893 894 895 |
# File 'lib/ms/sequest/pepxml.rb', line 890 def initialize(params=nil, modification_symbols_string='') @params = params if @params set_modifications(params, modification_symbols_string) end end |
Instance Attribute Details
#aa_mods ⇒ Object
array holding AAModifications
870 871 872 |
# File 'lib/ms/sequest/pepxml.rb', line 870 def aa_mods @aa_mods end |
#masses_by_diff_mod_hash ⇒ 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
879 880 881 |
# File 'lib/ms/sequest/pepxml.rb', line 879 def masses_by_diff_mod_hash @masses_by_diff_mod_hash end |
#mod_symbols_hash ⇒ Object
a hash, key is [AA_one_letter_symbol.to_sym, difference.to_f] values are the special_symbols
882 883 884 |
# File 'lib/ms/sequest/pepxml.rb', line 882 def mod_symbols_hash @mod_symbols_hash end |
#params ⇒ Object
sequest params object
868 869 870 |
# File 'lib/ms/sequest/pepxml.rb', line 868 def params @params end |
#term_mods ⇒ Object
array holding TerminalModifications
872 873 874 |
# File 'lib/ms/sequest/pepxml.rb', line 872 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
970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 |
# File 'lib/ms/sequest/pepxml.rb', line 970 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_table ## 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', } Sequest::PepXML::AAModification.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 Sequest::PepXML::TerminalModification.new(hash) end [static_mods, static_terminal_mods] end |
#modification_info(peptide) ⇒ Object
given a bare peptide (no end pieces) returns a ModificationInfo object e.g. given “]PEPT*IDE”, NOT ‘K.PEPTIDE.R’ if there are no modifications, returns nil
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
# File 'lib/ms/sequest/pepxml.rb', line 930 def modification_info(peptide) if @masses_by_diff_mod.size == 0 return nil end hash = {} hash[:modified_peptide] = peptide.dup hsh = @masses_by_diff_mod table = @params.mass_table h = table[:h] # this? or h_plus ?? oh = table[:o] + h ## only the termini can match a single char if hsh.key? peptide[0,1] # AA + H + differential_mod hash[:mod_nterm_mass] = table[peptide[1,1].to_sym] + h + hsh[peptide[0,1]] peptide = peptide[1...(peptide.size)] end if hsh.key? peptide[(peptide.size-1),1] # AA + OH + differential_mod hash[:mod_cterm_mass] = table[peptide[(peptide.size-2),1].to_sym] + oh + hsh[peptide[-1,1]] peptide.slice!( 0..-2 ) peptide = peptide[0...(peptide.size-1)] end mod_array = [] (0...peptide.size).each do |i| if hsh.key? peptide[i,2] mod_array << Sequest::PepXML::SearchHit::ModificationInfo::ModAminoacidMass.new([ i+1 , hsh[peptide[i,2]] ]) end end if mod_array.size > 0 hash[:mod_aminoacid_masses] = mod_array end if hash.size > 1 # if there is more than just the modified peptide there Sequest::PepXML::SearchHit::ModificationInfo.new(hash) #Sequest::PepXML::SearchHit::ModificationInfo.new(hash.values_at(:modified_peptide, :mod_aminoacid_masses, :mod_nterm_mass, :mod_cterm_mass) else nil end end |
#set_hashes(modification_symbols_string) ⇒ Object
set the masses_by_diff_mod and mod_symbols_hash from
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
# File 'lib/ms/sequest/pepxml.rb', line 898 def set_hashes(modification_symbols_string) @mod_symbols_hash = {} @masses_by_diff_mod = {} if (modification_symbols_string == nil || modification_symbols_string == '') return nil end table = @params.mass_table modification_symbols_string.split(/\)\s+\(/).each do |mod| if mod =~ /\(?(\w+)(.) (.[\d\.]+)\)?/ if $1 == 'ct' || $1 == 'nt' mass_diff = $3.to_f @masses_by_diff_mod[$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 @masses_by_diff_mod[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 @masses_by_diff_mod
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 |
# File 'lib/ms/sequest/pepxml.rb', line 1030 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_table ################################# # 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 << Sequest::PepXML::AAModification.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, } Sequest::PepXML::TerminalModification.new(hash) end ######################### # COLLECT THEM ######################### @aa_mods = static_mods + variable_mods @term_mods = static_terminal_mods + variable_terminal_mods end |
#to_pepxml ⇒ Object
Generates the pepxml for static and differential amino acid mods based on sequest object
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File 'lib/ms/sequest/pepxml.rb', line 1097 def to_pepxml st = '' if @aa_mods st << @aa_mods.map {|v| v.to_pepxml }.join end if @term_mods st << @term_mods.map {|v| v.to_pepxml }.join end st end |