#!/usr/bin/env python# -*- coding: utf-8 -*-## This file is part of the `pypath` python module## Copyright 2014-2023# EMBL, EMBL-EBI, Uniklinik RWTH Aachen, Heidelberg University## Authors: see the file `README.rst`# Contact: Dénes Türei (turei.denes@gmail.com)## Distributed under the GPLv3 License.# See accompanying file LICENSE.txt or copy at# https://www.gnu.org/licenses/gpl-3.0.html## Website: https://pypath.omnipathdb.org/#"""This file collects all available models from the biomodels repositoryusing the bioservices python module, then downloads the individualmodels to parse for the relevant information to enter into pypath."""importtimeimportjsonimportpycurlimportrequestsimportpypath.resources.urlsasurlsimportpypath.share.curlascurlimportpypath.share.settingsassettingsimportpypath.share.sessionassession_logger=session.Logger(name='biomodels_input')_log=_logger._logtry:importbioservices.biomodelsasbiomexceptModuleNotFoundError:_log('Module `bioservices` not available. ''Install it by: pip install bioservices')
[docs]defget_single_model(model_id):""" Get single BioModel using bioservices. Args model_id (str): ID of model Returns dict: dictionary containing model specifics, eg name/id, description, associated files """bm=biom.BioModels()model=bm.get_model(model_id)returnmodel
[docs]defget_all_models():""" Fetch list of available models using bioservices. Returns dict: A dictionary of models with model identifiers as keys and model attributes as values. Model attributes include format (SMBL being most common), model id, name, submission/modification date and author. """bm=biom.BioModels()# CAUTION: Below function has a bug causing an infinite loop (Mar22)models=bm.get_all_models()returnmodels
[docs]defdownload_single_model(model_id):""" Download the main file of a single model to extract relevant data for pypath integration. Downloaded models should be cached. """