Skip to content

Commit

Permalink
Merge pull request #15 from cokelaer/main
Browse files Browse the repository at this point in the history
add more tools
  • Loading branch information
cokelaer authored Jan 16, 2024
2 parents fd24aee + 455eecc commit 5efe41d
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 214 deletions.
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

files: '\.(py|rst|sh)$'
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
#- id: check-executables-have-shebangs
- id: check-ast

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ["-j8", "--ignore=E203,E501,W503,E722", "--max-line-length=120", "--exit-zero"]

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args: ["--line-length=120"]
exclude: E501

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"] # solves conflicts between black and isort

3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This tool uses a registry so it will work only with resgistered tools, which lis

Type::

versionix --help
versionix --help

to get more help like this example:

Expand All @@ -67,6 +67,7 @@ Changelog
========= ========================================================================
Version Description
========= ========================================================================
0.2.4 More tools in the registry and added precommit
0.2.3 More tools in the registry
0.2.2 add all tools required by sequana pipelines (oct 2023)
0.2.1 More tools added.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "versionix"
version = "0.2.3"
version = "0.2.4"
description = "Get version of any tools"
authors = ["Sequana Team"]
license = "BSD-3"
Expand Down
26 changes: 15 additions & 11 deletions test/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
import sys

from versionix.parser import get_version as get_version
from versionix.scripts import main

import sys

# for testing we do not want to install all those tools/software so
# we have set testing=True, in which case some sanity checks and
# error won't be raised.
# def get_version(standalone):
# return get_version_orig(standalone, testing=True)

#The mocker which is set so that when we test the presence of e.G. macs3, which is not installed,
#no error is raise
# The mocker which is set so that when we test the presence of e.G. macs3, which is not installed,
# no error is raise


def test_sequana(fp, mocker):
mocker.patch('shutil.which', return_value="something")
mocker.patch("shutil.which", return_value="something")
fp.register(["sequana_coverage", "--version"], stdout=["sequana_coverage, version 0.15.4"])
assert get_version("sequana_coverage") == "0.15.4"


def test_macs3(fp, mocker):
mocker.patch('shutil.which', return_value="something")
mocker.patch("shutil.which", return_value="something")
fp.register(["macs3", "--version"], stdout=["macs3 3.0.0b1"])
assert get_version("macs3") == "3.0.0b1"


def test_kallisto(fp, mocker):
mocker.patch('shutil.which', return_value="something")
mocker.patch("shutil.which", return_value="something")
fp.register(["kallisto", "version"], stdout=["kallisto, version 0.48.0"])
assert get_version("kallisto") == "0.48.0"


def test_pigz(fp, mocker):
# stderr parser
mocker.patch('shutil.which', return_value="something")
mocker.patch("shutil.which", return_value="something")
fp.register(["pigz", "--version"], stderr=["pigz 2.4"])
assert get_version("pigz") == "2.4"


def test_fastqc(fp, mocker):
# stderr parser
mocker.patch('shutil.which', return_value="something")
mocker.patch("shutil.which", return_value="something")
fp.register(["fastqc", "--version"], stderr=["fastqc v1.0.0"])
assert get_version("fastqc") == "1.0.0"


def _test_bwa(fp, mocker):
mocker.patch('shutil.which', return_value="something")
mocker.patch("shutil.which", return_value="something")
fp.register(
["bwa"],
stderr=[
Expand Down Expand Up @@ -92,7 +93,10 @@ def test_script(fp, mocker):

runner.invoke(main, ["--registered"])
runner.invoke(main, ["--stats"])
runner.invoke(main, )
runner.invoke(
main,
)


def test_bedtools_error(fp, mocker):
# registered tool but if not installed, should raise a SystemExit error
Expand Down
2 changes: 1 addition & 1 deletion versionix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

try:
version = pkg_resources.require("versionix")[0].version
except: #pragma: no cover
except: # pragma: no cover
version = ">=0.1.0"
2 changes: 1 addition & 1 deletion versionix/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ def get_version(standalone, verbose=True):
version = parser(p)
return version

except Exception as err: #pragma: no cover
except Exception as err: # pragma: no cover
print(err)
sys.exit(1)
Loading

0 comments on commit 5efe41d

Please sign in to comment.