-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Gromac's Tng lib #2218
Added Gromac's Tng lib #2218
Changes from 10 commits
4a82930
adf520a
47fef6c
f63aeae
c6b1bad
dd9ee64
35cd497
62ccddb
6f92f23
6389563
1310937
ac98fe8
0c20699
7c8918a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory("source_subfolder") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sources: | ||
"1.8.2": | ||
url: "https://github.com/gromacs/tng/archive/v1.8.2.tar.gz" | ||
sha256: "242b2ecab5018a42ba80d8df58528ecb9edf419caa671eca4864234672bf025d" | ||
patches: | ||
"1.8.2": | ||
- base_path: "source_subfolder" | ||
patch_file: "patches/0001-BuildTNG.patch" | ||
- base_path: "source_subfolder" | ||
patch_file: "patches/0002-CMakeLists.patch" |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,82 @@ | ||||||
from conans import ConanFile, tools, CMake | ||||||
import os | ||||||
import glob | ||||||
|
||||||
|
||||||
class tngConan(ConanFile): | ||||||
name = "tng" | ||||||
description = "External GROMACS library for loading tng files." | ||||||
license = "BSD-3-Clause" | ||||||
topics = ("conan", "tng", "gromacs") | ||||||
homepage = "https://github.com/gromacs/tng/" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you'll need to point this ti gitlab as well =) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed :) |
||||||
url = "https://github.com/conan-io/conan-center-index" | ||||||
exports_sources = ["CMakeLists.txt", "patches/*"] | ||||||
generators = "cmake" | ||||||
settings = "os", "arch", "compiler", "build_type" | ||||||
options = { | ||||||
"shared": [True, False], | ||||||
"fPIC": [True, False] | ||||||
} | ||||||
default_options = { | ||||||
"shared": False, | ||||||
"fPIC": True | ||||||
} | ||||||
|
||||||
requires = ( | ||||||
"zlib/1.2.11" | ||||||
) | ||||||
|
||||||
_cmake = None | ||||||
|
||||||
@property | ||||||
def _source_subfolder(self): | ||||||
return "source_subfolder" | ||||||
|
||||||
@property | ||||||
def _build_subfolder(self): | ||||||
return "build_subfolder" | ||||||
|
||||||
def config_options(self): | ||||||
if self.settings.os == "Windows": | ||||||
del self.options.fPIC | ||||||
|
||||||
def configure(self): | ||||||
if self.options.shared: | ||||||
del self.options.fPIC | ||||||
del self.settings.compiler.libcxx | ||||||
del self.settings.compiler.cppstd | ||||||
|
||||||
def source(self): | ||||||
tools.get(**self.conan_data["sources"][self.version]) | ||||||
url = self.conan_data["sources"][self.version]["url"] | ||||||
extracted_dir = self.name + "-" + self.version | ||||||
os.rename(extracted_dir, self._source_subfolder) | ||||||
|
||||||
def build(self): | ||||||
for patch in self.conan_data["patches"][self.version]: | ||||||
tools.patch(**patch) | ||||||
cmake = self._configure_cmake() | ||||||
cmake.build() | ||||||
|
||||||
def _configure_cmake(self): | ||||||
if self._cmake: | ||||||
return self._cmake | ||||||
self._cmake = CMake(self) | ||||||
self._cmake.definitions["TNG_BUILD_OWN_ZLIB"] = False | ||||||
GavinNL marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
self._cmake.definitions["TNG_BUILD_EXAMPLES"] = False | ||||||
self._cmake.definitions["TNG_BUILD_TEST"] = False | ||||||
self._cmake.configure(build_folder=self._build_subfolder) | ||||||
This comment was marked as outdated.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this problem is caused by these lines in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured it would be an issue with the project's cmake file. Not sure what I should do about it, should we apply a patch? My preference is to not edit the original if I can avoid it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change would be equivalent to your move of sources. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tested it locally.
I think upstream would be happy to apply this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I added it as a patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've opened an issue with the patch at gromacs/tng#1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if anyone is even bothering to look at the issues in the original project. I don't think that library has changed in many years There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's up to them to accept or not... |
||||||
return self._cmake | ||||||
|
||||||
def package(self): | ||||||
self.copy("COPYING", dst="licenses", src=self._source_subfolder) | ||||||
cmake = self._configure_cmake() | ||||||
cmake.install() | ||||||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||||||
|
||||||
def package_info(self): | ||||||
self.cpp_info.libs = ["tng_io"] | ||||||
GavinNL marked this conversation as resolved.
Show resolved
Hide resolved
GavinNL marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
if self.settings.os == "Linux": | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't test, but some zealots (aka @ericLemanissier 🤣) have recently begun with adding FreeBSD support.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol...is that "LInux" a typo? (capital I) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, typo! Fixing it now.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to get a free FreeBSD CI test, just put "FreeBSD" in your PR's description ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @prince-chrismc @ericLemanissier |
||||||
self.cpp_info.system_libs = ["m"] | ||||||
self.cpp_info.names["cmake_find_package"] = "tng_io" | ||||||
self.cpp_info.names["cmake_find_package_multi"] = "tng_io" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- BuildTNG.cmake | ||
+++ BuildTNG.cmake | ||
@@ -1,9 +1,9 @@ | ||
set(TNG_ROOT_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||
-file(RELATIVE_PATH TNG_ROOT_BINARY_DIR ${CMAKE_SOURCE_DIR} ${TNG_ROOT_SOURCE_DIR}) | ||
+file(RELATIVE_PATH TNG_ROOT_BINARY_DIR ${PROJECT_SOURCE_DIR} ${TNG_ROOT_SOURCE_DIR}) | ||
if ("${TNG_ROOT_BINARY_DIR}" MATCHES "^\.\.") | ||
set(TNG_ROOT_BINARY_DIR tng) | ||
endif() | ||
-set(TNG_ROOT_BINARY_DIR ${CMAKE_BINARY_DIR}/${TNG_ROOT_BINARY_DIR}) | ||
+set(TNG_ROOT_BINARY_DIR ${PROJECT_BINARY_DIR}/${TNG_ROOT_BINARY_DIR}) | ||
|
||
set(TNG_MAJOR_VERSION "1") | ||
set(TNG_MINOR_VERSION "8") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index bc6f8fd..602630e 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -47,7 +47,8 @@ configure_file( src/lib/tng_io-configVersion.cmake.in | ||
install(TARGETS tng_io | ||
EXPORT tng_io | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") | ||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") | ||
|
||
install(EXPORT tng_io FILE tng_io.cmake | ||
NAMESPACE tng_io:: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} example.c) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
src = os.path.join(self.source_folder, "tng_example.tng") | ||
self.run("{} {}".format(os.path.join("bin", "test_package"), src), run_environment=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/* This code is part of the tng binary trajectory format. | ||
* | ||
* Written by Magnus Lundborg | ||
* Copyright (c) 2012-2013, The GROMACS development team. | ||
* check out http://www.gromacs.org for more information. | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the Revised BSD License. | ||
*/ | ||
|
||
#include "tng/tng_io.h" | ||
|
||
#ifdef USE_STD_INTTYPES_H | ||
#include <inttypes.h> | ||
#endif | ||
|
||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
int main(int argc, char **argv) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we like to have much move minimal test_packages... I idea it to make sure the conan packing went well no so much the library is functional. could you please try to reduce this to a few lines? example instantiate a few objects? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used an example piece of code from the library to create the test_package.c, figured it would be a good way to test it. I will reduce it. |
||
{ | ||
tng_trajectory_t traj; | ||
union data_values ***positions = 0; /* A 3-dimensional array to be populated */ | ||
int64_t n_particles, n_values_per_frame, n_frames, tot_n_frames; | ||
char data_type; | ||
int i, j; | ||
int particle = 0; | ||
/* Set a default frame range */ | ||
int first_frame = 0, last_frame = 50; | ||
char atom_name[64], res_name[64], chain_name[64]; | ||
|
||
if(argc <= 1) | ||
{ | ||
printf("No file specified\n"); | ||
printf("Usage:\n"); | ||
printf("tng_io_read_pos <tng_file> [particle number = %d] " | ||
"[first_frame = %d] [last_frame = %d]\n", | ||
particle, first_frame, last_frame); | ||
exit(1); | ||
} | ||
|
||
/* A reference must be passed to allocate memory */ | ||
if(tng_trajectory_init(&traj) != TNG_SUCCESS) | ||
{ | ||
tng_trajectory_destroy(&traj); | ||
exit(1); | ||
} | ||
tng_input_file_set(traj, argv[1]); | ||
|
||
/* Read the file headers */ | ||
tng_file_headers_read(traj, TNG_USE_HASH); | ||
|
||
if(argc >= 3) | ||
{ | ||
particle = strtol(argv[2], 0, 10); | ||
if(argc >= 4) | ||
{ | ||
first_frame = strtol(argv[3], 0, 10); | ||
if(argc >= 5) | ||
{ | ||
last_frame = strtol(argv[4], 0, 10); | ||
} | ||
} | ||
} | ||
|
||
if(tng_num_frames_get(traj, &tot_n_frames) != TNG_SUCCESS) | ||
{ | ||
printf("Cannot determine the number of frames in the file\n"); | ||
tng_trajectory_destroy(&traj); | ||
exit(1); | ||
} | ||
|
||
printf("%"PRId64" frames in file\n", tot_n_frames); | ||
|
||
if(last_frame > tot_n_frames - 1) | ||
{ | ||
last_frame = tot_n_frames - 1; | ||
} | ||
|
||
n_frames = last_frame - first_frame + 1; | ||
|
||
if(tng_atom_name_of_particle_nr_get(traj, particle, atom_name, | ||
sizeof(atom_name)) == | ||
TNG_SUCCESS && | ||
tng_residue_name_of_particle_nr_get(traj, particle, res_name, | ||
sizeof(res_name)) == | ||
TNG_SUCCESS && | ||
tng_chain_name_of_particle_nr_get(traj, particle, chain_name, | ||
sizeof(chain_name)) == | ||
TNG_SUCCESS) | ||
{ | ||
printf("Particle: %s (%s: %s)\n", atom_name, chain_name, res_name); | ||
} | ||
else | ||
{ | ||
printf("Particle name not found\n"); | ||
} | ||
|
||
/* Get the positions of all particles in the requested frame range. | ||
The positions are stored in the positions array. | ||
N.B. No proper error checks. */ | ||
if(tng_particle_data_interval_get(traj, TNG_TRAJ_POSITIONS, first_frame, | ||
last_frame, TNG_USE_HASH, &positions, &n_particles, &n_values_per_frame, | ||
&data_type) == TNG_SUCCESS) | ||
{ | ||
if(particle >= n_particles) | ||
{ | ||
printf("Chosen particle out of range. Only %"PRId64" particles in trajectory.\n", n_particles); | ||
} | ||
else | ||
{ | ||
/* Print the positions of the wanted particle (zero based) */ | ||
for(i=0; i<n_frames; i++) | ||
{ | ||
printf("%d", first_frame + i); | ||
for(j=0; j<n_values_per_frame; j++) | ||
{ | ||
switch(data_type) | ||
{ | ||
case TNG_INT_DATA: | ||
printf("\t%"PRId64"", positions[i][particle][j].i); | ||
break; | ||
case TNG_FLOAT_DATA: | ||
printf("\t%f", positions[i][particle][j].f); | ||
break; | ||
case TNG_DOUBLE_DATA: | ||
printf("\t%f", positions[i][particle][j].d); | ||
break; | ||
default: | ||
break; | ||
} | ||
printf("\n"); | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
printf("Cannot read positions\n"); | ||
} | ||
|
||
/* Free memory */ | ||
if(positions) | ||
{ | ||
tng_particle_data_values_free(traj, positions, n_frames, n_particles, | ||
n_values_per_frame, data_type); | ||
} | ||
tng_trajectory_destroy(&traj); | ||
|
||
return(0); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.8.2": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems they moved to gitlab sometime ago.... https://gitlab.com/gromacs/tng/-/tags
is there a reason you are referencing the github page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I did not know this. I'll change this.