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
4 changes: 2 additions & 2 deletions .github/workflows/PR_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
python-version: [ 3.11 ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/commit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
python-version: [3.11]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
with:
ref: ${{ inputs.myCommit }}


- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python 3.9
uses: actions/setup-python@v1
uses: actions/checkout@v7
- name: Set up Python 3.12
uses: actions/setup-python@v7
with:
python-version: 3.9
- uses: actions/cache@v2
python-version: "3.12"
- uses: actions/cache@v6
with:
path: |
~/.cache/pip
Expand All @@ -42,7 +42,7 @@ jobs:
sphinx-build -E -b html ./docs/source ./pages
- name: Deploy to GH-Pages
if: always()
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./pages
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ examples/**/*_rotlib.npz
docs/build
docs/make.bat
docs/Makefile

# MDAnalysis trajectory offset caches
*_offsets.npz
*_offsets.lock
52 changes: 0 additions & 52 deletions .gitlab-ci.yml

This file was deleted.

75 changes: 47 additions & 28 deletions pyproject.toml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,47 +1,66 @@
[project]
name = "chilife"
description = 'A package for modeling non-canonical amino acid side chain ensembles.'
readme = 'README.md'
license= {name = 'GNU GPLv3', file = 'LICENSE'}
authors=[{name = 'Maxx Tessmer', email='mhtessmer@gmail.com'},
{name = 'Stefan Stoll', email='stst@uw.edu'}]
keywords=['Spin-label', 'EPR', 'DEER', 'PELDOR', 'Side-chain']
description = "A package for modeling non-canonical amino acid side chain ensembles."
readme = "README.md"
license = "GPL-3.0-only"
license-files = ["LICENSE"]
authors = [
{name = "Maxx Tessmer", email = "mhtessmer@gmail.com"},
{name = "Stefan Stoll", email = "stst@uw.edu"},
]
keywords = ["Spin-label", "EPR", "DEER", "PELDOR", "Side-chain"]
dynamic = ["version"]
requires-python = ">= 3.8,<3.14"
dependencies = ['numpy>=1.23.0',
'scipy>=1.6.3',
'matplotlib>=3.3.4',
'numba>=0.55.0',
'mdanalysis>=2.0.0',
'tqdm>=4.45.0',
'pytest>=6.2.2',
'memoization>=0.3.1',
'igraph>=0.10.3',
'rtoml>=0.9.0']

classifiers=['License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12']
requires-python = ">=3.10"
dependencies = [
"numpy>=1.23.0",
"scipy>=1.8.0",
"matplotlib>=3.5.0",
"numba>=0.56.2",
"mdanalysis>=2.2.0",
"tqdm>=4.45.0",
"pytest>=6.2.2",
"memoization>=0.3.1",
"igraph>=0.10.3",
"rtoml>=0.9.0",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Physics",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]

[project.urls]
homepage = 'https://github.com/StollLab/chiLife'
homepage = "https://github.com/StollLab/chiLife"
documentation = "https://stolllab.github.io/chiLife/"

[project.optional-dependencies]
smiles2residue = ["rdkit>=2023.9.6"]
openmm = ["openmm>=8.1.1"]

[tool.setuptools]
script-files = ['scripts/update_rotlib.py', 'scripts/oldProteinIC.py']
script-files = ["scripts/update_rotlib.py", "scripts/oldProteinIC.py"]

[tool.setuptools.package-data]
chilife = ['data/*', 'data/*/*', 'data/*/*/*']
chilife = ["data/**/*"]

[tool.setuptools.dynamic]
version = {attr = "chilife.__version__"}

[tool.pytest.ini_options]
addopts = ["-ra", "--strict-markers"]
filterwarnings = [
# Tests build single-frame in-memory MDAnalysis Universes directly; chiLife's own loaders already suppress this.
"ignore:Reader has no dt information:UserWarning",
]

[build-system]
requires = ["setuptools", "matplotlib", "wheel"]
requires = ["setuptools>=77", "matplotlib"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion src/chilife/IntrinsicLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, res, atom_selection, spin_atoms=None, name='IntrinsicLabel'):
sa_mask = np.isin(self.atom_names, self.spin_atoms,)

self.spin_idx = np.argwhere(sa_mask)
self.spin_idx.shape = -1
self.spin_idx = self.spin_idx.reshape(-1)

self.atoms = [FreeAtom(atom.name, atom.type, idx, atom.resname, atom.resnum, atom.position)
for idx, atom in enumerate(self._selection.atoms)]
Expand Down
10 changes: 9 additions & 1 deletion src/chilife/MolSys.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"chains",
"occupancies",
"bs",
"tempfactors",
"segs",
"segids",
"atypes",
Expand Down Expand Up @@ -70,6 +71,7 @@
"segid": "segids",
"charge": "charges",
"bfactor": "bs",
"tempfactor": "bs",
"qfactor": "occupancies",
"occupancy": "occupancies",
"segix": "segixs",
Expand Down Expand Up @@ -1168,7 +1170,7 @@ def from_cif(cls, file_name):
icodes = np.array(atom_site_data["pdbx_PDB_ins_code"][:n_atoms])
icodes[icodes == "?"] = ""

segs = np.char.array(atom_site_data["label_asym_id"][:n_atoms])
segs = np.array(atom_site_data["label_asym_id"][:n_atoms], dtype=str)

raw_eid = atom_site_data["label_entity_id"][:n_atoms]
parsed_eid = np.array(
Expand Down Expand Up @@ -1693,6 +1695,12 @@ def _segments(self):
]
return self._segments_list

@property
def tempfactors(self):
"""Alias of ``bs`` matching the MDAnalysis ``tempfactors`` attribute. A property rather than an attribute set
in ``__init__`` so that it also exists on MolSys objects unpickled from older files."""
return self.bs

@property
def molsys(self):
return self
Expand Down
2 changes: 1 addition & 1 deletion src/chilife/MolSysIC.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def nonbonded(self):
dtype=int,
)

self._nonbonded.shape = (-1, 2)
self._nonbonded = self._nonbonded.reshape(-1, 2)

return self._nonbonded

Expand Down
2 changes: 1 addition & 1 deletion src/chilife/SpinLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, label, site=None, protein=None, chain=None, rotlib=None, **kw
self.spin_atoms = self.spin_atoms[sa_mask]
self.spin_weights = self.spin_weights[sa_mask]
self.spin_idx = np.argwhere(np.isin(self.atom_names, self.spin_atoms))
self.spin_idx.shape = -1
self.spin_idx = self.spin_idx.reshape(-1)

@property
def spin_coords(self):
Expand Down
3 changes: 1 addition & 2 deletions src/chilife/SpinLigand.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ def __init__(self, res, site=None, protein=None, chain=None, rotlib=None, **kwar

self.spin_atoms = self.atom_names[spin_atoms].copy()
self.spin_weights = spin_weights
self.spin_idx = spin_atoms
self.spin_idx.shape = -1
self.spin_idx = spin_atoms.reshape(-1)
2 changes: 1 addition & 1 deletion src/chilife/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
# SpinLabel = SpinLabel.SpinLabel
# dSpinLabel = dSpinLabel.dSpinLabel

__version__ = "1.2.5"
__version__ = "1.3.0"
2 changes: 1 addition & 1 deletion src/chilife/chilife.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def create_library(
)

if dihedrals.shape == (len(dihedrals),):
dihedrals.shape = (len(dihedrals), 1)
dihedrals = dihedrals.reshape(-1, 1)

if weights is None:
weights = np.ones(len(dihedrals))
Expand Down
8 changes: 4 additions & 4 deletions src/chilife/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,8 @@ def write_frame(pdb_file: TextIO, atoms, frame=None, coords=None):
"occupancies", np.ones(len(atoms.universe.atoms))
)

if not hasattr(atoms.universe, "bfactors"):
atoms.universe.add_TopologyAttr("bfactors", np.ones(len(atoms.universe.atoms)))
if not hasattr(atoms.universe, "tempfactors"):
atoms.universe.add_TopologyAttr("tempfactors", np.ones(len(atoms.universe.atoms)))

[
pdb_file.write(
Expand All @@ -1263,7 +1263,7 @@ def write_frame(pdb_file: TextIO, atoms, frame=None, coords=None):
atom.resnum,
*coord,
atom.occupancy,
atom.bfactor,
atom.tempfactor,
atom.type,
)
)
Expand Down Expand Up @@ -1468,7 +1468,7 @@ def write_atoms(
for atom, coord in zip(atoms, coords):
file.write(
f"ATOM {atom.index + 1:5d} {atom.name:^4s} {atom.resname:3s} {'A':1s}{atom.resnum:4d} "
f"{coord[0]:8.3f}{coord[1]:8.3f}{coord[2]:8.3f}{atom.occupancy:6.2f}{atom.bfactor:6.2f} {atom.type:>2s} \n"
f"{coord[0]:8.3f}{coord[1]:8.3f}{coord[2]:8.3f}{atom.occupancy:6.2f}{atom.tempfactor:6.2f} {atom.type:>2s} \n"
)


Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
from pathlib import Path

# Test modules reference data via relative paths such as "test_data/1ubq.pdb",
# and several load them at import time. Switch to the tests directory before
# collection so tests work no matter where pytest is launched from.
os.chdir(Path(__file__).parent)
2 changes: 1 addition & 1 deletion tests/test_MolSysIC.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_set_dihedral2():
print("DSF")


@pytest.mark.parametrize(["inp", "ans"], zip(gd_kwargs, gd_ans))
@pytest.mark.parametrize(["inp", "ans"], list(zip(gd_kwargs, gd_ans)))
def test_get_dihedral(inp, ans):
ubqIC = xl.MolSysIC.from_atoms(ubq)
dihedral = ubqIC.get_dihedral(**inp)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ProteinUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ def test_mkpep_template():
tphi = np.rad2deg(pep_IC.z_matrix[phi_idx, 2])
tpsi = np.rad2deg(pep_IC.z_matrix[psi_idx, 2])

np.testing.assert_allclose(phi, tphi)
np.testing.assert_allclose(psi, tpsi)
np.testing.assert_allclose(phi, tphi, atol=1e-4)
np.testing.assert_allclose(psi, tpsi, atol=1e-4)


def test_parsed_sequence():
Expand All @@ -597,7 +597,7 @@ def test_parsed_sequence():
s2rans = [f"test_data/s2rm{i + 1}.npy" for i in range(len(s2rkeys))]


@pytest.mark.parametrize("key, ans", zip(s2rkeys, s2rans))
@pytest.mark.parametrize("key, ans", list(zip(s2rkeys, s2rans)))
def test_smiles2residue(key, ans):
m1 = chilife.smiles2residue(key, randomSeed=0)
test_mask = np.argsort(m1.names)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_Scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
lj_rot_idx = [0, 5, 5]


@pytest.mark.parametrize(("func", "ans", "rot_idx"), zip(lj_funcs, lj_ans, lj_rot_idx))
@pytest.mark.parametrize(("func", "ans", "rot_idx"), list(zip(lj_funcs, lj_ans, lj_rot_idx)))
def test_lj(func, ans, rot_idx):
f = chilife.ljEnergyFunc(func)
RL = chilife.RotamerEnsemble("TRP", 28, protein, energy_func=f, eval_clash=True)
Expand Down
13 changes: 12 additions & 1 deletion tests/test_Topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
import MDAnalysis
import chilife as xl
from chilife.Topology import *
from MDAnalysis.topology.guessers import guess_angles, guess_dihedrals

try: # MDAnalysis >= 2.8
from MDAnalysis.guesser import DefaultGuesser

def guess_angles(bonds):
return DefaultGuesser(None).guess_angles(bonds)

def guess_dihedrals(angles):
return DefaultGuesser(None).guess_dihedrals(angles)

except ImportError: # older MDAnalysis
from MDAnalysis.topology.guessers import guess_angles, guess_dihedrals

ubq = xl.MolSys.from_pdb('test_data/1ubq.pdb', sort_atoms=True)
mbp = MDAnalysis.Universe("test_data/2klf.pdb", in_memory=True)
Expand Down
Loading
Loading