Hi RDKit gurus.
I noted that compound 4 in the sdf, a poorly represented aryl system fails with this error. Any ideas on how to try/catch this error, or skip the molecule with an error, as the script dies painfully when it gets this far. Snippet enclosed of the python call. Best - and thanks, mike def calc_SDF(file_name_list): print("") print("SDF Chunking Completed") print("") calc_values = [] calc_values.append(str("ORIG_SMI SMILES InChi HAC HBD HBA molWt nRotB nAr TPSA nChr")) for j in range(len(file_name_list)): assert os.path.isfile(file_name_list[j]), "File %s does not exist!" % file_name_list[j] mols = file_name_list[j] suppl = Chem.SDMolSupplier(mols) lensuppl = len(suppl) remover = SaltRemover() for i in range(lensuppl): if suppl[i] is None: with open('.//test_out.csv', 'w', newline='') as csvfile: output = csv.writer(csvfile, delimiter=',', quoting = csv.QUOTE_ALL) output.writerow(['Compound: ', i, ' failed.']) else: orig = Chem.MolToSmiles(suppl[i]) Chem.rdmolops.SanitizeMol(suppl[i],268435455) y = Chem.MolToSmiles(remover.StripMol(suppl[i])) HAC = Chem.Lipinski.HeavyAtomCount(Chem.MolFromSmiles(y)) HBD = Chem.Lipinski.NumHDonors(Chem.MolFromSmiles(y)) HBA = Chem.Lipinski.NumHAcceptors(Chem.MolFromSmiles(y)) molwt = Chem.Descriptors.MolWt(Chem.MolFromSmiles(y)) nRotB = Chem.Lipinski.NumRotatableBonds(Chem.MolFromSmiles(y)) nAr = Chem.Lipinski.NumAromaticRings(Chem.MolFromSmiles(y)) InChi = Chem.MolToInchi(Chem.MolFromSmiles(y)) TPSA = Chem.Descriptors.TPSA(Chem.MolFromSmiles(y)) nChr = len(Chem.FindMolChiralCenters(Chem.MolFromSmiles(y),includeUnassigned=True)) calc_values.append(str('{} {} {} {} {} {} {:.2f} {} {} {:.0f} {}'.format(orig, y, InChi, HAC, HBD, HBA, molwt, nRotB, nAr, TPSA, nChr))) print(j, i) now = datetime.datetime.now() print("") print("Job ended at", now.strftime("%H:%M"), "on", now.strftime("%Y-%m-%d")) log.close() sys.stderr = save_std_err return calc_values
enamine_fail.sdf
Description: Binary data
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss