parsmart.cpp File Reference

Implementation of Daylight SMARTS parser. More...

#include <openbabel/babelconfig.h>
#include <ctype.h>
#include <iomanip>
#include <openbabel/mol.h>
#include <openbabel/parsmart.h>

Namespaces

namespace  OpenBabel

Defines

#define ELEMMAX   104
#define ATOMEXPRPOOL   1
#define BONDEXPRPOOL   1
#define ATOMPOOL   1
#define BONDPOOL   1
#define BF_NONRINGUNSPEC   0x0001
#define BF_NONRINGDOWN   0x0002
#define BF_NONRINGUP   0x0004
#define BF_NONRINGDOUBLE   0x0008
#define BF_NONRINGTRIPLE   0x0010
#define BF_RINGUNSPEC   0x0020
#define BF_RINGDOWN   0x0040
#define BF_RINGUP   0x0080
#define BF_RINGAROM   0x0100
#define BF_RINGDOUBLE   0x0200
#define BF_RINGTRIPLE   0x0400
#define BS_ALL   0x07FF
#define BS_SINGLE   0x00E7
#define BS_DOUBLE   0x0208
#define BS_TRIPLE   0x0410
#define BS_AROM   0x0100
#define BS_UP   0x0084
#define BS_DOWN   0x0042
#define BS_UPUNSPEC   0x00A5
#define BS_DOWNUNSPEC   0x0063
#define BS_RING   0x07E0
#define BS_DEFAULT   0x01E7
#define AE_LEAF   0x01
#define AE_RECUR   0x02
#define AE_NOT   0x03
#define AE_ANDHI   0x04
#define AE_OR   0x05
#define AE_ANDLO   0x06
#define AL_CONST   0x01
#define AL_MASS   0x02
#define AL_AROM   0x03
#define AL_ELEM   0x04
#define AL_HCOUNT   0x05
#define AL_NEGATIVE   0x06
#define AL_POSITIVE   0x07
#define AL_CONNECT   0x08
#define AL_DEGREE   0x09
#define AL_IMPLICIT   0x0a
#define AL_RINGS   0x0b
#define AL_SIZE   0x0c
#define AL_VALENCE   0x0d
#define AL_CHIRAL   0x0e
#define AL_HYB   0x0f
#define AL_RINGCONNECT   0x10
#define AL_CLOCKWISE   1
#define AL_ANTICLOCKWISE   2
#define AL_UNSPECIFIED   0
#define OB_EVAL_STACKSIZE   40

Functions

static bool match (OBMol &mol, Pattern *pat, std::vector< std::vector< int > > &mlist, bool single=false)
static bool EvalAtomExpr (AtomExpr *expr, OBAtom *atom)
static bool EvalBondExpr (BondExpr *expr, OBBond *bond)
static int GetVectorBinding ()
static int CreateAtom (Pattern *, AtomExpr *, int, int vb=0)
static void FatalAllocationError (const char *ptr)
static void FreePattern (Pattern *)
static Pattern * CopyPattern (Pattern *)
static AtomExpr * AllocAtomExpr (void)
static AtomExpr * CopyAtomExpr (AtomExpr *expr)
static void FreeAtomExpr (AtomExpr *expr)
static AtomExpr * BuildAtomLeaf (int prop, int val)
static AtomExpr * BuildAtomNot (AtomExpr *expr)
static AtomExpr * BuildAtomBin (int op, AtomExpr *lft, AtomExpr *rgt)
static AtomExpr * BuildAtomRecurs (Pattern *pat)
static AtomExpr * GenerateElement (int elem)
static AtomExpr * GenerateAromElem (int elem, int flag)
static int IsInvalidAtom (AtomExpr *expr)
static BondExpr * AllocBondExpr (void)
static BondExpr * CopyBondExpr (BondExpr *expr)
static bool EquivalentBondExpr (BondExpr *expr1, BondExpr *expr2)
static void FreeBondExpr (BondExpr *expr)
static BondExpr * BuildBondLeaf (int prop, int val)
static BondExpr * BuildBondNot (BondExpr *expr)
static BondExpr * BuildBondBin (int op, BondExpr *lft, BondExpr *rgt)
static BondExpr * GenerateDefaultBond (void)
static Pattern * AllocPattern (void)
static int CreateBond (Pattern *pat, BondExpr *expr, int src, int dst)
static Pattern * ParseSMARTSPattern (void)
static Pattern * ParseSMARTSPart (Pattern *, int)
static Pattern * SMARTSError (Pattern *pat)
static AtomExpr * ParseSimpleAtomPrimitive (void)
static AtomExpr * ParseComplexAtomPrimitive (void)
static AtomExpr * ParseAtomExpr (int level)
static BondExpr * ParseBondPrimitive (void)
static BondExpr * ParseBondExpr (int level)
static Pattern * ParseSMARTSError (Pattern *pat, BondExpr *expr)
static Pattern * SMARTSParser (Pattern *pat, ParseState *stat, int prev, int part)
static void MarkGrowBonds (Pattern *pat)
static int GetChiralFlag (AtomExpr *expr)
static Pattern * ParseSMARTSString (char *ptr)
Pattern * ParseSMARTSRecord (char *ptr)
static void TraverseSMARTS (Pattern *pat, int i)
static AtomExpr * NotAtomExpr (AtomExpr *)
static AtomExpr * AndAtomExpr (AtomExpr *, AtomExpr *)
static AtomExpr * OrAtomExpr (AtomExpr *, AtomExpr *)
static int IsBooleanAtomLeaf (AtomExpr *expr)
static int IsNegatingAtomLeaf (AtomExpr *expr)
static int EqualAtomExpr (AtomExpr *lft, AtomExpr *rgt)
static int OrderAtomExpr (AtomExpr *lft, AtomExpr *rgt)
static int AtomLeafConflict (AtomExpr *lft, AtomExpr *rgt)
static int AtomExprConflict (AtomExpr *lft, AtomExpr *rgt)
static int AtomLeafImplies (AtomExpr *lft, AtomExpr *rgt)
static int AtomExprImplied (AtomExpr *lft, AtomExpr *rgt)
static AtomExpr * AtomExprImplies (AtomExpr *lft, AtomExpr *rgt)
static AtomExpr * AndAtomExprLeaf (AtomExpr *lft, AtomExpr *rgt)
static AtomExpr * ConstrainRecursion (AtomExpr *recur, AtomExpr *expr)
static AtomExpr * OrAtomExprLeaf (AtomExpr *lft, AtomExpr *rgt)
static int GetBondLeafIndex (BondExpr *expr)
static int GetBondExprIndex (BondExpr *expr)
void SetupAtomMatchTable (std::vector< std::vector< bool > > &ttab, Pattern *pat, OBMol &mol)
static void FastSingleMatch (OBMol &mol, Pattern *pat, std::vector< std::vector< int > > &mlist)
static int GetExprOrder (BondExpr *expr)
void SmartsLexReplace (std::string &s, std::vector< std::pair< std::string, std::string > > &vlex)

Variables

std::vector< std::pair
< Pattern *, std::vector< bool > > > 
RSCACHE
static char * MainPtr
static char * LexPtr
static char Buffer [BUFF_SIZE]
static char Descr [BUFF_SIZE]


Detailed Description

Implementation of Daylight SMARTS parser.


Define Documentation

#define ELEMMAX   104

#define ATOMEXPRPOOL   1

#define BONDEXPRPOOL   1

#define ATOMPOOL   1

Referenced by OpenBabel::CreateAtom().

#define BONDPOOL   1

Referenced by OpenBabel::CreateBond().

#define BF_NONRINGUNSPEC   0x0001

#define BF_NONRINGDOWN   0x0002

#define BF_NONRINGUP   0x0004

#define BF_NONRINGDOUBLE   0x0008

#define BF_NONRINGTRIPLE   0x0010

#define BF_RINGUNSPEC   0x0020

#define BF_RINGDOWN   0x0040

#define BF_RINGUP   0x0080

#define BF_RINGAROM   0x0100

#define BF_RINGDOUBLE   0x0200

#define BF_RINGTRIPLE   0x0400

#define BS_ALL   0x07FF

#define BS_SINGLE   0x00E7

#define BS_DOUBLE   0x0208

#define BS_TRIPLE   0x0410

#define BS_AROM   0x0100

#define BS_UP   0x0084

#define BS_DOWN   0x0042

#define BS_UPUNSPEC   0x00A5

#define BS_DOWNUNSPEC   0x0063

#define BS_RING   0x07E0

#define BS_DEFAULT   0x01E7

#define AE_LEAF   0x01

#define AE_RECUR   0x02

#define AE_NOT   0x03

#define AE_ANDHI   0x04

#define AE_OR   0x05

#define AE_ANDLO   0x06

#define AL_CONST   0x01

#define AL_MASS   0x02

#define AL_AROM   0x03

#define AL_ELEM   0x04

#define AL_HCOUNT   0x05

#define AL_NEGATIVE   0x06

#define AL_POSITIVE   0x07

#define AL_CONNECT   0x08

#define AL_DEGREE   0x09

#define AL_IMPLICIT   0x0a

#define AL_RINGS   0x0b

#define AL_SIZE   0x0c

#define AL_VALENCE   0x0d

#define AL_CHIRAL   0x0e

#define AL_HYB   0x0f

#define AL_RINGCONNECT   0x10

#define AL_CLOCKWISE   1

#define AL_ANTICLOCKWISE   2

#define AL_UNSPECIFIED   0

#define OB_EVAL_STACKSIZE   40