Skip to content
Snippets Groups Projects
Commit c0c46ec3 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

make saving/loading or rotamer libraries faster

parent f4a33960
No related branches found
No related tags found
No related merge requests found
...@@ -133,10 +133,7 @@ void BBDepRotamerLib::Save(const String& filename){ ...@@ -133,10 +133,7 @@ void BBDepRotamerLib::Save(const String& filename){
} }
out_stream.write(reinterpret_cast<char*>(&total_num_rotamers_),sizeof(uint64_t)); out_stream.write(reinterpret_cast<char*>(&total_num_rotamers_),sizeof(uint64_t));
for(uint i = 0; i < total_num_rotamers_; ++i){ out_stream.write(reinterpret_cast<char*>(&static_data_[0]),total_num_rotamers_ * sizeof(RotamerLibEntry));
out_stream << static_data_[i];
}
out_stream.close(); out_stream.close();
} }
...@@ -198,10 +195,8 @@ BBDepRotamerLibPtr BBDepRotamerLib::Load(const String& filename){ ...@@ -198,10 +195,8 @@ BBDepRotamerLibPtr BBDepRotamerLib::Load(const String& filename){
in_stream.read(reinterpret_cast<char*>(&p->total_num_rotamers_),sizeof(uint64_t)); in_stream.read(reinterpret_cast<char*>(&p->total_num_rotamers_),sizeof(uint64_t));
p->static_data_ = new RotamerLibEntry[p->total_num_rotamers_]; p->static_data_ = new RotamerLibEntry[p->total_num_rotamers_];
for(uint i = 0; i < p->total_num_rotamers_; ++i){ in_stream.read(reinterpret_cast<char*>(&p->static_data_[0]),p->total_num_rotamers_ * sizeof(RotamerLibEntry));
in_stream >> p->static_data_[i];
}
in_stream.close();
return p; return p;
} }
... ...
......
...@@ -57,9 +57,7 @@ void RotamerLib::Save(const String& filename){ ...@@ -57,9 +57,7 @@ void RotamerLib::Save(const String& filename){
} }
out_stream.write(reinterpret_cast<char*>(&total_num_rotamers_),sizeof(uint64_t)); out_stream.write(reinterpret_cast<char*>(&total_num_rotamers_),sizeof(uint64_t));
for(uint i = 0; i < total_num_rotamers_; ++i){ out_stream.write(reinterpret_cast<char*>(&static_data_[0]),total_num_rotamers_ * sizeof(RotamerLibEntry));
out_stream << static_data_[i];
}
out_stream.close(); out_stream.close();
} }
...@@ -112,9 +110,7 @@ RotamerLibPtr RotamerLib::Load(const String& filename){ ...@@ -112,9 +110,7 @@ RotamerLibPtr RotamerLib::Load(const String& filename){
in_stream.read(reinterpret_cast<char*>(&p->total_num_rotamers_),sizeof(uint64_t)); in_stream.read(reinterpret_cast<char*>(&p->total_num_rotamers_),sizeof(uint64_t));
p->static_data_ = new RotamerLibEntry[p->total_num_rotamers_]; p->static_data_ = new RotamerLibEntry[p->total_num_rotamers_];
for(uint i = 0; i < p->total_num_rotamers_; ++i){ in_stream.read(reinterpret_cast<char*>(&p->static_data_[0]),p->total_num_rotamers_ * sizeof(RotamerLibEntry));
in_stream >> p->static_data_[i];
}
in_stream.close(); in_stream.close();
return p; return p;
} }
... ...
......
...@@ -69,18 +69,6 @@ struct RotamerLibEntry{ ...@@ -69,18 +69,6 @@ struct RotamerLibEntry{
bool SimilarDihedral(RotamerLibEntryPtr other, uint dihedral_idx, bool SimilarDihedral(RotamerLibEntryPtr other, uint dihedral_idx,
Real thresh, const String& res_name); 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 // portable serialization
// (cleanly element by element with fixed-width base-types) // (cleanly element by element with fixed-width base-types)
template <typename DS> template <typename DS>
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment