From 5fd32e36e4eeaf723b4e10d6fb25be14bb75a204 Mon Sep 17 00:00:00 2001 From: Jacques Serizay Date: Thu, 20 Feb 2025 12:49:22 +0100 Subject: [PATCH] CI and dependencies managment (#20) * fix: list looseversion in dependencies * fix: unpin biopython * fix: raise python pin to 3.13 * fix: GC roudings for tests with GC/gc_fraction * ci: add codecov back * docs: update badges --- .github/workflows/ci.yml | 1 + README.md | 4 ++-- metator.yaml | 5 +++-- pyproject.toml | 10 +++++----- src/metator/network.py | 14 ++++++++++++-- tests/test_network.py | 4 ++-- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66f2cbf..f519c9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,4 +48,5 @@ jobs: run: | ruff check . --select=E9,F63,F7,F82 pytest --cov --cov-report=xml + codecov shell: micromamba-shell {0} diff --git a/README.md b/README.md index aa4ffee..1eb1398 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![PyPI version](https://badge.fury.io/py/metator.svg)](https://badge.fury.io/py/metator) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/metator.svg) -[![Build Status](https://github.com/koszullab/metator/actions/workflows/python-package.yml/badge.svg)](https://github.com/koszullab/metaTOR/actions) +[![Build Status](https://github.com/koszullab/metator/actions/workflows/ci.yml/badge.svg)](https://github.com/koszullab/metaTOR/actions) [![codecov](https://codecov.io/gh/koszullab/metator/branch/master/graph/badge.svg)](https://codecov.io/gh/koszullab/metator) -[![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/koszullab/metator)](https://hub.docker.com/r/koszullab/metator) + [![Read the docs](https://readthedocs.org/projects/metator/badge)](https://metator.readthedocs.io) [![License: GPLv3](https://img.shields.io/badge/License-GPL%203-0298c3.svg)](https://opensource.org/licenses/bo-3.0) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) diff --git a/metator.yaml b/metator.yaml index 396f92e..d31daa9 100644 --- a/metator.yaml +++ b/metator.yaml @@ -4,11 +4,11 @@ channels: - bioconda - defaults dependencies: - - python<3.12 + - python<3.13 - hicstuff - networkx - checkv - - biopython<=1.80 + - biopython - pysam - pairtools - pyfastx @@ -18,6 +18,7 @@ dependencies: - scikit-learn - scipy - seaborn + - looseversion - bowtie2 - pairix - bwa diff --git a/pyproject.toml b/pyproject.toml index 0bc2cde..c7ab2a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "metator" version = "1.3.4" description = "A pipeline for binning metagenomic datasets from metaHiC data." readme = "README.md" -requires-python = ">=3.9,<3.12" +requires-python = ">=3.9,<3.13" license = { text = "GNU General Public License v3 (GPLv3)" } authors = [ @@ -34,7 +34,7 @@ dependencies = [ "hicstuff", "networkx", "checkv", - "biopython<=1.80", + "biopython", "pysam", "pairtools", "pyfastx", @@ -44,18 +44,17 @@ dependencies = [ "scikit-learn", "scipy", "seaborn", + "looseversion", "micomplete" # NON PIP DEPENDENCIES - #"bowtie2" #"pairix" #"bwa" #"samtools" #"prodigal" #"hmmer" - #"gcc" - #"java-jdk" + #"openjdk" ] [project.optional-dependencies] @@ -90,6 +89,7 @@ docs = [ dev = [ "metator[test,docs]", "hatch", + "hatchling", "hatch-build-scripts", "pre-commit", "mypy", diff --git a/src/metator/network.py b/src/metator/network.py index dbf0d55..3e599d9 100644 --- a/src/metator/network.py +++ b/src/metator/network.py @@ -19,6 +19,8 @@ import csv import numpy as np import re +from packaging import version +import Bio from Bio import SeqIO from Bio import SeqUtils from os.path import join, basename @@ -294,10 +296,14 @@ def create_contig_data(assembly, nb_alignment=1, depth_file=None, enzyme=None): line = depth.readline() for contig in SeqIO.parse(assembly, "fasta"): line = depth.readline().split("\t") + if version.parse(Bio.__version__) >= version.parse("1.80"): + gc_content = int(SeqUtils.gc_fraction(contig.seq) * 100 * 10**13) / 10**13 + else: + gc_content = int(SeqUtils.GC(contig.seq) * 10**13) / 10**13 contig_data[contig.id] = { "id": global_id, "length": int(line[1]), - "GC": SeqUtils.gc_fraction(contig.seq)*100, + "GC": gc_content, "hit": 0, "coverage": float(line[2]), "RS": (len(re.findall(pattern, str(contig.seq))) + 1) @@ -312,10 +318,14 @@ def create_contig_data(assembly, nb_alignment=1, depth_file=None, enzyme=None): global_id += 1 else: for contig in SeqIO.parse(assembly, "fasta"): + if version.parse(Bio.__version__) >= version.parse("1.80"): + gc_content = int(SeqUtils.gc_fraction(contig.seq) * 100 * 10**13) / 10**13 + else: + gc_content = int(SeqUtils.GC(contig.seq) * 10**13) / 10**13 contig_data[contig.id] = { "id": global_id, "length": len(contig.seq), - "GC": SeqUtils.gc_fraction(contig.seq)*100, + "GC": gc_content, "hit": 0, "coverage": "-", "RS": (len(re.findall(pattern, str(contig.seq))) + 1) diff --git a/tests/test_network.py b/tests/test_network.py index e63636b..67d6e2f 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -128,7 +128,7 @@ def test_create_contig_data(): assert contig_data["NODE_522"] == { "id": 1, "length": 22786, - "GC": 62.07759150355482, + "GC": 62.0775915035548, "hit": 0, "coverage": "-", "RS": "-", @@ -142,7 +142,7 @@ def test_create_contig_data(): assert contig_data["NODE_522"] == { "id": 1, "length": 22786, - "GC": 62.07759150355482, + "GC": 62.0775915035548, "hit": 0, "coverage": 4.76595, "RS": 162,