Fix/github1287 (#1297)

* Fixes #1287

* unconnected fix to clean up a compiler warning from clang
This commit is contained in:
Greg Landrum
2017-02-09 19:01:43 +01:00
committed by Brian Kelley
parent e70599a12e
commit 6152165ad3
3 changed files with 43 additions and 36 deletions

View File

@@ -351,7 +351,7 @@ void addRecursiveQuery(ROMol &mol, const ROMol &query, unsigned int atomIdx,
oAt->expandQuery(q, Queries::COMPOSITE_AND);
}
}
MolOps::SanitizeFlags sanitizeMol(ROMol &mol, boost::uint64_t sanitizeOps,
MolOps::SanitizeFlags sanitizeMol(ROMol &mol, boost::uint64_t sanitizeOps,
bool catchErrors) {
RWMol &wmol = static_cast<RWMol &>(mol);
unsigned int operationThatFailed;
@@ -751,26 +751,29 @@ ROMol *replaceCoreHelper(const ROMol &mol, const ROMol &core,
}
int v1, v2;
if (sz != 1 && sz != 2)
throw ValueErrorException(
"Input not a vector of (core_atom_idx,molecule_atom_idx) or "
"(molecule_atom_idx,...) entries");
if (sz == 1) {
if (length != core.getNumAtoms()) {
std::string entries = core.getNumAtoms() == 1 ? " entry" : " entries";
switch (sz) {
case 1:
if (length != core.getNumAtoms()) {
std::string entries = core.getNumAtoms() == 1 ? " entry" : " entries";
std::stringstream ss;
ss << std::string(
"When using input vector of type (molecule_atom_idx,...) "
"supplied core requires ")
<< core.getNumAtoms() << entries;
throw ValueErrorException(ss.str());
}
v1 = (int)i;
v2 = python::extract<int>(match[i]);
} else if (sz == 2) {
v1 = python::extract<int>(match[i][0]);
v2 = python::extract<int>(match[i][1]);
std::stringstream ss;
ss << std::string(
"When using input vector of type (molecule_atom_idx,...) "
"supplied core requires ")
<< core.getNumAtoms() << entries;
throw ValueErrorException(ss.str());
}
v1 = (int)i;
v2 = python::extract<int>(match[i]);
break;
case 2:
v1 = python::extract<int>(match[i][0]);
v2 = python::extract<int>(match[i][1]);
break;
default:
throw ValueErrorException(
"Input not a vector of (core_atom_idx,molecule_atom_idx) or "
"(molecule_atom_idx,...) entries");
}
matchVect.push_back(std::make_pair(v1, v2));
}
@@ -798,7 +801,6 @@ struct molops_wrapper {
.export_values();
;
// ------------------------------------------------------------------------
docString =
"Assign stereochemistry to bonds based on coordinates.\n\
@@ -808,10 +810,9 @@ struct molops_wrapper {
- mol: the molecule to be modified\n\
- conformer: Conformer providing the coordinates\n\
\n";
python::def(
"DetectBondStereoChemistry", DetectBondStereoChemistry,
(python::arg("mol"), python::arg("conformer")),
docString.c_str());
python::def("DetectBondStereoChemistry", DetectBondStereoChemistry,
(python::arg("mol"), python::arg("conformer")),
docString.c_str());
// ------------------------------------------------------------------------
docString =
@@ -1521,7 +1522,6 @@ struct molops_wrapper {
(python::arg("mol"), python::arg("cleanIt") = false),
docString.c_str());
// ------------------------------------------------------------------------
docString =
"Removes all stereochemistry info from the molecule.\n\

View File

@@ -1,6 +1,5 @@
# $Id$
#
# Copyright (C) 2001-2010 greg Landrum and Rational Discovery LLC
# Copyright (C) 2001-2017 greg Landrum and Rational Discovery LLC
#
# @@ All Rights Reserved @@
# This file is part of the RDKit.
@@ -17,15 +16,14 @@ def _isCallable(thing):
return (hasattr(collections,'Callable') and isinstance(thing,collections.Callable)) or \
hasattr(thing,'__call__')
_descList = []
def _setupDescriptors(namespace):
global _descList, descList
from rdkit.Chem import GraphDescriptors, MolSurf, Lipinski, Fragments, Crippen, Descriptors3D
from rdkit.Chem import GraphDescriptors, MolSurf, Lipinski, Fragments, Crippen
from rdkit.Chem.EState import EState_VSA
mods = [GraphDescriptors, MolSurf, EState_VSA, Lipinski, Crippen, Descriptors3D, Fragments]
mods = [GraphDescriptors, MolSurf, EState_VSA, Lipinski, Crippen, Fragments]
otherMods = [Chem]

View File

@@ -1,6 +1,5 @@
# $Id$
#
# Copyright (C) 2007-2010 Greg Landrum
# Copyright (C) 2007-2017 Greg Landrum
#
# @@ All Rights Reserved @@
# This file is part of the RDKit.
@@ -30,6 +29,19 @@ def feq(n1, n2, tol=1e-4):
class TestCase(unittest.TestCase):
def testGithub1287(self):
smis = ('CCC', )
for smi in smis:
m = Chem.MolFromSmiles(smi)
self.assertTrue(m)
for nm, fn in Descriptors._descList:
try:
v = fn(m)
except Exception:
import traceback
traceback.print_exc()
raise AssertionError('SMILES: %s; Descriptor: %s' % (smi, nm))
def testBadAtomHandling(self):
smis = ('CC[Pu]', 'CC[*]')
for smi in smis:
@@ -38,9 +50,6 @@ class TestCase(unittest.TestCase):
for nm, fn in Descriptors._descList:
try:
v = fn(m)
except RuntimeError:
# 3D descriptors fail since the mol has no conformers
pass
except Exception:
import traceback
traceback.print_exc()