Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
rna_denovo.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 /// @author Rhiju Das
13 
14 // libRosetta headers
15 #include <core/types.hh>
16 #include <core/chemical/AA.hh>
17 #include <core/chemical/ChemicalManager.hh>
18 #include <core/scoring/ScoreFunction.hh>
19 #include <core/scoring/ScoreFunctionFactory.hh>
20 #include <core/scoring/constraints/ConstraintSet.hh>
21 #include <core/scoring/constraints/ConstraintSet.fwd.hh>
22 #include <core/scoring/constraints/ConstraintIO.hh>
23 #include <core/sequence/util.hh>
24 #include <core/import_pose/pose_stream/SilentFilePoseInputStream.hh>
25 #include <basic/options/option.hh>
26 #include <basic/database/open.hh>
28 #include <protocols/viewer/viewers.hh>
29 #include <core/pose/Pose.hh>
30 #include <core/init/init.hh>
31 #include <core/io/pdb/pdb_writer.hh>
32 #include <core/io/rna/RNA_DataReader.hh>
33 #include <utility/vector1.hh>
35 
36 //RNA stuff.
37 #include <protocols/farna/RNA_DeNovoProtocol.hh>
38 #include <protocols/farna/options/RNA_DeNovoProtocolOptions.hh>
39 #include <protocols/farna/util.hh>
40 //#include <protocols/moves/PyMolMover.hh>
41 
42 // C++ headers
43 #include <iostream>
44 #include <string>
45 
46 // option key includes
53 
54 #include <core/import_pose/import_pose.hh>
55 #include <core/pose/annotated_sequence.hh>
56 #include <core/sequence/Sequence.hh>
59 
60 
61 using namespace core;
62 using namespace protocols;
63 using namespace basic::options::OptionKeys;
64 using utility::vector1;
65 
66 vector1<pose::PoseOP> get_refine_pose_list( std::string const & input_silent_file,
67  std::pair< utility::vector1< int >, utility::vector1< char > > const & output_res_and_chain,
68  core::chemical::ResidueTypeSetCOP rsd_set );
69 
70 ///////////////////////////////////////////////////////////////////////////////
71 void
73 {
74 
75  using namespace basic::options;
76  using namespace basic::options::OptionKeys;
77  using namespace core::chemical;
78  using namespace core::scoring;
79  using namespace core::scoring::constraints;
80  using namespace protocols::farna;
81 
82  /////////////////////////////////////////////////////////////////////////////////////////////
83  /////////////////////////////////////////////////////////////////////////////////////////////
84  // Some initialization
85  /////////////////////////////////////////////////////////////////////////////////////////////
86  /////////////////////////////////////////////////////////////////////////////////////////////
87  ResidueTypeSetCOP rsd_set;
88  rsd_set = core::chemical::ChemicalManager::get_instance()->residue_type_set( FA_STANDARD );
89 
90  pose::PoseOP native_pose_OP( new pose::Pose );
91  pose::Pose & native_pose = *native_pose_OP;
92 
94 
95  std::string const in_path = option[ in::path::path ]()[1];
96 
97  bool native_exists = false;
98  //Read in native if it exists.
99  if ( option[ in::file::native ].user() ) {
100  native_exists = true;
101  //Read in native if it exists.
102  std::string native_pdb_file = option[ in::file::native ];
103  core::import_pose::pose_from_file( native_pose, *rsd_set, in_path + native_pdb_file , core::import_pose::PDB_file);
104  } else {
106  }
107 
108  //Prepare starting structure from scratch --> read from fasta.
111  } else {
112  std::string const sequence = core::sequence::read_fasta_file_return_str( option[ in::file::fasta ]()[1] );
113  core::pose::make_pose_from_sequence( extended_pose, sequence, *rsd_set );
114  }
115  set_output_res_and_chain( extended_pose, option[ OptionKeys::rna::farna::output_res_num ].resnum_and_chain() );
116 
117  // Silent file input for fine refinement
119 
120  //Score these suckers.
122  ScoreFunctionOP scorefxn = ScoreFunctionFactory::create_score_function( RNA_LORES_WTS );
123 
124  RNA_DeNovoProtocolOptionsOP options( new RNA_DeNovoProtocolOptions);
125  options->initialize_from_command_line();
126  if ( option[ OptionKeys::rna::farna::refine_native ]() ) options->set_refine_pose( true );
127 
128  protocols::farna::RNA_DeNovoProtocol rna_de_novo_protocol( options );
129  if ( native_exists ) rna_de_novo_protocol.set_native_pose( native_pose_OP );
130  rna_de_novo_protocol.set_refine_pose_list( refine_pose_list );
131 
133  ConstraintSetOP cst_set = ConstraintIO::get_instance()->read_constraints( option[ OptionKeys::constraints::cst_file ](1), ConstraintSetOP( new ConstraintSet ), pose );
134  pose.constraint_set( cst_set );
135  for ( Size i = 1; i <= refine_pose_list.size(); ++i ) refine_pose_list[i]->constraint_set( cst_set );
136  }
137 
139  core::io::rna::RNA_DataReader rna_data_reader( in_path + option[ OptionKeys::rna::data_file ] );
140  rna_data_reader.fill_rna_data_info( pose );
141  }
142 
143  protocols::viewer::add_conformation_viewer( pose.conformation(), "current", 600, 600 );
144 
145  // protocols::moves::AddPyMolObserver( pose, false, 0.01);
146 
147  rna_de_novo_protocol.apply( pose );
148 
149 }
150 
151 ///////////////////////////////////////////////////////////////
153 get_refine_pose_list( std::string const & input_silent_file,
154  std::pair< utility::vector1< int >, utility::vector1< char > > const & output_res_and_chain,
155  core::chemical::ResidueTypeSetCOP rsd_set )
156 {
157 
158  vector1<pose::PoseOP> refine_pose_list;
159  if ( input_silent_file.size() > 0 ) {
160  core::import_pose::pose_stream::SilentFilePoseInputStream input( input_silent_file );
161  input.set_order_by_energy( true );
162  while ( input.has_another_pose() ) {
163  pose::PoseOP new_pose( new pose::Pose );
164  input.fill_pose( *new_pose, *rsd_set );
165  protocols::farna::set_output_res_and_chain( *new_pose, output_res_and_chain );
166  refine_pose_list.push_back( new_pose );
167  }
168  }
169  return refine_pose_list;
170 }
171 
172 ///////////////////////////////////////////////////////////////
173 void*
174 my_main( void* )
175 {
176  rna_denovo_test();
177  protocols::viewer::clear_conformation_viewers();
178  exit( 0 );
179 }
180 
181 
182 ///////////////////////////////////////////////////////////////////////////////
183 int
184 main( int argc, char * argv [] )
185 {
186  try {
187  using namespace basic::options;
188 
189  std::cout << std::endl << "Basic usage: " << argv[0] << " -fasta <fasta file with sequence> [ -native <native pdb file> ] " << std::endl;
190  std::cout << std::endl << " Type -help for full slate of options." << std::endl << std::endl;
191 
192  option.add_relevant( in::file::fasta );
193  option.add_relevant( in::file::input_res );
194  option.add_relevant( in::file::native );
195  option.add_relevant( out::file::silent );
196  option.add_relevant( out::nstruct );
197  option.add_relevant( score::weights );
198  option.add_relevant( constraints::cst_file );
199  option.add_relevant( rna::farna::minimize_rna );
200  option.add_relevant( rna::farna::relax_rna );
201  option.add_relevant( rna::farna::simple_relax );
202  option.add_relevant( rna::farna::ignore_secstruct );
203  option.add_relevant( rna::farna::lores_scorefxn );
209  option.add_relevant( rna::farna::cycles );
210  option.add_relevant( rna::farna::temperature );
212  option.add_relevant( rna::farna::close_loops );
215  option.add_relevant( rna::farna::heat );
216  option.add_relevant( rna::farna::dump );
217  option.add_relevant( rna::farna::staged_constraints );
218  option.add_relevant( rna::farna::jump_library_file );
219  option.add_relevant( rna::farna::params_file );
221  option.add_relevant( rna::farna::use_1jj2_torsions );
224  option.add_relevant( rna::farna::allow_bulge );
225  option.add_relevant( rna::farna::allowed_bulge_res );
227  option.add_relevant( rna::farna::binary_output );
231  option.add_relevant( rna::farna::output_filters );
232  option.add_relevant( rna::farna::autofilter );
233  option.add_relevant( rna::farna::output_res_num );
234  option.add_relevant( rna::farna::refine_silent_file );
235  option.add_relevant( rna::farna::refine_native );
236  option.add_relevant( rna::farna::bps_moves );
237  option.add_relevant( rna::vary_geometry );
243 
244  option.add_relevant( constraints::cst_file );
245 
246  ////////////////////////////////////////////////////////////////////////////
247  // setup
248  ////////////////////////////////////////////////////////////////////////////
249  core::init::init(argc, argv);
250 
251  ////////////////////////////////////////////////////////////////////////////
252  // end of setup
253  ////////////////////////////////////////////////////////////////////////////
254 
255  protocols::viewer::viewer_main( my_main );
256  } catch ( utility::excn::EXCN_Base const & e ) {
257  std::cout << "caught exception " << e.msg() << std::endl;
258  return -1;
259  }
260 }
261 
int main(int argc, char *argv[])
Definition: rna_denovo.cc:184
StringOptionKey const silent("out:file:silent")
void rna_denovo_test()
Definition: rna_denovo.cc:72
RealOptionKey const rna_lores_chainbreak_weight("rna:farna:rna_lores_chainbreak_weight")
RealOptionKey const suppress_bp_constraint("rna:farna:suppress_bp_constraint")
vector1< pose::PoseOP > get_refine_pose_list(std::string const &input_silent_file, std::pair< utility::vector1< int >, utility::vector1< char > > const &output_res_and_chain, core::chemical::ResidueTypeSetCOP rsd_set)
Definition: rna_denovo.cc:153
virtual std::string const msg() const
Definition: EXCN_Base.hh:70
BooleanOptionKey const relax_rna("rna:farna:relax_rna")
RealOptionKey const jump_change_frequency("rna:farna:jump_change_frequency")
BooleanOptionKey const minimize_bps("rna:farna:minimize:minimize_bps")
BooleanOptionKey const bps_moves("rna:farna:bps_moves")
BooleanOptionKey const dump("rna:farna:dump")
IntegerOptionKey const extended_pose
void * my_main(void *)
Definition: rna_denovo.cc:174
StringOptionKey const jump_library_file("rna:farna:jump_library_file")
BooleanOptionKey const allow_bulge("rna:farna:allow_bulge ")
BooleanOptionKey const filter_chain_closure_halfway("rna:farna:filter_chain_closure_halfway")
basic::options::OptionKeys collection
BooleanOptionKey const refine_native
BooleanOptionKey const simple_relax("rna:farna:simple_relax")
FileVectorOptionKey const fasta("in:file:fasta")
core::pose::Pose Pose
Definition: supercharge.cc:101
Platform independent operations on files (except I/O)
#define runtime_assert(_Expression)
Assert that the condition holds. Evaluated for both debug and release builds.
Definition: exit.hh:63
BooleanOptionKey const allow_consecutive_bulges("rna:farna:allow_consecutive_bulges")
BooleanOptionKey const output_lores_silent_file("rna:farna:output_lores_silent_file")
IntegerVectorOptionKey const extra_minimize_res("rna:farna:minimize:extra_minimize_res")
basic::options::OptionKeys collection
ResidueChainVectorOptionKey const input_res("in:file:input_res")
common derived classes for thrown exceptions
IntegerVectorOptionKey const extra_minimize_chi_res("rna:farna:minimize:extra_minimize_chi_res")
BooleanOptionKey const staged_constraints("rna:farna:staged_constraints")
BooleanOptionKey const heat("rna:farna:heat")
ResidueChainVectorOptionKey const output_res_num
BooleanOptionKey const output_filters("rna:farna:output_filters")
StringOptionKey const refine_silent_file("rna:farna:refine_silent_file")
tuple scorefxn
Definition: PyMOL_demo.py:63
StringOptionKey const lores_scorefxn("rna:farna:lores_scorefxn")
BooleanOptionKey const minimize_rna("rna:farna:minimize_rna")
basic::options::OptionKeys collection
BooleanOptionKey const filter_lores_base_pairs_early("rna:farna:filter_lores_base_pairs_early")
StringOptionKey const params_file("rna:farna:params_file")
BooleanOptionKey const ignore_secstruct("rna:farna:ignore_secstruct")
Functions for opening database files.
macros to define options on a per-application basis at the top of app files (those with main) ...
ResidueChainVectorOptionKey const output_res_num("rna:farna:output_res_num")
PathVectorOptionKey const path("in:path")
BooleanOptionKey const sequence
BooleanOptionKey const refine_native("rna:farna:refine_native")
BooleanOptionKey const use_1jj2_torsions("rna:farna:use_1jj2_torsions")
std::vector with 1-based indexing
Definition: vector1.fwd.hh:44
StringVectorOptionKey const cst_file("constraints:cst_file")
BooleanOptionKey const close_loops_after_each_move("rna:farna:close_loops_after_each_move")
basic::options::OptionKeys collection
rule< Scanner, options_closure::context_t > options
Definition: Tag.cc:377
BooleanOptionKey const autofilter("rna:farna:autofilter")
BooleanOptionKey const binary_output("rna:farna:binary_output")
BooleanOptionKey const vary_geometry("rna:vary_geometry")
BooleanOptionKey const move_first_rigid_body("rna:farna:move_first_rigid_body")
BooleanOptionKey const close_loops("rna:farna:close_loops")
BooleanOptionKey const filter_lores_base_pairs("rna:farna:filter_lores_base_pairs")
StringOptionKey const weights("score:weights")
FileOptionKey const native("in:file:native")
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
IntegerVectorOptionKey const allowed_bulge_res("rna:farna:allowed_bulge_res")
basic::options::OptionKeys collection
BooleanOptionKey const minimizer_use_coordinate_constraints("rna:farna:minimize:minimizer_use_coordinate_constraints")
RealOptionKey const filter_chain_closure_distance("rna:farna:filter_chain_closure_distance")
StringOptionKey const data_file
void init()
set global 'init_was_called' to true
Definition: init.cc:26
Program options global and initialization function.
BooleanOptionKey const chemical
basic::options::OptionKeys collection
IntegerOptionKey const cycles("rna:farna:cycles")
BooleanOptionKey const root_at_first_rigid_body("rna:farna:root_at_first_rigid_body")
BooleanOptionKey const filter_chain_closure("rna:farna:filter_chain_closure")
RealOptionKey const temperature("rna:farna:temperature")
platform::Size Size
Definition: random.fwd.hh:30
rule< Scanner, option_closure::context_t > option
Definition: Tag.cc:378
StringOptionKey const refine_silent_file
RealOptionKey const rna_lores_linear_chainbreak_weight("rna:farna:rna_lores_linear_chainbreak_weight")
IntegerOptionKey const nstruct("out:nstruct")
StringOptionKey const data_file