rformassspectrometry / MetaboCoreUtils

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

`containsElements` #51

Closed meowcat closed 2 years ago

meowcat commented 2 years ago
> containsElements("C9H10FNO2", "F")
[1] FALSE
> containsElements("C9H10F1NO2", "F")
[1] FALSE
> containsElements("C9H10FNO2", "F1")
[1] FALSE
> containsElements("C9H10F1NO2", "F1")
[1] FALSE
> fo <- standardizeFormula("C9H10FNO2")
> containsElements(fo, "F")
[1] FALSE
> fo <- standardizeFormula("C9H10F1N1O2")
> containsElements(fo, "F")
[1] FALSE
> containsElements(fo, "F1")
[1] FALSE

In contrast, sometimes it works:

> containsElements("C10H10F3N3", "F1")
[1] TRUE
> containsElements("C10H10F3N3", "F")
[1] TRUE

Weirdness:

> containsElements("C10H10F3N3", "F3")
[1] FALSE
> containsElements("C10H10F3N3", "F2")
[1] TRUE
meowcat commented 2 years ago

https://github.com/rformassspectrometry/MetaboCoreUtils/blob/e3a622b649a018ccd16797f6d4a259fd9a0f5b78/R/chemFormula.R#L173 should be >=0