// // Copyright (C) 2018 Susan H. Leung // // @@ All Rights Reserved @@ // This file is part of the RDKit. // The contents are covered by the terms of the BSD license // which is included in the file license.txt, found at the root // of the RDKit source tree. // #include #include #include namespace python = boost::python; using namespace RDKit; namespace { std::vector defaultChargeCorrections() { return MolStandardize::CHARGE_CORRECTIONS; } ROMol *reionizeHelper(MolStandardize::Reionizer &self, const ROMol &mol) { return self.reionize(mol); } MolStandardize::Reionizer *reionizerFromData(const std::string &data, python::object chargeCorrections) { std::istringstream sstr(data); auto corrections = pythonObjectToVect(chargeCorrections); MolStandardize::Reionizer *res; if (corrections) { res = new MolStandardize::Reionizer(sstr, *corrections); } else { res = new MolStandardize::Reionizer( sstr, std::vector()); } return res; } } // namespace struct charge_wrapper { static void wrap() { python::scope().attr("__doc__") = "Module containing functions for charge corrections"; std::string docString = ""; python::class_( "ChargeCorrection", python::init()) .def_readwrite("Name", &MolStandardize::ChargeCorrection::Name) .def_readwrite("Smarts", &MolStandardize::ChargeCorrection::Smarts) .def_readwrite("Charge", &MolStandardize::ChargeCorrection::Charge); python::def("CHARGE_CORRECTIONS", defaultChargeCorrections); python::class_( "Reionizer", python::init<>()) .def(python::init()) .def(python::init>()) .def("reionize", &reionizeHelper, (python::arg("self"), python::arg("mol")), "", python::return_value_policy()); python::def("ReionizerFromData", &reionizerFromData, (python::arg("paramData"), python::arg("chargeCorrections") = python::list()), "creates a reionizer from a string containing parameter data " "and a list of charge corrections", python::return_value_policy()); python::class_( "Uncharger", python::init((python::arg("self"), python::arg("canonicalOrder") = true))) .def("uncharge", &MolStandardize::Uncharger::uncharge, (python::arg("self"), python::arg("mol")), "", python::return_value_policy()); } }; void wrap_charge() { charge_wrapper::wrap(); }