Class: SampleEnzyme
- Inherits:
-
Object
- Object
- SampleEnzyme
- Includes:
- SpecIDXML
- Defined in:
- lib/spec_id.rb,
lib/sample_enzyme.rb
Constant Summary
Constants included from SpecIDXML
Instance Attribute Summary collapse
-
#cut ⇒ Object
amino acids after which to cleave.
-
#name ⇒ Object
Returns the value of attribute name.
-
#no_cut ⇒ Object
cleave at ‘cut’ amino acids UNLESS it is followed by ‘no_cut’.
-
#sense ⇒ Object
‘C’ or ‘N’.
Class Method Summary collapse
Instance Method Summary collapse
-
#digest(string, missed_cleavages = 0) ⇒ Object
returns all peptides of missed cleavages <= ‘missed_cleavages’ so 2 missed cleavages will return all no missed cleavage peptides all 1 missed cleavages and all 2 missed cleavages.
-
#get_missed_cleavages(tryptic_peps, num) ⇒ Object
takes an array of peptides and returns an array containing ‘num’ missed cleavages DOES NOT contain peptides that contain < num of missed cleavages (i.e., will not return missed cleaveages of 1 or 2 if num == 3.
-
#initialize(name = nil) ⇒ SampleEnzyme
constructor
Currently, recognize: trypsin For other enzymes, you must set :cut, :no_cut, :name, and :sense.
- #to_pepxml ⇒ Object
- #trypsin ⇒ Object
Methods included from SpecIDXML
#attr_xml, #attrs_xml, #element_xml, #element_xml_and_att_string, #element_xml_no_atts, #escape_special_chars, #param_xml, #params_xml, #short_element_xml, #short_element_xml_and_att_string, #short_element_xml_from_instance_vars, #tabs
Constructor Details
#initialize(name = nil) ⇒ SampleEnzyme
Currently, recognize:
trypsin
For other enzymes, you must set :cut, :no_cut, :name, and :sense
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sample_enzyme.rb', line 21 def initialize(name=nil) @sense = nil @cut = nil @no_cut = nil @name = name if @name # set the values if we recognize this name send(@name.to_sym) end end |
Instance Attribute Details
#cut ⇒ Object
amino acids after which to cleave
12 13 14 |
# File 'lib/sample_enzyme.rb', line 12 def cut @cut end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/sample_enzyme.rb', line 10 def name @name end |
#no_cut ⇒ Object
cleave at ‘cut’ amino acids UNLESS it is followed by ‘no_cut’
14 15 16 |
# File 'lib/sample_enzyme.rb', line 14 def no_cut @no_cut end |
#sense ⇒ Object
‘C’ or ‘N’
16 17 18 |
# File 'lib/sample_enzyme.rb', line 16 def sense @sense end |
Class Method Details
.tryptic(string, missed_cleavages = 0) ⇒ Object
94 95 96 |
# File 'lib/sample_enzyme.rb', line 94 def self.tryptic(string, missed_cleavages=0) self.new("trypsin").digest(string, missed_cleavages) end |
Instance Method Details
#digest(string, missed_cleavages = 0) ⇒ Object
returns all peptides of missed cleavages <= ‘missed_cleavages’ so 2 missed cleavages will return all no missed cleavage peptides all 1 missed cleavages and all 2 missed cleavages.
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 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/sample_enzyme.rb', line 47 def digest(string, missed_cleavages=0) s = StringScanner.new(string) no_cut_regex = Regexp.new("[#{@no_cut}]") regex = Regexp.new("[#{@cut}]") peps = [] last_pos = 0 current_pep = '' loop do if s.eos? break end m = s.scan_until(regex) if m ## found a cut point last_pos = s.pos # is the next amino acid a no_cut? if string[s.pos,1] =~ no_cut_regex current_pep << m else # cut it current_pep << m peps << current_pep current_pep = '' end else ## didn't find a cut point current_pep << string[last_pos..-1] peps << current_pep break end end ## LOOP through and grab each set of missed cleavages from num down to 0 all_sets_of_peps = [] (0..missed_cleavages).to_a.reverse.map do |num_mc| all_sets_of_peps.push( *(get_missed_cleavages(peps, num_mc)) ) end all_sets_of_peps end |
#get_missed_cleavages(tryptic_peps, num) ⇒ Object
takes an array of peptides and returns an array containing ‘num’ missed cleavages DOES NOT contain peptides that contain < num of missed cleavages (i.e., will not return missed cleaveages of 1 or 2 if num == 3
88 89 90 91 92 |
# File 'lib/sample_enzyme.rb', line 88 def get_missed_cleavages(tryptic_peps, num) (0...(tryptic_peps.size - num)).to_a.map do |i| tryptic_peps[i,num+1].join end end |
#to_pepxml ⇒ Object
38 39 40 41 42 |
# File 'lib/sample_enzyme.rb', line 38 def to_pepxml element_xml(:sample_enzyme, [:name]) do short_element_xml(:specificity, [:cut, :no_cut, :sense]) end end |
#trypsin ⇒ Object
32 33 34 35 36 |
# File 'lib/sample_enzyme.rb', line 32 def trypsin @sense = 'C' @cut = 'KR' @no_cut = 'P' end |