mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* atropisomer handling added * fixed non-used variables, linking directives * BOOST LIB start/stop fixes, linking fix * Fixes for RDKIT CI errors * minimalLib fix * changed vector<enum> for java builds * check for extra chars in CIP labeling * removed wrong deprecated message * fix ostrstream output error? * restored _ChiralAtomRank to lowercase first letter * changes for merged master * Fixed catch label for new Catch package * update expected psql results * get swig wrappers building * restore MolFileStereochem to FileParsers * fix java wrapper for reapplyMolBlockWedging * some suggestions * move a couple functions out of Bond * Merge branch 'master' into pr/atropisomers2 * merged master * Renamed setStereoanyFromSquiggleBond * atropisomers in cdxml, rationalize atrop wedging, stereoGroups in drawMol * fix for CI build * attempt to fix java build in CI * attempt to fix java build in CI #2 * New routine to remove non-explicit 3D-geneated chirality * changed to use pair for atrop atoms and related bonds * Changes as per PR reviews * PR review respnses * PR review reponse - more * Fix merge from master * fixing java ci after merge * Updated the help doc for atripisomers * update the atropisomer docs * improve the images * add the source CXSMILES --------- Co-authored-by: greg landrum <greg.landrum@gmail.com>
98 lines
3.5 KiB
C++
98 lines
3.5 KiB
C++
//
|
|
// Copyright (C) 2018 Dan Nealschneider
|
|
//
|
|
// @@ 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.
|
|
//
|
|
|
|
#define NO_IMPORT_ARRAY
|
|
#include <boost/python.hpp>
|
|
#include <string>
|
|
|
|
// ours
|
|
#include <RDBoost/Wrap.h>
|
|
#include <GraphMol/RDKitBase.h>
|
|
#include <GraphMol/StereoGroup.h>
|
|
|
|
namespace python = boost::python;
|
|
|
|
namespace RDKit {
|
|
|
|
namespace {
|
|
std::string stereoGroupClassDoc =
|
|
"A collection of atoms with a defined stereochemical relationship.\n\n"
|
|
"Used to help represent a sample with unknown stereochemistry, or that "
|
|
"is a mix\nof diastereomers.\n";
|
|
|
|
StereoGroup *createStereoGroup(StereoGroupType typ, ROMol &mol,
|
|
python::object atomIds, unsigned readId) {
|
|
std::vector<Atom *> cppAtoms;
|
|
std::vector<Bond *> cppBonds;
|
|
python::stl_input_iterator<unsigned int> beg(atomIds), end;
|
|
while (beg != end) {
|
|
unsigned int v = *beg;
|
|
if (v >= mol.getNumAtoms()) {
|
|
throw_value_error("atom index exceeds mol.GetNumAtoms()");
|
|
}
|
|
cppAtoms.push_back(mol.getAtomWithIdx(v));
|
|
++beg;
|
|
}
|
|
auto *sg = new StereoGroup(typ, cppAtoms, cppBonds, readId);
|
|
return sg;
|
|
}
|
|
|
|
python::object getAtomsHelper(StereoGroup &sg) {
|
|
python::list res;
|
|
for (auto at : sg.getAtoms()) {
|
|
res.append(boost::ref(*at));
|
|
}
|
|
return python::tuple(res);
|
|
}
|
|
} // namespace
|
|
|
|
struct stereogroup_wrap {
|
|
static void wrap() {
|
|
python::enum_<RDKit::StereoGroupType>("StereoGroupType")
|
|
.value("STEREO_ABSOLUTE", RDKit::StereoGroupType::STEREO_ABSOLUTE)
|
|
.value("STEREO_OR", RDKit::StereoGroupType::STEREO_OR)
|
|
.value("STEREO_AND", RDKit::StereoGroupType::STEREO_AND)
|
|
.export_values();
|
|
|
|
python::class_<StereoGroup, boost::shared_ptr<StereoGroup>>(
|
|
"StereoGroup", stereoGroupClassDoc.c_str(), python::no_init)
|
|
.def("GetGroupType", &StereoGroup::getGroupType, python::args("self"),
|
|
"Returns the StereoGroupType.\n")
|
|
.def("GetAtoms", getAtomsHelper, python::args("self"),
|
|
"access the atoms in the StereoGroup.\n")
|
|
.def("GetReadId", &StereoGroup::getReadId, python::args("self"),
|
|
"return the StereoGroup's original ID.\n"
|
|
"Note that the ID only makes sense for AND/OR groups.\n")
|
|
.def("GetWriteId", &StereoGroup::getWriteId, python::args("self"),
|
|
"return the StereoGroup's ID that will be exported.\n"
|
|
"Note that the ID only makes sense for AND/OR groups.\n")
|
|
.def("SetWriteId", &StereoGroup::setWriteId, python::args("self", "id"),
|
|
"return the StereoGroup's ID that will be exported.\n"
|
|
"Note that the ID only makes sense for AND/OR groups.\n");
|
|
|
|
python::def("CreateStereoGroup", &createStereoGroup,
|
|
"creates a StereoGroup associated with a molecule from a list "
|
|
"of atom Ids",
|
|
(python::arg("stereoGroupType"), python::arg("mol"),
|
|
python::arg("atomIds"), python::arg("readId") = 0),
|
|
python::return_value_policy<
|
|
python::manage_new_object,
|
|
python::with_custodian_and_ward_postcall<0, 2>>());
|
|
|
|
python::def(
|
|
"ForwardStereoGroupIds", &RDKit::forwardStereoGroupIds,
|
|
python::args("mol"),
|
|
"Forward the original Stereo Group IDs when exporting the Mol.");
|
|
}
|
|
};
|
|
} // namespace RDKit
|
|
|
|
void wrap_stereogroup() { RDKit::stereogroup_wrap::wrap(); }
|