Skip to content

Commit

Permalink
Updated matchms function path within cheminfo.py and its test
Browse files Browse the repository at this point in the history
  • Loading branch information
bkieft-usa committed Apr 5, 2024
1 parent 093b812 commit e07b1e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit e07b1e2

Please sign in to comment.