BioFSharp


Formula

📂View module documentation
BioFSharp offers a great bunch of functionality for working with molecules. All elements are represented as the composition of their stable isotopes. A `Formula` is a collection of those Elements with the given count. Creating and altering formulas is quite easy. Also functions for obtaining a mass of a molecule, which becomes quite handy especially for mass spectrometry, can be used straightforwardly.

To create formulas, no direct fiddling around with the data type is necessary. You can just use the stringparser:

1: 
2: 
3: 
4: 
5: 
6: 
#r "BioFSharp.dll"
open BioFSharp


let CO2 = Formula.parseFormulaString "CO2"
Formula.toString CO2 // val it : string = "C1.00 O2.00 "

We just created some Carbon Dioxide. Luckily there is no in silico climate change. But let's get rid of it anyways, by making some Sprudel*:

*german term for sprinkly water

1: 
2: 
let sprudel = Formula.add CO2 (Formula.Table.H2O)
Formula.toString sprudel // val it : string = "C1.00 H2.00 O3.00 "

Quite refreshing, but boring nevertheless. Let's make some radioactive sprudel.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
/// create a monoisotopic carbon consisting only of C14
let monoC14 = 
    Elements.createMono "C14" (Isotopes.Table.C14,1.)
    |> Elements.Mono 

/// exchanges all carbon in formula with monoIsotopic C14
let lableWithC14 molecule = Formula.lableElement molecule Elements.Table.C monoC14

let radioactiveSprudel = lableWithC14 sprudel

As you can see converting a refreshing drink to a refreshing, radioactive drink is quickly done. As a check up, let's compare the masses:

1: 
2: 
Formula.monoisoMass sprudel // val it : float = 62.00039392
Formula.monoisoMass radioactiveSprudel // val it : float = 64.00363591
namespace BioFSharp
val CO2 : Formula.Formula
module Formula

from BioFSharp
val parseFormulaString : strFormula:string -> Formula.Formula
val toString : f:Formula.Formula -> string
val sprudel : Formula.Formula
val add : f1:Formula.Formula -> f2:Formula.Formula -> Formula.Formula
module Table

from BioFSharp.Formula
val H2O : Formula.Formula
val monoC14 : Elements.Element


 create a monoisotopic carbon consisting only of C14
module Elements

from BioFSharp
val createMono : symbol:string -> x:Isotopes.Isotope * xcomp:float -> Elements.MonoIsotopic
module Isotopes

from BioFSharp
module Table

from BioFSharp.Isotopes
val C14 : Isotopes.Isotope
union case Elements.Element.Mono: Elements.MonoIsotopic -> Elements.Element
val lableWithC14 : molecule:'a -> 'b


 exchanges all carbon in formula with monoIsotopic C14
val molecule : 'a
module Table

from BioFSharp.Elements
val C : Elements.Element
val radioactiveSprudel : Formula.Formula
val monoisoMass : f:Formula.Formula -> float
Fork me on GitHub