From 23feed0d438ed7d269e8f96b935d03aa684fe1de Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Fri, 3 Feb 2023 12:10:39 +0100 Subject: [PATCH] Chore/restructure (#102) * restructure project --- .pre-commit-config.yaml | 9 +++ MANIFEST.in | 2 +- README.md | 6 +- .../include/example.bed}/ID_aberrations.bed | 0 .../include/example.bed}/ID_bins.bed | 0 .../example.bed}/ID_chr_statistics.txt | 0 .../include/example.bed}/ID_segments.bed | 0 .../example.blacklist}/acen.and.gvar.hg38.txt | 0 .../include/example.blacklist}/acen.hg38.txt | 0 .../include/example.plot}/chr1.png | Bin .../include/example.plot}/chr10.png | Bin .../include/example.plot}/chr11.png | Bin .../include/example.plot}/chr12.png | Bin .../include/example.plot}/chr13.png | Bin .../include/example.plot}/chr14.png | Bin .../include/example.plot}/chr15.png | Bin .../include/example.plot}/chr16.png | Bin .../include/example.plot}/chr17.png | Bin .../include/example.plot}/chr18.png | Bin .../include/example.plot}/chr19.png | Bin .../include/example.plot}/chr2.png | Bin .../include/example.plot}/chr20.png | Bin .../include/example.plot}/chr21.png | Bin .../include/example.plot}/chr22.png | Bin .../include/example.plot}/chr3.png | Bin .../include/example.plot}/chr4.png | Bin .../include/example.plot}/chr5.png | Bin .../include/example.plot}/chr6.png | Bin .../include/example.plot}/chr7.png | Bin .../include/example.plot}/chr8.png | Bin .../include/example.plot}/chr9.png | Bin .../include/example.plot}/chrX.png | Bin .../include/example.plot}/genome_wide.png | Bin .../include/pipeline}/convert.sh | 0 {pipeline => docs/include/pipeline}/newref.sh | 0 .../include/pipeline}/predict.sh | 0 pyproject.toml | 17 +++++ setup.cfg | 63 ++++++++++++++++++ setup.py | 58 ++-------------- {wisecondorX => src/wisecondorx}/__init__.py | 0 .../wisecondorx}/convert_tools.py | 0 .../wisecondorx}/include/CBS.R | 0 .../wisecondorx}/include/plotter.R | 0 {wisecondorX => src/wisecondorx}/main.py | 14 ++-- .../wisecondorx}/newref_control.py | 2 +- .../wisecondorx}/newref_tools.py | 0 .../wisecondorx}/overall_tools.py | 0 .../wisecondorx}/predict_control.py | 2 +- .../wisecondorx}/predict_output.py | 2 +- .../wisecondorx}/predict_tools.py | 2 +- 50 files changed, 108 insertions(+), 69 deletions(-) create mode 100644 .pre-commit-config.yaml rename {example.bed => docs/include/example.bed}/ID_aberrations.bed (100%) rename {example.bed => docs/include/example.bed}/ID_bins.bed (100%) rename {example.bed => docs/include/example.bed}/ID_chr_statistics.txt (100%) rename {example.bed => docs/include/example.bed}/ID_segments.bed (100%) rename {example.blacklist => docs/include/example.blacklist}/acen.and.gvar.hg38.txt (100%) rename {example.blacklist => docs/include/example.blacklist}/acen.hg38.txt (100%) rename {example.plot => docs/include/example.plot}/chr1.png (100%) rename {example.plot => docs/include/example.plot}/chr10.png (100%) rename {example.plot => docs/include/example.plot}/chr11.png (100%) rename {example.plot => docs/include/example.plot}/chr12.png (100%) rename {example.plot => docs/include/example.plot}/chr13.png (100%) rename {example.plot => docs/include/example.plot}/chr14.png (100%) rename {example.plot => docs/include/example.plot}/chr15.png (100%) rename {example.plot => docs/include/example.plot}/chr16.png (100%) rename {example.plot => docs/include/example.plot}/chr17.png (100%) rename {example.plot => docs/include/example.plot}/chr18.png (100%) rename {example.plot => docs/include/example.plot}/chr19.png (100%) rename {example.plot => docs/include/example.plot}/chr2.png (100%) rename {example.plot => docs/include/example.plot}/chr20.png (100%) rename {example.plot => docs/include/example.plot}/chr21.png (100%) rename {example.plot => docs/include/example.plot}/chr22.png (100%) rename {example.plot => docs/include/example.plot}/chr3.png (100%) rename {example.plot => docs/include/example.plot}/chr4.png (100%) rename {example.plot => docs/include/example.plot}/chr5.png (100%) rename {example.plot => docs/include/example.plot}/chr6.png (100%) rename {example.plot => docs/include/example.plot}/chr7.png (100%) rename {example.plot => docs/include/example.plot}/chr8.png (100%) rename {example.plot => docs/include/example.plot}/chr9.png (100%) rename {example.plot => docs/include/example.plot}/chrX.png (100%) rename {example.plot => docs/include/example.plot}/genome_wide.png (100%) rename {pipeline => docs/include/pipeline}/convert.sh (100%) rename {pipeline => docs/include/pipeline}/newref.sh (100%) rename {pipeline => docs/include/pipeline}/predict.sh (100%) create mode 100644 pyproject.toml create mode 100644 setup.cfg rename {wisecondorX => src/wisecondorx}/__init__.py (100%) rename {wisecondorX => src/wisecondorx}/convert_tools.py (100%) rename {wisecondorX => src/wisecondorx}/include/CBS.R (100%) rename {wisecondorX => src/wisecondorx}/include/plotter.R (100%) rename {wisecondorX => src/wisecondorx}/main.py (97%) rename {wisecondorX => src/wisecondorx}/newref_control.py (98%) rename {wisecondorX => src/wisecondorx}/newref_tools.py (100%) rename {wisecondorX => src/wisecondorx}/overall_tools.py (100%) rename {wisecondorX => src/wisecondorx}/predict_control.py (97%) rename {wisecondorX => src/wisecondorx}/predict_output.py (99%) rename {wisecondorX => src/wisecondorx}/predict_tools.py (99%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a3df05e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: https://github.com/psf/black + rev: 21.9b0 + hooks: + - id: black + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 21903f7..627eaa3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -recursive-include wisecondorX *.R +recursive-include wisecondorx *.R diff --git a/README.md b/README.md index 88ac46e..4f002d0 100755 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ WisecondorX convert input.bam/cram output.npz [--optional arguments] | `--binsize x` | Size per bin in bp; the reference bin size should be a multiple of this value. Note that this parameter does not impact the resolution, yet it can be used to optimize processing speed (default: x=5e3) | | `--normdup` | Use this flag to avoid duplicate removal | -→ Bash recipe at `./pipeline/convert.sh` +→ Bash recipe at `docs/include/pipeline/convert.sh` ### Stage (2) Create reference @@ -91,7 +91,7 @@ WisecondorX newref reference_input_dir/*.npz reference_output.npz [--optional ar | `--plotyfrac x` | plots Y read fraction histogram and Gaussian mixture fit to file x, can help when setting `--yfrac` manually; software quits after plotting | | `--cpus x` | Number of threads requested (default: x=1) | -→ Bash recipe at `./pipeline/newref.sh` +→ Bash recipe at `docs/include/pipeline/newref.sh` ### Stage (3) Predict copy number alterations @@ -116,7 +116,7 @@ WisecondorX predict test_input.npz reference_input.npz output_id [--optional arg **(\*)** At least one of these output formats should be selected -→ Bash recipe at `./pipeline/predict.sh` +→ Bash recipe at `docs/include/pipeline/predict.sh` ### Additional functionality diff --git a/example.bed/ID_aberrations.bed b/docs/include/example.bed/ID_aberrations.bed similarity index 100% rename from example.bed/ID_aberrations.bed rename to docs/include/example.bed/ID_aberrations.bed diff --git a/example.bed/ID_bins.bed b/docs/include/example.bed/ID_bins.bed similarity index 100% rename from example.bed/ID_bins.bed rename to docs/include/example.bed/ID_bins.bed diff --git a/example.bed/ID_chr_statistics.txt b/docs/include/example.bed/ID_chr_statistics.txt similarity index 100% rename from example.bed/ID_chr_statistics.txt rename to docs/include/example.bed/ID_chr_statistics.txt diff --git a/example.bed/ID_segments.bed b/docs/include/example.bed/ID_segments.bed similarity index 100% rename from example.bed/ID_segments.bed rename to docs/include/example.bed/ID_segments.bed diff --git a/example.blacklist/acen.and.gvar.hg38.txt b/docs/include/example.blacklist/acen.and.gvar.hg38.txt similarity index 100% rename from example.blacklist/acen.and.gvar.hg38.txt rename to docs/include/example.blacklist/acen.and.gvar.hg38.txt diff --git a/example.blacklist/acen.hg38.txt b/docs/include/example.blacklist/acen.hg38.txt similarity index 100% rename from example.blacklist/acen.hg38.txt rename to docs/include/example.blacklist/acen.hg38.txt diff --git a/example.plot/chr1.png b/docs/include/example.plot/chr1.png similarity index 100% rename from example.plot/chr1.png rename to docs/include/example.plot/chr1.png diff --git a/example.plot/chr10.png b/docs/include/example.plot/chr10.png similarity index 100% rename from example.plot/chr10.png rename to docs/include/example.plot/chr10.png diff --git a/example.plot/chr11.png b/docs/include/example.plot/chr11.png similarity index 100% rename from example.plot/chr11.png rename to docs/include/example.plot/chr11.png diff --git a/example.plot/chr12.png b/docs/include/example.plot/chr12.png similarity index 100% rename from example.plot/chr12.png rename to docs/include/example.plot/chr12.png diff --git a/example.plot/chr13.png b/docs/include/example.plot/chr13.png similarity index 100% rename from example.plot/chr13.png rename to docs/include/example.plot/chr13.png diff --git a/example.plot/chr14.png b/docs/include/example.plot/chr14.png similarity index 100% rename from example.plot/chr14.png rename to docs/include/example.plot/chr14.png diff --git a/example.plot/chr15.png b/docs/include/example.plot/chr15.png similarity index 100% rename from example.plot/chr15.png rename to docs/include/example.plot/chr15.png diff --git a/example.plot/chr16.png b/docs/include/example.plot/chr16.png similarity index 100% rename from example.plot/chr16.png rename to docs/include/example.plot/chr16.png diff --git a/example.plot/chr17.png b/docs/include/example.plot/chr17.png similarity index 100% rename from example.plot/chr17.png rename to docs/include/example.plot/chr17.png diff --git a/example.plot/chr18.png b/docs/include/example.plot/chr18.png similarity index 100% rename from example.plot/chr18.png rename to docs/include/example.plot/chr18.png diff --git a/example.plot/chr19.png b/docs/include/example.plot/chr19.png similarity index 100% rename from example.plot/chr19.png rename to docs/include/example.plot/chr19.png diff --git a/example.plot/chr2.png b/docs/include/example.plot/chr2.png similarity index 100% rename from example.plot/chr2.png rename to docs/include/example.plot/chr2.png diff --git a/example.plot/chr20.png b/docs/include/example.plot/chr20.png similarity index 100% rename from example.plot/chr20.png rename to docs/include/example.plot/chr20.png diff --git a/example.plot/chr21.png b/docs/include/example.plot/chr21.png similarity index 100% rename from example.plot/chr21.png rename to docs/include/example.plot/chr21.png diff --git a/example.plot/chr22.png b/docs/include/example.plot/chr22.png similarity index 100% rename from example.plot/chr22.png rename to docs/include/example.plot/chr22.png diff --git a/example.plot/chr3.png b/docs/include/example.plot/chr3.png similarity index 100% rename from example.plot/chr3.png rename to docs/include/example.plot/chr3.png diff --git a/example.plot/chr4.png b/docs/include/example.plot/chr4.png similarity index 100% rename from example.plot/chr4.png rename to docs/include/example.plot/chr4.png diff --git a/example.plot/chr5.png b/docs/include/example.plot/chr5.png similarity index 100% rename from example.plot/chr5.png rename to docs/include/example.plot/chr5.png diff --git a/example.plot/chr6.png b/docs/include/example.plot/chr6.png similarity index 100% rename from example.plot/chr6.png rename to docs/include/example.plot/chr6.png diff --git a/example.plot/chr7.png b/docs/include/example.plot/chr7.png similarity index 100% rename from example.plot/chr7.png rename to docs/include/example.plot/chr7.png diff --git a/example.plot/chr8.png b/docs/include/example.plot/chr8.png similarity index 100% rename from example.plot/chr8.png rename to docs/include/example.plot/chr8.png diff --git a/example.plot/chr9.png b/docs/include/example.plot/chr9.png similarity index 100% rename from example.plot/chr9.png rename to docs/include/example.plot/chr9.png diff --git a/example.plot/chrX.png b/docs/include/example.plot/chrX.png similarity index 100% rename from example.plot/chrX.png rename to docs/include/example.plot/chrX.png diff --git a/example.plot/genome_wide.png b/docs/include/example.plot/genome_wide.png similarity index 100% rename from example.plot/genome_wide.png rename to docs/include/example.plot/genome_wide.png diff --git a/pipeline/convert.sh b/docs/include/pipeline/convert.sh similarity index 100% rename from pipeline/convert.sh rename to docs/include/pipeline/convert.sh diff --git a/pipeline/newref.sh b/docs/include/pipeline/newref.sh similarity index 100% rename from pipeline/newref.sh rename to docs/include/pipeline/newref.sh diff --git a/pipeline/predict.sh b/docs/include/pipeline/predict.sh similarity index 100% rename from pipeline/predict.sh rename to docs/include/pipeline/predict.sh diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a72dbe7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[tool.black] +line-length = 79 +target_version = ['py36','py37','py38','py39'] +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist +)/ +''' \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..37b7cff --- /dev/null +++ b/setup.cfg @@ -0,0 +1,63 @@ +[metadata] +name = wisecondorx +version = 1.2.6dev +description = description="WisecondorX -- an evolved WISECONDOR" +long_description = file: README.md +author = "Matthias De Smet, Lennart Raman", +author_email = "ict@cmgg.be", +license = "by-nc-sa" +license_file = LICENSE.md +platforms = unix, linux, osx, win32 +keywords= + bioinformatics + biology + sequencing + NGS + next generation sequencing + CNV + SWGS + Shallow Whole Genome Sequencing +classifiers = + Environment :: Console + Intended Audience :: Science/Research + Natural Language :: English + Operating System :: MacOS :: MacOS X + Operating System :: POSIX + Operating System :: Unix + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Topic :: Scientific/Engineering + Topic :: Scientific/Engineering :: Bio-Informatics + + +[options] +packages = wisecondorx +package_dir = + =src +include_package_data=True +python_requires= >=3.6 +install_requires = + scipy + scikit-learn + pysam + numpy +zip_safe = False + +[options.entry_points] + console_scripts = + wisecondorx = wisecondorx.main:main + WisecondorX = wisecondorx.main:main + wisecondorX = wisecondorx.main:main + + +[options.extras_require] +testing = + flake8 + black + pre-commit + +[flake8] +ignore = E266, E203, E501, C901, W503 +max-line-length = 79 +max-complexity = 18 diff --git a/setup.py b/setup.py index 778a94a..374f6ae 100644 --- a/setup.py +++ b/setup.py @@ -1,55 +1,5 @@ -#! /usr/bin/env python -from setuptools import setup, find_packages +#!/usr/bin/env python +from setuptools import setup -version = "1.2.4" -dl_version = "master" if "dev" in version else "{}".format(version) - -setup( - name="WisecondorX", - version=version, - author="Matthias De Smet, Lennart Raman", - author_email="Lennart.raman@ugent.be", - description="WisecondorX -- an evolved WISECONDOR", - long_description=__doc__, - keywords=[ - "bioinformatics", - "biology", - "sequencing", - "NGS", - "next generation sequencing", - "CNV", - "SWGS", - "Shallow Whole Genome Sequencing", - ], - download_url="https://github.com/CenterForMedicalGeneticsGhent/WisecondorX/archive/v{}.tar.gz".format( - dl_version - ), - license="Attribution-NonCommercial-ShareAlike CC BY-NC-SA", - packages=find_packages("."), - python_requires=">=2.7", - include_package_data=True, - zip_safe=False, - install_requires=[ - 'futures;python_version<"3"', - "scipy", - "scikit-learn", - "pysam", - "numpy", - ], - entry_points={"console_scripts": ["WisecondorX = wisecondorX.main:main"]}, - classifiers=[ - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Science/Research", - "Natural Language :: English", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX", - "Operating System :: Unix", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Bio-Informatics", - ], -) +if __name__ == "__main__": + setup() diff --git a/wisecondorX/__init__.py b/src/wisecondorx/__init__.py similarity index 100% rename from wisecondorX/__init__.py rename to src/wisecondorx/__init__.py diff --git a/wisecondorX/convert_tools.py b/src/wisecondorx/convert_tools.py similarity index 100% rename from wisecondorX/convert_tools.py rename to src/wisecondorx/convert_tools.py diff --git a/wisecondorX/include/CBS.R b/src/wisecondorx/include/CBS.R similarity index 100% rename from wisecondorX/include/CBS.R rename to src/wisecondorx/include/CBS.R diff --git a/wisecondorX/include/plotter.R b/src/wisecondorx/include/plotter.R similarity index 100% rename from wisecondorX/include/plotter.R rename to src/wisecondorx/include/plotter.R diff --git a/wisecondorX/main.py b/src/wisecondorx/main.py similarity index 97% rename from wisecondorX/main.py rename to src/wisecondorx/main.py index c34f988..a6af776 100644 --- a/wisecondorX/main.py +++ b/src/wisecondorx/main.py @@ -8,17 +8,17 @@ import numpy as np -from wisecondorX.convert_tools import convert_reads -from wisecondorX.newref_control import ( +from wisecondorx.convert_tools import convert_reads +from wisecondorx.newref_control import ( tool_newref_prep, tool_newref_main, tool_newref_merge, ) -from wisecondorX.newref_tools import train_gender_model, get_mask -from wisecondorX.overall_tools import gender_correct, scale_sample -from wisecondorX.predict_control import normalize, get_post_processed_result -from wisecondorX.predict_output import generate_output_tables, exec_write_plots -from wisecondorX.predict_tools import ( +from wisecondorx.newref_tools import train_gender_model, get_mask +from wisecondorx.overall_tools import gender_correct, scale_sample +from wisecondorx.predict_control import normalize, get_post_processed_result +from wisecondorx.predict_output import generate_output_tables, exec_write_plots +from wisecondorx.predict_tools import ( log_trans, exec_cbs, apply_blacklist, diff --git a/wisecondorX/newref_control.py b/src/wisecondorx/newref_control.py similarity index 98% rename from wisecondorX/newref_control.py rename to src/wisecondorx/newref_control.py index fab4433..fa2b50b 100644 --- a/wisecondorX/newref_control.py +++ b/src/wisecondorx/newref_control.py @@ -9,7 +9,7 @@ import numpy as np from concurrent import futures -from wisecondorX.newref_tools import normalize_and_mask, train_pca, get_reference +from wisecondorx.newref_tools import normalize_and_mask, train_pca, get_reference """ Outputs preparation files of read depth normalized diff --git a/wisecondorX/newref_tools.py b/src/wisecondorx/newref_tools.py similarity index 100% rename from wisecondorX/newref_tools.py rename to src/wisecondorx/newref_tools.py diff --git a/wisecondorX/overall_tools.py b/src/wisecondorx/overall_tools.py similarity index 100% rename from wisecondorX/overall_tools.py rename to src/wisecondorx/overall_tools.py diff --git a/wisecondorX/predict_control.py b/src/wisecondorx/predict_control.py similarity index 97% rename from wisecondorX/predict_control.py rename to src/wisecondorx/predict_control.py index 5bc2224..29c971e 100644 --- a/wisecondorX/predict_control.py +++ b/src/wisecondorx/predict_control.py @@ -1,6 +1,6 @@ # WisecondorX -from wisecondorX.predict_tools import ( +from wisecondorx.predict_tools import ( coverage_normalize_and_mask, project_pc, get_optimal_cutoff, diff --git a/wisecondorX/predict_output.py b/src/wisecondorx/predict_output.py similarity index 99% rename from wisecondorX/predict_output.py rename to src/wisecondorx/predict_output.py index b295a0b..c20625c 100644 --- a/wisecondorX/predict_output.py +++ b/src/wisecondorx/predict_output.py @@ -4,7 +4,7 @@ import numpy as np -from wisecondorX.overall_tools import ( +from wisecondorx.overall_tools import ( exec_R, get_z_score, get_median_segment_variance, diff --git a/wisecondorX/predict_tools.py b/src/wisecondorx/predict_tools.py similarity index 99% rename from wisecondorX/predict_tools.py rename to src/wisecondorx/predict_tools.py index 5b57afe..e69965d 100644 --- a/wisecondorX/predict_tools.py +++ b/src/wisecondorx/predict_tools.py @@ -6,7 +6,7 @@ from scipy.stats import norm from sklearn.decomposition import PCA -from wisecondorX.overall_tools import exec_R, get_z_score +from wisecondorx.overall_tools import exec_R, get_z_score """ Returns gender based on Gaussian mixture