mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
SDMolSupplier: don't throw on errors parsing molecules. This allows the parsing of further mols to continue.
Conformer.cpp: make sure we don't ask for space for zero atoms. Kekulize.cpp: don't complain about marked bonds if we aren't removing markers. molopstest.cpp: bad smiles corrected in one test.exe ROMol.cpp, RWMol.cpp: extra preconditions added (should have been there all along) Wrap/MolOps.cpp: docs for replacesubstructs.
This commit is contained in:
@@ -16,8 +16,12 @@ namespace RDKit {
|
||||
|
||||
Conformer::Conformer(unsigned int numAtoms) {
|
||||
dp_mol = 0;
|
||||
d_positions.resize(numAtoms, RDGeom::Point3D(0.0, 0.0, 0.0));
|
||||
|
||||
if(numAtoms){
|
||||
d_positions.resize(numAtoms, RDGeom::Point3D(0.0, 0.0, 0.0));
|
||||
} else {
|
||||
d_positions.resize(0);
|
||||
d_positions.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Conformer::Conformer(const Conformer &conf) {
|
||||
|
||||
@@ -150,6 +150,7 @@ namespace RDKit {
|
||||
std::string tempStr = getLine(dp_inStream);
|
||||
// FIX: report files missing the $$$$ marker
|
||||
while(!(dp_inStream->eof()) && tempStr.find("$$$$") != 0){
|
||||
tempStr = strip(tempStr);
|
||||
if(tempStr!=""){
|
||||
if (tempStr[0] == '>') { // data header line: start of a data item
|
||||
// ignore all other crap and seek for for a data label enclosed
|
||||
@@ -242,10 +243,6 @@ namespace RDKit {
|
||||
d_line++;
|
||||
tempStr = getLine(dp_inStream);
|
||||
}
|
||||
// be sure to check to see if we hit EOF so that future
|
||||
// calls into this supplier don't die.
|
||||
this->checkForEnd();
|
||||
throw fe;
|
||||
}
|
||||
catch (MolSanitizeException &se) {
|
||||
// We couldn't sanitize a molecule we got - write out an error message and move to
|
||||
@@ -258,7 +255,7 @@ namespace RDKit {
|
||||
}
|
||||
} catch (...) {
|
||||
BOOST_LOG(rdErrorLog) << "Unexpected error hit on line " << d_line << std::endl;
|
||||
BOOST_LOG(rdErrorLog) << "ERROR: moving to the begining of the next moelcule\n";
|
||||
BOOST_LOG(rdErrorLog) << "ERROR: moving to the begining of the next molecule\n";
|
||||
}
|
||||
d_last++;
|
||||
unsigned int posHold=dp_inStream->tellg();
|
||||
|
||||
@@ -409,7 +409,7 @@ namespace RDKit {
|
||||
|
||||
for (bi = mol.beginBonds(); bi != mol.endBonds(); bi++) {
|
||||
// by now the bondtype should have already changed from aromatic
|
||||
if ((*bi)->getBondType() == Bond::AROMATIC) {
|
||||
if (markAtomsBonds && (*bi)->getBondType() == Bond::AROMATIC) {
|
||||
std::ostringstream errout;
|
||||
errout << "Kekulization somehow did not convert bond " << (*bi)->getIdx();
|
||||
std::string msg = errout.str();
|
||||
|
||||
@@ -353,6 +353,7 @@ ROMol::BOND_ITER_PAIR ROMol::getEdges() const {return boost::edges(d_graph);}
|
||||
|
||||
|
||||
unsigned int ROMol::addAtom(Atom *atom_pin,bool updateLabel,bool takeOwnership){
|
||||
PRECONDITION(atom_pin,"null atom passed in");
|
||||
Atom *atom_p;
|
||||
if(!takeOwnership) atom_p = atom_pin->copy();
|
||||
else atom_p = atom_pin;
|
||||
@@ -377,6 +378,7 @@ unsigned int ROMol::addAtom(Atom::ATOM_SPTR atom_sp,bool updateLabel)
|
||||
return addAtom(atom_sp.get(),updateLabel,false);
|
||||
}
|
||||
unsigned int ROMol::addBond(Bond *bond_pin,bool takeOwnership){
|
||||
PRECONDITION(bond_pin,"null bond passed in");
|
||||
RANGE_CHECK(0,bond_pin->getBeginAtomIdx(),getNumAtoms()-1);
|
||||
RANGE_CHECK(0,bond_pin->getEndAtomIdx(),getNumAtoms()-1);
|
||||
Bond *bond_p;
|
||||
|
||||
@@ -199,6 +199,7 @@ namespace RDKit{
|
||||
|
||||
unsigned int RWMol::addBond(Atom *atom1,Atom *atom2,
|
||||
Bond::BondType bondType){
|
||||
PRECONDITION(atom1&&atom2,"NULL atom passed in");
|
||||
return addBond(atom1->getIdx(),atom2->getIdx(),bondType);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace RDKit{
|
||||
See below for examples.\n\
|
||||
Default value is 0 (remove the atoms whether or not the entire fragment matches)\n\
|
||||
\n\
|
||||
RETURNS: a new molecule with the Hs removed\n\
|
||||
RETURNS: a new molecule with the substructure removed\n\
|
||||
\n\
|
||||
NOTES:\n\
|
||||
\n\
|
||||
@@ -254,6 +254,39 @@ namespace RDKit{
|
||||
docString.c_str(),
|
||||
python::return_value_policy<python::manage_new_object>());
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
docString="Replaces atoms matching a substructure query in a molecule\n\
|
||||
\n\
|
||||
ARGUMENTS:\n\
|
||||
\n\
|
||||
- mol: the molecule to be modified\n\
|
||||
\n\
|
||||
- query: the molecule to be used as a substructure query\n\
|
||||
\n\
|
||||
- replacement: the molecule to be used as the replacement\n\
|
||||
\n\
|
||||
- replaceAll: (optional) if this toggle is set, all substructures matching\n\
|
||||
the query will be replaced in a single result, otherwise each result will\n\
|
||||
contain a separate replacement.\n\
|
||||
Default value is False (return multiple replacements)\n\
|
||||
\n\
|
||||
RETURNS: a tuple of new molecules with the substructures replaced removed\n\
|
||||
\n\
|
||||
NOTES:\n\
|
||||
\n\
|
||||
- The original molecule is *not* modified.\n\
|
||||
\n\
|
||||
EXAMPLES:\n\
|
||||
\n\
|
||||
The following examples substitute SMILES/SMARTS strings for molecules, you'd have\n\
|
||||
to actually use molecules:\n\
|
||||
\n\
|
||||
- ReplaceSubstructs('CCOC','OC','NC') -> ('CCNC',)\n\
|
||||
\n\
|
||||
- ReplaceSubstructs('COCCOC','OC','NC') -> ('COCCNC','CNCCOC')\n\
|
||||
\n\
|
||||
- ReplaceSubstructs('COCCOC','OC','NC',True) -> ('CNCCNC',)\n\
|
||||
\n";
|
||||
python::def("ReplaceSubstructs", replaceSubstructures,
|
||||
(python::arg("mol"),python::arg("query"),
|
||||
python::arg("replacement"),
|
||||
|
||||
@@ -785,7 +785,7 @@ void test11()
|
||||
TEST_ASSERT(!(m->getAtomWithIdx(1)->hasProp("_CIPCode")));
|
||||
|
||||
delete m;
|
||||
smi = "F[C@]1C(Cl)CC1";
|
||||
smi = "F[C@H]1C(Cl)CC1";
|
||||
m = SmilesToMol(smi);
|
||||
TEST_ASSERT(m);
|
||||
MolOps::assignAtomChiralCodes(*m,true);
|
||||
|
||||
Reference in New Issue
Block a user