Write the untargeted LC-HRMS feature-table program of a hospital metabolomics core (mass-scale correction, peak detection, retention alignment across injections, isotope/adduct/fragment grouping, saturation-proof quantities, from raw Q-TOF scans) within a 60-minute session; it is run on further batches from the same instrument with known compounds.
harbor run -t reactive-labs/lcms-feature-alignmentharbor download reactive-labs/lcms-feature-alignmentYou are Ingrid Aasen, postdoctoral researcher in the Department of Intensive Care of Linnehavn University Hospital.
The hospital's Metabolomics and Bioanalysis Core (MBC) runs the KT-PANEL for the KYNO-ICU sepsis study on its
Kestrel 6500 Q-TOF, which records full-scan MS1 data of every injection. Today is Wednesday 18 November 2026.
Sofie Brandt, the study's PI, wrote this morning (the mail is in /app/inputs/docs/mail/):
What I need per batch is one aligned feature table over the study specimens and the pooled QCs: one row per compound, not per ion, reported under its [M+H]+ ion on a corrected mass scale, with its retention time and a quantity in each injection. The processing runs on the MBC processing PC like any other step: one program, started once per batch folder as KestrelAcq exports it, and stopped by the PC after 40 seconds.
You have 60 minutes. Whatever is in /app/output when the time is up is graded, so keep a working program saved
as you go.
In /app/inputs:
batches/: four KYNO-ICU batches, B26-0914, B26-1005, B26-1022 and B26-1104. Each folder holds
<batch>_sequence.xlsx (sheet Sequence, the sample list) and raw/, one .npz scan file and one .json
run sidecar per injection. The .npz holds the centroided MS1 scans (scan_rt in minutes, scan_index, mz,
intensity; the centroids of scan i are scan_index[i]:scan_index[i+1]) and the LockSpray function
(lock_rt, lock_index, lock_mz, lock_intensity).docs/: SOP-MBC-031 rev 4, validation report VR-MBC-031-02, the instrument logbook, stock records, certificates
and mails.method/ and legacy/: the KT-PANEL target list and the previous analyst's targeted script./app/output/features.py, run as
python3 /app/output/features.py <batch_dir> <out.json>
It reads one batch folder in the format of the four in hand and writes one JSON object:
{"batch": "B26-0914",
"features": [
{"mz": 209.09213, "rt": 2.318,
"ions": [{"mz": 210.09541}, {"mz": 231.07402}, {"mz": 192.06558}],
"rt_by_file": {"B26-0914_015": 2.3164, "B26-0914_016": 2.3171},
"quantity_by_file": {"B26-0914_015": 51234.0, "B26-0914_016": 48810.5}},
...]}
| Key | Content |
|---|---|
features |
one entry per compound detected in the batch's injections of Sample Type SMP or PQC |
mz |
m/z of the compound's [M+H]+ monoisotopic ion, on the corrected mass scale |
rt |
the compound's retention time in the batch (min), for example the median over its injections |
ions |
the compound's other ions in the batch (isotopologues, [M+Na]+ and its isotopologues, in-source fragments and their isotopologues), each as an object with its mz |
rt_by_file |
apex retention time (min) of the [M+H]+ ion in each SMP and PQC injection, keyed by Data File |
quantity_by_file |
a positive quantity proportional to the amount of the compound reaching the detector in each SMP and PQC injection, keyed by Data File; quantities are compared only between injections of the same compound, never normalised |
Injections of other sample types may appear in the dictionaries and are ignored. The program runs with Python
3.12, numpy, scipy, pandas and openpyxl, on one CPU core with 2 GB of memory and no network, and must finish a
batch (up to 140 injections) within 40 seconds of wall time. It is run as another user from a copy of
/app/output: it may load helper files that you put in /app/output (found relative to __file__), but
/app/inputs is not there when it runs.
/app/output/results/<batch>.json for each of the four batches in hand (for example
/app/output/results/B26-0914.json): the program's output for that batch.
Your program runs on 24 further KYNO-ICU batches acquired on the same instrument between 7 September and 13 November 2026 and exported the same way, whose compounds are known: plasma, urine and CSF batches in the layouts and sizes SOP-MBC-031 allows, including runs of more than 40 specimens. Some hold later study days of the subjects in the four batches in hand; others come from other patients, whose medication differs. The four batches in hand are known too, and your result files are compared in the same way.
In each batch, a compound is listed in the reference table when the apex of its [M+H]+ ion reaches 200 counts per
scan in at least one in five of the SMP and PQC injections; a cell (compound, injection) is graded when that
apex reaches 120 counts. Your features are paired one to one with the compounds of the batch (including weaker
ones) on m/z (within 20 ppm) and retention time (within 0.15 min). For each listed compound:
ions within 10 ppm, times the share of the listed ions that belong to the compound.A compound scores q x (0.4 + 0.2 m + 0.2 t + 0.2 g); a listed compound without a paired feature scores zero. A batch scores the mean over its listed compounds times (0.65 + 0.35 P), where P is the share of your features that are paired with a compound (a separate row for an isotopologue, adduct, fragment, background ion or noise lowers P), divided by what the MBC's own reference processing scores on the same batch (capped at 1). A batch on which the program fails, runs out of time or writes no readable JSON scores zero. The final score is 80 % the mean over the 24 further batches and 20 % the mean over the four result files.