class Ms::Ident::Pepxml::SampleEnzyme

Attributes

cut[RW]

amino acids after which to cleave

name[RW]

an identifier

no_cut[RW]

cleave at ‘cut’ amino acids UNLESS it is followed by ‘no_cut’

sense[RW]

‘C’ or ‘N’

Public Class Methods

from_pepxml_node(node) click to toggle source
# File lib/ms/ident/pepxml/sample_enzyme.rb, line 58
def self.from_pepxml_node(node)
  self.new.from_pepxml_node(node)
end
new(arg={}) click to toggle source

Can pass in a name of an enzyme that is recognized (meaning there is a set_<name> method), or

trypsin

For other enzymes, you must set :cut, :no_cut, :name, and :sense will

# File lib/ms/ident/pepxml/sample_enzyme.rb, line 23
def initialize(arg={})
  if arg.is_a?(String)
    @name = arg
    send("set_#{@name}".to_sym)
  else
    merge!(arg)
  end
end

Public Instance Methods

from_pepxml_node(node) click to toggle source

returns self

# File lib/ms/ident/pepxml/sample_enzyme.rb, line 49
def from_pepxml_node(node)
  self.name = node['name']
  ch = node.child
  self.cut = ch['cut']
  self.no_cut= ch['no_cut']
  self.sense = ch['sense']
  self
end
num_missed_cleavages(aaseq) click to toggle source

takes an amino acid sequence (e.g. PEPTIDE). returns the number of missed cleavages

# File lib/ms/ident/pepxml/sample_enzyme.rb, line 64
def num_missed_cleavages(aaseq)
  seq_to_scan = '  ' + aaseq + '  ' 
  raise NotImplementedError, 'need to implement for N terminal sense'  if sense == 'N'
  @num_missed_cleavages_regex = 
    if @num_missed_cleavages_regex ; @num_missed_cleavages_regex
    else
      regex_string = "[#{@cut}]"
      if @no_cut and @no_cut != ''
        regex_string << "[^#{@no_cut}]"
      end
      /#{regex_string}/
    end
  arr = aaseq.scan(@num_missed_cleavages_regex)
  num = arr.size
  if aaseq[-1,1] =~ @num_missed_cleavages_regex
    num -= 1
  end
  num
end
num_tol_term(prev_aa, middle, next_aa) click to toggle source

No arguments should contain non-standard amino acids

# File lib/ms/ident/pepxml/sample_enzyme.rb, line 85
def num_tol_term(prev_aa, middle, next_aa)
  raise NotImplementedError, 'need to implement for N terminal sense'  if sense == 'N'
  no_cut = @no_cut || ''
  num_tol = 0
  last_of_middle = middle[-1,1]
  first_of_middle = middle[0,1]
  if ( @cut.include?(prev_aa) && !no_cut.include?(first_of_middle) ) || prev_aa == '-'
    num_tol += 1
  end
  if @cut.include?(last_of_middle) && !no_cut.include?(next_aa) || next_aa == '-'
    num_tol += 1
  end
  num_tol
end
set_trypsin() click to toggle source
# File lib/ms/ident/pepxml/sample_enzyme.rb, line 32
def set_trypsin
  @sense = 'C'
  @cut = 'KR'
  @no_cut = 'P'
end
to_xml(builder=nil) click to toggle source

if an xml builder object is given, it adds to the object and returns the builder object, otherwise it returns an xml fragment string

# File lib/ms/ident/pepxml/sample_enzyme.rb, line 40
def to_xml(builder=nil)
  xmlb = builder || Nokogiri::XML::Builder.new
  xmlb.sample_enzyme(:name => name) do |xmlb|
    xmlb.specificity(:cut => cut, :no_cut => no_cut, :sense => sense)
  end
  builder || xmlb.doc.root.to_xml
end