23 #include <basic/options/option.hh>
35 #include <basic/MetricValue.hh>
36 #include <basic/Tracer.hh>
38 #include <utility/vector1.hh>
40 #include <utility/file/file_sys_util.hh>
41 #include <utility/file/gzip_util.hh>
42 #include <utility/string_util.hh>
50 #include <basic/options/keys/dna.OptionKeys.gen.hh>
51 #include <basic/options/keys/score.OptionKeys.gen.hh>
52 #include <basic/options/keys/run.OptionKeys.gen.hh>
55 #include <utility/io/ozstream.hh>
56 #include <ObjexxFCL/format.hh>
62 using utility::string_split;
65 using namespace core::chemical;
66 using namespace core::conformation;
67 using namespace core::scoring;
68 using namespace core::pack;
69 using namespace basic::options;
70 using namespace ObjexxFCL::fmt;
75 static basic::Tracer
TR(
"protocols.dna.PDBOutput", t_info );
79 : jd2::PDBJobOutputter(),
82 chi_diff_threshold_(0.0001),
83 mainchain_torsion_diff_threshold_(0.0001),
100 utility_exit_with_message(
"Unable to open file: " +
extended_name(job) +
"\n" );
101 pdbout <<
"REMARK BEGIN ROSETTA INFO\n";
122 if ( !pdbout.good() )
123 utility_exit_with_message(
"Unable to open file: " + name +
"\n" );
124 pdbout <<
"REMARK BEGIN ROSETTA INFO\n";
140 ( *score_function_ )( *pose_copy_ );
173 int const ext( index - s );
184 for (
Size index(1),
end( ptask->total_residue() ); index <
end; ++index ) {
185 if ( ptask->design_residue(index) ||
186 ptask->residue_task(index).has_behavior(
"TARGET") ) {
197 itr !=
end; ++itr ) {
199 pdbout << itr->first <<
'\n';
200 for ( Strings::const_iterator line( itr->second.begin() ), end2( itr->second.end() );
201 line != end2; ++line ) {
202 pdbout << *line <<
'\n';
204 pdbout <<
"REMARK\n";
216 StringsMap::iterator finditer(
info_map_.find( key ) );
220 Strings & existing_info( finditer->second );
221 for ( Strings::const_iterator it( info.begin() ),
end( info.end() ); it !=
end; ++it ) {
222 existing_info.push_back( *it );
244 if ( res1.
aa() != res2.
aa() )
return true;
250 end1( res1chi.end() ), end2( res2chi.end() ); it1 != end1 && it2 != end2; ++it1, ++it2 ) {
259 end1( res1mc.end() ), end2( res2mc.end() ); it1 != end1 && it2 != end2; ++it1, ++it2 ) {
274 if ( !
reference_pose_ || !option[ OptionKeys::dna::design::sparse_pdb_output ]() ) {
296 for ( std::list< std::string >::const_iterator it( list.begin() ),
end( list.end() );
297 it !=
end; ++it ) os += sep + *it;
308 pdbout <<
"REMARK Residues varied in this design:\n";
310 std::list< std::string > moved, moved_DNA, mutated, mutated_DNA;
312 for (
Size index(1), nres(
pose_copy_->total_residue() ); index <= nres; ++index ) {
313 std::ostringstream os;
315 os <<
pose_copy_->pdb_info()->number( index ) <<
" "
317 else os << index <<
" " <<
pose_copy_->chain( index );
323 if (
pose_copy_->residue_type(index).is_DNA() ) mutated_DNA.push_back( os.str() );
324 else mutated.push_back( os.str() );
328 if (
pose_copy_->residue_type(index).is_DNA() ) moved_DNA.push_back( os.str() );
329 else moved.push_back( os.str() );
333 pdbout <<
"REMARK MovedRes" <<
string_join( moved ) <<
'\n';
334 pdbout <<
"REMARK MovedDNA" <<
string_join( moved_DNA ) <<
'\n';
335 pdbout <<
"REMARK MutatedRes" <<
string_join( mutated ) <<
'\n';
336 pdbout <<
"REMARK MutatedDNA" <<
string_join( mutated_DNA ) <<
'\n';
337 pdbout <<
"REMARK\n";
346 pdbout <<
"REMARK Non-zero ScoreFunction weights:\n";
348 if ( weights[
ScoreType(i) ] == 0 )
continue;
350 pdbout <<
"REMARK " <<
A(16,name) <<
" " << F( 6, 4, weights[
ScoreType(i) ] ) <<
'\n';
352 pdbout <<
"REMARK\n";
356 if ( option[ OptionKeys::score::output_residue_energies ]() ) {
357 pdbout <<
"REMARK Weighted per-residue energies\n";
359 int const colwidth(10);
360 pdbout <<
"REMARK " <<
A( 4,
"pdb" ) <<
A( 4,
"type" ) <<
A( 2,
"ch" );
362 if ( weights[
ScoreType(i) ] == 0 )
continue;
372 pdbout << I( 4,
pose_copy_->pdb_info()->number(*pos) )
373 <<
A( 4,
pose_copy_->residue(*pos).type().name3() )
376 pdbout << I( 4, *pos ) <<
A( 4,
pose_copy_->residue(*pos).type().name3() )
381 if ( weights[
ScoreType(st) ] == 0 )
continue;
387 pdbout <<
"REMARK\n";
391 pdbout <<
"REMARK Weighted total energies:\n";
397 if ( W == 0 )
continue;
398 Real const weighted_E(
E * W );
400 pdbout <<
"REMARK " <<
A(16,name) <<
" " << F( 8, 2, weighted_E ) <<
'\n';
403 pdbout <<
"REMARK " <<
A(16,
"total_score") <<
" " << F( 8,2,total_energies[
total_score] ) <<
'\n';
404 pdbout <<
"REMARK \n";
414 if ( ! option[ OptionKeys::run::output_hbond_info ]() )
return;
416 using namespace scoring::hbonds;
424 pdbout <<
"REMARK Loc, res, pos, pdb, chain, atom, x, y, z, res, pos, pdb, chain, atom, x, y, z, hbE, HAdis, xD, xH\n";
437 relevant_residue[ *index ] =
true;
440 for (
Size i(1); i <= hbond_set.nhbonds(); ++i ) {
442 HBond
const & hb( hbond_set.hbond(i) );
443 Size const don_res_i( hb.don_res() ), acc_res_i( hb.acc_res() );
447 if ( don_rsd.is_DNA() && acc_rsd.is_DNA() )
continue;
449 if ( hb.don_hatm_is_protein_backbone() || hb.acc_atm_is_protein_backbone() )
continue;
451 if ( !relevant_residue[ don_res_i ] && !relevant_residue[ acc_res_i ] )
continue;
453 if ( !don_rsd.is_DNA() && !interface.protein_neighbors().find( don_res_i )->second.close() )
455 if ( !acc_rsd.is_DNA() && !interface.protein_neighbors().find( acc_res_i )->second.close() )
458 Size const donH_i( hb.don_hatm() ), acc_i( hb.acc_atm() );
459 std::string const don_hatm_name( don_rsd.atom_name( donH_i ) ),
460 acc_atm_name( acc_rsd.atom_name( acc_i ) );
463 if ( acc_rsd.atom_is_backbone( acc_i ) || don_rsd.atom_is_backbone( donH_i ) ) {
470 if ( acc_rsd.is_DNA() || don_rsd.is_DNA() ) {
471 category = ( category ==
"sc_bb" ?
"dna_bb" :
"dna_base" );
473 if ( acc_rsd.atom_type( acc_i ).name() ==
"HOH" ||
474 don_rsd.atom_type( donH_i ).name() ==
"HOH" ) {
475 category =
"dna_wat";
479 Real const weighted_E( hb.energy() * weight );
480 if ( category ==
"dna_base" || category ==
"dna_wat" ) hb_spec += weighted_E;
483 Size const don_i( don_rsd.bonded_neighbor( donH_i ).front() );
487 Dxyz( don_rsd.atom( don_i ).xyz() ),
488 Axyz( acc_rsd.atom( acc_i ).xyz() ),
489 Bxyz( acc_rsd.atom( acc_rsd.atom_base( acc_i ) ).
xyz() ),
490 B2xyz( acc_rsd.atom( acc_rsd.abase2( acc_i ) ).
xyz() );
493 Vector const HD( Dxyz - Hxyz ), AH( Hxyz - Axyz );
494 Real const HDdis( HD.length() ), AHdis( AH.length() );
495 Real const inv_HDdis( 1.0f / HDdis ), inv_AHdis( 1.0f / AHdis );
496 Vector const HDunit( HD * inv_HDdis ), AHunit( AH * inv_AHdis );
499 hbond_set.hbond_options(),
501 Axyz, Bxyz, B2xyz, PBxyz, BAunit );
502 Real const xD( dot( AHunit, HDunit ) ), xH( dot( BAunit, AHunit ) );
504 int don_pdb(0), acc_pdb(0);
506 don_pdb =
pose_copy_->pdb_info()->number( don_res_i );
507 acc_pdb =
pose_copy_->pdb_info()->number( acc_res_i );
509 pdbout <<
"REMARK " <<
A(8,category) <<
" ";
510 pdbout << don_rsd.name3() <<
" " << I(4,don_res_i) <<
" " << I(4,don_pdb) <<
" ";
512 else pdbout <<
pose_copy_->chain( don_res_i );
513 pdbout <<
" " << don_hatm_name <<
" "
515 << F(8,3,Hxyz[0]) <<
" " << F(8,3,Hxyz[1]) <<
" " << F(8,3,Hxyz[2]) <<
" ";
516 pdbout << acc_rsd.name3() <<
" " << I(4,acc_res_i) <<
" " << I(4,acc_pdb) <<
" ";
518 else pdbout <<
pose_copy_->chain( acc_res_i );
519 pdbout <<
" " << acc_atm_name <<
" "
521 << F(8,3,Axyz[0]) <<
" " << F(8,3,Axyz[1]) <<
" " << F(8,3,Axyz[2]) <<
" ";
522 pdbout << F(6,2, weighted_E ) <<
" " << AHdis <<
" " << xD <<
" " << xH <<
'\n';
534 if ( !option[ OptionKeys::run::decoystats ]() )
return;
536 using namespace protocols::toolbox::pose_metric_calculators;
540 basic::MetricValue< AtomID_Map< bool > > map;
544 for(
Size atomi(1); atomi <= map.value().n_atom(*pos); ++atomi ) {
545 if( map.value()(*pos,atomi) ) {
550 pdbout <<
"REMARK Unsat ";
552 pdbout <<
pose_copy_->pdb_info()->chain(*pos) <<
'.'
555 pdbout <<
pose_copy_->chain(*pos) <<
'.' << *pos;
557 pdbout <<
'.' << name3 <<
" " << rt.atom_name(atomi) << std::endl;
567 basic::MetricValue< Size > nhbonds;
570 TR(t_info) <<
"pdb nhbonds " << nhbonds.value() << std::endl;
571 pdbout <<
"REMARK nhbonds " << nhbonds.value() <<
'\n';
575 basic::MetricValue< Real > total_sasa;
578 TR(t_info) <<
"pdb total_sasa " << total_sasa.value() << std::endl;
579 pdbout <<
"REMARK total_sasa " << total_sasa.value() <<
'\n';
583 basic::MetricValue< Real > total_packstat;
584 calc_packstat.
get(
"total_packstat", total_packstat, *
pose_copy_ );
585 TR(t_info) <<
"pdb total_packstat " << total_packstat.value() << std::endl;
586 pdbout <<
"REMARK total_packstat " << total_packstat.value() <<
'\n';
596 StringVec
const subdirs( string_split( name,
'/' ) );
597 for ( StringVec::const_iterator dir( subdirs.begin() ); dir != subdirs.end()-1; ++dir ) {
599 utility::file::create_directory( dir->c_str() );