Skip to content

Commit

Permalink
Merge pull request #10 from padix-key/update
Browse files Browse the repository at this point in the history
Update package to newest Python and Biotite versions
  • Loading branch information
padix-key authored Jul 25, 2024
2 parents 37d6530 + 69ddfc2 commit 9bb079e
Show file tree
Hide file tree
Showing 34 changed files with 1,199 additions and 1,068 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- published

env:
CIBW_BUILD: cp39-* cp310-* cp311-*
CIBW_BUILD: cp310-* cp311-* cp312-*
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_WINDOWS: "x86 AMD64"
Expand All @@ -27,15 +27,30 @@ env:


jobs:
lint:
name: Check code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install ruff
run: pip install ruff==0.5.2
- name: Check code formatting
run: ruff format --diff
- name: Lint code base
run: ruff check

test-and-build:
name: "Build & Test"
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
os: [ubuntu-latest, windows-latest, macos-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
Expand All @@ -44,7 +59,7 @@ jobs:
platforms: all

- name: Build & (optionally) test wheels
uses: pypa/cibuildwheel@v2.12.1
uses: pypa/cibuildwheel@v2.19.1

- uses: actions/upload-artifact@v3
with:
Expand All @@ -57,7 +72,7 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -79,7 +94,7 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: hydride
Expand All @@ -102,7 +117,11 @@ jobs:
name: Upload to GitHub Releases & PyPI
permissions:
contents: write
needs: [test-and-build, make-sdist, make-doc]
needs:
- lint
- test-and-build
- make-sdist
- make-doc
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ htmlcov
# Ignore all compiled python files (e.g. from running the unit tests)
*.pyc
*.pyo
*.py{}
*.py-e

# Ignore files created via Cython
Expand All @@ -42,5 +41,6 @@ htmlcov
*.code-workspace
.vscode/*

# Ignore fuse_hidden files on Linux systems
# Ignore OS specific files
*.fuse_hidden*
.DS_Store
6 changes: 2 additions & 4 deletions doc/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Structure input and output

``--infile``/``-i`` and ``-outfile``/``-o`` define the paths of the input or
output structure file, respectively.
*Hydride* supports the *PDB*, *PDBx/mmCIF*, *MMTF*, *MOL* and *SDF*
*Hydride* supports the *PDB*, *PDBx/mmCIF*, *BinaryCIF*, *MOL* and *SDF*
format.
By default, the format is determined from the file extension, but it can also
be explicitly provided via the ``--informat``/``-I`` or
Expand All @@ -38,8 +38,6 @@ used is specified with ``--model``/``-m``. By default, the first model is used.

The addition of hydrogen atoms requires complete information about the
bonds between atoms.
Currently, this information can only be read from *PDB*, *MMTF*, *MOL* and
*SDF* files.
If bond information is absent, *Hydride* automatically connects
atoms based on the molecule/residue name and the atom names.
However, the automatic bond detection only works for molecules in the
Expand Down Expand Up @@ -97,7 +95,7 @@ libraries by providing a path to a corresponding structure file via
Analogous to the input and output file parameters, the file format can be
specified with ``--fragformat``/``-f``.
Note that the file must contain proper bond information and correct formal
charges, so effectively a *MMTF*, *MOL* and *SDF* must be supplied.
charges.

By default, *Hydride* does not consider periodic boundary conditions,
as they appear e.g. in MD simulations.
Expand Down
60 changes: 32 additions & 28 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,40 @@
try:
import numpy as np
import pyximport

pyximport.install(
build_in_temp=False,
setup_args={"include_dirs":np.get_include()},
language_level=3
setup_args={"include_dirs": np.get_include()},
language_level=3,
)
except ImportError:
pass

from os.path import realpath, dirname, join, isdir, isfile, basename
from os import listdir, makedirs
import sys
from os.path import dirname, join, realpath

doc_path = dirname(realpath(__file__))
# Include hydride/src in PYTHONPATH
# in order to import the 'hydride' package
package_path = join(dirname(doc_path), "src")
sys.path.insert(0, package_path)
import hydride

# Include gecos/doc in PYTHONPATH
# in order to import modules for plot genaration etc.
sys.path.insert(0, doc_path)


#### General ####

extensions = ["sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"numpydoc"]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"numpydoc",
]

templates_path = ["templates"]
source_suffix = [".rst"]
Expand All @@ -62,25 +65,26 @@

html_theme = "alabaster"
html_static_path = ["static"]
html_css_files = [
"hydride.css",
"fonts.css"
]
html_css_files = ["hydride.css", "fonts.css"]
html_favicon = "static/assets/hydride_icon_32p.png"
htmlhelp_basename = "HydrideDoc"
html_sidebars = {"**": ["about.html",
"navigation.html",
"relations.html",
"searchbox.html",
"donate.html"]}
html_sidebars = {
"**": [
"about.html",
"navigation.html",
"relations.html",
"searchbox.html",
"donate.html",
]
}
html_theme_options = {
"description" : "Adding hydrogen atoms to molecular models",
"logo" : "assets/hydride_logo.png",
"logo_name" : "false",
"github_user" : "biotite-dev",
"github_repo" : "hydride",
"github_type" : "star",
"github_banner" : "true",
"page_width" : "85%",
"fixed_sidebar" : "true"
"description": "Adding hydrogen atoms to molecular models",
"logo": "assets/hydride_logo.png",
"logo_name": "false",
"github_user": "biotite-dev",
"github_repo": "hydride",
"github_type": "star",
"github_banner": "true",
"page_width": "85%",
"fixed_sidebar": "true",
}
15 changes: 8 additions & 7 deletions doc/figure_scripts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
"""

import tempfile
import ammolite
import biotite.structure as struc
import biotite.structure.io.mol as mol
import biotite.structure.info as info
import ammolite
import biotite.structure.io.mol as mol
from util import COLORS, init_pymol_parameters


ZOOM = 1.5
PNG_SIZE = (400, 400)

Expand Down Expand Up @@ -63,7 +62,7 @@ def color_atoms(pymol_object, atom_array):

print("\nEND OF SNIPPET\n")
pymol_heavy = ammolite.PyMOLObject.from_structure(molecule, "heavy")
#pymol_heavy.orient()
# pymol_heavy.orient()
pymol_heavy.zoom(buffer=ZOOM)
color_atoms(pymol_heavy, molecule)
ammolite.cmd.png("api_01.png", *PNG_SIZE)
Expand Down Expand Up @@ -168,9 +167,10 @@ def color_atoms(pymol_object, atom_array):


print("\nEND OF SNIPPET\n", end="")
import matplotlib.pyplot as plt
import matplotlib as mpl
plt.rcParams['axes.prop_cycle'] = mpl.cycler(color=[COLORS["N"]])
import matplotlib.pyplot as plt

plt.rcParams["axes.prop_cycle"] = mpl.cycler(color=[COLORS["N"]])


########################################################################
Expand Down Expand Up @@ -201,6 +201,7 @@ def color_atoms(pymol_object, atom_array):
fig.savefig("api_04.png")

import biotite.structure.info as info

molecule = info.residue("ASP")


Expand Down Expand Up @@ -229,4 +230,4 @@ def color_atoms(pymol_object, atom_array):

#
#
########################################################################
########################################################################
32 changes: 13 additions & 19 deletions doc/figure_scripts/cover_structure.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import numpy as np
import pyximport

pyximport.install(
build_in_temp=False,
setup_args={"include_dirs":np.get_include()},
language_level=3
build_in_temp=False, setup_args={"include_dirs": np.get_include()}, language_level=3
)

from os.path import join
import numpy as np
import biotite.structure as struc
import biotite.structure.io.mmtf as mmtf
import biotite.database.rcsb as rcsb
import hydride
import ammolite
import biotite.database.rcsb as rcsb
import biotite.structure as struc
import biotite.structure.io.pdbx as pdbx
import numpy as np
from util import COLORS, init_pymol_parameters
import hydride


mmtf_file = mmtf.MMTFFile.read(rcsb.fetch("1bna", "mmtf"))
heavy_atoms = mmtf.get_structure(
mmtf_file, model=1, include_bonds=True, extra_fields=["charge"]
pdbx_file = pdbx.BinaryCIFFile.read(rcsb.fetch("1bna", "bcif"))
heavy_atoms = pdbx.get_structure(
pdbx_file, model=1, include_bonds=True, extra_fields=["charge"]
)
heavy_atoms = heavy_atoms[heavy_atoms.res_name != "HOH"]

Expand All @@ -43,9 +40,7 @@
pymol_all.zoom(buffer=1.0)
ammolite.cmd.rotate("z", 90)

for pymol_object, atoms in zip(
(pymol_heavy, pymol_all), (heavy_atoms, all_atoms)
):
for pymol_object, atoms in zip((pymol_heavy, pymol_all), (heavy_atoms, all_atoms)):
for element in ("H", "C", "N", "O", "P"):
pymol_object.color(COLORS[element], atoms.element == element)

Expand All @@ -56,9 +51,8 @@
pymol_heavy.disable()
pymol_all.enable()
for i, (_, atom_i, atom_j) in enumerate(bonds):
color = COLORS["N"] if all_atoms.element[atom_j] == "N"\
else COLORS["O"]
color = COLORS["N"] if all_atoms.element[atom_j] == "N" else COLORS["O"]
pymol_all.distance(str(i), atom_i, atom_j, show_label=False)
ammolite.cmd.set_color(f"bond_color_{i}", list(color))
ammolite.cmd.color(f"bond_color_{i}", str(i))
ammolite.cmd.png("cover_hydrogenated.png", 400, 800)
ammolite.cmd.png("cover_hydrogenated.png", 400, 800)
Loading

0 comments on commit 9bb079e

Please sign in to comment.