/src/openbabel/include/openbabel/rotamer.h
Line | Count | Source |
1 | | /********************************************************************** |
2 | | rotamer.h - Handle rotamer list data. |
3 | | |
4 | | Copyright (C) 1998-2000 by OpenEye Scientific Software, Inc. |
5 | | Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison |
6 | | |
7 | | This file is part of the Open Babel project. |
8 | | For more information, see <http://openbabel.org/> |
9 | | |
10 | | This program is free software; you can redistribute it and/or modify |
11 | | it under the terms of the GNU General Public License as published by |
12 | | the Free Software Foundation version 2 of the License. |
13 | | |
14 | | This program is distributed in the hope that it will be useful, |
15 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | GNU General Public License for more details. |
18 | | ***********************************************************************/ |
19 | | |
20 | | #ifndef OB_ROTAMER_H |
21 | | #define OB_ROTAMER_H |
22 | | |
23 | | #include <vector> |
24 | | #include <map> |
25 | | |
26 | | #include <openbabel/rotor.h> |
27 | | #include <openbabel/generic.h> |
28 | | |
29 | | namespace OpenBabel |
30 | | { |
31 | | class OBMol; |
32 | | |
33 | | //! \brief Supports a set of rotamer coordinate sets for some number of potentially rotatable bonds |
34 | | // Further class introduction in rotamer.cpp |
35 | | class OBAPI OBRotamerList : public OBGenericData |
36 | | { |
37 | | //! Number of atoms in the base coordinate set (i.e., OBMol::NumAtoms()) |
38 | | unsigned int _NBaseCoords; |
39 | | //! Base coordinate sets (i.e., existing conformers to be modified) |
40 | | std::vector<double*> _c; |
41 | | //! Individual bond rotors (from an OBRotor object or other) |
42 | | std::vector<std::pair<OBAtom**,std::vector<int> > > _vrotor; |
43 | | //! \brief Index of each rotor's different sampling states ("resolution") |
44 | | //! Usually from OBRotor::GetResolution() |
45 | | std::vector<std::vector<double> > _vres; |
46 | | //! Individual rotamer states (i.e., the array of rotor settings) |
47 | | std::vector<unsigned char*> _vrotamer; |
48 | | //! Rotors in rings |
49 | | std::vector<std::vector<int> > _vrings; |
50 | | //! Dihedral angles of ring bonds |
51 | | std::vector<std::vector<double> > _vringTors; |
52 | | |
53 | | public: |
54 | | OBRotamerList() |
55 | 0 | { |
56 | 0 | _NBaseCoords=0; |
57 | 0 | _type= OBGenericDataType::RotamerList; |
58 | 0 | _attr="RotamerList"; |
59 | 0 | } |
60 | | OBGenericData* Clone(OBBase* parent) const override; |
61 | | |
62 | | ~OBRotamerList(); |
63 | | //! Set up a rotamer list based on an already created OBRotorList |
64 | | void Setup(OBMol&,OBRotorList&); |
65 | | //! Set up a rotamer list based on the supplied reference atoms and the number of rotors |
66 | | //! \param mol The molecule to evaluate |
67 | | //! \param ref An array of the 4 dihedral atoms for each rotor |
68 | | //! \param nrotors The number of rotors (i.e., the size of ref / 4) |
69 | | void Setup(OBMol &mol,unsigned char*ref,int nrotors); |
70 | | //! \return the number of rotatable bonds considered |
71 | | unsigned int NumRotors() const |
72 | 0 | { |
73 | 0 | return (unsigned int)_vrotor.size(); |
74 | 0 | } |
75 | | //! \return the number of rotamer (conformation) coordinate sets |
76 | | unsigned int NumRotamers() const |
77 | 0 | { |
78 | 0 | return (unsigned int)_vrotamer.size(); |
79 | 0 | } |
80 | | //! Add a rotamer to the list based on the supplied coordinate set as a double* |
81 | | void AddRotamer(double*); |
82 | | //! Add a rotamer to the list based on @p key as a configuration of the individual rotor bonds |
83 | | void AddRotamer(int *key); |
84 | | //! Add a rotamer to the list based on @p key as a configuration of the individual rotor bonds |
85 | | void AddRotamer(std::vector<int> key); |
86 | | //! Add a rotamer to the list based on @p key as a configuration of the individual rotor bonds |
87 | | void AddRotamer(unsigned char *key); |
88 | | //! Add @p nconf rotamers based on @p as an array of configurations much like AddRotamer() |
89 | | void AddRotamers(unsigned char *arr,int nconf); |
90 | | //! \return A reference array (as used by AddRotamer() as a configuration of the individual rotor bonds |
91 | | void GetReferenceArray(unsigned char*) const; |
92 | | |
93 | | //! \name Iterator methods |
94 | | //@{ |
95 | | std::vector<unsigned char*>::iterator BeginRotamer() |
96 | 0 | { |
97 | 0 | return _vrotamer.begin(); |
98 | 0 | } |
99 | | std::vector<unsigned char*>::iterator EndRotamer() |
100 | 0 | { |
101 | 0 | return _vrotamer.end(); |
102 | 0 | } |
103 | | //@} |
104 | | |
105 | | //! \brief Create a conformer list using the internal base set of coordinates |
106 | | //! \return The set of coordinates by rotating the bonds in each rotamer |
107 | | std::vector<double*> CreateConformerList(OBMol& mol); |
108 | | |
109 | | //! \brief Create a conformer list using the internal base set of coordinates |
110 | | //! \return The set of coordinates as a reference in @p confs |
111 | | void ExpandConformerList(OBMol&mol,std::vector<double*>& confs); |
112 | | |
113 | | bool SetCurrentCoordinates(OBMol &mol, std::vector<int> arr); |
114 | | |
115 | | //! \brief Copies the mol's conformers (the coordinates, NOT the pointers) |
116 | | //! into the object as base coordinates |
117 | | void SetBaseCoordinateSets(OBMol& mol); |
118 | | |
119 | | //! Copies the coordinates in bc, NOT the pointers, into this object |
120 | | /** \param bc The conformer set for the molecule |
121 | | \param N The number of atoms in the molecule |
122 | | **/ |
123 | | void SetBaseCoordinateSets(std::vector<double*> bc, unsigned int N); |
124 | | |
125 | | //! \return The number of "base" coordinate sets (i.e., the number of conformers in the base OBMol) |
126 | | unsigned int NumBaseCoordinateSets() const |
127 | 0 | { |
128 | 0 | return static_cast<unsigned int> (_c.size()); |
129 | 0 | } |
130 | | |
131 | | //! Get a pointer to a specific base pointer (i.e., specific conformer) |
132 | | double *GetBaseCoordinateSet(unsigned int i) const |
133 | 0 | { |
134 | 0 | return (i<_c.size()) ? _c[i] : nullptr; |
135 | 0 | } |
136 | | |
137 | | //! \return The number of atoms in the base OBMol |
138 | | unsigned int NumAtoms() const |
139 | 0 | { |
140 | 0 | return _NBaseCoords; |
141 | 0 | } |
142 | | }; |
143 | | |
144 | | //! Swap Byte instruction (i.e., handle transfers between endian forms) |
145 | | int Swab(int); |
146 | | |
147 | | } |
148 | | |
149 | | #endif // OB_ROTAMER_H |
150 | | |
151 | | //! \file rotamer.h |
152 | | //! \brief Handle rotamer list data. |