#pragma cling add_library_path("/opt/conda/lib") #pragma cling add_include_path("/opt/conda/include/rdkit") #include #include #pragma cling load("libRDKitSmilesParse.so") #pragma cling load("libRDKitGraphMol.so") std::string methotrexate_smi = "CN(Cc1cnc2nc(N)nc(N)c2n1)c1ccc(C(=O)N[C@@H](CCC(=O)O)C(=O)O)cc1"; std::unique_ptr methotrexate(RDKit::SmilesToMol(methotrexate_smi)); std::cout << methotrexate->getNumAtoms() << " atoms" << std::endl; #include #pragma cling load("libRDKitDescriptors.so") double logp = RDKit::Descriptors::calcClogP(*methotrexate); std::cout << "logP: " << logp << std::endl; double e_mwt = RDKit::Descriptors::calcExactMW(*methotrexate); std::cout << "molecular weight: " << e_mwt << std::endl; #include #pragma cling load("libRDKitInchi.so") #pragma cling load("libRDKitRDInchiLib.so") RDKit::ExtraInchiReturnValues tmp; std::string inchi = RDKit::MolToInchi(*methotrexate, tmp); std::cout << "InChI: " << inchi << std::endl; std::string key = RDKit::InchiToInchiKey(inchi); std::cout << "InChIKey: " << key << std::endl; #include #include #include #include #include "nlohmann/json.hpp" #pragma cling load("libRDKitMolDraw2D.so") #pragma cling load("libRDKitDepictor.so") namespace ht { struct html { inline html(const std::string& content) { m_content = content; } std::string m_content; }; nl::json mime_bundle_repr(const html& a) { auto bundle = nl::json::object(); bundle["text/html"] = a.m_content; return bundle; } } // generate the 2D coordinates: RDDepict::compute2DCoords(*methotrexate); // // generate SVG as string RDKit::MolDraw2DSVG drawer(400, 400); drawer.drawMolecule(*methotrexate); drawer.finishDrawing(); std::string svgs = drawer.getDrawingText(); // show the molecule ht::html mol_svg(svgs); mol_svg #include #include #include #include #pragma cling load("libRDKitFingerprints.so") #pragma cling load("libRDKitDataStructs.so") std::string aspirin_smi = "CC(=O)Oc1ccccc1C(=O)O"; std::string paracetamol_smi = "CC(=O)Nc1ccc(O)cc1"; std::unique_ptr aspirin(RDKit::SmilesToMol(aspirin_smi)); std::unique_ptr paracetamol(RDKit::SmilesToMol(paracetamol_smi)); // unhashed fps RDKit::SparseIntVect *fp_aspirin, *fp_paracetamol; fp_aspirin = RDKit::MorganFingerprints::getFingerprint(*aspirin, 2); fp_paracetamol = RDKit::MorganFingerprints::getFingerprint(*paracetamol, 2); double tani = TanimotoSimilarity(*fp_aspirin, *fp_paracetamol); std::cout << "Similarity between aspirin and paracetamol: " << tani << std::endl; #include #pragma cling load("libRDKitSubstructMatch.so") std::unique_ptr mol_ss(RDKit::SmilesToMol("CC[C@H](F)Cl")); std::unique_ptr patt(RDKit::SmartsToMol("C[C@H](F)Cl")); RDKit::MatchVectType res; if( RDKit::SubstructMatch(*mol_ss , *patt , res) ) { std::cout << "SMARTS 1 match" << std::endl; } else { std::cout << "Not SMARTS 1 match" << std::endl; } res #include "GraphMol/FMCS/FMCS.h" #pragma cling load("libRDKitFMCS.so") std::vector mols; const std::string smi[] = { aspirin_smi, paracetamol_smi, methotrexate_smi }; for (auto& i : smi) { mols.emplace_back(RDKit::SmilesToMol(i)); } RDKit::MCSResult res = RDKit::findMCS(mols); res.SmartsString #include "GraphMol/MolHash/MolHash.h" #pragma cling load("libRDKitMolHash.so") std::unique_ptr murcko_mol(RDKit::SmilesToMol(methotrexate_smi)); auto scaffold = RDKit::MolHash::MolHash(murcko_mol.get(), RDKit::MolHash::HashFunction::MurckoScaffold); std::cout << scaffold << std::endl; std::unique_ptr extended_murcko_mol(RDKit::SmilesToMol(methotrexate_smi)); auto extended_murcko = RDKit::MolHash::MolHash(extended_murcko_mol.get(), RDKit::MolHash::HashFunction::ExtendedMurcko); std::cout << extended_murcko << std::endl;