Skip to content

Commit

Permalink
update GNPSSpectrumLoader for gnps2 (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng authored Jan 21, 2025
1 parent 1da6622 commit b9524c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/nplinker/metabolomics/gnps/gnps_spectrum_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class GNPSSpectrumLoader(SpectrumLoaderBase):
- METABOLOMICS-SNETS-V2*.mgf
3. FEATURE-BASED-MOLECULAR-NETWORKING
- spectra/*.mgf
4. GNPS2 classical_networking_workflow
- nf_output/clustering/specs_ms.mgf
5. GNPS2 feature_based_molecular_networking_workflow
- nf_output/clustering/specs_ms.mgf
"""

def __init__(self, file: str | PathLike) -> None:
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/metabolomics/test_gnps_spectrum_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"workflow, num_spectra",
[[GNPSFormat.FBMN, 1492], [GNPSFormat.SNETS, 25935], [GNPSFormat.SNETSV2, 7383]],
)
def test_gnps_spectrum_loader(workflow, num_spectra, gnps_spectra_files):
def test_gnps_spectrum_loader_gnps1(workflow, num_spectra, gnps_spectra_files):
loader = GNPSSpectrumLoader(gnps_spectra_files[workflow])
assert len(loader.spectra) == num_spectra


@pytest.mark.parametrize(
"workflow, num_spectra",
[[GNPSFormat.GNPS2CN, 1051], [GNPSFormat.GNPS2FBMN, 371]],
)
def test_gnps_spectrum_loader_gnps2(workflow, num_spectra, gnps2_spectra_files):
loader = GNPSSpectrumLoader(gnps2_spectra_files[workflow])
assert len(loader.spectra) == num_spectra

0 comments on commit b9524c6

Please sign in to comment.