Skip to content
Merged
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
38 changes: 20 additions & 18 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,28 @@ jobs:

- name: Install dssp
run: |
sudo apt-get install libboost-all-dev
wget https://github.com/cmbi/dssp/archive/refs/tags/2.3.0.zip
mv 2.3.0.zip dssp-2.3.0.zip
unzip dssp-2.3.0.zip
cd dssp-2.3.0
./autogen.sh
./configure
make mkdssp
cp mkdssp ..
sudo apt-get update
sudo apt-get install -y cmake libboost-all-dev zlib1g-dev libbz2-dev
git clone --branch v4.5.8 --depth 1 https://github.com/PDB-REDO/dssp.git
cmake -S dssp -B dssp/build
cmake --build dssp/build --target mkdssp
cp dssp/build/mkdssp .

- name: Install DSSP data files
run: |
mkdir -p "$GITHUB_WORKSPACE/libcifpp-data"
curl -L -o "$GITHUB_WORKSPACE/libcifpp-data/components.cif" https://files.wwpdb.org/pub/pdb/data/monomers/components.cif
curl -L -o "$GITHUB_WORKSPACE/libcifpp-data/mmcif_pdbx.dic" https://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v50.dic
echo "LIBCIFPP_DATA_DIR=$GITHUB_WORKSPACE/libcifpp-data" >> "$GITHUB_ENV"

- name: Install stride
run: |
wget --no-check-certificate https://webclu.bio.wzw.tum.de/stride/stride.tar.gz
mkdir stride-src
mv stride.tar.gz stride-src/
git clone https://github.com/MDAnalysis/stride.git stride-src
cd stride-src
tar zxvf stride.tar.gz
make
cp stride ..
cd ..
git checkout 867a5eb0f2479cb16615512a53ee472c54649505
make -C src
cp src/stride "$GITHUB_WORKSPACE/stride"
chmod +x "$GITHUB_WORKSPACE/stride"

- name: Install msms
run: |
Expand All @@ -56,11 +58,11 @@ jobs:
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install .
pip3 install ".[dev]"

- name: Test with pytest
run: |
pytest --exitfirst --verbose --failed-first \
python -m pytest --exitfirst --verbose --failed-first \
--cov=. --cov-report html

- name: Install pypa/build
Expand Down
38 changes: 20 additions & 18 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,28 @@ jobs:

- name: Install dssp
run: |
sudo apt-get install libboost-all-dev
wget https://github.com/cmbi/dssp/archive/refs/tags/2.3.0.zip
mv 2.3.0.zip dssp-2.3.0.zip
unzip dssp-2.3.0.zip
cd dssp-2.3.0
./autogen.sh
./configure
make mkdssp
cp mkdssp ..
sudo apt-get update
sudo apt-get install -y cmake libboost-all-dev zlib1g-dev libbz2-dev
git clone --branch v4.5.8 --depth 1 https://github.com/PDB-REDO/dssp.git
cmake -S dssp -B dssp/build
cmake --build dssp/build --target mkdssp
cp dssp/build/mkdssp .

- name: Install DSSP data files
run: |
mkdir -p "$GITHUB_WORKSPACE/libcifpp-data"
curl -L -o "$GITHUB_WORKSPACE/libcifpp-data/components.cif" https://files.wwpdb.org/pub/pdb/data/monomers/components.cif
curl -L -o "$GITHUB_WORKSPACE/libcifpp-data/mmcif_pdbx.dic" https://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v50.dic
echo "LIBCIFPP_DATA_DIR=$GITHUB_WORKSPACE/libcifpp-data" >> "$GITHUB_ENV"

- name: Install stride
run: |
wget --no-check-certificate https://webclu.bio.wzw.tum.de/stride/stride.tar.gz
mkdir stride-src
mv stride.tar.gz stride-src/
git clone https://github.com/MDAnalysis/stride.git stride-src
cd stride-src
tar zxvf stride.tar.gz
make
cp stride ..
cd ..
git checkout 867a5eb0f2479cb16615512a53ee472c54649505
make -C src
cp src/stride "$GITHUB_WORKSPACE/stride"
chmod +x "$GITHUB_WORKSPACE/stride"

- name: Install msms
run: |
Expand All @@ -51,10 +53,10 @@ jobs:
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install .
pip3 install ".[dev]"

- name: Test with pytest
run: |
pytest --exitfirst --verbose --failed-first \
python -m pytest --exitfirst --verbose --failed-first \
--cov=. --cov-report html

5 changes: 2 additions & 3 deletions sbmlcore/AminoAcidProperties.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
from importlib.resources import files

import pandas
#N.B. All property scales have been checked! CIL
Expand Down Expand Up @@ -87,7 +87,7 @@ class AminoAcidRogovChange(AminoAcidPropertyChange):

def __init__(self):

filename = pkg_resources.resource_filename("sbmlcore", 'data/rogov.csv')
filename = files("sbmlcore").joinpath("data/rogov.csv")
self.lookup = pandas.read_csv(filename)
Comment on lines +90 to 91

def split_row(row):
Expand Down Expand Up @@ -356,4 +356,3 @@ def __init__(self):
self.lookup = _make_table(h_donors)
self.lookup.rename(columns = {'value': 'h_acceptors'}, inplace=True)
self.lookup.set_index(['amino_acid'],inplace=True)

3 changes: 2 additions & 1 deletion sbmlcore/ResidueDepth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, pdb_file, segids=None, offsets=None):
for chain in offsets:
assert chain in chain_list, "Need to specify a segid that exists in pdb!"
assert isinstance(offsets[chain], int), "Offsets for each segid must be an integer!"
segids = list(offsets)

rows = {'segid': [],\
'resid': [],\
Expand Down Expand Up @@ -82,4 +83,4 @@ def split_mutation(row):

other.drop(columns = ['resid'], inplace=True)

return(other)
return(other)
13 changes: 12 additions & 1 deletion sbmlcore/StructuralDistances.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import pandas
import pathlib
import MDAnalysis
import sbmlcore


def _load_mdanalysis():
try:
import MDAnalysis
except Exception as exc: # pragma: no cover - environment dependent
raise ImportError(
"MDAnalysis is required for StructuralDistances. Install sbmlcore with the 'md' extra."
) from exc

return MDAnalysis


class StructuralDistances(object):
"""
Distances between a specified region (i.e. origin) and all amino acids in a protein.
Expand Down Expand Up @@ -41,6 +51,7 @@ def __init__(
# check file exists
assert pathlib.Path(pdb_file).is_file(), "File does not exist!"

MDAnalysis = _load_mdanalysis()
u = MDAnalysis.Universe(pdb_file)

assert dataset_type in [
Expand Down
13 changes: 12 additions & 1 deletion sbmlcore/TempFactors.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import pandas
import pathlib
import MDAnalysis
import sbmlcore


def _load_mdanalysis():
try:
import MDAnalysis
except Exception as exc: # pragma: no cover - environment dependent
raise ImportError(
"MDAnalysis is required for TempFactors. Install sbmlcore with the 'md' extra."
) from exc

return MDAnalysis


class TempFactors(object):
"""
Distances between a specified region (i.e. origin) and all amino acids in a protein.
Expand All @@ -29,6 +39,7 @@ def __init__(self, pdb_file, offsets=None):
# check file exists
assert pathlib.Path(pdb_file).is_file(), "File does not exist!"

MDAnalysis = _load_mdanalysis()
u = MDAnalysis.Universe(pdb_file)

# apply any offsets to the residue numbering
Expand Down
20 changes: 18 additions & 2 deletions sbmlcore/TrajectoryDihedrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

import pandas
import numpy
import MDAnalysis
from MDAnalysis.analysis.dihedrals import Dihedral
import sbmlcore


def _load_mdanalysis():
try:
import MDAnalysis
from MDAnalysis.analysis.dihedrals import Dihedral
except Exception as exc: # pragma: no cover - environment dependent
raise ImportError(
"MDAnalysis is required for TrajectoryDihedrals. Install sbmlcore with the 'md' extra."
) from exc

return MDAnalysis, Dihedral


class TrajectoryDihedrals(object):
"""Average dihedrals between a specified region (i.e. origin) and all amino acids in a protein.

Expand Down Expand Up @@ -106,6 +116,7 @@ def __init__(
self.dihedral = dihedral
self.angle_type = angle_type

MDAnalysis, Dihedral = _load_mdanalysis()
first_pass = True

for trajectory in trajectory_list:
Expand Down Expand Up @@ -190,6 +201,7 @@ def calculate_dihedrals(self, trajectory, protein_res):
and returns array of shape (timesteps, residues)
"""

_, Dihedral = _load_mdanalysis()
selection_call = "res." + self.dihedral + "_selection()"

# generate list of nonetype dihedral indexes (residue index)
Expand Down Expand Up @@ -345,6 +357,8 @@ def _filter_frames(pdb, traj, boundary, spec_time, dt):
"""Returns MDAnalysis.Universe with frames greater and
less than the specified start and end times"""

MDAnalysis, _ = _load_mdanalysis()

# Becuase a new universe is essentially being created, every coordinate in the original is needed
coordinates = (
MDAnalysis.analysis.base.AnalysisFromFunction(
Expand Down Expand Up @@ -385,6 +399,8 @@ def _filter_frames(pdb, traj, boundary, spec_time, dt):
def _add_bonds(traj):
"""add bonds to protein (only) in a trajectory"""

MDAnalysis, _ = _load_mdanalysis()

protein_res = traj.select_atoms("protein")
# run the bond guessing algorithm
bonds = MDAnalysis.topology.guessers.guess_bonds(
Expand Down
16 changes: 14 additions & 2 deletions sbmlcore/TrajectoryDistances.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

import pandas
import numpy
import MDAnalysis
import sbmlcore


def _load_mdanalysis():
try:
import MDAnalysis
except Exception as exc: # pragma: no cover - environment dependent
raise ImportError(
"MDAnalysis is required for TrajectoryDistances. Install sbmlcore with the 'md' extra."
) from exc

return MDAnalysis


class TrajectoryDistances(object):
"""
Average distances between a specified region (i.e. origin) and all amino acids in a protein.
Expand Down Expand Up @@ -92,13 +102,13 @@ def __init__(
if start_time is not None:
assert start_time < end_time

MDAnalysis = _load_mdanalysis()
first_pass = True

for trajectory in trajectory_list:

u = MDAnalysis.Universe(pdb_file, trajectory)
u_static = MDAnalysis.Universe(static_pdb)

reference_com = u.select_atoms(distance_selection).center_of_mass()

# check atom selection exists
Expand Down Expand Up @@ -129,6 +139,8 @@ def __init__(
else:
distance_array = numpy.concatenate([distance_array, distances])

assert not first_pass, "No trajectory frames matched the requested time range."

# inverts the array to make subseqeunt calculations more intuitive
distance_array = distance_array.T

Expand Down
Loading
Loading