Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible format for scan titles #369

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@ def _create_mzml(peptides, mzml_file, random_state=42):
)
with writer.run(id=1, instrument_configuration="ic"):
with writer.spectrum_list(len(peptides)):
for scan_nr, peptide in zip([17, 111], peptides):
for scan_id, peptide in zip(
[
"scan=17",
"merged=11 frame=12 scanStart=763 scanEnd=787",
],
peptides,
):
charge = rng.choice([2, 3])

precursor = writer.precursor_builder()
Expand All @@ -193,7 +199,7 @@ def _create_mzml(peptides, mzml_file, random_state=42):
writer.write_spectrum(
mzs,
intensities,
id=f"scan={scan_nr}",
id=scan_id,
centroided=True,
params=[{"ms level": 2}],
precursor_information=precursor,
Expand Down
5 changes: 4 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def test_train_and_run(
assert psms.loc[3, "sequence"] == "LESLLEK"
assert psms.loc[3, "spectra_ref"] == "ms_run[2]:scan=17"
assert psms.loc[4, "sequence"] == "PEPTLDEK"
assert psms.loc[4, "spectra_ref"] == "ms_run[2]:scan=111"
assert (
psms.loc[4, "spectra_ref"]
== "ms_run[2]:merged=11 frame=12 scanStart=763 scanEnd=787"
)

# Finally, try evaluating:
output_filename = tmp_path / "test-eval.mztab"
Expand Down
14 changes: 7 additions & 7 deletions tests/unit_tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,23 +864,23 @@ def test_spectrum_id_mgf(mgf_small, tmp_path):


def test_spectrum_id_mzml(mzml_small, tmp_path):
"""Test that spectra from mzML files are specified by their scan number."""
"""Test that spectra from mzML files are specified by their scan id."""
mzml_small2 = tmp_path / "mzml_small2.mzml"
shutil.copy(mzml_small, mzml_small2)

index = SpectrumIndex(
tmp_path / "index.hdf5", [mzml_small, mzml_small2], overwrite=True
)
dataset = SpectrumDataset(index)
for i, (filename, scan_nr) in enumerate(
for i, (filename, scan_id) in enumerate(
[
(mzml_small, 17),
(mzml_small, 111),
(mzml_small2, 17),
(mzml_small2, 111),
(mzml_small, "scan=17"),
(mzml_small, "merged=11 frame=12 scanStart=763 scanEnd=787"),
(mzml_small2, "scan=17"),
(mzml_small2, "merged=11 frame=12 scanStart=763 scanEnd=787"),
]
):
spectrum_id = str(filename), f"scan={scan_nr}"
spectrum_id = str(filename), scan_id
assert dataset.get_spectrum_id(i) == spectrum_id


Expand Down
Loading