cobramod.core.crossreferences ============================= .. py:module:: cobramod.core.crossreferences Attributes ---------- .. autoapisummary:: cobramod.core.crossreferences.debug_log Functions --------- .. autoapisummary:: cobramod.core.crossreferences.inchikey2pubchem_cid cobramod.core.crossreferences.load_cache_from_disk cobramod.core.crossreferences.get_crossreferences cobramod.core.crossreferences.metanetx2ec cobramod.core.crossreferences.get_reac_prop_with_ec cobramod.core.crossreferences.add2dict_unique cobramod.core.crossreferences.add_crossreferences Module Contents --------------- .. py:data:: debug_log .. py:function:: 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. :param directory: The directory for storing the data. This is where the cache is stored in a folder called XRef. :returns: The PubChem compound ID(s) found as a string if it is one or as a list of strings otherwise. .. py:function:: 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. .. py:function:: 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. :param querys: 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. :param directory: The directory for storing the data. This is where the cache is stored in a folder called XRef. :returns: All references retrieved as a set of strings of the structure: "database:ID". .. py:function:: 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. :param include_metanetx_specific_ec: Determines whether MetaNetX specific EC numbers should be taken over. These are generally not found in other databases. The default value is False. Raises KeyError: If no EC number can be assigned to this ID. :returns: All found EC numbers. .. py:function:: 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. :param directory: The directory for storing the data. This is where the cache is stored in a folder called XRef. .. py:function:: 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. :param dictionary: The dictionary to which the objects should be added. :returns: The new dictionary. .. py:function:: 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). :param object: The CobraPy object to be extended. :param directory: The directory for storing the data. This is where the cache is stored in a folder called XRef. :param consider_sub_elements: 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. :param include_metanetx_specific_ec: 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.