Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ignored subdirecotires:
.vscode/*
build/*
bin/*
devdoc/*
Expand Down
44 changes: 40 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


# minimum version of cmake required for building:
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

# set project parameters:
project(CHAP LANGUAGES CXX C VERSION 0.9.1)
Expand Down Expand Up @@ -85,6 +85,41 @@ endif()
find_package(GROMACS 2016 REQUIRED)
gromacs_check_double(GMX_DOUBLE)
gromacs_check_compiler(CXX)

# GROMACS Conda package exports carry a non-relocatable absolute libm path
# from the build environment. Drop that stale path and keep portable math linking.
if(TARGET Gromacs::libgromacs)
get_target_property(_gmx_iface_libs Gromacs::libgromacs INTERFACE_LINK_LIBRARIES)
if(_gmx_iface_libs)
set(_gmx_iface_libs_sanitized "")
set(_gmx_removed_abs_libm FALSE)
set(_gmx_has_portable_m FALSE)
foreach(_lib IN LISTS _gmx_iface_libs)
if(_lib MATCHES ".*/libm\\.so(\\.[0-9]+)*$")
set(_gmx_removed_abs_libm TRUE)
else()
if(_lib STREQUAL "m")
set(_gmx_has_portable_m TRUE)
endif()
list(APPEND _gmx_iface_libs_sanitized "${_lib}")
endif()
endforeach()
if(_gmx_removed_abs_libm)
if(NOT _gmx_has_portable_m)
list(APPEND _gmx_iface_libs_sanitized m)
endif()
set_target_properties(Gromacs::libgromacs PROPERTIES
INTERFACE_LINK_LIBRARIES "${_gmx_iface_libs_sanitized}"
)
message(STATUS "Patched GROMACS imported target: replaced absolute libm.so dependency with portable math link")
endif()
unset(_gmx_iface_libs_sanitized)
unset(_gmx_removed_abs_libm)
unset(_gmx_has_portable_m)
endif()
unset(_gmx_iface_libs)
endif()

include_directories(${GROMACS_INCLUDE_DIRS})
add_definitions(${GROMACS_DEFINITIONS})

Expand All @@ -98,7 +133,8 @@ include(ExternalProject)
# Google test as external project:
ExternalProject_Add(
googletest
URL https://github.com/google/googletest/archive/release-1.7.0.zip
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
# Disable install step
INSTALL_COMMAND ""
)
Expand All @@ -107,8 +143,8 @@ ExternalProject_Add(
ExternalProject_Get_Property(googletest source_dir binary_dir)

# set include and library path variables:
set(GTEST_INCLUDE_DIR ${source_dir}/include)
set(GTEST_LIBRARY_PATH ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
set(GTEST_LIBRARY_PATH ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
set(GTEST_LIBRARY gtest)
include_directories(${GTEST_INCLUDE_DIR})

Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@

CHAP is a tool for the functional annotation of ion channel structures written in C++. See the website under [www.channotation.org][CHANNOTATION] for a full documentation including installation instructions and usage examples. If you have any questions please use the GitHub [Issue Tracker](https://github.com/channotation/chap/issues).


## Prerequisites ##
## Building from source ##
### Prerequisites ###

Prior to installing CHAP, make sure that you have the following libraries and tools installed:

1. The [CMake][CMake] tool in version 3.2 or higher. This will typically be available through your system's package manager. For example, on Ubuntu you can install CMake by typing `sudo apt-get install cmake`. CMake is used to check the availability of libraries and compilers on your system and will ensure that CHAP is installed properly.
1. The [CMake][CMake] tool in version 3.5 or higher. This will typically be available through your system's package manager. For example, on Ubuntu you can install CMake by typing `sudo apt-get install cmake`. CMake is used to check the availability of libraries and compilers on your system and will ensure that CHAP is installed properly.
2. A C++ compiler that supports the `C++11` standard. A popular choice is the [GNU Compiler Collection][GCC], which on Ubuntu can be obtained by typing `sudo apt-get install gcc`.
3. The [Boost][Boost] C++ libraries, which on Ubuntu can be installed using `sudo apt-get install libboost-all-dev`. Boost algorithms are used in CHAP to solve some root finding and optimisation problems.
4. The CBLAS and LAPACKE linear algebra libraries. On Ubuntu, the easiest way to obtain these is by typing `sudo apt-get install libblas-dev libatlas-base-dev libopenblas-dev liblapacke-dev`. The linear algebra libraries are used in CHAP's spline interpolation.
5. The `libgromacs` library of the [Gromacs][Gromacs] molecular dynamics engine in version 2016 or higher. Comprehensive installation instructions for Gromacs can be found [here][Gromacs-install].
Please note that for using Gromacs as a library, the underlying FFTW libray
5. The `libgromacs` library of the [Gromacs][Gromacs] molecular dynamics engine in version 2020 or higher. Comprehensive installation instructions for Gromacs can be found [here][Gromacs-install].
Please note that for using Gromacs as a library, the underlying FFTW library
may **not** be installed automatically, i.e. you need to set
`-DGMX_BUILD_OWN_FFTW=OFF` when running CMake during the Gromacs
installation.
You also need `-DGMX_INSTALL_LEGACY_API=ON` to get the required headers for CHAP.

CHAP also depends on [RapidJSON](http://rapidjson.org/), but this is included as a header-only library, and on [GTest][GTest], but this is downloaded and installed automatically by CMake, so you don't need to do anything about either of these (you will however need Internet access when installing CHAP).


## Installation ##
### Installation ###

For a minimal install of CHAP create a `build` directory parallel to the source tree and from there run `cmake`, `make`, `make check`, and `make install`.

Expand Down Expand Up @@ -57,7 +58,16 @@ which should bring up an online help for using CHAP.
[GTest]: https://github.com/google/googletest
[CHANNOTATION]: http://www.channotation.org

## Building with Conda ##

If you have conda installed, you can create a conda environment with all dependencies and install chap using the following commands:

```bash
conda env create -f conda/env.yml
conda activate chap-env
bash conda/build.sh
```

## New ##
## Running with Singularity ##

If you have ubuntu and you want to run a precompiled chap version with a singularity image, follow these instructions [here](https://github.com/channotation/chap/blob/singularity_branch/docs/_docs/getting-started/index.md)
14 changes: 14 additions & 0 deletions conda/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

mkdir build
cd build
# Ensure installed binaries can find shared libs in conda-style prefixes without requiring LD_LIBRARY_PATH.
cmake -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \
-DCMAKE_INSTALL_RPATH="\$ORIGIN/../lib;\$ORIGIN/../lib.AVX2_256;\$ORIGIN/../../lib;\$ORIGIN/../../lib.AVX2_256" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=OFF \
..
make
make check
make install
cp ${CONDA_PREFIX}/chap/bin/* ${CONDA_PREFIX}/bin
17 changes: 17 additions & 0 deletions conda/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: chap-env
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- make
- gcc
- cmake >=3.5
- boost-cpp
- libcblas * *_netlib # Only for build
- liblapacke * *_netlib # Only for build
- libtmglib # Only for build
- gromacs
- rapidjson
- intel-compute-runtime

1 change: 1 addition & 0 deletions include/aggregation/multiscalar_time_series.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <map>
#include <vector>
#include <string>
#include <stdexcept>

#include "aggregation/scalar_time_series.hpp"

Expand Down
1 change: 1 addition & 0 deletions include/analysis-setup/residue_information_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <gromacs/topology/atoms.h>
#include <gromacs/topology/topology.h>
#include <gromacs/trajectoryanalysis/analysissettings.h>
#include <gromacs/trajectoryanalysis/topologyinformation.h>
#include <gromacs/utility/real.h>

#include "external/rapidjson/document.h"
Expand Down
2 changes: 1 addition & 1 deletion include/geometry/abstract_cubic_spline_interp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include <vector>

#include <gromacs/math/vec.h>
#include <gromacs/utility/vec.h>

#include "geometry/basis_spline.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/geometry/abstract_spline_curve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include <vector>

#include <gromacs/math/vec.h>
#include <gromacs/utility/vec.h>

#include "geometry/bspline_basis_set.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/geometry/spline_curve_1D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include <gtest/gtest_prod.h>

#include <gromacs/math/vec.h>
#include <gromacs/utility/vec.h>

#include "geometry/abstract_spline_curve.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/geometry/spline_curve_3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <gtest/gtest_prod.h>

#include <gromacs/utility/real.h>
#include <gromacs/math/vec.h>
#include <gromacs/utility/vec.h>

#include "geometry/abstract_spline_curve.hpp"

Expand Down
15 changes: 15 additions & 0 deletions include/gromacs/legal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Vendored GROMACS Headers ##

CHAP currently vendors selected GROMACS-derived headers to allow its compilation with newer GROMACS versions (>=2018) that have changed their API. This includes are mostly reimplementations of random number generators of other libraries with additional upstream notices:

1. `random/threefry.h` (includes notice for the Boost Software License)
2. `random/uniformrealdistribution.h` (includes notice for The LLVM compiler infrastructure MIT-licensed implementation)

To stay compliant when vendoring these files, use the following checklist:

1. Place vendored files in a dedicated folder, for example: `/third_party/gromacs/`.
2. Do not modify these files unless you are prepared to distribute those modifications under the GNU Lesser General Public License (LGPL) v2.1 or later, consistent with GROMACS licensing terms.
3. In your About/Legal material, include this exact statement: "This software uses the ThreeFry implementation from GROMACS, licensed under LGPL v2.1."
4. Provide a link to the GROMACS source code: https://github.com/gromacs/gromacs

When redistributing, preserve all original license and attribution notices present in the vendored files, including the additional Boost and LLVM-related notices where applicable.
80 changes: 80 additions & 0 deletions include/gromacs/math/3dtransforms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* This file is part of the GROMACS molecular simulation package.
*
* Copyright 1991- The GROMACS Authors
* and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
* Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* GROMACS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GROMACS; if not, see
* https://www.gnu.org/licenses, or write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* If you want to redistribute modifications to GROMACS, please
* consider that scientific software is very special. Version
* control is crucial - bugs must be traceable. We will be happy to
* consider code for inclusion in the official distribution, but
* derived work must not be called official GROMACS. Details are found
* in the README & COPYING files - if they are missing, get the
* official version at https://www.gromacs.org.
*
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out https://www.gromacs.org.
*/
#ifndef GMX_MATH_3DTRANSFORMS_H
#define GMX_MATH_3DTRANSFORMS_H

#include <cstdio>

#include "gromacs/utility/real.h"
#include "gromacs/utility/vectypes.h"

/** Index for the fourth dimension for `vec4`. */
#define WW 3

/*! \brief
* 4D vector type used in 3D transformations.
*
* In \Gromacs, only a limited set of 3D transformations are used, and all of
* them operate on coordinates, so the fourth element is assumed to be one and
* ignored in all contexts.
*/
typedef real vec4[4];

/*! \brief
* 4D matrix type used in 3D transformations.
*/
typedef real mat4[4][4];

void gmx_mat4_copy(mat4 a, mat4 b);

void gmx_mat4_transform_point(mat4 m, const rvec x, vec4 v);

/*! \brief
* Computes the product of two `mat4` matrices as A = B * C.
*
* Note that the order of operands is different from mmul() in vec.h!
*/
void gmx_mat4_mmul(mat4 A, mat4 B, mat4 C);

void gmx_mat4_init_unity(mat4 m);

void gmx_mat4_init_rotation(int axis, real angle, mat4 A);

void gmx_mat4_init_translation(real tx, real ty, real tz, mat4 A);

void gmx_mat4_print(FILE* fp, const char* s, mat4 A);

void gmx_vec4_print(FILE* fp, const char* s, vec4 a);

#endif
Loading