import os
import shutil
import logging

#try:
#    from bcbio.install import _set_matplotlib_default_backend
#    _set_matplotlib_default_backend()
#except (ImportError, OSError, IOError):
#    pass
#import matplotlib
#matplotlib.use('Agg', force=True)

from libs.read import load_data
from libs.report import make_profile
from libs.utils import safe_dirs
from db import make_database
import templates

logger = logging.getLogger('report')


def report(args):
    """
    Create report in html format
    """
    logger.info("reading sequeces")
    data = load_data(args.json)
    # out_dir = os.path.join(args.out, "html")
    safe_dirs(out_dir)

    logger.info("create profile")
    data = make_profile(data, out_dir, args)
    logger.info("create database")
    make_database(data, "seqcluster.db", args.out)

    logger.info("Done. Download https://github.com/lpantano/seqclusterViz/archive/master.zip to browse the output.")

import os
import shutil
import logging

#try:
#    from bcbio.install import _set_matplotlib_default_backend
#    _set_matplotlib_default_backend()
#except (ImportError, OSError, IOError):
#    pass
#import matplotlib
#matplotlib.use('Agg', force=True)

from libs.read import load_data
from libs.report import make_profile
from libs.utils import safe_dirs
from db import make_database
import templates

logger = logging.getLogger('report')


def report(args):
    """
    Create report in html format
    """
    logger.info("reading sequeces")
    data = load_data(args.json)

    logger.info("create profile")
    data = make_profile(data, out_dir, args)
    logger.info("create database")
    make_database(data, "seqcluster.db", args.out)

    logger.info("Done. Download https://github.com/lpantano/seqclusterViz/archive/master.zip to browse the output.")

remove createdir from report cmd