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
23 changes: 11 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: CI Pipeline (PRs and pushes main)
run-name: Merged to main by ${{ github.actor }}

on:
push:
branches:
- main
branches: [main]
pull_request:
branches:
- main
branches: [main]

permissions:
contents: read
Expand All @@ -23,16 +22,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Install package with pip
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: uv sync --group dev

- name: Run tests
run: pytest
run: uv run pytest
2 changes: 1 addition & 1 deletion .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
name: python-package-distributions
path: dist/
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@release/v1
55 changes: 47 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-illegal-windows-names
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-yaml
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.9.5
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/fpgmaas/deptry
rev: 0.24.0
hooks:
- id: uv-lock
- id: deptry
language: python
additional_dependencies: [deptry]
exclude: '^(?!.*\.py$).*$'
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
- repo: https://github.com/asottile/add-trailing-comma
rev: v4.0.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
rev: v0.14.14
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-check
args:
- --fix
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.9.28
hooks:
- id: uv-lock
- repo: https://github.com/tombi-toml/tombi-pre-commit
rev: v0.7.25
hooks:
- id: tombi-format
- id: tombi-lint
- repo: https://github.com/crate-ci/typos
rev: v1
hooks:
- id: typos
exclude: "^tests/"
- repo: local
hooks:
- id: uv-upgrade
Expand All @@ -25,4 +64,4 @@ repos:
name: pytest
entry: uv run pytest
language: system
pass_filenames: false
pass_filenames: false
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Changed

- In html_json generation, changed substrate from tuple to list of tuples to visualize substrates separately
- Changed Wikidata QID checking from raise errror to log warning (frequent 403 errors)
- Changed Wikidata QID checking from raise error to log warning (frequent 403 errors)

## [1.5.1] 26-07-2025

Expand Down Expand Up @@ -75,7 +75,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Bumped `mite_schema` version to `1.7.0`
- Reworked `ValidationManager`
- Implemented option for intramolecular reactions (recognized from reaction SMARTS)
- Pinned RDkit version to `2024.3.6`
- Pinned RDkit version to `2024.3.6`

## [1.3.1] 02-12-2024

Expand Down Expand Up @@ -142,4 +142,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- Initial version of `mite_extras`
- Initial version of `mite_extras`
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CODE OF CONDUCT

See our organization-level [Code of Conduct](https://github.com/mite-standard/.github/blob/main/CODE_OF_CONDUCT.md).
See our organization-level [Code of Conduct](https://github.com/mite-standard/.github/blob/main/CODE_OF_CONDUCT.md).
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mite_extras
==========

[![DOI](https://zenodo.org/badge/804997522.svg)](https://doi.org/10.5281/zenodo.13941745)
[![DOI](https://zenodo.org/badge/804997522.svg)](https://doi.org/10.5281/zenodo.13941745)
[![PyPI version](https://badge.fury.io/py/mite-extras.svg)](https://badge.fury.io/py/mite-extras)


Expand Down Expand Up @@ -59,7 +59,7 @@ Dependencies including exact versions are specified in the [pyproject.toml](./py

## Quick Start

To validate MITE entries or update them to a new schema versiom, run:
To validate MITE entries or update them to a new schema version, run:

- `mite_extras -i <input/> -o <output/>`

Expand Down Expand Up @@ -87,7 +87,7 @@ This work was supported by the Netherlands Organization for Scientific Research

### With `uv` from GitHub

*Note: assumes that `uv` is installed locally - see the methods described [here](https://docs.astral.sh/uv/getting-started/installation/).*
*Note: assumes that `uv` is installed locally - see the methods described [here](https://docs.astral.sh/uv/getting-started/installation/).*

```commandline
git clone https://github.com/mite-standard/mite_extras
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/mite_extras/main.py → mite_extras/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def config_logger(verboseness: str) -> logging.Logger:
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(
coloredlogs.ColoredFormatter(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
"%(asctime)s - %(name)s - %(levelname)s - %(message)s",
),
)
logger.addHandler(console_handler)
return logger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def to_json(self: Self) -> dict:

if self.databaseIds.to_json() == {}:
raise RuntimeError(
"At least one of 'uniprot' and 'genpept' IDs must be provided."
"At least one of 'uniprot' and 'genpept' IDs must be provided.",
)
else:
json_dict["databaseIds"] = self.databaseIds.to_json()
Expand Down Expand Up @@ -271,7 +271,8 @@ def validate_ids(self):
try:
if self.uniprot and self.genpept:
self._id_validator.cleanup_ids(
genpept=self.genpept, uniprot=self.uniprot
genpept=self.genpept,
uniprot=self.uniprot,
)
elif self.uniprot:
data = self._id_validator.cleanup_ids(uniprot=self.uniprot)
Expand Down Expand Up @@ -336,8 +337,8 @@ def cleanup_smarts(self):
cleaned_smarts = (
self._reaction_validator.reaction_cleaner.clean_ketcher_format(
self._reaction_validator.molecule_validator._clean_string(
self.reactionSMARTS
)
self.reactionSMARTS,
),
)
)

Expand Down Expand Up @@ -372,7 +373,7 @@ def validate_reactions(self):
)
except Exception as e:
raise ValueError(
f"Reaction SMARTS #{reaction_id} - reaction example #{reaction}: Validation failed for substrate {reaction.substrate}: {e!s}"
f"Reaction SMARTS #{reaction_id} - reaction example #{reaction}: Validation failed for substrate {reaction.substrate}: {e!s}",
) from e
return self

Expand Down Expand Up @@ -460,13 +461,13 @@ def validate_smiles(self):
try:
# Clean substrate SMILES
self.substrate = self._molecule_validator.canonicalize_smiles(
self._molecule_validator._clean_string(self.substrate)
self._molecule_validator._clean_string(self.substrate),
)

# Clean product SMILES
self.products = [
self._molecule_validator.canonicalize_smiles(
self._molecule_validator._clean_string(prod)
self._molecule_validator._clean_string(prod),
)
for prod in self.products
]
Expand All @@ -476,7 +477,7 @@ def validate_smiles(self):
cleaned_forbidden = []
for prod in self.forbidden_products:
cleaned = self._molecule_validator.canonicalize_smiles(
self._molecule_validator._clean_string(prod)
self._molecule_validator._clean_string(prod),
)
# Split composite SMILES into individual molecules
cleaned_forbidden.extend(cleaned.split("."))
Expand Down Expand Up @@ -505,7 +506,7 @@ def to_json(self: Self) -> dict:

def to_html(self: Self) -> dict:
def _smiles_to_svg(smiles: str) -> str:
"""Generates a base64 encoded SVG strin"""
"""Generates a base64 encoded SVG string"""
m = MolFromSmiles(smiles)

for atom in m.GetAtoms():
Expand Down Expand Up @@ -538,7 +539,7 @@ def _smiles_to_svg(smiles: str) -> str:
]
except Exception as e:
logger.warning(
f"Error during splitting substrate SMILES for rendering: {e!s}"
f"Error during splitting substrate SMILES for rendering: {e!s}",
)
html_dict["substrate"] = [(self.substrate, _smiles_to_svg(self.substrate))]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ def validate_exists(self):
def read_files_indir(self: Self) -> None:
"""Read files in the indir, store to self"""
logger.debug(
f"FileManager: started reading file in input directory '{self.indir.name}'."
f"FileManager: started reading file in input directory '{self.indir.name}'.",
)

for infile in self.indir.iterdir():
if infile.suffix != ".json":
logger.warning(
f"FileManager: file '{infile.name}' does not apprear to be in .json-format - SKIP."
f"FileManager: file '{infile.name}' does not appear to be in .json-format - SKIP.",
)
continue
self.infiles.append(infile)

logger.debug(
f"FileManager: completed reading file in input directory '{self.indir.name}'."
f"FileManager: completed reading file in input directory '{self.indir.name}'.",
)

def write_json(self: Self, outfile_name: str, payload: dict) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_databaseids_reaction(
return ReactionDatabaseIds(**data)

def get_reactions(self: Self, reactions: list) -> list:
"""Extract reactions infor and converts into internal data structure
"""Extract reactions info and converts into internal data structure

Args:
reactions: list with reaction data
Expand Down Expand Up @@ -166,19 +166,19 @@ def parse_mite_json(self: Self, data: dict):
description=data.get("enzyme", {}).get("description"),
databaseIds=EnyzmeDatabaseIds(**data["enzyme"]["databaseIds"]),
auxiliaryEnzymes=self.get_auxenzymes(
auxenzymes=data.get("enzyme", {}).get("auxiliaryEnzymes")
auxenzymes=data.get("enzyme", {}).get("auxiliaryEnzymes"),
),
references=data.get("enzyme", {}).get("references"),
cofactors=self.get_cofactors(
cofactors=data.get("enzyme", {}).get("cofactors")
cofactors=data.get("enzyme", {}).get("cofactors"),
),
),
reactions=self.get_reactions(reactions=data.get("reactions")),
comment=data.get("comment"),
)
except Exception as e:
msg = str(e).split("For further information visit")[0].rstrip()
msg = f"Error in parsing entry {data.get("accession")}: {msg}"
msg = f"Error in parsing entry {data.get('accession')}: {msg}"
raise ValueError(msg) from e

logger.debug("MiteParser: completed creating Entry object.")
Loading
Loading