Loading...
Searching...
No Matches
Abbreviations.h
Go to the documentation of this file.
//
// Copyright (C) 2020 Greg Landrum and T5 Informatics GmbH
//
// @@ 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 <RDGeneral/export.h>
#ifndef RD_ABBREVIATIONS_H
#define RD_ABBREVIATIONS_H
#include <GraphMol/Substruct/SubstructMatch.h>
#include <utility>
#include <vector>
#include <string>
#include <memory>
namespace RDKit {
class ROMol;
class RWMol;
namespace Abbreviations {
struct RDKIT_ABBREVIATIONS_EXPORT AbbreviationDefinition {
std::string label;
std::string displayLabel;
std::string displayLabelW;
std::string smarts;
std::shared_ptr<ROMol> mol; //!< optional
std::vector<unsigned int> extraAttachAtoms; //!< optional
bool operator==(const AbbreviationDefinition &other) const {
return label == other.label && displayLabel == other.displayLabel &&
displayLabelW == other.displayLabelW && smarts == other.smarts;
}
bool operator!=(const AbbreviationDefinition &other) const {
return !(*this == other);
}
};
struct RDKIT_ABBREVIATIONS_EXPORT AbbreviationMatch {
MatchVectType match;
AbbreviationDefinition abbrev;
AbbreviationMatch(std::vector<std::pair<int, int>> matchArg,
AbbreviationDefinition abbrevArg)
: match(std::move(matchArg)), abbrev(std::move(abbrevArg)) {}
AbbreviationMatch() : match(), abbrev() {}
bool operator==(const AbbreviationMatch &other) const {
return abbrev == other.abbrev && match == other.match;
}
bool operator!=(const AbbreviationMatch &other) const {
return !(*this == other);
}
};
namespace common_properties {
RDKIT_ABBREVIATIONS_EXPORT extern const std::string numDummies;
RDKIT_ABBREVIATIONS_EXPORT extern const std::string origAtomMapping;
RDKIT_ABBREVIATIONS_EXPORT extern const std::string origBondMapping;
} // namespace common_properties
namespace Utils {
//! returns the default set of abbreviation definitions
RDKIT_ABBREVIATIONS_EXPORT std::vector<AbbreviationDefinition>
getDefaultAbbreviations();
//! returns the default set of linker definitions
RDKIT_ABBREVIATIONS_EXPORT std::vector<AbbreviationDefinition>
getDefaultLinkers();
//! parses a string describing abbreviation matches and returns the result
/*
\param text the data to be parsed, see below for the format
\param removeExtraDummies controls whether or not dummy atoms beyond atom 0 are
removed. Set this to true to create abbreviations for linkers
\param allowConnectionToDummies allows abbreviations to directly connect to
abbreviations. set this to true for linkers
Format of the text data:
A series of lines, each of which contains:
label SMARTS displayLabel displayLabelW
the "displayLabel" and "displayLabelW" fields are optional.
where label is the label used for the abbreviation,
SMARTS is the SMARTS definition of the abbreviation.
displayLabel is used in drawings to render the abbreviations.
displayLabelW is the display label if a bond comes in from the right
Use dummies to indicate attachment points. The assumption is that the first
atom is a dummy (one will be added if this is not true) and that the second
atom is the surrogate for the rest of the group.
*/
RDKIT_ABBREVIATIONS_EXPORT std::vector<AbbreviationDefinition>
parseAbbreviations(const std::string &text, bool removeExtraDummies = false,
bool allowConnectionToDummies = false);
//! \brief equivalent to calling \c parseAbbreviations(text,true,true)
inline std::vector<AbbreviationDefinition> parseLinkers(
const std::string &text) {
return parseAbbreviations(text, true, true);
};
} // namespace Utils
//! returns all matches for the abbreviations across the molecule
/*!
\param abbrevs the abbreviations to look for. This list is used in order.
\param maxCoverage any abbreviation that covers than more than this fraction
of the molecule's atoms (not counting dummies) will not be returned.
*/
RDKIT_ABBREVIATIONS_EXPORT std::vector<AbbreviationMatch>
findApplicableAbbreviationMatches(
const ROMol &mol, const std::vector<AbbreviationDefinition> &abbrevs,
double maxCoverage = 0.4);
//! applies the abbreviation matches to a molecule, modifying it in place.
//! the modified molecule is not sanitized
RDKIT_ABBREVIATIONS_EXPORT void applyMatches(
RWMol &mol, const std::vector<AbbreviationMatch> &matches);
//! creates "SUP" SubstanceGroups on the molecule describing the abbreviation
RDKIT_ABBREVIATIONS_EXPORT void labelMatches(
RWMol &mol, const std::vector<AbbreviationMatch> &matches);
//! convenience function for finding and applying abbreviations
//! the modified molecule is not sanitized
RDKIT_ABBREVIATIONS_EXPORT void condenseMolAbbreviations(
RWMol &mol, const std::vector<AbbreviationDefinition> &abbrevs,
double maxCoverage = 0.4, bool sanitize = true);
//! convenience function for finding and labeling abbreviations as SUP
//! SubstanceGroups
RDKIT_ABBREVIATIONS_EXPORT void labelMolAbbreviations(
RWMol &mol, const std::vector<AbbreviationDefinition> &abbrevs,
double maxCoverage = 0.4);
//! collapses abbreviation (i.e. "SUP") substance groups
//! the modified molecule is not sanitized
RDKIT_ABBREVIATIONS_EXPORT void condenseAbbreviationSubstanceGroups(RWMol &mol);
} // namespace Abbreviations
} // namespace RDKit
#endif
SubstructMatch.h
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_ABBREVIATIONS_EXPORT
#define RDKIT_ABBREVIATIONS_EXPORT
Definition export.h:9
RDKit::Abbreviations::Utils::parseLinkers
std::vector< AbbreviationDefinition > parseLinkers(const std::string &text)
equivalent to calling parseAbbreviations(text,true,true)
Definition Abbreviations.h:95
RDKit::Abbreviations::Utils::getDefaultLinkers
RDKIT_ABBREVIATIONS_EXPORT std::vector< AbbreviationDefinition > getDefaultLinkers()
returns the default set of linker definitions
RDKit::Abbreviations::Utils::parseAbbreviations
RDKIT_ABBREVIATIONS_EXPORT std::vector< AbbreviationDefinition > parseAbbreviations(const std::string &text, bool removeExtraDummies=false, bool allowConnectionToDummies=false)
parses a string describing abbreviation matches and returns the result
RDKit::Abbreviations::Utils::getDefaultAbbreviations
RDKIT_ABBREVIATIONS_EXPORT std::vector< AbbreviationDefinition > getDefaultAbbreviations()
returns the default set of abbreviation definitions
RDKit::Abbreviations::common_properties::origAtomMapping
RDKIT_ABBREVIATIONS_EXPORT const std::string origAtomMapping
RDKit::Abbreviations::common_properties::origBondMapping
RDKIT_ABBREVIATIONS_EXPORT const std::string origBondMapping
RDKit::Abbreviations::common_properties::numDummies
RDKIT_ABBREVIATIONS_EXPORT const std::string numDummies
RDKit::Abbreviations::applyMatches
RDKIT_ABBREVIATIONS_EXPORT void applyMatches(RWMol &mol, const std::vector< AbbreviationMatch > &matches)
RDKit::Abbreviations::condenseAbbreviationSubstanceGroups
RDKIT_ABBREVIATIONS_EXPORT void condenseAbbreviationSubstanceGroups(RWMol &mol)
RDKit::Abbreviations::labelMolAbbreviations
RDKIT_ABBREVIATIONS_EXPORT void labelMolAbbreviations(RWMol &mol, const std::vector< AbbreviationDefinition > &abbrevs, double maxCoverage=0.4)
RDKit::Abbreviations::condenseMolAbbreviations
RDKIT_ABBREVIATIONS_EXPORT void condenseMolAbbreviations(RWMol &mol, const std::vector< AbbreviationDefinition > &abbrevs, double maxCoverage=0.4, bool sanitize=true)
RDKit::Abbreviations::labelMatches
RDKIT_ABBREVIATIONS_EXPORT void labelMatches(RWMol &mol, const std::vector< AbbreviationMatch > &matches)
creates "SUP" SubstanceGroups on the molecule describing the abbreviation
RDKit::Abbreviations::findApplicableAbbreviationMatches
RDKIT_ABBREVIATIONS_EXPORT std::vector< AbbreviationMatch > findApplicableAbbreviationMatches(const ROMol &mol, const std::vector< AbbreviationDefinition > &abbrevs, double maxCoverage=0.4)
returns all matches for the abbreviations across the molecule
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::MatchVectType
std::vector< std::pair< int, int > > MatchVectType
used to return matches from substructure searching, The format is (queryAtomIdx, molAtomIdx)
Definition FragFPGenerator.h:24
RDKit::rdvalue_is
bool rdvalue_is(const RDValue_cast_t)
Definition RDValue-doublemagic.h:372
RDKit::Abbreviations::AbbreviationDefinition
Definition Abbreviations.h:24
RDKit::Abbreviations::AbbreviationDefinition::extraAttachAtoms
std::vector< unsigned int > extraAttachAtoms
optional
Definition Abbreviations.h:30
RDKit::Abbreviations::AbbreviationDefinition::operator==
bool operator==(const AbbreviationDefinition &other) const
Definition Abbreviations.h:31
RDKit::Abbreviations::AbbreviationDefinition::mol
std::shared_ptr< ROMol > mol
optional
Definition Abbreviations.h:29
RDKit::Abbreviations::AbbreviationDefinition::label
std::string label
Definition Abbreviations.h:25
RDKit::Abbreviations::AbbreviationDefinition::operator!=
bool operator!=(const AbbreviationDefinition &other) const
Definition Abbreviations.h:35
RDKit::Abbreviations::AbbreviationDefinition::smarts
std::string smarts
Definition Abbreviations.h:28
RDKit::Abbreviations::AbbreviationDefinition::displayLabel
std::string displayLabel
Definition Abbreviations.h:26
RDKit::Abbreviations::AbbreviationDefinition::displayLabelW
std::string displayLabelW
Definition Abbreviations.h:27
RDKit::Abbreviations::AbbreviationMatch
Definition Abbreviations.h:39
RDKit::Abbreviations::AbbreviationMatch::AbbreviationMatch
AbbreviationMatch(std::vector< std::pair< int, int > > matchArg, AbbreviationDefinition abbrevArg)
Definition Abbreviations.h:42
RDKit::Abbreviations::AbbreviationMatch::operator!=
bool operator!=(const AbbreviationMatch &other) const
Definition Abbreviations.h:49
RDKit::Abbreviations::AbbreviationMatch::AbbreviationMatch
AbbreviationMatch()
Definition Abbreviations.h:45
RDKit::Abbreviations::AbbreviationMatch::match
MatchVectType match
Definition Abbreviations.h:40
RDKit::Abbreviations::AbbreviationMatch::abbrev
AbbreviationDefinition abbrev
Definition Abbreviations.h:41
RDKit::Abbreviations::AbbreviationMatch::operator==
bool operator==(const AbbreviationMatch &other) const
Definition Abbreviations.h:46