Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MultiStateEntity.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 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file MultiStateEntity.hh
11 /// @brief
12 /// @author Colin A. Smith
13 
14 // Unit headers
16 
19 
20 #include <core/types.hh>
21 #include <basic/MetricValue.hh>
22 
23 // Utility Headers
24 #include <utility/pointer/ReferenceCount.hh>
25 
26 // ObjexxFCL Headers
27 #include <ObjexxFCL/format.hh>
28 
29 // C++ Headers
30 #include <map>
31 
32 #include <utility/vector1.hh>
33 
34 
35 
36 namespace protocols {
37 namespace multistate_design {
38 
39 MultiStateEntity::MultiStateEntity() : protocols::genetic_algorithm::Entity() {}
40 
42  protocols::genetic_algorithm::Entity(entity),
43  single_state_entity_data_(entity.single_state_entity_data())
44 {}
45 
47 
49 MultiStateEntity::clone() const { return new MultiStateEntity(*this); }
50 
51 void MultiStateEntity::show( std::ostream & os ) const
52 {
53  using namespace ObjexxFCL::fmt;
54 
55  os << "MultiStateEntity with traits:";
56  genetic_algorithm::EntityElements const & seq( this->traits() );
57  for ( genetic_algorithm::EntityElements::const_iterator
58  it( seq.begin() ), end( seq.end() );
59  it != end; ++it ) {
60  os << " " << (*it)->to_string();
61  }
62  os << " and fitness " << F(6,3,this->fitness());
63  for (core::Size i = 1; i <= single_state_entity_data_.size(); ++i) {
64  os << '\n' << " SingleState " << i << " with fitness: " << single_state_entity_data_[i].fitness();
65  }
66 }
67 
68 
69 void
71  std::ostream & os
72 ) const
73 {
75 
76  os << " states " << single_state_entity_data_.size();
77  for (core::Size i = 1; i <= single_state_entity_data_.size(); ++i) {
78  os << "\n ";
79  single_state_entity_data_[i].write_checkpoint(os);
80  }
81 }
82 
83 bool
85  std::istream & is
86 )
87 {
89 
90  std::string word;
91  if (!(is >> word)) return false;
92  if (word != "states") return false;
93 
94  core::Size num_states;
95  if (!(is >> num_states)) return false;
96  single_state_entity_data_.resize(num_states);
97 
98  for (core::Size i = 1; i <= single_state_entity_data_.size(); ++i) {
99  if (!single_state_entity_data_[i].read_checkpoint(is)) return false;
100  }
101 
102  return true;
103 }
104 
107 
110 
111 
112 } // namespace multistate_design
113 } // namespace protocols
114