Beispiel #1
0
def add_to_all_mapping(dataframe, mapping):
    for other_id, mnx_id in dataframe[['XREF', 'MNX_ID']].values:
        cleaned_key = _apply_sanitize_rules(
            _apply_sanitize_rules(other_id,
                                  REVERSE_ID_SANITIZE_RULES_SIMPHENY),
            ID_SANITIZE_RULES_TAB_COMPLETION)
        mapping[cleaned_key] = mnx_id
Beispiel #2
0
def add_to_bigg_mapping(xref, bigg2mnx, mnx2bigg):
    bigg_selection = xref[['bigg' in blub for blub in xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(_apply_sanitize_rules(id, REVERSE_ID_SANITIZE_RULES_SIMPHENY),
                              ID_SANITIZE_RULES_TAB_COMPLETION) for id in bigg_selection.XREF]
    bigg2mnx.update(dict(zip(sanitized_XREF, bigg_selection.MNX_ID)))
    mnx2bigg.update(dict(zip(bigg_selection.MNX_ID, sanitized_XREF)))
Beispiel #3
0
def add_to_bigg_mapping(xref, bigg2mnx, mnx2bigg):
    bigg_selection = xref[['bigg' in blub for blub in xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(_apply_sanitize_rules(id, REVERSE_ID_SANITIZE_RULES_SIMPHENY),
                              ID_SANITIZE_RULES_TAB_COMPLETION) for id in bigg_selection.XREF]
    bigg2mnx.update(dict(zip(sanitized_XREF, bigg_selection.MNX_ID)))
    mnx2bigg.update(dict(zip(bigg_selection.MNX_ID, sanitized_XREF)))
Beispiel #4
0
    reac_xref.columns = [name.replace('#', '') for name in reac_xref.columns]
    reac_prop = read_table('../data/metanetx/reac_prop.tsv.gz', skiprows=107, compression='gzip', index_col=0)
    reac_prop.columns = [name.replace('#', '') for name in reac_prop.columns]
    chem_prop = read_table('../data/metanetx/chem_prop.tsv.gz', skiprows=125, compression='gzip', index_col=0,
                           names=['name', 'formula', 'charge', 'mass', 'InChI', 'SMILES', 'source'])

    # replace NaN with None
    chem_prop = chem_prop.where((notnull(chem_prop)), "")

    REVERSE_ID_SANITIZE_RULES_SIMPHENY = [(value, key) for key, value in ID_SANITIZE_RULES_SIMPHENY]

    metanetx = dict()
    # Metabolites
    bigg_selection = chem_xref[['bigg' in blub for blub in chem_xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(_apply_sanitize_rules(id.replace('bigg:', ''), REVERSE_ID_SANITIZE_RULES_SIMPHENY),
                              ID_SANITIZE_RULES_TAB_COMPLETION) for id in bigg_selection.XREF]
    bigg2mnx = dict(zip(sanitized_XREF, bigg_selection.MNX_ID))
    mnx2bigg = dict(zip(bigg_selection.MNX_ID, sanitized_XREF))

    # Reactions
    bigg_selection = reac_xref[['bigg' in blub for blub in reac_xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(_apply_sanitize_rules(id.replace('bigg:', ''), REVERSE_ID_SANITIZE_RULES_SIMPHENY),
                              ID_SANITIZE_RULES_TAB_COMPLETION) for id in bigg_selection.XREF]
    bigg2mnx.update(dict(zip(sanitized_XREF, bigg_selection.MNX_ID)))
    mnx2bigg.update(dict(zip(bigg_selection.MNX_ID, sanitized_XREF)))

    # put into final result dict
    metanetx['bigg2mnx'] = bigg2mnx
    metanetx['mnx2bigg'] = mnx2bigg
Beispiel #5
0
    reac_xref.columns = [name.replace('#', '') for name in reac_xref.columns]
    reac_prop = read_table('../data/metanetx/reac_prop.tsv.gz', skiprows=107, compression='gzip', index_col=0)
    reac_prop.columns = [name.replace('#', '') for name in reac_prop.columns]
    chem_prop = read_table('../data/metanetx/chem_prop.tsv.gz', skiprows=125, compression='gzip', index_col=0,
                           names=['name', 'formula', 'charge', 'mass', 'InChI', 'SMILES', 'source'])

    # replace NaN with None
    chem_prop = chem_prop.where((notnull(chem_prop)), None)

    REVERSE_ID_SANITIZE_RULES_SIMPHENY = [(value, key) for key, value in ID_SANITIZE_RULES_SIMPHENY]

    metanetx = dict()
    # Metabolites
    bigg_selection = chem_xref[['bigg' in blub for blub in chem_xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(_apply_sanitize_rules(id.replace('bigg:', ''), REVERSE_ID_SANITIZE_RULES_SIMPHENY),
                              ID_SANITIZE_RULES_TAB_COMPLETION) for id in bigg_selection.XREF]
    bigg2mnx = dict(zip(sanitized_XREF, bigg_selection.MNX_ID))
    mnx2bigg = dict(zip(bigg_selection.MNX_ID, sanitized_XREF))

    # Reactions
    bigg_selection = reac_xref[['bigg' in blub for blub in reac_xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(_apply_sanitize_rules(id.replace('bigg:', ''), REVERSE_ID_SANITIZE_RULES_SIMPHENY),
                              ID_SANITIZE_RULES_TAB_COMPLETION) for id in bigg_selection.XREF]
    bigg2mnx.update(dict(zip(sanitized_XREF, bigg_selection.MNX_ID)))
    mnx2bigg.update(dict(zip(bigg_selection.MNX_ID, sanitized_XREF)))

    # put into final result dict
    metanetx['bigg2mnx'] = bigg2mnx
    metanetx['mnx2bigg'] = mnx2bigg
Beispiel #6
0
def add_to_all_mapping(dataframe, mapping):
    for other_id, mnx_id in dataframe[['XREF', 'MNX_ID']].values:
        cleaned_key = _apply_sanitize_rules(
            _apply_sanitize_rules(other_id, REVERSE_ID_SANITIZE_RULES_SIMPHENY),
            ID_SANITIZE_RULES_TAB_COMPLETION)
        mapping[cleaned_key] = mnx_id
Beispiel #7
0
        compression="gzip",
        index_col=0,
        names=["name", "formula", "charge", "mass", "InChI", "SMILES", "source"],
    )

    # replace NaN with None
    chem_prop = chem_prop.where((notnull(chem_prop)), None)

    REVERSE_ID_SANITIZE_RULES_SIMPHENY = [(value, key) for key, value in ID_SANITIZE_RULES_SIMPHENY]

    metanetx = dict()
    # Metabolites
    bigg_selection = chem_xref[["bigg" in blub for blub in chem_xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(
            _apply_sanitize_rules(id.replace("bigg:", ""), REVERSE_ID_SANITIZE_RULES_SIMPHENY),
            ID_SANITIZE_RULES_TAB_COMPLETION,
        )
        for id in bigg_selection.XREF
    ]
    bigg2mnx = dict(zip(sanitized_XREF, bigg_selection.MNX_ID))
    mnx2bigg = dict(zip(bigg_selection.MNX_ID, sanitized_XREF))

    # Reactions
    bigg_selection = reac_xref[["bigg" in blub for blub in reac_xref.XREF]]
    sanitized_XREF = [
        _apply_sanitize_rules(
            _apply_sanitize_rules(id.replace("bigg:", ""), REVERSE_ID_SANITIZE_RULES_SIMPHENY),
            ID_SANITIZE_RULES_TAB_COMPLETION,
        )
        for id in bigg_selection.XREF
    ]