5 #ifndef BALL_STRUCTURE_SMARTES_PARSER_H
6 #define BALL_STRUCTURE_SMARTES_PARSER_H
50 CHIRAL_CLASS_UNSPECIFIED = 1,
161 void setNot(
bool is_not) { not_ = is_not; }
433 bool isNot()
const {
return is_not_; }
436 void setNot(
bool is_not) { is_not_ = is_not; }
564 void setNot(
bool is_not) { is_not_ = is_not; }
679 void setSSSR(
const std::vector<std::vector<Atom*> >& sssr);
711 const std::set<SPNode*>&
getNodes()
const {
return nodes_; }
714 const std::set<SPEdge*>&
getEdges()
const {
return edges_; }
744 static vector<std::set<const Atom*> >*
sssr_;
BALL_EXTERN_VARIABLE const double E
Euler's number - base of the natural logarithm.
std::set< SPEdge * > rec_edges_
the recursive edges
void dumpTree()
dumps the tree to cerr
bool hasComponentGrouping() const
returns true if the component level grouping was enabled
const std::set< SPNode * > & getNodes() const
returns the eodes stored in the tree
int component_no_
the actual component number
std::set< SPNode * > nodes_
the nodes
SmartsParser()
Default constructor.
void setNextComponentNumberToSubTree(SPNode *spnode)
gets the next component no and assigns it to the subtree
bool recursive_
recursive flag
bool component_grouping_
component level grouping flag
SPNode * root_
the root node of the tree
std::map< Size, std::vector< SPNode * > > ring_connections_
the ring connection sorted by index of the SMARTS pattern
bool needs_SSSR_
sssr needed flag
void setSSSR(const std::vector< std::vector< Atom * > > &sssr)
sets the SSSR
ChiralClass
chiral class definitions CW = clock wise, CCW = counter clock wise
@ CW_DEFAULT_OR_UNSPECIFIED
@ CCW_DEFAULT_OR_UNSPECIFIED
@ NONCHIRAL_OR_UNSPECIFIED
void addEdge(SPEdge *edge)
adds an edge to the tree
void setRecursive(bool recursive)
sets the recursive flag
std::map< Size, std::vector< SPNode * > > getRingConnections() const
returns the ring connections sorted by index from SMARTS pattern
static SmartsParser * current_parser_
current instance
SPAtom * createAtom(const String &symbol, bool in_bracket=false)
creates a new atom of symbol
bool getNeedsSSSR() const
returns true if the SMARTS pattern contains ring related parts
static State state
static member for the parser itself
void setNeedsSSSR(bool needs_sssr)
sets the sssr needed flag
bool isRecursive() const
returns true if the tree represents a recursive SMARTS pattern
void addRecursiveEdge(SPEdge *edge)
adds a recursive edge to the tree
SPNode * getRoot() const
returns the root SPNode of the tree
void setRoot(SPNode *root)
sets the root SPNode of the tree
const std::set< SPEdge * > & getEdges() const
returns the edges stored in the tree
void addRingConnection(SPNode *spnode, Size index)
adds a ring connection, SPNode with an index used in the SMARTS pattern
SmartsParser(const SmartsParser &parser)
Copy constructor.
void dumpTreeRecursive_(SPEdge *edge, Size depth)
dump method for the tree
void addNode(SPNode *node)
adds a node to the tree
void parse(const String &s)
virtual ~SmartsParser()
Destructor.
std::set< SPEdge * > edges_
the edges
void clear()
clear the tree
bool hasRecursiveEdge(SPEdge *edge) const
returns true if the tree has the given recursive edge
void dumpTreeRecursive_(SPNode *node, Size depth)
dump method for the tree
static vector< std::set< const Atom * > > * sssr_
the sssr
void setComponentGrouping(bool component_grouping)
sets the component level flag
Bond representation of the smarts parser.
void setBondOrder(SPBondOrder bond_order)
sets the bond order
void setZEType(ZEIsomerType type)
sets the Z/E isomer type
virtual ~SPBond()
Destructor.
SPBondOrder bond_order_
the bond order
SPBond()
Default constructor.
ZEIsomerType getZEType() const
returns the Z/E isomer type
SPBondOrder getBondOrder() const
returns the bond order
SPBond(SPAtom *first, SPAtom *second, SPBondOrder bond_order)
Detailed constructor with.
bool isNot() const
return true if a general negation is set
SPBond(SPBondOrder bond_order)
Detailed constructor with bond order.
SPBondOrder
the bond orders supported by SMARTS-patterns
@ NOT_NECESSARILY_CONNECTED
void setNot(bool is_not)
set the general negation to the bool given
ZEIsomerType ze_type_
Z/E isomer type.
bool equals(const Bond *bond) const
bool not_
general negation flag
Smarts Parser Atom class.
PropertyValue getProperty(PropertyType type)
returns a value of the given property type
void setProperty(PropertyType type, ChiralClass chirality)
sets a chirality value
void setNotProperty(PropertyType type)
negotiates the property definition
Size getDefaultValence(const Atom *atom) const
return the number of valences of the given atom
SPAtom(const String &symbol)
copy constructor
Size getNumberOfImplicitHydrogens(const Atom *atom) const
returns the number of implicit hydrogens of the given atom
void setProperty(PropertyType type, const Element *element)
sets a Element
std::map< PropertyType, PropertyValue > properties_
the properties of this SPAtom
Size countProperties() const
returns the number of properties
SPAtom()
Default constructor.
Size countRealValences(const Atom *atom) const
returns the number of available valences of the given atom
PropertyType
enum of all properties possible for a smarts parser atom
std::set< PropertyType > not_properties_
the properties which are negated
bool hasProperty(PropertyType type) const
returns true if the property is set
void setProperty(PropertyType type, int int_value)
sets an int property
Atom * atom_
the atom which this sp_atom belongs to
void setProperty(PropertyType type, bool flag)
sets a flag
void setProperty(Property property)
sets a property
bool equals(const Atom *atom) const
returns true if the local properties of the atoms match
virtual ~SPAtom()
destructor
void addPropertiesFromSPAtom(SPAtom *sp_atom)
adds properties from another SPAtom
possible types of the properties
ChiralClass chiral_class_value
const Element * element_value
Property struct of smarts parser atom.
Property(PropertyType type, const Element *value)
Detailed constructor with type and Element.
virtual ~Property()
Destructor.
Property(PropertyType type, int value)
Detailed constructor with type and int value.
PropertyValue getValue() const
returns the value of the property
Property(PropertyType type, ChiralClass value)
Detailed constructor with type and chiral class definition.
Property(PropertyType type, bool value)
Detailed constructor with type and flag.
PropertyType getType() const
returns the type of the property
Edge representation of the smarts parser graph.
SPNode * getFirstSPNode() const
returns the first SPNode of this edge
void setFirstSPNode(SPNode *first)
set the first SPNode of this edge
SPEdge(const SPEdge &sp_edge)
Copy constructor.
void setSecondSPEdge(SPEdge *second)
set the second SPEdge (second tree child)
SPNode * getPartnerSPNode(SPNode *node)
returns the partner; either the first or the second SPNode
LogicalOperator getLogicalOperator() const
returns the asociated logical operator (for the child edges)
virtual ~SPEdge()
Destructor.
SPEdge * first_edge_
first SPEdge
SPBond * bond_
associated bond
SPEdge * getFirstSPEdge() const
returns the first SPEdge (first tree child)
SPNode * getSecondSPNode() const
returns the second SPNode of this edge
bool isInternal() const
returns true if this is a internal edge
void setNot(bool is_not)
set the negation flag
SPEdge * second_edge_
second SPEdge
SPNode * first_
first SPNode
bool is_not_
negation flag
void setSPBond(SPBond *sp_bond)
sets the corresponding SPBond of this edge
void setSecondSPNode(SPNode *second)
sets the second SPNode of this edge
bool internal_
internal flag
bool isNot() const
returns true if negation is enabled
SPNode * second_
second SPNode
SPEdge()
Default constructor.
void setInternal(bool internal)
set this edge to a internal edge
SPBond * getSPBond() const
returns the corresponding SPBond of this edge
SPEdge * getSecondSPEdge() const
returns the second SPEdge (second tree child)
void setFirstSPEdge(SPEdge *first)
set the first SPEdge (first tree child)
void setLogicalOperator(LogicalOperator log_op)
sets the associated logical operator (for the child edges)
LogicalOperator log_op_
logical operator associated with the SPEdges
Representation of a node in the smarts parser graph.
std::vector< SPEdge * >::const_iterator EdgeConstIterator
constant edge iterator
SPEdge * getFirstEdge() const
returns the first edge (for tree use)
Size getComponentNumber() const
returns the component number
bool internal_
internal flag
void setSecondEdge(SPEdge *second)
sets the second edge (for tree use)
SPAtom * getSPAtom() const
returns the associated SPAtom
EdgeIterator end()
mutable access to end of edges list
bool isInternal() const
returns true if the SPNode is an internal node
void setInternal(bool internal)
sets the internal flag
std::vector< SPEdge * > edges_
edges list
bool isRecursive() const
returns true if the SPNode is a recursive node (from recursive SMARTS)
void setFirstEdge(SPEdge *first)
sets the first edge (for tree use)
void addSPEdge(SPEdge *sp_edge)
flag whether the pattern is in brackets
void setRecursive(bool recursive)
sets the recursive flag
EdgeIterator begin()
mutable access to begin of edges list
std::vector< SPEdge * >::iterator EdgeIterator
non-constant edge iterator
SPAtom * sp_atom_
SPAtom associated with this SPNode.
void setNot(bool is_not)
sets the negation flag
int component_no_
component level
bool is_not_
negotiation flag
void setComponentNumber(int no)
set the component no of the component level grouping
Size countEdges() const
counts the number of edges
EdgeConstIterator begin() const
non-mutable access to begin of edges list
SPNode(const SPNode &sp_node)
Copy constructor.
void setSPAtom(SPAtom *sp_atom)
set the associated SPAtom
SPNode(SPAtom *atom)
Detailed constructor with an atom.
SPNode()
Default constructor.
SPEdge * second_edge_
second edge
LogicalOperator getLogicalOperator() const
returns the logical operator of the SPNode
LogicalOperator log_op_
in brackets flag
EdgeConstIterator end() const
non-mutable access to end of edges list
void setLogicalOperator(LogicalOperator log_op)
sets the logical operator associated with the SPNode
bool recursive_
recursive flag
virtual ~SPNode()
Destructor.
SPEdge * getSecondEdge() const
returns the second edge (for tree use)
bool getNot() const
returns the negation flag
SPEdge * first_edge_
first edge
SPNode(SPNode *first, LogicalOperator log_op, SPNode *second)
Detailed constructor with two nodes and a logical operator.
Parser state (used by the parser itself)
SmartsParser * current_parser