Simple arithmetic modifications of sum formulas.
Usage
addMolecules(formula1, formula2, elements = NULL, maxisotopes = 10)
subMolecules(formula1, formula2, elements = NULL, maxisotopes = 10)
Arguments
- formula1
Sum formula (can be a vector).
- formula2
Sum formula.
- elements
List of allowed chemical elements, defaults to full periodic system of elements. See
initializeElements
.- maxisotopes
Maximum number of isotopes shown in the resulting molecules.
Value
The input vector formula1 will be converted into molecule objects similar
to function getMolecule
. However, the results will be amended
or reduced by formula2.
Details
`addMolecules` adds the second argument to the first. `subMolecules` subtracts the second argument from the first. This can be useful to revert e.g. adduct/fragment formation found in ESI mass spectrometry, or to mimic simple chemical reactions. No chemical checks are performed.
Examples
# Remove the proton-adduct from Ethanol
subMolecules("C2H7O", "H")
#> $formula
#> [1] "C2H6O"
#>
#> $score
#> [1] 1
#>
#> $exactmass
#> [1] 46.04186
#>
#> $charge
#> [1] 0
#>
#> $parity
#> [1] "e"
#>
#> $valid
#> [1] "Valid"
#>
#> $DBE
#> [1] 0
#>
#> $isotopes
#> $isotopes[[1]]
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 46.0418648 47.04534542 48.04631711 4.904960e+01 5.005324e+01 5.105929e+01
#> [2,] 0.9749152 0.02293559 0.00210353 4.540559e-05 2.816635e-07 2.324709e-10
#> [,7] [,8] [,9] [,10]
#> [1,] 5.206548e+01 5.307171e+01 5.407796e+01 5.508422e+01
#> [2,] 8.458096e-14 1.665930e-17 1.857005e-21 1.107409e-25
#>
#>