Esempio n. 1
0
def test_chebi_mass():
    ch = ChEBI()
    mass1 = ch.getCompleteEntity("CHEBI:27732").mass
    assert float(mass1) == 194.19076

    res = ch.getLiteEntity("194.19076", "MASS", 5, 2)
    assert  res[0]["chebiId"] == "CHEBI:27732"

    # should return nothing
    res = ch.getLiteEntity("194.19076", "SMILES", 5, 2)
Esempio n. 2
0
def test_chebi_mass():
    ch = ChEBI()
    mass1 = ch.getCompleteEntity("CHEBI:27732").mass
    assert float(mass1) == 194.19076

    res = ch.getLiteEntity("194.19076", "MASS", 5, 2)
    assert res[0]["chebiId"] == "CHEBI:27732"

    # should return nothing
    res = ch.getLiteEntity("194.19076", "SMILES", 5, 2)
Esempio n. 3
0
    def chebi2name(self, name):
        """Return the ASCII name of a CHEBI identifier"""
        from bioservices import ChEBI

        c = ChEBI()
        name = dict(c.getLiteEntity(name)[0])["chebiAsciiName"]
        return name
Esempio n. 4
0
def kegg_to_chebi(compound_ids):
    results = {}
    ch = ChEBI()
    for compound_id in compound_ids:
        try:
            if compound_id.startswith('C'):
                res = ch.getLiteEntity(compound_id)
                assert len(res) > 0 # we should always be able to convert from KEGG -> ChEBI ids
                le = res[0]
                chebi_number = le.chebiId.split(':')[1]
                print('KEGG %s --> ChEBI %s' % (compound_id, chebi_number))
                results[compound_id] = chebi_number
            else:
                print('ChEBI %s --> ChEBI %s' % (compound_id, compound_id))
                results[compound_id] = compound_id
        except Exception:
            print('KEGG %s --> KEGG %s' % (compound_id, compound_id))
            results[compound_id] = compound_id
    return results
Esempio n. 5
0
 def chebi2name(self, name):
     """Return the ASCII name of a CHEBI identifier"""
     from bioservices import ChEBI
     c = ChEBI()
     name = dict(c.getLiteEntity(name)[0])['chebiAsciiName']
     return name