


rule canu:
    """CANU assembly

    Required input:
        - __canu__input: input fasta files (1 per {sample})

    Required output:
        - __canu__output: CANU creates lots of output. What we do is to
          check for the presence of {sample}.contigs.fasta

    Required parameters:
        - __canu__workdir: where to save the results of the analysis
        - __canu_prefix: prefix used for the names. typically the {sample}

    Required log:
        - __canu__log: where to save the stderr

    Required configuration:
        .. code-block:: yaml

            # Note that genomeSize can be in Giga (g) Mega (m), Kilo (k), 
            canu:
                genomeSize: 4.1m
                threads: 4
                techno: -pacbio-raw
                options: ""

    """
    input: __canu__input
    output: __canu__output
    params:
        genomeSize  = config["canu"]["genomeSize"],
        techno      = config['canu']["techno_choice"],
        options     = config['canu']['options'],
        wkdir       =  __canu__workdir,
        prefix      =  __canu__prefix
    log: __canu__log
    threads: config['canu']['threads']
    message: """Running CANU assembly. 
This make take a while. Check the log file for progress"""
    shell:
        """
        canu -p {params.prefix} -d {params.wkdir} \
            genomeSize={params.genomeSize} \
            maxThreads={threads} \
            {params.techno} {input[0]} 2>{log}
        """
