### How does the elemental composition plug-in determine the possible formulae?

The elemental composition plug-in tries every formula consisting of elements with counts within the ranges specified in the parameter set. Each calculated formula is evaluated against rules listed in the following paragraphs.

The theoretical mass of the formula is compared to the mass of the experimental compound, to determine whether the difference exceeds the configured mass error - if so, the formula is dropped.

Formulae describing odd electron molecules (molecules that do not have completely filled s, p-valence shells) are dropped (the LEWIS rule).

Formulae describing molecules that do not satisfy all of the following conditions are dropped (the SENIOR rule):

- the sum of valences or the total number of atoms having odd valences is even
- the sum of valences is greater than or equal to twice the maximum valence
- the sum of valences is greater than or equal to twice the number of atoms minus 1

The hydrogen to carbon ratio is checked - if the ratio is lower than 0.1 or higher than 6, the formula is dropped.

The ratios of the following elements to carbon are checked, and if they are higher than following, the formula is dropped:

- fluorine - maximum ratio 6
- chlorine - maximum ratio 2
- bromine - maximum ratio 2
- nitrogen - maximum ratio 4
- oxygen - maximum ratio 3
- phosphorus - maximum ratio 2
- sulphur - maximum ratio 3
- silicon - maximum ratio 1

If specific combinations of multiple elements are present in the formula, their counts must be as follows, or the formula is dropped:

- if N, O, P, S all > 1, then N < 10, O < 20, P < 4, S < 3
- if N, O, P all > 3, then N < 11, O < 22, P < 6
- if O, P, S all > 1, then O < 14, P < 3, S < 3
- if P, S, N all > 1, then P < 3, S < 3, N < 4
- if N, O, S all > 6, then N < 19, O < 14, S < 8

The theoretical isotope distribution of the formula is compared to the experimental isotope distribution of the compound, and if it is not similar enough according to the configured cut-off, the formula is dropped.

The resulting formula is then scored, taking the mass error and the isotope similarity into account.

The rationale behind these rules is described in the Seven Golden Rules for heuristic filtering of molecular formulas obtained by accurate mass spectrometry article.