"""fastq.dsrc to fastq codec

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


rule fastq_to_dsrc:
    """Convert fastq files to fastq.dsrc files

    Description:
        Takes a fastq file as input (wildcard dataset) and compress the file
        with **dsrc** executable. 

    :param input: fastq.bz2 files
    :return: fastq files
    :third-party executables: dsrc (http://sun.aei.polsl.pl/dsrc/download.html)

    Config requirements:
        - compressor:threads [integer]
    """
    input: "{dataset}"
    output: "{dataset}.dsrc"
    params: "-m2"
    threads: config["compressor"]["threads"]
    run:
        shell("dsrc c -t{threads} {params} {input} {output}")
        shell("rm -f {input}")
