Skip to content

Commit

Permalink
update GNPSMolecularFamilyLoader for gnps2 (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng authored Jan 21, 2025
1 parent a36f870 commit 1da6622
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class GNPSMolecularFamilyLoader(MolecularFamilyLoaderBase):
- networkedges_selfloop/*.selfloop
3. FEATURE-BASED-MOLECULAR-NETWORKING
- networkedges_selfloop/*.selfloop
4. GNPS2 classical_networking_workflow
- nf_output/networking/filtered_pairs.tsv
5. GNPS2 feature_based_molecular_networking_workflow
- nf_output/networking/filtered_pairs.tsv
The `ComponentIndex` column in the GNPS molecular family file is treated
as family id.
Expand Down
20 changes: 19 additions & 1 deletion tests/unit/metabolomics/test_gnps_molecular_family_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(GNPSFormat.FBMN, 60, 5, False),
],
)
def test_gnps_molecular_family_loader(
def test_gnps_molecular_family_loader_gnps1(
workflow, num_families, num_spectra, keep_singleton, gnps_mf_files
):
"""Test GNPSMolecularFamilyLoader class."""
Expand All @@ -24,3 +24,21 @@ def test_gnps_molecular_family_loader(
# test molecular family with id "1" has correct number of spectra ids
mf = [mf for mf in actual if mf.id == "1"][0]
assert len(mf.spectra_ids) == num_spectra


@pytest.mark.parametrize(
"workflow, num_families, num_spectra, keep_singleton",
[
(GNPSFormat.GNPS2CN, 88, 66, True),
(GNPSFormat.GNPS2FBMN, 38, 7, True),
],
)
def test_gnps_molecular_family_loader_gnps2(
workflow, num_families, num_spectra, keep_singleton, gnps2_mf_files
):
loader = GNPSMolecularFamilyLoader(gnps2_mf_files[workflow])
actual = loader.get_mfs(keep_singleton=keep_singleton)
assert len(actual) == num_families
# test molecular family with id "1" has correct number of spectra ids
mf = [mf for mf in actual if mf.id == "1"][0]
assert len(mf.spectra_ids) == num_spectra

0 comments on commit 1da6622

Please sign in to comment.