Sha256: 6f10cf9611267b6f2e3b536724b07b9500acfe1b921d824e3b5b557314ac8171
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'set' require 'ms/ident/protein_group' module Ms module Quant module SpectralCounts Counts = Struct.new(:spectral, :aaseqcharge, :aaseq) class Counts def initialize(*args) super(*args) # default is zero counts self[0] ||= 0.0 ; self[1] ||= 0.0 ; self[2] ||= 0.0 end end # returns a parallel array of Count objects. If split_hits then counts # are split between groups sharing the hit. peptide_hits must respond # to :charge and :aaseq. If a block is given, the weight of a # particular hit can be given (typically this will be 1/#proteins # sharing the hit def self.counts(peptide_hits, &share_the_pephit) uniq_aaseq = {} uniq_aaseq_charge = {} weights = peptide_hits.map do |hit| weight = share_the_pephit ? share_the_pephit.call(hit) : 1 # these guys will end up clobbering themselves, but the # linked_to_size should be consistent if the key is the same uniq_aaseq_charge[[hit.aaseq, hit.charge]] = weight uniq_aaseq[hit.aaseq] = weight weight end counts_data = [weights, uniq_aaseq_charge.values, uniq_aaseq.values].map do |array| array.reduce(:+) end Counts.new(*counts_data) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ms-quant-0.1.1 | lib/ms/quant/spectral_counts.rb |
ms-quant-0.1.0 | lib/ms/quant/spectral_counts.rb |