7.1.2.3. cobramod.retrieval

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

7.1.2.3.1. Attributes

7.1.2.3.2. Classes

Databases

Simple object that shows the information about the database

Data

7.1.2.3.3. Functions

get_response(query[, model_id])

Request different servers to see if there a valid response and returns the

file_to_Data_class(identifier, filename, genome)

Creates a Data object from given file.

write(name, directory, response)

Finds the content type and writes the data into disk and returns the Path

get_files(directory, identifier)

Returns a Generator with the possible files given a specific identifier

get_data(identifier, directory, database[, model_id, ...])

Retrieves the Data for given identifier. This function either retrieves

build_reaction_from_str(model, reaction, reaction_str, ...)

Populates the reaction with Metabolites from given reaction string.

7.1.2.3.4. Module Contents

cobramod.retrieval.debug_log
cobramod.retrieval.db_configuration
cobramod.retrieval.BIOCYC = 'https://websvc.biocyc.org/getxml?id='
cobramod.retrieval.PMN = 'https://pmn.plantcyc.org/getxml?id='
cobramod.retrieval.KEGG = 'https://rest.kegg.jp/get/'
cobramod.retrieval.SOLCYC = 'https://solcyc.sgn.cornell.edu/getxml?id='
cobramod.retrieval.EXTENSIONS = ['.xml', '.txt', '.json']
class cobramod.retrieval.Databases

Simple object that shows the information about the database

cobramod.retrieval.available_databases
cobramod.retrieval.databases
class cobramod.retrieval.Data(identifier, attributes, mode, database, path, model_id, version)
Parameters:
identifier: str
mode: str
database: str
attributes: dict[str, Any]
path: pathlib.Path
model_id: str
genome: str
version: str

CobraMod’s Data object. This class is responsible for converting information into COBRApy objects

classmethod from_json(entry, data, database, path)

Creates an instance from a JSON file. Database: BIGG

Parameters:
classmethod from_text(entry, text, database, path, genome)

Creates an instance from plain text. Database: KEGG

Parameters:
classmethod from_xml(entry, root, database, path)

Creates an instance from an XML file. Database: Biocyc families

Parameters:
parse(model, compartment, replacement={})

Parses information and creates a cobrapy Object. This can be a Metabolite or Reaction.

Parameters:
  • model (cobra.core.Model) – Model to search for information

  • compartment (str) – Location of the object

  • replacement (dict[str, str]) – 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

Returns:

cobra.core.Object This can be a Reaction or Metabolites

Return type:

cobra.core.Object

cobramod.retrieval.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

Parameters:
  • query (str)

  • model_id (Optional[str])

Return type:

tuple[str, requests.Response]

cobramod.retrieval.file_to_Data_class(identifier, filename, genome)

Creates a Data object from given file.

Parameters:
  • identifier (str) – Identifier of the object. It should be included in the file itself

  • filename (Path) – Location of the file

  • genome (Optional[str]) – BIGG-specific argument. Genome involved

Returns:

Data

Return type:

Data

cobramod.retrieval.write(name, directory, response)

Finds the content type and writes the data into disk and returns the Path of the new file

Parameters:
Return type:

pathlib.Path

cobramod.retrieval.get_files(directory, identifier)

Returns a Generator with the possible files given a specific identifier

Parameters:
cobramod.retrieval.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.

Parameters:
  • identifier (str) – Name of the object to retrieve

  • dictionary (str or Path) – Location of the files to retrieve or store

  • database (Optional[str]) – Name of the database. Check cobramod.retrieval.available_databases for more information

  • model_id (Optional[str]) – BIGG-specific argument. Name of the model to retrieve information

  • genome (Optional[str]) – (Optional[str]): Name of the genome to retrieve

  • directory (Union[str, pathlib.Path])

Returns:

Data

Return type:

Data

cobramod.retrieval.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

Parameters:
  • model (cobra.core.Model) – Model to search for metabolites

  • reaction (cobra.core.Reaction) – Empty reaction to populate

  • reaction_str (str) – valid reaction string

  • directory (Path) – Path for the location of the directory where the information is stored

  • database (str, optional) – Name of the database. Check cobramod.retrieval.available_databases for more information

  • model_id (str, optional) – BIGG-specific argument. Name of the model to retrieve information

  • genome – (Optional[str]): Name of the genome to retrieve

  • replacement (dict[str, str]) – 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