15 #include <core/types.hh>
17 #include <core/conformation/Conformation.hh>
18 #include <core/pose/Pose.hh>
19 #include <core/pose/PDBInfo.hh>
20 #include <core/scoring/ScoreFunction.hh>
21 #include <core/import_pose/import_pose.hh>
22 #include <core/io/pdb/pose_io.hh>
26 #include <basic/options/keys/in.OptionKeys.gen.hh>
27 #include <basic/options/keys/out.OptionKeys.gen.hh>
28 #include <basic/options/keys/motifs.OptionKeys.gen.hh>
33 #include <protocols/motifs/Motif.hh>
34 #include <protocols/motifs/SingleMotif.hh>
35 #include <protocols/motifs/MotifLibrary.hh>
43 #include <protocols/jd2/JobDistributor.hh>
50 using namespace chemical;
51 using namespace scoring;
52 using namespace ObjexxFCL;
54 using namespace basic::options::OptionKeys;
72 core::chemical::AA
const & aa,
175 TR <<
"Did not find residue type for " << name_from_aa( aa ) << std::endl;
187 AA
const & target_aa,
188 std::string & pdb_name,
190 std::vector< Size > & contacts
198 std::string atom1_name;
199 std::string atom2_name;
200 std::string atom3_name;
203 pose.append_residue_by_jump( src_pose.residue( prot_pos ), 1 );
204 for (
Size ic = 0 ; ic < contacts.size() ; ++ic ) {
205 Size dna_pos = contacts[ ic ];
206 pose.append_residue_by_jump( src_pose.residue( dna_pos ), 1 );
208 pose.conformation().insert_chain_ending( 1 );
213 centered_pose =
pose;
216 centered_pose.set_xyz( id::AtomID( centered_pose.residue( 1 ).atom_index( atom1_name ), 1 ),
atom1_vector );
217 centered_pose.set_xyz( id::AtomID( centered_pose.residue( 1 ).atom_index( atom2_name ), 1 ),
atom2_vector );
218 centered_pose.set_xyz( id::AtomID( centered_pose.residue( 1 ).atom_index( atom3_name ), 1 ),
atom3_vector );
222 core::kinematics::Stub end_stub(
223 centered_pose.residue( 1 ).atom( atom2_name ).xyz(),
224 centered_pose.residue( 1 ).atom( atom1_name ).xyz(),
225 centered_pose.residue( 1 ).atom( atom2_name ).xyz(),
226 centered_pose.residue( 1 ).atom( atom3_name ).xyz()
229 core::kinematics::Stub start_stub(
230 pose.residue( 1 ).atom( atom2_name ).xyz(),
231 pose.residue( 1 ).atom( atom1_name ).xyz(),
232 pose.residue( 1 ).atom( atom2_name ).xyz(),
233 pose.residue( 1 ).atom( atom3_name ).xyz()
236 for (
Size ires = 1 ; ires <= pose.total_residue() ; ++ires ) {
237 for (
Size iatom = 1 ; iatom <= pose.residue(ires).natoms() ; ++iatom ) {
238 pose.set_xyz( id::AtomID( iatom, ires ),
239 end_stub.local2global( start_stub.global2local( pose.residue(ires).xyz( iatom ) ) ) );
244 std::string delimiter(
"_" );
246 std::string motif_file_name( output_path + src_pose.residue_type( prot_pos ).name3() +
247 string_of( src_pose.pdb_info()->number( prot_pos ) ) +
248 string_of( src_pose.pdb_info()->chain( prot_pos ) ) + delimiter );
250 for (
Size ic = 0 ; ic < contacts.size() ; ++ic ) {
251 Size dna_pos = contacts[ ic ];
252 motif_file_name = motif_file_name +
253 src_pose.residue_type( dna_pos ).name1() +
254 string_of( src_pose.pdb_info()->number( dna_pos ) ) +
255 string_of( src_pose.pdb_info()->chain( dna_pos ) ) + delimiter;
259 motif_file_name = motif_file_name + pdb_name;
261 TR <<
"Writing " << motif_file_name << std::endl;
262 io::pdb::dump_pdb( pose, motif_file_name );
269 protocols::motifs::Motif
const & m1,
270 protocols::motifs::Motif
const & m2,
278 if ( m1.restype_name1() != m2.restype_name1() ||
279 m1.restype_name2() != m2.restype_name2() ) {
280 dist_diff = angl_diff = 9999.0;
284 core::kinematics::jump_distance( m1.forward_jump(), m2.forward_jump(), dist_diff, angl_diff );
305 sf.eval_ci_2b_sc_sc( pose.residue( pos1 ), pose.residue( pos2 ),
pose, pack_map );
307 return pack_map[ fa_atr ] + pack_map[ fa_rep ];
321 sf.eval_cd_2b_sc_sc( pose.residue( pos1 ), pose.residue( pos2 ),
pose, hbond_map );
323 return hbond_map[ hbond_sc ];
337 sf.eval_cd_2b_sc_sc( pose.residue( pos1 ), pose.residue( pos2 ),
pose, elec_map );
339 return elec_map[ fa_elec ];
350 std::string & pdb_name,
351 chemical::AA
const target_aa,
352 protocols::motifs::MotifLibrary & motif_lib
355 int nres( pose.total_residue() );
357 Real dist_threshold(
option[ motifs::duplicate_dist_cutoff ] );
358 Real angl_threshold(
option[ motifs::duplicate_angle_cutoff ] );
360 Real pack_min_threshold(
option[ motifs::pack_min_threshold ] );
361 Real pack_max_threshold(
option[ motifs::pack_max_threshold ] );
362 Real hbond_min_threshold(
option[ motifs::hbond_min_threshold ] );
363 Real hbond_max_threshold(
option[ motifs::hbond_max_threshold ] );
364 Real elec_min_threshold(
option[ motifs::elec_min_threshold ] );
365 Real elec_max_threshold(
option[ motifs::elec_max_threshold ] );
373 scorefxn.set_weight( fa_atr, 0.8 );
374 scorefxn.set_weight( fa_rep, 0.44 );
375 scorefxn.set_weight( hbond_sc, 1.1 );
376 scorefxn.set_weight( fa_elec, 0.7 );
377 scorefxn.setup_for_scoring( pose );
380 std::string atom1_name;
381 std::string atom2_name;
382 std::string atom3_name;
386 for (
int aaoi_pos = 1 ; aaoi_pos <=
nres ; ++aaoi_pos ) {
387 ResidueType
const & res_type( pose.residue_type( aaoi_pos ) );
389 if ( res_type.aa() != target_aa )
continue;
391 std::vector< Size > contacts;
393 Real total_pack_score( 0.0 );
394 Real total_hb_score( 0.0 );
395 Real check_hb_score( 0.0 );
398 for (
int other_pos = 1 ; other_pos <=
nres ; ++other_pos ) {
399 ResidueType
const & other_type( pose.residue_type( other_pos ) );
400 if ( other_pos == aaoi_pos )
continue;
403 if ( ( other_type.aa() == target_aa ) && ( other_pos < aaoi_pos ) )
continue;
409 int num_contacts( 0 );
412 for (
Size this_atom = 1 ; this_atom <= res_type.nheavyatoms() ; ++this_atom ) {
414 for (
Size other_atom = other_type.first_sidechain_atom() ;
415 other_atom <= other_type.nheavyatoms() ; ++other_atom ) {
417 Real const dis2( pose.residue( other_pos ).xyz( other_atom ).distance_squared(
418 pose.residue( aaoi_pos ).xyz( this_atom ) ) );
419 if ( dis2 < (3.9*3.9) ) {
426 check_hb_score += hb_score;
433 if ( ( pack_score > pack_min_threshold && pack_score < pack_max_threshold) &&
434 ( hb_score > hbond_min_threshold && hb_score < hbond_max_threshold) &&
435 ( elec_score > elec_min_threshold && elec_score < elec_max_threshold) ) {
437 TR <<
"Energies between " << aaoi_pos <<
" and " << other_pos <<
" are pack: " << pack_score <<
" hbond: " << hb_score << std::endl;
439 total_pack_score += pack_score;
440 total_hb_score += hb_score;
443 std::string other_atom1;
444 std::string other_atom2;
445 std::string other_atom3;
446 fetch_atom_names( pose.aa( other_pos ), other_atom1, other_atom2, other_atom3 );
447 if ( other_atom1 !=
"X" ) {
448 contacts.push_back( other_pos );
449 protocols::motifs::SingleMotif new_motif( pose, aaoi_pos, atom1_name, atom2_name, atom3_name, other_pos, other_atom1, other_atom2, other_atom3 );
450 std::string motif_origin( pose.residue_type( aaoi_pos ).name3() +
" " +
string_of( pose.pdb_info()->number( aaoi_pos ) ) +
string_of( pose.pdb_info()->chain( aaoi_pos ) ) +
" and " + pose.residue_type( other_pos ).name3() +
" " +
string_of( pose.pdb_info()->number( other_pos ) ) +
string_of( pose.pdb_info()->chain( other_pos ) ) +
" pdb code: " + pdb_name );
451 new_motif.store_remark( motif_origin );
452 TR << new_motif.remark() << std::endl;
454 protocols::motifs::Motif work_motif( new_motif );
456 bool unique_motif(
true );
466 if ( dist_diff < dist_threshold && angl_diff < angl_threshold ) {
467 unique_motif =
false;
472 if ( unique_motif ) {
473 motif_lib.add_to_library( new_motif );
480 if ( contacts.size() > 0 ) {
481 TR <<
"Outputing motif with " << contacts.size() <<
" contacts " << std::endl;
482 TR <<
"Energies are pack: " << total_pack_score <<
" hbond: " << total_hb_score << std::endl;
483 TR <<
"Check HB Energy is: " << check_hb_score << std::endl;
499 main(
int argc,
char * argv [] )
502 using namespace pose;
503 using namespace conformation;
504 using namespace chemical;
505 using namespace import_pose;
511 std::string
const list_of_pdb_files(
option[ in::file::l ]()[1] );
512 std::ifstream file_data( list_of_pdb_files.c_str() );
515 std::string target_3code(
option[ motifs::target_aa ]() );
516 chemical::AA target_aa( aa_from_name(
uppercase( target_3code ) ) );
518 std::string pdb_code;
520 protocols::motifs::MotifLibrary motif_lib;
523 std::string motif_path_and_file( output_path +
"motif_library" );
524 std::ofstream motif_ostream( motif_path_and_file.c_str() );
526 file_data >> pdb_code;
527 while ( !file_data.eof() ) {
529 TR <<
"Working on pdb " << pdb_code << std::endl;
531 std::string pdb_file( pdb_file_path + pdb_code );
532 TR <<
"PDB file " << pdb_file << std::endl;
535 pose_from_pdb( pose, pdb_file );
539 file_data >> pdb_code;
542 motif_ostream << motif_lib;
543 motif_ostream.close();
547 std::cout <<
"caught exception" << e.
msg() << std::endl;
virtual std::string const msg() const
utility::keys::KeyLookup< KeyType >::const_iterator const_iterator
Key collection iterators.
void init(int argc, char *argv[])
Command line init() version.
common derived classes for thrown exceptions
rule< Scanner, options_closure::context_t > options
ocstream cout(std::cout)
Wrapper around std::cout.
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for ...
std::string string_of(Fstring const &s)
string of an Fstring
Program options global and initialization function.
char & uppercase(char &c)
Uppercase a Character.
rule< Scanner, option_closure::context_t > option