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

[proforma] Use cache on modification resolvers #147

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 6 additions & 0 deletions pyteomics/proforma.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .mass import Composition, std_aa_mass, Unimod, nist_mass, calculate_mass, std_ion_comp, mass_charge_ratio
from .auxiliary import PyteomicsError, BasicComposition
from .auxiliary.utils import add_metaclass
from .auxiliary.utils import memoize

try:
import numpy as np
Expand Down Expand Up @@ -343,6 +344,7 @@ def load_database(self):
return obo_cache.resolve("http://www.unimod.org/obo/unimod.obo")
return Unimod()

@memoize(maxsize=10000)
def resolve(self, name=None, id=None, **kwargs):
strict = kwargs.get("strict", self.strict)
exhaustive = kwargs.get("exhaustive", True)
Expand Down Expand Up @@ -398,6 +400,7 @@ def __init__(self, **kwargs):
def load_database(self):
return load_psimod()

@memoize(maxsize=10000)
def resolve(self, name=None, id=None, **kwargs):
if name is not None:
defn = self.database[name]
Expand Down Expand Up @@ -443,6 +446,7 @@ def __init__(self, **kwargs):
def load_database(self):
return load_xlmod()

@memoize(maxsize=10000)
def resolve(self, name=None, id=None, **kwargs):
if name is not None:
defn = self.database[name]
Expand Down Expand Up @@ -562,6 +566,7 @@ def get_mass_from_term(self, term, raw_mass):
"Only a rough approximation is available.") % (term, ))
return rough_mass

@memoize(maxsize=10000)
def resolve(self, name=None, id=None, **kwargs):
if name is not None:
term = self.database[name]
Expand Down Expand Up @@ -613,6 +618,7 @@ def parse_identifier(self, identifier):
"""
return identifier, None

@memoize(maxsize=10000)
def resolve(self, name=None, id=None, **kwargs):
defn = None
for resolver in self.resolvers:
Expand Down