Skip to content

Commit 4c9e3f8

Browse files
mimakaevCopilot
andauthored
updated build system and deprecated polymerutils (#76)
* updated build system and deprecated modules * deprecate and clean up polymerutils * trailing spaces * Update polychrom/polymerutils.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update polychrom/polymerutils.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * update CI/CD * remove python 3.9 as it fails for being too old --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 320f25e commit 4c9e3f8

File tree

15 files changed

+157
-194
lines changed

15 files changed

+157
-194
lines changed

.github/workflows/pythonapp.yml

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
1-
name: Run pytest
1+
name: Tests
22

3-
on: [push]
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
48

59
jobs:
6-
build:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest]
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
717

8-
runs-on: ubuntu-latest
918
steps:
10-
- uses: actions/checkout@v2
11-
- name: Set up Python 3.12
12-
uses: actions/setup-python@v1
13-
with:
14-
python-version: 3.12
15-
- uses: s-weigand/setup-conda@v1
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
1623
with:
17-
python-version: 3.12
18-
activate-conda: true
19-
- run: conda --version
20-
- run: which python
21-
- run: pwd
22-
- run: ls -la
23-
- name: Install dependencies
24+
python-version: ${{ matrix.python-version }}
25+
cache: 'pip'
26+
27+
- name: Install build dependencies
2428
run: |
25-
sudo apt-get install build-essential
26-
conda install pip
27-
pip install openmm
28-
pip install cython
29-
pip install -r requirements.txt
30-
pip install -e .
31-
conda install -c conda-forge libstdcxx-ng=12
32-
- name: Test with pytest
33-
run: |
34-
pytest
29+
python -m pip install --upgrade pip
30+
pip install build
31+
32+
- name: Install OpenMM
33+
run: pip install openmm
34+
35+
- name: Install package
36+
run: pip install -e .[dev]
37+
38+
- name: Run tests
39+
run: pytest -v

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ polychrom/_polymer_math.cpp
88
*.dat
99
.idea
1010
dist
11+
polychrom/*.so

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def setup(app):
6363
"simtk.unit",
6464
"simtk.unit.nanometer",
6565
"simtk.openmm",
66-
"joblib",
6766
"scipy.interpolate.fitpack2",
6867
]
6968
for mod_name in MOCK_MODULES:

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Polychrom requires OpenMM, which can be installed through conda: ``conda install
1717

1818
CUDA is the fastest GPU-assisted backend to OpenMM. You would need to have the required version of CUDA, or install OpenMM compiled for your version of CUDA.
1919

20-
Other dependencies are simple, and are listed in requirements.txt. All but joblib are installable from either conda/pip, and joblib installs well with pip.
20+
Other dependencies are simple, and are listed in requirements.txt. All are installable through pip or conda.
2121

2222
Installation errors and possible fixes
2323
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

polychrom/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11
__version__ = "0.1.1"
2+
3+
# Check for OpenMM installation
4+
try:
5+
import openmm
6+
except ImportError:
7+
import warnings
8+
warnings.warn(
9+
"\n"
10+
"OpenMM is not installed. Polychrom requires OpenMM for molecular dynamics simulations.\n"
11+
"\n"
12+
"Please install OpenMM with the appropriate backend for your system:\n"
13+
" - For CUDA: pip install openmm[cuda13]\n"
14+
" - For CPU: pip install openmm\n"
15+
"\n"
16+
"Visit https://openmm.org for more information.",
17+
ImportWarning,
18+
stacklevel=2
19+
)

polychrom/__polymer_math.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <cmath>
77
#include <vector>
88
#include <ctime>
9-
#include <omp.h>
109

1110
using namespace std;
1211

polychrom/cli/show

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import os
55
import sys
66
import tempfile
77

8-
import joblib
98
import numpy as np
109

1110
usage = """
@@ -43,7 +42,7 @@ start, end, step will basically select data[start:end:step]
4342

4443

4544
if len(sys.argv) < 2:
46-
print(useage)
45+
print(usage)
4746
exit()
4847

4948

polychrom/cli/xyz

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import sys
66
import tempfile
77
import textwrap
88

9-
import joblib
109
import numpy as np
1110

1211
usage = """

polychrom/legacy/polymerutils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from polychrom.polymerutils import * # noqa: F403

polychrom/polymer_analyses.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
------------------------------
1212
1313
The main function calculating contacts is: :py:func:`polychrom.polymer_analyses.calculate_contacts`
14-
Right now it is a simple wrapper around scipy.cKDTree.
14+
Right now it is a simple wrapper around scipy.KDTree.
1515
1616
Another function :py:func:`polychrom.polymer_analyses.smart_contacts` was added recently to help build contact maps
1717
with a large contact radius. It randomly sub-samples the monomers; by default selecting N/cutoff monomers. It then
@@ -37,7 +37,7 @@
3737

3838
import numpy as np
3939
import pandas as pd
40-
from scipy.spatial import cKDTree
40+
from scipy.spatial import KDTree
4141
from scipy.ndimage import gaussian_filter1d
4242

4343
try:
@@ -66,7 +66,7 @@ def calculate_contacts(data, cutoff=1.7):
6666
if np.isnan(data).any():
6767
raise RuntimeError("Data contains NANs")
6868

69-
tree = cKDTree(data)
69+
tree = KDTree(data)
7070
pairs = tree.query_pairs(cutoff, output_type="ndarray")
7171
return pairs
7272

@@ -573,7 +573,7 @@ def calculate_cistrans(data, chains, chain_id=0, cutoff=5, pbc_box=False, box_si
573573
chain_end = chains[chain_id][1]
574574

575575
# all contact pairs available in the scaled data
576-
tree = cKDTree(data_scaled, boxsize=box_size)
576+
tree = KDTree(data_scaled, boxsize=box_size)
577577
pairs = tree.query_pairs(cutoff, output_type="ndarray")
578578

579579
# total number of contacts of the marked chain:
@@ -582,7 +582,7 @@ def calculate_cistrans(data, chains, chain_id=0, cutoff=5, pbc_box=False, box_si
582582
all_signal = len(pairs[pairs < chain_end]) - len(pairs[pairs < chain_start])
583583

584584
# contact pairs of the marked chain with itself
585-
tree = cKDTree(data[chain_start:chain_end], boxsize=None)
585+
tree = KDTree(data[chain_start:chain_end], boxsize=None)
586586
pairs = tree.query_pairs(cutoff, output_type="ndarray")
587587

588588
# doubled number of contacts of the marked chain with itself (i.e. cis signal)
@@ -593,3 +593,12 @@ def calculate_cistrans(data, chains, chain_id=0, cutoff=5, pbc_box=False, box_si
593593
trans_signal = all_signal - cis_signal
594594

595595
return cis_signal, trans_signal
596+
597+
598+
def rotation_matrix(rotate):
599+
"""Calculates rotation matrix based on three rotation angles"""
600+
tx, ty, tz = rotate
601+
Rx = np.array([[1, 0, 0], [0, np.cos(tx), -np.sin(tx)], [0, np.sin(tx), np.cos(tx)]])
602+
Ry = np.array([[np.cos(ty), 0, -np.sin(ty)], [0, 1, 0], [np.sin(ty), 0, np.cos(ty)]])
603+
Rz = np.array([[np.cos(tz), -np.sin(tz), 0], [np.sin(tz), np.cos(tz), 0], [0, 0, 1]])
604+
return np.dot(Rx, np.dot(Ry, Rz))

0 commit comments

Comments
 (0)