7.1.1.1.1.2. cobramod.core.crossreferences

7.1.1.1.1.2.1. Attributes

7.1.1.1.1.2.2. Functions

inchikey2pubchem_cid(inchikey, directory)

This function returns the corresponding PubChem compound ID for an

load_cache_from_disk(sort, directory)

The function loads the locally stored cache and returns it as a

get_crossreferences(sort, querys, directory)

Searches for IDs, other IDs from other databases. MetaNetX is

metanetx2ec(id, directory[, include_metanetx_specific_ec])

Returns the corresponding EC number for a specific MetaNetX ID.

get_reac_prop_with_ec(directory)

This function loads the file reac_prop from MetaNetX and stores it in

add2dict_unique(key, value, dictionary)

Adds key-value pairs to a dictionary. It is expected that the values

add_crossreferences(object, directory[, ...])

Extends the passed object by cross-references. Here, only the

7.1.1.1.1.2.3. Module Contents

cobramod.core.crossreferences.debug_log
cobramod.core.crossreferences.inchikey2pubchem_cid(inchikey, directory)

This function returns the corresponding PubChem compound ID for an InChIKey. A local cache is used, which is located in the specified directory under the folder XREF. :param inchikey: The InChIKey for which the PubChem compound ID is to be

searched.

Parameters:
  • directory (pathlib.Path) – The directory for storing the data. This is where the cache is stored in a folder called XRef.

  • inchikey (Union[str, List[str]])

Returns:

The PubChem compound ID(s) found as a string if it is one or as a

list of strings otherwise.

Return type:

Union[str, List[str]]

cobramod.core.crossreferences.load_cache_from_disk(sort, directory)

The function loads the locally stored cache and returns it as a pandas DataFrame. If there is no cache file yet an empty DataFrame with columns ‘ID’ and ‘XRefs’ is returned. :param sort: Der cache Name. :param directory: The directory for storing the data. This is where

the cache is stored in a folder called XRef.

Parameters:
Return type:

pandas.DataFrame

cobramod.core.crossreferences.get_crossreferences(sort, querys, directory)

Searches for IDs, other IDs from other databases. MetaNetX is used for this purpose. Results are stored locally in the specified directory and if they are found in it, they are loaded from it. :param sort: Type of IDs’ possible specifications are “chem” for

metabolites or “reac” for reactions.

Parameters:
  • querys (Union[str, List[str]]) – The IDs of a metabolite or a reaction. Can be either a string of the form “database:identifier” or a list of such strings. The list should only consist of identifiers for an object, as these will be merged.

  • directory (pathlib.Path) – The directory for storing the data. This is where the cache is stored in a folder called XRef.

  • sort (str)

Returns:

All references retrieved as a set of strings of the structure: “database:ID”.

Return type:

Set[str]

cobramod.core.crossreferences.metanetx2ec(id, directory, include_metanetx_specific_ec=False)

Returns the corresponding EC number for a specific MetaNetX ID. :param id: The MetaNetX ID. :param directory: The directory for storing the data. This is where

the cache is stored in a folder called XRef.

Parameters:
  • include_metanetx_specific_ec (bool) – Determines whether MetaNetX specific EC numbers should be taken over. These are generally not found in other databases. The default value is False.

  • id (Union[str, List[str]])

  • directory (pathlib.Path)

Return type:

Union[str, List[str]]

Raises

KeyError: If no EC number can be assigned to this ID.

Returns:

All found EC numbers.

Parameters:
Return type:

Union[str, List[str]]

cobramod.core.crossreferences.get_reac_prop_with_ec(directory)

This function loads the file reac_prop from MetaNetX and stores it in memory using the lru_cache. The returned DataFrame contains only the rows that have an EC number.

Parameters:

directory (pathlib.Path) – The directory for storing the data. This is where the cache is stored in a folder called XRef.

Return type:

pandas.DataFrame

cobramod.core.crossreferences.add2dict_unique(key, value, dictionary)

Adds key-value pairs to a dictionary. It is expected that the values are either single objects or in a list. If the key does not yet exist in the dictionary, the value is added directly with it. If the key already exists, the values are joined together like this. That a list is assigned to the key, which contains unique values. If only one value remains, it will be added directly and not in a list. :param key: The key to be used. :param value: The Values to be added. This can be a single object or

objects in a list.

Parameters:
  • dictionary (dict) – The dictionary to which the objects should be added.

  • value (Union[Any, List[Any]])

Returns:

The new dictionary.

Return type:

dict

cobramod.core.crossreferences.add_crossreferences(object, directory, consider_sub_elements=True, include_metanetx_specific_ec=False)

Extends the passed object by cross-references. Here, only the cross-references of reactions or metabolites are expanded. There must be at least one MetaNetX resolvable identifier in the annotation of the object in order to get as many cross-references as possible. Overall, an attempt is made to add all cross-references required by Memote. The only exception are reactom reactions. These are not added due to the current lack of query capabilities on the part of reactom. (Depending on the number of objects this function can take some time).

Parameters:
  • object (Union[cobra.Model, cobra.core.Group, cobra.Reaction, cobra.Metabolite]) – The CobraPy object to be extended.

  • directory (Union[pathlib.Path, str]) – The directory for storing the data. This is where the cache is stored in a folder called XRef.

  • consider_sub_elements (bool) – Specifies whether additional cross-references should also be added to the subelements. For example, you can specify whether only the reaction or also its metabolites should be expanded.

  • include_metanetx_specific_ec (bool) – Determines whether MetaNetX specific EC numbers should be taken over. These are generally not found in other databases. Furthermore, this could result in non-existing Brenda IDs being created. The default value is False.

Return type:

None