Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
rna_extract.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
11 /// @brief
12 
13 
14 // libRosetta headers
15 #include <core/types.hh>
16 #include <core/chemical/AA.hh>
17 #include <core/chemical/ChemicalManager.hh>
18 #include <core/pose/util.hh>
19 
20 #include <core/io/silent/SilentStruct.hh>
21 #include <core/io/silent/SilentFileData.hh>
22 #include <core/io/pdb/pdb_writer.hh>
23 
24 #include <core/pose/Pose.hh>
25 
26 
27 #include <basic/options/option.hh>
28 #include <protocols/viewer/viewers.hh>
29 
30 #include <core/init/init.hh>
31 
32 #include <utility/vector1.hh>
33 
35 
36 
37 // C++ headers
38 #include <iostream>
39 #include <string>
40 
41 
42 // option key includes
46 #include <basic/options/option.hh>
48 
50 
51 using namespace core;
52 using namespace protocols;
53 using utility::vector1;
54 
55 
56 OPT_KEY( Boolean, remove_variant_cutpoint_atoms )
57 
58 ///////////////////////////////////////////////////////////////////////////////////////////
59 // Basically stolen from James' protein silent file extractor.
60 void
62 {
63  using namespace core::scoring;
64  using namespace basic::options;
65  using namespace basic::options::OptionKeys;
66  using namespace core::io::silent;
67 
68  // setup residue types
69  core::chemical::ResidueTypeSetCOP rsd_set;
70  rsd_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( core::chemical::FA_STANDARD );
71 
72  // configure silent-file data object
73  core::io::silent::SilentFileData silent_file_data;
74  std::string infile = option[ in::file::silent ][1];
75 
76  if ( option[ in::file::silent ].user() ) {
77  silent_file_data.read_file( infile );
78  } else {
79  utility_exit_with_message( "Error: can't get any structures! Use -in::file::silent <silentfile>" );
80  }
81 
83 
84 
85  bool use_tags = false;
86  std::set< std::string > desired_tags;
87  if ( option[ in::file::tags ].active() ) {
88  use_tags = true;
89  desired_tags.insert( option[ in::file::tags ]().begin(), option[ in::file::tags ]().end() );
90  }
91 
92  for ( core::io::silent::SilentFileData::iterator iter = silent_file_data.begin(), end = silent_file_data.end(); iter != end; ++iter ) {
93 
94  std::string const tag = iter->decoy_tag();
95 
96  if ( use_tags && ( !desired_tags.count( tag ) ) ) continue;
97 
98  std::cout << "Extracting: " << tag << std::endl;
99 
100  iter->fill_pose( pose, *rsd_set );
101 
102  //Fang: This outputing will fail if the pose contains virtual residue.
103  //std::cout << "debug_rmsd(" << tag << ") = " << iter->get_debug_rmsd() << " over " << pose.total_residue() << " residues... \n";
104 
105 
106  if ( option[ remove_variant_cutpoint_atoms ]()==true ) {
107  for ( Size n = 1; n <= pose.total_residue(); n++ ) {
108  pose::remove_variant_type_from_pose_residue( pose, core::chemical::CUTPOINT_LOWER, n );
109  pose::remove_variant_type_from_pose_residue( pose, core::chemical::CUTPOINT_UPPER, n );
110  }
111  }
112 
113  std::string out_prefix = "";
114 
115  if ( option[out::prefix].user() ) out_prefix = option[out::prefix]();
116 
117  pose.dump_pdb( out_prefix + tag + ".pdb" );
118 
119  }
120 
121 }
122 ///////////////////////////////////////////////////////////////
123 void*
124 my_main( void* )
125 {
127  exit( 0 );
128 }
129 
130 
131 ///////////////////////////////////////////////////////////////////////////////
132 int
133 main( int argc, char * argv [] )
134 {
135  try {
136  using namespace basic::options;
137 
138  std::cout << std::endl << "Basic usage: " << argv[0] << " -in::file::silent <silent file> -tags <model tag like S_00001> " << std::endl;
139  std::cout << std::endl << " Type -help for full slate of options." << std::endl << std::endl;
140 
141  NEW_OPT( remove_variant_cutpoint_atoms , "remove_variant_cutpoint_atoms", false );
142  ////////////////////////////////////////////////////////////////////////////
143  // setup
144  ////////////////////////////////////////////////////////////////////////////
145  core::init::init(argc, argv);
146 
147  ////////////////////////////////////////////////////////////////////////////
148  // end of setup
149  ////////////////////////////////////////////////////////////////////////////
150 
151  protocols::viewer::viewer_main( my_main );
152  } catch ( utility::excn::EXCN_Base const & e ) {
153  std::cout << "caught exception " << e.msg() << std::endl;
154  return -1;
155  }
156 }
157 
StringVectorOptionKey const tags("in:file:tags")
#define utility_exit_with_message(m)
Exit with file + line + message.
Definition: exit.hh:47
void * my_main(void *)
Definition: rna_extract.cc:124
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
core::pose::Pose Pose
Definition: supercharge.cc:101
common derived classes for thrown exceptions
macros to define options on a per-application basis at the top of app files (those with main) ...
basic::options::OptionKeys collection
std::vector with 1-based indexing
Definition: vector1.fwd.hh:44
void extract_pdbs_test()
Definition: rna_extract.cc:61
basic::options::OptionKeys collection
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
#define OPT_KEY(type, key)
int main(int argc, char *argv[])
Definition: rna_extract.cc:133
#define NEW_OPT(akey, help, adef)
FileVectorOptionKey const silent
ocstream cout(std::cout)
Wrapper around std::cout.
Definition: ocstream.hh:287
BooleanOptionKey const exit("options:exit")
Definition: OptionKeys.hh:51
vector1: std::vector with 1-based indexing
utility::keys::lookup::begin< KeyType > const begin
basic::options::OptionKeys collection
FileVectorOptionKey const silent("in:file:silent")
void init()
set global 'init_was_called' to true
Definition: init.cc:26
Program options global and initialization function.
rule< Scanner, tag_closure::context_t > tag
Definition: Tag.cc:373
platform::Size Size
Definition: random.fwd.hh:30
StringOptionKey const prefix("out:prefix")
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378