Skip to content

Commit

Permalink
Dev fpo (#44)
Browse files Browse the repository at this point in the history
* Improve version checking of third-party software

* Update phylogeny.py

Raxml-ng is not available with version 1.0.0 in bioconda. We should ask for the version 1.0.1 (available in bioconda)

* Update conda badge

* Fix wrong link to conda badge

* Do not hardcode minimum software versions

---------

Co-authored-by: Amine Ghozlane <amine.ghozlane@pasteur.fr>
  • Loading branch information
fplazaonate and aghozlane authored May 3, 2024
1 parent 744df40 commit 392fe45
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Meteor

[![install with conda](https://img.shields.io/conda/vn/aghozlane/meteor?color=green&label=aghozlane%2Fmeteor&logo=anaconda)](https://anaconda.org/aghozlane/meteor)
[![install with conda](https://img.shields.io/conda/vn/bioconda/meteor?color=green&label=bioconda%2Fmeteor&logo=anaconda)](https://anaconda.org/bioconda/meteor)
[![PyPI](https://img.shields.io/pypi/v/METEOR?label=pypi%20package)](https://pypi.org/project/meteor/)
[![dockerhub](https://img.shields.io/docker/v/aghozlane/meteor?label=aghozlane/meteor&logo=docker)](https://hub.docker.com/r/aghozlane/meteor/)
![Github Actions](https://github.com/metagenopolis/meteor/actions/workflows/main.yml/badge.svg)
Expand Down
8 changes: 4 additions & 4 deletions meteor/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dataclasses import dataclass
from pathlib import Path
from datetime import datetime
from packaging.version import Version, parse
from packaging.version import parse
from re import findall
from meteor.session import Session, Component
from time import perf_counter
Expand Down Expand Up @@ -126,10 +126,10 @@ def execute(self) -> None:
)
sys.exit(1)
bowtie_version = str(bowtie_exec.stdout).split("\\n", maxsplit=1)[0].split(" ")[2]
if parse(bowtie_version) < Version("2.3.5"):
if parse(bowtie_version) < self.meteor.MIN_BOWTIE2_VERSION:
logging.error(
"The bowtie2 version %s is outdated for meteor. Please update bowtie2 to >=2.3.5.",
bowtie_version,
"The bowtie2 version %s is outdated for meteor. Please update bowtie2 to >= %s.",
bowtie_version, self.meteor.MIN_BOWTIE2_VERSION
)
sys.exit(1)
# Start mapping
Expand Down
8 changes: 4 additions & 4 deletions meteor/phylogeny.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pathlib import Path
import tempfile
from tempfile import NamedTemporaryFile
from packaging.version import Version, parse
from packaging.version import parse
from collections import OrderedDict
from datetime import datetime
from typing import Iterable
Expand Down Expand Up @@ -120,10 +120,10 @@ def execute(self) -> None:
logging.error("Failed to determine the raxml-ng version.")
sys.exit(1)
raxml_ng_version = match.group(1)
if parse(raxml_ng_version) < Version("1.0.1"):
if parse(raxml_ng_version) < self.meteor.MIN_RAXML_NG_VERSION:
logging.error(
"The raxml-ng version %s is outdated for meteor. Please update raxml-ng to >=1.0.1.",
raxml_ng_version,
"The raxml-ng version %s is outdated for meteor. Please update raxml-ng to >= %s.",
raxml_ng_version, self.meteor.MIN_RAXML_NG_VERSION
)
sys.exit(1)

Expand Down
7 changes: 4 additions & 3 deletions meteor/referencebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pathlib import Path
from dataclasses import dataclass, field
from datetime import datetime
from packaging.version import Version, parse
from packaging.version import parse
from textwrap import fill
from meteor.session import Session, Component
from typing import Iterator, Tuple, ClassVar
Expand Down Expand Up @@ -140,10 +140,11 @@ def execute(self) -> None:
)
sys.exit(1)
bowtie_version = bowtie_exec.stdout.decode("utf-8").split(" ")[2].split("\n")[0]
if parse(bowtie_version) < Version("2.3.5"):
if parse(bowtie_version) < self.meteor.MIN_BOWTIE2_VERSION:
logging.error(
"The bowtie2 version %s is outdated for meteor. Please update bowtie2.",
"The bowtie2 version %s is outdated for meteor. Please update bowtie2 to >= %s.",
bowtie_version,
self.meteor.MIN_BOWTIE2_VERSION,
)
sys.exit(1)
# Build the index with bowtie2
Expand Down
8 changes: 7 additions & 1 deletion meteor/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@

from pathlib import Path
from dataclasses import dataclass, field
from typing import Protocol, Iterator
from typing import Protocol, Iterator, ClassVar
import logging
import sys
import json
import lzma
from importlib.metadata import version
from packaging.version import Version


@dataclass(kw_only=True)
class Component:
"""Set of important constant for meteor"""

MIN_BOWTIE2_VERSION : ClassVar[Version] = Version('2.3.5')
MIN_BCFTOOLS_VERSION : ClassVar[Version] = Version('0.1.19')
MIN_BEDTOOLS_VERSION : ClassVar[Version] = Version('2.18')
MIN_RAXML_NG_VERSION : ClassVar[Version] = Version("1.0.1")

threads: int | None
fastq_dir: Path = field(default_factory=Path)
mapping_dir: Path = field(default_factory=Path)
Expand Down
14 changes: 7 additions & 7 deletions meteor/variantcalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from meteor.session import Session, Component
from time import perf_counter
from tempfile import NamedTemporaryFile
from packaging.version import Version, parse
from packaging.version import parse

# from pysam import AlignmentFile
# from collections import defaultdict
Expand Down Expand Up @@ -254,10 +254,10 @@ def execute(self) -> None:
bcftools_version = (
bcftools_exec.stdout.decode("utf-8").split("\n")[0].split(" ")[1]
)
if parse(bcftools_version) < Version("0.1.19"):
if parse(bcftools_version) < self.meteor.MIN_BCFTOOLS_VERSION:
logging.error(
"The bcftools version %s is outdated for meteor. Please update bcftools to >= 0.1.19.",
bcftools_version,
"The bcftools version %s is outdated for meteor. Please update bcftools to >= %s.",
bcftools_version, self.meteor.MIN_BCFTOOLS_VERSION
)
sys.exit(1)
bedtools_exec = run(["bedtools", "--version"], check=False, capture_output=True)
Expand All @@ -267,10 +267,10 @@ def execute(self) -> None:
)
sys.exit(1)
bedtools_version = bedtools_exec.stdout.decode("utf-8").split(" ")[1][1:]
if parse(bedtools_version) < Version("2.18"):
if parse(bedtools_version) < self.meteor.MIN_BEDTOOLS_VERSION:
logging.error(
"Error, the bedtools version %s is outdated for meteor. Please update bedtools to >= 2.18.",
bedtools_version,
"The bedtools version %s is outdated for meteor. Please update bedtools to >= %s.",
bedtools_version, self.meteor.MIN_BEDTOOLS_VERSION
)
sys.exit(1)
start = perf_counter()
Expand Down

0 comments on commit 392fe45

Please sign in to comment.