BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PDBFile.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_FORMAT_PDBFILE_H
6 #define BALL_FORMAT_PDBFILE_H
7 
8 #ifndef BALL_CONCEPT_PROPERTY_H
9 # include <BALL/CONCEPT/property.h>
10 #endif
11 
12 #ifndef BALL_FORMAT_GENERICMOLFILE_H
14 #endif
15 
16 #ifndef BALL_DATATYPE_OPTIONS_H
17 # include <BALL/DATATYPE/options.h>
18 #endif
19 
20 #ifndef BALL_DATATYPE_QUADRUPLE_H
21 # include <BALL/DATATYPE/quadruple.h>
22 #endif
23 
24 #ifndef BALL_FORMAT_PDBDEFS_H
25 # include <BALL/FORMAT/PDBdefs.h>
26 #endif
27 
28 #ifndef BALL_FORMAT_PDBINFO_H
29 # include <BALL/FORMAT/PDBInfo.h>
30 #endif
31 
32 #ifndef BALL_KERNEL_PDBAtom_H
33 # include <BALL/KERNEL/PDBAtom.h>
34 #endif
35 
36 #ifndef BALL_KERNEL_SYSTEM_H
37 # include <BALL/KERNEL/system.h>
38 #endif
39 
40 #ifndef BALL_KERNEL_RESIDUE_H
41 # include <BALL/KERNEL/residue.h>
42 #endif
43 
44 #ifndef BALL_KERNEL_SECONDARYSTRUCTURE_H
46 #endif
47 
48 #if defined(BALL_HAS_UNORDERED_MAP) || defined(BALL_HAS_HASH_MAP)
49 #ifdef BALL_EXTEND_HASH_IN_STD_NS
50 namespace std
51 {
52 #endif
53  namespace BALL_MAP_NAMESPACE {
54  template<>
55  struct hash<BALL::Quadruple<BALL::String, BALL::PDB::Character, BALL::PDB::Integer, BALL::PDB::AChar> >
56  {
57  size_t
59  { return (size_t)f.third; }
60  };
61  }
62 #ifdef BALL_EXTEND_HASH_IN_STD_NS
63 }
64 #endif
65 #endif
66 
67 namespace BALL
68 {
69 
75  : public GenericMolFile,
76  public PropertyManager
77  {
78  public:
79 
86  {
93  static const char* VERBOSITY;
94 
101  static const char* STRICT_LINE_CHECKING;
102 
110  static const char* CHOOSE_MODEL;
111 
117  static const char* STORE_SKIPPED_RECORDS;
118 
124  static const char* IGNORE_XPLOR_PSEUDO_ATOMS;
125 
131  static const char* PARSE_PARTIAL_CHARGES;
132 
137  static const char* WRITE_PDBFORMAT_1996;
138  };
139 
143  {
148  static const Index VERBOSITY;
149 
154  static const bool STRICT_LINE_CHECKING;
155 
160  static const Index CHOOSE_MODEL;
161 
165  static const bool STORE_SKIPPED_RECORDS;
166 
170  static const bool IGNORE_XPLOR_PSEUDO_ATOMS;
171 
175  static const bool PARSE_PARTIAL_CHARGES;
176 
181  static const bool WRITE_PDBFORMAT_1996;
182 
183  };
184 
188 
193 
197 
200  PDBFile();
201 
205  PDBFile(const String& filename, File::OpenMode open_mode = std::ios::in);
206 
209  PDBFile(const Options& new_options);
210 
213  virtual ~PDBFile();
215 
219 
221  virtual void clear(int state);
222 
224  virtual void clear();
225 
227 
231 
233  virtual float getVersion() const;
234 
239  void selectModel(Index index);
240 
252  void selectAltLocationIndicator(char c);
253 
255  Index getSelectedModel() const;
256 
258  void selectAllModels();
259 
261  Index getCurrentModel() const;
262 
264  char* getRecordString();
265 
267  const char* getRecordString() const;
268 
270  Index getRecordNumber() const;
271 
273  PDB::RecordType getRecordType() const;
274 
278  virtual const char* getAtomElementSymbol
279  (const PDB::Atom atom_name,
280  PDB::Atom element_symbol);
281 
283  virtual const char* getAtomName
284  (const PDB::Atom atom_name);
285 
287  virtual char getAtomRemotenessIndicator
288  (const PDB::Atom atom_name);
289 
291  virtual short getAtomBranchDesignator
292  (const PDB::Atom atom_name);
293 
295  Size countRecordFields() const;
296 
300  Size countRecord
301  (PDB::RecordType record_type,
302  bool from_begin_of_file = true);
303 
306  Size countRecords
307  (bool from_begin_of_file = true);
309 
316 
317  bool parseLine(const char* line, Size size, const char* format_string, ...);
318 
320  bool readLine(char* line, Size size, bool extract_values);
321 
323  bool readFirstRecord(bool read_values = true);
324 
326  bool readNextRecord(bool read_values = true);
327 
332  bool readRecords();
333 
338  virtual bool readUnknownRecord(const char* line);
339 
342  virtual bool readInvalidRecord(const char* line);
343 
352  bool skipCurrentRecord();
353 
355  virtual bool interpretRecord(const PDB::RecordANISOU& record);
356  virtual bool fillRecord(const char* line, Size size, PDB::RecordANISOU& record);
357  virtual bool parseRecordANISOU(const char* line, Size size);
358 
360  virtual bool interpretRecord(const PDB::RecordATOM& record);
361  virtual bool fillRecord(const char* line, Size size, PDB::RecordATOM& record);
362  virtual bool parseRecordATOM(const char* line, Size size);
363 
365  virtual bool interpretRecord(const PDB::RecordAUTHOR& record);
366  virtual bool fillRecord(const char* line, Size size, PDB::RecordAUTHOR& record);
367  virtual bool parseRecordAUTHOR(const char* line, Size size);
368 
370  virtual bool interpretRecord(const PDB::RecordCAVEAT& record);
371  virtual bool fillRecord(const char* line, Size size, PDB::RecordCAVEAT& record);
372  virtual bool parseRecordCAVEAT(const char* line, Size size);
373 
375  virtual bool interpretRecord(const PDB::RecordCISPEP& record);
376  virtual bool fillRecord(const char* line, Size size, PDB::RecordCISPEP& record);
377  virtual bool parseRecordCISPEP(const char* line, Size size);
378 
380  virtual bool interpretRecord(const PDB::RecordCOMPND& record);
381  virtual bool fillRecord(const char* line, Size size, PDB::RecordCOMPND& record);
382  virtual bool parseRecordCOMPND(const char* line, Size size);
383 
385  virtual bool interpretRecord(const PDB::RecordCONECT& record);
386  virtual bool fillRecord(const char* line, Size size, PDB::RecordCONECT& record);
387  virtual bool parseRecordCONECT(const char* line, Size size);
388 
392  virtual bool interpretRecord(const PDB::RecordCRYST1& record);
393  virtual bool fillRecord(const char* line, Size size, PDB::RecordCRYST1& record);
394  virtual bool parseRecordCRYST1(const char* line, Size size);
395 
397  virtual bool interpretRecord(const PDB::RecordDBREF& record);
398  virtual bool fillRecord(const char* line, Size size, PDB::RecordDBREF& record);
399  virtual bool parseRecordDBREF(const char* line, Size size);
400 
402  virtual bool interpretRecord(const PDB::RecordEND& record);
403  virtual bool fillRecord(const char* line, Size size, PDB::RecordEND& record);
404  virtual bool parseRecordEND(const char* line, Size size);
405 
407  virtual bool interpretRecord(const PDB::RecordENDMDL& record);
408  virtual bool fillRecord(const char* line, Size size, PDB::RecordENDMDL& record);
409  virtual bool parseRecordENDMDL(const char* line, Size size);
410 
412  virtual bool interpretRecord(const PDB::RecordEXPDTA& record);
413  virtual bool fillRecord(const char* line, Size size, PDB::RecordEXPDTA& record);
414  virtual bool parseRecordEXPDTA(const char* line, Size size);
415 
419  virtual bool interpretRecord(const PDB::RecordFORMUL& record);
420  virtual bool fillRecord(const char* line, Size size, PDB::RecordFORMUL& record);
421  virtual bool parseRecordFORMUL(const char* line, Size size);
422 
424  virtual bool interpretRecord(const PDB::RecordFTNOTE& record);
425  virtual bool fillRecord(const char* line, Size size, PDB::RecordFTNOTE& record);
426  virtual bool parseRecordFTNOTE(const char* line, Size size);
427 
431  virtual bool interpretRecord(const PDB::RecordHEADER& record);
432  virtual bool fillRecord(const char* line, Size size, PDB::RecordHEADER& record);
433  virtual bool parseRecordHEADER(const char* line, Size size);
434 
436  virtual bool interpretRecord(const PDB::RecordHELIX& record);
437  virtual bool fillRecord(const char* line, Size size, PDB::RecordHELIX& record);
438  virtual bool parseRecordHELIX(const char* line, Size size);
439 
441  virtual bool interpretRecord(const PDB::RecordHET& record);
442  virtual bool fillRecord(const char* line, Size size, PDB::RecordHET& record);
443  virtual bool parseRecordHET(const char* line, Size size);
444 
446  virtual bool interpretRecord(const PDB::RecordHETATM& record);
447  virtual bool fillRecord(const char* line, Size size, PDB::RecordHETATM& record);
448  virtual bool parseRecordHETATM(const char* line, Size size);
449 
451  virtual bool interpretRecord(const PDB::RecordHETNAM& record);
452  virtual bool fillRecord(const char* line, Size size, PDB::RecordHETNAM& record);
453  virtual bool parseRecordHETNAM(const char* line, Size size);
454 
456  virtual bool interpretRecord(const PDB::RecordHETSYN& record);
457  virtual bool fillRecord(const char* line, Size size, PDB::RecordHETSYN& record);
458  virtual bool parseRecordHETSYN(const char* line, Size size);
459 
461  virtual bool interpretRecord(const PDB::RecordHYDBND& record);
462  virtual bool fillRecord(const char* line, Size size, PDB::RecordHYDBND& record);
463  virtual bool parseRecordHYDBND(const char* line, Size size);
464 
466  virtual bool interpretRecord(const PDB::RecordJRNL& record);
467  virtual bool fillRecord(const char* line, Size size, PDB::RecordJRNL& record);
468  virtual bool parseRecordJRNL(const char* line, Size size);
469 
471  virtual bool interpretRecord(const PDB::RecordKEYWDS& record);
472  virtual bool fillRecord(const char* line, Size size, PDB::RecordKEYWDS& record);
473  virtual bool parseRecordKEYWDS(const char* line, Size size);
474 
476  virtual bool interpretRecord(const PDB::RecordLINK& record);
477  virtual bool fillRecord(const char* line, Size size, PDB::RecordLINK& record);
478  virtual bool parseRecordLINK(const char* line, Size size);
479 
483  virtual bool interpretRecord(const PDB::RecordMASTER& record);
484  virtual bool fillRecord(const char* line, Size size, PDB::RecordMASTER& record);
485  virtual bool parseRecordMASTER(const char* line, Size size);
486 
488  virtual bool interpretRecord(const PDB::RecordMODEL& record);
489  virtual bool fillRecord(const char* line, Size size, PDB::RecordMODEL& record);
490  virtual bool parseRecordMODEL(const char* line, Size size);
491 
493  virtual bool interpretRecord(const PDB::RecordMODRES& record);
494  virtual bool fillRecord(const char* line, Size size, PDB::RecordMODRES& record);
495  virtual bool parseRecordMODRES(const char* line, Size size);
496 
500  virtual bool interpretRecord(const PDB::RecordMTRIX1& record);
501  virtual bool fillRecord(const char* line, Size size, PDB::RecordMTRIX1& record);
502  virtual bool parseRecordMTRIX1(const char* line, Size size);
503 
507  virtual bool interpretRecord(const PDB::RecordMTRIX2& record);
508  virtual bool fillRecord(const char* line, Size size, PDB::RecordMTRIX2& record);
509  virtual bool parseRecordMTRIX2(const char* line, Size size);
510 
514  virtual bool interpretRecord(const PDB::RecordMTRIX3& record);
515  virtual bool fillRecord(const char* line, Size size, PDB::RecordMTRIX3& record);
516  virtual bool parseRecordMTRIX3(const char* line, Size size);
517 
521  virtual bool interpretRecord(const PDB::RecordOBSLTE& record);
522  virtual bool fillRecord(const char* line, Size size, PDB::RecordOBSLTE& record);
523  virtual bool parseRecordOBSLTE(const char* line, Size size);
524 
528  virtual bool interpretRecord(const PDB::RecordORIGX1& record);
529  virtual bool fillRecord(const char* line, Size size, PDB::RecordORIGX1& record);
530  virtual bool parseRecordORIGX1(const char* line, Size size);
531 
535  virtual bool interpretRecord(const PDB::RecordORIGX2& record);
536  virtual bool fillRecord(const char* line, Size size, PDB::RecordORIGX2& record);
537  virtual bool parseRecordORIGX2(const char* line, Size size);
538 
542  virtual bool interpretRecord(const PDB::RecordORIGX3& record);
543  virtual bool fillRecord(const char* line, Size size, PDB::RecordORIGX3& record);
544  virtual bool parseRecordORIGX3(const char* line, Size size);
545 
547  virtual bool interpretRecord(const PDB::RecordREMARK& record);
548  virtual bool fillRecord(const char* line, Size size, PDB::RecordREMARK& record);
549  virtual bool parseRecordREMARK(const char* line, Size size);
550 
552  virtual bool interpretRecord(const PDB::RecordREVDAT& record);
553  virtual bool fillRecord(const char* line, Size size, PDB::RecordREVDAT& record);
554  virtual bool parseRecordREVDAT(const char* line, Size size);
555 
557  virtual bool interpretRecord(const PDB::RecordSCALE1& record);
558  virtual bool fillRecord(const char* line, Size size, PDB::RecordSCALE1& record);
559  virtual bool parseRecordSCALE1(const char* line, Size size);
560 
562  virtual bool interpretRecord(const PDB::RecordSCALE2& record);
563  virtual bool fillRecord(const char* line, Size size, PDB::RecordSCALE2& record);
564  virtual bool parseRecordSCALE2(const char* line, Size size);
565 
567  virtual bool interpretRecord(const PDB::RecordSCALE3& record);
568  virtual bool fillRecord(const char* line, Size size, PDB::RecordSCALE3& record);
569  virtual bool parseRecordSCALE3(const char* line, Size size);
570 
572  virtual bool interpretRecord(const PDB::RecordSEQADV& record);
573  virtual bool fillRecord(const char* line, Size size, PDB::RecordSEQADV& record);
574  virtual bool parseRecordSEQADV(const char* line, Size size);
575 
577  virtual bool interpretRecord(const PDB::RecordSEQRES& record);
578  virtual bool fillRecord(const char* line, Size size, PDB::RecordSEQRES& record);
579  virtual bool parseRecordSEQRES(const char* line, Size size);
580 
582  virtual bool interpretRecord(const PDB::RecordSHEET& record);
583  virtual bool fillRecord(const char* line, Size size, PDB::RecordSHEET& record);
584  virtual bool parseRecordSHEET(const char* line, Size size);
585 
587  virtual bool interpretRecord(const PDB::RecordSIGATM& record);
588  virtual bool fillRecord(const char* line, Size size, PDB::RecordSIGATM& record);
589  virtual bool parseRecordSIGATM(const char* line, Size size);
590 
594  virtual bool interpretRecord(const PDB::RecordSIGUIJ& record);
595  virtual bool fillRecord(const char* line, Size size, PDB::RecordSIGUIJ& record);
596  virtual bool parseRecordSIGUIJ(const char* line, Size size);
597 
599  virtual bool interpretRecord(const PDB::RecordSITE& record);
600  virtual bool fillRecord(const char* line, Size size, PDB::RecordSITE& record);
601  virtual bool parseRecordSITE(const char* line, Size size);
602 
604  virtual bool interpretRecord(const PDB::RecordSLTBRG& record);
605  virtual bool fillRecord(const char* line, Size size, PDB::RecordSLTBRG& record);
606  virtual bool parseRecordSLTBRG(const char* line, Size size);
607 
611  virtual bool interpretRecord(const PDB::RecordSOURCE& record);
612  virtual bool fillRecord(const char* line, Size size, PDB::RecordSOURCE& record);
613  virtual bool parseRecordSOURCE(const char* line, Size size);
614 
616  virtual bool interpretRecord(const PDB::RecordSPRSDE& record);
617  virtual bool fillRecord(const char* line, Size size, PDB::RecordSPRSDE& record);
618  virtual bool parseRecordSPRSDE(const char* line, Size size);
619 
621  virtual bool interpretRecord(const PDB::RecordSSBOND& record);
622  virtual bool fillRecord(const char* line, Size size, PDB::RecordSSBOND& record);
623  virtual bool parseRecordSSBOND(const char* line, Size size);
624 
626  virtual bool interpretRecord(const PDB::RecordTER& record);
627  virtual bool fillRecord(const char* line, Size size, PDB::RecordTER& record);
628  virtual bool parseRecordTER(const char* line, Size size);
629 
631  virtual bool interpretRecord(const PDB::RecordTITLE& record);
632  virtual bool fillRecord(const char* line, Size size, PDB::RecordTITLE& record);
633  virtual bool parseRecordTITLE(const char* line, Size size);
634 
636  virtual bool interpretRecord(const PDB::RecordTURN& record);
637  virtual bool fillRecord(const char* line, Size size, PDB::RecordTURN& record);
638  virtual bool parseRecordTURN(const char* line, Size size);
639 
643  virtual bool interpretRecord(const PDB::RecordTVECT& record);
644  virtual bool fillRecord(const char* line, Size size, PDB::RecordTVECT& record);
645  virtual bool parseRecordTVECT(const char* line, Size size);
647 
649  virtual bool hasFormat();
650 
654  typedef std::list<ResidueQuadruple> QuadrupleList;
655  typedef std::list<SecondaryStructure*> SecStructList;
656 
657 
660 
664  PDBFile& operator >> (Protein& protein);
665 
669  PDBFile& operator >> (Molecule& molecule);
670 
674  PDBFile& operator >> (System& system);
675 
679  PDBFile& operator << (const Protein& protein);
680 
684  PDBFile& operator << (const System& system);
685 
689  PDBFile& operator << (const Molecule& molecule);
690 
696  bool read(Protein& protein);
697 
703  bool read(Molecule& protein);
704 
710  bool read(System& system);
711 
716  Molecule* read();
717 
723  bool write(const Protein& protein);
724 
730  bool write(const Molecule& molecule);
731 
737  bool write(const System& system);
738 
744  bool write(const System& system, const PDBInfo& info);
746 
747  protected:
748 
749  //_
750  PDBFile(const File& pdbf);
751 
752  //_
753  PDBFile& operator = (const PDBFile& pdbf);
754 
755  /*_ A helper function for initializing certain data structures. Used by
756  constructors.
757  */
758  void init_() ;
759 
760  void postprocessSSBonds_();
761  void postprocessHelices_();
762  void postprocessSheetsTurns_(QuadrupleList& sectruct_list, SecStructList& new_secstruct_list);
763  void postprocessRandomCoils_();
764 
765 
766 
767  // Method related to the writing of PDB files
768 
769  //
770  void write_(const AtomContainer& ac, const PDBInfo& info = PDBInfo());
771 
777  void writeRecord_(PDB::RecordType record, ...);
778  void writeCONECTRecords_(PDB::Structure::ConectAtomList& cl);
779 
786  void writeRawRecord_(const char* format, const char* tag, ...);
787 
789  void addAllRecords_(const PDBInfo& info, PDB::RecordType type);
790 
792  void writeRecord_(const PDB::RecordSEQRES& seqres);
794  void writeRecord_(const PDB::RecordHELIX& helix);
796  void writeRecord_(const PDB::RecordSHEET& helix);
798  void writeRecord_(const PDB::RecordTURN& helix);
800  void writeRecord_(const PDB::RecordSSBOND& helix);
802  void writeRecord_(const PDB::RecordCONECT& helix);
804  void writeRecord_(const PDB::RecordCRYST1& cryst1);
806  void writeRecord_(const PDB::RecordMTRIX1& mtrix1);
808  void writeRecord_(const PDB::RecordMTRIX2& mtrix2);
810  void writeRecord_(const PDB::RecordMTRIX3& mtrix3);
811 
812  void writeAtom_(const PDB::Structure::AtomEntry& atom, PDB::AdditionalAtomInfo& cr, bool hetatm = false);
813 
814  void writeTitleSection_(const PDB::Structure& structure, const PDBInfo& info);
815  void writePrimaryStructureSection_(const PDB::Structure& structure, const PDBInfo& info);
816  void writeHeterogenSection_(const PDB::Structure& structure, const PDBInfo& info);
817  void writeSecondaryStructureSection_(const PDB::Structure& structure, const PDBInfo& info);
818  void writeConnectivityAnnotationSection_(const PDB::Structure& structure, const PDBInfo& info);
819  void writeMiscellaneousFeaturesSection_(const PDB::Structure& structure, const PDBInfo& info);
820  void writeCrystallographicSection_(const PDB::Structure& structure, const PDBInfo& info);
821  void writeCoordinateSection_(const PDB::Structure& structure, const PDBInfo& info);
822  void writeConnectivitySection_(const PDB::Structure& structure, const PDBInfo& info);
823  void writeBookKeepingSection_(const PDB::Structure& structure, const PDBInfo& info);
824 
825  void writeSEQRESSection_(const std::vector<std::pair<char, String> >& chain_residues);
826  void writeHELIXSection_(const PDB::Structure& structure);
827  void writeSHEETSection_(const PDB::Structure& structure);
828  void writeTURNSection_(const PDB::Structure& structure);
829  void writeSSBONDSection_(const PDB::Structure& structure);
830  void writeHYDBNDSection_(const PDB::Structure& structure);
831  void writeSLTBRGSection_(const PDB::Structure& structure);
832  void writeCRYST1Section_(const PDB::Structure& structure);
833  void writeMTRIXnSection_(const PDB::Structure& structure);
834 
838  static void extractStructure_(const AtomContainer& ac, PDB::Structure& structure);
839 
843  static bool isHeteroAtom_(const Atom& atom);
844 
850  static void updateAdditionalAtomInfo_(const PDB::Structure::AtomEntry& atom, PDB::AdditionalAtomInfo& cr);
851 
852 
853  char line_buffer_[PDB::SIZE_OF_PDB_LINE_BUFFER];
854 
862 
869 
873 
889 
892 
895 
897 
900 
903 
906 
909 
912  };
913 
914 
915 
916 
917 
921  inline
923 
924  {
925  return (Index)quadruple.third;
926  }
927 
931  inline
932  BALL_EXPORT std::ostream& operator << (std::ostream& s, const Quadruple<String,PDB::Character,PDB::Integer,PDB::AChar>& /* q */)
933  {
934  return s;
935  }
936 
937 
938 
939 # ifndef BALL_NO_INLINE_FUNCTIONS
940 # include <BALL/FORMAT/PDBFile.iC>
941 # endif
942 
943 } // namespace BALL
944 
945 #endif // BALL_FORMAT_PDBFILE_H