Sha256: df387d71e9299aa6cd38959fe8253c51a6e8262c45e82848067b38687e39803f

Contents?: true

Size: 920 Bytes

Versions: 10

Compression:

Stored size: 920 Bytes

Contents

module Mspire
  module Mass
      end
end

require 'mspire/molecular_formula'
require 'mspire/mass/element'
require 'mspire/mass/subatomic'
require 'mspire/mass/common'
require 'mspire/mass/aa'

module Mspire
  module Mass

    ELECTRON = Subatomic::MONO[:e]
    NEUTRON = Subatomic::MONO[:neutron]
    PROTON = Subatomic::MONO[:proton]
    H_PLUS = PROTON

    class << self
      # takes a molecular formula as a string, hash or MolecularFormula object
      # and returns the exact mass.
      def formula_to_exact_mass(formula)
        Mspire::MolecularFormula.from_any(formula).mass
      end
      alias_method :formula, :formula_to_exact_mass

      def aa_to_exact_mass(aa_seq)
        chain_mass = aa_seq.each_char.inject(0.0) do |sum, aa_char|
          sum + AA[aa_char]
        end
        chain_mass + formula_to_exact_mass('H2O')
      end
      alias_method :aa, :aa_to_exact_mass

    end


  end
end


Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mspire-0.10.6 lib/mspire/mass.rb
mspire-0.10.5 lib/mspire/mass.rb
mspire-0.10.4 lib/mspire/mass.rb
mspire-0.10.3 lib/mspire/mass.rb
mspire-0.10.2 lib/mspire/mass.rb
mspire-0.10.1 lib/mspire/mass.rb
mspire-0.10.0 lib/mspire/mass.rb
mspire-0.9.2 lib/mspire/mass.rb
mspire-0.9.1 lib/mspire/mass.rb
mspire-0.9.0 lib/mspire/mass.rb