def substruct_mult_fm(mol, i, query_mol, j, filter_dict): match = mol.GetSubstructMatch(query_mol) if match: if mol.GetNumHeavyAtoms() == len(match): filt_mol = utils.filter_res(mol, filter_dict) if filt_mol: return (i, j, list(match))
def substruct_mult_fm_nost(mol, i, query_mol, j, filter_dict): match = mol.GetSubstructMatch(query_mol) if match: frags = Chem.GetMolFrags(mol, asMols=True) frag_max = max(frags, key=lambda m: m.GetNumAtoms()) if frag_max.GetNumHeavyAtoms() == len(match): filt_mol = utils.filter_res(mol, filter_dict) if filt_mol: return (i, j, list(match))
def sim_tver(mols, query, key, fp_key, cutoff, similarity, filter_dict, name, tva, tvb, mode): results = {} counter = 0 simis = [] if mode == "all_tauts": for j in query: for i in mols: int_simis = [] filt_mol = utils.filter_res(mols[i][key], filter_dict) if filt_mol: for k in range(len(query[j]["tauts"])): sim = sim_dict[similarity](mols[i][fp_key], query[j][f"fp{k}"]) if sim >= cutoff: int_simis.append(sim) if int_simis: simis.append((max(int_simis), i, j)) else: for j in query: for i in mols: sim = sim_dict[similarity](mols[i][fp_key], query[j]["fp"], tva, tvb) if sim >= cutoff: filt_mol = utils.filter_res(mols[i][key], filter_dict) if filt_mol: simis.append((sim, i, j)) grouped_simis = [ sorted(list(group), reverse=True) for k, group in groupby( sorted(simis, key=lambda entry: entry[2]), lambda x: x[2]) ] for entry in grouped_simis: for element in entry: props = copy.deepcopy(mols[element[1]]["props"]) props["QuerySmiles"] = query[element[2]]["pattern"] props["Fingerprint"] = name props[sim_dict_name[similarity]] = round(element[0], 5) results[counter] = { "mol": mols[element[1]][key], "props": props, "q_num": element[2] } counter += 1 return results
def sss(query, mols, key, filter_dict, results): counter = 0 for j in query: for i in mols: mol = mols[i][key] match = mol.GetSubstructMatches(query[j]["mol"]) if match: filt_mol = utils.filter_res(mol, filter_dict) if filt_mol: props = copy.deepcopy(mols[i]["props"]) props["QuerySmiles"] = query[j]["pattern"] results[counter] = { "mol": mol, "props": props, "match": list(match), "q_num": j, "num": i } counter += 1
def sss_fm_taut(query, mols, key, filter_dict, results): counter = 0 for i in mols: mol = mols[i][key] for j in query: for taut in query[j]["tauts"]: match = mol.GetSubstructMatch(taut) if match: if mol.GetNumHeavyAtoms() == len(match): filt_mol = utils.filter_res(mol, filter_dict) if filt_mol: props = copy.deepcopy(mols[i]["props"]) props["QuerySmiles"] = query[j]["pattern"] results[counter] = { "mol": mol, "props": props, "match": list(match), "q_num": j, "num": i } counter += 1 break
def sss_fm_nost(query, mols, key, filter_dict, results): counter = 0 for i in mols: mol = mols[i][key] for j in query: match = mol.GetSubstructMatch(query[j]["mol"]) if match: frags = Chem.GetMolFrags(mol, asMols=True) frag_max = max(frags, key=lambda m: m.GetNumAtoms()) if frag_max.GetNumHeavyAtoms() == len(match): filt_mol = utils.filter_res(mol, filter_dict) if filt_mol: props = copy.deepcopy(mols[i]["props"]) props["QuerySmiles"] = query[j]["pattern"] results[counter] = { "mol": mol, "props": props, "match": list(match), "q_num": j, "num": i } counter += 1
def substruct_mult(mol, i, query_mol, j, filter_dict): match = mol.GetSubstructMatches(query_mol) if match: filt_mol = utils.filter_res(mol, filter_dict) if filt_mol: return (i, j, list(match))