diff --git a/sidechain/src/bb_dep_rotamer_lib.cc b/sidechain/src/bb_dep_rotamer_lib.cc index 8637c35a5ef229e9ab0b6060962465df776ac536..357a5ce25858d3006f9c69364a11b2c08e2a2798 100644 --- a/sidechain/src/bb_dep_rotamer_lib.cc +++ b/sidechain/src/bb_dep_rotamer_lib.cc @@ -133,10 +133,7 @@ void BBDepRotamerLib::Save(const String& filename){ } out_stream.write(reinterpret_cast<char*>(&total_num_rotamers_),sizeof(uint64_t)); - for(uint i = 0; i < total_num_rotamers_; ++i){ - out_stream << static_data_[i]; - } - + out_stream.write(reinterpret_cast<char*>(&static_data_[0]),total_num_rotamers_ * sizeof(RotamerLibEntry)); out_stream.close(); } @@ -198,10 +195,8 @@ BBDepRotamerLibPtr BBDepRotamerLib::Load(const String& filename){ in_stream.read(reinterpret_cast<char*>(&p->total_num_rotamers_),sizeof(uint64_t)); p->static_data_ = new RotamerLibEntry[p->total_num_rotamers_]; - for(uint i = 0; i < p->total_num_rotamers_; ++i){ - in_stream >> p->static_data_[i]; - } - in_stream.close(); + in_stream.read(reinterpret_cast<char*>(&p->static_data_[0]),p->total_num_rotamers_ * sizeof(RotamerLibEntry)); + return p; } diff --git a/sidechain/src/rotamer_lib.cc b/sidechain/src/rotamer_lib.cc index c6bd203c80791f9e274bc0b6574e74a9f489072e..4e2a567ac74752062e3bde01e6e4e650e3fd6159 100644 --- a/sidechain/src/rotamer_lib.cc +++ b/sidechain/src/rotamer_lib.cc @@ -57,9 +57,7 @@ void RotamerLib::Save(const String& filename){ } out_stream.write(reinterpret_cast<char*>(&total_num_rotamers_),sizeof(uint64_t)); - for(uint i = 0; i < total_num_rotamers_; ++i){ - out_stream << static_data_[i]; - } + out_stream.write(reinterpret_cast<char*>(&static_data_[0]),total_num_rotamers_ * sizeof(RotamerLibEntry)); out_stream.close(); } @@ -112,9 +110,7 @@ RotamerLibPtr RotamerLib::Load(const String& filename){ in_stream.read(reinterpret_cast<char*>(&p->total_num_rotamers_),sizeof(uint64_t)); p->static_data_ = new RotamerLibEntry[p->total_num_rotamers_]; - for(uint i = 0; i < p->total_num_rotamers_; ++i){ - in_stream >> p->static_data_[i]; - } + in_stream.read(reinterpret_cast<char*>(&p->static_data_[0]),p->total_num_rotamers_ * sizeof(RotamerLibEntry)); in_stream.close(); return p; } diff --git a/sidechain/src/rotamer_lib_entry.hh b/sidechain/src/rotamer_lib_entry.hh index 31e271ca751db93b310d8664558d4589254e0e81..7e8afd80771dbd5e55b40fc6572efacc2bfa42e2 100644 --- a/sidechain/src/rotamer_lib_entry.hh +++ b/sidechain/src/rotamer_lib_entry.hh @@ -69,18 +69,6 @@ struct RotamerLibEntry{ bool SimilarDihedral(RotamerLibEntryPtr other, uint dihedral_idx, Real thresh, const String& res_name); - friend std::ofstream& operator<<(std::ofstream& os, RotamerLibEntry& entry){ - //assumes all variables being in memory in a consecutive order... - os.write(reinterpret_cast<char*>(&entry.probability),9*sizeof(Real)); - return os; - } - - friend std::ifstream& operator>>(std::ifstream& is, RotamerLibEntry& entry){ - //assumes all variables being in memory in a consecutive order... - is.read(reinterpret_cast<char*>(&entry.probability),9*sizeof(Real)); - return is; - } - // portable serialization // (cleanly element by element with fixed-width base-types) template <typename DS>