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

Updated matchms function path within cheminfo.py and its test #854

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions metatlas/tools/cheminfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import matchms
import numpy as np

from matchms.filtering.load_adducts import load_adducts_dict
from matchms.filtering.filter_utils.load_known_adducts import load_known_adducts
from rdkit import Chem

from metatlas.interfaces.compounds import structure_cleaning as cleaning
Expand All @@ -28,7 +28,7 @@ def get_parent_mass(precursor_mz: float, adduct: str) -> float:
@functools.lru_cache
def get_precursor_mz(parent_mass: float, adduct: str) -> float:
"""For an input molecule with parent_mass that generates adduct, return the resutling precursor_mz"""
adducts = load_adducts_dict()
adducts = load_known_adducts()
if adduct not in adducts:
raise KeyError("Adduct '%s' is not supported")
multiplier = adducts[adduct]["mass_multiplier"]
Expand All @@ -39,7 +39,7 @@ def get_precursor_mz(parent_mass: float, adduct: str) -> float:
@functools.lru_cache
def is_positive_mode(adduct: str) -> bool:
"""Returns True if the MS mode for an adduct is positive"""
adducts = load_adducts_dict()
adducts = load_known_adducts()
if adduct not in adducts:
raise KeyError("Adduct '%s' is not supported")
return adducts[adduct]["ionmode"] == "positive"
Expand Down Expand Up @@ -149,7 +149,7 @@ def valid_adduct(value: str) -> bool:
True if the value is an adduct listed supported by the matchms package
This is not a comprehensive list, so it will return False for some uncommon adducts
"""
adducts = load_adducts_dict()
adducts = load_known_adducts()
return value in adducts


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_cheminfo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pylint: disable=missing-function-docstring, missing-module-docstring, line-too-long

from matchms.filtering.load_adducts import load_adducts_dict
from matchms.filtering.filter_utils.load_known_adducts import load_known_adducts
from rdkit import Chem

from metatlas.tools import cheminfo
Expand All @@ -11,7 +11,7 @@


def test_get_parent_mass01():
adducts = load_adducts_dict()
adducts = load_known_adducts()
original_parent = 100
for name in adducts:
pre = cheminfo.get_precursor_mz(original_parent, name)
Expand Down
Loading