Skip to content

Commit

Permalink
remove function test_get_spectra_from_mfs
Browse files Browse the repository at this point in the history
  • Loading branch information
CunliangGeng committed Dec 19, 2023
1 parent 3820347 commit 53247f7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
2 changes: 0 additions & 2 deletions src/nplinker/metabolomics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .utils import add_annotation_to_spectrum
from .utils import add_spectrum_to_mf
from .utils import add_strains_to_spectrum
from .utils import get_spectra_from_mfs


logging.getLogger(__name__).addHandler(logging.NullHandler())
Expand All @@ -13,7 +12,6 @@
__all__ = [
"MolecularFamily",
"Spectrum",
"get_spectra_from_mfs",
"add_annotation_to_spectrum",
"add_spectrum_to_mf",
"add_strains_to_spectrum",
Expand Down
15 changes: 0 additions & 15 deletions src/nplinker/metabolomics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,3 @@ def add_spectrum_to_mf(
f"{len(mf_missing_spec)} MolecularFamily objects have missing Spectrum objects."
)
return mf_with_spec, mf_without_spec, mf_missing_spec


def get_spectra_from_mfs(mfs: list[MolecularFamily]) -> list[Spectrum]:
"""Get all Spectrum objects from given MolecularFamily objects.
Args:
mfs(list[MolecularFamily]): A list of MolecularFamily objects.
Returns:
list[Spectrum]: A list of Spectrum objects.
"""
s = set()
for mf in mfs:
s |= set(mf.spectra)
return list(s)
22 changes: 0 additions & 22 deletions tests/metabolomics/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from nplinker.metabolomics import add_annotation_to_spectrum
from nplinker.metabolomics import add_spectrum_to_mf
from nplinker.metabolomics import add_strains_to_spectrum
from nplinker.metabolomics import get_spectra_from_mfs
from nplinker.strain import Strain
from nplinker.strain_collection import StrainCollection

Expand Down Expand Up @@ -77,24 +76,3 @@ def test_add_spectrum_to_mf(spectra):
assert mf_with_spec == [mf0, mf1]
assert mf_without_spec == [mf2]
assert mf_missing_spec == {mf1: {"spec-missing-1"}, mf2: {"spec-missing-2", "spec-missing-3"}}


def test_get_spectra_from_mfs(spectra):
"""Test the get_spectra_from_mfs function."""
mf0 = MolecularFamily("mf0")
mf0.spectra_ids = {"spec0", "spec1"}
mf0.add_spectrum(spectra[0])
mf0.add_spectrum(spectra[1])
mf1 = MolecularFamily("mf1")
mf1.spectra_ids = {
"spec2",
"spec-missing-1",
}
mf1.add_spectrum(spectra[2])
mf2 = MolecularFamily("mf2")
mf2.spectra_ids = {"spec-missing-2", "spec-missing-3"}
mfs = [mf0, mf1, mf2]

spec_from_mfs = get_spectra_from_mfs(mfs)

assert len(spec_from_mfs) == 3

0 comments on commit 53247f7

Please sign in to comment.