Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PDBInfo.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/pose/PDBInfo.hh
11 /// @brief pose information so it's not loose in the pose
12 /// @author Steven Lewis
13 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
14 
15 
16 #ifndef INCLUDED_core_pose_PDBInfo_hh
17 #define INCLUDED_core_pose_PDBInfo_hh
18 
19 #include <core/pose/PDBInfo.fwd.hh>
20 
21 // Unit headers
22 #include <core/pose/Pose.fwd.hh>
23 
24 // type headers
25 #include <core/types.hh>
26 
27 // Project headers
32 
33 #include <core/pose/PDBPoseMap.hh>
34 
36 #include <core/pose/Remarks.hh>
37 
38 // Utility headers
39 #include <utility/exit.hh>
40 #include <utility/PyAssert.hh>
41 #include <utility/pointer/ReferenceCount.hh>
42 // AUTO-REMOVED
43 #include <utility/vector1.hh>
44 
45 #include <numeric/xyzVector.hh>
46 
47 // C++ Headers
48 #include <algorithm>
49 #include <map>
50 
51 namespace core {
52 namespace pose {
53 
54 // TODO move this to core/chemical/types.hh
55 static std::string const chr_chains( " ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz" );
56 
57 
58 ///@brief info about an atom in a unrecognized res (not in pose, but we want to remember it)
60 
61 public:
62 
64  Size res_num,
68  Real temp
69  ) : res_num_(res_num),
70  res_name_(res_name),
71  atom_name_(atom_name),
72  coords_(coords),
73  temp_(temp)
74  {}
75 
76  inline core::Size const & res_num() const { return res_num_; }
77  inline std::string const & res_name() const { return res_name_; }
78  inline std::string const & atom_name() const { return atom_name_; }
79  inline numeric::xyzVector<Real> const & coords() const { return coords_; }
80  inline Real const & temp() const { return temp_; }
81 
82 private:
83 
88 
89 };
90 
91 
92 /// @brief maintains pdb residue & atom information inside a Pose
93 /// @details Upon creation of new residue records, e.g. when calling the
94 /// constructors without 'init' or appending/prepending residues, the
95 /// chain id for the new records will be set to a character, currently
96 /// '^', denoting "empty record". This character may be looked up by
97 /// calling the static method PDBInfo::empty_record().
98 /// @remarks Class implementation is biased towards simplicity and fast lookup.
99 /// Residue/atom information are kept in vectors. An internally maintained
100 /// PDBPoseMap provides mapping from pdb -> pose residue numbering. This
101 /// causes residue mutators to be a bit more expensive due to map updates,
102 /// but this is ok because they are typically called sparingly. Accessors
103 /// and mutators have overloaded method convention, while special mutators
104 /// use .set_* convention.
106 
107 
108 public: // typedefs
109 
110 
112 
113  typedef core::Size Size;
114  typedef core::Real Real;
117 
118 
119 private: // forward declarations
120 
121 
122  struct AtomRecord;
124 
125 
126 private: // typedefs
127 
128 
131 
132 
133 private: // structs
134 
135 
136  /// @brief internal struct for storing PDB atom related information
137  struct AtomRecord {
138  /// @brief default constructor
140  isHet( false ),
141  altLoc( ' ' ),
142  occupancy( 1.0 ),
143  temperature( 0.0 )
144  {}
145 
146  /// @brief Returns true if there is a heteroatom in the pdb
147  bool isHet;
148  /// @brief alternate location
149  char altLoc;
150  /// @brief occupancy
152  /// @brief temperature factor
154 #ifdef USEBOOSTSERIALIZE
155  friend class boost::serialization::access;
156 
157  // lazy as hell, only serializing remarks + pdb2posemap now
158  template<class Archive>
159  void serialize(Archive & ar, const unsigned int version) {
160  ar & isHet;
161  ar & altLoc;
162  ar & occupancy;
163  ar & temperature;
164  }
165 #endif
166  };
167 
168 
169  /// @brief internal struct for storing PDB residue related information
170  struct ResidueRecord {
171  /// @brief default constructor
174  resSeq( 0 ),
175  iCode( ' ')
176  {}
177 
178  /// @brief chain id
179  char chainID;
180  /// @brief residue sequence number
181  int resSeq;
182  /// @brief insertion code
183  char iCode;
184  /// @brief vector of AtomRecord
185  /// @details sized the same as number of atoms for a given instance of core::conformation::Residue
187 #ifdef USEBOOSTSERIALIZE
188  friend class boost::serialization::access;
189 
190  // lazy as hell, only serializing remarks + pdb2posemap now
191  template<class Archive>
192  void serialize(Archive & ar, const unsigned int version) {
193  ar & chainID;
194  ar & resSeq;
195  ar & iCode;
196  ar & atomRec;
197  }
198 #endif
199  };
200 
201 
202 public: // constructors
203 
204 
205  /// @brief default constructor, obsolete is *true*
206  PDBInfo();
207 
208 
209  /// @brief size constructor (ensure space for 'n' residue records),
210  /// obsolete is *true*
211  PDBInfo( Size const n );
212 
213 
214  /// @brief Pose constructor (ensures space for residue and atom records
215  /// relative to Pose)
216  /// @param[in] pose Pose
217  /// @param[in] init if true (default), then residue records are initialized
218  /// and obsolete set to false, otherwise obsolete is true
219  /// using Pose residue numbering and chains of the Residues in the Conformation
220  PDBInfo(
221  Pose const & pose,
222  bool init = true
223  );
224 
225 
226  /// @brief copy constructor
227  PDBInfo( PDBInfo const & info );
228 
229 
230 public: // destructor
231 
232 
233  /// @brief default destructor
234  virtual ~PDBInfo();
235 
236 
237 public: // assignment
238 
239 
240  /// @brief copy assignment
241  PDBInfo &
242  operator =( PDBInfo const & info );
243 
244 
245 public: // observer interface
246 
247 
248  /// @brief Returns the Conformation if this PDBInfo is currently observing
249  /// a conformation, otherwise return NULL
250  ///
251  /// example(s):
252  /// pose.pdb_info().is_observing()
253  /// See also:
254  /// Pose
255  /// PDBInfo
257  is_observing();
258 
259 
260  /// @brief Attaches the Conformation <conf> and begins observation
261  ///
262  /// example(s):
263  ///
264  /// See also:
265  /// Pose
266  /// PDBInfo
267  void
269 
270 
271  /// @brief Detaches the Conformation and stops observation
272  /// @remarks takes no arguments because PDBInfo can only observe one
273  /// Conformation at a time
274  ///
275  /// example(s):
276  /// pose.pdb_info().detach_from()
277  /// See also:
278  /// Pose
279  /// PDBInfo
280  void
281  detach_from();
282 
283 
284  /// @brief Updates when connection to Conformation is changed
285  void
287 
288 
289  /// @brief Updates atom records when residue identity changes in Conformation
290  void
292 
293 
294  /// @brief Updates residue and atom records when length changes in Conformation,
295  /// obsoletes PDBInfo
296  void
298 
299 
300 public: // obsolescence
301 
302 
303  /// @brief Returns true if PDBInfo is obsolete and needs updating
304  /// @details This flag is currently not used within the class and
305  /// is provided for user convenience. Setting this will
306  /// forcibly turn off pdb numbering when dumping pdbs.
307  ///
308  /// example(s):
309  /// pose.pdb_info().obsolete()
310  /// See also:
311  /// Pose
312  /// PDBInfo
313  inline
314  bool
315  obsolete() const
316  {
317  return obsolete_;
318  }
319 
320 
321  /// @brief Sets the obsolete state to <flag>
322  /// @details this flag is currently not used within the class and
323  /// is provided for user convenience. Setting this will
324  /// forcibly turn off pdb numbering when dumping pdbs.
325  inline
326  void
327  obsolete( bool flag )
328  {
329  obsolete_ = flag;
330  }
331 
332 
333 public: // state
334 
335 
336  /// @brief Returns the number of residues represented in PDBInfo
337  ///
338  /// example(s):
339  /// pose.pdb_info().nres()
340  /// See also:
341  /// Pose
342  /// PDBInfo
343  inline
344  Size
345  nres() const
346  {
347  return residue_rec_.size();
348  }
349 
350 
351  /// @brief Returns the number of atoms represented for the residue <res>
352  /// @note: residue <res> must be in pose numbering
353  ///
354  /// example(s):
355  /// pose.pdb_info().natoms(3)
356  /// See also:
357  /// Pose
358  /// PDBInfo
359  inline
360  Size
361  natoms( Size const res ) const
362  {
363  PyAssert( (res>0) && (res<residue_rec_.size()), "PDBInfo::natoms( Size const res): res is not in this PDBInfo!" );
364  return residue_rec_[ res ].atomRec.size();
365  }
366 
367 
368  /// @brief Resizes for <n> residue records
369  /// @details Leaves atom record state inconsistent. Atom records for
370  /// remaining residues are untouched while new residues have no atom
371  /// records, so make sure and call one of resize_atom_records()
372  /// afterwards if necessary.
373  /// @warning Do not use this method for ins/del of residues, as it leaves
374  /// the data state inconsistent. See append_res/prepend_res/delete_res
375  /// for that type of functionality.
376  void
377  resize_residue_records( Size const n );
378 
379 
380  /// @brief Ensures <n> atom records for residue <res> are available
381  /// @note: if <zero> is true, zero the atom records for this residue
382  void
384  Size const res,
385  Size const n,
386  bool const zero = true
387  );
388 
389 
390  /// @brief Ensures <n> atom records for residue <res> are available
391  /// @note: if <zero> is true, zero the atom records for this residue
392  void
394  Size const n,
395  bool const zero = true
396  );
397 
398 
399  /// @brief Updates the number of atom records with respect to atoms in <pose>
400  /// @details Number of internally available atom records will be adjusted
401  /// to match number of atoms within each residue in Pose. Only newly
402  /// created records will be zeroed, any existing records are untouched.
403  void
404  resize_atom_records( Pose const & pose );
405 
406 
407  /// @brief Tightens memory usage
408  void
409  tighten_memory();
410 
411 
412  /// @brief Returns the chain id character specifying "empty record",
413  /// currently '^'
414  inline
415  static
416  char empty_record() {
417  return '^';
418  }
419 
420 
421 public: // pdb-wide accessors/mutators
422 
423 
424  /// @brief Returns the pdb name
425  ///
426  /// example(s):
427  /// pose.pdb_info().name()
428  /// See also:
429  /// Pose
430  /// PDBInfo
431  inline
432  String const &
433  name() const
434  {
435  return name_;
436  }
437 
438 
439  /// @brief Sets the pdb name
440  ///
441  /// example(s):
442  /// pose.pdb_info().name('MyPDB')
443  /// See also:
444  /// Pose
445  /// PDBInfo
446  inline
447  void
448  name( String const & s )
449  {
450  name_ = s;
451  }
452 
453 
454  /// @brief Returns the model tag for a multi-model pdb
455  ///
456  /// example(s):
457  /// pose.pdb_info().modeltag()
458  /// See also:
459  /// Pose
460  /// PDBInfo
461  inline
462  String const &
463  modeltag() const
464  {
465  return modeltag_;
466  }
467 
468 
469  /// @brief Sets the model tag for a multi-model pdb to <tag>
470  ///
471  /// example(s):
472  /// pose.pdb_info().modeltag('Number1')
473  /// See also:
474  /// Pose
475  /// PDBInfo
476  inline
477  void
478  modeltag( String const & tag )
479  {
480  modeltag_ = tag;
481  }
482 
483 
484  /// @brief Returns the pdb remarks (const)
485  ///
486  /// example(s):
487  /// pose.pdb_info().remarks()
488  /// See also:
489  /// Pose
490  /// PDBInfo
491  inline
492  Remarks const &
493  remarks() const
494  {
495  return remarks_;
496  }
497 
498 
499  /// @brief Returns the pdb remarks (mutable)
500  /// @note we allow direct access to the remarks vector because its
501  /// state is independent of the rest of PDBInfo and it's much more
502  /// convenient for the user
503  ///
504  /// example(s):
505  /// pose.pdb_info().remarks()
506  /// See also:
507  /// Pose
508  /// PDBInfo
509  inline
510  Remarks &
512  {
513  return remarks_;
514  }
515 
516 
517  /// @brief Sets the pdb remarks to <in>
518  ///
519  /// example(s):
520  ///
521  /// See also:
522  /// Pose
523  /// PDBInfo
524  inline
525  void
526  remarks( Remarks const & in )
527  {
528  remarks_ = in;
529  }
530 
531  /// @brief For structures deposited into the protein databank, the
532  /// header information record stores the classfication, deposition
533  /// date and the 4 character identification code.
534 
535  /// For now only allow initalizing it with copy and accessing it
536  /// with a constant owning pointer.
537 
538  /// Note: The header information is only initialized if it is needed.
539  /// Generally this requires using the -run:preserve_header options flag.
540  inline
541  void
544  }
545 
546  inline
549  return header_information_;
550  }
551 
552  inline
555  return header_information_;
556  }
557 
558 
559 public: // single residue accessors
560 
561 
562  /// @brief Returns the chain id for pose residue <res>
563  ///
564  /// example(s):
565  /// pose.pdb_info().chain(3)
566  /// See also:
567  /// Pose
568  /// PDBInfo
569  /// PDBInfo.pdb2pose
570  /// PDBInfo.pose2pdb
571  inline
572  char const &
573  chain( Size const res ) const
574  {
575  //PyAssert( (res>0) && (res<residue_rec_.size()), "PDBInfo::chain( Size const res): res is not in this PDBInfo!" );
576  return residue_rec_[ res ].chainID;
577  }
578 
579 
580  /// @brief Returns the pdb sequence number of pose residue <res>
581  ///
582  /// example(s):
583  /// pose.pdb_info().number(3)
584  /// See also:
585  /// Pose
586  /// PDBInfo
587  /// PDBInfo.pdb2pose
588  /// PDBInfo.pose2pdb
589  inline
590  int const &
591  number( Size const res ) const
592  {
593  //PyAssert( (res>0) && (res<residue_rec_.size()), "PDBInfo::number( Size const res): res is not in this PDBInfo!" );
594  return residue_rec_[ res ].resSeq;
595  }
596 
597 
598  /// @brief Returns the pdb insertion code of residue <res>
599  ///
600  /// example(s):
601  /// pose.pdb_info().icode(3)
602  /// See also:
603  /// Pose
604  /// PDBInfo
605  /// PDBInfo.pdb2pose
606  /// PDBInfo.pose2pdb
607  inline
608  char const &
609  icode( Size const res ) const
610  {
611  //PyAssert( ( (res>0) && (res<residue_rec_.size() ) || residue_rec_.size()==0), "PDBInfo::icode( Size const res): res is not in this PDBInfo!" );
612  return residue_rec_[ res ].iCode;
613  }
614 
615 
616  /// @brief Returns the pose numbering of the pdb residue with chain <chain>,
617  /// pdb residue <res>, and insertion code <icode>
618  /// @note: <icode> is not required, returns 0 if not found,
619  /// pose numbering is sequential ie. starts at 1 and goes up
620  /// pdb numbering can be anything
621  ///
622  /// example(s):
623  /// pose.pdb_info().pdb2pose("B",5)
624  /// See also:
625  /// Pose
626  /// PDBInfo
627  /// PDBInfo.pose2pdb
628  inline
629  Size
631  char const chain,
632  int const res,
633  char const icode = ' '
634  ) const
635  {
636  return pdb2pose_.find( chain, res, icode );
637  }
638 
639 
640  /// @brief Returns the pdb numbering string of pose residue <res>
641  /// @note: pdb string contains the chainID and number
642  /// pose numbering is sequential ie. starts at 1 and goes up
643  /// pdb numbering can be anything
644  ///
645  /// example(s):
646  /// pose.pdb_info().pose2pdb(25)
647  /// See also:
648  /// Pose
649  /// PDBInfo
650  /// PDBInfo.pdb2pose
651  String
652  pose2pdb( Size const res ) const;
653 
654 
655 public: // single residue mutators
656 
657 
658  /// @brief Sets the chain id of pose residue <res> to <chain_id>
659  /// @remarks chain id should not be the empty record character, currently '^'
660  /// @brief Returns the pdb insertion code of residue <res>
661  ///
662  /// example(s):
663  /// pose.pdb_info().chain(3,"R")
664  /// See also:
665  /// Pose
666  /// PDBInfo
667  /// PDBInfo.pdb2pose
668  /// PDBInfo.pose2pdb
669  void
670  chain(
671  Size const res,
672  char const chain_id
673  );
674 
675 
676  /// @brief Sets the pdb sequence residue number of pose residue <res> to <pdb_res>
677  /// @brief Returns the pdb insertion code of residue <res>
678  ///
679  /// example(s):
680  /// pose.pdb_info().number(3,81)
681  /// See also:
682  /// Pose
683  /// PDBInfo
684  /// PDBInfo.pdb2pose
685  /// PDBInfo.pose2pdb
686  void
687  number(
688  Size const res,
689  int const pdb_res
690  );
691 
692 
693  /// @brief Sets the insertion code of pose residue <res> to <ins_code>
694  /// @brief Returns the pdb insertion code of residue <res>
695  ///
696  /// example(s):
697  ///
698  /// See also:
699  /// Pose
700  /// PDBInfo
701  /// PDBInfo.pdb2pose
702  /// PDBInfo.pose2pdb
703  void
704  icode(
705  Size const res,
706  char const ins_code
707  );
708 
709 
710  /// @brief Sets the chain id, pdb sequence residue numbering, and insertion
711  /// code for pose residue <res> to <chain_id> , <pdb_res> , and
712  /// <ins_code> respectfully
713  /// @note: convenience method; more efficient than doing each individually
714  /// due to map updates
715  /// @brief Returns the pdb insertion code of residue <res>
716  ///
717  /// example(s):
718  /// pose.pdb_info().icode(3)
719  /// See also:
720  /// Pose
721  /// PDBInfo
722  /// PDBInfo.chain
723  /// PDBInfo.icode
724  /// PDBInfo.number
725  /// PDBInfo.pdb2pose
726  /// PDBInfo.pose2pdb
727  void
728  set_resinfo(
729  Size const res,
730  char const chain_id,
731  int const pdb_res,
732  char const ins_code = ' '
733  );
734 
735 
736 public: // atom accessors
737 
738 
739  /// @brief Returns true if the <atom_index> atom of pose residue <res>
740  /// is a heteratom
741  /// @note: atom index within instance of core::conformation::Residue,
742  /// currently Rosetta's pdb file output treats the value of .is_het() as an
743  /// override -- if this is set to true, the record will be hetatm, otherwise it
744  /// will decide by Residue type (the usual default)
745  inline
746  bool const &
748  Size const res,
749  Size const atom_index
750  ) const
751  {
752  return residue_rec_[ res ].atomRec[ atom_index ].isHet;
753  }
754 
755 
756  /// @brief Returns the alternate location for the <atom_index> atom of pose
757  /// residue <res>
758  ///
759  /// example(s):
760  /// pose.pdb_info().alt_loc(1,1)
761  /// See also:
762  /// Pose
763  /// PDBInfo
764  /// PDBInfo.pdb2pose
765  /// PDBInfo.pose2pdb
766  inline
767  char const &
769  Size const res,
770  Size const atom_index
771  ) const
772  {
773  return residue_rec_[ res ].atomRec[ atom_index ].altLoc;
774  }
775 
776 
777  /// @brief Returns the occupancy for the <atom_index> atom of pose residue <res>
778  ///
779  /// example(s):
780  /// pose.pdb_info().occupancy(1,1)
781  /// See also:
782  /// Pose
783  /// PDBInfo
784  /// PDBInfo.pdb2pose
785  /// PDBInfo.pose2pdb
786  inline
787  Real const &
789  Size const res,
790  Size const atom_index
791  ) const
792  {
793  return residue_rec_[ res ].atomRec[ atom_index ].occupancy;
794  }
795 
796 
797  /// @brief Returns the temperature for the <atom_index> atom of pose residue <res>
798  ///
799  /// example(s):
800  /// pose.pdb_info().temperature(1,1)
801  /// See also:
802  /// Pose
803  /// PDBInfo
804  /// PDBInfo.pdb2pose
805  /// PDBInfo.pose2pdb
806  inline
807  Real const &
809  Size const res,
810  Size const atom_index
811  ) const
812  {
813  return residue_rec_[ res ].atomRec[ atom_index ].temperature;
814  }
815 
816 
817 public: // atom mutators
818 
819 
820  /// @brief Sets the heteroatom flag of the <atom_index> atom of pose
821  /// residue <res> to <flag>
822  /// @note currently Rosetta's pdb file output treats the value of .is_het() as an
823  /// override -- if this is set to true, the record will be hetatm, otherwise it
824  /// will decide by Residue type (the usual default)
825  inline
826  void
828  Size const res,
829  Size const atom_index,
830  bool const flag
831  )
832  {
833  residue_rec_[ res ].atomRec[ atom_index ].isHet = flag;
834  }
835 
836 
837  /// @brief Sets the alternate location of the <atom_index> atom of pose
838  /// residue <res> to <loc>
839  /// @note: <loc> is an alternate location character
840  inline
841  void
843  Size const res,
844  Size const atom_index,
845  char const loc
846  )
847  {
848  residue_rec_[ res ].atomRec[ atom_index ].altLoc = loc;
849  }
850 
851 
852  /// @brief Sets the occupancy of the <atom_index> atom of pose residue
853  /// <res> to <occ>
854  inline
855  void
857  Size const res,
858  Size const atom_index,
859  Real const occ
860  )
861  {
862  residue_rec_[ res ].atomRec[ atom_index ].occupancy = occ;
863  }
864 
865 
866  /// @brief Sets the temperature of the <atom_index> atom of pose residue
867  /// <res> to <t>
868  inline
869  void
871  Size const res,
872  Size const atom_index,
873  Real const t
874  )
875  {
876  residue_rec_[ res ].atomRec[ atom_index ].temperature = t;
877  }
878 
879 
880 public: // residue accessors en masse
881 
882 
883  /// @brief Returns the internally maintained PDBPoseMap
884  ///
885  /// example(s):
886  ///
887  /// See also:
888  /// Pose
889  /// PDBInfo
890  /// PDBInfo.pdb2pose
891  /// PDBInfo.pose2pdb
892  inline
893  PDBPoseMap const &
894  pdb2pose() const
895  {
896  return pdb2pose_;
897  }
898 
899  /// @brief Displays segments of PDB information, segments may or may not
900  /// be entire chains
901  ///
902  /// example(s);
903  /// pose.pdb_info().show()
904  ///
905  /// See Also:
906  /// PDBInfo
907  /// PDBInfo.chain
908  /// PDBInfo.icode
909  /// PDBInfo.nres
910  /// PDBInfo.number
911  /// Pose
912  /// Pose.pdb_info
913  void
914  show( std::ostream & out ) const;
915 
916 
917 public: // residue mutators en masse
918 
919 
920  /// @brief Sets all residue chain ids to the character <id>
921  void set_chains( char const id );
922 
923 
924  /// @brief Sets the residue chain ids from some char container, iterator version
925  /// @warning This function does not check if number of elements within span
926  /// of iterators exceeds number of residues currently defined in object.
927  /// User must ensure this independently.
928  template< typename CharIterator >
929  inline
930  void
932  CharIterator const & begin,
933  CharIterator const & end
934  )
935  {
936  ResidueRecords::iterator rr = residue_rec_.begin();
937 
938  for ( CharIterator i = begin; i < end; ++i, ++rr ) {
939  rr->chainID = *i;
940  assert( rr < residue_rec_.end() );
941  }
942 
944  }
945 
946 
947  /// @brief Sets the residue chain ids from some char container, e.g. utility::vector1
948  /// @details Container must have const .size(), .begin() and .end() iterator
949  /// access methods.
950  /// @warning This function checks for size first and will cause failure if
951  /// size of container does not match number of residues currently defined
952  /// in object.
953  template< typename CharContainer >
954  inline
955  void
956  set_chains( CharContainer const & c )
957  {
958  assert( residue_rec_.size() == c.size() );
959  check_residue_records_size( c.size() ); // run-time check
960 
961  set_chains( c.begin(), c.end() );
962  }
963 
964 
965  /// @brief Sets the pdb sequence residue numbering from some int container, iterator version
966  /// @warning This function does not check if number of elements within span
967  /// of iterators exceeds number of residues currently defined in object.
968  /// User must ensure this independently.
969  template< typename IntIterator >
970  inline
971  void
973  IntIterator const & begin,
974  IntIterator const & end
975  )
976  {
977  ResidueRecords::iterator rr = residue_rec_.begin();
978 
979  for ( IntIterator i = begin; i < end; ++i, ++rr ) {
980  rr->resSeq = *i;
981  assert( rr < residue_rec_.end() );
982  }
983 
985  }
986 
987 
988  /// @brief Sets the pdb sequence residue numbering from some int container, e.g. utility::vector1
989  /// @details Container must have const .size(), .begin() and .end() iterator
990  /// access methods.
991  /// @warning This function checks for size first and will cause failure if
992  /// size of container does not match number of residues currently defined
993  /// in object.
994  template< typename IntContainer >
995  inline
996  void
997  set_numbering( IntContainer const & c )
998  {
999  assert( residue_rec_.size() == c.size() );
1000  check_residue_records_size( c.size() ); // run-time check
1001 
1002  set_numbering( c.begin(), c.end() );
1003  }
1004 
1005 
1006  /// @brief Sets the insertion codes from some char container, iterator version
1007  /// @warning This function does not check if number of elements within span
1008  /// of iterators exceeds number of residues currently defined in object.
1009  /// User must ensure this independently.
1010  template< typename CharIterator >
1011  inline
1012  void
1014  CharIterator const & begin,
1015  CharIterator const & end
1016  )
1017  {
1018  ResidueRecords::iterator rr = residue_rec_.begin();
1019 
1020  for ( CharIterator i = begin; i < end; ++i, ++rr ) {
1021  rr->iCode = *i;
1022  assert( rr < residue_rec_.end() );
1023  }
1024 
1025  rebuild_pdb2pose();
1026  }
1027 
1028 
1029  /// @brief Sets the insertion codes from some char container, e.g. utility::vector1
1030  /// @details Container must have const .size(), .begin() and .end() iterator
1031  /// access methods.
1032  /// @warning This function checks for size first and will cause failure if
1033  /// size of container does not match number of residues currently defined
1034  /// in object.
1035  template< typename CharContainer >
1036  inline
1037  void
1038  set_icodes( CharContainer const & c )
1039  {
1040  assert( residue_rec_.size() == c.size() );
1041  check_residue_records_size( c.size() ); // run-time check
1042 
1043  set_icodes( c.begin(), c.end() );
1044  }
1045 
1046 
1047  /// @brief Copyies a section from PDBInfo <input_info>
1048  /// @param[in] input_info the PDBInfo to copy from
1049  /// @param[in] copy_from the first residue position in input_info to copy
1050  /// @param[in] copy_to the final residue position in input_info to copy
1051  /// @param[in] start_from the first residue position in this PDBInfo to
1052  /// copy into
1053  void
1054  copy(
1055  PDBInfo const & input_info,
1056  Size const copy_from,
1057  Size const copy_to,
1058  Size const start_from
1059  );
1060 
1061 
1062 public: // residue insertion/deletion
1063 
1064 
1065  /// @brief Appends residue records given a pose residue number <res>
1066  /// @param[in] res residue to append after (in internal/pose numbering)
1067  /// @param[in] natoms number of atoms in type of appended residue
1068  /// @param[in] n number of residue records to append
1069  void
1070  append_res(
1071  Size const res,
1072  Size const natoms,
1073  Size const n = 1
1074  );
1075 
1076 
1077  /// @brief Prepends residue records before given pose residue number <res>
1078  /// @param[in] res residue to prepend before (in internal/pose numbering)
1079  /// @param[in] natoms number of atoms in type of appended residue
1080  /// @param[in] n number of residue records to prepend
1081  void
1082  prepend_res(
1083  Size const res,
1084  Size const natoms,
1085  Size const n = 1
1086  );
1087 
1088 
1089  /// @brief "Replaces" residue record for pose residue <res>
1090  /// @details Leaves information in residue record untouched, but resizes
1091  /// and zeroes atom records for the residue.
1092  /// @param[in] res residue to replace
1093  /// @param[in] natoms number of atoms in type of residue
1094  void
1095  replace_res(
1096  Size const res,
1097  Size const natoms
1098  );
1099 
1100 
1101  /// @brief Deletes <n> residue records starting from pose residue <res>
1102  /// @param[in] res residue to start deleting from (in internal/pose numbering)
1103  /// @param[in] n number of residue records to delete
1104  void
1105  delete_res(
1106  Size const res,
1107  Size const n = 1
1108  );
1109 
1110 
1111  // added by sheffler
1112  /// @brief remembers info about atoms not read into the pose
1113  inline
1116  return unrecognized_atoms_;
1117  }
1118 
1119 
1120  core::Size const &
1122  return num_unrecognized_atoms_;
1123  }
1124 
1125 
1126  inline
1127  core::Size const &
1129  return num_unrecognized_res_;
1130  }
1131 
1132 
1133  inline
1134  std::string const &
1136  return unrecognized_res_num2name_.find(i)->second;
1137  }
1138 
1139 
1140  inline
1141  core::Size const &
1143  return unrecognized_res_size_.find(i)->second;
1144  }
1145 
1146 
1147  // added by sheffler
1148  /// @brief remembers info about atoms not read into the pose
1149  void
1151  Size resnum,
1152  std::string resname,
1153  std::string atomname,
1154  numeric::xyzVector<Real> coords,
1155  Real temp
1156  );
1157 
1158  /// @brief rebuilds PDBPoseMap from scratch
1159  //fpd making this public because methods in this class don't keep the pdb2pose mapping in sync
1160  void
1161  rebuild_pdb2pose();
1162 
1163 private: // methods
1164 
1165 
1166  /// @brief if size of residue records != passed value, fail fast
1167  /// @note This is meant to be used only for en masse methods, not individual
1168  /// residue/atom methods
1169  void
1170  check_residue_records_size( Size const size ) const;
1171 
1172 #ifdef USEBOOSTSERIALIZE
1173  friend class boost::serialization::access;
1174 
1175  // lazy as hell, only serializing remarks + pdb2posemap now
1176  template<class Archive>
1177  void serialize(Archive & ar, const unsigned int version) {
1178  ar & remarks_;
1179  ar & pdb2pose_;
1180  ar & residue_rec_;
1181  ar & obsolete_;
1182  }
1183 #endif
1184 
1185 
1186 private: // data
1187 
1188 
1189  /// @brief indicates object is out of sync with reference (e.g. parent Pose)
1190  /// @details control boolean prevents PDB emitter access if info out of sync
1192 
1193 
1194  /// @brief name of pdb/structure
1196 
1197 
1198  /// @brief model tag for multi-model pdbs
1200 
1201 
1202  /// @brief header information
1204 
1205  /// @brief pdb remarks
1207 
1208 
1209  /// @brief residue records in internal rosetta numbering from 1 .. n
1211 
1212 
1213  /// @brief maps PDB chain,residue -> internal residue numbering
1215 
1216 
1217  /// @brief Conformation being observed, NULL if not attached
1219 
1220 
1221  // added by sheffler
1222  /// @brief information about unrecognized residues
1224  std::map< core::Size, std::string > unrecognized_res_num2name_;
1225  std::map< core::Size, core::Size > unrecognized_res_size_;
1228 
1229 
1230 }; //end class PDBInfo
1231 
1232 // for Python bindings
1233 std::ostream & operator << ( std::ostream & os, PDBInfo const & info);
1234 
1235 } // namespace pose
1236 } // namespace core
1237 
1238 
1239 #endif //INCLUDED_core_pose_PDBInfo_HH