63 #include <basic/Tracer.hh>
66 #include <utility/exit.hh>
67 #include <utility/file/file_sys_util.hh>
68 #include <utility/file/FileName.hh>
69 #include <utility/io/izstream.hh>
70 #include <utility/tools/make_map.hh>
71 #include <utility/tools/make_vector1.hh>
72 #include <utility/string_util.hh>
73 #include <utility/vector1.hh>
74 #include <utility/vector0.hh>
78 #include <numeric/xyzVector.hh>
86 #include <basic/options/option.hh>
87 #include <basic/options/keys/dna.OptionKeys.gen.hh>
88 #include <basic/options/keys/motifs.OptionKeys.gen.hh>
95 static basic::Tracer
mu_tr(
"protocols.motifs.motif_utils", basic::t_info );
111 retval->store_remark( this_remark );
112 retval->store_path( this_path );
119 utility::io::izstream & motif_info
129 char first_line[max_line_len];
130 motif_info.getline( first_line,
sizeof(first_line) );
131 std::istringstream line_in( first_line );
142 char rest_of_line[max_line_len];
143 line_in.getline( rest_of_line,
sizeof(rest_of_line) );
145 std::string::size_type index( rest.find(
"REMARK ") );
147 bool has_remark(
false );
148 if( index != std::string::npos ) {
149 this_remark = rest.substr( index + 7 );
158 motif_info >> motif_jump;
160 SingleMotifOP retval =
new SingleMotif( res1, r1atom1, r1atom2, r1atom3, res2, r2atom1, r2atom2, r2atom3, motif_jump );
162 retval->store_remark( this_remark );
170 std::istream & motif_info
180 char first_line[max_line_len];
181 motif_info.getline( first_line,
sizeof(first_line) );
182 std::istringstream line_in( first_line );
193 char rest_of_line[max_line_len];
194 line_in.getline( rest_of_line,
sizeof(rest_of_line) );
197 std::string::size_type index( rest.find(
"REMARK ") );
199 bool has_remark(
false );
200 if( index != std::string::npos ) {
201 this_remark = rest.substr( index + 7 );
212 motif_info >> motif_jump;
214 SingleMotifOP retval =
new SingleMotif( res1, r1atom1, r1atom2, r1atom3, res2, r2atom1, r2atom2, r2atom3, motif_jump );
216 retval->store_remark( this_remark );
224 std::istream & motif_info
234 char first_line[max_line_len];
235 motif_info.getline( first_line,
sizeof(first_line) );
236 std::istringstream line_in( first_line );
247 char rest_of_line[max_line_len];
248 line_in.getline( rest_of_line,
sizeof(rest_of_line) );
250 std::string::size_type index( rest.find(
"REMARK ") );
252 bool has_remark(
false );
253 if( index != std::string::npos ) {
254 this_remark = rest.substr( index + 7 );
258 motif_info >> motif_jump;
261 retval->store_remark( this_remark );
290 retval += r1.
xyz(
"N" ).distance_squared( r2.
xyz(
"N" ) );
291 retval += r1.
xyz(
"CA" ).distance_squared( r2.
xyz(
"CA" ) );
292 retval += r1.
xyz(
"C" ).distance_squared( r2.
xyz(
"C" ) );
298 retval += r1.
xyz( index1 ).distance_squared( r2.
xyz( index2 ) );
300 retval += r1.
xyz(
"CB" ).distance_squared( r2.
xyz(
"CB" ) );
303 retval = std::sqrt( 0.25 * retval );
316 using namespace core::scoring::constraints;
320 inv_rotamer.
xyz(
"CA" ),
325 inv_rotamer.
xyz(
"C" ),
330 inv_rotamer.
xyz(
"N" ),
342 inv_rotamer.
xyz( index2 ),
347 inv_rotamer.
xyz(
"CB" ),
361 bool const is_it_forward
364 using namespace core::scoring::constraints;
367 ( is_it_forward ? this_motif->res2_atom1_name() : this_motif->res1_atom1_name() )
371 ( is_it_forward ? this_motif->res2_atom2_name() : this_motif->res1_atom2_name() )
375 ( is_it_forward ? this_motif->res2_atom3_name() : this_motif->res1_atom3_name() )
383 first_protein_resi = i;
390 inv_rotamer.
xyz( index1 ),
395 inv_rotamer.
xyz( index2 ),
400 inv_rotamer.
xyz( index3 ),
426 alanize_task->nonconst_residue_task( ires ).restrict_absent_canonical_aas( allow_vector );
429 alanize_task->temporarily_set_pack_residue( ires,
false );
433 alanize_task->temporarily_set_pack_residue( ires,
false );
445 using namespace basic::options;
447 if ( option[ OptionKeys::motifs::list_motifs ].user() ) {
453 }
else if ( option[ OptionKeys::motifs::motif_filename ].user() ) {
454 std::string motif_filename( option[ OptionKeys::motifs::motif_filename ]() );
461 mu_tr <<
"User did not provide input motifs via cmd line, but could be coming in as BuildPosition specific data" << std::endl;
470 using namespace basic::options;
472 if ( option[ OptionKeys::motifs::list_motifs ].user() ) {
474 mu_tr <<
"In get_LigandMotifLibrary, it's working" << std::endl;
476 mu_tr <<
"" << std::endl;
478 mu_tr <<
"" << std::endl;
481 }
else if ( option[ OptionKeys::motifs::motif_filename ].user() ) {
482 std::string motif_filename( option[ OptionKeys::motifs::motif_filename ]() );
483 mu_tr <<
"Got filename" << std::endl;
485 mu_tr <<
"Made motiflibrary" << std::endl;
487 mu_tr <<
"added motifs from file" << std::endl;
493 mu_tr <<
"User did not provide input motifs via cmd line, but could be coming in as BuildPosition specific data" << std::endl;
502 using namespace basic::options;
508 if ( option[ OptionKeys::motifs::list_dnaconformers ].user() ) {
518 if ( pose->total_residue() > 1 ) {
519 std::cerr <<
"WARNING!!! Conformer PDB contains more than one residue, loading all residues in PDB as conformers." << std::endl;
521 for (
core::Size i(1); i <= pose->total_residue(); ++i ) {
522 conformerOPs.push_back( pose->residue(i).clone() );
530 std::map< std::string, utility::vector1< core::conformation::ResidueOP > >
const
535 using namespace core::conformation;
536 std::map< std::string, ResidueOPs > conformer_map;
537 for ( ResidueOPs::const_iterator itr = conformerOPs.begin(), end_itr = conformerOPs.end();
538 itr != end_itr; ++itr ) {
540 conformer_map[name].push_back( *itr );
542 return conformer_map;
554 using namespace basic::options;
555 using namespace protocols::dna;
557 if ( option[ OptionKeys::motifs::target_dna_defs ].user() &&
558 option[ OptionKeys::dna::design::dna_defs ].user() ) {
573 target_positions =
defs2vector( pose, targeted_dna );
574 }
else if ( option[ OptionKeys::dna::design::dna_defs ].user() ) {
578 target_positions =
defs2vector( pose, mutated_dna );
579 }
else if ( option[ OptionKeys::motifs::target_dna_defs ].user() ) {
581 mu_tr <<
"DNA is not being mutated, but alternative bases are allowed, so mutation may occur at a later point, use dna::dna_defs to input positions to mutate in the straightforward manner." << std::endl;
584 target_positions =
defs2vector( pose, targeted_dna );
586 mu_tr <<
"No input given for DNA target positions, will identify target positions based on input motif building positions." << std::endl;
588 return target_positions;
597 std::map< core::Size, std::set< std::string > >
602 using namespace basic::options;
603 using namespace protocols::dna;
605 std::map< core::Size, std::set< std::string > > target_positions;
606 if ( option[ OptionKeys::motifs::target_dna_defs ].user() &&
607 option[ OptionKeys::dna::design::dna_defs ].user() ) {
615 target_positions =
defs2map( pose, targeted_dna );
616 }
else if ( option[ OptionKeys::dna::design::dna_defs ].user() ) {
621 target_positions =
defs2map( pose, mutated_dna );
622 }
else if ( option[ OptionKeys::motifs::target_dna_defs ].user() ) {
624 mu_tr <<
"DNA is not being mutated, but alternative bases are allowed, so mutation may occur at a later point, use dna::dna_defs to input positions to mutate in the straightforward manner." << std::endl;
628 target_positions =
defs2map( pose, targeted_dna );
630 mu_tr <<
"No input given for DNA target positions, will identify target positions based on input motif building positions." << std::endl;
632 return target_positions;
640 using namespace basic::options;
641 using namespace protocols::dna;
642 if ( option[ OptionKeys::motifs::target_dna_defs ].user() &&
643 option[ OptionKeys::dna::design::dna_defs ].user() ) {
650 }
else if ( option[ OptionKeys::dna::design::dna_defs ].user() ) {
654 }
else if ( option[ OptionKeys::motifs::target_dna_defs ].user() ) {
656 mu_tr <<
"DNA is not being mutated, but alternative bases are allowed, so mutation may occur at a later point, use dna::dna_defs to input positions to mutate in the straightforward manner." << std::endl;
660 mu_tr <<
"No input given for DNA target positions, will identify target positions based on input motif building positions." << std::endl;
670 using namespace protocols::dna;
673 for ( DnaDesignDefOPs::const_iterator def( target.begin() );
674 def != target.end(); ++def ) {
676 core::Size index( pdb_pose_map.find( (*def)->chain, (*def)->pdbpos ) );
677 if ( ! (*def)->name3.empty() ) {
689 mu_tr <<
"DNA was not mutated because input Def did not include a type!" << std::endl;
701 using namespace protocols::dna;
704 for ( DnaDesignDefOPs::const_iterator def( targets.begin() );
705 def != targets.end(); ++def ) {
706 core::Size index( pdb_pose_map.find( (*def)->chain, (*def)->pdbpos ) );
707 positions.push_back( index );
718 using namespace protocols::dna;
721 for ( DnaDesignDefOPs::const_iterator def( targets.begin() );
722 def != targets.end(); ++def ) {
723 core::Size index( pdb_pose_map.find( (*def)->chain, (*def)->pdbpos ) );
727 if ( name.length() > 1 ) {
728 positions.push_back( std::make_pair( index, names ) );
729 }
else if ( name.length() == 1 ) {
731 std::map < std::string, utility::vector1< std::string > > degeneracycodes(
732 utility::tools::make_map(
735 names = degeneracycodes[name];
736 positions.push_back( std::make_pair( index, names ) );
738 mu_tr <<
"All target positions will remain wild-type." << std::endl;
745 std::map< core::Size, std::set< std::string > >
751 using namespace protocols::dna;
753 std::map< core::Size, std::set< std::string > > positions;
754 for ( DnaDesignDefOPs::const_iterator def( targets.begin() );
755 def != targets.end(); ++def ) {
756 core::Size index( pdb_pose_map.find( (*def)->chain, (*def)->pdbpos ) );
757 std::set< std::string > names;
759 if ( name.length() > 1 ) {
761 names.insert( name );
762 }
else if ( name.length() == 1 ) {
765 std::map < std::string, utility::vector1< std::string > > degeneracycodes(
766 utility::tools::make_map(
771 mu_tr <<
"All target positions will remain wild-type." << std::endl;
773 positions[index] = names;
778 std::map< core::Size, std::set< std::string > >
784 using namespace protocols::dna;
786 std::map< core::Size, std::set< std::string > > positions;
787 for ( DnaDesignDefOPs::const_iterator def( targets.begin() );
788 def != targets.end(); ++def ) {
789 core::Size index( pdb_pose_map.find( (*def)->chain, (*def)->pdbpos ) );
790 std::set< std::string > names;
793 mu_tr <<
"Allowing AAtype " << name[
c] <<
" for motif search." << std::endl;
795 std::stringstream name1;
797 if ( name1.str() ==
"X" ) {
798 utility::vector1< std::string > allAA(utility::tools::make_vector1(
std::string(
"A"),
std::string(
"C"),
std::string(
"D"),
std::string(
"E"),
std::string(
"F"),
std::string(
"H"),
std::string(
"I"),
std::string(
"K"),
std::string(
"L"),
std::string(
"M"),
std::string(
"N"),
std::string(
"P"),
std::string(
"Q"),
std::string(
"R"),
std::string(
"S"),
std::string(
"T"),
std::string(
"V"),
std::string(
"W"),
std::string(
"Y") ) );
799 for(
core::Size x(1); x <= allAA.size(); ++x ) {
804 names.insert( name3 );
805 if (name3 ==
"GLY") {
806 mu_tr <<
"There are no such thing as glycine motifs, check your build_position_defs and remove G" << std::endl;
811 positions[index] = names;
821 std::map< std::string, std::string > name3_name1( utility::tools::make_map(
843 return name3_name1[ oneletter ];
851 using namespace basic::options;
852 using namespace protocols::dna;
854 if ( option[ OptionKeys::motifs::motif_build_defs ].user() ) {
858 motif_build_positions =
defs2vector( pose, build_positions );
860 mu_tr <<
"No build positions specified by user input, will identify build positions based on proximity to target positions" << std::endl;
862 return motif_build_positions;
868 using namespace basic::options;
870 using namespace protocols::dna;
871 if ( option[ OptionKeys::motifs::motif_build_defs ].user() ) {
875 motif_build_positions = build_positions;
877 mu_tr <<
"No build positions specified by user input, will identify build positions based on proximity to target positions" << std::endl;
879 return motif_build_positions;
892 bool keep_one_motif(
true );
893 std::map< std::string, SingleMotifOP > single_motifs;
894 utility::io::izstream data_file( filename.c_str() );
897 if( key_in ==
"POSITION" ) {
898 while( data_file >> key_in ) {
899 std::stringstream bpseqpos;
901 if( key_in == bpseqpos.str() ) {
903 while( data_file >> key2_in ) {
904 if( key2_in ==
"POSITION" ) {
906 data_file >> key3_in;
908 }
else if( key2_in ==
"SINGLE" ) {
910 if( ! keep_one_motif ) {
913 single_motifs[ new_motif->remark() ] = new_motif;
915 }
else if( key2_in ==
"RESIDUE" ) {
919 rsd->seqpos( bp.
seqpos() );
932 if( keep_one_motif ) {
933 for( std::map< std::string, SingleMotifOP >::iterator mot( single_motifs.begin() ),
934 end( single_motifs.end()); mot !=
end; ++mot ) {
939 mu_tr <<
"This file doesn't have any positions in it" << std::endl;
950 bool keep_one_motif(
true );
951 std::map< std::string, SingleMotifOP > single_motifs;
952 utility::io::izstream data_file( filename.c_str() );
956 if( key_in ==
"POSITION" ) {
957 while( data_file >> key_in ) {
961 std::stringstream bpseqpos;
963 if( key_in == bpseqpos.str() ) {
967 while( data_file >> key2_in ) {
969 if( key2_in ==
"POSITION" ) {
971 data_file >> key3_in;
974 }
else if( key2_in ==
"SINGLE" ) {
976 if( ! keep_one_motif ) {
979 single_motifs[ new_motif->remark() ] = new_motif;
981 }
else if( key2_in ==
"RESIDUE" ) {
985 rsd->seqpos( bp.
seqpos() );
999 if( keep_one_motif ) {
1000 for( std::map< std::string, SingleMotifOP >::iterator mot( single_motifs.begin() ),
1001 end( single_motifs.end()); mot !=
end; ++mot ) {
1006 mu_tr <<
"This file doesn't have any positions in it" << std::endl;
1018 utility::io::izstream list( (*filename).name().c_str() );
1022 names.push_back( name );
1031 utility::io::izstream & residue_info
1035 residue_info >> resname;
1038 getline( residue_info, firstline );
1044 residue_info >> atomname;
1051 if( atomname == atomname2 ) {
1052 residue_info >> skip;
1062 core::Vector atomxyz( utility::string2float(x), utility::string2float(y), utility::string2float(z) );
1065 rsd->set_xyz( atomname2, atomxyz );
1089 using namespace core::chemical;
1090 using namespace core::conformation;
1091 using namespace core::scoring::dna;
1096 for (
int r=1; r<= 2; ++r ) {
1097 core::Size const pos( r == 1 ? seqpos : partner[seqpos] );
1098 if ( pos == 0 )
continue;
1102 assert( existing_residue.is_DNA() );
1106 (
ResidueSelector().set_aa( aa ).match_variants( existing_residue.type() ).select( residue_set ) );
1107 if ( rsd_types.size() != 1 ) {
1108 utility_exit_with_message(
"couldnt find residuetype for basepair mutation!");
1112 rsd->set_chi( 1, existing_residue.chi(1) );
1125 using namespace core;
1126 using namespace core::chemical;
1127 using namespace core::conformation;
1135 for(
core::Size j = 1; j <= atoms.size(); ++j ) {
1137 sum2 += diff.length_squared();
1140 core::Real const curr_rms = std::sqrt(sum2 / natoms);
1143 if( curr_rms < best_rms ) {
1144 best_rms = curr_rms;
1156 using namespace core;
1157 using namespace core::chemical;
1158 using namespace core::conformation;
1166 for(
core::Size j = 1; j <= atoms.size(); ++j ) {
1168 sum2 += diff.length_squared();
1171 core::Real const curr_rms = std::sqrt(sum2 / natoms);
1174 if( curr_rms < best_rms ) {
1175 best_rms = curr_rms;
1188 using namespace core::pack::rotamer_set;
1189 using namespace core::chemical;
1190 using namespace core::scoring;
1191 using namespace core::pack;
1192 using namespace core::pack::task;
1196 rotset->set_resid( rotamer_build_position );
1201 scorefxn.set_weight(
fa_rep, 1.00 );
1204 task->set_bump_check( bump_check );
1205 task->temporarily_fix_everything();
1206 task->temporarily_set_pack_residue( rotamer_build_position,
true );
1208 task->nonconst_residue_task( rotamer_build_position ).restrict_absent_canonical_aas( aa_info );
1214 if( ex_ > 0 ) task->nonconst_residue_task( rotamer_build_position ).or_ex1(
true );
1215 if( ex_ > 1 ) task->nonconst_residue_task( rotamer_build_position ).or_ex2(
true );
1216 if( ex_ > 2 ) task->nonconst_residue_task( rotamer_build_position ).or_ex3(
true );
1217 if( ex_ > 3 ) task->nonconst_residue_task( rotamer_build_position ).or_ex4(
true );
1226 rotset->build_rotamers( pose, scorefxn, *task, packer_neighbor_graph,
false );