Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SilentStruct.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/io/silent/SilentStruct.cc
12 ///
13 /// @brief silent input file reader for mini.
14 /// @author James Thompson
15 
16 // C++ Headers
17 #include <iostream>
18 #include <string>
19 #include <map>
20 
21 #ifdef WIN32
22 #include <ctime>
23 #endif
24 
25 #ifdef __CYGWIN__
26 #include <ctime>
27 #endif
28 
29 // mini headers
30 
31 #include <ObjexxFCL/char.functions.hh>
32 #include <ObjexxFCL/string.functions.hh>
34 
38 
39 #include <basic/Tracer.hh>
40 #include <basic/datacache/BasicDataCache.hh>
41 #include <basic/datacache/CacheableString.hh>
42 #include <basic/datacache/CacheableStringFloatMap.hh>
43 
44 #include <basic/options/option.hh>
45 
46 // AUTO-REMOVED #include <core/id/AtomID.hh>
47 // AUTO-REMOVED #include <core/id/AtomID_Map.hh>
48 
49 #include <core/pose/Pose.hh>
50 #include <core/pose/PDBInfo.hh>
51 #include <core/pose/util.hh>
53 
56 #include <core/scoring/Energies.hh>
58 
61 
62 
63 //#ifdef BOINC
64 //#include <protocols/boinc/boinc.hh>
65 //#endif
66 
67 // option key includes
68 
69 #include <basic/options/keys/out.OptionKeys.gen.hh>
70 #include <basic/options/keys/in.OptionKeys.gen.hh>
71 
72 #include <utility/vector1.hh>
74 
75 #include <ObjexxFCL/format.hh>
76 
77 
78 namespace core {
79 namespace io {
80 namespace silent {
81 
82 static basic::Tracer tr("core.io.silent");
83 
84 
85 template <>
87 
88 template <>
90 
91 
93  : strict_column_mode_(false), nres_(0), decoy_tag_(""), sequence_(""), precision_(3), scoreline_prefix_("SCORE: ")
94 {}
95 
97 
99  ReferenceCount()
100 {
101  *this = src;
102 }
103 
106  nres_ = src.nres_;
107  decoy_tag_ = src.decoy_tag_;
108  sequence_ = src.sequence_;
111  precision_ = src.precision_;
113  return *this;
114 }
115 
117  core::pose::Pose & pose
118 ) const {
119  runtime_assert( nres_ != 0 );
120  using namespace core::chemical;
121  ResidueTypeSetCAP residue_set
123  fill_pose( pose, *residue_set );
124 }
125 
126 /// @brief Fill a Pose with the conformation information in this SilentStruct
127 /// and the ResidueTypeSet provided by the caller. This is a virtual method
128 /// which must be implemented by classes derived from SilentStruct.
132 ) const {
133  tr.Error << "SilentStruct::fill_pose method stubbed out!" << std::endl;
134 }
135 
137  core::pose::Pose & pose
138 ) const
139 {
140  using namespace basic::options;
141  using namespace basic::options::OptionKeys;
142 
143  pose.pdb_info( new core::pose::PDBInfo(pose) );
144 
145  if ( option[ in::file::keep_input_scores ]() ) {
146  tr.Debug << "keep input scores... call energies into pose " << std::endl;
147  energies_into_pose( pose );
148  }
149 }
150 
151 bool
153  tr.Debug << "reading sequence from " << line << std::endl;
154  std::istringstream line_stream( line );
155 
156  std::string tag;
157  std::string temp_seq;
158  line_stream >> tag >> temp_seq;
159  if ( line_stream.fail() || tag != "SEQUENCE:" ) {
160  tr.Error << "bad format in sequence line of silent file" << std::endl;
161  tr.Error << "line = " << line << std::endl;
162  tr.Error << "tag = " << tag << std::endl;
163  return false;
164  }
165  sequence( temp_seq );
166  return true;
167 }
168 
170  // second line is a list of score names
171  std::istringstream score_line_stream( line );
172  tr.Debug << "reading score names from " << line << std::endl;
173  std::string tag;
174  score_line_stream >> tag; // SCORE:
175  if ( score_line_stream.fail() || tag != "SCORE:" ) {
176  tr.Error << "bad format in second line of silent file" << std::endl;
177  tr.Error << "tag = " << tag << std::endl;
178  tr.Error << "line = " << line << std::endl;
179  }
180 
181  score_line_stream >> tag; // first score name
182  while ( ! score_line_stream.fail() ) {
183  energy_names.push_back( tag );
184  score_line_stream >> tag; // try to get next score name
185  }
186 
187  EnergyNamesOP enames( new EnergyNames() );
188  SimpleSequenceDataOP seqdata( new SimpleSequenceData() );
189 
190  enames ->energy_names( energy_names );
191  seqdata->set_sequence( sequence() );
192 
193  container.set_shared_silent_data( energynames , enames );
194  container.set_shared_silent_data( simplesequencedata, seqdata );
195 
196 }
197 
198 void
199 SilentStruct::print_header( std::ostream & out ) const {
200  out << "SEQUENCE: " << one_letter_sequence() << std::endl;
201  print_score_header( out );
202 }
203 
204 void SilentStruct::print_score_header( std::ostream & out ) const {
205  out << scoreline_prefix();
206  using utility::vector1;
207 
208  using namespace ObjexxFCL::fmt;
210  for ( iter it = silent_energies_.begin(), end = silent_energies_.end();
211  it != end; ++it
212  ) {
213  out << " " << A( it->width(), it->name() );
214  }
215 
216  using namespace basic::options;
217  using namespace basic::options::OptionKeys;
218  /// print out a column for the user tag if specified.
219  if ( option[ out::user_tag ].user() ) {
220  std::string const tag = option[ out::user_tag ]();
221  int width = std::max( 11, static_cast< int > (tag.size()) );
222  out << ' ' << A( width, "user_tag" );
223  }
224 
225  int width = decoy_tag().size();
226  if ( width < 11 ) width = 11; //size of "description"
227  out << ' ' << A( width, "description" ) << std::endl;
228 }
229 
230 void
231 SilentStruct::print_scores( std::ostream & out ) const {
232  using namespace basic::options;
233  using namespace basic::options::OptionKeys;
234  using namespace ObjexxFCL;
235  using namespace ObjexxFCL::fmt;
236  //int precision = 3; // number of digits after decimal place
237 
238  out << scoreline_prefix();
239 
241  for ( iter it = silent_energies_.begin(), end = silent_energies_.end();
242  it != end; ++it
243  ) {
244  if ( it->string_value() == "" ){
245  core::Real weight = 1.0;
246  if ( option[ out::file::weight_silent_scores ]() ) { //default true
247  weight = it->weight();
248  }
249  out << " " << F( it->width(), precision(), it->value() * weight );
250  } else {
251  out << " " << std::setw( it->width() ) << it->string_value() << " ";
252  }
253  }
254 
255  /// print out a column for the user tag if specified.
256  if ( option[ out::user_tag ].user() ) {
257  std::string const tag = option[ out::user_tag ]();
258  int width = std::min( 11, static_cast< int > (tag.size()) );
259  out << ' ' << A( width, tag );
260  }
261 
262  int width = decoy_tag().size();
263  if ( width < 11 ) width = 11; // size of "description"
264  out << ' ' << A( width, decoy_tag() ) << "\n";
265  print_comments( out );
266 }
267 
268 void
269 SilentStruct::print_comments( std::ostream & out ) const {
270  using std::map;
271  using std::string;
272  string const remark( "REMARK" );
273 
274  typedef map< string, string >::const_iterator c_iter;
275  for ( c_iter it = silent_comments_.begin(), end = silent_comments_.end();
276  it != end; ++it
277  ) {
278  out << remark << ' ' << it->first << ' ' << it->second << std::endl;
279  }
280 } // print_comments
281 
282 bool SilentEnergy_sort_by_name( const SilentEnergy &score_energy1, const SilentEnergy &score_energy2 ){
283  // these two if statements ensure that score always sorts to the beginning
284  if( score_energy1.name() == "score" ) return true;
285  if( score_energy2.name() == "score" ) return false;
286  // if above not met, compare strings in ascii
287  return score_energy1.name() < score_energy2.name();
288 }
289 
291  std::sort( silent_energies_.begin(), silent_energies_.end(), SilentEnergy_sort_by_name);
292 }
293 
294 bool SilentStruct::has_energy( std::string const scorename ) const {
296  it = silent_energies_.begin(), end = silent_energies_.end();
297  it != end; ++it
298  ) {
299  if ( it->name() == scorename )
300  return true;
301  }
302  return false;
303 }
304 
305 void
306 SilentStruct::add_energy( std::string scorename, Real value, Real weight ) {
307  // check if we already have a SilentEnergy with this scorename
308  bool replace( false );
310  for ( iter it = silent_energies_.begin(), end = silent_energies_.end();
311  it != end; ++it
312  ) {
313  if ( it->name() == scorename ) {
314  it->value( value );
315  replace = true;
316  }
317  } // for (silent_energies_)
318 
319  // add this energy if we haven't added it already
320  if ( !replace ) {
321  int width = std::max( 10, (int) scorename.length() + 3 );
322  SilentEnergy new_se( scorename, value, weight, width );
323  silent_energies_.push_back( new_se );
324  } // if (!replace)
325 } // add_energy
326 
327 void
329  std::string scorename, std::string const & value
330 ) {
331  // check if we already have a SilentEnergy with this scorename
332  bool replace( false );
334  for ( iter it = silent_energies_.begin(), end = silent_energies_.end();
335  it != end; ++it
336  ) {
337  if ( it->name() == scorename ) {
338  it->value( value );
339  replace = true;
340  }
341  } // for (silent_energies_)
342 
343  // add this energy if we haven't added it already
344  if ( !replace ) {
345  int width = std::max( 10, (int) scorename.length() + 3 );
346  SilentEnergy new_se( scorename, value, width );
347  silent_energies_.push_back( new_se );
348  }
349 } // add_string_value
350 
351 core::Real SilentStruct::get_energy( std::string const & scorename ) const {
352  if ( has_energy( scorename ) )
353  return get_silent_energy( scorename ).value();
354  else
355  return 0.0;
356 }
357 
359  std::string const & scorename
360 ) const {
361  static const std::string empty_string("");
362  if ( has_energy( scorename ) )
363  return get_silent_energy( scorename ).string_value();
364  else
365  return empty_string;
366 }
367 
368 
370  std::string const & scorename
371 ) const {
372  assert( has_energy( scorename ) );
373  using utility::vector1;
375  end = silent_energies_.end();
376  it != end; ++it )
377  {
378  if ( it->name() == scorename ) return *it;
379  }
380  return (*silent_energies_.end()); // keep compiler happy
381 }
382 
383 
385  using utility::vector1;
386 
387  vector1< SilentEnergy > new_energies;
388  for ( vector1< std::string >::const_iterator it = valid.begin(),
389  end = valid.end();
390  it != end; ++it
391  ) {
392  SilentEnergy ener;
393  if ( *it == "description" ) continue; // hack!
394  if ( has_energy( *it ) ){
395  ener = get_silent_energy( *it );
396  }
397  ener.name( *it );
398  new_energies.push_back( ener );
399  }
400  silent_energies( new_energies );
401 } // set_valid_energies
402 
403 ///////////////////////////////////////////////////////////////////////
404 void
408 
409  for ( const_iter it = src_ss.silent_energies_.begin(),
410  end = src_ss.silent_energies_.end();
411  it != end; ++it
412  ) {
413  bool replace( false );
414 
415  //Check if score column already present.
416  for ( iter it2 = silent_energies_.begin(), end = silent_energies_.end();
417  it2 != end; ++it2
418  ) {
419  if ( it2->name() == it->name() ) {
420  it2->value( it->value() );
421  replace = true;
422  }
423  } // for it2
424 
425  if (!replace) silent_energies_.push_back( *it );
426  } // for it
427 } // copy_scores
428 
429 ///////////////////////////////////////////////////////////////////////
431  silent_comments_.insert( std::make_pair( name, value ) );
432 }
433 
435  std::istringstream line_stream( line );
436  std::string dummy, key, val, remark_tag;
437  line_stream >> remark_tag;
438  line_stream >> key;
439  line_stream >> val;
440  if ( line_stream.fail() ) {
441  tr.Error << "[ERROR] reading comment from line: " << line << std::endl;
442  return;
443  }
444  if ( val == "SILENTFILE" ) {
445  tr.Debug << "ignoring silent struct type specifier when reading comments: " << line << std::endl;
446  return;
447  }
448  line_stream >> dummy;
449  while( line_stream.good() ) {
450  val += " ";
451  val += dummy;
452  line_stream >> dummy;
453  }
454  add_comment( key, val );
455 }
456 
457 std::map< std::string, std::string > SilentStruct::get_all_comments() const {
458  return silent_comments_;
459 }
460 
461 bool SilentStruct::has_comment( std::string const & name ) const {
462  return ( silent_comments_.find( name ) != silent_comments_.end() );
463 }
464 
466  std::map< std::string, std::string >::const_iterator entry
467  = silent_comments_.find( name );
468  std::string comment( "" );
469  if ( entry != silent_comments_.end() ) {
470  comment = entry->second;
471  }
472 
473  return comment;
474 }
475 
477  silent_comments_.erase( name );
478 }
479 
481  silent_comments_.clear();
482 }
483 
484 
486  std::istream & input,
488 ) {
489  std::string tag;
491  Size input_count = 0;
492  Size const energy_names_count( energy_names.size() );
493 
494  using namespace ObjexxFCL;
495  for ( energy_iter = energy_names.begin();
496  energy_iter != energy_names.end();
497  ++energy_iter
498  ) {
499  input >> tag;
500  if ( is_float( tag ) ) {
501  Real score_val = static_cast< Real > ( float_of( tag ) );
502  add_energy( *energy_iter, score_val );
503  } else if ( *energy_iter == "description" ) {
504  decoy_tag( tag );
505  } else {
506  add_string_value( *energy_iter, tag );
507  }
508  ++input_count;
509  } // for ( energy_iter ... )
510 
511  if ( energy_names_count != input_count ) {
512  tr.Warning << "Warning: I have " << energy_names_count
513  << " energy names but I have " << input_count
514  << " energy values." << std::endl;
515  }
516 } // parse_energies
517 
519  runtime_assert( silent_energies_.begin()->name() == "score" );
520 
521  // set the "score" term to its appropriate value
523 
524  Real score( 0.0 );
525  for ( energy_it it = silent_energies_.begin(), end = silent_energies_.end();
526  it != end; ++it
527  ) {
528  score += it->weight() * it->value();
529  }
530 
531  silent_energies_.begin()->value( score );
532 } // update_score()
533 
535  using namespace core::pose::datacache;
536 
537  core::scoring::EnergyMap const emap = pose.energies().total_energies();
538  core::scoring::EnergyMap const wts = pose.energies().weights();
539 
540  clear_energies();
541 
542  // "score" is the total of weighted scores. always the first element in
543  // silent_energies_
544  SilentEnergy score_energy( "score", 0.0, 1.0, 8 );
545  silent_energies_.push_back( score_energy );
546  core::scoring::EnergyMap::const_iterator emap_iter, wts_iter;
547  for ( emap_iter = emap.begin(), wts_iter = wts.begin();
548  emap_iter != emap.end() && wts_iter!= wts.end();
549  ++emap_iter && ++wts_iter
550  ) {
551 
552  // only grab scores that have non-zero weights.
553  if ( *wts_iter != 0.0 ) {
555  = core::scoring::ScoreType( emap_iter - emap.begin() + 1 );
557 
558  int width = std::max( 10, (int) name.length() + 3 );
559  SilentEnergy new_se( name, *emap_iter, *wts_iter, width );
560  silent_energies_.push_back( new_se );
561  } // if ( *wts_iter != 0.0 )
562  } // for ( emap_iter ...)
563 
564  // set the "score" term to its appropriate value
565  update_score();
566 
567  // get arbitrary floating point scores from the map stored in the Pose data cache
568  if ( pose.data().has( CacheableDataType::ARBITRARY_FLOAT_DATA ) ) {
569  basic::datacache::CacheableStringFloatMapCOP data
570  = dynamic_cast< basic::datacache::CacheableStringFloatMap const * >
571  ( pose.data().get_raw_const_ptr(CacheableDataType::ARBITRARY_FLOAT_DATA) );
572 
573  using std::map;
574  using std::string;
575  for ( map< string, float >::const_iterator iter = data->map().begin(),
576  end = data->map().end(); iter != end; iter++
577  ) {
578  // skip score entry, as it gets confusing
579  if ( iter->first == "score" ) continue;
580  SilentEnergy new_se(
581  iter->first, iter->second, 1.0,
582  static_cast< int > (iter->first.size() + 3)
583  );
584  tr.Trace << " score energy from pose-cache: " << iter->first << " " << iter->second << std::endl;
585  silent_energies_.push_back( new_se );
586  }
587  } // if ( pose.data().has( CacheableDataType::ARBITRARY_FLOAT_DATA ) ) )
588 
589  // add comments from the Pose
590  using std::map;
591  using std::string;
592  map< string, string > comments = core::pose::get_all_comments( pose );
593  for ( map< string, string >::const_iterator it = comments.begin(),
594  end = comments.end(); it != end; ++it
595  ) {
596  add_comment( it->first, it->second );
597  }
598 
599  // add score_line_strings from Pose
600  map< string, string > score_line_strings(
602  );
603  for ( map< string, string >::const_iterator it = score_line_strings.begin(),
604  end = score_line_strings.end();
605  it != end; ++it
606  ) {
607  add_string_value( it->first, it->second );
608  }
609 
610 } // void energies_from_pose( core::pose::Pose const & pose )
611 
613  using namespace basic::options;
614  using namespace basic::options::OptionKeys;
615  using namespace core::pose::datacache;
616  using namespace core::scoring;
617  using std::string;
618  using utility::vector1;
619  // make sure that the pose has ARBITRARY_FLOAT_DATA in the DataCache
620  if ( !pose.data().has( ( CacheableDataType::ARBITRARY_FLOAT_DATA ) ) ){
621  pose.data().set(
622  CacheableDataType::ARBITRARY_FLOAT_DATA,
623  new basic::datacache::CacheableStringFloatMap()
624  );
625  }
626 
627  basic::datacache::CacheableStringFloatMapOP data
628  = dynamic_cast< basic::datacache::CacheableStringFloatMap * >
629  ( pose.data().get_raw_ptr(CacheableDataType::ARBITRARY_FLOAT_DATA) );
630 
631  runtime_assert( data.get() != NULL );
632 
633  EnergyMap weights;
634  EnergyMap & emap( pose.energies().total_energies() );
635 
636  string const input_score_prefix( option[ in::file::silent_score_prefix ]() );
637 
638 
639  std::set< string > wanted_scores;
640  if ( option[ in::file::silent_scores_wanted ].user() ) {
641  vector1< string > wanted = option[ in::file::silent_scores_wanted ]();
642  for ( vector1< string >::iterator it = wanted.begin(), end = wanted.end();
643  it != end; ++it
644  ) {
645  wanted_scores.insert( *it );
646  }
647  }
648 
649  typedef vector1< SilentEnergy > elist;
650  elist es = energies();
651  for ( elist::const_iterator it = es.begin(), end = es.end();
652  it != end; ++it
653  ) {
654  // only keep this score if we want it.
655  if ( wanted_scores.size() > 0 &&
656  wanted_scores.find(it->name()) == wanted_scores.end()
657  ) continue;
658 
659  // logic is:
660  // - if it->name() points to a ScoreType, put the value into the EnergyMap
661  // - otherwise, add the value to the Pose DataCache ARBITRARY_FLOAT_DATA
662  string const proper_name( input_score_prefix + it->name() );
663  if ( ScoreTypeManager::is_score_type( proper_name ) ) {
664  ScoreType sc_type( ScoreTypeManager::score_type_from_name( proper_name ) );
665  emap [ sc_type ] = it->value();
666  weights[ sc_type ] = it->weight();
667  } else if ( it->string_value() != "" ) {
668  tr.Trace << "add score line string : " << proper_name << " " << it->string_value() << std::endl;
670  pose, proper_name, it->string_value()
671  );
672  } else {
673  tr.Trace << "add score : " << proper_name << " " << it->value() << std::endl;
674  data->map()[ proper_name ] = it->value();
675  }
676  } // for silent_energies
677 
678  pose.energies().weights( weights );
679  pose.data().set( CacheableDataType::ARBITRARY_FLOAT_DATA, data );
680 
681  using std::map;
682  using std::string;
683  map< string, string > comments = get_all_comments();
684  for ( map< string, string >::const_iterator it = comments.begin(),
685  end = comments.end(); it != end; ++it
686  ) {
687  // only keep this score if we want it.
688  if ( wanted_scores.size() > 0 &&
689  wanted_scores.find(it->first) == wanted_scores.end()
690  ) continue;
691  string const proper_name( input_score_prefix + it->first );
692  core::pose::add_comment( pose, proper_name, it->second );
693  }
694 } // energies_into_pose
695 
698 
701  end = se.end(); it != end; ++it
702  ) {
703  names.push_back( it->name() );
704  }
705  EnergyNames enames;
706  enames.energy_names( names );
707  return enames;
708 }
709 
710 
712  using namespace std;
713 
714  static map< string, string > scorename_conversions;
715  static bool init( false );
716  if ( !init ) {
717  scorename_conversions["cb"] = "cbeta";
718  scorename_conversions["hs"] = "hs_pair";
719  scorename_conversions["ss"] = "ss_pair";
720  }
721 
722  // iterate over the silent-file energies, convert them when appropriate.
723  map< string, string >::const_iterator conv_it,
724  conv_end( scorename_conversions.end() );
726  end = silent_energies_.end(); it != end; ++it
727  ) {
728  conv_it = scorename_conversions.find( it->name() );
729  if ( conv_it != conv_end ) {
730  it->name( conv_it->second );
731  }
732  }
733 } // rename_energies
734 
736  const core::pose::Pose & pose
737 ) {
738  using namespace core::pose::datacache;
739  std::string tag( "empty_tag" );
740  if ( pose.data().has( CacheableDataType::JOBDIST_OUTPUT_TAG ) ) {
741  tag =
742  static_cast< basic::datacache::CacheableString const & >
743  ( pose.data().get( CacheableDataType::JOBDIST_OUTPUT_TAG ) ).str();
744  }
745  decoy_tag(tag);
746 }
747 
748 //void
749 //SilentStruct::print_sequence( bool print_seq ) {
750 // print_sequence_ = print_seq;
751 //}
752 //
753 //bool SilentStruct::print_sequence() const {
754 // return print_sequence_;
755 //}
756 
757 void
760 }
761 
763  return precision_;
764 }
765 
766 void
768 {
769  scoreline_prefix_ = prefix;
770 }
771 
773  return scoreline_prefix_;
774 }
775 
778  return sequence().one_letter_sequence();
779 }
780 /*
781  //using core::pose::annotated_to_oneletter_sequence;
782  //return core::pose::annotated_to_oneletter_sequence( sequence () );
783  std::string annotated_seq = sequence();
784  std::string sequence("");
785  bool in_bracket = false;
786  for ( Size i = 0, ie = annotated_seq.length(); i < ie; ++i ) {
787  char c = annotated_seq[i];
788  if ( c == '[' ) {
789  in_bracket = true;
790  continue;
791  } else if ( c == ']' ) {
792  in_bracket = false;
793  continue;
794  } else {
795  if ( in_bracket ) {
796  continue;
797  } else {
798  sequence = sequence + c;
799  }
800  }
801  }
802  runtime_assert( ! in_bracket );
803  return sequence;
804 }
805 */
806 
807 ///@ brief helper to detect fullatom input
808 ///@ detail
809 //* removing dependendence from input flag -in:file:Fullatom which made no sense, since reading inconsistent
810 //* will break anyhow... moreover the test was wrong before: GLY and ALA have 7 or 10 atoms respectively.
811 // strategy to dectet fullatom-ness now:
812 // look only at unpatched residues -- check for protein...
813 // (no modification in annotated sequence )
814 //
815 // centroid: GLY 6 atoms, all others 7 atoms
816 // centroid_HA patch: +1 (without showing up as "patched" residue in annotated sequence... )
817 // -> natoms>=9 on unpatched proteins residue should indicate fullatom
818 // if it remains unclear --> use the cmd-line flag to determine fullatom-ness...
819 //
820 void SilentStruct::detect_fullatom( core::Size pos, core::Size natoms, bool& fullatom, bool& well_defined ) {
821  if ( sequence().is_patched( pos ) ) return;
822  if ( sequence().aa( pos ) > core::chemical::num_canonical_aas ) return;
823  // if ( well_defined ) return; // no more checks necessary
824  //okay an unpatched regular aminoacid
825  if ( natoms <= 6 ) {
826  well_defined=true;
827  fullatom=false;
828  tr.Debug << "found less than 7 atoms on " << sequence().one_letter( pos ) << " switch to centroid mode" << std::endl;
829  } else if ( natoms>=9 ) {
830  tr.Debug << "found " << natoms << " atoms (more than 8) on " << sequence().one_letter( pos ) << " switch to fullatom mode" << std::endl;
831  well_defined=true;
832  fullatom=true;
833  }
834 }
835 
836 
837 ///////////////////////////////////////////////////////////////////////////
838 void
839 SilentStruct::print_parent_remarks( std::ostream & out ) const {
840  using std::map;
841  using std::string;
842  string const remark( "PARENT REMARK" );
843 
844  typedef map< string, string >::const_iterator c_iter;
845  for ( c_iter it = parent_remarks_map_.begin(), end = parent_remarks_map_.end(); it != end; ++it) {
846  out << remark << ' ' << it->first << ' ' << it->second << std::endl;
847  }
848 }
849 
850 ///////////////////////////////////////////////////////////////////////////
851 
854 
855  if(parent_remarks_map_.count(name)==0) utility_exit_with_message( "The key (" + name +") doesn't exist in the parent_remarks_map_!");
856 
857  std::map< std::string, std::string >::const_iterator entry= parent_remarks_map_.find( name );
858 
859  if ( entry == parent_remarks_map_.end() ) {
860  utility_exit_with_message( "entry == parent_remarks_map_.end() for the the key (" + name +").");
861  }
862 
863  std::string const parent_remark = entry->second;
864 
865  return parent_remark;
866 }
867 
868 ///////////////////////////////////////////////////////////////////////////
869 bool SilentStruct::has_parent_remark( std::string const & name ) const {
870  return ( parent_remarks_map_.find( name ) != parent_remarks_map_.end() );
871 }
872 
873 ///////////////////////////////////////////////////////////////////////////
874 
875 void
877 
878  // if(parent_remarks_map_.count(name)>0) utility_exit_with_message( "The key (" + name +") already exist in the parent_remarks_map_!");
879 
880  if(parent_remarks_map_.count(name)>0) {
881  tr << "The key (" + name +") already exist in the parent_remarks_map_!";
882  } else {
883  parent_remarks_map_.insert( std::make_pair( name, value ) );
884  }
885 
886 }
887 ///////////////////////////////////////////////////////////////////////////
888 
889 void
891 
892  std::istringstream line_stream( line );
893 
894  std::string key, val, remark_tag;
895  line_stream >> remark_tag;
896  line_stream >> key;
897  line_stream >> val;
898 
899  if ( line_stream.fail() ) utility_exit_with_message("[ERROR] reading REMARK from line: " + line );
900 
901  if(remark_tag!="REMARK") utility_exit_with_message(remark_tag!="REMARK"); //Extra precaution!
902 
903  std::string dummy;
904 
905  line_stream >> dummy;
906  while( line_stream.good() ) {
907  std::cout << "Extra characters in REMARK LINE!" << std::endl;
908  std::cout << "remark_tag= " << remark_tag << std::endl;
909  std::cout << "key= " << key << std::endl;
910  std::cout << "val= " << val << std::endl;
911  std::cout << "dummy= " << dummy << std::endl;
912  utility_exit_with_message("Extra characters in REMARK LINE!");
913  }
914 
915  add_parent_remark( key, val );
916 }
917 ///////////////////////////////////////////////////////////////////////////
918 
919 } // namespace silent
920 } // namespace io
921 } // namespace core