# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['sequana_pipetools',
 'sequana_pipetools.resources',
 'sequana_pipetools.scripts',
 'sequana_pipetools.snaketools']

package_data = \
{'': ['*']}

install_requires = \
['aiohttp>=3.8.4',
 'charset-normalizer>=2,<3',
 'deprecated>=1.2.13',
 'easydev>=0.12.1',
 'importlib_resources>=5.4.0',
 'packaging>=23.1',
 'parse>=1.19.0',
 'pykwalify>=1.8',
 'pyyaml>=1.3',
 'ruamel.yaml>=0.17.32',
 'tqdm>=4.65']

entry_points = \
{'console_scripts': ['sequana_completion = '
                     'sequana_pipetools.scripts.completion:main',
                     'sequana_slurm_status = '
                     'sequana_pipetools.scripts.slurm:main']}

setup_kwargs = {
    'name': 'sequana-pipetools',
    'version': '0.13.0',
    'description': 'A set of tools to help building or using Sequana pipelines',
    'long_description': '\n\n.. image:: https://badge.fury.io/py/sequana-pipetools.svg\n    :target: https://pypi.python.org/pypi/sequana_pipetools\n\n.. image:: https://github.com/sequana/sequana_pipetools/actions/workflows/main.yml/badge.svg?branch=main\n    :target: https://github.com/sequana/sequana_pipetools/actions/workflows/main.yml\n\n.. image:: https://coveralls.io/repos/github/sequana/sequana_pipetools/badge.svg?branch=main\n    :target: https://coveralls.io/github/sequana/sequana_pipetools?branch=main\n\n.. image:: https://readthedocs.org/projects/sequana-pipetools/badge/?version=latest\n    :target: https://sequana-pipetools.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://app.codacy.com/project/badge/Grade/9031e4e4213e4e57a876fd5b792b5003\n   :target: https://app.codacy.com/gh/sequana/sequana_pipetools/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade\n\n.. image:: http://joss.theoj.org/papers/10.21105/joss.00352/status.svg\n   :target: http://joss.theoj.org/papers/10.21105/joss.00352\n   :alt: JOSS (journal of open source software) DOI\n\n:Overview: A set of tools to help building or using Sequana pipelines\n:Status: Production\n:Issues: Please fill a report on `github <https://github.com/sequana/sequana/issues>`__\n:Python version: Python 3.8, 3.9, 3.10, 3.11\n:Citation: Cokelaer et al, (2017), ‘Sequana’: a Set of Snakemake NGS pipelines, Journal of Open Source Software, 2(16), 352,  `JOSS DOI doi:10.21105/joss.00352 <http://www.doi2bib.org/bib/10.21105%2Fjoss.00352>`_\n\n\nWhat is sequana_pipetools ?\n============================\n\n**sequana_pipetools** is a collection of tools that assists with the management of `Sequana <https://sequana.readthedocs.io>`_ pipelines, which includes next-generation sequencing (NGS) pipelines like RNA-seq, variant calling, ChIP-seq, and others.\n\nThe aim of this package is to simplify the deployment of `Sequana pipelines <https://sequana.readthedocs.io>`_ by\ncreating a pure Python library that includes commonly used tools for different pipelines.\n\nPreviously, the Sequana framework incorporated alll bioinformatics, Snakemake rules,\npipelines, and pipeline management tools into a single library (Sequana) as illustrated\nin **Fig 1** below.\n\n.. figure:: https://raw.githubusercontent.com/sequana/sequana_pipetools/main/doc/veryold.png\n    :scale: 40%\n\n    **Figure 1** Old Sequana framework will all pipelines and Sequana library in the same\n    place including pipetools (this library).\n\nWhenever changes were made to the Sequana library, a thorough check of the entire library was necessary, despite\nhaving 80% test coverage. Adding new pipelines also necessitated the addition of new dependencies, and the process was becoming increasingly complex. To mitigate this issue, we initially made all pipelines independent, as illustrated in **Fig. 2**. This way, pipeline changes could be made without updating Sequana and vice versa, which was a significant improvment.\n\n.. figure:: https://raw.githubusercontent.com/sequana/sequana_pipetools/main/doc/old.png\n    :scale: 40%\n\n    **Figure 2** v0.8 of Sequana moved the Snakemake pipelines in indepdendent\n    repositories. A `cookie cutter <https://github.com/sequana/sequana_pipeline_template>`_ \n    ease the creation of scuh pipelines\n\n\nHowever, certain tools, such as those used for user interface and input data sanity checks, were required by all pipelines, as depicted by the pipetools box in the figure. As new pipelines were being added every month, we aimed to make the pipelines and Sequana more modular. Consequently, we created a pure Python library known as **sequana_pipetools**, as shown in **Fig. 3**, to make the pipelines even more autonomous.\n\n.. figure:: https://raw.githubusercontent.com/sequana/sequana_pipetools/main/doc/new.png\n    :scale: 40%\n\n    **Figure 3** New Sequana framework. The library contains the core and\n    bioinformatics tools and is now distinct from  the pipelines. Additionally, the\n    sequana_pipetools library supplies common tools to assist in the creaton and management of all pipelines, \n    such as shared parser for options.\n\nFinally, we dropped the rules/ available in Sequana to build an independent package with a set of Snakemake\nwrappers. These wrappers are available on https://github.com/sequana/sequana-wrappers and have also the advantage of being tested through continuous integration.\n\n.. figure:: https://raw.githubusercontent.com/sequana/sequana_pipetools/main/doc/wrappers.png\n    :scale: 40%\n\n    **Figure 3** New Sequana framework 2021. The library itself with the core, the\n    bioinformatics tools is now fully independent of the pipelines. \n\n\nInstallation\n============\n\nfrom pypi website::\n\n    pip install sequana_pipetools\n\nNo dependencies for this package except Python itself. In practice, this package\nhas no interest if not used with a Sequana pipeline. So, when using it,\nyou will need to install the relevant Sequana pipelines that you wish to use. For example::\n\n    pip install sequana_rnaseq\n    pip install sequana_fastqc\n    ...\n\n\nThis package is for `Sequana <https://sequana.readthedocs.io>`_ developers.\nTo get more help, go to the doc directory and build the local sphinx directory using::\n\n    make html\n    browse build/html/index.html\n\nQuick tour\n==========\n\nThere are currently two standalone tools. The first one is for Linux users under\nbash to obtain completion of a sequana pipeline command line arguments::\n\n    sequana_completion --name fastqc\n\nThe second is used to introspect slurm files to get a summary of the SLURM log\nfiles::\n\n    sequana_slurm_status --directory .\n\nWill print a short summary report with common errors (if any).\n\n\nThe library is intended to help Sequana developers to design their pipelines.\nSee the `Sequana organization repository for examples <https://github.com/sequana>`_.\n\nIn addition to those standalones, sequana_pipetools goal is to provide utilities to help Sequana developers. \nWe currently provide a set of Options classes that should be used to\ndesign the API of your pipelines. For example, the\nsequana_pipetools.options.SlurmOptions can be used as follows inside a standard\nPython module (the last two lines is where the magic happens)::\n\n    import argparse\n    from sequana_pipetools.options import *\n    from sequana_pipetools.misc import Colors\n    from sequana_pipetools.info import sequana_epilog, sequana_prolog\n\n    col = Colors()\n    NAME = "fastqc"\n\n    class Options(argparse.ArgumentParser):\n        def __init__(self, prog=NAME, epilog=None):\n            usage = col.purple(sequana_prolog.format(**{"name": NAME}))\n            super(Options, self).__init__(usage=usage, prog=prog, description="",\n                epilog=epilog,\n                formatter_class=argparse.ArgumentDefaultsHelpFormatter\n            )\n            # add a new group of options to the parser\n            so = SlurmOptions()\n            so.add_options(self)\n\n\nDevelopers should look at e.g. module sequana_pipetools.options\nfor the API reference and one of the official sequana pipeline (e.g.,\nhttps://github.com/sequana/sequana_variant_calling) to get help from examples.\n\nThe Options classes provided can be used and combined to design pipelines. \n\n\nHow to create skeleton of a Sequana pipeline with cookiecutter\n=================================================================\n\nYou can start a Sequana pipeline skeleton as follows::\n\n    pip install cookiecuter\n    cookiecutter https://github.com/sequana/sequana_pipeline_template -o . --overwrite-if-exists\n\nand then follow the instructions. You will be asked some questions such as the name of your pipeline (eg. variant), a description, keywords and the *project_slug* (just press enter).\n\nHow to use sequana pipetools within your Pipeline\n##################################################\n\nFor FastQ files (paired ot not), The config file should look like::\n\n    sequana_wrappers: "v0.15.1"\n\n    input_directory: \'.\'\n    input_readtag: "_R[12]_"\n    input_pattern: \'*fastq.gz\'\n\n\n    apptainers:\n        fastqc: "https://zenodo.org/record/7923780/files/fastqc_0.12.1.img"\n\n    section1:\n        key1: value1\n        key2: value2\n\nAnd your pipeline could make use of this as follows::\n\n    configfile: "config.yaml"\n\n    from sequana_pipetools import PipelineManager\n    manager = PipelineManager("fastqc", config)\n\n    # you can then figure out wheter it is paired or not:\n    manager.paired\n\n    # get the wrapper version to be used within a rule:\n    manager.wrappers\n\n    # the raw data (with a wild card) for the first rule\n    manager.getrawdata()\n\n    # add a Makefile to clean things at the end\n    manager.teardown()\n\n\n\n\n\nSetting up and Running Sequana pipelines\n=========================================\n\n\nWhen you execute a sequana pipeline, e.g.::\n\n    sequana_fastqc --input-directory data\n\na working directory is created (with the name of the pipeline; here fastqc). Moreover, the working directory\ncontains a shell script that will hide the snakemake command. This snakemake command with make use\nof the sequana wrappers and will use the official sequana github repository by default\n(https://github.com/sequana/sequana-wrappers). This may be overwritten. For instance, you may use a local clone. To do\nso, you will need to create an environment variable::\n\n    export SEQUANA_WRAPPERS="git+file:///home/user/github/sequana-wrappers\n\nIf you decide to use singularity/apptainer, one common error on a cluster is that non-standard paths are not found. You can bind them using the -B option but a more general set up is to create thos environment variable::\n\n    export SINGULARITY_BINDPATH="  /path_to_bind"\n\nfor Singularity setup, or ::\n\n    export APPTAINER_BINDPATH=" /path_to_bind"\n\nfor Apptainer setup.\n\n\nWhat is Sequana ?\n=================\n\n**Sequana** is a versatile tool that provides \n\n#. A Python library dedicated to NGS analysis (e.g., tools to visualise standard NGS formats).\n#. A set of Pipelines dedicated to NGS in the form of Snakefiles\n   (Makefile-like with Python syntax based on snakemake framework) with more\n   than 80 re-usable rules.\n#. Standalone applications.\n\nSee the `sequana home page <https://sequana.readthedocs.io>`_ for details.\n\n\nTo join the project, please let us know on `github <https://github.com/sequana/sequana/issues/306>`_.\n\n\n\nChangelog\n=========\n\n========= ======================================================================\nVersion   Description\n========= ======================================================================\n0.13.0    * switch to pyproject and fixes #64\n0.12.5    * automatically populater \'wrappers\' in PipelineManager\' based on the \n            config entry \'sequana_wrappers\'.\n0.12.4    * handles sequana pipeline with underscores (e.g. pacbio_qc)\n0.12.3    * fixes singularity-args in profile\n0.12.2    * Fix the singularity arguments by (i) adding -e and (ii) bind the\n            /home. Indeed, snakemake sets --home to the current directory.\n            Somehow the /home is lost. Removed deprecated function\n0.12.1    * fix regression bug\n0.12.0    * factorise hash function to have url2hash easily accessible\n          * Use pth file to retrieve data dir in editable mode\n          * remove harcoded bind path for apptainer. Uses env variable instead\n          * Fixes singularity-prefix path in shell script if not absolute\n0.11.1    * fix regression, add codacy badge, applied black, remove\n            init_pipeline deprecated function.\n0.11.0    * More robust code to check pip executable.\n0.10.2    * Fixes https://github.com/sequana/sequana_pipetools/issues/49\n            that properly sets the apptainer prefix in defualt mode\n0.10.1    * any python module can implement a Sequana pipeline.\n0.10.0    * incorporate the sequana_start_template from sequana and refactorise\n            the scripts into scripts/\n0.9.6     * hotfix on apptainer to be back compatible if no apptainers section\n            is found in the config file.\n0.9.5     * replaced singularity word by apptainer (--use-aptainer instead of\n            --use-singularity)\n0.9.4     * If timeout occurs while singularity is downloaded, catch the error\n            remove truncated file.\n0.9.3     * hotfix missing import when checking sequana version\n          * add config2schema utility function for developers\n0.9.2     * Udate asynchronous downloads to use aiohttp\n0.9.1     * Ability to download automatically singularity images (as URLs) if\n            set in the  pipelines (container field). add the --use-singularity\n            option in all pipelines (and --singualrity-prefix)\n0.9.0     * **MAJOR update/Aug 2022**\n          * new mechanism to handle  profile for Snakemake that will replace the\n            cluster_config.yaml files\n          * Major cleanup of PipelineManager (PipelineManagerGeneric was\n            removed). The way input files are handled was also cleanup.\n            Fixes https://github.com/sequana/sequana_pipetools/issues/37\n            and also files starting with common prefixes\n0.8.1     * Better schema validation\n0.8.0     * removed \'required_binaries\' attribute in module.py (not used)\n          * removed \'copy_requirements\' in sequana_config and fixed the one\n            in the sequana_manager\n          * switch from distutils to packaging\n          * More tests reaching >90%\n0.7.6     * simplify the setup() method in pipeline manager\n0.7.5     * can set a SEQUANA_WRAPPERS env variable to use local wrappers\n0.7.4     * switch biomics to biomicspole for the slurm queue (internal change)\n0.7.3     * add schema pipeline manager directory & fix attrdict error with yaml\n0.7.2     * allows pipeline and rules to have the same name\n0.7.1     * Fix the --from-project option\n0.7.0     * Set the --wrapper-prefix to point to the  sequana-wrappers github\n0.6.3     * Fix SequanaConfig file\n0.6.2     * Fix script creation to include wrapper and take new snakemake\n            syntax into account\n0.6.1     * update schema handling\n0.6.0     * Move all modules related to pipelines rom sequana into\n            sequana_pipetools; This release should now be the entry point for\n            all Sequana pipelines (no need to import sequana itself).\n0.5.3     * feature removed in sequana to deal with adapter removal and\n            changes updated in the package (removed the \'design\' option\n            from the cutadapt rules and needed)\n          * Improve TrimmingOptions to provide specific list of tools\n            and a default trimming tool\n0.5.2     * add TrimmingOptions class intended at replacing CutadaptOptions\n          * to avoid extra spaces, add \'-o nospace\' in all completion files\n0.5.1     * fix typo\n0.5.0     * add new module called error to be added in onerror sections of all\n            pipelines. Usual test update. Pin to stable version\n0.4.3     * add MANIFEST to include missing requirements.txt\n0.4.2     * add FeatureCounts options\n0.4.1     * add slurm status utility (sequana_slurm_status)\n0.4.0     * stable version\n0.3.1     * comment the prin_newest_version, which is too slow\n0.3.0     * stable release\n0.2.6     * previous new feature led to overhead of a few seconds with --help\n            in this version, we include it only when using --version\n0.2.5     * include newest_version feature\n0.2.4     * completion can now handle multiple directories/files properly\n          * better doc and more tests\n0.2.3     * fix completion to avoir 2 scripts to overwrite each other\n0.2.2     * add a deprecated warning + before_pipeline function\n0.2.1     * add --from-project option to import existing config file\n          * remove --paired-data option\n0.2.0     add content from sequana.pipeline_common to handle all kind of\n          options in the argparse of all pipelines. This is independent of\n          sequana to speed up the --version and --help calls\n0.1.2     add version of the pipeline in the output completion file\n0.1.1     release bug fix\n0.1.0     creation of the package\n========= ======================================================================\n',
    'author': 'Sequana Team',
    'author_email': 'None',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://github.com/sequana/sequana_pipetools',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.8',
}


setup(**setup_kwargs)
