Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
rna_helix.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/scoring/rms_util.hh>
16 #include <core/sequence/Sequence.hh>
17 #include <core/sequence/util.hh>
18 #include <core/types.hh>
19 #include <core/chemical/AA.hh>
20 #include <core/conformation/Residue.hh>
21 #include <core/chemical/ResidueTypeSet.hh>
22 #include <core/chemical/ChemicalManager.hh>
23 
24 #include <core/scoring/ScoreFunction.hh>
25 #include <core/scoring/ScoreFunctionFactory.hh>
26 
27 #include <core/kinematics/FoldTree.hh>
28 #include <core/kinematics/Jump.hh>
29 
30 #include <core/io/silent/SilentFileData.hh>
31 #include <core/io/silent/BinarySilentStruct.hh>
32 #include <core/pose/annotated_sequence.hh>
33 #include <basic/options/option.hh>
35 #include <protocols/viewer/viewers.hh>
36 #include <protocols/stepwise/modeler/rna/helix/RNA_HelixAssembler.hh>
37 
38 #include <core/pose/Pose.hh>
39 #include <core/pose/PDBInfo.hh>
40 #include <core/init/init.hh>
41 #include <core/io/pdb/pose_io.hh>
42 
43 #include <utility/vector1.hh>
44 #include <utility/exit.hh>
45 
46 #include <numeric/xyzVector.hh>
48 
49 // C++ headers
50 #include <iostream>
51 #include <string>
52 
53 //silly using/typedef
54 
55 // option key includes
56 
57 #include <basic/options/keys/out.OptionKeys.gen.hh>
58 #include <basic/options/keys/in.OptionKeys.gen.hh>
59 #include <basic/options/keys/score.OptionKeys.gen.hh>
60 #include <basic/options/keys/rna.OptionKeys.gen.hh>
61 
63 
64 //Auto Headers
65 using namespace core;
66 using namespace protocols;
67 using namespace basic::options::OptionKeys;
68 
69 using utility::vector1;
70 
71 using io::pdb::dump_pdb;
72 
73 //Definition of new OptionKeys
74 // these will be available in the top-level OptionKey namespace:
75 // i.e., OPT_KEY( Type, key ) --> OptionKey::key
76 // to have them in a namespace use OPT_1GRP_KEY( Type, grp, key ) --> OptionKey::grp::key
77 OPT_KEY( StringVector, seq )
78 OPT_KEY( Boolean, minimize_all )
79 OPT_KEY( Boolean, dump )
80 OPT_KEY( String, finish_weights )
81 
82 /////////////////////////////////////////////////
83 void
85 
86  using namespace core::scoring;
87  using namespace core::chemical;
88  using namespace core::sequence;
89  using namespace basic::options;
90  using namespace basic::options::OptionKeys;
91  using namespace core::pose;
92  using namespace core::kinematics;
93  using namespace core::io::silent;
94  using namespace protocols::stepwise::modeler::rna::helix;
95 
96  std::string full_sequence;
97  if ( option[ in::file::fasta ].user() ) {
98  std::string const fasta_file = option[ in::file::fasta ]()[1];
99  SequenceOP fasta_sequence = read_fasta_file( fasta_file )[1];
100  full_sequence = fasta_sequence->sequence();
101  } else if ( option[ seq ].user() ) {
102  utility::vector1< std::string > full_sequence_segments = option[ seq ]();
103  full_sequence = "";
104  for ( Size n = 1; n <= full_sequence_segments.size(); n++ ) full_sequence += full_sequence_segments[ n ];
105  } else {
106  utility_exit_with_message( "Need to specify -fasta <fasta file> or -seq <sequence>." );
107  }
108 
109  std::string silent_file = "";
110  bool output_silent( false );
111  if ( option[ out::file::silent ].user() ) {
112  silent_file = option[ out::file::silent ]();
113  output_silent = true;
114  }
115  SilentFileData silent_file_data;
116 
117  bool const is_use_phenix_geo = option[ basic::options::OptionKeys::rna::corrected_geo] ();
118  ResidueTypeSetCOP rsd_set;
119  rsd_set = ChemicalManager::get_instance()->residue_type_set( FA_STANDARD );
120 
122  std::string sequence_to_build;
123  for ( Size n = 1; n <= full_sequence.size(); n++ ) if ( !is_blank_seq( full_sequence[n-1]) ) sequence_to_build.push_back( full_sequence[ n-1 ] );
124  pose::make_pose_from_sequence( pose, sequence_to_build, *rsd_set );
125 
126  RNA_HelixAssembler rna_helix_assembler;
127  //rna_helix_assembler.random_perturbation( true );
128  rna_helix_assembler.set_minimize_all( option[ minimize_all ]() );
129  rna_helix_assembler.set_dump( option[ dump ]() );
130  rna_helix_assembler.use_phenix_geo( is_use_phenix_geo );
132  ScoreFunctionOP scorefxn = get_score_function();
133  rna_helix_assembler.set_scorefxn ( scorefxn );
134  }
135  // if following is blank, there won't be a 'final' minimize.
136  if ( option[ finish_weights ].user() ) {
137  ScoreFunctionOP finish_scorefxn = ScoreFunctionFactory::create_score_function( option[ finish_weights ]() );
138  rna_helix_assembler.set_finish_scorefxn( finish_scorefxn );
139  }
140  rna_helix_assembler.set_model_and_remove_capping_residues( true );
141 
142  protocols::viewer::add_conformation_viewer( pose.conformation(), "current", 400, 400 );
143 
144  Size const nstruct = option[ out::nstruct ];
145 
146  std::string outfile = full_sequence+".pdb";
147  if ( option[ out::file::o ].user() ) outfile = option[ out::file::o ]();
148 
149  for ( Size n = 1; n <= nstruct; n++ ) {
150  rna_helix_assembler.apply( pose, full_sequence );
151 
152  if ( output_silent ) {
153  std::string const tag( "S_"+ObjexxFCL::lead_zero_string_of(n, 3) );
154  BinarySilentStruct s( pose, tag );
155  silent_file_data.write_silent_struct( s, silent_file, false /*write score only*/ );
156  }
157 
158  pose.dump_pdb( outfile );
159  }
160 
161 }
162 
163 
164 ///////////////////////////////////////////////////////////////
165 void*
166 my_main( void* )
167 {
168 
169  using namespace basic::options;
170 
172  protocols::viewer::clear_conformation_viewers();
173  exit( 0 );
174 
175 }
176 
177 
178 ///////////////////////////////////////////////////////////////////////////////
179 int
180 main( int argc, char * argv [] )
181 {
182  try {
183  using namespace basic::options;
184 
185  std::cout << std::endl << "Basic usage: " << argv[0] << " -seq <sequence of first strand> <sequence of second strand> -o <name of output pdb file> " << std::endl;
186  std::cout << std::endl << " Type -help for full slate of options." << std::endl << std::endl;
187 
188  utility::vector1< std::string > blank_string_vector;
189  NEW_OPT( seq, "Input sequence", blank_string_vector );
190  NEW_OPT( minimize_all, "minimize all torsions in response to each base pair addition", false );
191  NEW_OPT( dump, "dump intermediate pdbs", false );
192  NEW_OPT( finish_weights, "[ optional ] score function to do a second minimize with after each base pair addition", "" );
193 
194  ////////////////////////////////////////////////////////////////////////////
195  // setup
196  ////////////////////////////////////////////////////////////////////////////
197  core::init::init(argc, argv);
198 
199  ////////////////////////////////////////////////////////////////////////////
200  // end of setup
201  ////////////////////////////////////////////////////////////////////////////
202 
203  protocols::viewer::viewer_main( my_main );
204  } catch ( utility::excn::EXCN_Base const & e ) {
205  std::cout << "caught exception " << e.msg() << std::endl;
206  return -1;
207  }
208 
209 }
#define utility_exit_with_message(m)
Exit with file + line + message.
Definition: exit.hh:47
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
std::string lead_zero_string_of(T const &t, int const w)
Leading-Zero Right-Justified string of a Template Argument Type Supporting Stream Output...
def dump
Definition: __init__.py:177
std::string String
Definition: remodel.cc:69
BooleanOptionKey const user("options:user")
Definition: OptionKeys.hh:40
int main(int argc, char *argv[])
Definition: rna_helix.cc:180
core::pose::Pose Pose
Definition: supercharge.cc:101
common derived classes for thrown exceptions
void * my_main(void *)
Definition: rna_helix.cc:166
tuple scorefxn
Definition: PyMOL_demo.py:63
Program exit functions and macros.
void rna_build_helix_test()
Definition: rna_helix.cc:84
std::vector with 1-based indexing
Definition: vector1.fwd.hh:44
basic::options::IntegerOptionKey const nstruct("nstruct")
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
#define OPT_KEY(type, key)
#define NEW_OPT(akey, help, adef)
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
tuple seq
Definition: PyMOL_demo.py:72
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
Fast (x,y,z)-coordinate numeric vector.
platform::Size Size
Definition: random.fwd.hh:30
int const silent
Named verbosity levels.
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378