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

Added index= prefix for the scan_id key for spectra originating from MGF files #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion depthcharge/data/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def parse_spectrum(self, spectrum: dict) -> MassSpectrum:
if self.valid_charge is None or precursor_charge in self.valid_charge:
return MassSpectrum(
filename=str(self.peak_file),
scan_id=self._counter,
scan_id=f"index={self._counter}",
mz=spectrum["m/z array"],
intensity=spectrum["intensity array"],
ms_level=self._assumed_ms_level,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/test_data/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_indexing(tokenizer, mgf_small, tmp_path):
spec = dataset[0]
assert len(spec) == 7
assert spec["peak_file"] == ["small.mgf"]
assert spec["scan_id"] == ["0"]
assert spec["scan_id"] == ["index=0"]
assert spec["ms_level"].item() == 2
assert (spec["precursor_mz"].item() - 416.2448) < 0.001

Expand Down Expand Up @@ -124,7 +124,7 @@ def test_load(tokenizer, tmp_path, mgf_small):
spec = dataset[0]
assert len(spec) == 8
assert spec["peak_file"] == ["small.mgf"]
assert spec["scan_id"] == ["0"]
assert spec["scan_id"] == ["index=0"]
assert spec["ms_level"] == 2
assert (spec["precursor_mz"] - 416.2448) < 0.001

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_data/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_mgf_and_base(mgf_small):
expected = pl.DataFrame(
{
"peak_file": [mgf_small.name] * 2,
"scan_id": ["0", "1"],
"scan_id": ["index=0", "index=1"],
"ms_level": [2, 2],
"precursor_mz": [416.24474357, 257.464565],
"precursor_charge": [2, 3],
Expand Down
Loading