16 #include <protocols/moves/Mover.hh>
17 #include <core/pose/Pose.hh>
19 #include <core/types.hh>
20 #include <core/chemical/ChemicalManager.hh>
22 #include <protocols/jd2/JobDistributor.hh>
23 #include <protocols/jd2/NoOutputJobOutputter.hh>
24 #include <protocols/jd2/SilentFileJobInputter.hh>
26 #include <protocols/toolbox/DecoySetEvaluation.hh>
28 #include <protocols/toolbox/superimpose.hh>
29 #include <protocols/loops/Loop.hh>
30 #include <protocols/loops/Loops.hh>
31 #include <protocols/loops/LoopsFileIO.hh>
41 #include <basic/options/keys/in.OptionKeys.gen.hh>
42 #include <basic/options/keys/out.OptionKeys.gen.hh>
50 #include <core/import_pose/import_pose.hh>
57 using namespace protocols;
58 using namespace protocols::jd2;
61 using namespace basic::options::OptionKeys;
62 using namespace toolbox;
63 using namespace ObjexxFCL;
77 using namespace basic::options::OptionKeys;
82 NEW_OPT( wRMSD,
"compute wRMSD with this sigma", 2 );
83 NEW_OPT( tolerance,
"stop wRMSD iteration if <tolearance change in wSum", 0.00001);
85 NEW_OPT( rigid::in,
"residues that are considered for wRMSD or clustering",
"rigid.loop");
86 NEW_OPT( rmsf::out,
"write rmsf into this file",
"rmsf.dat" );
87 NEW_OPT( rigid::out,
"write a RIGID definition",
"rigid.loops" );
88 NEW_OPT( rigid::cutoff,
"residues with less then loop_cutoff will go into RIGID definition", 2 );
89 NEW_OPT( rigid::min_gap,
"don't have less then min_gap residues between rigid regions", 1 );
90 NEW_OPT(
calc::rmsd,
"calculate RMSD from mean, and average pairwise RMSD",
false);
97 typedef utility::pointer::shared_ptr< RmsfMover >
RmsfMoverOP;
98 typedef utility::pointer::shared_ptr< RmsfMover const >
RmsfMoverCOP;
103 std::string
get_name()
const {
return "RmsfMover"; }
109 if ( eval_.n_decoys_max() < eval_.n_decoys() + 1 ) {
110 eval_.reserve( eval_.n_decoys() + 100 );
112 eval_.push_back( pose );
118 std::string
get_name()
const {
return "FitMover"; }
129 if ( iref &&
first ) {
139 CA_superimpose( weights_, ref_pose_, pose );
144 SilentFileJobInputterOP sfd_inputter (
145 utility::pointer::dynamic_pointer_cast< protocols::jd2::SilentFileJobInputter > ( JobDistributor::get_instance()->job_inputter() ) );
146 if ( sfd_inputter ) {
148 io::silent::SilentFileData
const& sfd( sfd_inputter->silent_file_data() );
149 rmsf_tool->eval_.push_back_CA_xyz_from_silent_file( sfd,
false );
151 JobDistributor::get_instance()->go( rmsf_tool, JobOutputterOP(
new jd2::NoOutputJobOutputter ) );
156 if ( !
option[ rigid::in ].
user() )
return natoms;
157 loops::PoseNumberedLoopFileReader loop_file_reader;
158 loop_file_reader.hijack_loop_reading_code_set_loop_line_begin_token(
"RIGID" );
159 std::ifstream is(
option[ rigid::in ]().
name().c_str() );
161 loops::SerializedLoopList
loops = loop_file_reader.read_pose_numbered_loops_file(is,
option[ rigid::in ](),
false );
162 loops::Loops rigid = loops::Loops( loops );
164 for (
Size i=1; i<=natoms; ++i ) {
165 if ( rigid.is_loop_residue( i ) ) {
170 return count_expected;
176 Size icenter = eval.wRMSD(
option[ wRMSD ],
option[ tolerance ](), weights );
177 eval.rmsf( rmsf_result );
182 for (
Size i=1; i<=digits; ++i ) {
185 d = floor( d + 0.5 );
186 for (
Size i=1; i<=digits; ++i ) {
195 using namespace basic::options::OptionKeys;
196 using namespace protocols::jd2;
208 rmsf_tool->eval_.set_weights(
weights );
226 os_rmsf << ct <<
" " << *it <<
" " <<
weights( ct ) << std::endl;
232 Real const cutoff (
option[ rigid::cutoff ] );
233 tr.
Info <<
"make rigid with cutoff " << cutoff <<
" and write to file... " <<
option[ rigid::out ]() << std::endl;
235 for (
Size i=1; i<=rmsf_result.size(); ++i ) {
236 if ( rmsf_result[ i ]<cutoff && input_weights( i ) > 0 ) rigid.add_loop( loops::Loop( i, i ),
option[ rigid::min_gap ]() );
238 tr.
Info << rigid << std::endl;
239 rigid.write_loops_to_file(
option[ rigid::out ](),
"RIGID" );
240 std::string fname =
option[ rigid::out ]();
241 loops::Loops
loops = rigid.invert( rmsf_result.size() );
242 loops.write_loops_to_file( fname +
".loopfile" ,
"LOOP" );
250 fit_tool->iref = icenter - 1;
251 JobDistributor::get_instance()->restart();
252 JobDistributor::get_instance()->go( fit_tool, JobOutputterOP(
new jd2::NoOutputJobOutputter ) );
254 JobDistributor::get_instance()->restart();
255 JobDistributor::get_instance()->go( fit_tool );
258 core::import_pose::pose_from_pdb( native_pose,
259 *core::chemical::ChemicalManager::get_instance()->residue_type_set( chemical::CENTROID ),
option[
in::file::native ]() );
260 fit_tool->apply( native_pose );
261 native_pose.dump_pdb(
"fit_native.pdb");
267 Real const cutoff (
option[ rigid::cutoff ] );
268 tr.
Info <<
"make rigid with cutoff " << cutoff <<
" and calculate RMSD" << std::endl;
273 for (
Size i=1; i<=rmsf_result.size(); ++i ) {
274 if ( rmsf_result[ i ]<cutoff && input_weights( i ) > 0 ) {
275 rigid.add_loop( loops::Loop( i, i ),
option[ rigid::min_gap ]() );
280 tr.
Info <<
"computed RMSD on " << std::endl;;
281 rigid.write_loops_to_stream(
tr.
Info,
"RIGID" );
284 FArray2D_double average_structure( 3, rmsf_tool->eval_.n_atoms(), 0.0 );
285 rmsf_tool->eval_.compute_average_structure( average_structure );
286 Real mean_rmsd( 0.0 );
287 for (
Size n=1; n<=rmsf_tool->eval_.n_decoys(); n++ ) {
289 mean_rmsd+=1.0/rmsf_tool->eval_.n_decoys()*
290 rmsf_tool->eval_.rmsd(
weights, average_structure, xx );
292 tr.
Info <<
"number of atoms from " << expected_rigid_atoms <<
" for mean RMSD: " << ct << std::endl;
293 tr.
Info <<
"fraction of residues converged: " <<
round(1.0*ct/expected_rigid_atoms,2) << std::endl;
294 tr.
Info <<
"mean RMSD to average structure: " <<
round(mean_rmsd,2) << std::endl;
296 Real rmsd_pairs( 0.0 );
297 for (
Size n=1; n<=rmsf_tool->eval_.n_decoys(); n++ ) {
298 for (
Size m=n+1; m<=rmsf_tool->eval_.n_decoys(); m++ ) {
302 rmsd_pairs+=rmsf_tool->eval_.rmsd(
weights, xx1, xx2 );
305 core::Real fraction=1.0*ct/expected_rigid_atoms;
306 tr.
Info <<
"mean pairwise RMSD: " <<
round(rmsd_pairs/ct_pairs,2) << std::endl;
307 tr.
Info <<
"mean pairwise RMSD * superposed_fraction_of_atoms^-1: " <<
round(rmsd_pairs/ct_pairs/fraction,2 ) << std::endl;
316 main(
int argc,
char * argv [] )
328 std::cout <<
"caught exception " << e.
msg() << std::endl;
ocstream cerr(std::cerr)
Wrapper around std::cerr.
#define utility_exit_with_message(m)
Exit with file + line + message.
virtual std::string const msg() const
static THREAD_LOCAL basic::Tracer tr("main")
virtual void apply(core::pose::Pose &)
void init(int argc, char *argv[])
Command line init() version.
BooleanOptionKey const user("options:user")
std::string get_name() const
virtual void apply(core::pose::Pose &)
#define runtime_assert(_Expression)
Assert that the condition holds. Evaluated for both debug and release builds.
FArray2P< double > FArray2P_double
void read_structures(RmsfMoverOP rmsf_tool)
virtual void show(std::ostream &) const =0
utility::pointer::shared_ptr< FitMover > FitMoverOP
core::Size read_input_weights(FArray1D_double &weights, Size natoms)
Program exit functions and macros.
rule< Scanner, options_closure::context_t > options
super::const_iterator const_iterator
#define OPT_KEY(type, key)
Output file stream wrapper for uncompressed and compressed files.
#define NEW_OPT(akey, help, adef)
ocstream cout(std::cout)
Wrapper around std::cout.
vector1: std::vector with 1-based indexing
core::Real round(core::Real d, core::Size digits)
core::pose::Pose ref_pose_
base class for Exception system
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for ...
int main(int argc, char *argv[])
=============================== MAIN ============================================================ ...
rule< Scanner, string_closure::context_t > name
utility::pointer::shared_ptr< RmsfMover > RmsfMoverOP
std::string get_name() const
Size superimpose(DecoySetEvaluation &eval, utility::vector1< Real > &rmsf_result, FArray1D_double &weights)
ozstream: Output file stream wrapper for uncompressed and compressed files
#define OPT_1GRP_KEY(type, grp, key)
int const silent
Named verbosity levels.
utility::pointer::shared_ptr< RmsfMover const > RmsfMoverCOP
rule< Scanner, option_closure::context_t > option