Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SilentStruct.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/silent/SilentStruct.hh
12 ///
13 /// @brief silent input file reader for mini
14 /// @author James Thompson
15 
16 #ifndef INCLUDED_core_io_silent_SilentStruct_hh
17 #define INCLUDED_core_io_silent_SilentStruct_hh
18 
20 
21 // unit headers
24 // AUTO-REMOVED #include <core/io/silent/SilentFileData.fwd.hh>
25 
27 
28 // mini headers
29 #include <core/types.hh>
30 #include <core/pose/Pose.fwd.hh>
33 
34 // Utility headers
35 #include <utility/pointer/ReferenceCount.hh>
36 
37 // ObjexxFCL headers
38 
39 // C++ Headers
40 #include <string>
41 #include <map>
42 
43 #include <utility/vector1.hh>
44 #include <ObjexxFCL/FArray2D.fwd.hh>
45 
46 
47 namespace core {
48 namespace io {
49 namespace silent {
50 
51 
52  //////////////////////////////////////////////////////////////////////
53  // holds all the data for a silent-structure
55 
57 
58  public:
59  //constructor
60  SilentStruct();
61 
62  // destructor
63  virtual ~SilentStruct();
64 
65  SilentStruct( SilentStruct const & );
67 
68  virtual SilentStructOP clone() const = 0;
69 
70  // @brief Fill a Pose with the conformation information in this
71  // SilentStruct and the FA_STANDARD ResidueTypeSet.
72  virtual void fill_pose(
73  core::pose::Pose & pose
74  ) const;
75 
76  /// @brief Fill a Pose with the conformation information in this
77  /// SilentStruct and the ResidueTypeSet provided by the caller. This is
78  /// a virtual method which should be implemented by classes derived from
79  /// SilentStruct.
80  virtual void fill_pose(
81  core::pose::Pose & pose,
82  core::chemical::ResidueTypeSet const & residue_set
83  ) const;
84 
85  /// @brief Sets the tag from the Pose DataCache.
86  void set_tag_from_pose(
87  const core::pose::Pose & pose
88  );
89 
90  void
92  core::Size precision() const;
93 
94  void
95  scoreline_prefix( std::string const & prefix );
97 
98  /// @brief opposite of fill_pose
99  virtual void fill_struct(
100  core::pose::Pose const & pose,
101  std::string tag = "empty_tag"
102  ) = 0;
103 
104  /// @brief calls optH if command line requests optH.
105  /// must be called by derived classes.
106  void finish_pose(
107  core::pose::Pose & pose
108  ) const;
109 
110  /// @brief Do some sort of comparison between the actual RMSD of this
111  /// silent-struct and the cached coordinates. Used for SilentStruct
112  /// objects that are rebuild from torsions or other reduced
113  /// representations of data.
114  virtual Real get_debug_rmsd() = 0;
115 
116  /// @brief print out a header line to the given ozstream. In a rosetta++
117  /// silent-file, this contained the lines:
118  /// SEQUENCE: <protein sequence>\nSCORE: <list of score-types>.
119  virtual void print_header ( std::ostream & out ) const;
120  /// @brief only print SCORE: header line
121  virtual void print_score_header( std::ostream & out ) const;
122  /// @brief print out a SCORE line to the given ozstream.
123  virtual void print_scores ( std::ostream & out ) const;
124  /// @brief print the conformation information in SilentStruct to out.
125  virtual void print_conformation( std::ostream & out ) const = 0;
126  /// @brief print the comments in this SilentStruct.
127  virtual void print_comments ( std::ostream & out ) const;
128 
129  /// @brief returns the number of residues contained by this
130  /// SilentStruct.
131  virtual Size nres() const {
132  return nres_;
133  }
134 
135  /// @brief set the tag associate with this SilentStruct
136  void set_decoy_tag( std::string const & tag ) {
137  decoy_tag_ = tag;
138  }
139 
140  /// @brief returns the tag associated with this SilentStruct.
142  return decoy_tag_;
143  }
144 
145  /// @brief returns the sequence associated with this SilentStruct.
147  return sequence_;
148  }
149 
150  /// @brief returns the number of residues in this SilentStruct.
151  void nres( Size nres ) {
152  nres_ = nres;
153  }
154 
155  /// @brief sets the tag associated with this SilentStruct.
156  void decoy_tag( std::string const & tag ) {
157  decoy_tag_ = tag;
158  }
159 
160  /// @brief sets the sequence for this SilentStruct.
163  }
164 
165  /// @brief sets the silent_energies for this SilentStruct.
167  silent_energies_ = new_se;
168  }
169 
170  /// @brief sort all the silent energies by their name.
171  void sort_silent_scores();
172 
173  /// @brief returns true if this SilentStruct has an energy for the given
174  /// scorename, returns false otherwise.
175  bool has_energy( std::string const scorename ) const;
176 
177  /// @brief Returns the energy associated with the given scorename if this
178  /// SilentStruct has an energy for that scorename. Otherwise returns 0.
179  core::Real get_energy( std::string const & scorename ) const;
180 
181  /// @brief Returns the energy associated with the given scorename if this
182  /// SilentStruct has an energy for that scorename. Otherwise returns 0.
183  std::string const & get_string_value( std::string const & scorename ) const;
184 
185  /// @brief Returns the SilentEnergy associated with this scorename.
186  SilentEnergy const & get_silent_energy( std::string const & scorename ) const;
187 
189 
191 
192  /// @brief Clear all of the energies in the SilentStruct. Doesn't just
193  /// zero the energies, it entirely removes all knowledge of all energies
194  /// from this SilentStruct.
195  virtual void clear_energies() {
196  silent_energies_.clear();
197  }
198 
199  /// @brief Create a new SilentStruct object from the provided set of
200  /// lines. This abstract method should be overwritten by derived
201  /// classes. Returns false if the init_from_lines routine encounters a
202  /// problem with the lines provided.
203  virtual bool init_from_lines(
204  utility::vector1< std::string > const & lines,
205  SilentFileData & container
206  ) = 0;
207 
208  /// @brief add a score of a given name and value to this SilentStruct.
209  /// Takes an optional weight that defaults to 1.0.
210  void add_energy( std::string scorename, Real value, Real weight = 1.0 );
211 
212  /// @brief add a non-floating point score of a given name and value to this
213  /// SilentStruct.
214  void add_string_value( std::string scorename, std::string const & value );
215 
216  /// @brief Copy the score information in the given SilentStruct into
217  /// this SilentStruct.
218  void copy_scores( const SilentStruct & src_ss );
219 
220  /// @brief add a named comment to this SilentStruct object.
221  /// Similar to methods for playing with energies, but
222  /// mapping is string => string rather than string => Real.
223  void add_comment( std::string name, std::string value );
224  bool has_comment( std::string const & name ) const;
225  std::string get_comment( std::string const & name ) const;
226  void comment_from_line( std::string const & line );
227  void erase_comment( std::string const & name );
228  void clear_comments();
229 
230  std::map< std::string, std::string > get_all_comments() const;
231  //void set_all_comments( std::map< std::string, std::string > );
232 
233  void parse_energies(
234  std::istream & input,
236  );
237 
238  /// @brief Initialize this SilentStruct's energies from the given Pose.
239  /// This sets energies, energy weights, and the output widths for the
240  /// energies.
241  void energies_from_pose( core::pose::Pose const & pose );
242  /// @brief Put the energy information from this SilentStruct into the
243  /// pose. Energies that correspond to a ScoreType are put into the
244  /// pose.energies().total_energies() EnergyMap, all other energies are
245  /// put into the ARBITRARY_FLOAT_DATA map in the pose DataCache. Also
246  /// sets the scorefxn_weights in the Energies object using the
247  /// information from this SilentStruct.
248  void energies_into_pose( core::pose::Pose & pose ) const;
249 
250  /// @brief returns the positions of the CA atoms in this
251  /// ProteinSilentStruct. Useful for RMS calculations.
252  virtual ObjexxFCL::FArray2D< Real > get_CA_xyz() const = 0;
253 
254  /// @brief Returns the vector of SilentEnergy objects associated with
255  /// this SilentStruct object.
257  return silent_energies_;
258  }
259 
260  /// @brief Returns the EnergyNames that this SilentStruct contains.
261  EnergyNames energy_names() const;
262 
263  // @brief Renames energies from Rosetta++ to their appropriate mini
264  // names. Useful for reading older silent-files.
265  void rename_energies();
266 
267  bool read_sequence( std::string const& line );
268  void read_score_headers( std::string const& line, utility::vector1< std::string > & enames, SilentFileData& container );
269 
270  /// @brief strip [...] comment from seqeunce_ and return pure
271  /// one-letter sequence
273 
274  virtual core::Size mem_footprint() const { return 0; }
275 
276  //By Parin Sripakdeevong (sripakpa@stanford.edu).
277  void print_parent_remarks( std::ostream & out ) const;
278 
279  //By Parin Sripakdeevong (sripakpa@stanford.edu).
280  std::string get_parent_remark( std::string const & name ) const;
281 
282  //By Parin Sripakdeevong (sripakpa@stanford.edu).
283  bool has_parent_remark( std::string const & name ) const;
284 
285  //By Parin Sripakdeevong (sripakpa@stanford.edu).
286  void add_parent_remark( std::string const name, std::string const value );
287 
288  //By Parin Sripakdeevong (sripakpa@stanford.edu).
289  void get_parent_remark_from_line( std::string const line );
290 
291  protected:
292 
293  ///@ brief helper to detect fullatom input
294  // performs logical operation on fullatom and not_defined:
295  // if residue is patched we cannot tell -- no change to fullatom and not_defined
296  // if residue is not patched and is protein we do the following:
297  // if it has 7 or 8 atoms -- no change to fullatom and not_defined
298  // otherwise: well_defined = true;
299  // if this residue has > 8 atoms: fullatom = true
300  // if this residue has <= 6 atoms: fullatom = false
301  void detect_fullatom( core::Size pos, core::Size natoms, bool &fullatom, bool& well_defined );
302 
303  private:
308 
309  std::map< std::string, std::string > parent_remarks_map_; //Similar to silent_comments_ but this doesn't get outputted back to the silent_file.
310 
311 
312  // output-related data
313  std::map< std::string, std::string > silent_comments_;
315 
316 
317  private:
318  /// @brief Updates the "score" entry in the silent_energies.
319  void update_score();
320 
321  // number of digits after decimal place in scorefile
323  // prefix for the SCORE: lines. Usually "SCORE:"
325 }; // class SilentStruct
326 
327 } // namespace silent
328 } // namespace io
329 } // namespace core
330 
331 #endif