mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-04 21:54:27 +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>
107 lines
2.8 KiB
C++
107 lines
2.8 KiB
C++
//
|
|
//
|
|
// Copyright (C) 2020 Schrödinger, LLC
|
|
//
|
|
// @@ 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.
|
|
//
|
|
|
|
#include <GraphMol/MolOps.h>
|
|
|
|
#include "CIPMol.h"
|
|
|
|
namespace RDKit {
|
|
namespace CIPLabeler {
|
|
|
|
CIPMol::CIPMol(ROMol &mol) : d_mol{mol} {}
|
|
|
|
boost::rational<int> CIPMol::getFractionalAtomicNum(Atom *atom) const {
|
|
PRECONDITION(atom, "bad atom")
|
|
if (d_atomnums.empty()) {
|
|
const_cast<CIPMol *>(this)->d_atomnums = calcFracAtomNums(*this);
|
|
}
|
|
return d_atomnums[atom->getIdx()];
|
|
}
|
|
|
|
unsigned CIPMol::getNumAtoms() const { return d_mol.getNumAtoms(); }
|
|
|
|
unsigned CIPMol::getNumBonds() const { return d_mol.getNumBonds(); };
|
|
|
|
Atom *CIPMol::getAtom(int idx) const { return d_mol.getAtomWithIdx(idx); };
|
|
|
|
CXXAtomIterator<MolGraph, Atom *> CIPMol::atoms() const {
|
|
return d_mol.atoms();
|
|
}
|
|
|
|
Bond *CIPMol::getBond(int idx) const { return d_mol.getBondWithIdx(idx); };
|
|
|
|
CIPMolSpan<Bond *, ROMol::OEDGE_ITER> CIPMol::getBonds(Atom *atom) const {
|
|
PRECONDITION(atom, "bad atom")
|
|
return {d_mol, d_mol.getAtomBonds(atom)};
|
|
}
|
|
|
|
CIPMolSpan<Atom *, ROMol::ADJ_ITER> CIPMol::getNeighbors(Atom *atom) const {
|
|
PRECONDITION(atom, "bad atom")
|
|
return {d_mol, d_mol.getAtomNeighbors(atom)};
|
|
}
|
|
|
|
bool CIPMol::isInRing(Bond *bond) const {
|
|
PRECONDITION(bond, "bad bond")
|
|
const auto rings = d_mol.getRingInfo();
|
|
|
|
if (!rings->isFindFastOrBetter()) {
|
|
MolOps::fastFindRings(d_mol);
|
|
}
|
|
|
|
return rings->numBondRings(bond->getIdx()) != 0u;
|
|
};
|
|
|
|
int CIPMol::getBondOrder(Bond *bond) const {
|
|
PRECONDITION(bond, "bad bond")
|
|
if (dp_kekulized_mol == nullptr) {
|
|
auto tmp = new RWMol(d_mol);
|
|
try {
|
|
MolOps::Kekulize(*tmp);
|
|
} catch (const MolSanitizeException &) {
|
|
}
|
|
const_cast<CIPMol *>(this)->dp_kekulized_mol.reset(tmp);
|
|
}
|
|
|
|
const auto kekulized_bond = dp_kekulized_mol->getBondWithIdx(bond->getIdx());
|
|
|
|
// Dative bonds might need to be considered with a different bond order
|
|
// for the end atom at the end of the bond.
|
|
switch (kekulized_bond->getBondType()) {
|
|
case Bond::ZERO:
|
|
case Bond::HYDROGEN:
|
|
case Bond::DATIVE:
|
|
case Bond::DATIVEL:
|
|
case Bond::DATIVER:
|
|
return 0;
|
|
case Bond::SINGLE:
|
|
return 1;
|
|
case Bond::AROMATIC:
|
|
BOOST_LOG(rdWarningLog)
|
|
<< "non kekulizable aromatic bond being treated as bond order 1"
|
|
<< std::endl;
|
|
return 1;
|
|
case Bond::DOUBLE:
|
|
return 2;
|
|
case Bond::TRIPLE:
|
|
return 3;
|
|
case Bond::QUADRUPLE:
|
|
return 4;
|
|
case Bond::QUINTUPLE:
|
|
return 5;
|
|
case Bond::HEXTUPLE:
|
|
return 6;
|
|
default:
|
|
throw std::runtime_error("Non integer-order bonds are not allowed.");
|
|
}
|
|
};
|
|
|
|
} // namespace CIPLabeler
|
|
} // namespace RDKit
|