"""fastq.bz2 to fastq codec

.. author:: Thomas Cokelaer, 2016
"""


rule bz2_to_fastq:
    """Convert fastq.bz2 files to fastq files

    Description:
        Takes a fastq file as input (wildcard dataset) and bzip2 the file
        with pbzip executable. pbzip2/pbunzip2 by default uses the number
        of available threads.

    :param input: fastq.bz2 files
    :return: fastq files
    :third-party executables: pbunzip2

    """
    input: "{dataset}.bz2"
    output: "{dataset}"
    threads: config["compressor"]["threads"]
    run:
        shell("pbunzip2 {input} -p{threads}")
