Skip to content

Commit

Permalink
Updated gemmi and clipper-gemmi versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dialpuri committed Jun 15, 2024
1 parent c011fdc commit 6b9c534
Show file tree
Hide file tree
Showing 14 changed files with 132,415 additions and 375 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.12)
project(privateer VERSION 0.5 LANGUAGES C CXX)

SET(PRIVATEER_CC_FLAGS "-O2 -w")
SET(PRIVATEER_CXX_FLAGS "-O2 -w -fwasm-exceptions -I${CMAKE_INSTALL_PREFIX}/include")
SET(PRIVATEER_CXX_FLAGS "-O2 -w -fwasm-exceptions -I${CMAKE_INSTALL_PREFIX}/include")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PRIVATEER_CC_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PRIVATEER_CXX_FLAGS} ")

Expand All @@ -25,7 +25,8 @@ set(CLIBDENV $ENV{CLIBD})
# add_subdirectory(checkout/zlib)

if (MODE STREQUAL "TESTING")
else()
else()
add_subdirectory(gemmi)
add_subdirectory(ccp4)
add_subdirectory(rfftw)
add_subdirectory(fftw)
Expand Down Expand Up @@ -57,6 +58,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
checkout/zlib
${PRIVATEER_SOURCE_DIR}/cpp
${PRIVATEER_SOURCE_DIR}/cpp/pybind11
${PRIVATEER_SOURCE_DIR}/cpp/third-party/simdjson/

# checkout/ccp4srs
)

Expand Down Expand Up @@ -113,6 +116,7 @@ add_library(privateer_lib
# ${PRIVATEER_SOURCE_DIR}/cpp/pybind11/privateer-pymodelling.cpp
${PRIVATEER_SOURCE_DIR}/cpp/clipper-glyco_data.cpp
${PRIVATEER_SOURCE_DIR}/cpp/privateer-bind.cpp
${PRIVATEER_SOURCE_DIR}/cpp/third-party/simdjson/simdjson.cpp

)

Expand All @@ -122,7 +126,7 @@ add_executable(privateer_exec ${PRIVATEER_SOURCE_DIR}/cpp/privateer-bind.cpp)

set_target_properties (privateer_exec PROPERTIES OUTPUT_NAME privateer )

target_link_options(privateer_exec PRIVATE --preload-file data/linkage_torsions@/ -sDEMANGLE_SUPPORT=1 -sASSERTIONS=2 -fexceptions -sALLOW_MEMORY_GROWTH=1 --bind -sFORCE_FILESYSTEM=1 -sMODULARIZE=1 -sEXPORT_NAME=privateer_module -sEXPORTED_RUNTIME_METHODS=['FS'] -sMODULARIZE=1 -sEXPORT_ES6=1 )
target_link_options(privateer_exec PRIVATE --preload-file data/linkage_torsions@/ -sDEMANGLE_SUPPORT=0 -sEXIT_RUNTIME=1 -sASSERTIONS=2 -fexceptions -sALLOW_MEMORY_GROWTH=1 --bind -sFORCE_FILESYSTEM=1 -sMODULARIZE=1 -sEXPORT_NAME=privateer_module -sEXPORTED_RUNTIME_METHODS=['FS'] -sMODULARIZE=1 -sEXPORT_ES6=1 )

target_link_directories(privateer_exec
PUBLIC
Expand Down Expand Up @@ -176,6 +180,7 @@ ${PRIVATEER_SOURCE_DIR}/cpp/privateer-json.h
${PRIVATEER_SOURCE_DIR}/cpp/clipper-glyco.h
${PRIVATEER_SOURCE_DIR}/cpp/privateer-parallelism.h
${PRIVATEER_SOURCE_DIR}/cpp/privateer-cryo_em.h
${PRIVATEER_SOURCE_DIR}/cpp/third-party/simdjson/simdjson.h
)

set_target_properties(privateer_exec PROPERTIES PUBLIC_HEADER "${privateer_HEADERS}")
Expand Down
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source /Applications/ccp4-8.0/bin/ccp4.setup-sh
source ~/Development/privateer/emsdk/emsdk_env.sh
# source /opt/xtal/ccp4-8.0/bin/ccp4.setup-sh
# source ~/dev/privateer_wasm/emsdk/emsdk_env.sh
#source /Applications/ccp4-8.0/bin/ccp4.setup-sh
#source ~/Development/privateer/emsdk/emsdk_env.sh
source /opt/xtal/ccp4-8.0/bin/ccp4.setup-sh
source ~/dev/privateer_wasm/emsdk/emsdk_env.sh

emcmake cmake .
emmake make -j
Expand Down
18 changes: 15 additions & 3 deletions clipper/gemmi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
project(clipper-gemmi)

add_library(clipper-gemmi STATIC
../../checkout/clipper/clipper/gemmi/clipper_gemmi.cpp)
add_library(clipper-gemmi STATIC
../../checkout/clipper/clipper/gemmi/clipper_gemmi.cpp
../../checkout/clipper/clipper/gemmi/clipper_gemmi_model.cpp
)
#../../checkout/clipper/clipper/gemmi/clipper_gemmi_map.cpp


target_include_directories(clipper-gemmi PRIVATE
../../checkout/clipper/clipper
../../checkout/clipper/
../../checkout/gemmi/include)

target_link_directories(clipper-gemmi PRIVATE
../../gemmi
)

target_link_libraries(clipper-gemmi PRIVATE gemmi_cpp)

set(clipper-gemmi_HEADERS
${CMAKE_SOURCE_DIR}/checkout/clipper/clipper/gemmi/clipper_gemmi.h
# ${CMAKE_SOURCE_DIR}/checkout/clipper/clipper/gemmi/clipper_gemmi_map.h
${CMAKE_SOURCE_DIR}/checkout/clipper/clipper/gemmi/clipper_gemmi_model.h
)

target_compile_options(clipper-gemmi PUBLIC "-DFFTW_ENABLE_FLOAT")
Expand All @@ -18,4 +30,4 @@ set_target_properties(clipper-gemmi PROPERTIES PUBLIC_HEADER "${clipper-gemmi_HE
install(TARGETS clipper-gemmi
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/clipper/gemmi
)
)
19 changes: 15 additions & 4 deletions clipper/minimol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,29 @@ add_library(clipper-minimol STATIC
../../checkout/clipper/clipper/minimol/container_minimol.cpp
../../checkout/clipper/clipper/minimol/minimol.cpp
../../checkout/clipper/clipper/minimol/minimol_data.cpp
../../checkout/clipper/clipper/minimol/minimol_io.cpp
../../checkout/clipper/clipper/minimol/minimol_io_gemmi.cpp
../../checkout/clipper/clipper/minimol/minimol_io_mmdb.cpp
../../checkout/clipper/clipper/minimol/minimol_seq.cpp
../../checkout/clipper/clipper/minimol/minimol_utils.cpp
)

target_include_directories(clipper-minimol PRIVATE ../../checkout/mmdb2/ ../../checkout/clipper ../../checkout/clipper/clipper ../../checkout/fftw-2.1.5/fftw ../../checkout/fftw-2.1.5/rfftw ../../checkout/gemmi/include ../../dependencies/gemmi/include/gemmi)
target_include_directories(clipper-minimol PRIVATE
${CMAKE_SOURCE_DIR}/install/include/
${CMAKE_SOURCE_DIR}/install/include/gemmi
../../checkout/mmdb2/ .
./../checkout/clipper
../../checkout/fftw-2.1.5/fftw
../../checkout/fftw-2.1.5/rfftw
../../checkout/gemmi/include

)

set(clipper-minimol_HEADERS
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/minimol_data.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/minimol.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/container_minimol.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/minimol_io.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/minimol_io_gemmi.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/minimol_io_mmdb.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/minimol_seq.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/minimol/minimol_utils.h
${CMAKE_SOURCE_DIR}/checkout/clipper//clipper/clipper-minimol.h
Expand All @@ -27,4 +38,4 @@ set_target_properties(clipper-minimol PROPERTIES PUBLIC_HEADER "${clipper-minimo
install(TARGETS clipper-minimol
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/clipper/minimol
)
)
2 changes: 1 addition & 1 deletion src/privateer/cpp/clipper-glyco.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ inline bool altconf_compatible ( char m1, char m2 )
// else
// return true;
// would cause an endless while loop in is_stereocentre() when there would be altconfs like 'C'
if(( m1 == m2))
if( m1 == m2)
return true;
else if((m1 == ' ' && m2 != ' ') || (m1 != ' ' && m2 == ' '))
return true;
Expand Down
7 changes: 4 additions & 3 deletions src/privateer/cpp/privateer-bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <clipper/clipper-ccp4.h>
#include <clipper/clipper-minimol.h>
#include <clipper/clipper-contrib.h>
#include <clipper/clipper-gemmi.h>

#include <gemmi/mmread.hpp>
#include "clipper-glyco.h"
Expand Down Expand Up @@ -56,9 +57,9 @@ clipper::MiniMol read_molecule(const std::string &file, const std::string &name)
structure.spacegroup_hm = "P 1";
}

clipper::GEMMIFile gemmi_file;
clipper::GemmiStructure *gemmi_structure = &gemmi_file;
gemmi_structure->structure_ = structure;
clipper::GEMMIfile gemmi_file;
clipper::GemmiStructure gemmi_structure(structure);
gemmi_file.set_gemmi_structure(gemmi_structure);
clipper::MiniMol mol;
gemmi_file.import_minimol(mol);

Expand Down
140 changes: 70 additions & 70 deletions src/privateer/cpp/privateer-interactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,76 +16,76 @@ namespace privateer

void hydrogenate_input_model(std::string input_model, std::string output_path)
{
std::cout << "Hydrogenating '" << input_model << "' using project-gemmi/gemmi third party library." << std::endl;
try
{
std::string output;
if (output == "undefined")
output = "hydrogenated_input_model.pdb";
else
output = output_path;
gemmi::HydrogenChange h_change = gemmi::HydrogenChange::ReAdd;
std::string monomer_dir = privateer::restraints::check_monlib_access();
if (monomer_dir.empty())
throw std::runtime_error("Failed to locate $CLIBD_MON. Have ccp4 env variables been sourced?");

gemmi::Structure st = gemmi::read_structure_file(input_model);

if (st.models.empty() || st.models[0].chains.empty())
throw std::runtime_error("No atoms in the input file.");

gemmi::setup_entities(st);
size_t initial_h = 0;
initial_h = gemmi::count_hydrogen_sites(st);

std::vector<std::string> res_names = st.models[0].get_all_residue_names();

std::printf("Reading %zu monomers and all links from %s\n",
res_names.size(), input_model.c_str());

gemmi::MonLib monlib = gemmi::read_monomer_lib(monomer_dir, res_names,
gemmi::cif::read_file);

for (size_t i = 0; i != st.models.size(); ++i)
gemmi::prepare_topology(st, monlib, i, h_change, false);

std::printf("Hydrogen site count: %zu in input, %zu in output.\n",
initial_h, gemmi::count_hydrogen_sites(st));

// Clean up the H atoms that were placed at (0.00, 0.00, 0.00)
for (gemmi::Model &model : st.models)
for (gemmi::Chain &chain : model.chains)
for (gemmi::Residue &res : chain.residues)
{
std::vector<gemmi::Atom> modified_atoms;
for (gemmi::Atom &atom : res.atoms)
{
if (atom.is_hydrogen())
{
if (atom.pos.x == 0 && atom.pos.y == 0 && atom.pos.z == 0 && atom.occ == 0)
continue;
else
modified_atoms.push_back(atom);
}
else
{
modified_atoms.push_back(atom);
}
}
res.atoms = modified_atoms;
}

std::printf("Writing coordinates to %s\n", output.c_str());
gemmi::Ofstream os(output, &std::cout);
gemmi::write_pdb(st, os.ref());

std::cout << input_model << " was successfully hydrogenated!" << std::endl;
}
catch (std::exception &e)
{
std::fprintf(stderr, "ERROR: %s\n", e.what());
// throw stderr;
}
// std::cout << "Hydrogenating '" << input_model << "' using project-gemmi/gemmi third party library." << std::endl;
// try
// {
// std::string output;
// if (output == "undefined")
// output = "hydrogenated_input_model.pdb";
// else
// output = output_path;
// gemmi::HydrogenChange h_change = gemmi::HydrogenChange::ReAdd;
// std::string monomer_dir = privateer::restraints::check_monlib_access();
// if (monomer_dir.empty())
// throw std::runtime_error("Failed to locate $CLIBD_MON. Have ccp4 env variables been sourced?");

// gemmi::Structure st = gemmi::read_structure_file(input_model);

// if (st.models.empty() || st.models[0].chains.empty())
// throw std::runtime_error("No atoms in the input file.");

// gemmi::setup_entities(st);
// size_t initial_h = 0;
// initial_h = gemmi::count_hydrogen_sites(st);

// std::vector<std::string> res_names = st.models[0].get_all_residue_names();

// std::printf("Reading %zu monomers and all links from %s\n",
// res_names.size(), input_model.c_str());

// gemmi::MonLib monlib = gemmi::read_monomer_lib(monomer_dir, res_names,
// gemmi::cif::read_file);

// for (size_t i = 0; i != st.models.size(); ++i)
// gemmi::prepare_topology(st, monlib, i, h_change, false);

// std::printf("Hydrogen site count: %zu in input, %zu in output.\n",
// initial_h, gemmi::count_hydrogen_sites(st));

// // Clean up the H atoms that were placed at (0.00, 0.00, 0.00)
// for (gemmi::Model &model : st.models)
// for (gemmi::Chain &chain : model.chains)
// for (gemmi::Residue &res : chain.residues)
// {
// std::vector<gemmi::Atom> modified_atoms;
// for (gemmi::Atom &atom : res.atoms)
// {
// if (atom.is_hydrogen())
// {
// if (atom.pos.x == 0 && atom.pos.y == 0 && atom.pos.z == 0 && atom.occ == 0)
// continue;
// else
// modified_atoms.push_back(atom);
// }
// else
// {
// modified_atoms.push_back(atom);
// }
// }
// res.atoms = modified_atoms;
// }

// std::printf("Writing coordinates to %s\n", output.c_str());
// gemmi::Ofstream os(output, &std::cout);
// gemmi::write_pdb(st, os.ref());

// std::cout << input_model << " was successfully hydrogenated!" << std::endl;
// }
// catch (std::exception &e)
// {
// std::fprintf(stderr, "ERROR: %s\n", e.what());
// // throw stderr;
// }
}

privateer::interactions::CHPiBondsParser::CHPiBondsParser(std::string &input_model, std::string output_path, std::string algorithm)
Expand Down
2 changes: 1 addition & 1 deletion src/privateer/cpp/privateer-interactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "gemmi/mmread.hpp"
#include "gemmi/monlib.hpp"
#include "gemmi/placeh.hpp"
// #include "gemmi/placeh.hpp"
#include "gemmi/fstream.hpp"
#include "gemmi/cif.hpp"
#include "gemmi/to_pdb.hpp"
Expand Down
Loading

0 comments on commit 6b9c534

Please sign in to comment.