def generate_fingerprint(smiles): if smiles: compound = Compound(compound_string=smiles, identifier_type='smiles', suppress_hydrogens=True) fingerprint = compound.get_bitmap_fingerprint() fp = {x for x in str(fingerprint)[1:-1].split(', ')} return list(fp) else: return []
def generate_fingerprint(smiles, compound_id, main_label, qid): if smiles: compound = Compound(compound_string=smiles, identifier_type='smiles', suppress_hydrogens=True) fingerprint = compound.get_bitmap_fingerprint() fp = {x for x in str(fingerprint)[1:-1].split(', ')} # if only compound id is set as a label, try to set something more useful if compound_id in compound_id_fp_map: sim_item = compound_id_fp_map[compound_id] if sim_item[1] == compound_id: sim_item[1] = main_label else: compound_id_fp_map.update( {compound_id: (compound_id, main_label, qid, fp)}) return list(fp) else: return []