MonoForge

thinkerbot / molecules

molecules

Public

A library of molecules for scientific calculations in Ruby.

23 filesupdated Jun 18, 2026

README

= Molecules

A library of molecules for scientific calculations in Ruby.

== Description

Molecules provides libraries of commonly used molecules (currently just amino acid residues and polypeptides). Library classes inherit from EmpiricalFormula which allows calculation of molecular composition and mass, as well as adding/subtraction of other molecules.

I have attempted to use reputable sources and to adhere to standards when applicable. Please notify me of any errors and send me suggestions!

== Usage

require 'molecules' include Molecules::Libraries

Residue predefines all common amino acids

as well as some uncommon ones.

r = Residue::A r.name # => "Alanine" r.abbr # => "Ala" r.letter # => "A" r.side_chain.to_s # => "CH(3)" r.mass # => 71.03711 r.immonium_ion_mass # => 44.0500

Polypeptide allows for creation of polypeptides

from residue sequences.

p = Polypeptide.new("RPPGFSPFR") p.to_s # => "C(50)H(71)N(15)O(10)" p.mass # => 1041.5508

Generic molecules may be specified with EmpiricalFormula.

caffeine = Molecules::EmpiricalFormula.parse("C8H10N4O2") coffee = Molecules::EmpiricalFormula.parse("C8H10N4O2 + H2O")

=== Mass Calculator (tap task)

Molecules provides a mass calculator tap task. Tap[http://tap.rubyforge.org] is not required by molecules in general, but you get this bonus if you have tap installed:

% tap run -- molecules/calc H2O I[17:08:00] 18.0105646863 Da H2O

== Known Issues

== Installation

Molecules is available as a gem through RubyForge[http://rubyforge.org/projects/bioactive]. Use:

% gem install molecules

== Info

Copyright (c) 2006-2008, Regents of the University of Colorado. Developer:: {Simon Chiang}[http://bahuvrihi.wordpress.com], {Biomolecular Structure Program}[http://biomol.uchsc.edu/], {Hansen Lab}[http://hsc-proteomics.uchsc.edu/hansenlab/] Support:: CU Denver School of Medicine Deans Academic Enrichment Fund Licence:: MIT-Style