Package: sequana-pipetools
Overview:A set of tools to help building or using Sequana pipelinesStatus:ProductionIssues:Please fill a report ongithubPython version:Python 3.8, 3.9, 3.10, 3.11Citation: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.00352Installationfrom pypi website:pip install sequana_pipetoolsNo dependencies for this package except Python itself. In practice, this package
has no interest if not used within a Sequana pipeline. It is installed automatically when you install
a Sequana pipelines. For example:pip install sequana_rnaseq
pip install sequana_fastqcSeeSequanafor a list of pipelines ready for production.Targetted audienceThis package is intended forSequanadevelopers seeking to integrate Snakemake pipelines into the Sequana project. Please refer below for more information. Additionally, note that as a developer, you can generate the reference documentation using Sphinx:make html
browse build/html/index.htmlWhat is sequana_pipetools ?sequana_pipetoolsis a collection of tools designed to facilitate the management ofSequanapipelines, which includes next-generation sequencing (NGS) pipelines like RNA-seq, variant calling, ChIP-seq, and others.The aim of this package is to streamline the deployment ofSequana pipelinesby
creating a pure Python library that includes commonly used tools for various pipelines.Previously, the Sequana framework incorporated all bioinformatics, Snakemake rules,
pipelines, and pipeline management tools into a single library (Sequana) as illustrated
inFig 1below.Figure 1Old Sequana framework will all pipelines and Sequana library in the same
place including pipetools (this library).Despite maintaining an 80% test coverage, whenever changes were introduced to the Sequana library, a comprehensive examination of the entire library was imperative. The complexity escalated further when incorporating new pipelines or dependencies. To address this challenge, we initially designed all pipelines to operate independently, as depicted inFig. 2. This approach allowed modifications to pipelines without necessitating updates to Sequana and vice versa, resulting in a significant improvement.Figure 2v0.8 of Sequana moved the Snakemake pipelines in independent
repositories. Acookie cutterease the creation of such pipelinesNevertheless, certain tools, including those utilized for user interface and input data sanity checks, were essential for all pipelines, as illustrated by the pipetools box in the figure. With the continuous addition of new pipelines each month, our goal was to enhance the modularity of both the pipelines and Sequana. As a result, we developed a pure Python library named sequana_pipetools, depicted inFig. 3, to further empower the autonomy of the pipelines.Figure 3New Sequana framework. The new Sequana framework comprises the core library
and bioinformatics tools, which are now separate from the pipelines. Moreover, the
sequana_pipetools library provides essential tools for the creation and management
of all pipelines, including a shared parser for optionsAs a final step, we separated the rules originally available in Sequana to create an independent package featuring a collection of Snakemake wrappers. These wrappers can be accessed athttps://github.com/sequana/sequana-wrappersand offer the added benefit of being rigorously tested through continuous integration.Figure 3New Sequana framework 2021. The library itself with the core, the
bioinformatics tools is now fully independent of the pipelines.Quick tour of the standaloneThesequana_pipetoolspackage provide a standalone calledsequana_pipetools. Here is a snapshot of the user interface:There are currently 3-4 main application. The first one is for Linux users under
bash to obtain completion of a sequana pipeline command line arguments:sequana_pipetools --completion fastqcThe second is used to introspect slurm files to get a summary of the SLURM log
files:sequana_pipetools --slurm-diagIt searches for files with patternslurmin the current directory and slurm files in the ./logs directory.
This is used within th pipeline but can be used manually as well and is useful to get a quick summary of common errors found in slurm files.The following command provides statistics about Sequana pipelines installed on your system (number of rules, wrappers
used):sequana_pipetools -- statsAnd for developpers, a quick creation of schema file given a config file (experimental, developers would still need to edit the schema but it does 90% of the job):sequana_pipetools --config-to-schema config.yaml > schema.yamlFor Sequana developersThe library is intended to help Sequana developers to design their pipelines.
See theSequana organization repository for examples.
In addition to the standalone shown above,sequana_pipetoolsmain goal is to provide utilities to help Sequana developers.First, let us create a pipelineInitiate a project (Sequana pipeline) with cookiecutterYou can start a Sequana pipeline skeleton as follows:pip install cookiecuter
cookiecutter https://github.com/sequana/sequana_pipeline_template -o . --overwrite-if-existsand then follow the instructions. You will be asked some questions such as the name of your pipeline (eg. variant), a description, keywords and theproject_slug(just press enter).Update the main scriptGo to sequana_pipelines/NAME and look at the main.py script.We currently provide a set of Options classes that should be used to
design the API of your pipelines. For example, the
sequana_pipetools.options.SlurmOptions can be used as follows inside a standard
Python module (the last two lines is where the magic happens):import rich_click as click
from sequana_pipetools.options import *
from sequana_pipetools import SequanaManager

NAME = "fastqc"
help = init_click(NAME, groups={
    "Pipeline Specific": [
        "--method", "--skip-multiqc"],
        }
)

@click.command(context_settings=help)
@include_options_from(ClickSnakemakeOptions, working_directory=NAME)
@include_options_from(ClickSlurmOptions)
@include_options_from(ClickInputOptions, add_input_readtag=False)
@include_options_from(ClickGeneralOptions)
@click.option("--method", default="fastqc", type=click.Choice(["fastqc", "falco"]), help="your msg")
def main(**options):

    # the real stuff is here
    manager = SequanaManager(options, NAME)
    manager.setup()

    # just two aliases
    options = manager.options
    cfg = manager.config.config


    # fills input_data, input_directory, input_readtag
    manager.fill_data_options()

    # fill specific options.
    # create a function for a given option (here --method)
    def fill_method():
        # any extra sanity checks
        cfg['method'] = options['method']

    if options['from-project']:
        # in --from-project, we fill the method is --method is provided only (since already pre-filled)
        if "--method" in sys.argv
            fill_method()
    else:
        # in normal, we always want to fill the user-provided option
        fill_method()

    # finalise the command and save it; copy the snakemake. update the config
    # file and save it.
    manager.teardown()

if __name__ == "__main__":
    main()Developers should look at e.g. module sequana_pipetools.options
for the API reference and one of the official sequana pipeline (e.g.,https://github.com/sequana/sequana_variant_calling) to get help from examples.The Options classes provided can be used and combined to design pipelines.How to use sequana pipetools within your PipelineFor FastQ files (paired ot not), The config file should look like:sequana_wrappers: "v0.15.1"

input_directory: '.'
input_readtag: "_R[12]_"
input_pattern: '*fastq.gz'


apptainers:
    fastqc: "https://zenodo.org/record/7923780/files/fastqc_0.12.1.img"

section1:
    key1: value1
    key2: value2And your pipeline could make use of this as follows:configfile: "config.yaml"

from sequana_pipetools import PipelineManager
manager = PipelineManager("fastqc", config)

# you can then figure out wheter it is paired or not:
manager.paired

# get the wrapper version to be used within a rule:
manager.wrappers

# the raw data (with a wild card) for the first rule
manager.getrawdata()

# add a Makefile to clean things at the end
manager.teardown()Setting up and Running Sequana pipelinesWhen you execute a sequana pipeline, e.g.:sequana_fastqc --input-directory dataa working directory is created (with the name of the pipeline; here fastqc). Moreover, the working directory
contains a shell script that will hide the snakemake command. This snakemake command with make use
of the sequana wrappers and will use the official sequana github repository by default
(https://github.com/sequana/sequana-wrappers). This may be overwritten. For instance, you may use a local clone. To do
so, you will need to create an environment variable:export SEQUANA_WRAPPERS="git+file:///home/user/github/sequana-wrappersIf 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:export SINGULARITY_BINDPATH="  /path_to_bind"for Singularity setup, orexport APPTAINER_BINDPATH=" /path_to_bind"for Apptainer setup.What is Sequana ?Sequanais a versatile tool that providesA Python library dedicated to NGS analysis (e.g., tools to visualise standard NGS formats).A set of Pipelines dedicated to NGS in the form of Snakefiles
(Makefile-like with Python syntax based on snakemake framework) with more
common wrappers.Standalone applications such as sequana_coverage and sequana_taxonomy.See thesequana home pagefor details.To join the project, please let us know ongithub.ChangelogVersionDescription0.17.3remove useless code and fix a requirement0.17.2simpler logging0.17.1remove the –use-singulariry (replaced by –use-apptainer in
previous release)slight updates on logging and slight update on slurm module0.17.0Remove deprecated options and deprecated functions. More tests.0.16.9Fix slurm sys exit (replaced by print)upadte docmore tests0.16.8stats command add the number of rules per pipelinebetter slurm parsing using profile tree directory (slurm in logs/)0.16.7add missing –trimming-quality option in list of TrimmingOptionset default to cutadatp if no fastp availablebetter UI for the completion script.0.16.6Set default value for the option trimming to 20Fix issuehttps://github.com/sequana/sequana_pipetools/issues/850.16.5merge completion standalone into main sequana_pipetools applicationadd application to create schema given a config fileadd application to get basic stats about the pipelinesadd precommit and applied black/isort on all filesremove some useless codeupdate completion to use click instead of argparseRename Module into Pipeline (remove rules so Module are only made
of pipelines hence the renaming)0.16.4fix Trimming options (click) for the quality option0.16.3add class to handle multiplex entry for click.option (useful for
multitax multiple databases)0.16.2remove useless function get_pipeline_location, get_package_location
guess_scheduler from sequana_manager (not used)store sequana version correctly in info.txt Fixing #89sort click options alphabetically–from-project not funtcional (example in multitax pipeline)Click checks that input-directoyr is a directory indeed0.16.1Fix/rename error_report into onerror to be included in the Snakemake
onerror section. added ‘slurm’ in slurm output log file in the
profile0.16.0scripts now use click instead of argparseAll Options classes have now an equivalent using click.
For example GeneralOptions has a class ClickGeneralOptions.
The GeneralOptions is kept for now for back compatibility–run-mode removed and replaced by –profile options. Profiles are
used and stored withub .sequana/profilesRemove –slurm-cores-per-job redundant with resources from snakemakeWay a main.py is coded fully refactored and simplified as described
in the READMEcluster_config are now deprecated in favor of profilesequana_slurm_status removed. Use manager.error_report in pipelines
instead0.15.0remove useless code (readme, description) related to old rulesrequirements.txt renamed in tools.txt to store the required tools to
run a pipeline.remove copy_requirements, not used in any pipelines (replaced by code
in main.py of the pipelines)a utility function called getmetadata that returns dictionary
with name, version, wrappers version)0.14.XModule now returns the list of requirements. SequanaManager
creates a txt file with all standalones from the requirements.0.13.0switch to pyproject and fixes #640.12.Xautomatically populater ‘wrappers’ in PipelineManager’ based on the
config entry ‘sequana_wrappers’.Fix the singularity arguments by (i) adding -e and (ii) bind the
/home. Indeed, snakemake sets –home to the current directory.
Somehow the /home is lost. Removed deprecated functionfactorise hash function to have url2hash easily accessibleremove harcoded bind path for apptainer. Uses env variable instead0.11.Xfix regression, add codacy badge, applied black, remove
init_pipeline deprecated function.0.10.XFixeshttps://github.com/sequana/sequana_pipetools/issues/49that properly sets the apptainer prefix in defualt mode0.9.Xreplaced singularity word by apptainer (–use-aptainer instead of
–use-singularity)add config2schema utility function for developersAbility to download automatically singularity images (as URLs) if
set in the  pipelines (container field). add the –use-singularity
option in all pipelines (and –singualrity-prefix)0.9.0MAJOR update/Aug 2022new mechanism to handle  profile for Snakemake that will replace the
cluster_config.yaml filesMajor cleanup of PipelineManager (PipelineManagerGeneric was
removed). The way input files are handled was also cleanup.
Fixeshttps://github.com/sequana/sequana_pipetools/issues/37and also files starting with common prefixes0.8.XBetter schema validation. switch from distutils to packaging0.7.Xsimplify the setup() method in pipeline manager
can set a SEQUANA_WRAPPERS env variable to use local wrappers
add schema pipeline manager directory & fix attrdict error with yamlSet the –wrapper-prefix to point to the  sequana-wrappers github0.6.XFix SequanaConfig file to include wrapper
and take new snakemake syntax into account. update schema handlingMove all modules related to pipelines from sequana into
sequana_pipetools0.5.Xfeature removed in sequana to deal with adapter removal and
changes updated in the package (removed the ‘design’ option
from the cutadapt rules and needed); add TrimmingOptions.0.4.Xadd FeatureCounts options and slurm status utility0.4.0stable version0.3.Xfirst stable release0.2.Xcompletion can now handle multiple directories/files properly
better doc and more tests; add –from-project option to import
existing config file; remove –paired-data option; add content
from sequana.pipeline_common0.1.Xsoftware creation