cobramod.retrieval ================== .. py:module:: cobramod.retrieval .. autoapi-nested-parse:: Retrieval of data from multiple databases This module includes the class 'Data', that is responsable for the internal data representation for this package. The class Data includes methods for parsing itself into a Reaction, Metabolite or Pathway. Additionally, this package includes high level functions such as `get_data`, `file_to_Data_class` or `get_response` that handles the data retrieval or convertion Attributes ---------- .. autoapisummary:: cobramod.retrieval.debug_log cobramod.retrieval.db_configuration cobramod.retrieval.BIOCYC cobramod.retrieval.PMN cobramod.retrieval.KEGG cobramod.retrieval.SOLCYC cobramod.retrieval.EXTENSIONS cobramod.retrieval.available_databases cobramod.retrieval.databases Classes ------- .. autoapisummary:: cobramod.retrieval.Databases cobramod.retrieval.Data Functions --------- .. autoapisummary:: cobramod.retrieval.get_response cobramod.retrieval.file_to_Data_class cobramod.retrieval.write cobramod.retrieval.get_files cobramod.retrieval.get_data cobramod.retrieval.build_reaction_from_str Module Contents --------------- .. py:data:: debug_log .. py:data:: db_configuration .. py:data:: BIOCYC :value: 'https://websvc.biocyc.org/getxml?id=' .. py:data:: PMN :value: 'https://pmn.plantcyc.org/getxml?id=' .. py:data:: KEGG :value: 'https://rest.kegg.jp/get/' .. py:data:: SOLCYC :value: 'https://solcyc.sgn.cornell.edu/getxml?id=' .. py:data:: EXTENSIONS :value: ['.xml', '.txt', '.json'] .. py:class:: Databases Simple object that shows the information about the database .. py:data:: available_databases .. py:data:: databases .. py:class:: Data(identifier, attributes, mode, database, path, model_id, version) .. py:attribute:: identifier :type: str .. py:attribute:: mode :type: str .. py:attribute:: database :type: str .. py:attribute:: attributes :type: dict[str, Any] .. py:attribute:: path :type: pathlib.Path .. py:attribute:: model_id :type: str .. py:attribute:: genome :type: str .. py:attribute:: version :type: str CobraMod's Data object. This class is responsible for converting information into COBRApy objects .. py:method:: from_json(entry, data, database, path) :classmethod: Creates an instance from a JSON file. Database: BIGG .. py:method:: from_text(entry, text, database, path, genome) :classmethod: Creates an instance from plain text. Database: KEGG .. py:method:: from_xml(entry, root, database, path) :classmethod: Creates an instance from an XML file. Database: Biocyc families .. py:method:: parse(model, compartment, replacement = {}) Parses information and creates a cobrapy Object. This can be a Metabolite or Reaction. :param model: Model to search for information :type model: cobra.core.Model :param compartment: Location of the object :type compartment: str :param replacement: In case of Reactions, the dictionary represents the metabolites to replace. The key is the identifier of the object to replaced and the value is the new identifier to use instead. Defaults to an empty dictionary :type replacement: dict[str, str] :returns: cobra.core.Object This can be a Reaction or Metabolites .. py:function:: get_response(query, model_id = None) Request different servers to see if there a valid response and returns the database name with the response model_id is a BIGG-specific argument. The content type must be xml, json or text .. py:function:: file_to_Data_class(identifier, filename, genome) Creates a Data object from given file. :param identifier: Identifier of the object. It should be included in the file itself :type identifier: str :param filename: Location of the file :type filename: Path :param genome: BIGG-specific argument. Genome involved :type genome: Optional[str] :returns: Data .. py:function:: write(name, directory, response) Finds the content type and writes the data into disk and returns the Path of the new file .. py:function:: get_files(directory, identifier) Returns a Generator with the possible files given a specific identifier .. py:function:: get_data(identifier, directory, database, model_id = None, genome = None) Retrieves the Data for given identifier. This function either retrieves from the server of the databases or locally. :param identifier: Name of the object to retrieve :type identifier: str :param dictionary: Location of the files to retrieve or store :type dictionary: str or Path :param database: Name of the database. Check cobramod.retrieval.available_databases for more information :type database: Optional[str] :param model_id: BIGG-specific argument. Name of the model to retrieve information :type model_id: Optional[str] :param genome: (Optional[str]): Name of the genome to retrieve :returns: Data .. py:function:: build_reaction_from_str(model, reaction, reaction_str, directory, database, model_id, replacement) Populates the reaction with Metabolites from given reaction string. Metabolites are retrieved from the servers or locally :param model: Model to search for metabolites :type model: cobra.core.Model :param reaction: Empty reaction to populate :type reaction: cobra.core.Reaction :param reaction_str: valid reaction string :type reaction_str: str :param directory: Path for the location of the directory where the information is stored :type directory: Path :param database: Name of the database. Check cobramod.retrieval.available_databases for more information :type database: str, optional :param model_id: BIGG-specific argument. Name of the model to retrieve information :type model_id: str, optional :param genome: (Optional[str]): Name of the genome to retrieve :param replacement: The dictionary represents the metabolites to replace. The key is the identifier of the object to replaced and the value is the new identifier to use instead :type replacement: dict[str, str]