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

If psims is available, use its Unimod because it caches and vendors #129

Merged

Conversation

mobiusklein
Copy link
Contributor

Fixes #128

If available, proforma will use psims's Unimod API instead. This way applications and users can use psims's caching features and have access to a fallback copy of the supported controlled vocabularies when the internet is inaccessible.

@levitsky
Copy link
Owner

Thank you! It appears that on Python 2, psims 0.1.45 is installed, which is allowed by the current test-requirements and seems to include OBOCache and fallback files (although outdated, I imagine), but no load method on OBOCache. It appears that load does some kind of dispatching to a resolver which can be done directly here? I don't have a proper understanding of this but if I can help, I'll be happy to try.

@mobiusklein
Copy link
Contributor Author

Thank you for pointing out the older version. Apparently the earlier APIs of OBOCache weren't as consistent. I've updated the code to work with the older API. Fortunately, most of the other loader functions already wrap this behavior up, and it was only the custom loader for Unimod that wasn't working the way I expected it to.

@levitsky levitsky merged commit 07ae745 into levitsky:master Oct 17, 2023
7 checks passed
@levitsky
Copy link
Owner

Thank you! I tried it locally, and the proforma tests now pass even without Internet connection.

I do get some warnings from within psims when testing offline, which don't get raised when online:

  return GzipFile(fileobj=_load(__name__, "unimod_tables.xml.gz"))
/home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/controlled_vocabulary.py:622: ResourceWarning: unclosed file <_io.BufferedReader name='/home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/vendor/unimod_tables.xml.gz'>
  return unimod.Unimod(None, _use_vendored_unimod_xml())
ResourceWarning: Enable tracemalloc to get the object allocation traceback
../home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/vendor/__init__.py:17: DeprecationWarning: open_binary is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
  return GzipFile(fileobj=_load(__name__, "psi-mod.obo.gz"))
/home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/controlled_vocabulary.py:694: ResourceWarning: unclosed file <_io.BufferedReader name='/home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/vendor/psi-mod.obo.gz'>
  cv = obo_cache.load("https://raw.githubusercontent.com/HUPO-PSI/psi-mod-CV/master/PSI-MOD.obo")
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./home/lev/py/pyteomics/pyteomics/proforma.py:1315: UserWarning: Slice bisecting interval (4-12)None
  warnings.warn("Slice bisecting interval %s" % (self, ))
......./home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/vendor/__init__.py:45: DeprecationWarning: open_binary is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
  return GzipFile(fileobj=_load(__name__, "gno.obo.gz"))
/home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/controlled_vocabulary.py:699: ResourceWarning: unclosed file <_io.BufferedReader name='/home/lev/.virtualenvs/pyteomics/lib/python3.11/site-packages/psims/controlled_vocabulary/vendor/gno.obo.gz'>
  cv = obo_cache.load("http://purl.obolibrary.org/obo/gno.obo")
ResourceWarning: Enable tracemalloc to get the object allocation traceback
.../home/lev/py/pyteomics/pyteomics/proforma.py:1315: UserWarning: Slice bisecting interval (4-12)[MassModification(19.0523, None, None)]
  warnings.warn("Slice bisecting interval %s" % (self, ))
......
----------------------------------------------------------------------
Ran 19 tests in 7.930s

OK

With Internet, only the last warning is displayed. Just thought I'd let you know.

Thank you once more for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Import of Unimod schema crashes when Unimod is down
2 participants