Class: Mspire::Ident::Pepxml::SearchHit

Inherits:
Object
  • Object
show all
Includes:
Merge
Defined in:
lib/mspire/ident/pepxml/search_hit.rb,
lib/mspire/ident/pepxml/search_hit/modification_info.rb

Defined Under Namespace

Classes: Simple

Constant Summary

DEFAULT_MEMBERS =
[:hit_rank, :peptide, :peptide_prev_aa, :peptide_next_aa, :num_matched_ions, :tot_num_ions, :calc_neutral_pep_mass, :massdiff, :num_tol_term, :num_missed_cleavages, :is_rejected, :protein, :num_tot_proteins, :protein_desc, :calc_pI, :protein_mw, :modification_info, :search_scores, :spectrum_query]
Required =
Set.new([:hit_rank, :peptide, :protein, :num_tot_proteins, :calc_neutral_pep_mass, :massdiff])
Non_standard_amino_acid_char_re =
%r{[^A-Z\.\-]}

Class Attribute Summary (collapse)

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from Merge

#merge!

Constructor Details

- (SearchHit) initialize(*args, &block)

takes either a hash or an ordered list of values to set. yeilds an empty search_scores hash if given a block. mind that you set the ModificationInfo object as needed.



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 94

def initialize(*args, &block)
  @search_scores = {}
  if args.first.is_a?(Hash)
    merge!(args.first)
  else
    self.class.members.zip(args) do |k,v|
      send("#{k}=", v)
    end
  end
  block.call(@search_scores) if block
end

Class Attribute Details

+ (Object) members



20
21
22
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 20

def members
  @members || DEFAULT_MEMBERS
end

Instance Attribute Details

- (Object) calc_neutral_pep_mass

(required)



45
46
47
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 45

def calc_neutral_pep_mass
  @calc_neutral_pep_mass
end

- (Object) calc_pI

Returns the value of attribute calc_pI



71
72
73
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 71

def calc_pI
  @calc_pI
end

- (Object) hit_rank

rank of the peptide hit (required)



28
29
30
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 28

def hit_rank
  @hit_rank
end

- (Object) is_rejected

Potential use in future for user manual validation (true/false) by default, this will be set to false (the xml is expressed as a 0 or 1)



59
60
61
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 59

def is_rejected
  @is_rejected
end

- (Object) massdiff

Mass(precursor ion) - Mass(peptide) (required)



48
49
50
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 48

def massdiff
  @massdiff
end

- (Object) modification_info

a ModificationInfo object



75
76
77
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 75

def modification_info
  @modification_info
end

- (Object) num_matched_ions

Number of peptide fragment ions found in spectrum (Integer)



39
40
41
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 39

def num_matched_ions
  @num_matched_ions
end

- (Object) num_missed_cleavages

Number of sample enzyme cleavage sites internal to peptide<



54
55
56
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 54

def num_missed_cleavages
  @num_missed_cleavages
end

- (Object) num_tol_term

Number of peptide termini consistent with cleavage by sample enzyme



51
52
53
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 51

def num_tol_term
  @num_tol_term
end

- (Object) num_tot_proteins

Number of unique proteins in search database containing peptide (required)



66
67
68
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 66

def num_tot_proteins
  @num_tot_proteins
end

- (Object) peptide Also known as: aaseq

Peptide aminoacid sequence (with no indicated modifications) (required)



30
31
32
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 30

def peptide
  @peptide
end

- (Object) peptide_next_aa

Aminoacid following peptide (- if none)



36
37
38
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 36

def peptide_next_aa
  @peptide_next_aa
end

- (Object) peptide_prev_aa

Aminoacid preceding peptide ('-' if none)



33
34
35
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 33

def peptide_prev_aa
  @peptide_prev_aa
end

- (Object) protein

a protein identifier string (required)



62
63
64
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 62

def protein
  @protein
end

- (Object) protein_desc

Extracted from search database



69
70
71
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 69

def protein_desc
  @protein_desc
end

- (Object) protein_mw

Returns the value of attribute protein_mw



72
73
74
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 72

def protein_mw
  @protein_mw
end

- (Object) search_scores

a Hash with keys (the score type) and values (to_xml calls each_pair to generate the xml, so a Struct would also work)



80
81
82
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 80

def search_scores
  @search_scores
end

- (Object) spectrum_query

a link back to the spectrum_query object



83
84
85
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 83

def spectrum_query
  @spectrum_query
end

- (Object) tot_num_ions

Number of peptide fragment ions predicted for peptide (Integer)



42
43
44
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 42

def tot_num_ions
  @tot_num_ions
end

Instance Method Details

- (Object) from_pepxml_node(node)



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 122

def from_pepxml_node(node)
  node.attributes
  self[0] = node['hit_rank'].to_i
  self[1] = node['peptide']
  self[2] = node['peptide_prev_aa']
  self[3] = node['peptide_next_aa']
  self[4] = node['protein']  ## will this be the string?? (yes, for now)
  self[5] = node['num_tot_proteins'].to_i
  self[6] = node['num_matched_ions'].to_i
  self[7] = node['tot_num_ions'].to_i
  self[8] = node['calc_neutral_pep_mass'].to_f
  self[9] = node['massdiff'].to_f
  self[10] = node['num_tol_term'].to_i
  self[11] = node['num_missed_cleavages'].to_i
  self[12] = node['is_rejected'].to_i
  self
end

- (Object) members



106
107
108
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 106

def members
  self.class.members
end

- (Object) to_xml(builder = nil)



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/mspire/ident/pepxml/search_hit.rb', line 110

def to_xml(builder=nil)
  xmlb = builder || Nokogiri::XML::Builder.new
  attrs = members[0,14].map {|k| v=send(k) ; [k, v] if v }.compact
  hash_attrs = Hash[attrs]
  hash_attrs[:massdiff] = hash_attrs[:massdiff].to_plus_minus_string
  xmlb.search_hit(hash_attrs) do |xmlb|
    @modification_info.to_xml(xmlb) if @modification_info
    @search_scores.each_pair {|k,v| xmlb.search_score(:name => k, :value => v) }
  end
  builder || xmlb.doc.root.to_xml
end