Skip to main content
Research article - Peer-reviewed, 2022

Enumerating Possible Molecular Formulae in Mass Spectrometry Using a Generating Function Based Method

Li, Sean; Bohman, Bjorn; Jayatilaka, Dylan


What molecular formulae correspond to a given mass M? Here, we address this problem-the compomer problem of mass spectrometry. We describe, implement, and test a straightforward and practical aufbau algorithm which leads to the molecular formula tree from which all possible solutions may be obtained. The algorithm was inspired from the generating function method used in combinatorics, to count the number of compomers. The molecular formula tree can be generated in linear time with regards to the number of elements N, and in quadratic time with respect to the mass M; and we demonstrate that the memory requirements do not exceed that of a standard laptop for the formula of a small molecule, say about 10 elements and a mass of 1000 Da. Nevertheless, we still discuss and demonstrate how a range of heuristics can be used to mitigate the memory requirements.

Published in

MATCH Communications in Mathematical and in Computer Chemistry
2022, Volume: 88, number: 2, pages: 321-350

    SLU Authors

    UKÄ Subject classification

    Computational Mathematics

    Publication Identifiers


    Permanent link to this page (URI)