From 51efc3f3e19f89067ed8536b3e1c3cc790bb9262 Mon Sep 17 00:00:00 2001 From: linghao Date: Thu, 6 Mar 2025 22:26:45 +0000 Subject: [PATCH 1/2] update template --- .cruft.json | 20 ++++++ .dockerignore | 110 ++++++++++++++++++++++++++++++++ .gitignore | 8 +++ .gitlab-ci.yml | 11 ++++ .pre-commit-config.yaml | 30 +++++---- .secrets.baseline | 4 +- .travis.yml | 35 ---------- Dockerfile | 45 +++++++------ LICENSE | 6 +- README.md | 79 ++++------------------- justfile | 42 ++++++++++++ mutect2_tool/__init__.py | 8 +-- mutect2_tool/__main__.py | 0 pyproject.toml | 134 +++++++++++++++++++++++++++++++++++++-- requirements.txt | 80 ++--------------------- tests/unit/__init__.py | 0 tests/unit/test_main.py | 18 ++++++ tox.ini | 109 +++++++++++++++++++++++++++++++ 18 files changed, 515 insertions(+), 224 deletions(-) create mode 100644 .cruft.json create mode 100644 .dockerignore create mode 100644 .gitlab-ci.yml delete mode 100644 .travis.yml create mode 100644 justfile mode change 100644 => 100755 mutect2_tool/__main__.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/test_main.py create mode 100644 tox.ini diff --git a/.cruft.json b/.cruft.json new file mode 100644 index 0000000..cd9516e --- /dev/null +++ b/.cruft.json @@ -0,0 +1,20 @@ +{ + "template": "git@github.com:NCI-GDC/bio-python-template.git", + "commit": "0b6345a590be88d3cb69c007749a0e9e415ab56f", + "context": { + "cookiecutter": { + "full_name": "Linghao Song", + "email": "sxwcasd@gmail.com", + "github_username": "sxwcasd", + "project_name": "mutect2-tool", + "package_name": "mutect2_tool", + "project_short_description": "The GATK3 MuTect2 pipeline employs a "Panel of Normals" to identify additional germline mutations. This panel is generated using TCGA blood normal genomes from thousands of individuals that were curated and confidently assessed to be cancer-free. This method allows for a higher level of confidence to be assigned to somatic variants that were called by the MuTect2 pipeline.", + "min_python_version": "3.9", + "github_repo": "https://github.com/NCI-GDC/mutect2-tool", + "commit": "0b6345a590be88d3cb69c007749a0e9e415ab56f", + "_template": "git@github.com:NCI-GDC/bio-python-template.git" + } + }, + "directory": null, + "checkout": null + } diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4bf6500 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,110 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +_version.py + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# direnv +.envrc +.direnv/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# VSCode +.vscode/ +test-reports/ diff --git a/.gitignore b/.gitignore index 7b75539..716f3a8 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,11 @@ ENV/ # VSCode .vscode/ +test-reports/ + +# Gitlab CI - automatically created, break flit validation +vars.env +gl-code-quality-report.html + +# Added in base-container builder image +aws-lc diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..99e17bb --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,11 @@ +--- +include: + - project: nci-gdc/gitlab-templates + ref: master + file: + - templates/global/full.yaml + - templates/python/full.yaml + +variables: + BUILD_PY_VERSION: python3.9 + RELEASE_PY_VERSION: python3.9 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20245af..367e670 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,16 @@ default_stages: [commit, push] default_language_version: - python_venv: python3.6 + python_venv: python3.9 repos: - - repo: git@github.com:Yelp/detect-secrets - rev: v0.13.1 + - repo: https://github.com/Yelp/detect-secrets + rev: v1.4.0 hooks: - id: detect-secrets args: ['--baseline', '.secrets.baseline'] + exclude: ^(\.cruft\.json)$ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v4.2.0 hooks: - id: check-yaml - id: check-toml @@ -17,15 +18,16 @@ repos: - id: detect-aws-credentials args: ["--allow-missing-credentials"] - id: detect-private-key - - repo: https://github.com/asottile/seed-isort-config - rev: v1.9.3 + - id: end-of-file-fixer + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.265' hooks: - - id: seed-isort-config - - repo: https://github.com/pre-commit/mirrors-isort - rev: v4.3.21 + - id: ruff + args: [ '--select', 'I', '--fix' ] + - id: ruff-format + - repo: https://github.com/cruft/cruft + rev: 2.14.0 hooks: - - id: isort - - repo: https://github.com/psf/black - rev: 19.10b0 - hooks: - - id: black + - id: cruft + name: cruft + entry: bash -c 'cruft check || true' -- diff --git a/.secrets.baseline b/.secrets.baseline index b5ca712..248bb2f 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -1,9 +1,9 @@ { "exclude": { - "files": null, + "files": "^.secrets.baseline$", "lines": null }, - "generated_at": "2020-07-23T15:24:59Z", + "generated_at": "2020-07-21T15:11:38Z", "plugins_used": [ { "name": "AWSKeyDetector" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bc189d8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: python -python: -- '3.7' -services: docker -git: - depth: false -install: make build -stages: -- name: test -- name: publish-release - if: branch = master AND type != pull_request -- name: publish-staging - if: branch != master AND type != pull_request -jobs: - include: - - stage: test - name: Test Docker - script: - - make version version-pypi - - make test-docker - - stage: publish-staging - name: Publish staging image - script: - - docker login -u="$QUAY_USERNAME" -p="$QUAY_PASSWORD" quay.io - - make publish-staging - - stage: publish-release - name: Publish production image - script: - - docker login -u="$QUAY_USERNAME" -p="$QUAY_PASSWORD" quay.io - - make publish-release -env: - global: - - BRANCH_NAME=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH} - - secure: fcPoE+6OWPDUtkT8IncA5Wm1/99Sp+MLO5K0EPWEPscFl+MEQtDZEYk2MtJmfeUyx5u/ByV/Ur00PIlNssaRgGzYDOjPxV0JhSkq6HkkAehJFninCTIj7QhwEZKruzJipsiaPiIZrkdX3JScnkRxi8Z6czt26WTnf5wdyomjId3hrUv7mmpeFT7XUFhnbPMc1OscH5xuqoRYk/bCVCWImd7J8Rx7LFh11lT8wrgfzEHXk2xOq+mHZprgF5M+vfgqe4gmdpc3amDzIpN1K/ZFXrcqEA4KtrTYJ8Nc18iQUKBRKApvIVmXCV2ock8RhuZsopU4KIf3yIqPMAFas+PVfEQYUs3DTAKzzLpXLmOGgzd/DRPNsYs0XWXypK7PWCPfVsqYMS3HahNdiyKo1i3qKAiWrITQ1l1rx/E1+B7R9GDUNGYlAb5VF3tTA5ZeFcO2HybV5UbjRry4sCUg3KOrKhpJuWOOthtVIONX48snrEoznUV6JXuARLEg8Rqrfra0WGhoUPrEbK0USSckdlfwOb1s4BuIyBnb2/+Mj5f5BU60EZMpHsRlI6mLvOdJlVVUx4baF+vpmKEceEG7zfkC1FygFquF1D+3LJmfNkzEGNfU+myXg3mNObN+yPIXAIrKAwZtVnaGZwAfby+fKaNdN4XYiHNeJparchZ6e0cXeBQ= - - secure: Z39nbYMfoXZNvXzj7YslU001FyESj69jeuwz2W/INNzq2fp2IZhL234YZiLD89Q+ARBWM6MfzCVmV4gXmmw3KUAbgwmS47IAjLiwx3deyzzTrIeAytXUgHkUVybl7DkYN2+RG2pb2dQuMB0ELoHtEc/Lnsl+FGyZ0nwPD70FG+MskapD6gftt09MlI1EKVG4/6tArDXrHBEYmEgB7gjpbG2JS+yIcgwFdWg4ppZp8sm8VeG71BusAFG1KL9pFugUyn8f8bOoheMEycQGEJ6hlO+OZ3Dg1lJ5/1PpUVbGkTo5jWurKKw68efLT0HQgrSz0U86kAKWPwTnv8Rcd99+DvrkvepgJc7+IEBFgNchLqOWF5xXuOYVBw+9bk03MkR9CFEflZcuWjmuClT4Xlnm3vjmCZq3sYGm43NJA9qBIlGlJtP9SwDsNk04tjf5OUj8I7ClT2PgsIN0yCCd/3R9tdE+7TRFz+cbS4WUXgK3P+2GOcEP7n+8MSR3LnpvFlsoTjqmFkZMqM9dQEly8rQN3wetGpiH2MJTXwO7zPNx76lCzQqMRCr+uQQ2AxDyuhBZXAdf1PKlnx1uSyaI/dJy7GyAMFiHKIi860IOqhYwLWab8VOOxgJLZGrr67iGVsCJq435RLz+IFzgvcTieaozyb7mQ7UDj3DnAMZOZAlkxNI= diff --git a/Dockerfile b/Dockerfile index f54f000..cc92138 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,36 @@ +ARG REGISTRY=docker.osdc.io/ncigdc +ARG BASE_CONTAINER_VERSION=latest + FROM quay.io/ncigdc/gatk:3.7 AS gatk -FROM quay.io/ncigdc/python37 AS python -FROM quay.io/ncigdc/bio-openjdk:8u282-slim +FROM ${REGISTRY}/python3.9-builder:${BASE_CONTAINER_VERSION} as builder +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini -ENV BINARY mutect2-tool -LABEL maintainer="sli6@uchicago.edu" -LABEL version="nightly-2016-02-25-gf39d340" -LABEL description="GATK3 nightly-2016-02-25-gf39d340" +COPY ./ /mutect2_tool -COPY --from=python / / -COPY --from=gatk /usr/local/bin/ /usr/local/bin/ +WORKDIR /mutect2_tool -COPY ./dist/ /opt -WORKDIR /opt +RUN pip install tox && tox -e build -RUN apt-get update \ - && apt-get install make \ - && rm -rf /var/lib/apt/lists/* +FROM ${REGISTRY}/python3.9:${BASE_CONTAINER_VERSION} -RUN make init-pip \ - && ln -s /opt/bin/${BINARY} /usr/local/bin/${BINARY} +LABEL org.opencontainers.image.title="mutect2_tool" \ + org.opencontainers.image.description="The GATK3 MuTect2 pipeline employs a 'Panel of Normals' to identify additional germline mutations. This panel is generated using TCGA blood normal genomes from thousands of individuals that were curated and confidently assessed to be cancer-free. This method allows for a higher level of confidence to be assigned to somatic variants that were called by the MuTect2 pipeline." \ + org.opencontainers.image.source="https://github.com/NCI-GDC/mutect2-tool" \ + org.opencontainers.image.vendor="NCI GDC" + +COPY --from=builder /mutect2_tool/dist/*.whl /mutect2_tool/ +COPY requirements.txt /mutect2_tool/ + +WORKDIR /mutect2_tool + +RUN pip install --no-deps -r requirements.txt \ + && pip install --no-deps *.whl \ + && rm -f *.whl requirements.txt + +USER app -ENV TINI_VERSION v0.19.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini -RUN chmod +x /tini ENTRYPOINT ["/tini", "--", "mutect2_tool"] + CMD ["--help"] diff --git a/LICENSE b/LICENSE index 5c304d1..261eeb9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Apache License + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +178,7 @@ Apache License APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +186,7 @@ Apache License same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index be08d04..2d38a98 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,19 @@ -# GDC GATK3 MuTect2 -![Version badge](https://img.shields.io/badge/GATK3.6-nightly--2016--02--25--gf39d340-.svg) +# mutect2-tool The GATK3 MuTect2 pipeline employs a "Panel of Normals" to identify additional germline mutations. This panel is generated using TCGA blood normal genomes from thousands of individuals that were curated and confidently assessed to be cancer-free. This method allows for a higher level of confidence to be assigned to somatic variants that were called by the MuTect2 pipeline. -Original GATK3 MuTect2: https://gatkforums.broadinstitute.org/gatk/discussion/9183/how-to-call-somatic-snvs-and-indels-using-mutect2 +## Installation -## GATK3 - -Important note: - -* The GDC GATK MuTect2 version was frozen to the version when we delivered our first data release. GATK team normally do not keep nightly version beyond 30 days, so that it makes really difficult to re-build the identical docker image.
-However, according to GATK team, it seems reasonable to use GATK3.7 as a replacement.
-https://gatkforums.broadinstitute.org/gatk/discussion/9406/where-can-i-find-the-gdc-mutect2-version -* Please contact GATK team for the GATK3.7 `GenomeAnalysisTK.jar`. - -## How to build - -https://docs.docker.com/engine/reference/builder/ - -The docker images are tested under multiple environments. The most tested ones are: -* Docker version 19.03.2, build 6a30dfc -* Docker version 18.09.1, build 4c52b90 -* Docker version 18.03.0-ce, build 0520e24 -* Docker version 17.12.1-ce, build 7390fc6 - -## For external users -The repository has only been tested on GDC data and in the particular environment GDC is running in. Some of the reference data required for the workflow production are hosted in [GDC reference files](https://gdc.cancer.gov/about-data/data-harmonization-and-generation/gdc-reference-files "GDC reference files"). For any questions related to GDC data, please contact the GDC Help Desk at support@nci-gdc.datacommons.io. - -There is a production-ready CWL example at https://github.com/NCI-GDC/mutect2-cwl which uses the docker images that are built from the `Dockerfile`s in this repo. - -To run multi-threading GATK3 MuTect2: - -``` -[INFO] [20200109 04:10:13] [multi_mutect2] - -------------------------------------------------------------------------------- -[INFO] [20200109 04:10:13] [multi_mutect2] - multi_mutect2_p3.py -[INFO] [20200109 04:10:13] [multi_mutect2] - Program Args: docker/multi_mutect2/multi_mutect2.py -h -[INFO] [20200109 04:10:13] [multi_mutect2] - -------------------------------------------------------------------------------- -usage: Internal multithreading MuTect2 calling. [-h] -j JAVA_HEAP -f - REFERENCE_PATH -r - INTERVAL_BED_PATH -t TUMOR_BAM - -n NORMAL_BAM -c THREAD_COUNT - -p PON -s COSMIC -d DBSNP -e - CONTEST [-m] - -optional arguments: - -h, --help show this help message and exit - -j JAVA_HEAP, --java_heap JAVA_HEAP - Java heap memory. - -f REFERENCE_PATH, --reference_path REFERENCE_PATH - Reference path. - -r INTERVAL_BED_PATH, --interval_bed_path INTERVAL_BED_PATH - Interval bed file. - -t TUMOR_BAM, --tumor_bam TUMOR_BAM - Tumor bam file. - -n NORMAL_BAM, --normal_bam NORMAL_BAM - Normal bam file. - -c THREAD_COUNT, --thread_count THREAD_COUNT - Number of thread. - -p PON, --pon PON Panel of normals reference path. - -s COSMIC, --cosmic COSMIC - Cosmic reference path. - -d DBSNP, --dbsnp DBSNP - dbSNP reference path. - -e CONTEST, --contest CONTEST - Contamination estimation value from ContEst. - -m, --dontUseSoftClippedBases - If specified, it will not analyze soft clipped bases - in the reads. +```sh +pip install . ``` -## For GDC users +## Development -See https://github.com/NCI-GDC/gdc-somatic-variant-calling-workflow. +* Clone this repository +* Requirements: + * Python >= 3.9 + * Tox +* `make venv` to create a virtualenv +* `source .venv/bin/activate` to activate new virtualenv +* `make init` to install dependencies and pre-commit hooks diff --git a/justfile b/justfile new file mode 100644 index 0000000..8ab4734 --- /dev/null +++ b/justfile @@ -0,0 +1,42 @@ +build: + tox -e build + +clean: clean-dirs + +clean-dirs: + rm -rf ./build/ + rm -rf ./dist/ + rm -rf ./*.egg-info/ + rm -rf ./htmlcov/ + +detect-secrets: scan-secrets audit-secrets +scan-secrets: + detect-secrets scan --baseline .secrets.baseline + +audit-secrets: + detect-secrets audit .secrets.baseline + +init: init-hooks init-pip + +init-hooks: + pre-commit install + +init-pip: + uv pip install ".[dev,test]" + +venv: + rm -rf .venv/ + uv venv + +compile-requirements: + tox -e compile + +tox: + @echo + TOX_PARALLEL_NO_SPINNER=1 tox -p --recreate + +upload: + tox -e upload + +version: + tox -e version diff --git a/mutect2_tool/__init__.py b/mutect2_tool/__init__.py index 61521f5..ba4f045 100644 --- a/mutect2_tool/__init__.py +++ b/mutect2_tool/__init__.py @@ -1,6 +1,6 @@ try: - from mutect2_tool._version import __long_version__ - - __version__ = __long_version__ + from mutect2_tool._version import version except ImportError: - __version__ = "0.0.0" + version = "0" + +__version__ = version diff --git a/mutect2_tool/__main__.py b/mutect2_tool/__main__.py old mode 100644 new mode 100755 diff --git a/pyproject.toml b/pyproject.toml index ff212ff..9c929b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,131 @@ -[tool.black] +[build-system] +requires = ["flit_scm"] +build-backend = "flit_scm:buildapi" + +[project] +name = "mutect2-tool" +description = "The GATK3 MuTect2 pipeline employs a "Panel of Normals" to identify additional germline mutations. This panel is generated using TCGA blood normal genomes from thousands of individuals that were curated and confidently assessed to be cancer-free. This method allows for a higher level of confidence to be assigned to somatic variants that were called by the MuTect2 pipeline." +authors = [ + {name = "Linghao Song", email = "sxwcasd@gmail.com"} +] + +readme = "README.md" +requires-python = ">=3.9" +license = {file = "LICENSE"} +classifiers = [ + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only" +] +dynamic = ["version"] +dependencies = [ + "click" +] + +[project.optional-dependencies] +build = [ + "setuptools_scm", + "flit", + "twine", +] + +dev = [ + "black", + "detect-secrets==1.4.0", + "ruff", + "mypy", + "pre-commit>=2.9.0", + "tox", +] + +test = [ + "coverage[toml]", + "pytest", +] + +type = [ + "types-click", +] + +[project.urls] +homepage = "https://github.com/NCI-GDC/mutect2-tool" + +[project.scripts] +"mutect2_tool" = "mutect2_tool.__main__:main" + +[tool.setuptools_scm] +write_to = "mutect2_tool/_version.py" +local_scheme = "dirty-tag" +version_scheme = "python-simplified-semver" +fallback_version = "0" + +[tool.coverage.run] +source = ["mutect2_tool"] +branch = true +parallel = true + +[tool.flit.module] +name = "mutect2_tool" + +[tool.flit.sdist] +include = ["mutect2_tool/_version.py"] +exclude = [ + ".*", + "dev-requirements.*", + "Dockerfile", + "Jenkinsfile", + "*travis.yml", + "tox.ini", +] + +[tool.mypy] +python_version = 3.8 +disallow_untyped_defs = true +warn_return_any = true +warn_unused_configs = true + +[tool.coverage.report] +show_missing = true + +[tool.ruff] +# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. +select = ["E", "F"] +ignore = ["E501"] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "I"] +unfixable = [] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".mypy_cache", + ".pytype", + ".ruff_cache", + ".tox", + ".venv", + "__pypackages__", + "_build", + "build", + "dist", + "node_modules", + "venv", +] + +# Same as Black. line-length = 88 -skip-string-normalization = true -target-version = ['py37'] -[flake8] -max-line-length = 88 +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +target-version = 'py39' + +[tool.ruff.mccabe] +# Unlike Flake8, default to a complexity level of 10. +max-complexity = 10 + +[tool.ruff.per-file-ignores] +"__init__.py" = ["E402"] diff --git a/requirements.txt b/requirements.txt index 38989c1..cbb5c1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,80 +1,8 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # -# pip-compile --output-file=requirements.txt requirements.in +# pip-compile --output-file=requirements.txt pyproject.toml # -appdirs==1.4.4 - # via virtualenv -attrs==20.1.0 - # via pytest -certifi==2020.6.20 - # via requests -cfgv==3.2.0 - # via pre-commit -chardet==3.0.4 - # via requests -coverage==5.2.1 - # via pytest-cov -detect-secrets==0.13.1 - # via -r requirements.in -distlib==0.3.1 - # via virtualenv -filelock==3.0.12 - # via virtualenv -flake8==3.8.3 - # via -r requirements.in -identify==1.4.29 - # via pre-commit -idna==2.10 - # via requests -iniconfig==1.0.1 - # via pytest -isort==5.4.2 - # via -r requirements.in -mccabe==0.6.1 - # via flake8 -mock==4.0.2 - # via -r requirements.in -more-itertools==8.4.0 - # via pytest -nodeenv==1.5.0 - # via pre-commit -packaging==20.4 - # via pytest -pluggy==0.13.1 - # via pytest -pre-commit==2.7.1 - # via -r requirements.in -py==1.10.0 - # via pytest -pycodestyle==2.6.0 - # via flake8 -pyflakes==2.2.0 - # via flake8 -pyparsing==2.4.7 - # via packaging -pytest-cov==2.10.1 - # via -r requirements.in -pytest==6.0.1 - # via - # -r requirements.in - # pytest-cov -pyyaml==5.4 - # via - # detect-secrets - # pre-commit -requests==2.24.0 - # via detect-secrets -six==1.15.0 - # via - # packaging - # virtualenv -toml==0.10.1 - # via - # pre-commit - # pytest -urllib3==1.25.10 - # via requests -virtualenv==20.0.31 - # via pre-commit +click==8.1.3 + # via bio_python_project (pyproject.toml) diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py new file mode 100644 index 0000000..67ff5aa --- /dev/null +++ b/tests/unit/test_main.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import unittest + +from click.testing import CliRunner +from mutect2_tool import __main__ as MOD + + +class ThisTestCase(unittest.TestCase): + def setUp(self) -> None: + self.runner = CliRunner() + + def test_pass(self): + result = self.runner.invoke(MOD.main) + self.assertEqual(result.exit_code, 0) + + +# __END__ diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..d3baedc --- /dev/null +++ b/tox.ini @@ -0,0 +1,109 @@ +[tox] +envlist = py3,help,version,ruff,type,cov +isolated_build = true + +[tox:.package] +basepython = python3 + +[testenv] +setenv = + package = mutect2_tool + PYTHONHASHSEED = 0 +passenv = PIP_EXTRA_INDEX_URL +skip_install = + false +install_command = python -m pip install {opts} {packages} +extras = test +commands = pytest -vv {posargs} + +[testenv:dev] +basepython = python3.9 +extras = + dev + test + +[testenv:detect-secrets] +deps = + detect-secrets==1.4.0 +skip_install = + true +commands = + detect-secrets scan > .secrets.baseline + +[testenv:compile] +deps = uv +skip_install = + true +commands = + uv pip compile -o requirements.txt pyproject.toml + +[testenv:help] +skip_install = + false +deps = +commands = + python -m {env:package} --help + +[testenv:cov] +deps = +extras = test +commands = + coverage run -m pytest tests/ + coverage combine + coverage report -m + coverage xml + coverage xml -o test-reports/results.xml + +[testenv:ruff] +skip_install=True +deps = + ruff +commands = + ruff check {env:package}/ tests/ + +[testenv:type] +skip_install = false +deps= + mypy +extras = type +commands = + mypy {env:package}/ + +[testenv:build] +skip_install= true +isolated_build = false +extras = build +commands = + setuptools_scm + flit build + +[testenv:publish] +isolated_build=False +allowlist_externals = just +skip_install=true +passenv = + TWINE_USERNAME + TWINE_PASSWORD + TWINE_REPOSITORY_URL +extras = build +commands = + setuptools_scm + flit build + twine check dist/* + twine upload dist/* + +[testenv:version] +skip_install=True +allowlist_externals = + git +deps = +commands = + git describe --tags --always + +[testenv:cruft] +skip_install=True +deps = cruft +allowlist_externals = + git +commands = + cruft check From 34549993d0868e4f414904882f891da2d96f5d23 Mon Sep 17 00:00:00 2001 From: linghao Date: Thu, 6 Mar 2025 22:27:19 +0000 Subject: [PATCH 2/2] update template --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 367e670..51ea34b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,13 +4,13 @@ default_language_version: repos: - repo: https://github.com/Yelp/detect-secrets - rev: v1.4.0 + rev: v1.5.0 hooks: - id: detect-secrets args: ['--baseline', '.secrets.baseline'] exclude: ^(\.cruft\.json)$ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v5.0.0 hooks: - id: check-yaml - id: check-toml @@ -20,13 +20,13 @@ repos: - id: detect-private-key - id: end-of-file-fixer - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.265' + rev: 'v0.9.9' hooks: - id: ruff args: [ '--select', 'I', '--fix' ] - id: ruff-format - repo: https://github.com/cruft/cruft - rev: 2.14.0 + rev: 2.16.0 hooks: - id: cruft name: cruft