RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
MolOps.h File Reference
#include <RDGeneral/export.h>
#include <vector>
#include <map>
#include <list>
#include <RDGeneral/BoostStartInclude.h>
#include <boost/smart_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include <RDGeneral/BoostEndInclude.h>
#include <RDGeneral/types.h>
#include "SanitException.h"
#include <RDGeneral/FileParseException.h>

Go to the source code of this file.

Classes

struct  RDKit::MolOps::RemoveHsParameters
 
struct  RDKit::MolOps::AdjustQueryParameters
 Parameters controlling the behavior of MolOps::adjustQueryProperties. More...
 
class  RDKit::MolOps::Hybridizations
 

Namespaces

namespace  RDKit
 Std stuff.
 
namespace  RDKit::MolOps
 Groups a variety of molecular query and transformation operations.
 
namespace  RDKit::MolOps::details
 

Typedefs

typedef std::vector< doubleRDKit::INVAR_VECT
 
typedef INVAR_VECT::iterator RDKit::INVAR_VECT_I
 
typedef INVAR_VECT::const_iterator RDKit::INVAR_VECT_CI
 

Functions

RDKIT_GRAPHMOL_EXPORT int RDKit::MolOps::countAtomElec (const Atom *at)
 
RDKIT_GRAPHMOL_EXPORT int RDKit::MolOps::getFormalCharge (const ROMol &mol)
 sums up all atomic formal charges and returns the result
 
RDKIT_GRAPHMOL_EXPORT bool RDKit::MolOps::atomHasConjugatedBond (const Atom *at)
 returns whether or not the given Atom is involved in a conjugated bond
 
RDKIT_GRAPHMOL_EXPORT unsigned int RDKit::MolOps::getMolFrags (const ROMol &mol, std::vector< int > &mapping)
 find fragments (disconnected components of the molecular graph)
 
RDKIT_GRAPHMOL_EXPORT unsigned int RDKit::MolOps::getMolFrags (const ROMol &mol, std::vector< std::vector< int > > &frags)
 find fragments (disconnected components of the molecular graph)
 
RDKIT_GRAPHMOL_EXPORT unsigned int RDKit::MolOps::getMolFrags (const ROMol &mol, std::vector< std::unique_ptr< ROMol > > &molFrags, bool sanitizeFrags=true, std::vector< int > *frags=nullptr, std::vector< std::vector< int > > *fragsMolAtomMapping=nullptr, bool copyConformers=true)
 
RDKIT_GRAPHMOL_EXPORT std::vector< boost::shared_ptr< ROMol > > RDKit::MolOps::getMolFrags (const ROMol &mol, bool sanitizeFrags=true, std::vector< int > *frags=nullptr, std::vector< std::vector< int > > *fragsMolAtomMapping=nullptr, bool copyConformers=true)
 
template<typename T >
RDKIT_GRAPHMOL_EXPORT std::map< T, boost::shared_ptr< ROMol > > RDKit::MolOps::getMolFragsWithQuery (const ROMol &mol, T(*query)(const ROMol &, const Atom *), bool sanitizeFrags=true, const std::vector< T > *whiteList=nullptr, bool negateList=false)
 splits a molecule into pieces based on labels assigned using a query
 
template<typename T >
RDKIT_GRAPHMOL_EXPORT unsigned int RDKit::MolOps::getMolFragsWithQuery (const ROMol &mol, T(*query)(const ROMol &, const Atom *), std::map< T, std::unique_ptr< ROMol > > &molFrags, bool sanitizeFrags=true, const std::vector< T > *whiteList=nullptr, bool negateList=false)
 
RDKIT_GRAPHMOL_EXPORT unsigned RDKit::MolOps::getNumAtomsWithDistinctProperty (const ROMol &mol, std::string prop)
 returns the number of atoms which have a particular property set
 
RDKIT_GRAPHMOL_EXPORT bool RDKit::MolOps::needsHs (const ROMol &mol)
 returns whether or not a molecule needs to have Hs added to it.
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::hapticBondsToDative (const ROMol &mol)
 Replaces haptic bond with explicit dative bonds.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::hapticBondsToDative (RWMol &mol)
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::dativeBondsToHaptic (const ROMol &mol)
 Replaces explicit dative bonds with haptic.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::dativeBondsToHaptic (RWMol &mol)
 
RDKIT_GRAPHMOL_EXPORT double RDKit::MolOps::getAvgMolWt (const ROMol &mol, bool onlyHeavy=false)
 
RDKIT_GRAPHMOL_EXPORT double RDKit::MolOps::getExactMolWt (const ROMol &mol, bool onlyHeavy=false)
 
RDKIT_GRAPHMOL_EXPORT std::string RDKit::MolOps::getMolFormula (const ROMol &mol, bool separateIsotopes=false, bool abbreviateHIsotopes=true)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::expandAttachmentPoints (RWMol &mol, bool addAsQueries=true, bool addCoords=true)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::collapseAttachmentPoints (RWMol &mol, bool markedOnly=true)
 
Ring finding and SSSR
RDKIT_GRAPHMOL_EXPORT int RDKit::MolOps::findSSSR (const ROMol &mol, std::vector< std::vector< int > > &res, bool includeDativeBonds=false)
 finds a molecule's Smallest Set of Smallest Rings
 
RDKIT_GRAPHMOL_EXPORT int RDKit::MolOps::findSSSR (const ROMol &mol, std::vector< std::vector< int > > *res=nullptr, bool includeDativeBonds=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::fastFindRings (const ROMol &mol)
 use a DFS algorithm to identify ring bonds and atoms in a molecule
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::findRingFamilies (const ROMol &mol)
 
RDKIT_GRAPHMOL_EXPORT int RDKit::MolOps::symmetrizeSSSR (ROMol &mol, std::vector< std::vector< int > > &res, bool includeDativeBonds=false)
 symmetrize the molecule's Smallest Set of Smallest Rings
 
RDKIT_GRAPHMOL_EXPORT int RDKit::MolOps::symmetrizeSSSR (ROMol &mol, bool includeDativeBonds=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
Shortest paths and other matrices
RDKIT_GRAPHMOL_EXPORT doubleRDKit::MolOps::getAdjacencyMatrix (const ROMol &mol, bool useBO=false, int emptyVal=0, bool force=false, const char *propNamePrefix=nullptr, const boost::dynamic_bitset<> *bondsToUse=nullptr)
 returns a molecule's adjacency matrix
 
RDKIT_GRAPHMOL_EXPORT doubleRDKit::MolOps::getDistanceMat (const ROMol &mol, bool useBO=false, bool useAtomWts=false, bool force=false, const char *propNamePrefix=nullptr)
 Computes the molecule's topological distance matrix.
 
RDKIT_GRAPHMOL_EXPORT doubleRDKit::MolOps::getDistanceMat (const ROMol &mol, const std::vector< int > &activeAtoms, const std::vector< const Bond * > &bonds, bool useBO=false, bool useAtomWts=false)
 Computes the molecule's topological distance matrix.
 
RDKIT_GRAPHMOL_EXPORT doubleRDKit::MolOps::get3DDistanceMat (const ROMol &mol, int confId=-1, bool useAtomWts=false, bool force=false, const char *propNamePrefix=nullptr)
 Computes the molecule's 3D distance matrix.
 
RDKIT_GRAPHMOL_EXPORT std::list< intRDKit::MolOps::getShortestPath (const ROMol &mol, int aid1, int aid2)
 Find the shortest path between two atoms.
 
Stereochemistry
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::cleanupChirality (RWMol &mol)
 removes bogus chirality markers (e.g. tetrahedral flags on non-sp3 centers):
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::cleanupAtropisomers (RWMol &)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::cleanupAtropisomers (RWMol &mol, Hybridizations &hybridizations)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::assignChiralTypesFrom3D (ROMol &mol, int confId=-1, bool replaceExistingTags=true)
 Uses a conformer to assign ChiralTypes to a molecule's atoms.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::assignStereochemistryFrom3D (ROMol &mol, int confId=-1, bool replaceExistingTags=true)
 Uses a conformer to assign ChiralTypes to a molecule's atoms and stereo flags to its bonds.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::assignChiralTypesFromBondDirs (ROMol &mol, int confId=-1, bool replaceExistingTags=true)
 Use bond directions to assign ChiralTypes to a molecule's atoms and stereo flags to its bonds.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::detectBondStereochemistry (ROMol &mol, int confId=-1)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::setDoubleBondNeighborDirections (ROMol &mol, const Conformer *conf=nullptr)
 Sets bond directions based on double bond stereochemistry.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::clearSingleBondDirFlags (ROMol &mol, bool onlyWedgeFlags=false)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::clearAllBondDirFlags (ROMol &mol)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::clearDirFlags (ROMol &mol, bool onlyWedgeFlags=false)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::setBondStereoFromDirections (ROMol &mol)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::assignStereochemistry (ROMol &mol, bool cleanIt=false, bool force=false, bool flagPossibleStereoCenters=false)
 Assign stereochemistry tags to atoms and bonds.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::removeStereochemistry (ROMol &mol)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::findPotentialStereoBonds (ROMol &mol, bool cleanIt=false)
 finds bonds that could be cis/trans in a molecule and mark them as Bond::STEREOANY.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::assignChiralTypesFromMolParity (ROMol &mol, bool replaceExistingTags=true)
 Uses the molParity atom property to assign ChiralType to a molecule's atoms.
 

Variables

RDKIT_GRAPHMOL_EXPORT const int ci_LOCAL_INF
 

Dealing with hydrogens

enum  RDKit::MolOps::AdjustQueryWhichFlags {
  RDKit::MolOps::ADJUST_IGNORENONE = 0x0 , RDKit::MolOps::ADJUST_IGNORECHAINS = 0x1 , RDKit::MolOps::ADJUST_IGNORERINGS = 0x4 , RDKit::MolOps::ADJUST_IGNOREDUMMIES = 0x2 ,
  RDKit::MolOps::ADJUST_IGNORENONDUMMIES = 0x8 , RDKit::MolOps::ADJUST_IGNOREMAPPED = 0x10 , RDKit::MolOps::ADJUST_IGNOREALL = 0xFFFFFFF
}
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::addHs (const ROMol &mol, bool explicitOnly=false, bool addCoords=false, const UINT_VECT *onlyOnAtoms=nullptr, bool addResidueInfo=false)
 returns a copy of a molecule with hydrogens added in as explicit Atoms
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::addHs (RWMol &mol, bool explicitOnly=false, bool addCoords=false, const UINT_VECT *onlyOnAtoms=nullptr, bool addResidueInfo=false)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::setTerminalAtomCoords (ROMol &mol, unsigned int idx, unsigned int otherIdx)
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::removeHs (const ROMol &mol, bool implicitOnly=false, bool updateExplicitCount=false, bool sanitize=true)
 returns a copy of a molecule with hydrogens removed
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::removeHs (RWMol &mol, bool implicitOnly=false, bool updateExplicitCount=false, bool sanitize=true)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::removeHs (RWMol &mol, const RemoveHsParameters &ps, bool sanitize=true)
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::removeHs (const ROMol &mol, const RemoveHsParameters &ps, bool sanitize=true)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::removeAllHs (RWMol &mol, bool sanitize=true)
 removes all Hs from a molecule
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::removeAllHs (const ROMol &mol, bool sanitize=true)
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::mergeQueryHs (const ROMol &mol, bool mergeUnmappedOnly=false, bool mergeIsotopes=false)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::mergeQueryHs (RWMol &mol, bool mergeUnmappedOnly=false, bool mergeIsotopes=false)
 
RDKIT_GRAPHMOL_EXPORT std::pair< bool, boolRDKit::MolOps::hasQueryHs (const ROMol &mol)
 returns a pair of booleans (hasQueryHs, hasUnmergaebleQueryHs)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::parseAdjustQueryParametersFromJSON (MolOps::AdjustQueryParameters &p, const std::string &json)
 updates an AdjustQueryParameters object from a JSON string
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::adjustQueryProperties (const ROMol &mol, const AdjustQueryParameters *params=nullptr)
 returns a copy of a molecule with query properties adjusted
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::adjustQueryProperties (RWMol &mol, const AdjustQueryParameters *params=nullptr)
 
RDKIT_GRAPHMOL_EXPORT ROMolRDKit::MolOps::renumberAtoms (const ROMol &mol, const std::vector< unsigned int > &newOrder)
 returns a copy of a molecule with the atoms renumbered
 

Sanitization

{

enum  RDKit::MolOps::SanitizeFlags {
  RDKit::MolOps::SANITIZE_NONE = 0x0 , RDKit::MolOps::SANITIZE_CLEANUP = 0x1 , RDKit::MolOps::SANITIZE_PROPERTIES = 0x2 , RDKit::MolOps::SANITIZE_SYMMRINGS = 0x4 ,
  RDKit::MolOps::SANITIZE_KEKULIZE = 0x8 , RDKit::MolOps::SANITIZE_FINDRADICALS = 0x10 , RDKit::MolOps::SANITIZE_SETAROMATICITY = 0x20 , RDKit::MolOps::SANITIZE_SETCONJUGATION = 0x40 ,
  RDKit::MolOps::SANITIZE_SETHYBRIDIZATION = 0x80 , RDKit::MolOps::SANITIZE_CLEANUPCHIRALITY = 0x100 , RDKit::MolOps::SANITIZE_ADJUSTHS = 0x200 , RDKit::MolOps::SANITIZE_CLEANUP_ORGANOMETALLICS = 0x400 ,
  RDKit::MolOps::SANITIZE_CLEANUPATROPISOMERS = 0x800 , RDKit::MolOps::SANITIZE_ALL = 0xFFFFFFF
}
 
enum  RDKit::MolOps::AromaticityModel {
  RDKit::MolOps::AROMATICITY_DEFAULT = 0x0 , RDKit::MolOps::AROMATICITY_RDKIT = 0x1 , RDKit::MolOps::AROMATICITY_SIMPLE = 0x2 , RDKit::MolOps::AROMATICITY_MDL = 0x4 ,
  RDKit::MolOps::AROMATICITY_MMFF94 = 0x8 , RDKit::MolOps::AROMATICITY_CUSTOM = 0xFFFFFFF
}
 Possible aromaticity models. More...
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::sanitizeMol (RWMol &mol, unsigned int &operationThatFailed, unsigned int sanitizeOps=SANITIZE_ALL)
 carries out a collection of tasks for cleaning up a molecule and ensuring that it makes "chemical sense"
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::sanitizeMol (RWMol &mol)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
RDKIT_GRAPHMOL_EXPORT std::vector< std::unique_ptr< MolSanitizeException > > RDKit::MolOps::detectChemistryProblems (const ROMol &mol, unsigned int sanitizeOps=SANITIZE_ALL)
 Identifies chemistry problems (things that don't make chemical sense) in a molecule.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::setMMFFAromaticity (RWMol &mol)
 
RDKIT_GRAPHMOL_EXPORT int RDKit::MolOps::setAromaticity (RWMol &mol, AromaticityModel model=AROMATICITY_DEFAULT, int(*func)(RWMol &)=nullptr)
 Sets up the aromaticity for a molecule.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::cleanUp (RWMol &mol)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::cleanUpOrganometallics (RWMol &mol)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::assignRadicals (RWMol &mol)
 Called by the sanitizer to assign radical counts to atoms.
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::adjustHs (RWMol &mol)
 adjust the number of implicit and explicit Hs for special cases
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::Kekulize (RWMol &mol, bool markAtomsBonds=true, unsigned int maxBackTracks=100)
 Kekulizes the molecule.
 
RDKIT_GRAPHMOL_EXPORT bool RDKit::MolOps::KekulizeIfPossible (RWMol &mol, bool markAtomsBonds=true, unsigned int maxBackTracks=100)
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::setConjugation (ROMol &mol)
 flags the molecule's conjugated bonds
 
RDKIT_GRAPHMOL_EXPORT void RDKit::MolOps::setHybridization (ROMol &mol)
 calculates and sets the hybridization of all a molecule's Stoms
 

Variable Documentation

◆ ci_LOCAL_INF

RDKIT_GRAPHMOL_EXPORT const int ci_LOCAL_INF
extern