rule picard__prepare_dict_index:
    """
    Create sequence dictionary index from fasta file to quicker retrieve substring sequences
    :input reference: Genomic sequence file in fasta format to index
    :output dict: Index for the input reference genomic file
    """
    input:
        reference = 'reference/{reference}/{reference}.fa'
    output:
        dict = protected('reference/{reference}/{reference}.dict')
    log:
        out = 'reference/{reference}/log/picard_index.log',
        err = 'reference/{reference}/log/picard_index.err'
    conda:
        config['snakelines_dir'] + '/environments/picard.yaml'
    shell:
        """
        picard CreateSequenceDictionary \
            REFERENCE={input.reference} \
            OUTPUT={output.dict} \
            1>{log.out} \
            2>{log.err}
        """
    
