#!/usr/bin/env python
"""
epic-effective
Compute the effective genome size from a fasta file.

(Visit github.com/endrebak/epic for examples and help.)

Usage:
    epic-effective --read-length=LEN [--nb-cpu=CPU] [--tmpdir=TMP] FILE
    epic-effective --help

Arguments:
    FILE                      Fasta genome
    -r LEN --read-length LEN  length of reads

Options:
    -h --help                 show this help message
    -n CPU --nb-cpu CPU       number of cores to use [default: 1]
    -t --tmpdir TMP           temporary directory. Default is to use $TMPDIR if set, otherwise /tmp.
"""
import logging
import os

from docopt import docopt

args = docopt(__doc__)

from epic.config import logging_settings
from epic.scripts.effective_genome_size import effective_genome_size

if __name__ == '__main__':

    fasta, read_length = args["FILE"], int(args["--read-length"])
    nb_cpu = int(args["--nb-cpu"])

    backup_tempdir = os.environ.get("TMPDIR", "/tmp/")
    tmpdir = args["--tmpdir"] or backup_tempdir
    effective_genome_size(fasta, read_length, nb_cpu, tmpdir)
