Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PDBSilentStruct.cc
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/PDBSilentStruct.cc
12 ///
13 /// @brief Representation of PDB files in a silent-file format.
14 /// @author James Thompson
15 
16 // C++ Headers
17 #include <cmath>
18 #include <cstdlib>
19 #include <iostream>
20 #include <utility>
21 #include <vector>
22 #include <list>
23 #include <string>
24 #include <map>
25 #include <sstream>
26 
27 // mini headers
28 #include <ObjexxFCL/char.functions.hh>
29 #include <ObjexxFCL/string.functions.hh>
30 
31 #include <utility/exit.hh>
32 
33 #include <basic/Tracer.hh>
41 
43 
44 #include <core/pose/Pose.hh>
45 
46 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
47 
49 
50 // ObjexxFCL
51 #include <ObjexxFCL/FArray2D.hh>
52 
53 // option key includes
54 #include <basic/options/keys/out.OptionKeys.gen.hh>
55 
56 //Auto Headers
57 #include <platform/types.hh>
59 #include <utility/vector1.hh>
60 #include <utility/file/FileName.hh>
61 #include <utility/keys/SmallKeyVector.hh>
62 #include <basic/options/option.hh>
63 
64 namespace core {
65 namespace import_pose {
66 
67 using namespace ObjexxFCL;
68 
69 static basic::Tracer tr("core.io.silent.PDBSilentStruct");
70 
72  core::pose::Pose const & pose,
73  std::string tag
74 ) {
75  fill_struct( pose, tag );
76 } // PDBSilentStruct
77 
78 void PDBSilentStruct::print_header( std::ostream & out ) {
79  print_score_header( out );
80 }
81 
83  core::pose::Pose const & pose,
84  std::string tag
85 ) {
86  decoy_tag( tag );
87  if ( tag == "empty_tag" ) set_tag_from_pose( pose );
88 
89  energies_from_pose( pose );
90 
91  fd_.init_from_pose( pose );
92 
93  sequence( pose.sequence() );
94 }
95 
97  utility::vector1< std::string > const & lines,
99 ) {
100  bool success( false );
101  using std::string;
102  using utility::vector1;
103  using namespace core::io::silent;
104 
105  vector1< std::string > energy_names_;
106  vector1< std::string >::const_iterator iter = lines.begin();
107  if ( iter->substr(0,9) == "SEQUENCE:" ) iter++; // ignore sequence for now
108  if ( iter->substr(0,6) != "SCORE:" ) {
109  // get sequence and scorename data from the silent-file data object, because I don't have it!
110  EnergyNamesOP enames = EnergyNamesOP(
111  static_cast< EnergyNames * > ( container.get_shared_silent_data( energynames )() )
112  );
113 
114  energy_names_ = enames->energy_names();
115  } else {
116  // get scorename data from the first two lines provided, put into container
117  // for further use by other SilentStruct objects.
118 
119  EnergyNamesOP enames( new EnergyNames( *iter ) );
120  container.set_shared_silent_data( energynames, enames );
121  energy_names_ = enames->energy_names();
122  } // get header information
123 
124  std::string concatenated_pdb_info; // concatenated pdb information
125  for ( vector1< string >::const_iterator end = lines.end(); iter != end; ++iter ) {
126  string tag;
127  std::istringstream line_stream( *iter );
128 
129  if ( iter->substr(0,7) == "SCORE: " ) { // SCORE: line with values from this structure.
130  std::string tag;
131  line_stream >> tag;
132  if ( line_stream.fail() || tag != "SCORE:" ) {
133  tr.Error << "bad format in first score line of silent file" << std::endl;
134  tr.Error << "line = " << *iter << std::endl;
135  tr.Error << "tag = " << tag << std::endl;
136  }
137 
139  for ( energy_iter = energy_names_.begin();
140  energy_iter != energy_names_.end(); ++energy_iter
141  ) {
142  line_stream >> tag;
143  if ( *energy_iter != "description" ) { // currently the only text-based field, might change in future.
144  Real score_val = (Real) float_of( tag );
145  add_energy( *energy_iter, score_val );
146  } else {
147  line_stream >> tag;
148  }
149  } // for ( energy_iter ... )
150  decoy_tag( tag ); // decoy_tag should be last column of this line.
151  } else if ( iter->substr(0,6) == "REMARK" ) {
152  // do nothing!
153  } else {
154  using namespace basic::options;
155  using namespace basic::options::OptionKeys;
156  if ( option[ out::file::silent_preserve_H ]() || iter->substr(13,1) != "H" ) {
157  // FileData needs \n's
158  concatenated_pdb_info += iter->substr( 0, 79 ) + '\n';
159  string temp_decoy_tag = iter->substr( 80 );
160  }
161  } // else
162  } // for ( iter ... )
163 
164  pdb_lines_ = concatenated_pdb_info;
165  fd_ = core::io::pdb::PDB_DReader::createFileData( concatenated_pdb_info );
166 
167  success = true;
168  return success;
169 } // init_from_lines
170 
172  core::pose::Pose & pose,
173  core::chemical::ResidueTypeSet const & residue_set
174 ) const {
175  core::import_pose::build_pose( fd_, pose, residue_set );
176  core::import_pose::read_additional_pdb_data( pdb_lines_, pose, fd_ );
177 } // fill_pose
178 
180  core::pose::Pose & pose
181 ) const {
182 
183  using namespace core::chemical;
184  ResidueTypeSetCAP residue_set;
186  fill_pose( pose, *residue_set );
187  finish_pose( pose );
188 } // fill_pose
189 
190 
191 void PDBSilentStruct::print_conformation( std::ostream & output ) const {
192  using std::string;
193 
195  output.write( data.c_str(), data.size() );
196 } // print_conformation
197 
199  tr.Error << "get_debug_rmsd stubbed out!" << std::endl;
200  return 0.0;
201 }
202 
203 ObjexxFCL::FArray2D< Real >
205  tr.Error << "PDBSilentStruct::get_CA_xyz" << std::endl;
206  return FArray2D< Real > ( 3, 1 );
207 }
208 
210  PDBSilentStruct const &
211 )
212 {
213  utility_exit_with_message( "called ProteinSilentStruct::operator=)" );
214  exit(0); // just to keep the compiler happy
215 }
216 
217 } // namespace import_pose
218 } // namespace core