37 #include <utility/Binary_Util.hh>
39 #include <basic/Tracer.hh>
62 #include <numeric/model_quality/rms.hh>
70 #include <utility/vector1.hh>
73 #include <basic/options/keys/OptionKeys.hh>
81 static basic::Tracer
tr(
"core.io.silent");
87 using namespace basic::options;
88 using namespace basic::options::OptionKeys;
98 using namespace basic::options;
99 using namespace basic::options::OptionKeys;
122 tr.Trace <<
"binary:fill_struct... " << std::endl;
134 tr.Trace <<
"get energies from pose..." << std::endl;
142 tr.Trace <<
"read coords..." << std::endl;
147 for (
unsigned int j = 1; j <= resi.
natoms(); ++j) {
166 if ( iter->substr(0,9) !=
"SEQUENCE:" ) {
177 energy_names_ = enames ->energy_names();
184 std::istringstream line_stream( *iter );
186 tr.Debug <<
"reading sequence from " << *iter << std::endl;
190 line_stream >> tag >> temp_seq;
191 if ( line_stream.fail() || tag !=
"SEQUENCE:" ) {
192 tr.Error <<
"bad format in sequence line of silent file" << std::endl;
193 tr.Error <<
"line = " << *iter << std::endl;
194 tr.Error <<
"tag = " << tag << std::endl;
200 std::istringstream score_line_stream( *iter );
201 tr.Debug <<
"reading score names from " << *iter << std::endl;
204 score_line_stream >> tag;
205 if ( score_line_stream.fail() || tag !=
"SCORE:" ) {
206 tr.Error <<
"bad format in second line of silent file" << std::endl;
207 tr.Error <<
"tag = " << tag << std::endl;
208 tr.Error <<
"line = " << *iter << std::endl;
211 score_line_stream >> tag;
212 while ( ! score_line_stream.fail() ) {
213 energy_names_.push_back( tag );
214 score_line_stream >> tag;
220 enames ->energy_names( energy_names_ );
221 seqdata->set_sequence(
sequence() );
228 bool bitflip =
false;
233 std::istringstream line_stream( *iter );
237 if ( iter->substr(0,6) ==
"REMARK" ){
242 if ( iter->substr(0,7) ==
"SCORE: " ) {
249 if ( line_stream.fail() || tag !=
"SCORE:" ) {
250 tr.Error <<
"bad format in first score line of silent file" << std::endl;
251 tr.Error <<
"line = " << *iter << std::endl;
252 tr.Error <<
"tag = " << tag << std::endl;
259 if (
Size(currpos) >
nres() )
continue;
262 if ( iter->substr(0,10) ==
"FOLD_TREE " ) {
269 tr.Debug <<
"read fold-tree " << f;
270 tr.Debug <<
"reading " << f.num_jump() <<
" jumps " << std::endl;
272 }
else if ( iter->substr(0,2) ==
"RT" ) {
275 tr.Debug <<
"read jump " << jump << std::endl;
280 }
else if ( iter->substr(0,9) ==
"SEQUENCE:" ) {
281 tr.Debug <<
"Skipping duplicate sequence declaration " << std::endl;
283 }
else if ( iter->substr(0,19) ==
"ANNOTATED_SEQUENCE:" ) {
286 line_stream >> annotated_seq;
288 tr.Debug <<
"read annotated sequence as: " <<
sequence() << std::endl;
292 }
else if ( iter->substr(0,4) ==
"JUMP" ) {
300 <<
"WARNING: corrupted silent file read line JUMP X -- X should match number of jumps in FOLD_TREE " << std::endl;
302 for (
Size i = 1; i<= nr; i++ ) {
314 if (tag.length() < 1) {
315 tr.Warning <<
"WARNING: read blank line in decoy tag " <<
decoy_tag() << std::endl;
320 int natoms = (tag.length()-1) / 16;
322 utility::decode6bit( (
unsigned char*)&(atm_buff[1]) , tag.substr(1) );
329 core::Real len_check12 = (atm_buff[1]-atm_buff[2]).length();
330 if ( len_check12 < 0.5 || len_check12 > 2.0 ) {
333 len_check12 = (atm_buff[1]-atm_buff[2]).length();
334 if ( len_check12 < 0.5 || len_check12 > 2.0 ) {
337 tr.Warning <<
"reading big-endian binary silent file! " <<
decoy_tag() << std::endl;
348 for (
int j=1; j<=natoms; ++j) {
357 tr.Warning <<
"parse error: found " <<
jumps_.size()
359 <<
" for decoy tag " <<
decoy_tag() << std::endl;
365 tr.Error <<
"ERROR: didn't find coordinates for all sequence positions of "
367 tr.Error <<
" expected " <<
nres()
368 <<
", found " << currpos-1 << std::endl;
374 tr.Debug <<
" generating simple fold-tree " <<
fold_tree();
409 using namespace core::chemical;
439 tr.Debug <<
"nres = " <<
nres() << std::endl;
443 utility_exit_with_message(
"RuntimeAssert failed: nres() == one_letter_sequence().length()" );
447 for (
Size seqpos = 1; seqpos <=
nres(); ++seqpos ) {
450 int natoms_total = std::min( natoms_pose , natoms_struct );
452 if ( natoms_pose != natoms_struct) {
453 tr.Warning <<
"[ WARNING ] Number of atoms in pose and silent file disagree! ";
454 tr.Warning <<
"Attempting to continue ..." << std::endl;
455 tr.Warning <<
"[ WARNING ] (in residue "
456 << seqpos <<
" natoms_pose=" << natoms_pose
457 <<
" natoms_struct=" << natoms_struct <<
")" << std::endl;
461 natoms_total = std::min( natoms_pose, natoms_struct );
463 for (
int j = 1; j <= natoms_total; ++j ){
483 out <<
"REMARK BINARY_SILENTFILE RNA \n";
485 out <<
"REMARK BINARY_SILENTFILE RNA COARSE\n";
491 std::ostream & output
494 output <<
"FOLD_TREE ";
517 for (
Size i = 1; i <=
nres(); ++i ) {
520 if (this_secstr < 'A' || this_secstr >
'Z') this_secstr =
'L';
522 output << this_secstr << resline <<
' ' <<
decoy_tag() <<
"\n";
529 ObjexxFCL::FArray2D< Real > rebuilt_coords ( 3,
atm_coords_.size() ),
538 for (
Size k = 1; k <= 3; ++k ) {
539 rebuilt_coords (k,i) = temp_pose.
residue(i).
xyz(
" C4*" )[k-1];
540 original_coords(k,i) =
atm_coords_[i][c4star_index][k-1];
544 Real rmsd = numeric::model_quality::rms_wrapper( temp_pose.
total_residue(), rebuilt_coords, original_coords );
548 ObjexxFCL::FArray2D< Real >
551 ObjexxFCL::FArray2D< Real > my_coords( 3, n_residues );
552 for (
Size i = 1; i <= n_residues; ++i ) {
553 for (
Size k = 1; k <= 3; ++k ) {
562 ObjexxFCL::FArray2D< Real > my_coords =
get_CA_xyz();
563 ObjexxFCL::FArray2D< Real > other_coords = other_pss.
get_CA_xyz();
564 Real rmsd = numeric::model_quality::rms_wrapper(
nres(), my_coords, other_coords );