rformassspectrometry / MetaboCoreUtils

Core utilities for metabolomics.
https://rformassspectrometry.github.io/MetaboCoreUtils/index.html
9 stars 6 forks source link

heavy isotopes support #54

Closed sgibb closed 2 years ago

sgibb commented 2 years ago

This PR implements support for heavy isotopes as requested in #53 (resolves #53). Unfortunately it increase the complexity of some functions namely .load_isotopes() (added some additional sorting steps), countElements() (test for valid isotopes/element names) and .pasteElements (additional gsub call to surround heavy isotopes with brackets).

library("MetaboCoreUtils")

countElements(c("C6H12O6", "[13C3]C3H12O6"))
#> $C6H12O6
#>  C  H  O 
#>  6 12  6 
#> 
#> $`[13C3]C3H12O6`
#> 13C   C   H   O 
#>   3   3  12   6
standardizeFormula("O6[13C3]H12C3")
#>   O6[13C3]H12C3 
#> "[13C3]C3H12O6"
calculateMass(c("C6H12O6", "[13C3]C3H12O6"))
#>       C6H12O6 [13C3]C3H12O6 
#>      180.0634      183.0735

Created on 2022-03-11 by the reprex package (v2.0.1)

EDIT: All isotopes listed in isotope_definition.txt are supported.