15 #include <core/types.hh>
17 #include <core/chemical/AA.hh>
18 #include <protocols/scoring/Interface.hh>
19 #include <core/conformation/Residue.hh>
20 #include <core/chemical/ResidueTypeSet.hh>
22 #include <core/scoring/ScoreFunction.hh>
23 #include <core/scoring/ScoreFunctionFactory.hh>
25 #include <core/pack/task/PackerTask.hh>
26 #include <core/pack/task/TaskFactory.hh>
28 #include <core/pose/Pose.hh>
34 #include <basic/options/keys/ddg.OptionKeys.gen.hh>
35 #include <basic/options/keys/in.OptionKeys.gen.hh>
36 #include <basic/options/keys/score.OptionKeys.gen.hh>
37 #include <basic/options/keys/packing.OptionKeys.gen.hh>
44 #include <core/pack/task/ResfileReader.hh>
54 #include <protocols/ddg/ddGMover.hh>
57 #include <core/import_pose/import_pose.hh>
70 using namespace scoring;
80 ddgs delta_e_components,
84 protocols::ddg::ddGMover& mover,
89 std::ofstream ddg_output(ddg_out.c_str(), std::ios_base::app);
93 TR <<
"having trouble opening output file for dumping predicted ddgs "
94 << ddg_out << std::endl;
101 mover.get_scorefunction_header(mover.minimization_score_function(),scorefxn_header);
103 mover.get_scorefunction_header(mover.score_function(),scorefxn_header);
107 if ( print_header ) {
108 ddg_output <<
"ddG: description total ";
109 for (
Size i =1; i <=scorefxn_header.size(); i++ ) {
110 ddg_output << scorefxn_header[i] <<
" ";
116 if ( label.compare(
"") != 0 ) {
118 for (
Size m=1; m<=delta_e_components.size(); m++ ) {
124 ddg_output << std::endl;
148 std::ifstream inputstream;
149 inputstream.open(filename.c_str());
151 if ( inputstream.is_open() ) {
154 int total; std::string total_keyword;
155 inputstream >> total_keyword;
156 assert(total_keyword.compare(
"total") == 0);
157 inputstream >> total;
160 while ( !inputstream.eof() ) {
163 mutations current_mutation(pose.total_residue(),core::chemical::aa_unk);
165 inputstream >> num_mutations;
168 while ( num_mutations > 0 ) {
171 inputstream >> wt >> resnum >> mut;
173 TR <<
"wt is " << wt <<
" resnum is " << resnum <<
" and mut is " << mut << std::endl;
175 runtime_assert(core::chemical::oneletter_code_specifies_aa( mut ) );
178 core::chemical::AA mutation= core::chemical::aa_from_oneletter_code(mut);
179 current_mutation[
resnum]=mutation;
180 num_mutations--; total--;
182 TR <<
"end reading mutations for this" << std::endl;
185 if ( num_mutations < 0 ) {
186 TR.
Error <<
"number of mutations mismatch! num_mutations < 0" << std::endl;
190 res_to_mut.push_back(current_mutation);
195 TR.
Error <<
"total number of mutations mismatch! total < 0" << std::endl;
204 main(
int argc,
char * argv [] )
208 using namespace pose;
209 using namespace scoring;
210 using namespace conformation;
213 using namespace basic::options::OptionKeys;
215 using namespace protocols::moves;
218 OPT(ddg::weight_file);
219 OPT(ddg::iterations);
220 OPT(ddg::debug_output);
223 OPT(ddg::interface_ddg);
224 OPT(ddg::opt_radius);
232 bool header_printed =
false;
241 std::string weight_file =
option[ OptionKeys::ddg::weight_file ]();
246 TR <<
"option score::fa_max_dis unspecified on the command ine. Setting fa_max_dis to 9.0 A." << std::endl;
250 TR <<
"Using command line defined score::fa_max_dis of " <<
option[ score::fa_max_dis ] <<
" A." << std::endl;
254 ScoreFunctionOP score_structure_scorefxn(ScoreFunctionFactory::create_score_function(weight_file));
257 ScoreFunctionOP minimize_sfxn;
261 minimize_sfxn=ScoreFunctionFactory::create_score_function(
266 minimize_sfxn=ScoreFunctionFactory::create_score_function(
basic::options::option[OptionKeys::ddg::minimization_scorefunction]());
268 minimize_sfxn=get_score_function();
272 int num_iterations =
option[ OptionKeys::ddg::iterations ]();
275 bool opt_nbrs =
false;
288 bool debug_output =
option[ OptionKeys::ddg::debug_output ]();
289 if ( debug_output ) {
290 TR <<
"weights being used: " <<
291 score_structure_scorefxn->weights() <<
"\n";
295 bool dump_pdbs =
option[ OptionKeys::ddg::dump_pdbs ]();
298 std::string ddg_out =
option[ OptionKeys::ddg::out ]();
302 Size const interface_ddg =
option[ OptionKeys::ddg::interface_ddg ]();
306 bool min_cst =
option[OptionKeys::ddg::min_cst]();
324 protocols::ddg::ddGMover get_wt_score(score_structure_scorefxn,minimize_sfxn,all_unk);
325 get_wt_score.set_min_cst(min_cst);
326 get_wt_score.set_min(
min);
327 get_wt_score.set_mean(
mean);
331 get_wt_score.restrict_to_nbrs(opt_nbrs);
332 get_wt_score.neighbor_cutoff(cutoff);
333 get_wt_score.num_iterations(num_iterations);
334 get_wt_score.dump_pdbs(dump_pdbs);
335 get_wt_score.is_interface_ddg(interface_ddg);
336 get_wt_score.debug_output(debug_output);
337 get_wt_score.num_iterations(num_iterations);
338 get_wt_score.residues_to_mutate(all_unk);
339 get_wt_score.apply(
pose);
340 wt_averaged_score_components=get_wt_score.get_wt_averaged_score_components();
344 if (
option[ OptionKeys::ddg::mut_file ].
user() ) {
346 TR <<
"reading in mutfile" << std::endl;
350 TR <<
"size of res_to_mut is: " << res_to_mut.size() << std::endl;
353 for (
Size i=1; i <= res_to_mut.size(); i++ ) {
358 bool mutation_defined =
false;
359 for (
Size m =1; m<= residues_to_mutate.size(); m++ ) {
360 if ( residues_to_mutate[m] != core::chemical::aa_unk ) {
361 mutation_defined=
true;
364 if ( mutation_defined ) {
367 protocols::ddg::ddGMover point_mutation(score_structure_scorefxn,minimize_sfxn,residues_to_mutate);
368 point_mutation.set_min_cst(min_cst);
369 point_mutation.set_min(
min);
370 point_mutation.set_mean(
mean);
372 if ( !opt_nbrs && get_wt_score.is_wt_calc_complete() ) {
373 TR <<
"testing if wt calc is complete. should be complete!" << std::endl;
374 point_mutation.wt_score_components(get_wt_score.wt_score_components());
378 point_mutation.restrict_to_nbrs(opt_nbrs);
379 point_mutation.neighbor_cutoff(cutoff);
380 point_mutation.dump_pdbs(dump_pdbs);
381 point_mutation.debug_output(debug_output);
382 point_mutation.num_iterations(num_iterations);
385 point_mutation.apply(
pose);
386 delta_delta_G_label.push_back(point_mutation.mutation_label(
pose));
387 TR <<
"mutation label for this round is " << point_mutation.mutation_label(
pose) << std::endl;
390 if ( point_mutation.is_wt_calc_complete() &&
391 point_mutation.is_mutant_calc_complete() ) {
394 delta_energy_components.push_back(point_mutation.get_delta_energy_components());
395 mutant_averaged_score_components.push_back(point_mutation.get_mutant_averaged_score_components());
396 total_ddgs.push_back(point_mutation.ddG());
398 point_mutation.mutation_label(
pose),
399 point_mutation.get_delta_energy_components(),
400 point_mutation.get_mutant_averaged_score_components(),
401 point_mutation.ddG(),
405 if ( ! header_printed ) {
406 header_printed =
true;
417 pack::task::PackerTaskOP storage_task(pack::task::TaskFactory::create_packer_task(
pose));
418 storage_task->initialize_from_command_line();
419 pack::task::parse_resfile(
pose, *storage_task);
420 storage_task->or_include_current(
true);
423 for (
Size i =1; i<=
pose.total_residue(); i++ ) {
426 if ( storage_task->design_residue(i) ) {
429 for ( ResidueLevelTask::ResidueTypeCOPListConstIter aa_iter(storage_task->residue_task(i).allowed_residue_types_begin()),
430 aa_end(storage_task->residue_task(i).allowed_residue_types_end());
431 aa_iter != aa_end; ++aa_iter ) {
434 residues_to_mutate[i]=((*aa_iter)->aa());
437 if ( residues_to_mutate[i] != core::chemical::aa_unk ) {
440 protocols::ddg::ddGMover point_mutation(score_structure_scorefxn,minimize_sfxn,residues_to_mutate);
441 point_mutation.set_min_cst(min_cst);
442 point_mutation.set_min(
min);
443 point_mutation.set_mean(
mean);
446 if ( !opt_nbrs && get_wt_score.is_wt_calc_complete() ) {
447 TR <<
"testing if wt calc is complete. should be complete!" << std::endl;
448 point_mutation.wt_score_components(get_wt_score.wt_score_components());
452 point_mutation.restrict_to_nbrs(opt_nbrs);
453 point_mutation.neighbor_cutoff(cutoff);
454 point_mutation.dump_pdbs(dump_pdbs);
455 point_mutation.debug_output(debug_output);
456 point_mutation.num_iterations(num_iterations);
459 point_mutation.apply(
pose);
460 delta_delta_G_label.push_back(point_mutation.mutation_label(
pose));
463 if ( point_mutation.is_wt_calc_complete() &&
464 point_mutation.is_mutant_calc_complete() ) {
468 delta_energy_components.push_back(point_mutation.get_delta_energy_components());
469 mutant_averaged_score_components.push_back(point_mutation.get_mutant_averaged_score_components());
470 total_ddgs.push_back(point_mutation.ddG());
474 point_mutation.mutation_label(
pose),
475 point_mutation.get_delta_energy_components(),
476 point_mutation.get_mutant_averaged_score_components(),
477 point_mutation.ddG(),
481 if ( ! header_printed ) {
482 header_printed =
true;
491 if ( interface_ddg > 0 ) {
495 using namespace core;
496 using namespace core::conformation;
497 using namespace core::chemical;
501 protocols::scoring::Interface protein_interface(interface_ddg);
502 protein_interface.distance(10.0);
503 protein_interface.calculate(
pose);
507 for (
Size i =1; i<=
pose.total_residue(); i++ ) {
508 if ( protein_interface.is_interface(i) ) {
509 TR.
Debug <<
"[DEBUG]:" << i <<
" is in the interface " << std::endl;
514 for (
Size i =1; i<=
pose.total_residue(); i++ ) {
516 if ( protein_interface.is_interface(i) ) {
518 for (
Size j =1; j <= 20 ; j++ ) {
520 residues_to_mutate = all_unk;
521 core::chemical::AA curr_aa = (core::chemical::AA)j;
524 if ( curr_aa !=
pose.aa(i) && (
pose.aa(i) != aa_unk) ) {
527 residues_to_mutate[i]=curr_aa;
528 protocols::ddg::ddGMover interface_mutation(score_structure_scorefxn,minimize_sfxn,residues_to_mutate);
531 interface_mutation.set_min_cst(min_cst);
532 interface_mutation.is_interface_ddg(interface_ddg);
533 interface_mutation.set_min(
min);
534 interface_mutation.set_mean(
mean);
537 if ( get_wt_score.is_wt_calc_complete() ) {
538 TR <<
"testing if wt calc is complete. should be complete!" << std::endl;
539 interface_mutation.wt_score_components(get_wt_score.wt_score_components());
540 interface_mutation.wt_unbound_score_components(get_wt_score.wt_unbound_score_components());
544 if ( dump_pdbs ) interface_mutation.dump_pdbs(dump_pdbs);
545 if ( debug_output ) interface_mutation.debug_output(debug_output);
546 interface_mutation.num_iterations(num_iterations);
549 interface_mutation.apply(
pose);
550 delta_delta_G_label.push_back(interface_mutation.mutation_label(
pose));
551 TR <<
"mutation label for this round is " << interface_mutation.mutation_label(
pose) << std::endl;
554 if ( interface_mutation.is_wt_calc_complete() &&
555 interface_mutation.is_mutant_calc_complete() ) {
557 delta_energy_components.push_back(interface_mutation.get_delta_energy_components());
558 mutant_averaged_score_components.push_back(interface_mutation.get_mutant_averaged_score_components());
559 total_ddgs.push_back(interface_mutation.ddG());
562 interface_mutation.mutation_label(
pose),
563 interface_mutation.get_delta_energy_components(),
564 interface_mutation.get_mutant_averaged_score_components(),
565 interface_mutation.ddG(),
569 if ( ! header_printed ) {
570 header_printed =
true;
572 TR <<
"interface mutation is complete and ddg is: " << interface_mutation.ddG() << std::endl;
606 std::cout <<
"caught exception " << e.
msg() << std::endl;
virtual std::string const msg() const
void exit(std::string const &file, int const line, std::string const &message, int const status)
Exit with file + line + message + optional status.
vector0: std::vector with assert-checked bounds
void init(int argc, char *argv[])
Command line init() version.
BooleanOptionKey const user("options:user")
void read_in_mutations(utility::vector1< mutations > &res_to_mut, std::string filename, pose::Pose &pose)
The input file is a list of mutation blocks. Usually, this will be a set of point mutations...
#define runtime_assert(_Expression)
Assert that the condition holds. Evaluated for both debug and release builds.
Tracer & T(std::string const &channel, TracerPriority priority)
T is special function for assign tracer property on the static object.
common derived classes for thrown exceptions
std::string start_file()
kind of like the old -s – just one file
static THREAD_LOCAL basic::Tracer TR("apps.public.ddg.ddg_monomer")
Functions for opening database files.
Tracer & Error(TracerPriority priority=t_error)
Predefined Error tracer.
utility::vector1< core::chemical::AA > mutations
basic::options::OptionKeys collection
utility::vector1< double > ddgs
std::vector with 1-based indexing
rule< Scanner, options_closure::context_t > options
void print_ddgs(std::string ddg_out, std::string label, ddgs delta_e_components, ddgs, double total_ddgs, protocols::ddg::ddGMover &mover, bool print_header, bool min_cst)
print ddGs
Tracer & Warning(TracerPriority priority=t_warning)
Predefined Warning tracer.
list resnum
if line_edit[13:14]=='P': #Nucleic acid? Skip.
utility::options::OptionCollection option
OptionCollection global.
T mean(Iterator first, Iterator last, T)
mean value of an input vector
Option lookup functions emulating Rosetta++ equivalents for transitional use.
ocstream cout(std::cout)
Wrapper around std::cout.
vector1: std::vector with 1-based indexing
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for ...
int main(int argc, char *argv[])
Fast (x,y,z)-coordinate numeric vector.
StringOptionKey wt("revert_app:wt")
rule< Scanner, option_closure::context_t > option