Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DesignContrast.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 // (C) 199x-2008 University of Washington
11 // (C) 199x-2008 University of California Santa Cruz
12 // (C) 199x-2008 University of California San Francisco
13 // (C) 199x-2008 Johns Hopkins University
14 // (C) 199x-2008 University of North Carolina, Chapel Hill
15 // (C) 199x-2008 Vanderbilt University
16 
17 /// @file core/io/sequence_comparation/DesignContrast.cc
18 ///
19 /// @brief
20 /// @author Yi Liu
21 
22 
23 // C++ headers
24 #include <fstream>
25 #include <iostream>
26 #include <cstdlib>
27 
28 // Unit Headers
29 // AUTO-REMOVED #include <utility/stream_util.hh>
30 #include <basic/Tracer.hh>
31 // AUTO-REMOVED #include <basic/basic.hh>
32 // AUTO-REMOVED #include <core/init.hh>
33 #include <core/types.hh>
34 
35 // Utility Headers
36 #include <utility/vector1.hh>
37 #include <utility/file/FileName.hh>
38 #include <utility/io/izstream.hh>
39 
40 
41 // Project Headers
43 // AUTO-REMOVED #include <core/io/pdb/pose_io.hh>
45 #include <core/pose/Pose.hh>
46 #include <core/pose/PDBInfo.hh>
47 #include <core/pose/util.hh>
48 #include <basic/options/option.hh>
49 
50 #include <core/scoring/Energies.hh>
51 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
53 
54 // ObjexxFCL headers
55 #include <ObjexxFCL/format.hh>
56 
57 
58 // option key includes
59 
60 #include <basic/options/keys/in.OptionKeys.gen.hh>
61 
62 
63 
64 
65 namespace core {
66 namespace io {
67 namespace sequence_comparation {
68 
69 using namespace core;
70 using namespace basic;
71 
72 using namespace core::pose;
73 
74 using namespace basic::options;
75 using namespace basic::options::OptionKeys;
76 
77 using namespace ObjexxFCL::fmt;
78 
79 using basic::T;
80 using basic::Error;
81 using basic::Warning;
82 
83 using core::Size;
84 
85 using utility::vector1;
86 
87 /// Tracer instance for this file
88 static basic::Tracer TR("core.io.sequence_comparation.DesignContrast");
89 
91  list_file_names_ = dc.getListNames();
92  pdb_file_names_ = dc.getPdbNames();
93  nneighbs_ = dc.getNeighbors();
94  secstructs_ = dc.getSecStruct();
95  pdb_codes_ = dc.getPdbCodes();
96  }
97 
98  /// @details go through residues in the pose, count the number of neighbors of each residue.
99  /// currently using tenA neighbor graph to # neighbors within 10 Angstroms
102  nneighbs_.clear();
103  int nneighb;
104  for ( Size i=1; i<= pose.total_residue(); ++i ) {
106  nneighbs_.push_back(nneighb);
107  }
108  }
109 
111  return nneighbs_;
112  }
113 
115  return nneighbs_;
116  }
117 
118 
119  /// @details Set secondary structure for residues in the pose. Have to call
120  /// set_ss_from_phipsi to set up the secondary structure infomation for pose.
122  secstructs_.clear();
123  set_ss_from_phipsi(pose); // This function is defined in pose/util.cc
124  std::string secstruct;
125  for ( Size i=1; i<= pose.total_residue(); ++i ) {
126  secstruct = pose.secstruct(i);
127  secstructs_.push_back(secstruct);
128  }
129  }
130 
132  return secstructs_;
133  }
135  return secstructs_;
136  }
137 
138  /// @details Copied the major parts of this function from Andrew. Read the lines
139  /// of the list files and store the pdb names in pdb_file_names.
141  list_file_names_.clear();
142  pdb_file_names_.clear();
143  if ( option[ in::file::s ].active() )
144  pdb_file_names_ = option[ in::file::s ]().vector();
145  if ( option[ in::file::l ].active() ) {
146  list_file_names_ = option[ in::file::l ]().vector(); // make the copy of list file
147  }
148  for(vector1< FileName >::iterator i = list_file_names_.begin(), i_end = list_file_names_.end(); i != i_end; ++i) {
149  std::string listname( i->name() );
150  utility::io::izstream data( listname.c_str() );
151  if ( !data.good() ) {
152  utility_exit_with_message( "Unable to open file: " + listname + '\n' );
153  }
154  std::string line;
155  while( getline(data, line) ) {
156  pdb_file_names_.push_back( line );
157  }
158  data.close();
159  }
160  }
161 
163  return pdb_file_names_;
164  }
165 
167  return pdb_file_names_;
168  }
169 
171  return list_file_names_;
172  }
173 
175  return list_file_names_;
176  }
177 
179  std::string code;
180  for (Size i=1; i<=pdb_file_names_.size(); ++i){
181  code = std::string(pdb_file_names_[i]).substr(std::string(pdb_file_names_[i]).size()-8,4);
182  TR << "in DesignContrast check the code: " << code <<std::endl;
183  pdb_codes_.push_back(code);
184  }
185  }
186 
188  return pdb_codes_;
189  }
190 
192  return pdb_codes_;
193  }
194 
196  pose::Pose & native_pose,
197  pose::Pose & decoy_pose,
198  std::string const & single_code,
199  std::ofstream & sqc
200  ){
201 
202  TR << "in the start of output_sqc_file"<< std::endl;
203  setNeighbors(native_pose);
204  TR << "after setNeighbors "<< std::endl;
205  setSecStruct(decoy_pose);
206  TR << "after setSecStruct "<< std::endl;
207 
208  vector1<std::string> native_res_name;
209  vector1<std::string> decoy_res_name;
210  vector1<char> chain_ids;
211  vector1<int> pdb_res_num;
212 
213  // this block is commented out due to deprecation of old PDBInfo interface
214  // chain ids
215 // chain_ids = decoy_pose.pdb_chains();
216 // TR << "after get chains"<< std::endl;
217  // sequence position for each residue.
218 // pdb_res_num = decoy_pose.pdb_numbering();
219 // TR << "after get pdb number "<< std::endl;
220 
221  for (Size i=1; i<=native_pose.total_residue(); ++i){
222  native_res_name.push_back(native_pose.residue(i).name3());
223  }
224  for (Size j=1 ; j<=decoy_pose.total_residue(); ++j) {
225  decoy_res_name.push_back(decoy_pose.residue(j).name3());
226  }
227  TR << "total residues: " << decoy_pose.total_residue() << std::endl;
228  for (Size n=1; n<=decoy_pose.total_residue(); ++n){
229  sqc
230  << single_code << " "
231  << decoy_pose.pdb_info()->chain(n) << " "
232  << I( 4, decoy_pose.pdb_info()->number(n) ) << ' '
233  << A( 3, native_res_name[n] ) << ' '
234  << A( 3, decoy_res_name[n] ) << ' '
235  << I( 5, nneighbs_[n]) << ' '
236  << A( 2, secstructs_[n] ) << ' '
237  << '\n';
238  }
239  TR << "end of sqc output" << std::endl;
240  }
241 
243  list_file_names_.clear();
244  pdb_file_names_.clear();
245  nneighbs_.clear();
246  secstructs_.clear();
247  pdb_codes_.clear();
248  }
249 
250 } // namespace sequence_comparation
251 } // namespace io
252 } // namespace core