Class: Ms::Ident::Pepxml::SampleEnzyme

Inherits:
Object
  • Object
show all
Includes:
Merge
Defined in:
lib/ms/ident/pepxml/sample_enzyme.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Merge

#merge!

Constructor Details

#initialize(arg = {}) ⇒ SampleEnzyme

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



23
24
25
26
27
28
29
30
# 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

Instance Attribute Details

#cutObject

amino acids after which to cleave



13
14
15
# File 'lib/ms/ident/pepxml/sample_enzyme.rb', line 13

def cut
  @cut
end

#nameObject

an identifier



11
12
13
# File 'lib/ms/ident/pepxml/sample_enzyme.rb', line 11

def name
  @name
end

#no_cutObject

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



15
16
17
# File 'lib/ms/ident/pepxml/sample_enzyme.rb', line 15

def no_cut
  @no_cut
end

#senseObject

‘C’ or ‘N’



17
18
19
# File 'lib/ms/ident/pepxml/sample_enzyme.rb', line 17

def sense
  @sense
end

Class Method Details

.from_pepxml_node(node) ⇒ Object



58
59
60
# File 'lib/ms/ident/pepxml/sample_enzyme.rb', line 58

def self.from_pepxml_node(node)
  self.new.from_pepxml_node(node)
end

Instance Method Details

#from_pepxml_node(node) ⇒ Object

returns self



49
50
51
52
53
54
55
56
# 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) ⇒ Object

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

Raises:

  • (NotImplementedError)


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# 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) ⇒ Object

No arguments should contain non-standard amino acids

Raises:

  • (NotImplementedError)


85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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_trypsinObject



32
33
34
35
36
# 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) ⇒ Object

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



40
41
42
43
44
45
46
# 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