- add describeQuery() method to atoms (this is primarily for debugging)

- add SetConjugation() and SetHybridization() methods for molecules.
This commit is contained in:
Greg Landrum
2010-06-23 04:14:25 +00:00
parent a5e0546ccf
commit 7065810cfd
2 changed files with 41 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
// $Id$
//
// Copyright (C) 2003-2009 Greg Landrum and Rational Discovery LLC
// Copyright (C) 2003-2010 Greg Landrum and Rational Discovery LLC
//
// @@ All Rights Reserved @@
//
@@ -22,6 +22,27 @@
namespace python = boost::python;
namespace RDKit{
namespace {
std::string qhelper(Atom::QUERYATOM_QUERY *q,int depth){
std::string res="";
if(q){
for (unsigned int i=0;i<depth;++i) res+=" ";
res += q->getDescription()+"\n";
for(Atom::QUERYATOM_QUERY::CHILD_VECT_CI ci=q->beginChildren();
ci!=q->endChildren();++ci){
res += qhelper((*ci).get(),depth+1);
}
}
return res;
}
} // end of local namespace
std::string describeQuery(const Atom*atom){
std::string res="";
if(atom->hasQuery()){
res=qhelper(atom->getQuery(),0);
}
return res;
}
void AtomSetProp(const Atom *atom, const char *key,std::string val) {
//std::cerr<<"asp: "<<atom<<" " << key<<" - " << val << std::endl;
@@ -208,6 +229,9 @@ struct atom_wrapper {
.def("HasQuery",&Atom::hasQuery,
"Returns whether or not the atom has an associated query\n\n")
.def("DescribeQuery",describeQuery,
"returns a text description of the query. Primarily intended for debugging purposes.\n\n")
.def("GetSmarts",AtomGetSmarts,
"returns the SMARTS (or SMILES) string for an Atom\n\n")

View File

@@ -103,12 +103,21 @@ namespace RDKit{
MolOps::setAromaticity(wmol);
}
void setConjugationMol(ROMol &mol) {
RWMol &wmol = static_cast<RWMol &>(mol);
MolOps::setConjugation(wmol);
}
void setHybridizationMol(ROMol &mol) {
RWMol &wmol = static_cast<RWMol &>(mol);
MolOps::setHybridization(wmol);
}
VECT_INT_VECT getSymmSSSR(ROMol &mol) {
VECT_INT_VECT rings;
MolOps::symmetrizeSSSR(mol, rings);
return rings;
}
PyObject *getDistanceMatrix(ROMol &mol, bool useBO=false,
bool useAtomWts=false,bool force=false,
const char *prefix=0) {
@@ -489,6 +498,12 @@ namespace RDKit{
python::def("SetAromaticity", setAromaticityMol,
(python::arg("mol")),
docString.c_str());
python::def("SetConjugation", setConjugationMol,
(python::arg("mol")),
docString.c_str());
python::def("SetHybridization", setHybridizationMol,
(python::arg("mol")),
docString.c_str());