Exemple #1
0
    def __add_xref(self, xref, entry, chemical):
        '''Adds an xref.'''
        namespace = namespace_utils.resolve_namespace(xref[0], chemical)

        if namespace is not None:
            xref[1] = self.__parse_id(xref[1])

            entry[namespace] = xref[1] \
                if namespace != 'chebi' \
                else 'CHEBI:' + xref[1]
    def __add_xref(self, xref, entry, chemical):
        '''Adds an xref.'''
        namespace = namespace_utils.resolve_namespace(xref[0],
                                                      chemical)

        if namespace is not None:
            xref[1] = self.__parse_id(xref[1])

            entry[namespace] = xref[1] \
                if namespace is not 'chebi' \
                else 'CHEBI:' + xref[1]
def _get_chebi_data(chebi_id, properties):
    '''Gets ChEBI data.'''
    chebi_ent = ChebiEntity(str(chebi_id))

    if chebi_ent.get_parent_id():
        chebi_id = chebi_ent.get_parent_id()
    else:
        chebi_id = chebi_ent.get_id()

    properties['chebi'] = chebi_id

    formula = chebi_ent.get_formula()
    charge = chebi_ent.get_charge()
    inchi = chebi_ent.get_inchi()
    smiles = chebi_ent.get_smiles()

    if formula:
        properties['formula'] = formula

    if not math.isnan(charge):
        properties['charge'] = charge

    if inchi:
        properties['inchi'] = inchi

    if smiles:
        properties['smiles'] = smiles

    properties['name'] = chebi_ent.get_name()
    properties['names:string[]'] = \
        [name.get_name() for name in chebi_ent.get_names()] + \
        [chebi_ent.get_name()]

    for db_acc in chebi_ent.get_database_accessions():
        namespace = ns_utils.resolve_namespace(
            db_acc.get_type(), True)

        if namespace is not None:
            properties[namespace] = db_acc.get_accession_number()

    return chebi_id, chebi_ent
Exemple #4
0
def _get_chebi_data(chebi_id, properties, array_delimiter):
    '''Gets ChEBI data.'''
    chebi_ent = ChebiEntity(str(chebi_id))

    if chebi_ent.get_parent_id():
        chebi_id = chebi_ent.get_parent_id()
    else:
        chebi_id = chebi_ent.get_id()

    properties['chebi'] = chebi_id

    formula = chebi_ent.get_formula()
    charge = chebi_ent.get_charge()
    inchi = chebi_ent.get_inchi()
    smiles = chebi_ent.get_smiles()

    if formula:
        properties['formula'] = formula

    if not math.isnan(charge):
        properties['charge:float'] = charge

    if inchi:
        properties['inchi'] = inchi

    if smiles:
        properties['smiles'] = smiles

    properties['name'] = chebi_ent.get_name()
    properties['names:string[]'] = \
        array_delimiter.join([name.get_name()
                              for name in chebi_ent.get_names()] +
                             [chebi_ent.get_name()])

    for db_acc in chebi_ent.get_database_accessions():
        namespace = ns_utils.resolve_namespace(db_acc.get_type(), True)

        if namespace is not None:
            properties[namespace] = db_acc.get_accession_number()

    return chebi_id, chebi_ent