| 1 | // ---------------------------------------------------- |
| 2 | // $Maintainer: Marc Röttig $ |
| 3 | // $Authors: Marc Röttig, Marcel Schumann $ |
| 4 | // ---------------------------------------------------- |
| 5 | |
| 6 | #ifndef BALL_DOCKING_COMMON_FLEXIBLEMOLECULE_H |
| 7 | #define BALL_DOCKING_COMMON_FLEXIBLEMOLECULE_H |
| 8 | |
| 9 | #include <BALL/KERNEL/molecule.h> |
| 10 | #include <BALL/KERNEL/forEach.h> |
| 11 | #include <BALL/DATATYPE/hashMap.h> |
| 12 | #include <BALL/DOCKING/COMMON/conformation.h> |
| 13 | #include <BALL/COMMON/exception.h> |
| 14 | #include <iostream> |
| 15 | |
| 16 | namespace BALL |
| 17 | { |
| 18 | /** FlexibleMolecule class. |
| 19 | This class represents any molecule having |
| 20 | multiple conformers. |
| 21 | */ |
| 22 | class BALL_EXPORT FlexibleMolecule |
| 23 | { |
| 24 | public: |
| 25 | |
| 26 | /* Constructor. |
| 27 | */ |
| 28 | FlexibleMolecule(Molecule* mol); |
| 29 | |
| 30 | /** Copy constructor. */ |
| 31 | FlexibleMolecule(const FlexibleMolecule& flexmol); |
| 32 | |
| 33 | /** Destructor. |
| 34 | */ |
| 35 | virtual ~FlexibleMolecule(); |
| 36 | |
| 37 | /** Add a conformation |
| 38 | @param conformation pointer |
| 39 | */ |
| 40 | virtual void addConformation(Conformation* conf); |
| 41 | |
| 42 | /** Removes and destroyes all conformations of this FlexibleMolecule */ |
| 43 | void clearConformations(); |
| 44 | |
| 45 | /** Generate a hashkey for the topology of the given molecule. \n |
| 46 | This hashkey uses information about all atoms, bonds and bond-orders and generates a cryptographic hashkey from this data. \n |
| 47 | Note that the atom positions are not taken into account by this function; if you need a hashkey for a conformation, please you Conformation::generateHash() instead. |
| 48 | @param ignore_hydrogen if set to true, hydrogen atom are ignore during creation of the hashkey. This is useful for searching molecules regardless of the exact protonation state. */ |
| 49 | static void generateTopologyHash(const AtomContainer* mol, String& hash, bool ignore_hydrogen = false); |
| 50 | |
| 51 | |
| 52 | /** Get the number of stored conformations. |
| 53 | @return number of conformations |
| 54 | */ |
| 55 | Size getNumberOfConformations(); |
| 56 | |
| 57 | /** Get a vector of all stored conformations. |
| 58 | @return vector of conformation pointers |
| 59 | */ |
| 60 | const vector < Conformation* > & getConformations() const; |
| 61 | |
| 62 | /** Get the ID of the i-th conformation. |
| 63 | @return ID of i-th conformation |
| 64 | */ |
| 65 | String getConformationId(Position i); |
| 66 | |
| 67 | /** Get a pointer to the i-th conformation. |
| 68 | @return pointer to i-th conformation |
| 69 | */ |
| 70 | Conformation* getConformation(Position i); |
| 71 | |
| 72 | /** Get a pointer to the i-th conformer ( = conformation applied to parent molecule). |
| 73 | @return pointer to i-th conformer |
| 74 | */ |
| 75 | Molecule* getConformer(Position i); |
| 76 | |
| 77 | /** Get a pointer to the conformer by ID ( = conformation applied to parent molecule). |
| 78 | @return pointer to conformer having the specified ID |
| 79 | */ |
| 80 | Molecule* getConformerById(String id); |
| 81 | |
| 82 | /** Get a pointer to a conformation by specifying its ID. |
| 83 | @return pointer to Conformation having the specified ID |
| 84 | */ |
| 85 | Conformation* getConformationById(String id); |
| 86 | |
| 87 | /** Has the Flexible Molecule an associated conformation with given ID. |
| 88 | @return bool |
| 89 | */ |
| 90 | bool hasConformation(String id); |
| 91 | |
| 92 | /** Get a pointer to the parent molecule supplied in the constructor |
| 93 | @return pointer to parent molecule |
| 94 | */ |
| 95 | Molecule* getParent(); |
| 96 | |
| 97 | /** Get the ID of the Flexible Molecule |
| 98 | @return ID of Flexible Molecule |
| 99 | */ |
| 100 | String getId() const; |
| 101 | |
| 102 | /** Set the ID of the Flexible Molecule |
| 103 | @param id of Flexible Molecule |
| 104 | */ |
| 105 | void setId(String id); |
| 106 | |
| 107 | void removeMoleculeOwnership(); |
| 108 | |
| 109 | protected: |
| 110 | String id; |
| 111 | bool checkCompatibility(Conformation* conf); |
| 112 | Molecule* molecule; |
| 113 | vector < Conformation* > conformations; |
| 114 | HashMap < String, Conformation* > conf_ids_; |
| 115 | bool molecule_ownership_; |
| 116 | |
| 117 | private: |
| 118 | static void calculatePseudoSmile(const Atom* atom, String& smile, HashSet<const Atom*>& visited_atoms, bool ignore_hydrogen); |
| 119 | }; |
| 120 | |
| 121 | typedef FlexibleMolecule Ligand; |
| 122 | } |
| 123 | |
| 124 | #endif /* BALL_DOCKING_COMMON_FLEXIBLEMOLECULE_H */ |