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