mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
another batch of warnings squashed
This commit is contained in:
@@ -240,14 +240,14 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
std::streampos rdkCurrent;
|
||||
std::streampos refPos;
|
||||
std::streampos refCurrent;
|
||||
int i = 1;
|
||||
int iarg = 1;
|
||||
unsigned int n = 0;
|
||||
bool error = false;
|
||||
bool fullTest = false;
|
||||
int inc = 4;
|
||||
bool testFailure = false;
|
||||
while (i < argc) {
|
||||
arg = argv[i];
|
||||
while (iarg < argc) {
|
||||
arg = argv[iarg];
|
||||
error = (arg.at(0) != '-');
|
||||
if (error) {
|
||||
break;
|
||||
@@ -256,34 +256,34 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
if (error) {
|
||||
break;
|
||||
} else if (arg == "-f") {
|
||||
error = ((i + 1) >= argc);
|
||||
error = ((iarg + 1) >= argc);
|
||||
if (error) {
|
||||
break;
|
||||
}
|
||||
ffVariant = argv[i + 1];
|
||||
ffVariant = argv[iarg + 1];
|
||||
error = ((ffVariant != "MMFF94") && (ffVariant != "MMFF94s"));
|
||||
if (error) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
++iarg;
|
||||
} else if ((arg == "-sdf") || (arg == "-smi")) {
|
||||
molType = arg.substr(1);
|
||||
if ((i + 1) < argc) {
|
||||
molFile = argv[i + 1];
|
||||
++i;
|
||||
if ((iarg + 1) < argc) {
|
||||
molFile = argv[iarg + 1];
|
||||
++iarg;
|
||||
}
|
||||
} else if (arg == "-L") {
|
||||
fullTest = true;
|
||||
inc = 1;
|
||||
} else if (arg == "-l") {
|
||||
error = ((i + 1) >= argc);
|
||||
error = ((iarg + 1) >= argc);
|
||||
if (error) {
|
||||
break;
|
||||
}
|
||||
rdk = argv[i + 1];
|
||||
++i;
|
||||
rdk = argv[iarg + 1];
|
||||
++iarg;
|
||||
}
|
||||
++i;
|
||||
++iarg;
|
||||
}
|
||||
if (error) {
|
||||
std::cerr << "Usage: testMMFFForceField [-L] [-f {MMFF94|MMFF94s}] "
|
||||
@@ -340,14 +340,14 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
molVec.clear();
|
||||
if (*molTypeIt == "sdf") {
|
||||
SDMolSupplier sdfSupplier(*molFileIt, false, false);
|
||||
for (size_t i = 0; i < sdfSupplier.length(); ++i) {
|
||||
molVec.push_back(sdfSupplier[i]);
|
||||
for (size_t ii = 0; ii < sdfSupplier.length(); ++ii) {
|
||||
molVec.push_back(sdfSupplier[ii]);
|
||||
}
|
||||
sdfSupplier.reset();
|
||||
} else {
|
||||
SmilesMolSupplier smiSupplier(*molFileIt);
|
||||
for (size_t i = 0; i < smiSupplier.length(); ++i) {
|
||||
molVec.push_back(smiSupplier[i]);
|
||||
for (size_t ii = 0; ii < smiSupplier.length(); ++ii) {
|
||||
molVec.push_back(smiSupplier[ii]);
|
||||
}
|
||||
smiSupplier.reset();
|
||||
}
|
||||
@@ -365,21 +365,19 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
std::string computingKey = (*ffIt) + " energies for " + (*molFileIt);
|
||||
std::cerr << std::endl
|
||||
<< "Computing " << computingKey << "..." << std::endl;
|
||||
for (size_t i = 0; i < computingKey.length(); ++i) {
|
||||
for (size_t ii = 0; ii < computingKey.length(); ++ii) {
|
||||
rdkFStream << "*";
|
||||
}
|
||||
rdkFStream << std::endl
|
||||
<< computingKey << std::endl;
|
||||
for (size_t i = 0; i < computingKey.length(); ++i) {
|
||||
rdkFStream << std::endl << computingKey << std::endl;
|
||||
for (size_t ii = 0; ii < computingKey.length(); ++ii) {
|
||||
rdkFStream << "*";
|
||||
}
|
||||
rdkFStream << std::endl
|
||||
<< std::endl;
|
||||
for (size_t i = 0; i < molVec.size(); i += inc) {
|
||||
rdkFStream << std::endl << std::endl;
|
||||
for (size_t ii = 0; ii < molVec.size(); ii += inc) {
|
||||
if (*molTypeIt == "sdf") {
|
||||
mol = molVec[i];
|
||||
mol = molVec[ii];
|
||||
} else {
|
||||
mol = MolOps::addHs(*(molVec[i]));
|
||||
mol = MolOps::addHs(*(molVec[ii]));
|
||||
DGeomHelpers::EmbedMolecule(*mol);
|
||||
}
|
||||
MMFF::sanitizeMMFFMol((RWMol &)(*mol));
|
||||
@@ -433,19 +431,20 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
double refVdWEnergy;
|
||||
double refEleEnergy;
|
||||
unsigned int n_failed = 0;
|
||||
bool failed;
|
||||
bool failed = false;
|
||||
rdkFStream.seekg(0);
|
||||
fgrep(rdkFStream, computingKey);
|
||||
for (size_t i = 0; i < nameArray.size(); i += inc) {
|
||||
size_t ii;
|
||||
for (ii = 0; ii < nameArray.size(); ii += inc) {
|
||||
error = false;
|
||||
failed = false;
|
||||
errorMsg = rdk + ": Molecule not found";
|
||||
found = fgrep(rdkFStream, nameArray[i]);
|
||||
found = fgrep(rdkFStream, nameArray[ii]);
|
||||
if (!found) {
|
||||
break;
|
||||
}
|
||||
errorMsg = ref + ": Molecule not found";
|
||||
found = fgrep(refFStream, nameArray[i]);
|
||||
found = fgrep(refFStream, nameArray[ii]);
|
||||
if (!found) {
|
||||
break;
|
||||
}
|
||||
@@ -657,9 +656,10 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
failed = true;
|
||||
std::stringstream diff;
|
||||
diff << "Bond stretching: energies differ\n"
|
||||
"Expected " << std::fixed << std::setprecision(4)
|
||||
<< refEnergy << ", found " << std::fixed
|
||||
<< std::setprecision(4) << rdkEnergy << "\n";
|
||||
"Expected "
|
||||
<< std::fixed << std::setprecision(4) << refEnergy
|
||||
<< ", found " << std::fixed << std::setprecision(4)
|
||||
<< rdkEnergy << "\n";
|
||||
errorMsg += diff.str();
|
||||
}
|
||||
}
|
||||
@@ -811,9 +811,10 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
failed = true;
|
||||
std::stringstream diff;
|
||||
diff << "Angle bending: energies differ\n"
|
||||
"Expected " << std::fixed << std::setprecision(4)
|
||||
<< refEnergy << ", found " << std::fixed
|
||||
<< std::setprecision(4) << rdkEnergy << "\n";
|
||||
"Expected "
|
||||
<< std::fixed << std::setprecision(4) << refEnergy
|
||||
<< ", found " << std::fixed << std::setprecision(4)
|
||||
<< rdkEnergy << "\n";
|
||||
errorMsg += diff.str();
|
||||
}
|
||||
}
|
||||
@@ -972,9 +973,10 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
failed = true;
|
||||
std::stringstream diff;
|
||||
diff << "Stretch-bending: energies differ\n"
|
||||
"Expected " << std::fixed << std::setprecision(4)
|
||||
<< refEnergy << ", found " << std::fixed
|
||||
<< std::setprecision(4) << rdkEnergy << "\n";
|
||||
"Expected "
|
||||
<< std::fixed << std::setprecision(4) << refEnergy
|
||||
<< ", found " << std::fixed << std::setprecision(4)
|
||||
<< rdkEnergy << "\n";
|
||||
errorMsg += diff.str();
|
||||
}
|
||||
}
|
||||
@@ -1127,9 +1129,10 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
failed = true;
|
||||
std::stringstream diff;
|
||||
diff << "Out-of-plane bending: energies differ\n"
|
||||
"Expected " << std::fixed << std::setprecision(4)
|
||||
<< refEnergy << ", found " << std::fixed
|
||||
<< std::setprecision(4) << rdkEnergy << "\n";
|
||||
"Expected "
|
||||
<< std::fixed << std::setprecision(4) << refEnergy
|
||||
<< ", found " << std::fixed << std::setprecision(4)
|
||||
<< rdkEnergy << "\n";
|
||||
errorMsg += diff.str();
|
||||
}
|
||||
}
|
||||
@@ -1293,9 +1296,10 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
failed = true;
|
||||
std::stringstream diff;
|
||||
diff << "Torsional: energies differ\n"
|
||||
"Expected " << std::fixed << std::setprecision(4)
|
||||
<< refEnergy << ", found " << std::fixed
|
||||
<< std::setprecision(4) << rdkEnergy << "\n";
|
||||
"Expected "
|
||||
<< std::fixed << std::setprecision(4) << refEnergy
|
||||
<< ", found " << std::fixed << std::setprecision(4)
|
||||
<< rdkEnergy << "\n";
|
||||
errorMsg += diff.str();
|
||||
}
|
||||
}
|
||||
@@ -1354,9 +1358,10 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
failed = true;
|
||||
std::stringstream diff;
|
||||
diff << "Van der Waals: energies differ\n"
|
||||
"Expected " << std::fixed << std::setprecision(4)
|
||||
<< refVdWEnergy << ", found " << std::fixed
|
||||
<< std::setprecision(4) << rdkEnergy << "\n";
|
||||
"Expected "
|
||||
<< std::fixed << std::setprecision(4) << refVdWEnergy
|
||||
<< ", found " << std::fixed << std::setprecision(4)
|
||||
<< rdkEnergy << "\n";
|
||||
errorMsg += diff.str();
|
||||
}
|
||||
error = (fabs(rdkEleEnergy - refEleEnergy) > ENERGY_TOLERANCE);
|
||||
@@ -1364,19 +1369,20 @@ int mmffValidationSuite(int argc, char *argv[]) {
|
||||
failed = true;
|
||||
std::stringstream diff;
|
||||
diff << "Electrostatic: energies differ\n"
|
||||
"Expected " << std::fixed << std::setprecision(4)
|
||||
<< refEleEnergy << ", found " << std::fixed
|
||||
<< std::setprecision(4) << rdkEnergy << "\n";
|
||||
"Expected "
|
||||
<< std::fixed << std::setprecision(4) << refEleEnergy
|
||||
<< ", found " << std::fixed << std::setprecision(4)
|
||||
<< rdkEnergy << "\n";
|
||||
errorMsg += diff.str();
|
||||
}
|
||||
if (failed) {
|
||||
std::cerr << nameArray[i] << "\n\n" << errorMsg << std::endl;
|
||||
std::cerr << nameArray[ii] << "\n\n" << errorMsg << std::endl;
|
||||
++n_failed;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (!failed) {
|
||||
std::cerr << nameArray[i] << "\n\n";
|
||||
std::cerr << nameArray[ii] << "\n\n";
|
||||
}
|
||||
std::cerr << errorMsg << std::endl;
|
||||
} else {
|
||||
|
||||
@@ -714,7 +714,7 @@ void testUFF7() {
|
||||
ps.push_back(&p3);
|
||||
ps.push_back(&p4);
|
||||
|
||||
ForceFields::UFF::AtomicParams param1, param2;
|
||||
ForceFields::UFF::AtomicParams param1;
|
||||
// sp3 carbon:
|
||||
param1.r1 = .757;
|
||||
param1.Z1 = 1.912;
|
||||
@@ -724,11 +724,6 @@ void testUFF7() {
|
||||
param1.V1 = 2.119;
|
||||
param1.U1 = 2.0;
|
||||
|
||||
// H_1:
|
||||
param2.r1 = 0.354;
|
||||
param2.Z1 = 0.712;
|
||||
param2.GMP_Xi = 4.528;
|
||||
|
||||
RDGeom::Point3D d, v1, v2;
|
||||
double cosPhi;
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ void testTorsionPrefs() {
|
||||
TEST_ASSERT(expTorsionAngles.size() == 2);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main() {
|
||||
testTorsionAngleM6();
|
||||
testTorsionPrefs();
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ void test1() {
|
||||
strcpy(fs[8], fs1[8]);
|
||||
//-----------------------------------
|
||||
|
||||
for (int i = 0; i < sizeof(smi) / sizeof(smi[0]); i++) {
|
||||
for (unsigned int i = 0; i < sizeof(smi) / sizeof(smi[0]); i++) {
|
||||
static const std::string es("NULL");
|
||||
std::string id;
|
||||
std::string smiles = getSmilesOnly(smi[i], &id);
|
||||
@@ -376,7 +376,7 @@ void test2() {
|
||||
"Cc1c(C(=O)NCCO)[n+](=O)c2ccccc2n1[O-],ZINC21984717,O=C(NC[*:2])[*:1],"
|
||||
"Cc1c([*:1])[n+](=O)c2ccccc2n1[O-].OC[*:2]"};
|
||||
|
||||
for (int i = 0; i < sizeof(smi) / sizeof(smi[0]); i++) {
|
||||
for (unsigned int i = 0; i < sizeof(smi) / sizeof(smi[0]); i++) {
|
||||
static const std::string es("NULL");
|
||||
std::string id;
|
||||
std::string smiles = getSmilesOnly(smi[i], &id);
|
||||
@@ -664,7 +664,7 @@ std::endl;
|
||||
//====================================================================================================
|
||||
//====================================================================================================
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
int main() {
|
||||
BOOST_LOG(rdInfoLog)
|
||||
<< "*******************************************************\n";
|
||||
BOOST_LOG(rdInfoLog) << "MMPA Unit Test \n";
|
||||
|
||||
@@ -217,7 +217,7 @@ void parseAtomAttribs(Atom *atom, AttribListType attribs, bool doingQuery) {
|
||||
// a block of properties that can have "f" values, and so need special
|
||||
// handling:
|
||||
std::string fTag = "";
|
||||
int val;
|
||||
int val = 0;
|
||||
if (attribVal == "f" || attribName == "f") {
|
||||
fTag = "_SLN_";
|
||||
atom->setProp(common_properties::_Unfinished_SLN_, 1);
|
||||
@@ -352,8 +352,8 @@ void parseFinalAtomAttribs(Atom *atom, bool doingQuery) {
|
||||
if (description.size() > 5 && description.substr(0, 5) == "_SLN_") {
|
||||
boost::erase_head(description, 5);
|
||||
query->setDescription(description);
|
||||
static_cast<ATOM_EQUALS_QUERY *>(query)
|
||||
->setVal((int)(query->getDataFunc()(atom)));
|
||||
static_cast<ATOM_EQUALS_QUERY *>(query)->setVal(
|
||||
(int)(query->getDataFunc()(atom)));
|
||||
}
|
||||
// now add the query's children to the queue and continue:
|
||||
for (QueryAtom::QUERYATOM_QUERY::CHILD_VECT_CI cIt = query->beginChildren();
|
||||
@@ -505,10 +505,10 @@ void adjustAtomChiralities(RWMol *mol) {
|
||||
int nSwaps = (*atomIt)->getPerturbationOrder(bondOrdering);
|
||||
|
||||
if (nSwaps % 2) {
|
||||
(*atomIt)
|
||||
->setChiralTag((*atomIt)->getChiralTag() == Atom::CHI_TETRAHEDRAL_CW
|
||||
? Atom::CHI_TETRAHEDRAL_CCW
|
||||
: Atom::CHI_TETRAHEDRAL_CW);
|
||||
(*atomIt)->setChiralTag((*atomIt)->getChiralTag() ==
|
||||
Atom::CHI_TETRAHEDRAL_CW
|
||||
? Atom::CHI_TETRAHEDRAL_CCW
|
||||
: Atom::CHI_TETRAHEDRAL_CW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
407
External/AvalonTools/Wrap/pyAvalonTools.cpp
vendored
407
External/AvalonTools/Wrap/pyAvalonTools.cpp
vendored
@@ -11,125 +11,121 @@
|
||||
#include <AvalonTools.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
extern "C" {
|
||||
#include "struchk.h"
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#include "struchk.h"
|
||||
}
|
||||
|
||||
namespace python = boost::python;
|
||||
|
||||
namespace {
|
||||
|
||||
RDKit::SparseIntVect<boost::uint32_t> *getAvalonCountFP(const RDKit::ROMol &mol,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
unsigned int bitFlags) {
|
||||
RDKit::SparseIntVect<boost::uint32_t> *res =
|
||||
new RDKit::SparseIntVect<boost::uint32_t>(nBits);
|
||||
AvalonTools::getAvalonCountFP(mol, *res, nBits, isQuery, bitFlags);
|
||||
return res;
|
||||
}
|
||||
RDKit::SparseIntVect<boost::uint32_t> *getAvalonCountFP(const std::string &data,
|
||||
bool isSmiles,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
unsigned int bitFlags) {
|
||||
RDKit::SparseIntVect<boost::uint32_t> *res =
|
||||
new RDKit::SparseIntVect<boost::uint32_t>(nBits);
|
||||
AvalonTools::getAvalonCountFP(data, isSmiles, *res, nBits, isQuery, bitFlags);
|
||||
return res;
|
||||
}
|
||||
|
||||
RDKit::SparseIntVect<boost::uint32_t> *getAvalonCountFP(const RDKit::ROMol &mol,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
unsigned int bitFlags){
|
||||
RDKit::SparseIntVect<boost::uint32_t> *res=new RDKit::SparseIntVect<boost::uint32_t>(nBits);
|
||||
AvalonTools::getAvalonCountFP(mol,*res,nBits,isQuery,bitFlags);
|
||||
return res;
|
||||
}
|
||||
RDKit::SparseIntVect<boost::uint32_t> *getAvalonCountFP(const std::string &data,bool isSmiles,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
unsigned int bitFlags){
|
||||
RDKit::SparseIntVect<boost::uint32_t> *res=new RDKit::SparseIntVect<boost::uint32_t>(nBits);
|
||||
AvalonTools::getAvalonCountFP(data,isSmiles,*res,nBits,isQuery,bitFlags);
|
||||
return res;
|
||||
ExplicitBitVect *getAvalonFP(const RDKit::ROMol &mol, unsigned int nBits,
|
||||
bool isQuery, bool resetVect,
|
||||
unsigned int bitFlags) {
|
||||
ExplicitBitVect *res = new ExplicitBitVect(nBits);
|
||||
AvalonTools::getAvalonFP(mol, *res, nBits, isQuery, resetVect, bitFlags);
|
||||
return res;
|
||||
}
|
||||
python::list getAvalonFPAsWords(const RDKit::ROMol &mol, unsigned int nBits,
|
||||
bool isQuery, bool resetVect,
|
||||
unsigned int bitFlags) {
|
||||
std::vector<boost::uint32_t> words;
|
||||
AvalonTools::getAvalonFP(mol, words, nBits, isQuery, resetVect, bitFlags);
|
||||
python::list res;
|
||||
for (std::vector<boost::uint32_t>::const_iterator ci = words.begin();
|
||||
ci != words.end(); ++ci) {
|
||||
res.append(static_cast<unsigned long>(*ci));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
ExplicitBitVect *getAvalonFP(const RDKit::ROMol &mol,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
bool resetVect,
|
||||
unsigned int bitFlags){
|
||||
ExplicitBitVect *res=new ExplicitBitVect(nBits);
|
||||
AvalonTools::getAvalonFP(mol,*res,nBits,isQuery,resetVect,bitFlags);
|
||||
return res;
|
||||
}
|
||||
python::list getAvalonFPAsWords(const RDKit::ROMol &mol,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
bool resetVect,
|
||||
unsigned int bitFlags){
|
||||
std::vector<boost::uint32_t> words;
|
||||
AvalonTools::getAvalonFP(mol,words,nBits,isQuery,resetVect,bitFlags);
|
||||
python::list res;
|
||||
for(std::vector<boost::uint32_t>::const_iterator ci=words.begin();
|
||||
ci!=words.end();++ci){
|
||||
res.append(static_cast<unsigned long>(*ci));
|
||||
}
|
||||
return res;
|
||||
ExplicitBitVect *getAvalonFP(const std::string &data, bool isSmiles,
|
||||
unsigned int nBits, bool isQuery, bool resetVect,
|
||||
unsigned int bitFlags) {
|
||||
ExplicitBitVect *res = new ExplicitBitVect(nBits);
|
||||
AvalonTools::getAvalonFP(data, isSmiles, *res, nBits, isQuery, resetVect,
|
||||
bitFlags);
|
||||
return res;
|
||||
}
|
||||
python::list getAvalonFPAsWords(const std::string &data, bool isSmiles,
|
||||
unsigned int nBits, bool isQuery,
|
||||
bool resetVect, unsigned int bitFlags) {
|
||||
std::vector<boost::uint32_t> words;
|
||||
AvalonTools::getAvalonFP(data, isSmiles, words, nBits, isQuery, resetVect,
|
||||
bitFlags);
|
||||
python::list res;
|
||||
for (std::vector<boost::uint32_t>::const_iterator ci = words.begin();
|
||||
ci != words.end(); ++ci) {
|
||||
res.append(static_cast<unsigned long>(*ci));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
python::tuple CheckMolecule(const std::string &data, bool isSmiles) {
|
||||
int errs = 0;
|
||||
RDKit::ROMOL_SPTR rMol = AvalonTools::checkMol(errs, data, isSmiles);
|
||||
return python::make_tuple(errs, rMol);
|
||||
;
|
||||
}
|
||||
python::tuple CheckMolecule(RDKit::ROMol &mol) {
|
||||
int errs = 0;
|
||||
RDKit::ROMOL_SPTR rMol = AvalonTools::checkMol(errs, mol);
|
||||
return python::make_tuple(errs, rMol);
|
||||
;
|
||||
}
|
||||
python::tuple CheckMoleculeString(const std::string &data, bool isSmiles) {
|
||||
std::pair<std::string, int> res = AvalonTools::checkMolString(data, isSmiles);
|
||||
return python::make_tuple(res.second, res.first);
|
||||
;
|
||||
}
|
||||
|
||||
ExplicitBitVect *getAvalonFP(const std::string &data,bool isSmiles,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
bool resetVect,
|
||||
unsigned int bitFlags){
|
||||
ExplicitBitVect *res=new ExplicitBitVect(nBits);
|
||||
AvalonTools::getAvalonFP(data,isSmiles,*res,nBits,isQuery,resetVect,bitFlags);
|
||||
return res;
|
||||
}
|
||||
python::list getAvalonFPAsWords(const std::string &data,bool isSmiles,
|
||||
unsigned int nBits,
|
||||
bool isQuery,
|
||||
bool resetVect,
|
||||
unsigned int bitFlags){
|
||||
std::vector<boost::uint32_t> words;
|
||||
AvalonTools::getAvalonFP(data,isSmiles,words,nBits,isQuery,resetVect,bitFlags);
|
||||
python::list res;
|
||||
for(std::vector<boost::uint32_t>::const_iterator ci=words.begin();
|
||||
ci!=words.end();++ci){
|
||||
res.append(static_cast<unsigned long>(*ci));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
enum StruChkFlag {
|
||||
bad_molecule = BAD_MOLECULE,
|
||||
alias_conversion_failed = ALIAS_CONVERSION_FAILED,
|
||||
transformed = TRANSFORMED,
|
||||
fragments_found = FRAGMENTS_FOUND,
|
||||
either_warning = EITHER_WARNING,
|
||||
stereo_error = STEREO_ERROR,
|
||||
dubious_stereo_removed = DUBIOUS_STEREO_REMOVED,
|
||||
atom_clash = ATOM_CLASH,
|
||||
atom_check_failed = ATOM_CHECK_FAILED,
|
||||
size_check_failed = SIZE_CHECK_FAILED,
|
||||
recharged = RECHARGED,
|
||||
stereo_forced_bad = STEREO_FORCED_BAD,
|
||||
stereo_transformed = STEREO_TRANSFORMED,
|
||||
template_transformed = TEMPLATE_TRANSFORMED,
|
||||
};
|
||||
|
||||
python::tuple CheckMolecule(const std::string &data, bool isSmiles) {
|
||||
int errs = 0;
|
||||
RDKit::ROMOL_SPTR rMol = AvalonTools::checkMol(errs, data, isSmiles);
|
||||
return python::make_tuple(errs, rMol);;
|
||||
}
|
||||
python::tuple CheckMolecule(RDKit::ROMol &mol) {
|
||||
int errs = 0;
|
||||
RDKit::ROMOL_SPTR rMol = AvalonTools::checkMol(errs, mol);
|
||||
return python::make_tuple(errs, rMol);;
|
||||
}
|
||||
python::tuple CheckMoleculeString(const std::string &data, bool isSmiles){
|
||||
int errs = 0;
|
||||
std::pair<std::string,int> res=AvalonTools::checkMolString(data,isSmiles);
|
||||
return python::make_tuple(res.second,res.first);;
|
||||
}
|
||||
|
||||
enum StruChkFlag {
|
||||
bad_molecule=BAD_MOLECULE,
|
||||
alias_conversion_failed=ALIAS_CONVERSION_FAILED,
|
||||
transformed=TRANSFORMED,
|
||||
fragments_found=FRAGMENTS_FOUND,
|
||||
either_warning=EITHER_WARNING,
|
||||
stereo_error=STEREO_ERROR,
|
||||
dubious_stereo_removed=DUBIOUS_STEREO_REMOVED,
|
||||
atom_clash=ATOM_CLASH,
|
||||
atom_check_failed=ATOM_CHECK_FAILED,
|
||||
size_check_failed=SIZE_CHECK_FAILED,
|
||||
recharged=RECHARGED,
|
||||
stereo_forced_bad=STEREO_FORCED_BAD,
|
||||
stereo_transformed=STEREO_TRANSFORMED,
|
||||
template_transformed=TEMPLATE_TRANSFORMED,
|
||||
} ;
|
||||
|
||||
enum StruChkResult {
|
||||
success=0,
|
||||
bad_set=BAD_SET,
|
||||
transformed_set=TRANSFORMED_SET,
|
||||
} ;
|
||||
enum StruChkResult {
|
||||
success = 0,
|
||||
bad_set = BAD_SET,
|
||||
transformed_set = TRANSFORMED_SET,
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_PYTHON_MODULE(pyAvalonTools) {
|
||||
python::scope().attr("__doc__") =
|
||||
"Module containing functionality from the Avalon toolkit.\n\
|
||||
"Module containing functionality from the Avalon toolkit.\n\
|
||||
\n\
|
||||
The functions currently exposed are:\n\
|
||||
- GetCanonSmiles() : return the canonical smiles for a molecule\n\
|
||||
@@ -146,162 +142,165 @@ See the individual docstrings for more information.\n\
|
||||
";
|
||||
|
||||
std::string docString = "returns canonical smiles for an RDKit molecule";
|
||||
python::def("GetCanonSmiles", (std::string (*)(RDKit::ROMol &,int))AvalonTools::getCanonSmiles,
|
||||
(python::arg("mol"), python::arg("flags")=-1),
|
||||
python::def("GetCanonSmiles",
|
||||
(std::string(*)(RDKit::ROMol &, int))AvalonTools::getCanonSmiles,
|
||||
(python::arg("mol"), python::arg("flags") = -1),
|
||||
docString.c_str());
|
||||
docString = "Returns canonical smiles for some molecule data.\n\
|
||||
docString =
|
||||
"Returns canonical smiles for some molecule data.\n\
|
||||
If the isSmiles argument is true, the data is assumed to be SMILES, otherwise\n\
|
||||
MDL mol data is assumed.";
|
||||
python::def("GetCanonSmiles", (std::string (*)(const std::string &,bool,int))AvalonTools::getCanonSmiles,
|
||||
(python::arg("molData"), python::arg("isSmiles"), python::arg("flags")=-1),
|
||||
python::def("GetCanonSmiles",
|
||||
(std::string(*)(const std::string &, bool,
|
||||
int))AvalonTools::getCanonSmiles,
|
||||
(python::arg("molData"), python::arg("isSmiles"),
|
||||
python::arg("flags") = -1),
|
||||
docString.c_str());
|
||||
docString = "returns the Avalon fingerprint for an RDKit molecule";
|
||||
python::def("GetAvalonFP",
|
||||
(ExplicitBitVect *(*)(const RDKit::ROMol &,unsigned int,bool,bool,unsigned int))getAvalonFP,
|
||||
(python::arg("mol"),
|
||||
python::arg("nBits")=512,
|
||||
python::arg("isQuery")=false,
|
||||
python::arg("resetVect")=false,
|
||||
python::arg("bitFlags")=AvalonTools::avalonSimilarityBits),
|
||||
(ExplicitBitVect * (*)(const RDKit::ROMol &, unsigned int, bool,
|
||||
bool, unsigned int))getAvalonFP,
|
||||
(python::arg("mol"), python::arg("nBits") = 512,
|
||||
python::arg("isQuery") = false, python::arg("resetVect") = false,
|
||||
python::arg("bitFlags") = AvalonTools::avalonSimilarityBits),
|
||||
docString.c_str(),
|
||||
python::return_value_policy<python::manage_new_object>());
|
||||
docString = "returns the Avalon fingerprint for some molecule data.\n\
|
||||
docString =
|
||||
"returns the Avalon fingerprint for some molecule data.\n\
|
||||
If the isSmiles argument is true, the data is assumed to be SMILES, otherwise\n\
|
||||
MDL mol data is assumed.";
|
||||
python::def("GetAvalonFP",
|
||||
(ExplicitBitVect *(*)(const std::string&,bool,unsigned int,bool,bool,unsigned int))getAvalonFP,
|
||||
(python::arg("molData"),python::arg("isSmiles"),
|
||||
python::arg("nBits")=512,
|
||||
python::arg("isQuery")=false,
|
||||
python::arg("resetVect")=false,
|
||||
python::arg("bitFlags")=AvalonTools::avalonSimilarityBits),
|
||||
(ExplicitBitVect * (*)(const std::string &, bool, unsigned int,
|
||||
bool, bool, unsigned int))getAvalonFP,
|
||||
(python::arg("molData"), python::arg("isSmiles"),
|
||||
python::arg("nBits") = 512, python::arg("isQuery") = false,
|
||||
python::arg("resetVect") = false,
|
||||
python::arg("bitFlags") = AvalonTools::avalonSimilarityBits),
|
||||
docString.c_str(),
|
||||
python::return_value_policy<python::manage_new_object>());
|
||||
docString = "Generates 2d coordinates for an RDKit molecule";
|
||||
python::def("Generate2DCoords", (unsigned int (*)(RDKit::ROMol &,bool))AvalonTools::set2DCoords,
|
||||
(python::arg("mol"),python::arg("clearConfs")=true),
|
||||
python::def("Generate2DCoords",
|
||||
(unsigned int (*)(RDKit::ROMol &, bool))AvalonTools::set2DCoords,
|
||||
(python::arg("mol"), python::arg("clearConfs") = true),
|
||||
docString.c_str());
|
||||
docString = "returns an MDL mol block with 2D coordinates for some molecule data.\n\
|
||||
docString =
|
||||
"returns an MDL mol block with 2D coordinates for some molecule data.\n\
|
||||
If the isSmiles argument is true, the data is assumed to be SMILES, otherwise\n\
|
||||
MDL mol data is assumed.";
|
||||
python::def("Generate2DCoords", (std::string (*)(const std::string &,bool))AvalonTools::set2DCoords,
|
||||
(python::arg("molData"),python::arg("isSmiles")),
|
||||
docString.c_str());
|
||||
python::def(
|
||||
"Generate2DCoords",
|
||||
(std::string(*)(const std::string &, bool))AvalonTools::set2DCoords,
|
||||
(python::arg("molData"), python::arg("isSmiles")), docString.c_str());
|
||||
|
||||
|
||||
docString = "returns the Avalon fingerprint for an RDKit molecule as a list of ints";
|
||||
docString =
|
||||
"returns the Avalon fingerprint for an RDKit molecule as a list of ints";
|
||||
python::def("GetAvalonFPAsWords",
|
||||
(python::list (*)(const RDKit::ROMol &,unsigned int,bool,bool,unsigned int))getAvalonFPAsWords,
|
||||
(python::arg("mol"),
|
||||
python::arg("nBits")=512,
|
||||
python::arg("isQuery")=false,
|
||||
python::arg("resetVect")=false,
|
||||
python::arg("bitFlags")=AvalonTools::avalonSimilarityBits),
|
||||
(python::list(*)(const RDKit::ROMol &, unsigned int, bool, bool,
|
||||
unsigned int))getAvalonFPAsWords,
|
||||
(python::arg("mol"), python::arg("nBits") = 512,
|
||||
python::arg("isQuery") = false, python::arg("resetVect") = false,
|
||||
python::arg("bitFlags") = AvalonTools::avalonSimilarityBits),
|
||||
docString.c_str());
|
||||
|
||||
|
||||
docString = "returns the Avalon count fingerprint for an RDKit molecule";
|
||||
python::def("GetAvalonCountFP",
|
||||
(RDKit::SparseIntVect<boost::uint32_t> *(*)(const RDKit::ROMol &,unsigned int,bool,unsigned int))getAvalonCountFP,
|
||||
(python::arg("mol"),
|
||||
python::arg("nBits")=512,
|
||||
python::arg("isQuery")=false,
|
||||
python::arg("bitFlags")=AvalonTools::avalonSimilarityBits),
|
||||
python::def("GetAvalonCountFP", (RDKit::SparseIntVect<boost::uint32_t> *
|
||||
(*)(const RDKit::ROMol &, unsigned int, bool,
|
||||
unsigned int))getAvalonCountFP,
|
||||
(python::arg("mol"), python::arg("nBits") = 512,
|
||||
python::arg("isQuery") = false,
|
||||
python::arg("bitFlags") = AvalonTools::avalonSimilarityBits),
|
||||
docString.c_str(),
|
||||
python::return_value_policy<python::manage_new_object>());
|
||||
docString = "returns the Avalon count fingerprint for some molecule data.\n\
|
||||
docString =
|
||||
"returns the Avalon count fingerprint for some molecule data.\n\
|
||||
If the isSmiles argument is true, the data is assumed to be SMILES, otherwise\n\
|
||||
MDL mol data is assumed.";
|
||||
python::def("GetAvalonCountFP",
|
||||
(RDKit::SparseIntVect<boost::uint32_t> *(*)(const std::string&,bool,unsigned int,bool,unsigned int))getAvalonCountFP,
|
||||
(python::arg("molData"),python::arg("isSmiles"),
|
||||
python::arg("nBits")=512,
|
||||
python::arg("isQuery")=false,
|
||||
python::arg("bitFlags")=AvalonTools::avalonSimilarityBits),
|
||||
python::def("GetAvalonCountFP", (RDKit::SparseIntVect<boost::uint32_t> *
|
||||
(*)(const std::string &, bool, unsigned int,
|
||||
bool, unsigned int))getAvalonCountFP,
|
||||
(python::arg("molData"), python::arg("isSmiles"),
|
||||
python::arg("nBits") = 512, python::arg("isQuery") = false,
|
||||
python::arg("bitFlags") = AvalonTools::avalonSimilarityBits),
|
||||
docString.c_str(),
|
||||
python::return_value_policy<python::manage_new_object>());
|
||||
|
||||
|
||||
|
||||
docString = "returns the Avalon fingerprint for some molecule data as a list of ints.\n\
|
||||
docString =
|
||||
"returns the Avalon fingerprint for some molecule data as a list of ints.\n\
|
||||
If the isSmiles argument is true, the data is assumed to be SMILES, otherwise\n\
|
||||
MDL mol data is assumed.";
|
||||
python::def("GetAvalonFPAsWords",
|
||||
(python::list (*)(const std::string&,bool,unsigned int,bool,bool,unsigned int))getAvalonFPAsWords,
|
||||
(python::arg("molData"),python::arg("isSmiles"),
|
||||
python::arg("nBits")=512,
|
||||
python::arg("isQuery")=false,
|
||||
python::arg("resetVect")=false,
|
||||
python::arg("bitFlags")=AvalonTools::avalonSimilarityBits),
|
||||
(python::list(*)(const std::string &, bool, unsigned int, bool,
|
||||
bool, unsigned int))getAvalonFPAsWords,
|
||||
(python::arg("molData"), python::arg("isSmiles"),
|
||||
python::arg("nBits") = 512, python::arg("isQuery") = false,
|
||||
python::arg("resetVect") = false,
|
||||
python::arg("bitFlags") = AvalonTools::avalonSimilarityBits),
|
||||
docString.c_str());
|
||||
|
||||
docString = "initializes the structure checker.\n\
|
||||
docString =
|
||||
"initializes the structure checker.\n\
|
||||
The argument should contain option lines separated by embedded newlines.\
|
||||
An empty string will be used if the argument is omitted.\
|
||||
An non-zero error code is returned in case of failure.";
|
||||
python::def("InitializeCheckMol",
|
||||
(int(*)(const std::string&)) AvalonTools::initCheckMol,
|
||||
(python::arg("options") = ""),
|
||||
docString.c_str());
|
||||
docString = "close open files used by molecule-checking functions.";
|
||||
python::def("CloseCheckMolFiles",
|
||||
AvalonTools::closeCheckMolFiles,
|
||||
docString.c_str());
|
||||
python::def("InitializeCheckMol",
|
||||
(int (*)(const std::string &))AvalonTools::initCheckMol,
|
||||
(python::arg("options") = ""), docString.c_str());
|
||||
docString = "close open files used by molecule-checking functions.";
|
||||
python::def("CloseCheckMolFiles", AvalonTools::closeCheckMolFiles,
|
||||
docString.c_str());
|
||||
|
||||
docString = "check a molecule passed in as a string.\n\
|
||||
docString =
|
||||
"check a molecule passed in as a string.\n\
|
||||
If the isSmiles argument is true, the string should represent the SMILES encoding\n\
|
||||
of the molecule, otherwise it should be encoded as an MDL molfile.\n\
|
||||
The first member of the return tuple contains the bit-encoded corrections made to the molecule.\n\
|
||||
If possible, the molecule (corrected when appropriate) is returned as the second member of \n\
|
||||
the return tuple. Otherwise, None is returned.";
|
||||
python::def("CheckMolecule",
|
||||
(python::tuple(*)(const std::string&, bool)) CheckMolecule,
|
||||
(python::arg("molstring"), python::arg("isSmiles")),
|
||||
docString.c_str());
|
||||
python::def("CheckMolecule",
|
||||
(python::tuple(*)(const std::string &, bool))CheckMolecule,
|
||||
(python::arg("molstring"), python::arg("isSmiles")),
|
||||
docString.c_str());
|
||||
|
||||
docString = "check a molecule passed in as an RDKit molecule.\n\
|
||||
docString =
|
||||
"check a molecule passed in as an RDKit molecule.\n\
|
||||
The first member of the return tuple contains the bit-encoded corrections made to the molecule.\n\
|
||||
If possible, the molecule (corrected when appropriate) is returned as the second member of \n\
|
||||
the return tuple. Otherwise, None is returned.";
|
||||
python::def("CheckMolecule",
|
||||
(python::tuple(*)(RDKit::ROMol&)) CheckMolecule,
|
||||
(python::arg("mol")),
|
||||
docString.c_str());
|
||||
python::def("CheckMolecule", (python::tuple(*)(RDKit::ROMol &))CheckMolecule,
|
||||
(python::arg("mol")), docString.c_str());
|
||||
|
||||
docString = "check a molecule passed in as a string and returns the result as a string.\n\
|
||||
docString =
|
||||
"check a molecule passed in as a string and returns the result as a string.\n\
|
||||
If the isSmiles argument is true, the string should represent the SMILES encoding\n\
|
||||
of the molecule, otherwise it should be encoded as an MDL molfile.\n\
|
||||
The first member of the return tuple contains the bit-encoded corrections made to the molecule.\n\
|
||||
If possible, a corrected CTAB for the molecule is returned as the second member of \n\
|
||||
the return tuple.";
|
||||
python::def("CheckMoleculeString",
|
||||
CheckMoleculeString,
|
||||
(python::arg("molstring"), python::arg("isSmiles")),
|
||||
docString.c_str());
|
||||
python::def("CheckMoleculeString", CheckMoleculeString,
|
||||
(python::arg("molstring"), python::arg("isSmiles")),
|
||||
docString.c_str());
|
||||
|
||||
python::scope().attr("avalonSSSBits")=AvalonTools::avalonSSSBits;
|
||||
python::scope().attr("avalonSimilarityBits")=AvalonTools::avalonSimilarityBits;
|
||||
python::scope().attr("avalonSSSBits") = AvalonTools::avalonSSSBits;
|
||||
python::scope().attr("avalonSimilarityBits") =
|
||||
AvalonTools::avalonSimilarityBits;
|
||||
|
||||
python::enum_<StruChkFlag>("StruChkFlag")
|
||||
.value("bad_molecule",bad_molecule)
|
||||
.value("alias_conversion_failed",alias_conversion_failed)
|
||||
.value("transformed",transformed)
|
||||
.value("fragments_found",fragments_found)
|
||||
.value("either_warning",either_warning)
|
||||
.value("stereo_error",stereo_error)
|
||||
.value("dubious_stereo_removed",dubious_stereo_removed)
|
||||
.value("atom_clash",atom_clash)
|
||||
.value("atom_check_failed",atom_check_failed)
|
||||
.value("size_check_failed",size_check_failed)
|
||||
.value("recharged",recharged)
|
||||
.value("stereo_forced_bad",stereo_forced_bad)
|
||||
.value("stereo_transformed",stereo_transformed)
|
||||
.value("template_transformed",template_transformed)
|
||||
;
|
||||
.value("bad_molecule", bad_molecule)
|
||||
.value("alias_conversion_failed", alias_conversion_failed)
|
||||
.value("transformed", transformed)
|
||||
.value("fragments_found", fragments_found)
|
||||
.value("either_warning", either_warning)
|
||||
.value("stereo_error", stereo_error)
|
||||
.value("dubious_stereo_removed", dubious_stereo_removed)
|
||||
.value("atom_clash", atom_clash)
|
||||
.value("atom_check_failed", atom_check_failed)
|
||||
.value("size_check_failed", size_check_failed)
|
||||
.value("recharged", recharged)
|
||||
.value("stereo_forced_bad", stereo_forced_bad)
|
||||
.value("stereo_transformed", stereo_transformed)
|
||||
.value("template_transformed", template_transformed);
|
||||
python::enum_<StruChkResult>("StruChkResult")
|
||||
.value("success",success)
|
||||
.value("bad_set",bad_set)
|
||||
.value("transformed_set",transformed_set)
|
||||
;
|
||||
|
||||
.value("success", success)
|
||||
.value("bad_set", bad_set)
|
||||
.value("transformed_set", transformed_set);
|
||||
}
|
||||
|
||||
10
External/AvalonTools/test1.cpp
vendored
10
External/AvalonTools/test1.cpp
vendored
@@ -276,7 +276,8 @@ void testSmilesSegFault() {
|
||||
|
||||
void testGithub336() {
|
||||
BOOST_LOG(rdInfoLog) << "testing github issue 336: bad canonical smiles for "
|
||||
"conjugated double bonds" << std::endl;
|
||||
"conjugated double bonds"
|
||||
<< std::endl;
|
||||
// some tests around dealing with bad mol blocks
|
||||
{
|
||||
std::string pathName = getenv("RDBASE");
|
||||
@@ -386,7 +387,6 @@ void testCountFps() {
|
||||
void testInitStruChk() {
|
||||
BOOST_LOG(rdInfoLog) << "testing init struchk " << std::endl;
|
||||
{
|
||||
|
||||
std::string pathName = getenv("RDBASE");
|
||||
pathName += "/Data/struchk/";
|
||||
std::string struchk_init =
|
||||
@@ -402,9 +402,9 @@ void testInitStruChk() {
|
||||
"-cs\n"
|
||||
"-cn 999\n"
|
||||
"-l " +
|
||||
#ifdef _WIN32
|
||||
#ifdef _WIN32
|
||||
std::getenv("TEMP") +
|
||||
#endif
|
||||
#endif
|
||||
std::string(std::tmpnam(NULL)) + std::string("\n");
|
||||
int errs = AvalonTools::initCheckMol(struchk_init);
|
||||
TEST_ASSERT(!errs);
|
||||
@@ -414,7 +414,7 @@ void testInitStruChk() {
|
||||
BOOST_LOG(rdInfoLog) << "done" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main() {
|
||||
RDLog::InitLogs();
|
||||
#if 1
|
||||
test1();
|
||||
|
||||
3542
External/INCHI-API/inchi.cpp
vendored
3542
External/INCHI-API/inchi.cpp
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user