55 #include <basic/Tracer.hh>
58 #include <utility/io/ozstream.hh>
61 #include <numeric/xyzVector.hh>
67 #include <basic/options/option.hh>
70 #include <basic/options/keys/motifs.OptionKeys.gen.hh>
72 #include <utility/vector1.hh>
78 static basic::Tracer
ms_tr(
"protocols.motifs.MotifSearch", basic::t_info );
86 build_positionOPs_(0),
87 target_conformers_map_(),
89 ztest_cutoff_1_( basic::options::option[ basic::options::OptionKeys::motifs::z1 ]() ),
90 ztest_cutoff_2_( basic::options::option[ basic::options::OptionKeys::motifs::z2 ]() ),
91 rmsd_cutoff_1_( basic::options::option[ basic::options::OptionKeys::motifs::r1 ]() ),
92 rmsd_cutoff_2_( basic::options::option[ basic::options::OptionKeys::motifs::r2 ]() ),
93 dtest_cutoff_( basic::options::option[ basic::options::OptionKeys::motifs::dtest ]() ),
94 rot_level_( basic::options::option[ basic::options::OptionKeys::motifs::rotlevel ]() ),
95 minimize_( basic::options::option[ basic::options::OptionKeys::motifs::minimize ]() )
101 utility::pointer::ReferenceCount( src )
163 if( input_BPs.empty() ) {
177 ms_tr <<
"No input build or target positions, will be doing a motif search using every protein position in the interface as a build position." << std::endl;
180 std::set< std::string > names;
184 if( ! input_BPs.empty() ) {
185 for(
Size i(1); i <= input_BPs.size(); ++i ) {
191 }
else if( build_position_defs.empty() ) {
192 ms_tr <<
"Identifying build positions based on input target positions (or they're from DnaInterfacePacker)." << std::endl;
193 if ( ! input_BPs.empty() ) {
194 for(
Size i(1); i <= input_BPs.size(); ++i ) {
203 ms_tr <<
"No target positions given, will be using closest position to placed motif." << std::endl;
206 std::set< std::string > names;
218 ir != end_ir; ++ir ) {
226 ms_tr <<
"WARNING!! Loading BPData, but also loaded a MotifLibrary of all motifs" << std::endl;
240 utility::io::ozstream motif_output_file;
241 utility::io::ozstream data_output_file;
242 utility::io::ozstream qd_output_file;
251 motif_filename.erase( motif_filename.end()-4, motif_filename.end() );
252 std::string qd_output_filename = motif_filename +
".qd_motifs";
253 qd_output_file.open_append( qd_output_filename );
258 ir != end_ir; ++ir ) {
260 std::map< std::string, std::map< Real, MotifHitOP > > best_mhits_all;
264 ms_tr <<
"WORKING ON PROTEIN POSITION " << (*ir)->seqpos() << std::endl;
265 MotifCOPs bp_best_motifs( (*ir)->best_motifs() );
270 Size seqpos( (*ir)->seqpos() );
271 std::stringstream firstline;
272 firstline <<
"POSITION " << seqpos;
274 motif_output_file << firstline.str() <<
"\n";
277 data_output_file << firstline.str() <<
"\n";
280 qd_output_file << firstline.str() <<
"\n";
285 if( ! bp_best_motifs.empty() ) {
286 motif_library = bp_best_motifs;
291 std::map< core::Size, core::pack::rotamer_set::RotamerSetOP > rotamer_sets;
292 if( bp_best_rotamers.empty() ) {
297 rotamer_sets[i] = rotset;
300 Size bp_rots( bp_best_rotamers.size() );
304 for(
Size r(1); r <= bp_rots; ++r ) {
306 rotset->add_rotamer( *((bp_best_rotamers)[r]) );
309 rotamer_sets[i] = rotset;
315 for( protocols::motifs::MotifCOPs::const_iterator motifcop_itr = motif_library.begin(), end_itr = motif_library.end();
316 motifcop_itr != end_itr; ++motifcop_itr ) {
318 bool passed_quick_and_dirty(
false);
327 std::set< std::string > allowedtypes( (*ir)->allowed_types() );
336 rmsd_cutoff_1 = (rmsd_cutoff_1 / 2.0 );
337 rmsd_cutoff_2 = (rmsd_cutoff_2 / 2.0 );
338 dtest_cutoff = (dtest_cutoff / 2.0 );
340 if( ( (motifcop->restype_name1() ==
"MET") || (motifcop->restype_name1() ==
"LYS") || (motifcop->restype_name1() ==
"GLU") || (motifcop->restype_name1() ==
"GLN") ) && ( !
quick_and_dirty_ ) ) {
341 rmsd_cutoff_1 = (rmsd_cutoff_1 / 1.33 );
342 rmsd_cutoff_2 = (rmsd_cutoff_2 / 1.33 );
343 dtest_cutoff = (dtest_cutoff / 1.33 );
351 atoms.push_back(
"C5");
352 atoms.push_back(
"C6");
353 atoms.push_back(
"N3");
354 atoms.push_back(
"C2");
355 atoms.push_back(
"N1");
356 atoms.push_back(
"C4");
358 atoms.push_back(
"C5");
359 atoms.push_back(
"C4");
360 atoms.push_back(
"N1");
361 atoms.push_back(
"C2");
362 atoms.push_back(
"N3");
363 atoms.push_back(
"C6");
365 ms_tr <<
"Residue you are planning to do parallel base test with is not a DNA base!" << std::endl;
368 bool automorphism(
false);
369 bool passed_automorphism(
false);
371 motifcop->restype_name1() ==
"ASP" ||
372 motifcop->restype_name1() ==
"GLU" ||
373 motifcop->restype_name1() ==
"PHE" ||
374 motifcop->restype_name1() ==
"LEU" ||
375 motifcop->restype_name1() ==
"ARG" ||
376 motifcop->restype_name1() ==
"TYR" ||
377 motifcop->restype_name1() ==
"VAL"
386 if( allowedtypes.empty() ) {
389 for( std::set< std::string >::const_iterator ir2(allowedtypes.begin() ), end_ir2( allowedtypes.end() );
390 ir2 != end_ir2; ++ir2 ) {
391 if( (*ir2) == motifcop->restype_name1() ) {
395 if( ! allowed )
continue;
404 bool noconformers(
false );
405 if( DNAResidueOPs.empty() ) {
413 std::pair< core::conformation::ResidueOP, core::conformation::ResidueOP > bestpair;
414 bool b_bestpair(
false );
415 Size rs1( rotset->num_rotamers() );
418 for(
Size ir2(1); ir2 <= rs1; ++ir2 ) {
420 Real rmsdtest_ir2(100.0);
426 motifcop->place_atom( *(rotset->nonconst_rotamer(ir2)), *baseres2, atm );
428 motifcop->place_atom( *(rotset->nonconst_rotamer(ir2)), *baseres2, auto_atm,
false );
439 bpos !=
end; ++bpos ) {
441 for( std::set< std::string >::const_iterator type( allowed_types.begin()), atend( allowed_types.end() );
442 type != atend; ++type ) {
443 if( basetype == *type ) {
445 Real dtest1( atm.xyz().distance_squared( posecopy.
residue( *bpos ).
xyz(
"C1*" ) ) );
446 Real dtest1_auto(100);
448 dtest1_auto = ( auto_atm.xyz().distance_squared( posecopy.
residue( *bpos ).
xyz(
"C1*" ) ) );
451 if( ! automorphism ) {
452 if( dtest1 > dtest_cutoff )
continue;
454 if( dtest1 > dtest_cutoff && dtest1_auto > dtest_cutoff )
continue;
455 if( dtest1 < dtest_cutoff && dtest1_auto < dtest_cutoff ) {
456 if( dtest1_auto < dtest1 ) {
457 passed_automorphism =
true;
459 passed_automorphism =
false;
461 }
else if( dtest1_auto < dtest_cutoff ) {
462 passed_automorphism =
true;
464 passed_automorphism =
false;
468 if( passed_automorphism ) {
469 motifcop->place_atoms( *(rotset->nonconst_rotamer(ir2)), *posebase, atoms,
false );
471 motifcop->place_atoms( *(rotset->nonconst_rotamer(ir2)), *posebase, atoms );
475 if( ztest < ztest_cutoff_1 )
continue;
478 qd_output_file << *motifcop;
479 passed_quick_and_dirty =
true;
487 if( rmsdtest > rmsd_cutoff_1 )
continue;
488 rmsdtest_ir2 = rmsdtest;
489 if( rmsdtest < test ) {
492 posecopy2 = posecopy;
497 if( passed_quick_and_dirty )
break;
500 if( passed_quick_and_dirty )
break;
501 if( ! tftest )
continue;
508 if( passed_automorphism ) {
509 motifcop->place_residue(*(rotset->nonconst_rotamer(ir2)), *posebase2,
false );
511 motifcop->place_residue(*(rotset->nonconst_rotamer(ir2)), *posebase2 );
517 Real finaltest = ( ( rmsdtest_ir2 * 100 ) / ( ztest_ir2 * 100 ) );
519 if( (rmsdtest_ir2 < rmsd_cutoff_2) && (ztest_ir2 >
ztest_cutoff_2) ) {
520 ms_tr <<
"Passed! RMSD between DNA resi (rosetta #), no conformers " << bestpos <<
" and motif DNA = " << rmsdtest_ir2 <<
" and Z-test = " << ztest_ir2 <<
" and combined score = " << finaltest <<
" for residue type " << motifcop->restype_name1() <<
", rotamer # " << ir2 <<
", motif named " << motifcop->remark() << std::endl;
523 data_output_file <<
"Passed! RMSD between DNA resi (rosetta #), no conformers " << bestpos <<
" and motif DNA = " << rmsdtest_ir2 <<
" and Z-test = " << ztest_ir2 <<
" and combined score = " << finaltest <<
" for residue type " << motifcop->restype_name1() <<
", rotamer # " << ir2 <<
", motif named " << motifcop->remark() << std::endl;
526 if ( ( motifcop->restype_name1() ==
"SER" ) || ( motifcop->restype_name1() ==
"THR" ) || ( motifcop->restype_name1() ==
"TYR" ) || ( motifcop->restype_name1() ==
"ILE" ) || ( motifcop->restype_name1() ==
"CYS" ) ) {
527 finaltest = finaltest + ( 0.00001 * ir2 );
529 motifhit->final_test( finaltest );
530 motifhit->build_rotamer( *(rotset->nonconst_rotamer(ir2) ) );
531 motifhit->target_conformer( *posebase2 );
532 best_mhits_all[motifcop->restype_name1()][finaltest] = motifhit->clone();
533 if ( finaltest <
final ) {
535 bestpair = std::make_pair( (rotset->nonconst_rotamer(ir2))->
clone(), posebase2->clone() );
540 for( core::conformation::ResidueOPs::const_iterator resop( DNAResidueOPs.begin() ),
end( DNAResidueOPs.end() );
541 resop !=
end; ++resop ) {
542 if( passed_automorphism ) {
543 motifcop->place_residue(*(rotset->nonconst_rotamer(ir2)), **resop,
false );
545 motifcop->place_residue(*(rotset->nonconst_rotamer(ir2)), **resop );
548 if( ztest2 < ztest_cutoff_2 )
continue;
550 if( rmsdtest2 > rmsd_cutoff_2 )
continue;
551 Real finaltest = ( ( rmsdtest2 * 100 ) / ( ztest2 * 100 ) );
552 Real finaltestc = ( ( rmsdtest_ir2 * 100 ) / ( ztest_ir2 * 100 ) );
555 ms_tr <<
"Passed! RMSD between DNA resi (rosetta #) " << bestpos <<
" and motif DNA = " << rmsdtest2 <<
" and Z-test = " << ztest2 <<
" and combined score = " << finaltest <<
" for residue type " << motifcop->restype_name1() <<
", rotamer # " << ir2 <<
", motif named " << motifcop->remark() << std::endl;
557 data_output_file <<
"Passed! RMSD between DNA resi (rosetta #) " << bestpos <<
" and motif DNA = " << rmsdtest2 <<
" and Z-test = " << ztest2 <<
" and combined score = " << finaltest <<
" for residue type " << motifcop->restype_name1() <<
", rotamer # " << ir2 <<
", motif named " << motifcop->remark() << std::endl;
560 if ( ( motifcop->restype_name1() ==
"SER" ) || ( motifcop->restype_name1() ==
"THR" ) || ( motifcop->restype_name1() ==
"TYR" ) || ( motifcop->restype_name1() ==
"ILE" ) || ( motifcop->restype_name1() ==
"CYS" ) ) {
561 finaltest = finaltest + ( 0.00001 * ir2 );
563 motifhit->final_test( finaltest );
564 motifhit->build_rotamer( *(rotset->nonconst_rotamer(ir2) ) );
565 motifhit->target_conformer( **resop );
566 best_mhits_all[motifcop->restype_name1()][finaltestc] = motifhit->clone();
567 if ( finaltest <
final ) {
569 bestpair = std::make_pair( (rotset->nonconst_rotamer(ir2))->
clone(), (*resop)->clone() );
583 std::stringstream pose2_name_full;
584 if( passed_automorphism ) {
585 pose2_name_full <<
"Test_auto_" << motifcop->restype_name2()[0] <<
"_" << (*ir)->seqpos() << motifcop->restype_name1() <<
"_" << motifcop->remark() <<
".pdb";
587 pose2_name_full <<
"Test_" << motifcop->restype_name2()[0] <<
"_" << (*ir)->seqpos() << motifcop->restype_name1() <<
"_" << motifcop->remark() <<
".pdb";
593 if( ! best_mhits_all.empty() ) {
595 for( std::map<
std::string, std::map< Real, MotifHitOP > >::const_iterator bh( best_mhits_all.begin() ),
596 end( best_mhits_all.end() ); bh !=
end; ++bh ) {
598 for( std::map< Real, MotifHitOP >::const_iterator bh2( (bh->second).begin() ),
599 end2( (bh->second).end() ); bh2 != end2; ++bh2 ) {
602 (*ir)->keep_rotamer( *(motifhitop->build_rotamer()) );
603 (*ir)->keep_motif( *(motifhitop->motifcop()) );
604 (*ir)->keep_motifhit( *(motifhitop) );
607 motif_output_file << *(motifhitop->motifcop());
608 motif_output_file <<
"RESIDUE " << (*(motifhitop->build_rotamer()));
612 using namespace core::scoring;
629 if( motifhitop->passed_automorphism() ) {
630 (motifhitop->motifcop())->place_residue( pose_dump.
residue( motifhitop->vbpos() ), *build_rotamer,
false );
632 (motifhitop->motifcop())->place_residue( pose_dump.
residue( motifhitop->vbpos() ), *build_rotamer );
650 score_fxn->set_energy_method_options( options );
662 movemap->set_chi( (*ir)->seqpos(), true );
664 minmover->apply( pose_dump );
667 ms_tr <<
"After sidechain refinement constraints score is " << sc_constraint_check << std::endl;
687 if( sc_constraint_check < 10.0 ) {
688 (*ir)->keep_rotamer( (pose_dump.
residue((*ir)->seqpos())) );
689 (*ir)->keep_motif( *(motifhitop->motifcop()) );
690 (*ir)->keep_motifhit( *(motifhitop) );
693 motif_output_file << *(motifhitop->motifcop());
694 motif_output_file <<
"RESIDUE " << (pose_dump.
residue((*ir)->seqpos()));
697 pose_dump.
replace_residue( (*ir)->seqpos(), *(motifhitop->build_rotamer()),
true );
698 (*ir)->keep_rotamer( (pose_dump.
residue((*ir)->seqpos())) );
699 (*ir)->keep_motif( *(motifhitop->motifcop()) );
700 (*ir)->keep_motifhit( *(motifhitop) );
702 motif_output_file << *(motifhitop->motifcop());
703 motif_output_file <<
"RESIDUE " << (pose_dump.
residue((*ir)->seqpos()));
712 motif_output_file.close();
715 data_output_file.close();
718 qd_output_file.close();
729 ir != end_ir; ++ir ) {
730 if( (*ir)->seqpos() != seqpos )
continue;
731 if ( ! ((*ir)->best_rotamers()).empty() ) {
732 std::set< std::string > allowedtypes( (*ir)->allowed_types() );
733 if( allowedtypes.empty() ) {
734 best_rotamers = (*ir)->best_rotamers();
736 Size rs( ((*ir)->best_rotamers()).
size() );
737 for (
Size r(1) ; r <= rs; ++r ) {
738 for( std::set< std::string >::const_iterator ir2(allowedtypes.begin() ), end_ir2( allowedtypes.end() );
739 ir2 != end_ir2; ++ir2 ) {
740 if( (*ir2) == ((*ir)->best_rotamers()[r])->name3() ) {
741 best_rotamers.push_back( (*ir)->best_rotamers()[r] );
747 ms_tr <<
"There were no rotamers to be included for position " << seqpos << std::endl;
750 return best_rotamers;
760 ir != end_ir; ++ir ) {
761 if( (*ir)->seqpos() != seqpos )
continue;
762 if ( ! ((*ir)->best_motifhits()).empty() ) {
763 Size rs( ((*ir)->best_motifhits()).
size() );
764 for (
Size r(1) ; r <= rs; ++r ) {
765 motifhitcops.push_back( (*ir)->best_motifhits()[r] );
768 ms_tr <<
"There were no motif hits for " << seqpos <<
". Check to be sure that MotifSearch protocol actually ran. Use flag rerun_motifsearch to ensure that it runs even with input rotamers from BPData flag." << std::endl;
778 using namespace core::chemical;
780 bool protein_dna(
false );
787 if ( ( res1->is_protein() && res2->is_DNA() ) || ( res2->is_protein() && res1->is_DNA() ) ) {
791 ms_tr <<
"MotifLibrary has not been initialized yet, cannot yet identify the type of motifs being used, assuming protein-DNA with possible disastrous consequences." << std::endl;
823 ms_tr <<
"ERROR! These motifs are not protein-DNA, need to add another else if statement that allows for a different type of interface finding function." << std::endl;
836 for ( Sizes::const_iterator pos( positions.begin() ),
end( positions.end() );
837 pos !=
end; ++pos ) {
840 std::set< std::string > allowed_types;
848 ms_tr <<
"ERROR! These motifs are not protein-DNA, need to add another else if statement that allows for a different type of interface finding function." << std::endl;
860 std::set< std::string > allowed_types;
862 allowed_types.insert( pose.
residue( input_BP ).
name3() );
876 std::map< Size, std::set< std::string > > mappositions(
bpdefs2map( pose, defs ) );
877 for ( std::map<
Size, std::set< std::string > >::const_iterator it( mappositions.begin() ),
878 end( mappositions.end() ); it !=
end; ++it ) {
883 ms_tr <<
"ERROR! These motifs are not protein-DNA, need to add another else if statement that allows for a different type of interface finding function." << std::endl;
895 std::map< Size, std::set< std::string > > mappositions(
bpdefs2map( pose, defs ) );
896 for ( std::map<
Size, std::set< std::string > >::const_iterator it( mappositions.begin() ),
897 end( mappositions.end() ); it !=
end; ++it ) {
898 Size test(it->first);
904 ms_tr <<
"ERROR! These motifs are not protein-DNA, need to add another else if statement that allows for a different type of interface finding function." << std::endl;
910 std::map<
Size, std::set< std::string > > mappositions
914 for ( std::map<
Size, std::set< std::string > >::const_iterator it( mappositions.begin() ),
915 end( mappositions.end() ); it !=
end; ++it ) {
916 positions.push_back( it->first );
938 Sizes & build_positions,
943 if ( ! target_positions.empty() ) {
946 for ( protocols::dna::DnaNeighbors::const_iterator itr( protein_neighbors.begin() ),
947 end( protein_neighbors.end() ); itr !=
end; ++itr ) {
948 if ( (*itr).second.contact() ) {
949 build_positions.push_back( itr->first );
950 ms_tr <<
"Positions being targeted for motif design " << itr->first << std::endl;
953 ms_tr <<
"Attempting to identify build positions when there are no target positions." << std::endl;
960 Sizes & build_positions,
967 if ( ! build_positions.empty() ) {
970 for ( protocols::dna::DnaNeighbors::const_iterator itr( dna_neighbors.begin() ),
971 end( dna_neighbors.end() ); itr !=
end; ++itr ) {
972 if ( (*itr).second.contact() ) {
973 short_tl.push_back( itr->first );
974 ms_tr <<
"Positions (DNA) being targeted for motif design " << itr->first << std::endl;
977 ms_tr <<
"Attempting to identify build positions when there are no target positions." << std::endl;
990 bool const bump_check
1006 ztest_cutoff_1_ = basic::options::option[ basic::options::OptionKeys::motifs::z1 ]();
1007 ztest_cutoff_2_ = basic::options::option[ basic::options::OptionKeys::motifs::z2 ]();
1008 rmsd_cutoff_1_ = basic::options::option[ basic::options::OptionKeys::motifs::r1 ]();
1009 rmsd_cutoff_2_ = basic::options::option[ basic::options::OptionKeys::motifs::r2 ]();
1010 dtest_cutoff_ = basic::options::option[ basic::options::OptionKeys::motifs::dtest ]();
1011 rot_level_ = basic::options::option[ basic::options::OptionKeys::motifs::rotlevel ]();
1019 for( protocols::motifs::MotifCOPs::const_iterator motifcop_itr = motiflibrary.
begin(), end_itr = motiflibrary.
end();
1020 motifcop_itr != end_itr; ++motifcop_itr ) {
1030 if( basic::options::option[ basic::options::OptionKeys::motifs::BPData ].user() ) {
1032 bpdata_filename_ = basic::options::option[ basic::options::OptionKeys::motifs::BPData ]();
1036 if( basic::options::option[ basic::options::OptionKeys::motifs::output_file ].user() ) {
1037 output_filename_ = basic::options::option[ basic::options::OptionKeys::motifs::output_file ]();
1042 if( basic::options::option[ basic::options::OptionKeys::motifs::data_file ].user() ) {
1043 data_filename_ = basic::options::option[ basic::options::OptionKeys::motifs::data_file ]();
1048 if( (basic::options::option[ basic::options::OptionKeys::motifs::quick_and_dirty ]).user() ) {
1053 if( (basic::options::option[ basic::options::OptionKeys::motifs::dump_motifs ]).user() ) {
1058 if( basic::options::option[ basic::options::OptionKeys::motifs::clear_bprots ].user() ) {
1063 if( basic::options::option[ basic::options::OptionKeys::motifs::rots2add ].user() ) {
1064 rots2add_ = basic::options::option[ basic::options::OptionKeys::motifs::rots2add ]();
1068 if( (basic::options::option[ basic::options::OptionKeys::motifs::restrict_to_wt ]).user() ) {
1073 if( (basic::options::option[ basic::options::OptionKeys::motifs::rerun_motifsearch ]).user() ) {
1078 if( (basic::options::option[ basic::options::OptionKeys::motifs::no_rotamer_bump ]).user() ) {