formula_from_mass
Candidate elemental formulas (C, H, N, O, S, P, F, Cl, Br, I within limits) for a measured monoisotopic neutral mass, or an m/z with its adduct ([M+H]+, [M-H]-, [M+Na]+, [M+2H]2+, [2M+H]+ ...), within a ppm tolerance.
Exhaustive search inside the element limits; ring-and-double-bond equivalents RDBE = C - (H+X)/2 + (N+P)/2 + 1, the nitrogen rule and H/C limits as filters; ranked by absolute ppm error.
Monoisotopic masses are the single IUPAC/AME values of bench_science::iupac, the electron mass CODATA.
- Field
- Mass spectrometry
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 0.05 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001Glucose C₆H₁₂O₆ at 180.06339 Da, 5 ppm (spec): listed; mass = 72 + 12 × 1.00782503223 + 6 × 15.99491461957 = 180.06338810418 Da (IUPAC monoisotopic sum, rel 10⁻¹²); RDBE = 6 - 12/2 + 1 = 1; error = (180.06339 - 180.06338810418)/180.06338810418 × 10⁶ = 0.0105286256 ppm (exact decimal arithmetic, abs 10⁻⁶ ppm)passed
target.listed= truemisseddifferstarget.mass_Da= 180.063388, within 1.000000 × 10⁻¹² relativereading not recorded on this pagetarget.rdbe= 1, within 1.000000 × 10⁻¹²reading not recorded on this pagetarget.error_ppm= 0.010529, within 1.000000 × 10⁻⁶reading not recorded on this pagebest_formula= C₆H₁₂O₆C₆H₁₂O₆lockedexact matchr0002Caffeine [M+H]+ at m/z 195.08765, 5 ppm (spec): best C₈H₁₀N₄O₂; m/z = 194.08037557916 + 1.00782503223 - 0.000548579909 (CODATA
m_e) = 195.087652031481 (rel 10⁻¹²); RDBE = 8 - 10/2 + 4/2 + 1 = 6; error -0.0104131706 ppm (exact decimal, abs 10⁻⁶ ppm)passedbest_formula= C₈H₁₀N₄O₂C₈H₁₀N₄O₂lockedexact matchbest_mz195.088 ± 2 × 10⁻¹⁰195.088locked0.015 % of the tolerance usedbest_rdbe6 ± 10⁻¹²6lockedunder 0.01 % of the tolerance usedbest_error_ppm-0.0104132 ± 10⁻⁶-0.0104132lockedunder 0.01 % of the tolerance usedr0003Benzene C₆H₆ at 78.04695 Da, 5 ppm (spec): the only formula; RDBE = 6 - 6/2 + 1 = 4 (three C=C + one ring); mass 78.04695019338 Da (IUPAC sum, rel 10⁻¹²)passed
best_formula= C₆H₆C₆H₆lockedexact matchunique= truetruelockedexact matchbest_rdbe4 ± 10⁻¹²4lockedunder 0.01 % of the tolerance usedbest_mass_Da78.047 ± 7.8 × 10⁻¹¹78.047lockedunder 0.01 % of the tolerance usedr0004Tight tolerance 0.1 ppm at 180.06339 Da returns one formula, C₆H₁₂O₆ (spec; the 5 ppm runner-up C₇H₁₆OS₂ sits 4.8 ppm away, checked by an independent brute-force enumeration)passed
candidate_count= 11lockedexact matchunique= truetruelockedexact matchbest_formula= C₆H₁₂O₆C₆H₁₂O₆lockedexact matchr0005Halogen RDBE: chlorobenzene C₆H₅Cl at 112.00798 Da,
cl_max2: RDBE = 6 - (5+1)/2 + 1 = 4; mass 72 + 5 × 1.00782503223 + 34.968852682 = 112.00797784315 Da (IUPAC sum, rel 10⁻¹²)passedtarget.listed= truemisseddifferstarget.rdbe= 4, within 1.000000 × 10⁻¹²reading not recorded on this pagetarget.mass_Da= 112.007978, within 1.000000 × 10⁻¹² relativereading not recorded on this pagebest_formula= C₆H₅ClC₆H₅Cllockedexact matchr0006Nitrogen rule: radical C₅H₆N (nominal 80, one N, RDBE 5 - 6/2 + 1/2 + 1 = 3.5) at 80.05002 Da is in the 5 ppm window but rejectedpassed
target.nitrogen_rule_ok= falsemisseddifferstarget.listed= falsemisseddifferstarget.nominal_mass= 80misseddifferstarget.rdbe= 3.5, within 1.000000 × 10⁻¹²reading not recorded on this pager0007Negative mode: glucose [M-H]- at m/z 179.0561, 3 ppm: m/z = 180.06338810418 - 1.00782503223 + 0.000548579909 = 179.056111651859 (rel 10⁻¹²; electron added, not removed)passed
best_formula= C₆H₁₂O₆C₆H₁₂O₆lockedexact matchbest_mz179.056 ± 1.8 × 10⁻¹⁰179.056lockedunder 0.01 % of the tolerance usedcharge= -1-1lockedexact match
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
neutral_mass | Da | Measured monoisotopic mass of the neutral molecule. Give this or mz, not both. | |
mz | Da | Measured m/z of the ion (Da per elementary charge, i.e. thomson). Give this or neutral_mass, not both. | |
adduct | [M+H]+ | Ion form when mz is given: [M+H]+, [M-H]-, [M+Na]+, [M+K]+, [M+NH₄]+, [M+2H]2+, [2M+H]+, [M+FA-H]-, [M-H₂O+H]+, [M]+ ... m/z = (n M + atoms added - atoms lost - z m_e) / |z|. | |
tolerance_ppm | 5 | Half-width of the window, parts per million of the theoretical value on the measured scale. | |
c_max | 1 | 100 | |
h_max | 1 | 200 | |
n_max | 1 | 10 | |
o_max | 1 | 20 | |
s_max | 1 | 4 | |
p_max | 1 | 3 | |
f_max | 1 | 0 | |
cl_max | 1 | 0 | |
br_max | 1 | 0 | |
i_max | 1 | 0 | |
min_atoms | Lower limits per element, e.g. {"Cl": 1} when the isotope pattern shows chlorine. | ||
rdbe_min | 1 | 0 | |
rdbe_max | 1 | 40 | |
h_per_c_min | 1 | 0.2 | |
h_per_c_max | 1 | 3.1 | |
nitrogen_rule | true | Keep only closed-shell neutral formulas: nominal mass and N count both even or both odd (same as a whole-number RDBE for these ten elements). | |
target_formula | Optional expected formula (e.g. C₆H₁₂O₆): its mass, error, RDBE and why it is or is not listed. | ||
max_candidates | 1 | 25 | Rows in the candidates reading; out/candidates.csv holds them all. |
Readings
| Name | Unit | Meaning |
|---|---|---|
measured | Da | The measured value: neutral mass, or m/z in Da per charge. |
neutral_mass_Da | Da | |
tolerance_ppm | parts per million (no kernel unit for ppm, left undeclared) | |
window_mDa | mDa | Half-width of the neutral-mass window. |
in_window_count | 1 | |
candidate_count | 1 | |
listed_count | 1 | |
unique | true when exactly one formula passes | |
best_formula | Hill formula of the lowest-|error| candidate | |
best_mass_Da | Da | |
best_mz | Da | |
best_error_ppm | (measured - theoretical)/theoretical x 10⁶, parts per million | |
best_error_mDa | mDa | |
best_rdbe | 1 | |
best_h_per_c | 1 | |
best_nominal_mass | Da | |
second_error_ppm | parts per million | |
candidates | Best first: formula, mass_Da, mz, error_ppm, error_mDa, rdbe, h_per_c, nominal_mass, nitrogen_rule_ok, atoms | |
target | The expected formula, if named | |
rejected | Formulas inside the window rejected by each rule (one formula may fail several) | |
warnings | ||
search_nodes | 1 | Loop steps taken; out/candidates.csv holds every candidate, best first, with its atom counts. |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.