Skip to content

Commit

Permalink
If psims is available, use its Unimod because it caches and vendors
Browse files Browse the repository at this point in the history
  • Loading branch information
mobiusklein committed Oct 10, 2023
1 parent e2d4a8a commit 1bc5b35
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyteomics/proforma.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@
np = None

try:
from psims.controlled_vocabulary.controlled_vocabulary import (load_psimod, load_xlmod, load_gno, obo_cache)
from psims.controlled_vocabulary.controlled_vocabulary import (load_psimod, load_xlmod, load_gno, obo_cache, load_unimod)
_has_psims = True
except ImportError:
def _needs_psims(name):
raise ImportError("Loading %s requires the `psims` library. To access it, please install `psims`" % name)

load_psimod = partial(_needs_psims, 'PSIMOD')
load_xlmod = partial(_needs_psims, 'XLMOD')
load_gno = partial(_needs_psims, 'GNO')
load_unimod = partial(_needs_psims, 'UNIMOD')
obo_cache = None
_has_psims = False

_water_mass = calculate_mass("H2O")

Expand Down Expand Up @@ -357,6 +360,8 @@ def __init__(self, **kwargs):
self.strict = kwargs.get("strict", True)

def load_database(self):
if _has_psims:
return load_unimod()
return Unimod()

def resolve(self, name=None, id=None, **kwargs):
Expand Down

0 comments on commit 1bc5b35

Please sign in to comment.