RDKit: SmilesParseOps.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
SmilesParseOps.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2022 Greg Landrum and other RDKit contributors
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <string_view>
11
12#include <RDGeneral/export.h>
13#ifndef RD_SMILESPARSEOPS_H
14#define RD_SMILESPARSEOPS_H
15#include <GraphMol/Bond.h>
16
17namespace RDKit {
18class RWMol;
19class Atom;
20class QueryBond;
21} // namespace RDKit
22 namespace SmilesParseOps {
23 RDKIT_SMILESPARSE_EXPORT void CheckRingClosureBranchStatus(RDKit::Atom *atom,
24 RDKit::RWMol *mp);
25 RDKIT_SMILESPARSE_EXPORT void ReportParseError(const char *message,
26 bool throwIt = true);
27 RDKIT_SMILESPARSE_EXPORT void CleanupAfterParseError(RDKit::RWMol *mol);
28// This uses SMARTS semantics: unspecified bonds are treated as
29// aromatic or single.
30 RDKIT_SMILESPARSE_EXPORT void AddFragToMol(
31 RDKit::RWMol *mol, RDKit::RWMol *frag,
32 RDKit::Bond::BondType bondOrder = RDKit::Bond::UNSPECIFIED,
33 RDKit::Bond::BondDir bondDir = RDKit::Bond::NONE);
34 RDKIT_SMILESPARSE_EXPORT RDKit::Bond::BondType GetUnspecifiedBondType(
35 const RDKit::RWMol *mol, const RDKit::Atom *atom1,
36 const RDKit::Atom *atom2);
37 RDKIT_SMILESPARSE_EXPORT void CheckChiralitySpecifications(RDKit::RWMol *mol,
38 bool strict);
39 RDKIT_SMILESPARSE_EXPORT void CloseMolRings(RDKit::RWMol *mol,
40 bool toleratePartials);
41 RDKIT_SMILESPARSE_EXPORT void SetUnspecifiedBondTypes(RDKit::RWMol *mol);
42 RDKIT_SMILESPARSE_EXPORT void AdjustAtomChiralityFlags(RDKit::RWMol *mol);
43 RDKIT_SMILESPARSE_EXPORT void CleanupAfterParsing(RDKit::RWMol *mol);
44 RDKIT_SMILESPARSE_EXPORT void parseCXExtensions(
45 RDKit::RWMol &mol, const std::string &extText,
46 std::string::const_iterator &pos, unsigned int startAtomIdx = 0,
47 unsigned int startBondIdx = 0);
48 inline void parseCXExtensions(RDKit::RWMol &mol, const std::string &extText,
49 unsigned int startAtomIdx,
50 unsigned int startBondIdx) {
51 auto iter = extText.begin();
52 parseCXExtensions(mol, extText, iter, startAtomIdx, startBondIdx);
53};
54//! removes formal charge, isotope, etc. Primarily useful for QueryAtoms
55 RDKIT_SMILESPARSE_EXPORT void ClearAtomChemicalProps(RDKit::Atom *atom);
56
57//! returns whether or not the combination of tag and permutation provided are
58//! legal
59 RDKIT_SMILESPARSE_EXPORT bool checkChiralPermutation(int chiralTag,
60 int permutation);
61
62//! this is a bit of a hack to try and get nicer "SMILES" from
63//! a SMARTS molecule
64 RDKIT_SMILESPARSE_EXPORT RDKit::QueryBond *getUnspecifiedQueryBond(
65 const RDKit::Atom *a1, const RDKit::Atom *a2);
66
67 namespace detail {
68 constexpr auto _needsDetectBondStereo = "_needsDetectBondStereo";
69 constexpr auto _needsDetectAtomStereo = "_needsDetectAtomStereo";
70
71 void printSyntaxErrorMessage(std::string_view input,
72 std::string_view err_message,
73 unsigned int bad_token_position,
74 std::string_view input_type);
75} // namespace detail
76} // namespace SmilesParseOps
77
78#endif
Bond.h
RDKit::Atom
The class for representing atoms.
Definition Atom.h:74
RDKit::Bond::BondType
BondType
the type of Bond
Definition Bond.h:55
RDKit::Bond::UNSPECIFIED
@ UNSPECIFIED
Definition Bond.h:56
RDKit::Bond::BondDir
BondDir
the bond's direction (for chirality)
Definition Bond.h:82
RDKit::Bond::NONE
@ NONE
no special style
Definition Bond.h:83
RDKit::QueryBond
Class for storing Bond queries.
Definition QueryBond.h:28
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_SMILESPARSE_EXPORT
#define RDKIT_SMILESPARSE_EXPORT
Definition export.h:537
RDKit
Std stuff.
Definition Abbreviations.h:19
SmilesParseOps::detail
Definition SmilesParseOps.h:67
SmilesParseOps::detail::printSyntaxErrorMessage
void printSyntaxErrorMessage(std::string_view input, std::string_view err_message, unsigned int bad_token_position, std::string_view input_type)
SmilesParseOps::detail::_needsDetectBondStereo
constexpr auto _needsDetectBondStereo
Definition SmilesParseOps.h:68
SmilesParseOps::detail::_needsDetectAtomStereo
constexpr auto _needsDetectAtomStereo
Definition SmilesParseOps.h:69
SmilesParseOps
Definition SmilesParseOps.h:22
SmilesParseOps::CheckChiralitySpecifications
RDKIT_SMILESPARSE_EXPORT void CheckChiralitySpecifications(RDKit::RWMol *mol, bool strict)
SmilesParseOps::CloseMolRings
RDKIT_SMILESPARSE_EXPORT void CloseMolRings(RDKit::RWMol *mol, bool toleratePartials)
SmilesParseOps::getUnspecifiedQueryBond
RDKIT_SMILESPARSE_EXPORT RDKit::QueryBond * getUnspecifiedQueryBond(const RDKit::Atom *a1, const RDKit::Atom *a2)
SmilesParseOps::checkChiralPermutation
RDKIT_SMILESPARSE_EXPORT bool checkChiralPermutation(int chiralTag, int permutation)
SmilesParseOps::ClearAtomChemicalProps
RDKIT_SMILESPARSE_EXPORT void ClearAtomChemicalProps(RDKit::Atom *atom)
removes formal charge, isotope, etc. Primarily useful for QueryAtoms
SmilesParseOps::parseCXExtensions
RDKIT_SMILESPARSE_EXPORT void parseCXExtensions(RDKit::RWMol &mol, const std::string &extText, std::string::const_iterator &pos, unsigned int startAtomIdx=0, unsigned int startBondIdx=0)
SmilesParseOps::ReportParseError
RDKIT_SMILESPARSE_EXPORT void ReportParseError(const char *message, bool throwIt=true)
SmilesParseOps::SetUnspecifiedBondTypes
RDKIT_SMILESPARSE_EXPORT void SetUnspecifiedBondTypes(RDKit::RWMol *mol)
SmilesParseOps::AddFragToMol
RDKIT_SMILESPARSE_EXPORT void AddFragToMol(RDKit::RWMol *mol, RDKit::RWMol *frag, RDKit::Bond::BondType bondOrder=RDKit::Bond::UNSPECIFIED, RDKit::Bond::BondDir bondDir=RDKit::Bond::NONE)
SmilesParseOps::CleanupAfterParseError
RDKIT_SMILESPARSE_EXPORT void CleanupAfterParseError(RDKit::RWMol *mol)
SmilesParseOps::AdjustAtomChiralityFlags
RDKIT_SMILESPARSE_EXPORT void AdjustAtomChiralityFlags(RDKit::RWMol *mol)
SmilesParseOps::CheckRingClosureBranchStatus
RDKIT_SMILESPARSE_EXPORT void CheckRingClosureBranchStatus(RDKit::Atom *atom, RDKit::RWMol *mp)
SmilesParseOps::GetUnspecifiedBondType
RDKIT_SMILESPARSE_EXPORT RDKit::Bond::BondType GetUnspecifiedBondType(const RDKit::RWMol *mol, const RDKit::Atom *atom1, const RDKit::Atom *atom2)
SmilesParseOps::CleanupAfterParsing
RDKIT_SMILESPARSE_EXPORT void CleanupAfterParsing(RDKit::RWMol *mol)