From c7622c5eb386b3c9ec934c2606b832e40c34be40 Mon Sep 17 00:00:00 2001
From: Rafal Gumienny <guma44@gmail.com>
Date: Thu, 22 Feb 2018 13:51:18 +0100
Subject: [PATCH] fix: SCHWED-3126 Successful compilation and pymod import

---
 modules/conop/pymod/CMakeLists.txt            |  1 -
 modules/conop/pymod/wrap_conop.cc             |  2 --
 modules/conop/src/CMakeLists.txt              |  4 +---
 modules/mol/alg/pymod/CMakeLists.txt          |  1 +
 .../alg}/pymod/export_non_standard.cc         |  4 ++--
 modules/mol/alg/pymod/wrap_mol_alg.cc         |  2 ++
 modules/mol/alg/src/CMakeLists.txt            |  4 +++-
 modules/mol/alg/src/molck.cc                  |  4 ++--
 modules/mol/alg/src/molck.hh                  | 10 +++++++---
 modules/mol/alg/src/nonstandard.cc            |  4 ++--
 modules/mol/alg/src/nonstandard.hh            | 15 ++++++++------
 tools/molck/CMakeLists.txt                    |  2 +-
 tools/molck/main.cc                           | 20 +++++++++----------
 13 files changed, 39 insertions(+), 34 deletions(-)
 rename modules/{conop => mol/alg}/pymod/export_non_standard.cc (96%)

diff --git a/modules/conop/pymod/CMakeLists.txt b/modules/conop/pymod/CMakeLists.txt
index 9c0990622..23dff26a0 100644
--- a/modules/conop/pymod/CMakeLists.txt
+++ b/modules/conop/pymod/CMakeLists.txt
@@ -8,7 +8,6 @@ set(OST_CONOP_PYMOD_SOURCES
   export_conop.cc
   export_diag.cc
   export_rule_based.cc
-  export_non_standard.cc
   export_ring_finder.cc
 )
 
diff --git a/modules/conop/pymod/wrap_conop.cc b/modules/conop/pymod/wrap_conop.cc
index 119c86c32..04bcfce14 100644
--- a/modules/conop/pymod/wrap_conop.cc
+++ b/modules/conop/pymod/wrap_conop.cc
@@ -25,7 +25,6 @@ void export_Sanitizer();
 void export_Conop();
 void export_RingFinder();
 void export_AminoAcids();
-void export_NonStandard();
 void export_processor();
 void export_rule_based();
 void export_heuristic();
@@ -41,6 +40,5 @@ BOOST_PYTHON_MODULE(_ost_conop)
   export_Compound();
   export_RingFinder();
   export_AminoAcids();
-  export_NonStandard();
   export_diag();
 }
diff --git a/modules/conop/src/CMakeLists.txt b/modules/conop/src/CMakeLists.txt
index 0185618ea..c2f1f4c6d 100644
--- a/modules/conop/src/CMakeLists.txt
+++ b/modules/conop/src/CMakeLists.txt
@@ -9,7 +9,6 @@ compound.hh
 compound_lib.hh
 module_config.hh
 rule_based.hh
-nonstandard.hh
 minimal_compound_lib.hh
 compound_lib_base.hh
 ring_finder.hh
@@ -27,12 +26,11 @@ rule_based.cc
 model_check.cc
 compound.cc
 compound_lib.cc
-nonstandard.cc
 ring_finder.cc
 )
 
 module(NAME conop SOURCES ${OST_CONOP_SOURCES}
-       HEADERS ${OST_CONOP_HEADERS} DEPENDS_ON ost_mol ost_mol_alg ost_geom ost_db)
+       HEADERS ${OST_CONOP_HEADERS} DEPENDS_ON ost_mol ost_geom ost_db)
 
 
 if (WIN32)
diff --git a/modules/mol/alg/pymod/CMakeLists.txt b/modules/mol/alg/pymod/CMakeLists.txt
index 612caccfb..5519c6adf 100644
--- a/modules/mol/alg/pymod/CMakeLists.txt
+++ b/modules/mol/alg/pymod/CMakeLists.txt
@@ -7,6 +7,7 @@ set(OST_MOL_ALG_PYMOD_SOURCES
   export_contact_overlap.cc
   export_accessibility.cc
   export_sec_structure.cc
+  export_non_standard.cc
   export_molck.cc
 )
 
diff --git a/modules/conop/pymod/export_non_standard.cc b/modules/mol/alg/pymod/export_non_standard.cc
similarity index 96%
rename from modules/conop/pymod/export_non_standard.cc
rename to modules/mol/alg/pymod/export_non_standard.cc
index 50b1fd2d6..8d485b169 100644
--- a/modules/conop/pymod/export_non_standard.cc
+++ b/modules/mol/alg/pymod/export_non_standard.cc
@@ -18,11 +18,11 @@
 //------------------------------------------------------------------------------
 #include <boost/python.hpp>
 #include <ost/mol/mol.hh>
-#include <ost/conop/nonstandard.hh>
+#include <ost/mol/alg/nonstandard.hh>
 
 using namespace boost::python;
 
-using namespace ost::conop;
+using namespace ost::mol::alg;
 using namespace ost::mol;
                    
 object copy_conserved_handle(ResidueHandle src_res, ResidueHandle dst_res,
diff --git a/modules/mol/alg/pymod/wrap_mol_alg.cc b/modules/mol/alg/pymod/wrap_mol_alg.cc
index b90ab2bef..f32e3256f 100644
--- a/modules/mol/alg/pymod/wrap_mol_alg.cc
+++ b/modules/mol/alg/pymod/wrap_mol_alg.cc
@@ -39,6 +39,7 @@ void export_svdSuperPose();
 void export_TrajectoryAnalysis();
 void export_StructureAnalysis();
 void export_Clash();
+void export_NonStandard();
 void export_Molck();
 void export_contact_overlap();
 void export_accessibility();
@@ -111,6 +112,7 @@ BOOST_PYTHON_MODULE(_ost_mol_alg)
   export_TrajectoryAnalysis();
   export_StructureAnalysis();
   export_Clash();
+  export_NonStandard();
   export_Molck();
   export_contact_overlap();
   export_accessibility();
diff --git a/modules/mol/alg/src/CMakeLists.txt b/modules/mol/alg/src/CMakeLists.txt
index 8049b99a9..ef2ae22ae 100644
--- a/modules/mol/alg/src/CMakeLists.txt
+++ b/modules/mol/alg/src/CMakeLists.txt
@@ -20,6 +20,7 @@ set(OST_MOL_ALG_HEADERS
   similarity_matrix.hh
   accessibility.hh
   sec_struct.hh
+  nonstandard.hh
   molck.hh
 )
 
@@ -44,6 +45,7 @@ set(OST_MOL_ALG_SOURCES
   similarity_matrix.cc
   accessibility.cc
   sec_struct.cc
+  nonstandard.cc
   molck.cc
 )
 
@@ -60,7 +62,7 @@ if (ENABLE_IMG)
     entity_to_density.cc
   )
 
-  set(MOL_ALG_DEPS ${MOL_ALG_DEPS} ost_img ost_img_alg ost_seq_alg)
+  set(MOL_ALG_DEPS ${MOL_ALG_DEPS} ost_img ost_img_alg ost_seq_alg ost_conop)
 endif()
 
 executable(NAME lddt SOURCES lddt.cc 
diff --git a/modules/mol/alg/src/molck.cc b/modules/mol/alg/src/molck.cc
index df931f8ed..0667275af 100644
--- a/modules/mol/alg/src/molck.cc
+++ b/modules/mol/alg/src/molck.cc
@@ -1,7 +1,7 @@
 #include <ost/mol/xcs_editor.hh>
+#include <ost/mol/alg/nonstandard.hh>
 #include <ost/conop/model_check.hh>
 #include <ost/conop/amino_acids.hh>
-#include <ost/conop/nonstandard.hh>
 #include <ost/mol/alg/molck.hh>
 
 using namespace ost::conop;
@@ -36,7 +36,7 @@ EntityHandle ost::mol::alg::MapNonStandardResidues(EntityHandle& ent, CompoundLi
            continue;
         } 
         ResidueHandle dest_res = new_edi.AppendResidue(new_chain,OneLetterCodeToResidueName(compound->GetOneLetterCode()),r->GetNumber());
-        CopyResidue(*r,dest_res,new_edi,lib);
+        ost::mol::alg::CopyResidue(*r,dest_res,new_edi,lib);
       }   
     }        
   }
diff --git a/modules/mol/alg/src/molck.hh b/modules/mol/alg/src/molck.hh
index 1034602e7..d7e4b65d2 100644
--- a/modules/mol/alg/src/molck.hh
+++ b/modules/mol/alg/src/molck.hh
@@ -27,7 +27,8 @@ struct MolckSettings{
 
 };
 
-ost::mol::EntityHandle MapNonStandardResidues(ost::mol::EntityHandle& ent, ost::conop::CompoundLibPtr lib);
+ost::mol::EntityHandle MapNonStandardResidues(ost::mol::EntityHandle& ent,
+                                              ost::conop::CompoundLibPtr lib);
 
 void RemoveAtoms(ost::mol::EntityHandle& ent,
                  ost::conop::CompoundLibPtr lib,
@@ -38,9 +39,12 @@ void RemoveAtoms(ost::mol::EntityHandle& ent,
                  bool rm_zero_occ_atoms,
                  bool colored=true);
 
-void CleanUpElementColumn(ost::mol::EntityHandle& ent, ost::conop::CompoundLibPtr lib);
+void CleanUpElementColumn(ost::mol::EntityHandle& ent,
+                          ost::conop::CompoundLibPtr lib);
 
-void Molck(ost::mol::EntityHandle& ent, ost::conop::CompoundLibPtr lib, const MolckSettings& settings);
+void Molck(ost::mol::EntityHandle& ent,
+           ost::conop::CompoundLibPtr lib,
+           const MolckSettings& settings);
 
 
 }}} // namespace
diff --git a/modules/mol/alg/src/nonstandard.cc b/modules/mol/alg/src/nonstandard.cc
index eaf06680d..b51c582ad 100644
--- a/modules/mol/alg/src/nonstandard.cc
+++ b/modules/mol/alg/src/nonstandard.cc
@@ -32,7 +32,7 @@ using namespace ost::mol;
 using namespace ost;
 using namespace ost::conop;
 
-namespace ost { namespace conop {
+namespace ost { namespace mol { namespace alg {
 
 
 bool CopyResidue(ResidueHandle src_res, ResidueHandle dst_res, XCSEditor& edi)
@@ -234,4 +234,4 @@ bool CopyNonConserved(ResidueHandle src_res, ResidueHandle dst_res,
 
 
 
-}}
+}}}
diff --git a/modules/mol/alg/src/nonstandard.hh b/modules/mol/alg/src/nonstandard.hh
index a57022def..b37ffd52b 100644
--- a/modules/mol/alg/src/nonstandard.hh
+++ b/modules/mol/alg/src/nonstandard.hh
@@ -23,11 +23,11 @@
   Author: Marco Biasini, Juergen Haas
  */
 #include "module_config.hh"
-#include "compound_lib.hh"
+#include <ost/conop/compound_lib.hh>
 
 
 
-namespace ost { namespace conop {
+namespace ost { namespace mol { namespace alg {
 
 
 /// \brief copies all atom of src_res to dst_res, gets compound lib from builder
@@ -40,7 +40,8 @@ bool DLLEXPORT_OST_CONOP CopyResidue(ost::mol::ResidueHandle src_res,
 /// \brief copies all atom of src_res to dst_res, requires a compound lib 
 bool DLLEXPORT_OST_CONOP CopyResidue(ost::mol::ResidueHandle src_res,
                                      ost::mol::ResidueHandle dst_res,
-                                     ost::mol::XCSEditor& edi, CompoundLibPtr lib);
+                                     ost::mol::XCSEditor& edi,
+                                     ost::conop::CompoundLibPtr lib);
 
                              
 /// \brief copies all atom of src_res to dst_res
@@ -66,7 +67,8 @@ bool DLLEXPORT_OST_CONOP CopyIdentical(ost::mol::ResidueHandle src_res,
 bool DLLEXPORT_OST_CONOP CopyConserved(ost::mol::ResidueHandle src_res, 
                                        ost::mol::ResidueHandle dst_res,
                                        ost::mol::XCSEditor& edi,
-                                       bool& has_cbeta, CompoundLibPtr lib);
+                                       bool& has_cbeta,
+                                       ost::conop::CompoundLibPtr lib);
 
 /// \brief copies atoms of src_res to dst_res, requires compound lib
 ///
@@ -107,10 +109,11 @@ bool DLLEXPORT_OST_CONOP CopyMSE(ost::mol::ResidueHandle src_res,
 bool DLLEXPORT_OST_CONOP CopyModified(ost::mol::ResidueHandle src_res, 
                                       ost::mol::ResidueHandle dst_res,
                                       ost::mol::XCSEditor& edi,
-                                      bool& has_cbeta, CompoundLibPtr lib);
+                                      bool& has_cbeta,
+                                      ost::conop::CompoundLibPtr lib);
 
 
 
-}}
+}}}
 
 #endif
diff --git a/tools/molck/CMakeLists.txt b/tools/molck/CMakeLists.txt
index 4e1dc2fb7..c76f1fd71 100644
--- a/tools/molck/CMakeLists.txt
+++ b/tools/molck/CMakeLists.txt
@@ -1,4 +1,4 @@
 if (NOT WIN32)
 executable(NAME molck SOURCES main.cc
-           DEPENDS_ON ost_io STATIC)
+           DEPENDS_ON ost_io ost_mol_alg STATIC)
 endif(NOT WIN32)
diff --git a/tools/molck/main.cc b/tools/molck/main.cc
index 610c074bf..ef2d77c20 100644
--- a/tools/molck/main.cc
+++ b/tools/molck/main.cc
@@ -15,10 +15,8 @@
 #include <mach-o/dyld.h>
 #endif
 using namespace ost;
-using namespace ost::conop;
 using namespace ost::mol;
 using namespace ost::io;
-using namespace ost::mol::alg;
 
 namespace po=boost::program_options;
 namespace fs=boost::filesystem;
@@ -82,20 +80,20 @@ EntityHandle load_x(const String& file, const IOProfile& profile)
 }
 
 // load compound library, exiting if it could not be found...
-CompoundLibPtr load_compound_lib(const String& custom_path)
+ost::conop::CompoundLibPtr load_compound_lib(const String& custom_path)
 {
   if (custom_path!="") {
     if (fs::exists(custom_path)) {  
-      return CompoundLib::Load(custom_path);
+      return ost::conop::CompoundLib::Load(custom_path);
     } else {
       std::cerr << "Could not find compounds.chemlib at the provided location, trying other options" << std::endl;
     }
   } 
   if (fs::exists("compounds.chemlib")) {
-    return CompoundLib::Load("compounds.chemlib");
+    return ost::conop::CompoundLib::Load("compounds.chemlib");
   }
   char result[ 1024 ]; 
-  CompoundLibPtr lib;
+  ost::conop::CompoundLibPtr lib;
   String exe_path; 
   #if defined(__APPLE__)
   uint32_t size=1023;
@@ -118,14 +116,14 @@ CompoundLibPtr load_compound_lib(const String& custom_path)
     String share_path_string=BFPathToString(share_path);
       
     if (fs::exists(share_path_string)) {
-      return CompoundLib::Load(share_path_string);
+      return ost::conop::CompoundLib::Load(share_path_string);
     }  
   }
   if (!lib) {
     std::cerr << "Could not load compounds.chemlib" << std::endl;
     exit(-1);
   }
-  return CompoundLibPtr();
+  return ost::conop::CompoundLibPtr();
 }
 
 
@@ -136,7 +134,7 @@ int main(int argc, char *argv[])
   }
   IOProfile prof;
   prof.fault_tolerant=true;
-  MolckSettings settings;
+  ost::mol::alg::MolckSettings settings;
   String rm;
   String color;
 
@@ -223,14 +221,14 @@ int main(int argc, char *argv[])
     usage();
     exit(-1);
   }
-  CompoundLibPtr lib=load_compound_lib(custom_path);  
+  ost::conop::CompoundLibPtr lib=load_compound_lib(custom_path);  
   for (unsigned int i = 0; i < files.size(); ++i) {
     EntityHandle ent=load_x(files[i], prof);
     if (!ent.IsValid()) {
       continue;
     }
     
-    Molck(ent, lib, settings);
+    ost::mol::alg::Molck(ent, lib, settings);
  
     if (write_to_stdout) {
       PDBWriter writer(std::cout, prof);
-- 
GitLab