BALL  1.5.0
standardPredicates.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: standardPredicates.h,v 1.52.16.2 2007/03/29 10:34:59 bertsch Exp $
5 //
6 
7 #ifndef BALL_KERNEL_STANDARDPREDICATES_H
8 #define BALL_KERNEL_STANDARDPREDICATES_H
9 
10 #ifndef BALL_DATATYPE_STRINGHASHMAP_H
12 #endif
13 
14 #ifndef BALL_DATATYPE_HASHSET_H
15 # include <BALL/DATATYPE/hashSet.h>
16 #endif
17 
18 #ifndef BALL_KERNEL_BOND_H
19 # include <BALL/KERNEL/bond.h>
20 #endif
21 
22 #ifndef BALL_KERNEL_EXPRESSION_H
23 # include <BALL/KERNEL/expression.h>
24 #endif
25 
26 #ifndef BALL_STRUCTURE_SMARTSMATCHER_H
28 #endif
29 
30 #ifndef BALL_QSAR_AROMATICITYPROCESSOR_H
32 #endif
33 
34 #ifndef BALL_QSAR_RINGPERCEPTIONPROCESSOR_H
36 #endif
37 
38 namespace BALL
39 {
40  class Atom;
41 
49 
55  : public ExpressionPredicate
56  {
57  public:
59 
60 
64  virtual bool operator () (const Atom& atom) const;
65  };
66 
72  : public ExpressionPredicate
73  {
74  public:
76 
77 
81  virtual bool operator () (const Atom& atom) const;
82  };
83 
89  : public ExpressionPredicate
90  {
91  public:
93 
94 
98  virtual bool operator () (const Atom& atom) const;
99  };
100 
106  : public ExpressionPredicate
107  {
108  public:
110 
111 
115  virtual bool operator () (const Atom& atom) const;
116  };
117 
122  : public ExpressionPredicate
123  {
124  public:
126 
127 
131  virtual bool operator () (const Atom& atom) const;
132  };
133 
138  : public ExpressionPredicate
139  {
140  public:
142 
143 
147  virtual bool operator () (const Atom& atom) const;
148  };
149 
155  : public ExpressionPredicate
156  {
157  public:
159 
160 
164  virtual bool operator () (const Atom& atom) const;
165  };
166 
172  : public ExpressionPredicate
173  {
174  public:
176 
177 
181  virtual bool operator () (const Atom& atom) const;
182  };
183 
189  : public ExpressionPredicate
190  {
191  public:
193 
194 
198  virtual bool operator () (const Atom& atom) const;
199  };
200 
206  : public ExpressionPredicate
207  {
208  public:
210 
211 
215  virtual bool operator () (const Atom& atom) const;
216  };
217 
223  : public ExpressionPredicate
224  {
225  public:
227 
228 
232  virtual bool operator () (const Atom& atom) const;
233  };
234 
244  : public ExpressionPredicate
245  {
246  public:
248 
249 
253  virtual bool operator () (const Atom& atom) const;
254  };
255 
260  : public ExpressionPredicate
261  {
262  public:
264 
265 
269  virtual bool operator () (const Atom& atom) const;
270  };
271 
277  : public ExpressionPredicate
278  {
279  public:
281 
282 
286  virtual bool operator () (const Atom& atom) const;
287  };
288 
292  : public ExpressionPredicate
293  {
294  public:
296 
297 
301  virtual bool operator () (const Atom& atom) const;
302  };
303 
308  : public ExpressionPredicate
309  {
310  public:
312 
313 
317  virtual bool operator () (const Atom& atom) const;
318  };
319 
323  : public ExpressionPredicate
324  {
325  public:
326 
328 
329 
331 
334 
337 
342  virtual bool operator () (const Atom& atom) const;
343 
344  };
345 
354  : public ExpressionPredicate
355  {
356  public:
357 
360 
362 
363 
367  virtual bool operator () (const Atom& atom) const;
368 
369  protected:
370  bool testPredicate_(const Atom& atom, Bond::Order order) const;
371  };
372 
373 
379  : public NumberOfBondsPredicate
380  {
381  public:
383 
384 
388  virtual bool operator () (const Atom& atom) const;
389  };
390 
391 
397  : public NumberOfBondsPredicate
398  {
399  public:
401 
402 
406  virtual bool operator () (const Atom& atom) const;
407 
408  };
409 
410 
416  : public DoubleBondsPredicate
417  {
418  public:
420 
421 
425  virtual bool operator () (const Atom& atom) const;
426  };
427 
428 
440  : public ExpressionPredicate
441  {
442  public:
444 
445 
449  virtual bool operator () (const Atom& atom) const;
450 
451  protected:
452  bool testPredicate_(const Atom& atom) const;
453  };
454 
455 
481  : public ExpressionPredicate
482  {
483 
484  public:
485 
487  {
488  public:
489 
490  enum BondType
491  {
492  BONDTYPE__UNINITIALISED = 0,
493  BONDTYPE__ANY = 1,
494  BONDTYPE__SINGLE = 2,
495  BONDTYPE__DOUBLE = 3,
496  BONDTYPE__TRIPLE = 4,
497  BONDTYPE__QUADRUPLE = 5,
498  BONDTYPE__AROMATIC = 6
499  };
500 
501  typedef std::list<CTPNode*>::iterator Iterator;
502  typedef std::list<CTPNode*>::const_iterator ConstIterator;
503 
504  /*
505  */
507 
508  /*
509  */
510  CTPNode(const CTPNode& node);
511 
512  /*
513  */
514  virtual ~CTPNode();
515 
516  /*
517  */
518  virtual void destroy();
519 
520  /*
521  */
522  void setParent(CTPNode* parent);
523 
524  /*
525  */
526  CTPNode* getParent() const;
527 
528  /*
529  */
530  void addChild(CTPNode* child);
531 
532  /*
533  */
534  void removeChild(CTPNode* child);
535 
536  /*
537  */
538  ::std::list<CTPNode*>& getChildren();
539 
541 
543 
545 
547 
548  /*
549  */
551 
552  /*
553  */
554  void setBondType(Size type);
555 
556  /*
557  */
558  void setBondType(char type);
559 
560  /*
561  */
562  Size getBondType() const;
563 
564  /*
565  */
566  char getBondTypeChar() const;
567 
568  /*
569  */
570  String getSymbol() const;
571 
572  /*
573  */
574  void setSymbol(const String& symbol);
575 
576  /*
577  */
578  void setFinished();
579 
580  /*
581  */
583 
584  /*
585  */
586  bool isFinished() const;
587 
588  /*
589  */
590  void setLinked();
591 
592  /*
593  */
594  void unsetLinked();
595 
596  /*
597  */
598  bool isLinked() const;
599 
600  /*
601  */
602  void linkWith(CTPNode* partner);
603 
604  /*
605  */
607 
608 
609  private:
610 
611  /*
612  */
613  String element_symbol_;
614 
615  /* Bond type means the bond connecting *to* this node.
616  */
617  Size bond_type_;
618 
619  /*
620  */
621  std::list<CTPNode*> children_;
622 
623  /*
624  */
625  CTPNode* parent_;
626 
627  /*
628  */
629  bool finished_;
630 
631  /*
632  */
633  bool linked_;
634 
635  /*
636  */
637  HashSet<CTPNode*> link_set_;
638 
639  /*
640  */
641  struct greater_
642  : public binary_function<const CTPNode*, const CTPNode*, bool>
643  {
644 
645  bool operator () (const CTPNode* a, const CTPNode* b) const
646  {
647  if ((a != 0) && (b != 0))
648  {
649  if (a->getSymbol() == "*")
650  {
651  return true;
652  }
653  else
654  {
655  return false;
656  }
657  }
658  else
659  {
660  Log.error() << "greater_: got NULL pointers" << std::endl;
661  return false;
662  }
663  }
664 
665  };
666 
667  };
668 
669  public:
670  BALL_CREATE(ConnectedToPredicate)
671 
673 
675 
677 
678  virtual void clear();
679 
684  virtual bool operator () (const Atom& atom) const;
685 
686  void dump() const;
687 
688  void dump(const CTPNode* current) const;
689 
690  virtual void setArgument(const String& argument);
691 
692  private:
693  /*_ The syntax tree
694  */
695  CTPNode* tree_;
696 
697  /*_ Needed for realising parsing of loops (or links).
698  */
699  HashMap<char, std::pair<CTPNode*, CTPNode*> > link_map_;
700 
701  /*_ Needed for realising parsing of loops (or links).
702  */
703  char link_mark_;
704 
705  /*_ Keep it consistent
706  */
707  CTPNode* createNewNode_(CTPNode* node);
708 
709  /*_
710  */
711  CTPNode* parse_();
712 
713  // Clean up nodes created if parse_ exits with a parse error.
714  void cleanUpNodes_(std::vector<CTPNode*>& all_nodes);
715 
716  /*_
717  */
718  CTPNode* parse_(const String& input);
719 
720  bool bondOrderMatch_(const Bond& bond, const CTPNode& node) const;
721 
722  bool find_(const Atom& atom, const CTPNode* current,
723  HashSet<const Bond*>& visited) const;
724 
725  };
726 
730  : public ExpressionPredicate
731  {
732  public:
734 
735 
739  virtual bool operator () (const Atom& atom) const;
740  };
741 
745  : public ExpressionPredicate
746  {
747  public:
749 
750 
754  virtual bool operator () (const Atom& atom) const;
755  };
756 
757 
761  : public ExpressionPredicate
762  {
763  public:
765 
766 
770  virtual bool operator () (const Atom& atom) const;
771  };
772 
776  : public ExpressionPredicate
777  {
778  public:
780 
781 
790  virtual bool operator () (const Atom& atom) const;
791  };
792 
798  : public ExpressionPredicate
799  {
800  public:
802 
803 
812  virtual bool operator () (const Atom& atom) const;
813  };
814 
819  : public ExpressionPredicate
820  {
821  public:
823 
824 
828  virtual bool operator () (const Atom& atom) const;
829  };
830 
834  {
835  public:
836 
837  // BALL_CREATE(RingFinder)
838 
841 
847 
849  virtual ~RingFinder();
850 
853  bool operator () (const Atom& atom);
854 
857  bool dfs(const Atom& atom, const Size limit);
858 
863  void setRingSize(Size n);
864 
868 
871  const std::vector<const Atom*>& getRingAtoms() const;
872 
873  private:
874 
877  const Atom* first_atom_;
878 
881  Size n_;
882 
885  bool exact_;
886 
887  /*_
888  */
889  HashSet<const Bond*> visited_bonds_;
890 
891  /*_
892  */
893  std::vector<const Atom*> ring_atoms_;
894 
895  };
896 
900  : public ExpressionPredicate
901  {
902  public:
903 
906 
909 
911  virtual ~SMARTSPredicate();
912 
914 
915 
919  virtual bool operator () (const Atom& atom) const;
920 
921  mutable SmartsMatcher matcher_;
922  mutable Molecule* last_molecule_;
923  mutable AromaticityProcessor arom_proc_;
924  mutable RingPerceptionProcessor ring_proc_;
925  // when was the aromaticity lastly calculated for a given molecule:
926  static HashMap<Molecule*, TimeStamp> call_time_map_;
927  static Molecule dummy_molecule_;
928  mutable HashSet<Atom*> matches_;
929  };
930 
931 
933 } // namespace BALL
934 
935 #endif // BALL_KERNEL_STANDARDPREDICATES_H
BALL::TimeStamp
Definition: timeStamp.h:172
BALL::RingFinder::dfs
bool dfs(const Atom &atom, const Size limit)
BALL::SmartsMatcher
Definition: smartsMatcher.h:45
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL::ConnectedToPredicate::CTPNode::end
ConstIterator end() const
BALL::ChainPredicate
Definition: standardPredicates.h:207
BALL::ConnectedToPredicate::CTPNode::destroy
virtual void destroy()
BALL::BackBonePredicate
Definition: standardPredicates.h:278
BALL::ConnectedToPredicate::CTPNode::getBondType
Size getBondType() const
BALL::SMARTSPredicate::~SMARTSPredicate
virtual ~SMARTSPredicate()
BALL::AxialPredicate
Definition: standardPredicates.h:799
BALL::ConnectedToPredicate::CTPNode::CTPNode
CTPNode()
BALL::AtomTypePredicate
Definition: standardPredicates.h:123
BALL::Bond
Definition: bond.h:57
BALL::SolventPredicate
Definition: standardPredicates.h:245
BALL::ConnectedToPredicate::CTPNode::unsetLinked
void unsetLinked()
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:74
BALL::SpHybridizedPredicate
Definition: standardPredicates.h:731
BALL::TruePredicate
Definition: standardPredicates.h:56
BALL::Molecule
Definition: molecule.h:31
BALL::ProteinPredicate
Definition: standardPredicates.h:190
bond.h
BALL::ConnectedToPredicate::CTPNode::BondType
BondType
Definition: standardPredicates.h:491
BALL::ConnectedToPredicate
Definition: standardPredicates.h:482
BALL::Log
BALL_EXPORT LogStream Log
BALL::ConnectedToPredicate::CTPNode::begin
ConstIterator begin() const
BALL::LogStream::error
LogStream & error(int n=0)
BALL::ConnectedToPredicate::CTPNode::setBondType
void setBondType(Size type)
BALL::RingFinder::RingFinder
RingFinder()
Default constructor.
BALL::ConnectedToPredicate::CTPNode::begin
Iterator begin()
BALL::Atom
Definition: atom.h:90
BALL::RingFinder
Definition: standardPredicates.h:834
BALL::ResiduePredicate
Definition: standardPredicates.h:156
BALL::NumberOfBondsPredicate::NumberOfBondsPredicate
NumberOfBondsPredicate()
Default constructor.
BALL::ConnectedToPredicate::CTPNode::linkWith
void linkWith(CTPNode *partner)
BALL::TripleBondsPredicate
Definition: standardPredicates.h:417
BALL::ConnectedToPredicate::CTPNode::setSymbol
void setSymbol(const String &symbol)
BALL::ChargePredicate
Definition: standardPredicates.h:777
BALL::AtomNamePredicate
Definition: standardPredicates.h:107
BALL::NumberOfBondsPredicate
Definition: standardPredicates.h:355
ringPerceptionProcessor.h
BALL::ConnectedToPredicate::CTPNode::setFinished
void setFinished()
stringHashMap.h
BALL::SMARTSPredicate::SMARTSPredicate
SMARTSPredicate(const SMARTSPredicate &pred)
BALL::String
Definition: string.h:57
BALL::NucleotidePredicate
Definition: standardPredicates.h:309
BALL::ConnectedToPredicate::CTPNode::getChildren
::std::list< CTPNode * > & getChildren()
BALL::ConnectedToPredicate::CTPNode::CTPNode
CTPNode(const CTPNode &node)
BALL
Definition: constants.h:13
BALL::RingFinder::getRingAtoms
const std::vector< const Atom * > & getRingAtoms() const
BALL::ConnectedToPredicate::CTPNode::end
Iterator end()
BALL::HashSet
Definition: hashSet.h:46
BALL::ConnectedToPredicate::CTPNode::setParent
void setParent(CTPNode *parent)
BALL::PDB::Atom
char Atom[5]
Definition: PDBdefs.h:257
BALL::ConnectedToPredicate::CTPNode::unsetFinished
void unsetFinished()
BALL::ConnectedToPredicate::CTPNode::getBondTypeChar
char getBondTypeChar() const
BALL::SMARTSPredicate::SMARTSPredicate
SMARTSPredicate()
BALL::ConnectedToPredicate::CTPNode::getLinkSet
const HashSet< CTPNode * > & getLinkSet() const
BALL::ConnectedToPredicate::CTPNode::addChild
void addChild(CTPNode *child)
BALL_SIZE_TYPE
BALL::DoubleBondsPredicate
Definition: standardPredicates.h:398
BALL::ExpressionPredicate
Definition: expressionPredicate.h:27
BALL::ConnectedToPredicate::CTPNode::isFinished
bool isFinished() const
BALL::RingFinder::~RingFinder
virtual ~RingFinder()
Destructor.
BALL::RingPerceptionProcessor
Definition: ringPerceptionProcessor.h:38
BALL::Sp2HybridizedPredicate
Definition: standardPredicates.h:746
BALL::FalsePredicate
Definition: standardPredicates.h:73
BALL::ConnectedToPredicate::CTPNode
Definition: standardPredicates.h:487
BALL::RingFinder::setRingSize
void setRingSize(Size n)
BALL::ConnectedToPredicate::CTPNode::getNumberOfChildren
Size getNumberOfChildren() const
BALL::ConnectedToPredicate::CTPNode::setBondType
void setBondType(char type)
hashSet.h
BALL::AromaticityProcessor
This processor provides methods for detection and assignment of aromaticity.
Definition: aromaticityProcessor.h:30
BALL::ConnectedToPredicate::CTPNode::removeChild
void removeChild(CTPNode *child)
BALL::MoleculePredicate
Definition: standardPredicates.h:261
BALL::AromaticBondsPredicate
Definition: standardPredicates.h:441
BALL::ConnectedToPredicate::CTPNode::~CTPNode
virtual ~CTPNode()
BALL::SingleBondsPredicate
Definition: standardPredicates.h:380
expression.h
BALL::RingFinder::RingFinder
RingFinder(Size n)
BALL::ConnectedToPredicate::CTPNode::setLinked
void setLinked()
BALL::SecondaryStructurePredicate
Definition: standardPredicates.h:224
BALL::SMARTSPredicate
Definition: standardPredicates.h:901
BALL::ResidueIDPredicate
Definition: standardPredicates.h:173
BALL::InRingPredicate
Definition: standardPredicates.h:324
BALL::Conformation4C1Predicate
Definition: standardPredicates.h:820
BALL::ElementPredicate
Definition: standardPredicates.h:139
aromaticityProcessor.h
BALL::Sp3HybridizedPredicate
Definition: standardPredicates.h:762
BALL::SelectedPredicate
Definition: standardPredicates.h:90
BALL::ConnectedToPredicate::CTPNode::getSymbol
String getSymbol() const
BALL_CREATE
#define BALL_CREATE(name)
Definition: create.h:62
smartsMatcher.h
BALL::ConnectedToPredicate::CTPNode::Iterator
std::list< CTPNode * >::iterator Iterator
Definition: standardPredicates.h:501
BALL::ConnectedToPredicate::CTPNode::ConstIterator
std::list< CTPNode * >::const_iterator ConstIterator
Definition: standardPredicates.h:502
BALL::RingFinder::getVisitedBonds
const HashSet< const Bond * > & getVisitedBonds() const
BALL::NucleicAcidPredicate
Definition: standardPredicates.h:293
BALL::ConnectedToPredicate::CTPNode::getParent
CTPNode * getParent() const
BALL::ConnectedToPredicate::CTPNode::isLinked
bool isLinked() const