Loading...
Searching...
No Matches
BALL::Expression Class Reference
Kernel Classes » Kernel Predicates

`#include <BALL/KERNEL/expression.h>`

## Public Types

Type Definitions
typedef void *(* | CreationMethod) ()

## Public Member Functions

Constructors and Destructor
| Expression ()
| Expression (const Expression &expression)
| Expression (const String &expression_string)
virtual | ~Expression ()
Predicates
bool | hasPredicate (const String &name) const
bool | operator== (const Expression &expression) const
Accessors
virtual bool | operator() (const Atom &atom) const
ExpressionPredicate * | getPredicate (const String &name, const String &args="") const
void | registerPredicate (const String &name, CreationMethod creation_method)
void | setExpression (const String &expression)
const String & | getExpressionString () const
const ExpressionTree * | getExpressionTree () const
const StringHashMap< CreationMethod > & | getCreationMethods () const

## Assignment

StringHashMap< CreationMethod > | create_methods_
ExpressionTree * | expression_tree_
String | expression_string_
Expression & | operator= (const Expression &expression)
virtual void | clear ()
ExpressionTree * | constructExpressionTree_ (const ExpressionParser::SyntaxTree &tree)
void | registerStandardPredicates_ ()

## Detailed Description

The class Expression provides a frontend to ExpressionTree.

  Expressions may be built from the following modules:
  - AND a conjunction
  - OR a disjunction
  - ! a negation
  - predicate(argument) a predicate class that is derived from ExpressionPredicate and provides operator()(const Atom& atom) const.
  Additionally brackets can be used for grouping. At least one bracket pair must exist which encloses the argument of a predicate. Empty arguments are allowed.

  Example:
  !residueID(12) AND (element(N) OR element(C))

  BALL offers various predefined ExpressionPredicates. These are:

  Syntax | Description
  --- | ---
  true() | always true
  false() | always false
  SMARTS(string) | use a SMARTS expression
  selected() | true for already selected atoms
  name(string) | the name of an atom
  type(string) | type name of an atom
  element(char) | element (abbreviated by its symbol)
  residue(string) | name of a residue
  residueID(string) | PDB ID of the residue (usually a number)
  protein(string) | name of protein, the atom is contained in
  secondaryStruct(string) | name of the secondary structure, the atom is contained in
  chain(string) | name of the chain, the atom is contained in
  nucleotide(string) | name of the nucleotide the atom is contained in
  solvent() | the atom is a solvent atom added by BALL
  backbone() | backbone atoms
  inRing() | part of a ring
  doubleBonds() | atoms with double bonds
  tripleBonds() | atoms with triple bonds
  numberOfBonds(int) | atoms with a given number of bonds
  aromaticBonds() | atoms with aromatic bonds
  connectedTo(char) | atoms which are connected to an atom (see ConnectedToPredicate)
  charge([op][number]) | select by charge, Possible operators are '<' '<=' '=' '>=' '>'
  spHybridized() |
  sp2Hybridized() |
  sp3Hybridized() |
  charge(float) | atoms with given charge
  isAxial() |
  is4C1() |

See also
  ExpressionTree

Definition at line 79 of file expression.h.

## Member Typedef Documentation

## CreationMethod

typedef void *(* BALL::Expression::CreationMethod) ()

A creation method for predicates.

Definition at line 91 of file expression.h.

## Constructor & Destructor Documentation

## Expression() [1/3]

BALL::Expression::Expression | ( |  | ) |

Default Constructor.

## Expression() [2/3]

BALL::Expression::Expression | ( | const Expression & | expression | ) |

Copy Constructor.

## Expression() [3/3]

BALL::Expression::Expression | ( | const String & | expression_string | ) |

Construct an Expression with a string

Exceptions

  Exception::ParseError | if a syntax error was encountered

## ~Expression()

virtual BALL::Expression::~Expression | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## clear()

virtual void BALL::Expression::clear | ( |  | ) |

virtual

Clear method

## constructExpressionTree_()

ExpressionTree * BALL::Expression::constructExpressionTree_ | ( | const ExpressionParser::SyntaxTree & | tree | ) |

protected

## getCreationMethods()

const StringHashMap< CreationMethod > & BALL::Expression::getCreationMethods | ( |  | ) | const

Get the creation methods.

## getExpressionString()

const String & BALL::Expression::getExpressionString | ( |  | ) | const

Get the expression string.

## getExpressionTree()

const ExpressionTree * BALL::Expression::getExpressionTree | ( |  | ) | const

Get the expression tree.

## getPredicate()

ExpressionPredicate * BALL::Expression::getPredicate | ( | const String & | name,
|  | const String & | args = "" ) const

Create a new predicate according to the name. If the predicate is not known, return 0.

Parameters

  name | the name of the predicate
  args | the optional argument of the predicate

## hasPredicate()

bool BALL::Expression::hasPredicate | ( | const String & | name | ) | const

## operator()()

virtual bool BALL::Expression::operator() | ( | const Atom & | atom | ) | const

virtual

Evaluate the expression of atom

Parameters

  atom |

## operator=()

Expression & BALL::Expression::operator= | ( | const Expression & | expression | ) |

Assignment operator

## operator==()

bool BALL::Expression::operator== | ( | const Expression & | expression | ) | const

Equality operator

## registerPredicate()

void BALL::Expression::registerPredicate | ( | const String & | name,
|  | CreationMethod | creation_method )

Register a new predicate class.

## registerStandardPredicates_()

void BALL::Expression::registerStandardPredicates_ | ( |  | ) |

protected

## setExpression()

void BALL::Expression::setExpression | ( | const String & | expression | ) |

Set the expression and build a tree for it.

Exceptions

  Exception::ParseError | if a syntax error was encountered

## Member Data Documentation

## create_methods_

StringHashMap<CreationMethod> BALL::Expression::create_methods_

protected

Definition at line 205 of file expression.h.

## expression_string_

String BALL::Expression::expression_string_

protected

Definition at line 214 of file expression.h.

## expression_tree_

ExpressionTree* BALL::Expression::expression_tree_

protected

Definition at line 210 of file expression.h.