RDKit: QueryAtom.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

QueryAtom.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2006 Greg Landrum and Rational Discovery LLC
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 #ifndef _RD_QUERYATOM_H_
11 #define _RD_QUERYATOM_H_
12
13 #include "Atom.h"
14 #include <Query/QueryObjects.h>
15 #include <GraphMol/QueryOps.h>
16
17 namespace RDKit {
18
19 //! Class for storing atomic queries
20 /*!
21 QueryAtom objects are derived from Atom objects, so they can be
22 added to molecules and the like, but they have much fancier
23 querying capabilities.
24
25 */
26 class QueryAtom : public Atom {
27 public:
28 typedef Queries::Query<int, Atom const *, true> QUERYATOM_QUERY;
29
30 QueryAtom() : Atom(), dp_query(NULL){};
31 explicit QueryAtom(int num) : Atom(num), dp_query(makeAtomNumQuery(num)){};
32 explicit QueryAtom(const Atom &other)
33 : Atom(other), dp_query(makeAtomNumQuery(other.getAtomicNum())){};
34 QueryAtom(const QueryAtom &other) : Atom(other) {
35 dp_query = other.dp_query->copy();
36 };
37 ~QueryAtom();
38
39 //! returns a copy of this query, owned by the caller
40 Atom *copy() const;
41
42 // This method can be used to distinguish query atoms from standard atoms:
43 bool hasQuery() const { return dp_query != 0; };
44
45 //! replaces our current query with the value passed in
46 void setQuery(QUERYATOM_QUERY *what) { dp_query = what; }
47 //! returns our current query
48 QUERYATOM_QUERY *getQuery() const { return dp_query; };
49
50 //! expands our current query
51 /*!
52 \param what the Queries::Query to be added
53 \param how the operator to be used in the expansion
54 \param maintainOrder (optional) flags whether the relative order of
55 the queries needs to be maintained, if this is
56 false, the order is reversed
57 <b>Notes:</b>
58 - \c what should probably be constructed using one of the functions
59 defined in QueryOps.h
60 - the \c maintainOrder option can be useful because the combination
61 operators short circuit when possible.
62
63 */
64 void expandQuery(QUERYATOM_QUERY *what,
65 Queries::CompositeQueryType how = Queries::COMPOSITE_AND,
66 bool maintainOrder = true);
67
68 //! returns true if we match Atom \c what
69 bool Match(const Atom::ATOM_SPTR &what) const;
70 //! \overload
71 bool Match(Atom const *what) const;
72
73 //! returns true if our query details match those of QueryAtom \c what
74 bool QueryMatch(QueryAtom const *what) const;
75
76 private:
77 QUERYATOM_QUERY *dp_query;
78
79 }; // end o' class
80
81 }; // end o' namespace
82
83 #endif
RDKit::QueryAtom::QueryAtom
QueryAtom()
Definition: QueryAtom.h:30
RDKit::QueryAtom::QueryAtom
QueryAtom(int num)
Definition: QueryAtom.h:31
Queries::CompositeQueryType
CompositeQueryType
Definition: QueryObjects.h:35
RDKit::QueryAtom::copy
Atom * copy() const
returns a copy of this query, owned by the caller
RDKit::QueryAtom::hasQuery
bool hasQuery() const
Definition: QueryAtom.h:43
RDKit::QueryAtom::Match
bool Match(const Atom::ATOM_SPTR &what) const
returns true if we match Atom what
RDKit::QueryAtom
Class for storing atomic queries.
Definition: QueryAtom.h:26
RDKit::QueryAtom::QueryMatch
bool QueryMatch(QueryAtom const *what) const
returns true if our query details match those of QueryAtom what
RDKit::QueryAtom::setQuery
void setQuery(QUERYATOM_QUERY *what)
replaces our current query with the value passed in
Definition: QueryAtom.h:46
RDKit::QueryAtom::QUERYATOM_QUERY
Queries::Query< int, Atom const *, true > QUERYATOM_QUERY
Definition: QueryAtom.h:28
RDKit::QueryAtom::~QueryAtom
~QueryAtom()
RDKit::Atom::getAtomicNum
int getAtomicNum() const
returns our atomic number
Definition: Atom.h:115
RDKit::QueryAtom::QueryAtom
QueryAtom(const QueryAtom &other)
Definition: QueryAtom.h:34
RDKit
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
RDKit::makeAtomNumQuery
T * makeAtomNumQuery(int what, const std::string &descr)
returns a Query for matching atomic number
Definition: QueryOps.h:210
QueryOps.h
RDKit::Atom::ATOM_SPTR
boost::shared_ptr< Atom > ATOM_SPTR
Definition: Atom.h:73
RDKit::QueryAtom::getQuery
QUERYATOM_QUERY * getQuery() const
returns our current query
Definition: QueryAtom.h:48
Atom.h
Defines the Atom class and associated typedefs.
QueryObjects.h
Pulls in all the query types.
RDKit::QueryAtom::QueryAtom
QueryAtom(const Atom &other)
Definition: QueryAtom.h:32
Queries::Query
Base class for all queries.
Definition: Query.h:45
Queries::COMPOSITE_AND
Definition: QueryObjects.h:35
RDKit::Atom
The class for representing atoms.
Definition: Atom.h:67
RDKit::QueryAtom::expandQuery
void expandQuery(QUERYATOM_QUERY *what, Queries::CompositeQueryType how=Queries::COMPOSITE_AND, bool maintainOrder=true)
expands our current query
Queries::Query::copy
virtual Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const
returns a copy of this Query
Definition: Query.h:125