BALL  1.5.0
dockResultFile.h
Go to the documentation of this file.
1 // ----------------------------------------------------
2 // $Maintainer: Marc Röttig $
3 // $Authors: Marc Röttig, Marcel Schumann $
4 // ----------------------------------------------------
5 
6 #ifndef BALL_FORMAT_DOCKRESULTFILE_H
7 #define BALL_FORMAT_DOCKRESULTFILE_H
8 
9 #include <BALL/FORMAT/PDBFile.h>
10 #include <BALL/DATATYPE/hashMap.h>
13 
14 #include <QtXml/QXmlDefaultHandler>
15 #include <QtCore/QXmlStreamReader>
16 #include <QtCore/QXmlStreamWriter>
17 #include <QtCore/QFile>
18 #include <QtCore/QTemporaryFile>
19 
20 #include <vector>
21 
22 namespace BALL
23 {
28  {
29  public:
30 
32 
33  DockResultFile(const String& name, File::OpenMode open_mode = std::ios::in);
34 
35  virtual ~DockResultFile() throw();
36 
41  Receptor* readReceptor();
42 
46  void writeReceptor(Receptor* s);
47 
52  Ligand* readLigand();
53 
57  bool writeLigand(Ligand* lig);
58 
62  void writeResult(Result* res);
63 
67  void writeResults(vector<Result*>& res);
68 
73  vector<Result*> readResults();
74 
76  void close();
77 
78  const vector<Result*>* getResults();
79  void addResult(Result* res);
80 
82  Size countConformations();
83 
84 
87 
89  Molecule* read();
90 
92  bool write(const Molecule& mol);
93 
94  void setOutputParameters(Result::Method, String property_name, String& receptor_conf_UID, String method_description="");
95 
96  void setToolInfo(const String& toolinfo, const String& timestamp);
97 
98  void setInputParameters(list<Size>& selected_results);
99 
100  void selectAllResultsForInput();
101 
103  void disableAutomaticResultCreation();
104 
106  const FlexibleMolecule* getCurrentLigand();
107 
109 
110 
111 
112  private:
113 
114  static const String VERSION;
115 
116  Result* receptor_result_;
117  bool closed_;
118  bool mode_read_;
119  String filename_;
120 
121  String timestamp_;
122  String toolinfo_;
123 
124  // --- for use of GenericMolFile interface functions ---
125  vector<Conformation*> gmf_input_conformations_;
126  static FlexibleMolecule* gmf_current_ligand_;
127  static FlexibleMolecule* gmf_last_ligand_;
128  static bool gmf_new_ligand_read_;
129  HashSet<String> gmf_input_conformation_IDs_;
130  String gmf_property_name_;
131  Result* gmf_result_;
132  Result* gmf_import_;
133  Result::Method gmf_result_method_;
134  String gmf_result_description_;
135  String gmf_receptor_conf_UID_;
136  bool gmf_result_creation_disabled_;
137  // ---------------------------------
138 
139  /* Stores the IDs of the Ligands that have already been written to file in order to make sure that identical molecules are not written multiple times. */
140  HashSet<String> written_ligand_IDs_;
141 
142  QXmlStreamReader* xmlIn_;
143  QFile* file_;
144 
145  // output file handles
146  QTemporaryFile* resultfileTmp_;
147  QTemporaryFile* ligandfileTmp_;
148  QTemporaryFile* receptorfileTmp_;
149  QFile* resultfile_;
150  QFile* ligandfile_;
151  QFile* receptorfile_;
152  QXmlStreamWriter* xmlOutReceptor_;
153  QXmlStreamWriter* xmlOutLigand_;
154  QXmlStreamWriter* xmlOutResult_;
155 
156  vector<Result*> results_;
157  Receptor* receptor_;
158  vector<Ligand*> ligands_;
159 
160  // receptors
161  Protein* current_protein_;
162  Chain* current_chain_;
163  Residue* current_residue_;
164 
165  vector<PDBAtom*> current_PDB_atoms_;
166  HashMap<String,Vector3> pdb_atom_coords_;
167 
168  Position flexdef_idx;
169  FlexDefinition current_flexdef_;
170  Receptor* current_receptor_;
171  Ligand* current_ligand_;
172  String current_ligand_id_;
173  String current_receptor_id_;
174  Molecule* current_molecule_;
175  String current_molecule_id_;
176  String current_conformation_id_;
177  String current_molecule_name_;
178  String current_protein_name_;
179  Atom* current_atom_;
180  Vector3 current_coords_;
181  vector<Atom*> current_atoms_;
182  vector<int> bonds_from_;
183  vector<int> bonds_to_;
184  vector<int> bonds_order_;
185  HashMap<Size,Vector3> current_conformation_data_;
186 
187  // results
188  Result* current_result_;
189  String current_Result_InputPoseId_;
190 
191  void addReceptor(Receptor* s);
192  void addLigand(Ligand* lig);
193  void concatenate();
194  // receptor write
195  void writeReceptors(QXmlStreamWriter &out);
196  void writeReceptor(Receptor* recep, QXmlStreamWriter &out);
197  void writeProtein(Protein* prot, QXmlStreamWriter &out);
198  void writeResidue(Residue* res, QXmlStreamWriter &out);
199  void writePDBAtom(PDBAtom* at, QXmlStreamWriter &out);
200  void writePDBAtom(Atom* at, QXmlStreamWriter &out);
201  void writeConformation(Conformation* conf, QXmlStreamWriter &out);
202  void writeFlexibility(const FlexDefinition &fd, QXmlStreamWriter &out);
203  void writeRotamericFlexibleResidue(Position idx, QXmlStreamWriter &out);
204  void writeFullyFlexibleResidue(Position idx, QXmlStreamWriter &out);
205  // receptor read (might throw BALL::Exception::ParseError)
206  bool readReceptors_();
207  bool readReceptor_();
208  bool readProtein();
209  bool readResidue();
210  bool readPDBAtom();
211  // result read (might throw BALL::Exception::ParseError)
212  bool readResults_();
213  bool readResult();
214  bool readSubResult();
215  bool readEntry();
216  // result write
217  void writeResults(QXmlStreamWriter &out);
218  void writeResult(Result* result, QXmlStreamWriter &out);
219  void writeResultData(const Result::ResultData &rd, QXmlStreamWriter &out);
220  // ligand write
221  void writeLigands(QXmlStreamWriter &out);
222  bool writeLigand(Ligand* lig, QXmlStreamWriter &out);
223  void writeMolecule(Molecule* mol, QXmlStreamWriter &out);
224  void writeAtom(Atom* at, QXmlStreamWriter &out);
225  void writeBond(Bond* b, QXmlStreamWriter &out);
226  // ligand read (might throw BALL::Exception::ParseError)
227  bool readLigands();
228  bool readLigand_();
229  bool readMolecule();
230  bool readConformations(FlexibleMolecule* target);
231  bool readConformation(Conformation* conformation);
232  bool readCoordinates();
233  bool readFlexibility();
234  bool readFlexibilities();
235  bool readFullFlexResidue();
236  bool readRotamericResidue();
237  bool readAtoms();
238  bool readAtom();
239  bool readBonds();
240  bool readBond();
241 
242  // building (might throw BALL::Exception::ParseError)
243  void buildLigand();
244  void buildMolecule();
245  void buildReceptor();
246  void buildProtein();
247  void buildResidue();
248 
249  // helper methods
250  bool retrieveInt(const String& s, int &out);
251  bool retrieveFloat(const String& s, float &out);
252  void setElement(Atom* at, String symbol);
253  bool setCoordinate(const int& idx , const String& coord);
254  static String fromQString(const QString &s);
255  static QString toQString(const String &s);
256  static void attributesToHashMap(const QXmlAttributes& attributes, HashMap<String,String>& map);
257  static void attributesToHashMap(const QXmlStreamAttributes& attributes, HashMap<String,String>& map);
258  static bool isAminoAcid(String s);
259 
260  // we do not allow copy construction ..
261  DockResultFile(const DockResultFile &df);
262  // .. and assignment
263  DockResultFile& operator=(const DockResultFile &df);
264 
265  // XML tags
266  static String ROOTTAG;
267  static String RECEPTORSTAG;
268  static String RECEPTORTAG;
269  static String RECEPTOR_A_ID;
270  static String PROTEINTAG;
271  static String PROTEIN_A_NAME;
272  static String CONFORMATIONSTAG;
273  static String CONFORMATIONTAG;
274  static String CONFORMATION_A_ID;
275  static String FLEXIBILITIESTAG;
276  static String FLEXIBILITYTAG;
277  static String RESIDUETAG;
278  static String RESIDUE_A_NAME;
279  static String RESIDUE_A_IDX;
280  static String PDBATOMTAG;
281  static String PDBATOM_A_NAME;
282 
283  static String RESULTSTAG;
284  static String RESULTTAG;
285  static String RESULT_A_METHOD;
286  static String RESULT_A_METHODSTRING;
287  static String SUBRESULTTAG;
288  static String SUBRESULT_A_LIGCONFID;
289  static String RESULTDATATAG;
290  static String POSEDATATAG;
291  static String RESULTDATA_A_ENERGY;
292  static String RESULTDATA_A_CONFID;
293  static String RESULTDATA_A_LIGID;
294  static String RESULTDATA_A_METHOD;
295 
296  static String LIGANDSTAG;
297  static String LIGANDTAG;
298  static String LIGAND_A_ID;
299  static String MOLECULETAG;
300  static String MOLECULE_A_NAME;
301  static String ATOMTAG;
302  static String ATOM_A_ELEMENT;
303  static String ATOMSTAG;
304  static String BONDSTAG;
305  static String BONDTAG;
306  static String BOND_A_FROM;
307  static String BOND_A_TO;
308  static String BOND_A_ORDER;
309  };
310 }
311 
312 #endif
BALL::DockResultFile::~DockResultFile
virtual ~DockResultFile()
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL::Chain
Definition: chain.h:32
BALL::DockResultFile::DockResultFile
DockResultFile(const String &name, File::OpenMode open_mode=std::ios::in)
BALL::Bond
Definition: bond.h:57
hashMap.h
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions)
Definition: hashMap.h:74
BALL::Molecule
Definition: molecule.h:31
BALL::FlexibleMolecule
Definition: flexibleMolecule.h:23
PDBFile.h
BALL::Atom
Definition: atom.h:90
BALL::PDBAtom
Definition: PDBAtom.h:40
BALL::Result
Definition: result.h:22
BALL::Residue
Definition: residue.h:38
BALL::GenericMolFile
Definition: genericMolFile.h:58
BALL::String
Definition: string.h:57
BALL::Protein
Definition: protein.h:30
BALL
Definition: constants.h:13
BALL::HashSet
Definition: hashSet.h:46
BALL::DockResultFile::SHOW_IDENTICAL_LIGANDS_WARNING
static bool SHOW_IDENTICAL_LIGANDS_WARNING
Definition: dockResultFile.h:31
BALL::File::OpenMode
std::ios::openmode OpenMode
Definition: file.h:165
BALL_SIZE_TYPE
BALL::TVector3< float >
BALL::Conformation
Definition: conformation.h:25
BALL::DockResultFile
Definition: dockResultFile.h:28
BALL::Receptor
Definition: receptor.h:23
BALL::FlexDefinition
Definition: flexDefinition.h:18
receptor.h
result.h