Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
file_data.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/io/pdb/file_data.hh
12 ///
13 /// @brief
14 /// @author Sergey Lyskov
15 
16 #ifndef INCLUDED_core_io_pdb_file_data_hh
17 #define INCLUDED_core_io_pdb_file_data_hh
18 
19 
20 // Unit headers
21 #include <core/io/pdb/Field.fwd.hh>
24 
25 // Package headers
28 
29 // Project headers
31 #include <core/pose/Remarks.hh>
32 
34 #include <core/pose/Pose.fwd.hh>
37 
38 #include <utility/pointer/ReferenceCount.hh>
39 #include <utility/pointer/owning_ptr.hh>
40 
41 
42 #include <utility/vector1.hh>
43 #include <numeric/xyzVector.hh>
44 
45 #include <core/types.hh>
46 
47 // C++ headers
48 #include <iostream>
49 #include <map>
50 #include <string>
51 
52 
53 namespace core {
54 namespace io {
55 namespace pdb {
56 
58 
59 /// @brief A class that contains information for individual atoms.
60 /// @details Only fields that are present in the PDB file will be initialized;
61 /// others will have the default value.
62 /// This class basically reflects the structure of 'ATOM' lines in PDB file format.
64 {
65 public:
66  ///@brief default constructor to initialize all values
68  isHet( false ),
69  serial( 0 ),
70  name( "" ),
71  altLoc( ' ' ),
72  resName( "" ),
73  chainID( ' ' ),
74  resSeq( 0 ),
75  iCode( ' ' ),
76  x( 0.0 ), y( 0.0 ), z( 0.0 ),
77  occupancy( 0.0 ),
78  temperature( 0.0 ),
79  element( "" ),
80  terCount( 0 )
81  {}
82 
83  /// For now, all member names have the same names as fields in PDB standard.
84  bool isHet;
85  int serial;
87  char altLoc;
89  char chainID;
90  int resSeq;
91  char iCode;
92  double x, y, z;
93  double occupancy;
94  double temperature;
96  int terCount; //< number of TER or END cards encountered prior to this
97 
98  /// @brief Debug printing, serializing to Tracer like object.
99  friend std::ostream& operator <<(std::ostream &os, AtomInformation const & ai) {
100  os << "<AtomInformation>{" << "isHet=" << ai.isHet << " serial=" << ai.serial << " name=" << ai.name << " resName=" << ai.resName
101  << " chainID=" << ai.chainID << " resSeq=" << ai.resSeq
102  << " x=" << ai.x << " y=" << ai.y << " z=" << ai.z
103  << " temperature=" << ai.temperature
104  << " occupancy=" << ai.occupancy
105  << " element=" << ai.element
106  << "}";
107  return os;
108  }
109 }; // class AtomInformation
110 
111 typedef std::vector<AtomInformation> AtomChain;
112 
113 
114 /// @brief Intermediate format for easy construction of core::conformation::Residue objects.
115 /// @details Subset of data from "ATOM" lines that is shared by all atoms in a residue.
117 {
118 public:
119  ///@brief default constructor to initialize all values
121 
123 
124  bool operator==(ResidueInformation const & that) const;
125  bool operator!=(ResidueInformation const & that) const;
126 
127  /// For now, all member names have the same names as fields in PDB standard.
128  String resid; //< 6-character (partial) identifier used by reader
130  char chainID;
131  int resSeq;
132  char iCode;
133  int terCount; //< number of TER or END cards encountered prior to this
135  std::map< std::string, Vector > xyz; //< map of names to coords; redundant but used a lot in reader
136  std::map< std::string, double > temps; //< map of names to B-factors; redundant but used a lot in reader
137 }; // class ResidueInformation
138 
139 
140 /// @brief A structure for storing information from PDB LINK records.
144  std::string resID1_; // a 6-character resID, as defined elsewhere in FileData
149 }; // struct LinkInformation
150 
151 
152 /// @brief FileData class. Hold data created from PDB file.
153 class FileData
154 {
155 public:
157  remarks(new pose::Remarks),
158  header(0)
159  {}
160 
161  /// @brief empty destructor in C++ file to reduce number of necessary includes.
162  ~FileData();
163 
164  // only one data member, that should not preserve any 'state' - so it is public.
165  std::vector< AtomChain > chains;
166  //std::vector< RemarkInfo > remarks;
171 
172  // map for storing LINK records:
173  // key is 6-character resID of 1st residue in link
174  // TODO: Redesign to allow for multiple branches from the same residue; as keys must be unique, this current method
175  // limits us to a single branch. ~ Labonte
176  std::map<std::string, LinkInformation> links;
177 
178  // map for storing (non-sugar) HETNAM records:
179  // key is hetID
180  std::map<std::string, std::string> heterogen_names;
181 
182  // map for storing carbohydrate ResidueType base (non-variant) names; parsed from HETNAM records:
183  // key is 6-character resID
184  std::map<std::string, std::string> carbohydrate_residue_type_base_names;
185 
186  void
188 
190  header_information() const;
191 
192  void
194 
195  /// @brief The header records can span multiple lines while the
196  /// pdb_dynamic_parser is done line-wise. Finalizing the header
197  /// information ensures that all the information is fully processed.
198  void
200 
201  /// @brief Make sure to call finalize_header_information before
202  /// calling this.
203  void
204  fill_header_records(std::vector< Record > & VR) const;
205 
206 
207  /// @brief Store (non-standard) polymer linkages in a map.
208  void store_link_record(Record & record);
209 
210 
211  /// @brief Store heterogen name information in a map.
212  void store_heterogen_names(std::string const & hetID, std::string const & text);
213 
214  /// @brief Parse heterogen name data for a given carbohydrate and save the particular base (non-variant)
215  /// ResidueType needed in a map.
217 
218 
219  /// @brief Fill FileData structure using information from given pose object.
220  void init_from_pose(core::pose::Pose const & pose);
221 
222  /// @brief Fill FileData structure using information from given pose object and a set of options.
223  void init_from_pose(core::pose::Pose const & pose, FileDataOptions const & options);
224 
225  /// @brief Fill FileData structure using information from given pose object,
226  /// for a specified subset of residues
227  void
228  init_from_pose( core::pose::Pose const & pose, utility::vector1< core::Size > const & residue_indices );
229 
230  ///@brief randomize missing density
232 
233 
234  /// @brief Debug printing
235  friend std::ostream& operator <<(std::ostream &os, FileData const &);
236 
237  /// @brief Writes <pose> to a given stream in PDB file format
238  static
239  void dump_pdb(
240  core::pose::Pose const & pose,
241  std::ostream & out,
242  std::string const & tag="",
243  bool write_fold_tree = false
244  );
245 
246  /// @brief Writes <pose> to a PDB file, returns false if an error occurs
247  static
248  bool dump_pdb(
249  core::pose::Pose const & pose,
250  std::string const & file_name,
251  std::string const & tag="",
252  bool write_fold_tree = false
253  );
254 
255  static
256  void
257  dump_pdb(
258  core::pose::Pose const & pose,
259  std::ostream & out,
260  utility::vector1< core::Size > const & residue_indices,
261  std::string const & tag=""
262  );
263 
264  // Intermediate representation of date for easy of creating Pose object.
265  typedef std::map< std::string, double > ResidueTemps;
266  typedef std::map< std::string, ResidueTemps > Temps;
267  typedef std::map< std::string, Vector > ResidueCoords;
268  typedef std::map< std::string, ResidueCoords > Coords;
270 
271  /// @brief Convert FileData into set of residues, sequences, coordinates etc.
272  void create_working_data(
274  );
275 
276  /// @brief Convert FileData into set of residues, sequences, coordinates etc. using a set of options
277  void create_working_data(
279  FileDataOptions const & options
280  );
281 
282  ///@brief appends pdb information for a single residue
283  void append_residue(
284  core::conformation::Residue const & rsd,
285  core::Size & atom_index,
286  core::pose::Pose const & pose
287  );
288 }; // class FileData
289 
290 void
292  std::ostream & out,
293  pose::Pose const & pose,
294  io::pdb::FileData const & fd,
295  bool write_fold_tree = false
296 );
297 
298 /// @brief Builds a pose into <pose>, without repacking or optimizing
299 /// hydrogens; using the fullatom ResidueTypeSet
300 void
302  pose::Pose & pose,
303  std::string const & filename
304 );
305 
306 /// @brief Builds a pose into <pose>, without repacking or optimizing
307 /// hydrogens; using the fullatom ResidueTypeSet and a set of options.
308 void
310  pose::Pose & pose,
311  std::string const & filename,
312  PDB_DReaderOptions const & pdr_options
313 );
314 
315 void
317  pose::Pose & pose,
318  chemical::ResidueTypeSet const & residue_set,
319  std::string const & filename
320 );
321 
322 void
324  pose::Pose & pose,
325  chemical::ResidueTypeSet const & residue_set,
326  std::string const & filename,
327  PDB_DReaderOptions const & pdr_options
328 );
329 
330 //void
331 //build_pose_as_is1(
332 // io::pdb::FileData & fd,
333 // pose::Pose & pose,
334 // chemical::ResidueTypeSet const & residue_set,
335 // id::AtomID_Mask & missing
336 //);
337 
338 void
340  io::pdb::FileData & fd,
341  pose::Pose & pose,
342  chemical::ResidueTypeSet const & residue_set,
343  id::AtomID_Mask & missing,
344  FileDataOptions const & options
345 );
346 
347 bool
349  Size const pdb_residue_index,
350  std::string const & pdb_name,
351  core::chemical::ResidueTypeCOPs const & rsd_type_list,
352  std::map< std::string, Vector > const & xyz,
353  std::map< std::string, double > const & rtemp,
354  utility::vector1<Size> & UA_res_nums,
355  utility::vector1<std::string> & UA_res_names,
356  utility::vector1<std::string> & UA_atom_names,
358  utility::vector1<core::Real> & UA_temps);
359 
360 bool
362  Size const pdb_residue_index,
363  std::string const & pdb_name,
364  core::chemical::ResidueTypeCOPs const & rsd_type_list,
365  std::map< std::string, Vector > const & xyz,
366  std::map< std::string, double > const & rtemp,
367  utility::vector1<Size> & UA_res_nums,
368  utility::vector1<std::string> & UA_res_names,
369  utility::vector1<std::string> & UA_atom_names,
371  utility::vector1<core::Real> & UA_temps,
372  FileDataOptions const & options);
373 
374 
375 void
377  pose::Pose & new_pose,
378  pose::Pose const & old_pose,
379  utility::vector1< core::Size > const & residue_indices
380 );
381 
382 void
384  pose::Pose & new_pose,
385  pose::Pose const & old_pose,
386  utility::vector1< core::Size > const & residue_indices,
387  FileDataOptions const & options
388 );
389 
390 void
392  pose::Pose & new_pose,
393  pose::Pose const & old_pose,
394  chemical::ResidueTypeSet const & residue_set,
395  utility::vector1< core::Size > const & residue_indices
396 );
397 
398 void
400  pose::Pose & new_pose,
401  pose::Pose const & old_pose,
402  chemical::ResidueTypeSet const & residue_set,
403  utility::vector1< core::Size > const & residue_indices,
404  FileDataOptions const & options
405 );
406 
407 
408 } // namespace pdb
409 } // namespace io
410 } // namespace core
411 
412 
413 #endif // INCLUDED_core_io_pdb_file_data_HH