From 2c14a4a91a076063bce0ffcb974f5fb0356f52e7 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Wed, 24 Mar 2021 12:35:48 +0100
Subject: [PATCH] reduce code duplication and use PagedArray from ost

---
 loop/src/CMakeLists.txt  |  1 -
 loop/src/frag_db.cc      |  2 +-
 loop/src/frag_db.hh      |  1 -
 loop/src/fragger.cc      | 14 +++++++-------
 loop/src/fragger.hh      |  2 +-
 loop/src/structure_db.hh | 34 +++++++++++++++++-----------------
 6 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/loop/src/CMakeLists.txt b/loop/src/CMakeLists.txt
index 6c874f58..39da6810 100644
--- a/loop/src/CMakeLists.txt
+++ b/loop/src/CMakeLists.txt
@@ -17,7 +17,6 @@ set(LOOP_HEADERS
   idx_handler.hh
   loop_object_loader.hh
   mm_system_creator.hh
-  paged_array.hh
   psipred_prediction.hh
   stem_geom.hh
   structure_db.hh
diff --git a/loop/src/frag_db.cc b/loop/src/frag_db.cc
index 4e0bfdd7..8467f5cc 100644
--- a/loop/src/frag_db.cc
+++ b/loop/src/frag_db.cc
@@ -258,7 +258,7 @@ void FragDB::AddFragments(uint fragment_length,
 
     //extract all stem information of this chain to create the
     //stem geoms later on
-    const PagedArray<PeptideCoords, 65536>& db_coords = structure_db->GetCoords();
+    const ost::PagedArray<PeptideCoords, 65536>& db_coords = structure_db->GetCoords();
     stem_coords.clear();
     for(uint j = 0; j < size; ++j){
       const PeptideCoords& coords = db_coords[offset + j];
diff --git a/loop/src/frag_db.hh b/loop/src/frag_db.hh
index 8deb7b19..75195312 100644
--- a/loop/src/frag_db.hh
+++ b/loop/src/frag_db.hh
@@ -28,7 +28,6 @@
 #include <ost/mol/entity_view.hh>
 #include <ost/mol/mol.hh>
 
-#include <promod3/loop/paged_array.hh>
 #include <promod3/loop/data_bag.hh>
 #include <promod3/loop/ushort_vec.hh>
 #include <promod3/loop/structure_db.hh>
diff --git a/loop/src/fragger.cc b/loop/src/fragger.cc
index 7f5ed5d1..fa1054ed 100644
--- a/loop/src/fragger.cc
+++ b/loop/src/fragger.cc
@@ -500,14 +500,14 @@ void Fragger::FillProfiles(StructureDBPtr db,
         break;
       }
       case SequenceProfile:{
-        const PagedArray<AAFreq, 65536>& frequencies = 
+        const ost::PagedArray<AAFreq, 65536>& frequencies = 
         db->GetAAFrequencies();
         this->GenerateProfileProfile(db, profiles[i], chain_idx, frequencies, 
                                      profiles_[i]);
         break;
       }
       case StructureProfile:{
-        const PagedArray<AAFreq, 65536>& frequencies = 
+        const ost::PagedArray<AAFreq, 65536>& frequencies = 
         db->GetAAStructFrequencies();        
         this->GenerateProfileProfile(db, profiles[i], chain_idx, frequencies, 
                                      profiles_[i]);
@@ -553,7 +553,7 @@ void Fragger::GenerateSeqSimProfile(StructureDBPtr db,
                           const ost::seq::alg::SubstWeightMatrix& subst) const{
 
   const std::vector<CoordInfo>& coord_toc = db->GetCoordToc();
-  const PagedArray<char, 65536>& full_db_seq = db->GetSeq();
+  const ost::PagedArray<char, 65536>& full_db_seq = db->GetSeq();
 
   profile.clear();
 
@@ -591,7 +591,7 @@ void Fragger::GenerateSeqIDProfile(StructureDBPtr db,
                                    uint index) const{
 
   const std::vector<CoordInfo>& coord_toc = db->GetCoordToc();
-  const PagedArray<char, 65536>& full_db_seq = db->GetSeq();
+  const ost::PagedArray<char, 65536>& full_db_seq = db->GetSeq();
 
   profile.clear();
 
@@ -622,7 +622,7 @@ void Fragger::GenerateSSAgreementProfile(StructureDBPtr db,
                               const std::vector<int>& confidence) const {
 
   const std::vector<CoordInfo>& coord_toc = db->GetCoordToc();
-  const PagedArray<char, 65536>& full_db_dssp = db->GetDSSP();
+  const ost::PagedArray<char, 65536>& full_db_dssp = db->GetDSSP();
 
   profile.clear();
 
@@ -658,7 +658,7 @@ void Fragger::GenerateTorsionProbabilityProfile(StructureDBPtr db,
                               const std::vector<int>& t_sampler_indices) const {
 
   const std::vector<CoordInfo>& coord_toc = db->GetCoordToc();
-  const PagedArray<DihedralInfo, 65536>& full_db_dihedrals = db->GetDihedrals();
+  const ost::PagedArray<DihedralInfo, 65536>& full_db_dihedrals = db->GetDihedrals();
 
   profile.clear();
 
@@ -693,7 +693,7 @@ void Fragger::GenerateTorsionProbabilityProfile(StructureDBPtr db,
 void Fragger::GenerateProfileProfile(StructureDBPtr db,
                                      std::vector<Real>& profile,
                                      uint index,
-                                     const PagedArray<AAFreq,65536>& frequencies,
+                                     const ost::PagedArray<AAFreq,65536>& frequencies,
                                      short** prof) const {
 
   const std::vector<CoordInfo>& coord_toc = db->GetCoordToc();
diff --git a/loop/src/fragger.hh b/loop/src/fragger.hh
index dfe545f4..205f10dc 100644
--- a/loop/src/fragger.hh
+++ b/loop/src/fragger.hh
@@ -134,7 +134,7 @@ private:
 
   void GenerateProfileProfile(StructureDBPtr db, std::vector<Real>& profile,
                               uint index,
-                              const PagedArray<AAFreq, 65536>& frequencies,
+                              const ost::PagedArray<AAFreq, 65536>& frequencies,
                               short** prof) const;
 
 
diff --git a/loop/src/structure_db.hh b/loop/src/structure_db.hh
index 89395b36..075d0a3f 100644
--- a/loop/src/structure_db.hh
+++ b/loop/src/structure_db.hh
@@ -24,6 +24,7 @@
 #include <list>
 
 #include <ost/base.hh>
+#include <ost/paged_array.hh>
 #include <ost/fixed_string.hh>
 #include <ost/mol/entity_view.hh>
 #include <ost/mol/mol.hh>
@@ -34,7 +35,6 @@
 #include <ost/seq/profile_handle.hh>
 #include <ost/mol/surface_handle.hh>
 
-#include <promod3/loop/paged_array.hh>
 #include <promod3/loop/backbone.hh>
 #include <promod3/core/message.hh>
 #include <promod3/core/superpose.hh>
@@ -249,15 +249,15 @@ public:
 
   const std::vector<CoordInfo>& GetCoordToc() const { return coord_toc_; }
 
-  const PagedArray<char, 65536>& GetSeq() const { 
+  const ost::PagedArray<char, 65536>& GetSeq() const { 
     return seq_; 
   } 
 
-  const PagedArray<PeptideCoords, 65536>& GetCoords() const { 
+  const ost::PagedArray<PeptideCoords, 65536>& GetCoords() const { 
     return coords_; 
   }
 
-  const PagedArray<DihedralInfo, 65536>& GetDihedrals() const {
+  const ost::PagedArray<DihedralInfo, 65536>& GetDihedrals() const {
 
     if(!this->HasData(Dihedrals)) {
       throw promod3::Error("StructureDB does not contain dihedrals!");
@@ -266,7 +266,7 @@ public:
     return dihedrals_; 
   }
 
-  const PagedArray<unsigned short, 65536>& GetSolvAcc() const {
+  const ost::PagedArray<unsigned short, 65536>& GetSolvAcc() const {
 
     if(!this->HasData(SolventAccessibilities)) {
       throw promod3::Error("StructureDB does not contain "
@@ -276,7 +276,7 @@ public:
     return solv_acc_;
   }
 
-  const PagedArray<unsigned short, 65536>& GetResDepth() const {
+  const ost::PagedArray<unsigned short, 65536>& GetResDepth() const {
 
     if(!this->HasData(ResidueDepths)) {
       throw promod3::Error("StructureDB does not contain residue depths!");
@@ -285,7 +285,7 @@ public:
     return res_depths_;
   }
 
-  const PagedArray<char, 65536>& GetDSSP() const {
+  const ost::PagedArray<char, 65536>& GetDSSP() const {
 
     if(!this->HasData(DSSP)) {
       throw promod3::Error("StructureDB does not contain dssp assignments!");
@@ -294,7 +294,7 @@ public:
     return dssp_;
   } 
 
-  const PagedArray<AAFreq, 65536>& GetAAFrequencies() const { 
+  const ost::PagedArray<AAFreq, 65536>& GetAAFrequencies() const { 
 
     if(!this->HasData(AAFrequencies)) {
       throw promod3::Error("StructureDB does not contain amino acid "
@@ -304,7 +304,7 @@ public:
     return aa_frequencies_; 
   }
 
-  const PagedArray<AAFreq, 65536>& GetAAStructFrequencies() const {
+  const ost::PagedArray<AAFreq, 65536>& GetAAStructFrequencies() const {
 
     if(!this->HasData(AAFrequenciesStruct)) {
       throw promod3::Error("StructureDB does not contain amino acid " 
@@ -336,30 +336,30 @@ private:
   std::vector<CoordInfo>            coord_toc_;
 
   // one letter codes
-  PagedArray<char, 65536>           seq_;
+  ost::PagedArray<char, 65536>           seq_;
 
   // backbone coordinates
-  PagedArray<PeptideCoords, 65536>  coords_;
+  ost::PagedArray<PeptideCoords, 65536>  coords_;
 
   // phi and psi dihedrals
-  PagedArray<DihedralInfo, 65536>   dihedrals_;    
+  ost::PagedArray<DihedralInfo, 65536>   dihedrals_;    
 
   // solvent accessibility in A^2 as calculated by Lee & Richards implementation 
   // in ost
-  PagedArray<uint16_t, 65536> solv_acc_;      
+  ost::PagedArray<uint16_t, 65536> solv_acc_;      
 
   // distance towards closest surface residue in A multiplied by 10 to allow
   // accuracy of 0.1
-  PagedArray<uint16_t, 65536> res_depths_;   
+  ost::PagedArray<uint16_t, 65536> res_depths_;   
                     
   // dssp state, which is a member of {H,B,E,G,I,T,S}  
-  PagedArray<char, 65536>           dssp_;
+  ost::PagedArray<char, 65536>           dssp_;
 
   // Amino acid frequencies as given as input profile
-  PagedArray<AAFreq, 65536>         aa_frequencies_;
+  ost::PagedArray<AAFreq, 65536>         aa_frequencies_;
 
   // Amino acid frequencies as derived from structural information
-  PagedArray<AAFreq, 65536>         aa_frequencies_struct_;
+  ost::PagedArray<AAFreq, 65536>         aa_frequencies_struct_;
 };
 
 }}
-- 
GitLab