Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
082afe4
almost there
danpf Sep 13, 2019
a8a924e
remove excess
danpf Sep 13, 2019
4b33819
done with reader
danpf Sep 14, 2019
111b734
temporary stuff
danpf Sep 23, 2019
caeb577
updated to have encode work
danpf Oct 2, 2019
eddb760
setup for pip
danpf Oct 4, 2019
8e7f475
remove extra
danpf Oct 15, 2019
dc91554
make pybind11 https
danpf Oct 20, 2019
1cb3597
binary enc changes
danpf Mar 24, 2020
c940bd3
merged
danpf Mar 24, 2020
86cbd91
cmakelists to spaces
danpf Mar 24, 2020
037eb69
checkpoint
danpf Mar 24, 2020
60103bc
fixes
danpf Mar 25, 2020
5dacd2d
removed mmtf_t.py
danpf Mar 25, 2020
2ec61b4
build ci
danpf Mar 25, 2020
bae25d3
lowercase bionic
danpf Mar 25, 2020
4d54664
try2
danpf Mar 25, 2020
a65d69a
debug travis
danpf Mar 25, 2020
9143d1a
setup gcc7
danpf Mar 25, 2020
8a0f1a4
add to env for ever matrix
danpf Mar 25, 2020
6701c19
attempt 01
danpf Mar 25, 2020
daadb33
more updates
danpf Mar 25, 2020
7bb120f
fixed exe
danpf Mar 25, 2020
1692246
upagain
danpf Mar 25, 2020
b10e6a3
up
danpf Mar 25, 2020
7a2c67e
update langauge
danpf Mar 25, 2020
cf92b45
hopefully done
danpf Mar 25, 2020
ded948f
remove user call
danpf Mar 25, 2020
7892582
fix pybind11 call
danpf Mar 25, 2020
4c3414e
set catch2
danpf Mar 25, 2020
6e5beb6
not sure 2
danpf Mar 25, 2020
470ae1a
fix gitignore
danpf Mar 25, 2020
740f8d2
update
danpf Mar 25, 2020
54d8f30
fix build
danpf Mar 25, 2020
aa3fb33
add back docs
danpf Mar 25, 2020
b6648fa
fix extras
danpf Mar 25, 2020
cc2e1b5
remove pycache
danpf Mar 25, 2020
c0158a6
fix submodule loc
danpf Mar 25, 2020
1ab4052
last try
danpf Mar 25, 2020
674aea1
fixes
danpf Mar 25, 2020
2394da2
donezo
danpf Mar 26, 2020
7aab1a3
fix cpp tests
danpf Mar 26, 2020
efcb14a
remove pyc
danpf Mar 26, 2020
83ea2be
update gitignore
danpf Mar 26, 2020
4761465
fix pathing
danpf Mar 26, 2020
95c81d1
change travis python addon name
danpf Mar 26, 2020
e3bf246
get rid of CC in travis check
danpf Mar 26, 2020
9464880
attempt substitute python command
danpf Mar 26, 2020
10e2148
lint .travis
danpf Mar 26, 2020
433810e
fix extra DNDEBUG setting
danpf Mar 26, 2020
22d8b68
add CC back
danpf Mar 26, 2020
5ac8042
update readme with python information
danpf Mar 26, 2020
a24420c
update
danpf Mar 26, 2020
6f2aea1
merge with master
danpf Nov 14, 2023
c740b14
update mmtf_spec
danpf Nov 14, 2023
65c8345
update to Catch2 v3.4.0 (for m1 silicon support)
danpf Nov 14, 2023
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,10 @@ build/*
docs/html/*
examples/out/*
examples/out_json_ref/*

# python eggs
python_src/*.egg-info
**/__pycache__
**/*.pyc


17 changes: 10 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "Catch2"]
path = submodules/Catch2
url = https://github.com/catchorg/Catch2
[submodule "msgpack-c"]
[submodule "submodules/pybind11"]
path = submodules/pybind11
url = https://github.com/pybind/pybind11.git
[submodule "submodules/msgpack-c"]
path = submodules/msgpack-c
url = https://github.com/msgpack/msgpack-c
[submodule "mmtf_spec"]
url = https://github.com/msgpack/msgpack-c.git
[submodule "submodules/Catch2"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catch2 listed twice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this once the other two PRs are merged

path = submodules/Catch2
url = https://github.com/catchorg/Catch2.git
[submodule "submodules/mmtf_spec"]
path = submodules/mmtf_spec
url = https://github.com/rcsb/mmtf
url = https://github.com/rcsb/mmtf.git
40 changes: 39 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I 'linted' this file using yamllint, sorry for the noise

language: cpp
sudo: false
dist: trusty
Expand Down Expand Up @@ -27,8 +28,25 @@ linux64_cpp17addons:
sources:
- ubuntu-toolchain-r-test

linux64_cpp17addons:
addons: &linux64cpp17
apt:
sources:
- ubuntu-toolchain-r-test


linux64_cpp17addons_py:
addons: &linux64cpp17py
apt:
sources:
- ubuntu-toolchain-r-test
- gcc-7
- g++-7

python_test_command_sub: &python_test_command TEST_COMMAND=$TRAVIS_BUILD_DIR/ci/build_and_run_python_tests.sh CC=gcc
# Set empty values for allow_failures to work
env: TEST_COMMAND=$TRAVIS_BUILD_DIR/ci/build_and_run_tests.sh
python:

matrix:
fast_finish: true
Expand All @@ -54,7 +72,27 @@ matrix:
compiler: gcc
addons: *linux64cpp17
dist: bionic

- os: linux
compiler: gcc
addons: *linux64cpp17py
dist: bionic
env: *python_test_command
python: 3.8
language: python
- os: linux
compiler: gcc
addons: *linux64cpp17py
dist: bionic
env: *python_test_command
python: 3.11
language: python
- os: linux
compiler: gcc
addons: *linux64cpp17py
dist: bionic
env: *python_test_command
python: 3.12
language: python

before_install:
# Setting environement
Expand Down
32 changes: 29 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ if (mmtf_build_local)
add_library(msgpackc INTERFACE)
target_include_directories(msgpackc INTERFACE ${MSGPACKC_INCLUDE_DIR})
if (BUILD_TESTS)
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/submodules/Catch2/single_include)
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/submodules/Catch2)
endif()
endif()

Expand All @@ -40,6 +38,34 @@ if (mmtf_build_examples)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples)
endif()


if (build_py)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
add_library(mmtf_bindings SHARED
${CMAKE_CURRENT_SOURCE_DIR}/python_src/bindings.cpp
)

set(MSGPACKC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/submodules/msgpack-c/include)
set(PYBIND_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/submodules/pybind11/include)

target_include_directories(mmtf_bindings PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(mmtf_bindings PUBLIC ${MSGPACKC_INCLUDE_DIR})
target_include_directories(mmtf_bindings PUBLIC ${PYBIND_INCLUDE_DIR})
target_include_directories(mmtf_bindings PUBLIC ${python_include_A})
target_include_directories(mmtf_bindings PUBLIC ${python_include_B})

set_target_properties(mmtf_bindings PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(mmtf_bindings PROPERTIES PREFIX "")
set_target_properties(mmtf_bindings PROPERTIES SUFFIX ".so")
set_target_properties(mmtf_bindings PROPERTIES CXX_STANDARD 17)
endif()

install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION "include"
Expand Down
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,53 @@ Here, `<MSGPACK_INCLUDE_PATH>` and `<MMTF_INCLUDE_PATH>` are the paths to the

For your more complicated projects, a `CMakeLists.txt` is included for you.


### Python bindings

The C++ MMTF library now can build python bindings using pybind11. To use them
you must have A) a c++11 compatible compiler and B) python >= 3.6

to install, it is as simple as `pip install .`

(in the future possible `pip install mmtf-cpp`)

```python
from mmtf_cppy import StructureData
import numpy as np
import math


def rotation_matrix(axis, theta):
"""
Return the rotation matrix associated with counterclockwise rotation about
the given axis by theta radians.
from https://stackoverflow.com/a/6802723
"""
axis = np.asarray(axis)
axis = axis / math.sqrt(np.dot(axis, axis))
a = math.cos(theta / 2.0)
b, c, d = -axis * math.sin(theta / 2.0)
aa, bb, cc, dd = a * a, b * b, c * c, d * d
bc, ad, ac, ab, bd, cd = b * c, a * d, a * c, a * b, b * d, c * d
return np.array([[aa + bb - cc - dd, 2 * (bc + ad), 2 * (bd - ac)],
[2 * (bc - ad), aa + cc - bb - dd, 2 * (cd + ab)],
[2 * (bd + ac), 2 * (cd - ab), aa + dd - bb - cc]])


theta = 1.2
axis = [0, 0, 1]

sd = StructureData("my_favorite_structure.mmtf")
sd.atomProperties["pymol_colorList"] = [1 if x % 2 == 0 else 5 for x in sd.xCoordList]
xyz = np.column_stack((sd.xCoordList, sd.yCoordList, sd.zCoordList))
xyz_rot = rotation_matrix(axis, theta).dot(xyz.T).T
sd.xCoordList, sd.yCoordList, sd.zCoordList = np.hsplit(xyz_rot, 3)
sd.write_to_file("my_favorite_structure_rot.mmtf")

```



## Installation
You can also perform a system wide installation with `cmake` and `ninja` (or `make`).
To do so:
Expand Down
10 changes: 10 additions & 0 deletions ci/build_and_run_python_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

python3 --version
pip3 --version
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
cd $TRAVIS_BUILD_DIR
pip3 install .
pytest python_src/tests/tests.py -s -vv


4 changes: 3 additions & 1 deletion ci/build_and_run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -e
cd $TRAVIS_BUILD_DIR
cd "$TRAVIS_BUILD_DIR"
mkdir build && cd build
$CMAKE_CONFIGURE cmake $CMAKE_ARGS $CMAKE_EXTRA ..
make -j2
Expand Down
2 changes: 1 addition & 1 deletion include/mmtf/structure_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct StructureData {
std::string title;
std::string depositionDate;
std::string releaseDate;
std::vector<std::vector<float> > ncsOperatorList;
std::vector<std::vector<float>> ncsOperatorList;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is C++11 syntax. As far as I know this project is still C++03 (but you have my vote for dropping that).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing you meant to comment this somewhere else?

std::vector<BioAssembly> bioAssemblyList;
std::vector<Entity> entityList;
std::vector<std::string> experimentalMethods;
Expand Down
Loading