Class: Ms::Ident::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/ms/ident/search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil, peptide_hits = []) ⇒ Search

Returns a new instance of Search.



10
11
12
13
# File 'lib/ms/ident/search.rb', line 10

def initialize(id=nil, peptide_hits=[])
  @id = id
  @peptide_hits = peptide_hits
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/ms/ident/search.rb', line 6

def id
  @id
end

#peptide_hitsObject Also known as: hits

Returns the value of attribute peptide_hits.



7
8
9
# File 'lib/ms/ident/search.rb', line 7

def peptide_hits
  @peptide_hits
end

Instance Method Details

#merge!(ar_of_peptide_hit_arrays) ⇒ Object

returns an array of peptide_hits and protein_hits that are linked to one another. NOTE: this will update peptide and protein hits :proteins and :peptides attributes respectively). Assumes that each search responds to :peptides, each peptide responds to :proteins and each protein to :peptides. Can be done on a single file to restore protein/peptide linkages to their original single-file state. Assumes the protein is initialized with (reference, peptide_ar)

yields the protein that will become the template for a new protein and expects a new protein hit



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ms/ident/search.rb', line 25

def merge!(ar_of_peptide_hit_arrays)
  all_peptide_hits = []
  reference_hash = {}
  ar_of_peptide_hit_arrays.each do |peptide_hits|
    all_peptide_hits.push(*peptide_hits)
    peptide_hits.each do |peptide|
      peptide.proteins.each do |protein|
        ref = protein.reference
        if reference_hash.key? ref
          reference_hash[ref].peptides << peptide
          reference_hash[ref]
        else
          reference_hash[ref] = yield(protein, [peptide])
        end
      end
    end
  end
  [all_peptide_hits, reference_hash.values]
end