Skip to content

Commit

Permalink
MGF file index= prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilferrit committed Oct 17, 2024
1 parent 486221c commit 29f3d22
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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

0 comments on commit 29f3d22

Please sign in to comment.