Skip to content

Commit

Permalink
Merge branch 'PDBE-7032' of https://github.com/PDBeurope/ccdutils int…
Browse files Browse the repository at this point in the history
…o PDBE-7032
  • Loading branch information
roshan committed Sep 4, 2024
2 parents dba5cc0 + 017b1b2 commit 7a808c4
Show file tree
Hide file tree
Showing 28 changed files with 1,357 additions and 51 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
with:
python-version: "3.10"
- run: |
pip install rdkit
pip install -e ".[docs]"
pip install poetry
poetry install --with docs
- run: |
cd doc
make html
poetry run make html
- name: Deploy pages
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install poetry
poetry install
- name: Build package
run: python -m build
run: poetry build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
python-version: "3.10"

- run: |
pip install rdkit==2023.09.6
pip install -e ".[tests]"
pip install poetry
pip install pre-commit
pre-commit install && pre-commit run --all
- run: pytest --cov=pdbeccdutils
poetry install --with tests
poetry run pre-commit install && pre-commit run --all
- run: poetry run pytest --cov=pdbeccdutils
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ repos:
- id: end-of-file-fixer
- id: check-ast

- repo: https://github.com/ambv/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5 # Ruff version.
hooks:
- id: black

- repo: https://github.com/pycqa/flake8
rev: 3.9.1
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/dzhu/rstfmt
rev: v0.0.14
hooks:
- id: flake8
args: ["--max-line-length=88", "--ignore=E501,W503"]
exclude: \.cif$
- id: rstfmt
name: rST Formatter
2 changes: 1 addition & 1 deletion pdbeccdutils/core/boundmolecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def infer_bound_molecules(structure, to_discard, assembly=False):
bm = BoundMolecule(subgraph)
bound_molecules.append(bm)

bound_molecules = sorted(bound_molecules, key=lambda l: -len(l.graph.nodes))
bound_molecules = sorted(bound_molecules, key=lambda item: -len(item.graph.nodes))
return bound_molecules


Expand Down
1 change: 1 addition & 0 deletions pdbeccdutils/core/ccd_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
CCDUtilsError: If deemed format is not supported or an unrecoverable
error occurres.
"""

import json
import logging
import math
Expand Down
1 change: 0 additions & 1 deletion pdbeccdutils/core/clc_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def read_pdb_cif_file(


def infer_multiple_chem_comp(path_to_cif, bm, bm_id, sanitize=True):

"""Args:
path_to_cif: Path to input structure
bm: bound-molecules identified from input structure
Expand Down
11 changes: 6 additions & 5 deletions pdbeccdutils/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,12 @@ def export_2d_svg(
Raises:
CCDUtilsError: If bond or atom does not exist.
"""
get_atom_name = (
lambda a: a.GetProp("name")
if a.HasProp("name")
else a.GetSymbol() + str(a.GetIdx())
)

def get_atom_name(atom):
if atom.HasProp("name"):
return atom.GetProp("name")
else:
return f"{atom.GetSymbol()}{atom.GetIdx()}"

if self.mol2D is None:
drawing.save_no_image(file_name, self.id, width)
Expand Down
3 changes: 2 additions & 1 deletion pdbeccdutils/core/depictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
quality
"""

import logging
import math
import os
Expand Down Expand Up @@ -118,7 +119,7 @@ def depict_molecule(

results = results + template_res

results.sort(key=lambda l: (l.score, l.source))
results.sort(key=lambda item: (item.score, item.source))

if results:
to_return = results[0]
Expand Down
4 changes: 2 additions & 2 deletions pdbeccdutils/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def __eq__(self, other) -> bool:
class BoundMolecule:
def __init__(self, graph):
self.graph = graph
self.nodes = sorted(self.graph, key=lambda l: (int(l.res_id), l.chain))
self.nodes = sorted(self.graph, key=lambda item: (int(item.res_id), item.chain))

@property
def id(self) -> str:
Expand Down Expand Up @@ -362,7 +362,7 @@ def to_dict(self):
dict of `str`: dict representation of the object
"""

nodes = sorted(self.graph, key=lambda l: (int(l.res_id), l.chain))
nodes = sorted(self.graph, key=lambda item: (int(item.res_id), item.chain))

results_bag = {}
results_bag["residues"] = [x.to_dict() for x in nodes]
Expand Down
1 change: 1 addition & 0 deletions pdbeccdutils/core/prd_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
CCDUtilsError: If deemed format is not supported or an unrecoverable
error occurres.
"""

import json
import math
from pathlib import Path
Expand Down
3 changes: 1 addition & 2 deletions pdbeccdutils/helpers/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
# specific language governing permissions and limitations
# under the License.

"""Module helper providing drawing functionality based on RDKit
"""
"""Module helper providing drawing functionality based on RDKit"""

import os
import re
Expand Down
4 changes: 1 addition & 3 deletions pdbeccdutils/helpers/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
# specific language governing permissions and limitations
# under the License.

"""Generic helper functions that may be re-used
"""
"""Generic helper functions that may be re-used"""

import os
import sys
Expand Down Expand Up @@ -145,7 +144,6 @@ def requests_retry_session(
status_forcelist=(429, 500, 502, 503, 504),
session=None,
):

session = session or requests.Session()
retry = Retry(
total=retries,
Expand Down
1 change: 1 addition & 0 deletions pdbeccdutils/scripts/process_components_cif_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
https://gitlab.ebi.ac.uk/pdbe/release/pdbechem
"""

import argparse
import logging
import os
Expand Down
1 change: 1 addition & 0 deletions pdbeccdutils/scripts/setup_pubchem_library_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
the pdbeccdutils. Based on the inchikey provided in the CCD
a corresponding 2D layout is downloaded from PubChem database.
"""

import argparse
import os
import sys
Expand Down
4 changes: 2 additions & 2 deletions pdbeccdutils/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Common fixtures shared among all the tests
"""
"""Common fixtures shared among all the tests"""

import pytest
from pdbeccdutils.core import ccd_reader, clc_reader
from pdbeccdutils.core.fragment_library import FragmentLibrary
Expand Down
3 changes: 1 addition & 2 deletions pdbeccdutils/tests/test_bound_molecule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Common fixtures shared among all the tests
"""
"""Common fixtures shared among all the tests"""

import json
import pytest
Expand Down
1 change: 1 addition & 0 deletions pdbeccdutils/tests/test_clc_reader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
load 6lq4_updated.cif from file and test important cif item.
"""

import pytest
from pdbeccdutils.core import clc_reader
from pdbeccdutils.core.models import ReleaseStatus
Expand Down
3 changes: 1 addition & 2 deletions pdbeccdutils/tests/test_fragment_library.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test fragment library functionality
"""
"""Test fragment library functionality"""

import os

Expand Down
1 change: 1 addition & 0 deletions pdbeccdutils/tests/test_load_eoh_cif.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
load EOH.cif from file and test important cif item.
"""

import pytest

from pdbeccdutils.core import ccd_reader, ccd_writer
Expand Down
3 changes: 1 addition & 2 deletions pdbeccdutils/tests/test_parity.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test of PARITY method
"""
"""Test of PARITY method"""

import pytest

Expand Down
1 change: 1 addition & 0 deletions pdbeccdutils/tests/test_process_components_cif_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
http://dustinrcollins.com/testing-python-command-line-apps
adapted to use nose then converted to pytest
"""

import json
import os
import re
Expand Down
3 changes: 1 addition & 2 deletions pdbeccdutils/tests/test_web_services.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test of routine for retrieving 2D layouts of the CCDs.
"""
"""Test of routine for retrieving 2D layouts of the CCDs."""

import os

Expand Down
4 changes: 1 addition & 3 deletions pdbeccdutils/tests/test_write_img.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Unit tests for checking whether or not depictions are written properly.
"""

"""Unit tests for checking whether or not depictions are written properly."""

import json
import os
Expand Down
4 changes: 2 additions & 2 deletions pdbeccdutils/utils/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Package configuration with the paths to the templates
"""
"""Package configuration with the paths to the templates"""

import os
import pdbeccdutils

Expand Down
3 changes: 1 addition & 2 deletions pdbeccdutils/utils/web_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
# specific language governing permissions and limitations
# under the License.

"""module handling UniChem mapping
"""
"""module handling UniChem mapping"""

from pdbeccdutils.helpers import helper

Expand Down
Loading

0 comments on commit 7a808c4

Please sign in to comment.