Sha256: 9a6ae700843c929fc62ed933d5d0621440752954fa0696a975dacc0c14cd78c4

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

require 'ms/fasta'
require 'ms/error_rate/sbv'
require 'transmembrane'

module Ms
  module ErrorRate
    class Sbv
      module ProteinBased
        DEFAULT_NO_PROTS_VAL = 0.0 
        # note the pep to prot hash has proteins in a string separated by a
        # hyphen.  returns the names of the files written
        def self.generate_hashes(pep_to_prot_file, protid_to_val, options={})
          options[:protein_hash] = protid_to_val
          options[:type_code] = 'tm' unless options[:type_code]
          files = Ms::ErrorRate::Sbv.generate_hashes(pep_to_prot_file, options) do |prot_return_vals|
            
            total_with_bias = 0
            total_known = 0
            prot_return_vals.each do |val|
              if !val.nil?
                total_with_bias += val
                total_known += 1
              end
            end
            if total_known == 0
              DEFAULT_NO_PROTS_VAL
            else
              total_with_bias.to_f / total_known
            end
          end #block

          files

        end # end method
      end # module
    end # class
  end # ErrorRate
end # Ms 

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ms-error_rate-0.0.13 lib/ms/error_rate/sbv/protein_based.rb
ms-error_rate-0.0.12 lib/ms/error_rate/sbv/protein_based.rb
ms-error_rate-0.0.11 lib/ms/error_rate/sbv/protein_based.rb
ms-error_rate-0.0.10 lib/ms/error_rate/sbv/protein_based.rb