Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResFileOutputter.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 //
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 protocols/outputter/ResFileOutputter.cc
11 /// @brief Saves a resfile that is generated by applying the input task operations to the pose
12 /// @author Ken Jung
13 
14 // Unit Headers
16 
21 #include <core/pose/PDBInfo.hh>
22 #include <iostream>
23 #include <fstream>
24 
25 // tracer
26 #include <basic/Tracer.hh>
27 
28 namespace protocols {
29 namespace outputter {
30 
31 static basic::Tracer TR("protocols.outputter.ResFileOutputter");
32 
33 #ifdef USELUA
34 void lregister_ResFileOutputter( lua_State * lstate ) {
35  lregister_FormatStringOutputter( lstate );
36 
37  luabind::module(lstate, "protocols")
38  [
39  luabind::namespace_( "outputter")
40  [
41  luabind::class_<ResFileOutputter, FormatStringOutputter>("ResFileOutputter")
42  ]
43  ];
44 }
45 #endif
46 
50  return OutputterSP( new ResFileOutputter () );
51 }
52 
54  utility::vector1< core::Size > selected_residues;
55  // Prepare the PackerTask
56  assert( task_factory_ );
57  core::pack::task::PackerTaskCOP task( task_factory_->create_task_and_apply_taskoperations( p ) );
58  // Find out which residues are packable or designable
59  for( core::Size resi = 1; resi <= p.total_residue(); ++resi ) {
60  if ( designable_only_ ) {
61  if( task->residue_task( resi ).being_designed() && p.residue(resi).is_protein() )
62  selected_residues.push_back( resi );
63  } else {
64  if( task->residue_task( resi ).being_packed() && p.residue(resi).is_protein() )
65  selected_residues.push_back( resi );
66  }
67  }
68  if( selected_residues.empty() )
69  TR.Warning << "WARNING: No residues were selected by your TaskOperations." << std::endl;
70 
71  // write to disk
72  std::string outfilename;
74  assert( outfilename != "" );
75  std::ofstream resfile;
76  resfile.open( outfilename.c_str(), std::ios::out );
77  resfile << resfile_general_property_ << "\nstart\n";
78  for ( core::Size i=1; i<=selected_residues.size(); i++ ) {
79  resfile << selected_residues[i] << '\t' << p.pdb_info()->chain(selected_residues[i]) << " PIKAA " << p.residue(selected_residues[i]).name1() << '\n';
80  }
81  resfile.close();
82 }
83 
84 #ifdef USELUA
85 void ResFileOutputter::parse_def( utility::lua::LuaObject const & def,
86  utility::lua::LuaObject const & tasks ) {
87  format_string_ = def["format_string"] ? def["format_string"].to<std::string>() : "%filebasename_%filemultiplier.resfile";
88  if( def["tasks"] ) {
89  task_factory_ = protocols::elscripts::parse_taskdef( def["tasks"], tasks );
90  }
91  designable_only_ = def["designable_only"] ? def["designable_only"].to<bool>() : false;
92  resfile_general_property_ = def["resfile_general_property"] ? def["resfile_general_property"].to<std::string>() : "NATAA";
93 }
94 
95 void ResFileOutputter::lregister( lua_State * lstate ) {
96  lregister_ResFileOutputter(lstate);
97 }
98 #endif
99 
100 } // outputter
101 } // protocols