29 #include <ObjexxFCL/char.functions.hh>
30 #include <ObjexxFCL/string.functions.hh>
32 #include <basic/Tracer.hh>
59 #include <numeric/model_quality/rms.hh>
68 #include <basic/options/option.hh>
69 #include <basic/options/keys/in.OptionKeys.gen.hh>
70 #include <basic/options/keys/run.OptionKeys.gen.hh>
72 #include <boost/lexical_cast.hpp>
75 #include <utility/vector1.hh>
76 #include <utility/Binary_Util.hh>
79 static basic::Tracer
tr(
"core.io.silent");
90 using namespace basic::options;
91 using namespace basic::options::OptionKeys;
103 using namespace basic::options;
104 using namespace basic::options::OptionKeys;
130 tr.Trace <<
"binary:fill_struct... " << std::endl;
136 tr.Trace <<
"get energies from pose..." << std::endl;
154 tr.Trace <<
"read coords..." << std::endl;
162 for (
unsigned int j = 1; j <= resi.
natoms(); ++j) {
181 nres_pose =
symmetry_info()->num_total_residues_with_pseudo() ;
182 if ( seqpos < 1 || seqpos >= nres_pose ) {
183 tr.Fatal <<
"ERROR: add_chain_ending() invalid chain ending " << seqpos << std::endl;
196 while ( stream.good() ) {
201 for (
Size i = 1, ie = v.size(); i < ie; ++i ) {
207 std::ostringstream ss;
208 ss <<
"CHAIN_ENDINGS ";
220 nres_pose =
symmetry_info()->num_total_residues_with_pseudo() ;
222 if ( (*i) < 1 || (*i) > nres_pose ) {
223 tr.Fatal <<
"ERROR: chain_endings() invalid chain ending " << (*i) << std::endl;
236 using namespace basic::options;
237 using namespace basic::options::OptionKeys;
242 if ( iter->substr(0,9) !=
"SEQUENCE:" ) {
246 static_cast< EnergyNames * >
255 energy_names_ = enames ->energy_names();
262 std::istringstream line_stream( *iter );
264 tr.Debug <<
"reading sequence from " << *iter << std::endl;
267 line_stream >> tag >> temp_seq;
268 if ( line_stream.fail() || tag !=
"SEQUENCE:" ) {
269 tr.Error <<
"bad format in sequence line of silent file" << std::endl;
270 tr.Error <<
"line = " << *iter << std::endl;
271 tr.Error <<
"tag = " << tag << std::endl;
278 if ( iter == lines.end() ) {
279 utility_exit_with_message(
"While reading binary silent structure, encountered end of structure too early after reading the 'SEQUENCE' line" );
281 std::istringstream score_line_stream( *iter );
282 tr.Debug <<
"reading score names from " << *iter << std::endl;
285 score_line_stream >> tag;
286 if ( score_line_stream.fail() || tag !=
"SCORE:" ) {
287 tr.Error <<
"bad format in second line of silent file" << std::endl;
288 tr.Error <<
"tag = " << tag << std::endl;
289 tr.Error <<
"line = " << *iter << std::endl;
292 score_line_stream >> tag;
293 while ( ! score_line_stream.fail() ) {
294 energy_names_.push_back( tag );
295 score_line_stream >> tag;
301 enames ->energy_names( energy_names_ );
302 seqdata->set_sequence(
sequence() );
310 bool bitflip =
false;
312 bool fullatom_well_defined =
false;
314 iter !=
end; ++iter ) {
316 std::istringstream line_stream( *iter );
318 if ( iter->substr(0,6) ==
"REMARK" ) {
322 line_stream >> tag >> comment >> value;
326 if ( iter->substr(0,7) ==
"SCORE: " ) {
333 if ( line_stream.fail() || tag !=
"SCORE:" ) {
334 tr.Error <<
"bad format in first score line of silent file" << std::endl;
335 tr.Error <<
"line = " << *iter << std::endl;
336 tr.Error <<
"tag = " << tag << std::endl;
343 if ( iter->substr(0,10) ==
"FOLD_TREE " ) {
347 tr.Debug <<
"read fold-tree " << f;
348 tr.Debug <<
"reading " << f.num_jump() <<
" jumps " << std::endl;
350 }
else if ( iter->substr(0,2) ==
"RT" ) {
353 tr.Debug <<
"read jump " << jump << std::endl;
358 }
else if ( iter->substr(0,9) ==
"SEQUENCE:" ) {
359 tr.Warning <<
"Skipping duplicate sequence declaration " << std::endl;
361 }
else if ( iter->substr(0,19) ==
"ANNOTATED_SEQUENCE:" ) {
364 line_stream >> annotated_seq;
369 }
else if ( iter->substr(0,4) ==
"JUMP" ) {
377 <<
"WARNING: corrupted silent file read line JUMP X -- X should match number of jumps in FOLD_TREE " << std::endl;
379 for (
Size i = 1; i<= nr; i++ ) {
386 }
else if ( iter->substr(0,13) ==
"SYMMETRY_INFO" ) {
393 }
else if ( iter->substr( 0, 13 ) ==
"CHAIN_ENDINGS" ) {
403 if ( tag.length() < 1 ) {
404 tr.Warning <<
"WARNING: read blank line in decoy tag " <<
decoy_tag()
408 if ( static_cast< core::Size > (currpos) >
secstruct_.size() ) {
409 tr.Error <<
"ERROR: trying to index off the end of the secstruct array"
410 <<
", idx is " << currpos <<
" secstruct_.size() is " <<
secstruct_.size()
416 int natoms = (tag.length()-1) / 16;
418 utility::decode6bit( (
unsigned char*)&(atm_buff[1]) , tag.substr(1) );
424 core::Real len_check12 = (atm_buff[1]-atm_buff[2]).length();
425 core::Real len_check23 = (atm_buff[3]-atm_buff[2]).length();
426 if ( len_check12 < 0.5 || len_check12 > 2.0 || len_check23 < 0.5 ||
431 len_check12 = (atm_buff[1]-atm_buff[2]).length();
432 len_check23 = (atm_buff[3]-atm_buff[2]).length();
433 if ( len_check12 < 0.5 || len_check12 > 2.0 || len_check23 < 0.5 || len_check23 > 2.0 ) {
436 tr.Warning <<
"reading big-endian binary silent file! " <<
decoy_tag() << std::endl;
455 for (
int j=1; j<=natoms; ++j) {
464 tr.Warning <<
"parse error: found " <<
jumps_.size()
466 <<
" for decoy tag " <<
decoy_tag() << std::endl;
475 tr <<
"ERROR: didn't find coordinates for all sequence positions of "
477 tr <<
" expected " <<
nres()
478 <<
", found " << currpos-1 << std::endl;
484 tr.Debug <<
" generating simple fold-tree " <<
fold_tree();
495 if ( !fullatom_well_defined )
fullatom_ = option[ in::file::fullatom ]();
519 using namespace core::chemical;
521 tr.Debug <<
"fill_pose: SilentStruct is " << (
fullatom() ?
"fullatom" :
"centroid" ) << std::endl;
535 runtime_assert(
nres() != 0 );
553 nres_pose =
symmetry_info()->num_total_residues_with_pseudo() ;
554 for (
Size seqpos = 1; seqpos <= nres_pose; ++seqpos ) {
556 int atm_seqpos =
symmetry_info()->get_asymmetric_seqpos( seqpos ) ;
557 int natoms_struct =
atm_coords_[atm_seqpos].size();
558 int natoms_total = std::min( natoms_pose , natoms_struct );
560 if ( natoms_pose != natoms_struct) {
561 tr.Warning <<
"[ WARNING ] "
562 <<
"Number of atoms in pose and silent file disagree! "
563 <<
"Attempting to continue ..." << std::endl
564 <<
"[ WARNING ] (in residue " << seqpos
565 <<
" natoms_pose=" << natoms_pose
566 <<
"atm_seqpos " << atm_seqpos <<
" natoms_struct="
567 << natoms_struct <<
")" << std::endl;
574 for (
int j = 1; j <= natoms_total; ++j ){
578 atm_ids.push_back(
id );
614 tr.Debug <<
"nres = " << nres_pose << std::endl;
618 utility_exit_with_message(
"RuntimeAssert failed: nres() == one_letter_sequence().length()" );
640 std::ostream & output
642 output <<
"REMARK BINARY SILENTFILE\n";
648 output <<
"FOLD_TREE ";
684 using namespace basic::options;
685 if( option[ OptionKeys::run::write_failures ].user() && option[ OptionKeys::run::write_failures ] ==
false &&
decoy_tag().substr( 0, 8 ) ==
"FAILURE_" )
return;
687 for (
Size i = 1; i <=
nres(); ++i ) {
692 if (this_secstr < 'A' || this_secstr >
'Z') this_secstr =
'L';
695 output << this_secstr << resline <<
' ' <<
decoy_tag() <<
"\n";
702 ObjexxFCL::FArray2D< Real > rebuilt_coords ( 3,
atm_coords_.size() ),
709 for (
Size k = 1; k <= 3; ++k ) {
710 rebuilt_coords (k,i) = temp_pose.
residue(i).
xyz(
"CA" )[k-1];
715 Real rmsd = numeric::model_quality::rms_wrapper( temp_pose.
total_residue(), rebuilt_coords, original_coords );
719 ObjexxFCL::FArray2D< Real >
722 ObjexxFCL::FArray2D< Real > my_coords( 3, n_residues );
723 for (
Size i = 1; i <= n_residues; ++i ) {
724 for (
Size k = 1; k <= 3; ++k ) {
733 ObjexxFCL::FArray2D< Real > my_coords =
get_CA_xyz();
734 ObjexxFCL::FArray2D< Real > other_coords = other_pss.
get_CA_xyz();
735 Real rmsd = numeric::model_quality::rms_wrapper(
nres(), my_coords, other_coords );
744 utility_exit_with_message(
"called BinaryProteinSilentStruct::operator=)" );