:py:mod:`cobra.io.web` ====================== .. py:module:: cobra.io.web .. autoapi-nested-parse:: Provide functionality to access remote model repositories. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 abstract_model_repository/index.rst bigg_models_repository/index.rst biomodels_repository/index.rst cobrapy_repository/index.rst load/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: cobra.io.web.AbstractModelRepository cobra.io.web.BiGGModels cobra.io.web.BioModels Functions ~~~~~~~~~ .. autoapisummary:: cobra.io.web.load_model .. py:class:: AbstractModelRepository(*, url: Union[httpx.URL, str], **kwargs) Bases: :py:obj:`abc.ABC` Define an abstract base class that describes a remote model repository. .. attribute:: name The name of the remote repository. :type: str .. py:property:: url :type: httpx.URL Return the repository's URL. .. py:attribute:: _progress .. py:attribute:: name :type: str :value: 'Abstract' .. py:method:: get_sbml(model_id: str) -> bytes :abstractmethod: Attempt to download an SBML document from the repository. :param model_id: The identifier of the desired metabolic model. This is typically repository specific. :type model_id: str :returns: A gzip-compressed, UTF-8 encoded SBML document. :rtype: bytes .. py:class:: BiGGModels(**kwargs) Bases: :py:obj:`cobra.io.web.abstract_model_repository.AbstractModelRepository` Define a concrete implementation of the BiGG Models repository. .. attribute:: name The name of the BiGG Models repository. :type: str .. py:attribute:: name :type: str :value: 'BiGG Models' .. py:method:: get_sbml(model_id: str) -> bytes Attempt to download an SBML document from the repository. :param model_id: The identifier of the desired metabolic model. This is typically repository specific. :type model_id: str :returns: A gzip-compressed, UTF-8 encoded SBML document. :rtype: bytes :raises httpx.HTTPError: In case there are any connection problems. .. py:class:: BioModels(**kwargs) Bases: :py:obj:`cobra.io.web.abstract_model_repository.AbstractModelRepository` Define a concrete implementation of the BioModels repository. .. attribute:: name The name of the BioModels repository. :type: str .. py:attribute:: name :type: str :value: 'BioModels' .. py:method:: get_sbml(model_id: str) -> bytes Attempt to download an SBML document from the repository. :param model_id: The identifier of the desired metabolic model. This is typically repository specific. :type model_id: str :returns: A gzip-compressed, UTF-8 encoded SBML document. :rtype: bytes :raises httpx.HTTPError: In case there are any connection problems. .. py:function:: load_model(model_id: str, repositories: Iterable[cobra.io.web.abstract_model_repository.AbstractModelRepository] = DEFAULT_REPOSITORIES, cache: bool = True) -> cobra.core.Model Download an SBML model from a remote repository. Downloaded SBML documents are by default stored in a cache on disk such that future access is much faster. By default, models can be loaded from the following repositories: * BiGG Models * BioModels You can use the ``AbstractModelRepository`` class as a parent to implement your own repository accessor which you pass to the ``load_model`` function. In case you implement a new interface, please consider submitting a pull request to COBRApy. :param model_id: The identifier of the desired metabolic model. This is typically repository specific. :type model_id: str :param repositories: An iterable of repository accessor instances. The model_id is searched in order. :type repositories: iterable, optional :param cache: Whether or not to use the local caching mechanism (default yes). :type cache: bool, optional :returns: A model instance generated from the SBML document. :rtype: Model :raises RuntimeError: As with any internet connection, there are multiple errors that can occur. .. rubric:: Examples # Most of the time calling `load_model` with an identifier should be enough. >>> print(load_model("e_coli_core")) e_coli_core >>> print(load_model("MODEL1510010000")) MODEL1510010000 .. seealso:: :obj:`BiGGModels`, :obj:`BioModels`