mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
implement hasPrimaryLabel (#9052)
This commit is contained in:
committed by
greg landrum
parent
03074d3b6e
commit
0402ea6792
@@ -178,7 +178,7 @@ void label(std::vector<std::unique_ptr<Configuration>> &configs,
|
||||
// resolved.
|
||||
for (auto &conf : configs) {
|
||||
// Make sure this stereo center has no label
|
||||
conf->getFocus()->clearProp(common_properties::_CIPCode);
|
||||
conf->resetPrimaryLabel();
|
||||
|
||||
remainingCallCount = constitutionalRuleTimeout;
|
||||
try {
|
||||
@@ -200,7 +200,7 @@ void label(std::vector<std::unique_ptr<Configuration>> &configs,
|
||||
|
||||
// try again on everything that hasn't been resolved yet
|
||||
for (const auto &conf : configs) {
|
||||
if (conf->getFocus()->hasProp(common_properties::_CIPCode)) {
|
||||
if (conf->hasPrimaryLabel()) {
|
||||
// already resolved!
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
//
|
||||
#include <GraphMol/Chirality.h>
|
||||
#include <GraphMol/Atropisomers.h>
|
||||
#include <RDGeneral/types.h>
|
||||
|
||||
#include "AtropisomerBond.h"
|
||||
#include "../Sort.h"
|
||||
@@ -47,9 +48,6 @@ void AtropisomerBond::setPrimaryLabel(Descriptor desc) {
|
||||
case Descriptor::P:
|
||||
case Descriptor::m:
|
||||
case Descriptor::p: {
|
||||
auto carriers = getCarriers();
|
||||
// dp_bond->setStereoAtoms(carriers[0]->getIdx(), carriers[1]->getIdx());
|
||||
// dp_bond->setStereo(d_cfg);
|
||||
dp_bond->setProp(common_properties::_CIPCode, to_string(desc));
|
||||
return;
|
||||
}
|
||||
@@ -71,6 +69,14 @@ void AtropisomerBond::setPrimaryLabel(Descriptor desc) {
|
||||
}
|
||||
}
|
||||
|
||||
bool AtropisomerBond::hasPrimaryLabel() const {
|
||||
return dp_bond->hasProp(common_properties::_CIPCode);
|
||||
}
|
||||
|
||||
void AtropisomerBond::resetPrimaryLabel() const {
|
||||
dp_bond->clearProp(common_properties::_CIPCode);
|
||||
}
|
||||
|
||||
Descriptor AtropisomerBond::label(const Rules &comp) {
|
||||
auto &digraph = getDigraph();
|
||||
auto root1 = digraph.getOriginalRoot();
|
||||
|
||||
@@ -24,6 +24,10 @@ class AtropisomerBond : public Configuration {
|
||||
|
||||
void setPrimaryLabel(Descriptor desc) override;
|
||||
|
||||
bool hasPrimaryLabel() const override;
|
||||
|
||||
void resetPrimaryLabel() const override;
|
||||
|
||||
Descriptor label(const Rules &comp) override;
|
||||
|
||||
Descriptor label(Node *root1, Digraph &digraph, const Rules &comp) override;
|
||||
@@ -34,8 +38,7 @@ class AtropisomerBond : public Configuration {
|
||||
// bond->getStereo() can return both E/Z or CIS/TRANS,
|
||||
// so we cache CIS/TRANS we found.
|
||||
Bond::BondStereo d_cfg;
|
||||
|
||||
}; // namespace CIPLabeler
|
||||
};
|
||||
|
||||
} // namespace CIPLabeler
|
||||
} // namespace RDKit
|
||||
|
||||
@@ -180,6 +180,10 @@ class Configuration {
|
||||
|
||||
virtual void setPrimaryLabel(Descriptor desc) = 0;
|
||||
|
||||
virtual bool hasPrimaryLabel() const = 0;
|
||||
|
||||
virtual void resetPrimaryLabel() const = 0;
|
||||
|
||||
protected:
|
||||
Edge *findInternalEdge(const std::vector<Edge *> &edges, Atom *f1, Atom *f2);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
// of the RDKit source tree.
|
||||
//
|
||||
#include <GraphMol/Chirality.h>
|
||||
#include <RDGeneral/types.h>
|
||||
|
||||
#include "Sp2Bond.h"
|
||||
#include "../Sort.h"
|
||||
@@ -63,6 +64,14 @@ void Sp2Bond::setPrimaryLabel(Descriptor desc) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Sp2Bond::hasPrimaryLabel() const {
|
||||
return dp_bond->hasProp(common_properties::_CIPCode);
|
||||
}
|
||||
|
||||
void Sp2Bond::resetPrimaryLabel() const {
|
||||
dp_bond->clearProp(common_properties::_CIPCode);
|
||||
}
|
||||
|
||||
Descriptor Sp2Bond::label(const Rules &comp) {
|
||||
auto &digraph = getDigraph();
|
||||
auto root1 = digraph.getOriginalRoot();
|
||||
|
||||
@@ -24,6 +24,10 @@ class Sp2Bond : public Configuration {
|
||||
|
||||
void setPrimaryLabel(Descriptor desc) override;
|
||||
|
||||
bool hasPrimaryLabel() const override;
|
||||
|
||||
void resetPrimaryLabel() const override;
|
||||
|
||||
Descriptor label(const Rules &comp) override;
|
||||
|
||||
Descriptor label(Node *root1, Digraph &digraph, const Rules &comp) override;
|
||||
@@ -34,8 +38,7 @@ class Sp2Bond : public Configuration {
|
||||
// bond->getStereo() can return both E/Z or CIS/TRANS,
|
||||
// so we cache CIS/TRANS we found.
|
||||
Bond::BondStereo d_cfg;
|
||||
|
||||
}; // namespace CIPLabeler
|
||||
};
|
||||
|
||||
} // namespace CIPLabeler
|
||||
} // namespace RDKit
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
// which is included in the file license.txt, found at the root
|
||||
// of the RDKit source tree.
|
||||
//
|
||||
#include <RDGeneral/types.h>
|
||||
|
||||
#include "Tetrahedral.h"
|
||||
#include "../rules/Rules.h"
|
||||
@@ -68,6 +69,14 @@ void Tetrahedral::setPrimaryLabel(Descriptor desc) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Tetrahedral::hasPrimaryLabel() const {
|
||||
return getFocus()->hasProp(common_properties::_CIPCode);
|
||||
}
|
||||
|
||||
void Tetrahedral::resetPrimaryLabel() const {
|
||||
getFocus()->clearProp(common_properties::_CIPCode);
|
||||
}
|
||||
|
||||
Descriptor Tetrahedral::label(const Rules &comp) {
|
||||
auto &digraph = getDigraph();
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@ class Tetrahedral : public Configuration {
|
||||
|
||||
void setPrimaryLabel(Descriptor desc) override;
|
||||
|
||||
bool hasPrimaryLabel() const override;
|
||||
|
||||
void resetPrimaryLabel() const override;
|
||||
|
||||
Descriptor label(const Rules &comp) override;
|
||||
|
||||
Descriptor label(Node *node, Digraph &digraph, const Rules &comp) override;
|
||||
|
||||
Reference in New Issue
Block a user