26 #include <openbabel/babelconfig.h> 147 class OBSmartsPrivate;
167 Pattern *ParseSMARTSPattern(
void );
171 AtomExpr *ParseSimpleAtomPrimitive(
void );
172 AtomExpr *ParseComplexAtomPrimitive(
void );
173 AtomExpr *ParseAtomExpr(
int level );
174 BondExpr *ParseBondPrimitive(
void );
175 BondExpr *ParseBondExpr(
int level );
176 Pattern *ParseSMARTSString(
char *ptr );
177 Pattern *ParseSMARTSRecord(
char *ptr );
178 int GetVectorBinding();
180 int prev,
int part );
202 std::string s = cp.
_str;
210 bool Init(
const char* pattern);
215 bool Init(
const std::string& pattern);
220 const std::string &GetSMARTS()
const {
return _str; }
226 bool Empty()
const {
return(_pat == NULL); }
229 bool IsValid()
const {
return(_pat != NULL); }
234 return _pat ? _pat->
acount : 0;
239 return _pat ? _pat->
bcount : 0;
247 void GetBond(
int& src,
int& dst,
int& ord,
int idx);
251 int GetCharge(
int idx);
256 return(_pat->
atom[idx].
vb);
265 bool Match(
OBMol &mol,
bool single=
false);
273 bool Match(
OBMol &mol, std::vector<std::vector<int> > & mlist,
MatchType mtype = All)
const;
283 bool HasMatch(
OBMol &mol)
const;
288 bool RestrictedMatch(
OBMol &mol, std::vector<std::pair<int,int> > &pairs,
bool single=
false);
290 bool RestrictedMatch(
OBMol &mol,
OBBitVec &bv,
bool single=
false);
295 return static_cast<unsigned int>(_mlist.size());
307 return(_mlist.begin());
310 std::vector<std::vector<int> >::iterator
EndMList()
312 return(_mlist.end());
326 std::vector<std::vector<int> > &GetUMapList();
330 void WriteMapList(std::ostream&);
342 std::vector<std::pair<const Pattern*,std::vector<bool> > >
RSCACHE;
353 void SetupAtomMatchTable(std::vector<std::vector<bool> > &
ttab,
356 std::vector<std::vector<int> > &mlist);
363 bool match(
OBMol &mol,
const Pattern *pat,std::vector<std::vector<int> > &mlist,
bool single=
false);
381 void Match(std::vector<std::vector<int> > &v,
int bidx=-1);
385 std::vector<std::pair<std::string,std::string> > &);
389 #endif // OB_PARSMART_H void SmartsLexReplace(std::string &, std::vector< std::pair< std::string, std::string > > &)
unsigned int NumMatches() const
Definition: parsmart.h:293
union _AtomExpr * arg
Definition: parsmart.h:62
MatchType
Definition: parsmart.h:261
bool hasExplicitH
Definition: parsmart.h:127
unsigned int GetAtomicNum(const char *ptr)
Definition: elements.cpp:174
union _BondExpr * rgt
Definition: parsmart.h:88
OBSmartsMatcher()
Definition: parsmart.h:360
char * LexPtr
Definition: parsmart.h:164
int part
Definition: parsmart.h:110
bool * _uatoms
Definition: parsmart.h:373
OBSmartsPrivate * _d
Internal data storage for future expansion.
Definition: parsmart.h:157
A SMARTS parser internal pattern.
Definition: parsmart.h:119
bool IsValid() const
Definition: parsmart.h:229
unsigned int NumAtoms() const
Definition: parsmart.h:232
unsigned int NumBonds() const
Definition: parsmart.h:237
An internal (SMARTS parser) atom specification.
Definition: parsmart.h:106
Pattern * _pat
The parsed SMARTS pattern.
Definition: parsmart.h:160
const Pattern * _pat
Definition: parsmart.h:375
std::string _str
The string of the SMARTS expression.
Definition: parsmart.h:161
union OpenBabel::_BondExpr BondExpr
std::vector< int > _map
Definition: parsmart.h:376
OBSmartsPattern()
Definition: parsmart.h:183
Bond class.
Definition: bond.h:58
struct OpenBabel::_AtomExpr::@5 bin
union _AtomExpr * rgt
Definition: parsmart.h:69
struct OpenBabel::_AtomExpr::@2 leaf
Molecule Class.
Definition: mol.h:118
char * MainPtr
Definition: parsmart.h:165
int type
Definition: parsmart.h:77
AtomExpr * expr
Definition: parsmart.h:108
bool ischiral
Definition: parsmart.h:123
void * recur
Definition: parsmart.h:56
An internal (SMARTS parser) bond expression.
Definition: parsmart.h:76
An internal (SMARTS parser) atomic expression.
Definition: parsmart.h:45
int closindex
Definition: parsmart.h:137
Internal class: performs fast, exhaustive matching used to find just a single match in match() using ...
Definition: parsmart.h:370
A speed-optimized vector of bits.
Definition: bitvec.h:57
virtual ~OBSmartsMatcher()
Definition: parsmart.h:361
std::vector< std::pair< const Pattern *, std::vector< bool > > > RSCACHE
Definition: parsmart.h:342
bool grow
Definition: parsmart.h:100
int type
Definition: parsmart.h:46
SMARTS (SMiles ARbitrary Target Specification) substructure searching.
Definition: parsmart.h:154
int GetVectorBinding(int idx) const
Definition: parsmart.h:254
OBTypeTable ttab
Definition: data.h:225
union _AtomExpr * lft
Definition: parsmart.h:68
std::vector< int > nbrs
Definition: parsmart.h:113
BondSpec * bond
Definition: parsmart.h:125
int visit
Definition: parsmart.h:99
std::string & GetSMARTS()
Definition: parsmart.h:224
std::vector< std::vector< int > > _mlist
The list of matches.
Definition: parsmart.h:159
std::vector< std::vector< int > > & GetMapList()
Definition: parsmart.h:300
union _BondExpr * lft
Definition: parsmart.h:87
std::vector< std::vector< int > >::iterator EndMList()
Definition: parsmart.h:310
int value
Definition: parsmart.h:50
int src
Definition: parsmart.h:98
struct OpenBabel::_AtomExpr::@4 mon
AtomSpec * atom
Definition: parsmart.h:124
OBSmartsPattern & operator=(const OBSmartsPattern &cp)
Definition: parsmart.h:191
OBMol * _mol
Definition: parsmart.h:374
An internal (SMARTS parser) bond specification.
Definition: parsmart.h:95
Definition: parsmart.h:261
std::vector< std::vector< int > >::iterator BeginMList()
Definition: parsmart.h:305
int bcount
Definition: parsmart.h:122
char * _buffer
Definition: parsmart.h:163
OBSmartsPattern(const OBSmartsPattern &cp)
Definition: parsmart.h:186
union OpenBabel::_AtomExpr AtomExpr
A SMARTS parser internal state.
Definition: parsmart.h:133
std::vector< bool > _growbond
Definition: parsmart.h:158
BondExpr * expr
Definition: parsmart.h:97
std::vector< const Pattern * > Fragments
Definition: parsmart.h:344
int parts
Definition: parsmart.h:126
int acount
Definition: parsmart.h:121
int visit
Definition: parsmart.h:109
union _BondExpr * arg
Definition: parsmart.h:81
Internal class: performs matching; a wrapper around previous C matching code to make it thread safe...
Definition: parsmart.h:338
int chiral_flag
Definition: parsmart.h:111
int vb
Definition: parsmart.h:112
Global namespace for all Open Babel code.
Definition: alias.h:22
Atom class.
Definition: atom.h:71