Read an internal, non-standard formula convention which allows for gains, losses and isotopes

create_isotopic_chemical_formula(labeled_counts)

parse_isotopic_chemical_formula(formula)

Arguments

labeled_counts

a tibble (or data.frame) containing two variables which will be used: label and count

formula

a chemical formula which may included losses as generated by create_isotopic_chemical_formula

Value

a length one character vector containing a chemical formula Explicitly check number of rows in mass_gains and mass_losses before returning.

Examples

parse_isotopic_chemical_formula("C(6) H(12) O(6)")
#> # A tibble: 3 × 3
#> # Groups:   formula [1]
#>   formula         element count
#>   <chr>           <chr>   <dbl>
#> 1 C(6) H(12) O(6) C           6
#> 2 C(6) H(12) O(6) H          12
#> 3 C(6) H(12) O(6) O           6
parse_isotopic_chemical_formula("13C C(5) H(12) O(6)")
#> # A tibble: 4 × 3
#> # Groups:   formula [1]
#>   formula             element count
#>   <chr>               <chr>   <dbl>
#> 1 13C C(5) H(12) O(6) 13C         1
#> 2 13C C(5) H(12) O(6) C           5
#> 3 13C C(5) H(12) O(6) H          12
#> 4 13C C(5) H(12) O(6) O           6
parse_isotopic_chemical_formula("13C C(5) H(12) O(6) - H(2)")
#> # A tibble: 4 × 3
#> # Groups:   formula [1]
#>   formula                    element count
#>   <chr>                      <chr>   <dbl>
#> 1 13C C(5) H(12) O(6) - H(2) 13C         1
#> 2 13C C(5) H(12) O(6) - H(2) C           5
#> 3 13C C(5) H(12) O(6) - H(2) H          10
#> 4 13C C(5) H(12) O(6) - H(2) O           6