Module: Ms::Ident::Peptide

Defined in:
lib/ms/ident/peptide.rb,
lib/ms/ident/peptide/db.rb

Overview

A ‘sequence’ is a notation of a peptide that includes the leading and trailing amino acid after cleavage (e.g., K.PEPTIDER.E or -.STARTK.L ) and may contain post-translational modification information.

‘aaseq’ is the amino acid sequence of just the peptide with no leading or trailing notation (e.g., PEPTIDER or LAKKLY)

Defined Under Namespace

Classes: Db

Constant Summary collapse

Nonstandard_AA_re =
/[^A-Z\.\-]/

Class Method Summary collapse

Class Method Details

.prepare_sequence(sequence) ⇒ Object

remove non amino acids and split the sequence



42
43
44
45
# File 'lib/ms/ident/peptide.rb', line 42

def prepare_sequence(sequence)
  nv = remove_non_amino_acids(sequence)
  split_sequence(nv)
end

.remove_non_amino_acids(sequence) ⇒ Object

removes non standard amino acids specified by Nonstandard_AA_re



37
38
39
# File 'lib/ms/ident/peptide.rb', line 37

def remove_non_amino_acids(sequence)
  sequence.gsub(Nonstandard_AA_re, '')
end

.sequence_to_aaseq(sequence) ⇒ Object

Takes a peptide sequence of the form ‘-.PEPTIDE.R’, removes non-standard amino acids, and returns the center piece



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ms/ident/peptide.rb', line 17

def sequence_to_aaseq(sequence)
  after_removed = remove_non_amino_acids(sequence)
  pieces = after_removed.split('.') 
  case pieces.size
  when 3
    pieces[1]
  when 2
    if pieces[0].size > 1  ## N termini
      pieces[0]
    else  ## C termini
      pieces[1]
    end
  when 1  ## this must be a parse error!
    pieces[0] ## which is the peptide itself  
  else
    abort "bad peptide sequence: #{sequence.inspect}"
  end
end

.split_sequence(sequence) ⇒ Object

Returns prev, peptide, next from sequence. Parse errors return nil,nil,nil

R.PEPTIDE.A  # -> R, PEPTIDE, A
R.PEPTIDE.-  # -> R, PEPTIDE, -
PEPTIDE.A    # -> -, PEPTIDE, A
A.PEPTIDE    # -> A, PEPTIDE, -
PEPTIDE      # -> nil,nil,nil


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ms/ident/peptide.rb', line 54

def split_sequence(sequence)
  pieces = sequence.split('.') 
  case pieces.size
  when 3
    pieces
  when 2
    if pieces[0].size > 1  ## N termini
      ['-', pieces[0], pieces[1]]
    else  ## C termini
      [pieces[0], pieces[1], '-']
    end
  when 1  ## this must be a parse error!
    [nil,nil,nil]
  when 0
    [nil,nil,nil]
  end
end