def generate_component_id_namespace_overview(model, components):
    """
    Tabulate which MIRIAM databases the component's identifier matches.

    Parameters
    ----------
    model : cobra.Model
        A cobrapy metabolic model.
    components : {"metabolites", "reactions", "genes"}
        A string denoting `cobra.Model` components.

    Returns
    -------
    pandas.DataFrame
        The index of the table is given by the component identifiers. Each
        column corresponds to one MIRIAM database and a Boolean entry
        determines whether the annotation matches.

    """
    patterns = {
        "metabolites": METABOLITE_ANNOTATIONS,
        "reactions": REACTION_ANNOTATIONS,
        "genes": GENE_PRODUCT_ANNOTATIONS
    }[components]
    databases = list(patterns)
    data = list()
    index = list()
    for elem in getattr(model, components):
        index.append(elem.id)
        data.append(tuple(patterns[db].match(elem.id) is not None
                          for db in databases))
    df = pd.DataFrame(data, index=index, columns=databases)
    if components != "genes":
        # Clean up of the dataframe. Unfortunately the Biocyc patterns match
        # broadly. Hence, whenever a Metabolite or Reaction ID matches to any
        # DB pattern AND the Biocyc pattern we have to assume that this is a
        # false positive.
        # First determine all rows in which 'biocyc' and other entries are
        # True simultaneously and use this Boolean series to create another
        # column temporarily.
        df['duplicate'] = df[df['biocyc']].sum(axis=1) >= 2
        # Replace all nan values with False
        df['duplicate'].fillna(False, inplace=True)
        # Use the additional column to index the original dataframe to identify
        # false positive biocyc hits and set them to False.
        df.loc[df['duplicate'], 'biocyc'] = False
        # Delete the additional column
        del df['duplicate']
    return df
def generate_component_id_namespace_overview ( model , components ) : patterns = { "metabolites" : METABOLITE_ANNOTATIONS , "reactions" : REACTION_ANNOTATIONS , "genes" : GENE_PRODUCT_ANNOTATIONS } [ components ] databases = list ( patterns ) data = list ( ) index = list ( ) for elem in getattr ( model , components ) : index . append ( elem . id ) data . append ( tuple ( patterns [ db ] . match ( elem . id ) is not None for db in databases ) ) df = pd . DataFrame ( data , index = index , columns = databases ) if components != "genes" : df [ 'duplicate' ] = df [ df [ 'biocyc' ] ] . sum ( axis = 1 ) >= 2 df [ 'duplicate' ] . fillna ( False , inplace = True ) df . loc [ df [ 'duplicate' ] , 'biocyc' ] = False del df [ 'duplicate' ] return df
Tabulate which MIRIAM databases the component's identifier matches.

    Parameters
    ----------
    model : cobra.Model
        A cobrapy metabolic model.
    components : {"metabolites", "reactions", "genes"}
        A string denoting `cobra.Model` components.

    Returns
    -------
    pandas.DataFrame
        The index of the table is given by the component identifiers. Each
        column corresponds to one MIRIAM database and a Boolean entry
        determines whether the annotation matches.