Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_ontology(name):
"""Imports the requested ontology with pronto
Tries to reach the online version, and if it fails then
use the local version instead.
Arguments:
name (str): the name of the ontology to import (either
'MS' or 'IMS')
"""
warnings.simplefilter('ignore', pronto.utils.ProntoWarning)
if name == 'MS':
try:
obo = pronto.Ontology(MS_CV_URL, False)
except BaseException as be:
obo = pronto.Ontology(os.path.join(ONTOLOGIES_DIR,"psi-ms.obo"), False)
warnings.warn("Could not use latest online MS ontology, "
"using local (version {})".format(obo.meta['version']))
elif name == 'IMS':
try:
obo = pronto.Ontology(IMS_CV_URL, True, 1)
except BaseException as be:
obo = pronto.Ontology(os.path.join(ONTOLOGIES_DIR,"imagingMS.obo"), True, 1)
warnings.warn("Could not use latest online IMS ontology, "
"using local (version {})".format(obo.meta['version']))
else:
raise ValueError("Unknow ontology to import: {}".format(name))