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/pdb_writer.hh>
32 #include <protocols/motifs/Motif.hh>
33 #include <protocols/motifs/SingleMotif.hh>
34 #include <protocols/motifs/MotifLibrary.hh>
42 #include <protocols/jd2/JobDistributor.hh>
51 using namespace ObjexxFCL;
53 using namespace basic::options::OptionKeys;
71 core::chemical::AA
const &
aa,
174 TR <<
"Did not find residue type for " << name_from_aa( aa ) << std::endl;
187 std::string & pdb_name,
197 std::string atom1_name;
198 std::string atom2_name;
199 std::string atom3_name;
202 pose.append_residue_by_jump( src_pose.residue( prot_pos ), 1 );
203 for (
Size ic = 0 ; ic < contacts.size() ; ++ic ) {
204 Size dna_pos = contacts[ ic ];
205 pose.append_residue_by_jump( src_pose.residue( dna_pos ), 1 );
207 pose.conformation().insert_chain_ending( 1 );
212 centered_pose =
pose;
215 centered_pose.set_xyz( id::AtomID( centered_pose.residue( 1 ).atom_index( atom1_name ), 1 ),
atom1_vector );
216 centered_pose.set_xyz( id::AtomID( centered_pose.residue( 1 ).atom_index( atom2_name ), 1 ),
atom2_vector );
217 centered_pose.set_xyz( id::AtomID( centered_pose.residue( 1 ).atom_index( atom3_name ), 1 ),
atom3_vector );
221 core::kinematics::Stub end_stub(
222 centered_pose.residue( 1 ).atom( atom2_name ).xyz(),
223 centered_pose.residue( 1 ).atom( atom1_name ).xyz(),
224 centered_pose.residue( 1 ).atom( atom2_name ).xyz(),
225 centered_pose.residue( 1 ).atom( atom3_name ).xyz()
228 core::kinematics::Stub start_stub(
229 pose.residue( 1 ).atom( atom2_name ).xyz(),
230 pose.residue( 1 ).atom( atom1_name ).xyz(),
231 pose.residue( 1 ).atom( atom2_name ).xyz(),
232 pose.residue( 1 ).atom( atom3_name ).xyz()
235 for (
Size ires = 1 ; ires <= pose.total_residue() ; ++ires ) {
236 for (
Size iatom = 1 ; iatom <= pose.residue(ires).natoms() ; ++iatom ) {
237 pose.set_xyz( id::AtomID( iatom, ires ),
238 end_stub.local2global( start_stub.global2local( pose.residue(ires).xyz( iatom ) ) ) );
243 std::string delimiter(
"_" );
245 std::string motif_file_name( output_path + src_pose.residue_type( prot_pos ).name3() +
246 string_of( src_pose.pdb_info()->number( prot_pos ) ) +
247 string_of( src_pose.pdb_info()->chain( prot_pos ) ) + delimiter );
249 for (
Size ic = 0 ; ic < contacts.size() ; ++ic ) {
250 Size dna_pos = contacts[ ic ];
251 motif_file_name = motif_file_name +
252 src_pose.residue_type( dna_pos ).name1() +
253 string_of( src_pose.pdb_info()->number( dna_pos ) ) +
254 string_of( src_pose.pdb_info()->chain( dna_pos ) ) + delimiter;
258 motif_file_name = motif_file_name + pdb_name;
260 TR <<
"Writing " << motif_file_name << std::endl;
268 protocols::motifs::Motif
const & m1,
269 protocols::motifs::Motif
const & m2,
277 if ( m1.restype_name1() != m2.restype_name1() ||
278 m1.restype_name2() != m2.restype_name2() ) {
279 dist_diff = angl_diff = 9999.0;
283 core::kinematics::jump_distance( m1.forward_jump(), m2.forward_jump(), dist_diff, angl_diff );
304 sf.eval_ci_2b_sc_sc( pose.residue( pos1 ), pose.residue( pos2 ),
pose, pack_map );
306 return pack_map[ fa_atr ] + pack_map[ fa_rep ];
320 sf.eval_cd_2b_sc_sc( pose.residue( pos1 ), pose.residue( pos2 ),
pose, hbond_map );
322 return hbond_map[ hbond_sc ];
336 sf.eval_cd_2b_sc_sc( pose.residue( pos1 ), pose.residue( pos2 ),
pose, elec_map );
338 return elec_map[ fa_elec ];
349 std::string & pdb_name,
351 protocols::motifs::MotifLibrary & motif_lib
354 int nres( pose.total_residue() );
372 scorefxn.set_weight( fa_atr, 0.8 );
373 scorefxn.set_weight( fa_rep, 0.44 );
374 scorefxn.set_weight( hbond_sc, 1.1 );
375 scorefxn.set_weight( fa_elec, 0.7 );
376 scorefxn.setup_for_scoring( pose );
379 std::string atom1_name;
380 std::string atom2_name;
381 std::string atom3_name;
385 for (
int aaoi_pos = 1 ; aaoi_pos <=
nres ; ++aaoi_pos ) {
386 ResidueType
const & res_type( pose.residue_type( aaoi_pos ) );
388 if ( res_type.aa() !=
target_aa )
continue;
392 Real total_pack_score( 0.0 );
393 Real total_hb_score( 0.0 );
394 Real check_hb_score( 0.0 );
397 for (
int other_pos = 1 ; other_pos <=
nres ; ++other_pos ) {
398 ResidueType
const & other_type( pose.residue_type( other_pos ) );
399 if ( other_pos == aaoi_pos )
continue;
402 if ( ( other_type.aa() ==
target_aa ) && ( other_pos < aaoi_pos ) )
continue;
408 int num_contacts( 0 );
411 for (
Size this_atom = 1 ; this_atom <= res_type.nheavyatoms() ; ++this_atom ) {
413 for (
Size other_atom = other_type.first_sidechain_atom() ;
414 other_atom <= other_type.nheavyatoms() ; ++other_atom ) {
416 Real const dis2( pose.residue( other_pos ).xyz( other_atom ).distance_squared(
417 pose.residue( aaoi_pos ).xyz( this_atom ) ) );
418 if ( dis2 < (3.9*3.9) ) {
425 check_hb_score += hb_score;
432 if ( ( pack_score > pack_min_threshold && pack_score < pack_max_threshold) &&
433 ( hb_score > hbond_min_threshold && hb_score < hbond_max_threshold) &&
434 ( elec_score > elec_min_threshold && elec_score < elec_max_threshold) ) {
436 TR <<
"Energies between " << aaoi_pos <<
" and " << other_pos <<
" are pack: " << pack_score <<
" hbond: " << hb_score << std::endl;
438 total_pack_score += pack_score;
439 total_hb_score += hb_score;
442 std::string other_atom1;
443 std::string other_atom2;
444 std::string other_atom3;
445 fetch_atom_names( pose.aa( other_pos ), other_atom1, other_atom2, other_atom3 );
446 if ( other_atom1 !=
"X" ) {
447 contacts.push_back( other_pos );
448 protocols::motifs::SingleMotif new_motif( pose, aaoi_pos, atom1_name, atom2_name, atom3_name, other_pos, other_atom1, other_atom2, other_atom3 );
449 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 );
450 new_motif.store_remark( motif_origin );
451 TR << new_motif.remark() << std::endl;
453 protocols::motifs::Motif work_motif( new_motif );
455 bool unique_motif(
true );
465 if ( dist_diff < dist_threshold && angl_diff < angl_threshold ) {
466 unique_motif =
false;
471 if ( unique_motif ) {
472 motif_lib.add_to_library( new_motif );
479 if ( contacts.size() > 0 ) {
480 TR <<
"Outputing motif with " << contacts.size() <<
" contacts " << std::endl;
481 TR <<
"Energies are pack: " << total_pack_score <<
" hbond: " << total_hb_score << std::endl;
482 TR <<
"Check HB Energy is: " << check_hb_score << std::endl;
498 main(
int argc,
char * argv [] )
501 using namespace pose;
502 using namespace conformation;
504 using namespace import_pose;
511 std::ifstream file_data( list_of_pdb_files.c_str() );
517 std::string pdb_code;
519 protocols::motifs::MotifLibrary motif_lib;
522 std::string motif_path_and_file( output_path +
"motif_library" );
523 std::ofstream motif_ostream( motif_path_and_file.c_str() );
525 file_data >> pdb_code;
526 while ( !file_data.eof() ) {
528 TR <<
"Working on pdb " << pdb_code << std::endl;
530 std::string pdb_file( pdb_file_path + pdb_code );
531 TR <<
"PDB file " << pdb_file << std::endl;
534 pose_from_file( pose, pdb_file , core::import_pose::PDB_file);
538 file_data >> pdb_code;
541 motif_ostream << motif_lib;
542 motif_ostream.close();
546 std::cout <<
"caught exception" << e.
msg() << std::endl;
RealOptionKey const duplicate_angle_cutoff("motifs:duplicate_angle_cutoff")
RealOptionKey const pack_min_threshold("motifs:pack_min_threshold")
virtual std::string const msg() const
RealOptionKey const elec_max_threshold("motifs:elec_max_threshold")
RealOptionKey const pack_max_threshold
RealOptionKey const elec_min_threshold
utility::keys::KeyLookup< KeyType >::const_iterator const_iterator
Key collection iterators.
RealOptionKey const pack_max_threshold("motifs:pack_max_threshold")
StringOptionKey const target_aa
BooleanOptionKey const scoring
RealOptionKey const duplicate_dist_cutoff("motifs:duplicate_dist_cutoff")
void init(int argc, char *argv[])
Command line init() version.
BooleanOptionKey const dump_pdb
FileVectorOptionKey const l("in:file:l")
StringOptionKey const target_aa("motifs:target_aa")
PathOptionKey const pdb("out:path:pdb")
common derived classes for thrown exceptions
RealOptionKey const hbond_max_threshold
RealOptionKey const hbond_min_threshold
RealOptionKey const hbond_max_threshold("motifs:hbond_max_threshold")
PathVectorOptionKey const pdb("in:path:pdb")
RealOptionKey const pack_min_threshold
RealOptionKey const elec_min_threshold("motifs:elec_min_threshold")
basic::options::OptionKeys collection
rule< Scanner, options_closure::context_t > options
BooleanOptionKey const aa
RealOptionKey const elec_max_threshold
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 ...
basic::options::OptionKeys collection
RealOptionKey const hbond_min_threshold("motifs:hbond_min_threshold")
std::string string_of(Fstring const &s)
string of an Fstring
Program options global and initialization function.
BooleanOptionKey const chemical
basic::options::OptionKeys collection
char & uppercase(char &c)
Uppercase a Character.
rule< Scanner, option_closure::context_t > option