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

Save full peak file path key under the peak_file key of SpectrumDataset instead of just the file name. #69

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 @@ -197,7 +197,7 @@ def iter_batches(self, batch_size: int | None) -> pa.RecordBatch:
parsed = processor(parsed)

entry = {
"peak_file": self.peak_file.name,
"peak_file": str(self.peak_file.resolve()),
"scan_id": str(parsed.scan_id),
"ms_level": parsed.ms_level,
"precursor_mz": parsed.precursor_mz,
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 @@ -47,7 +47,7 @@ def test_indexing(tokenizer, mgf_small, tmp_path):

spec = dataset[0]
assert len(spec) == 7
assert spec["peak_file"] == ["small.mgf"]
assert spec["peak_file"] == [str(mgf_small.resolve())]
assert spec["scan_id"] == ["0"]
assert spec["ms_level"].item() == 2
assert (spec["precursor_mz"].item() - 416.2448) < 0.001
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_load(tokenizer, tmp_path, mgf_small):
dataset = SpectrumDataset.from_lance(db_path, 1)
spec = dataset[0]
assert len(spec) == 8
assert spec["peak_file"] == ["small.mgf"]
assert spec["peak_file"] == [str(mgf_small.resolve())]
assert spec["scan_id"] == ["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 @@ -71,7 +71,7 @@ def test_mgf_and_base(mgf_small):
)
expected = pl.DataFrame(
{
"peak_file": [mgf_small.name] * 2,
"peak_file": [str(mgf_small.resolve())] * 2,
"scan_id": ["0", "1"],
"ms_level": [2, 2],
"precursor_mz": [416.24474357, 257.464565],
Expand Down
Loading