"""fastq to fastq.bz2 codec

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


rule fastq_to_bz2:
    """Convert fastq files to fastq.bz2 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 files
    :return: fastq.bz2 files
    :third-party executables: pbzip2

    """

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