# Path: crumbs/exceptions.py
# class OptionalRequirementError(Exception):
#     'An optional module is not present'
#     pass
# 
# Path: crumbs/utils/optional_modules.py
# MSG = 'A python package to run this executable is required,'
# BIO = 'biopython'
# BIO_BGZF = 'biopython with Bgzf support'
#     NCBIXML = create_fake_class(MSG + BIO)
#     NCBIWWW = create_fake_class(MSG + BIO)
# def create_fake_class(msg):
#         def __init__(self, *args, **kwargs):
# def create_fake_funct(msg):
#     def FakeRequiredfunct(*args, **kwargs):
#     class FakePythonRequiredClass(object):


from os.path import splitext
from crumbs.exceptions import OptionalRequirementError
from crumbs.utils.optional_modules import FigureCanvas, Figure, cm, Normalize
                            ylog_scale=False, figsize=None):
    'It draws an histogram and if the fhand is given it saves it'
    plot_hist = HistogramPlotter([counter], xlabel=xlabel, ylabel=ylabel,
                                 xmax=xmax, xmin=xmin, titles=[title],
                                 ylimits=ylimits, kind=kind, figsize=None)
    plot_hist.write_figure(fhand)


def draw_histograms(counters, fhand, distrib_labels=None, num_cols=2,
                    plots_per_chart=3, xlabel=None, ylabel=None, titles=None,
                    kind=LINE, xmax=None, xmin=None, linestyles=None,
                    ylimits=None, ylog_scale=False):

    plot_hist = HistogramPlotter(counters, xlabel=xlabel, ylabel=ylabel,
                                 xmax=xmax, xmin=xmin, titles=titles,
                                 distrib_labels=distrib_labels, kind=kind,
                                 linestyles=linestyles, ylimits=ylimits,
                                 num_cols=num_cols, ylog_scale=ylog_scale,
                                 plots_per_chart=plots_per_chart)
    plot_hist.write_figure(fhand)


def get_canvas_and_axes(figure_size=FIGURE_SIZE, left=0.1, right=0.9, top=0.9,
                        bottom=0.1, plot_type=111):
    'It returns a matplotlib canvas and axes instance'
    try:
        fig = Figure(figsize=FIGURE_SIZE)
        canvas = FigureCanvas(fig)
    except NameError:
        msg = 'Matplotlib module is required to draw graphical histograms'

# Path: crumbs/exceptions.py
# class OptionalRequirementError(Exception):
#     'An optional module is not present'
#     pass
# 
# Path: crumbs/utils/optional_modules.py
# MSG = 'A python package to run this executable is required,'
# BIO = 'biopython'
# BIO_BGZF = 'biopython with Bgzf support'
#     NCBIXML = create_fake_class(MSG + BIO)
#     NCBIWWW = create_fake_class(MSG + BIO)
# def create_fake_class(msg):
#         def __init__(self, *args, **kwargs):
# def create_fake_funct(msg):
#     def FakeRequiredfunct(*args, **kwargs):
#     class FakePythonRequiredClass(object):


# Path: crumbs/plot.py
from os.path import splitext
from crumbs.exceptions import OptionalRequirementError
from crumbs.utils.optional_modules import FigureCanvas, Figure, cm, Normalize

                            ylog_scale=False, figsize=None):
    'It draws an histogram and if the fhand is given it saves it'
    plot_hist = HistogramPlotter([counter], xlabel=xlabel, ylabel=ylabel,
                                 xmax=xmax, xmin=xmin, titles=[title],
                                 ylimits=ylimits, kind=kind, figsize=None)
    plot_hist.write_figure(fhand)


def draw_histograms(counters, fhand, distrib_labels=None, num_cols=2,
                    plots_per_chart=3, xlabel=None, ylabel=None, titles=None,
                    kind=LINE, xmax=None, xmin=None, linestyles=None,
                    ylimits=None, ylog_scale=False):

    plot_hist = HistogramPlotter(counters, xlabel=xlabel, ylabel=ylabel,
                                 xmax=xmax, xmin=xmin, titles=titles,
                                 distrib_labels=distrib_labels, kind=kind,
                                 linestyles=linestyles, ylimits=ylimits,
                                 num_cols=num_cols, ylog_scale=ylog_scale,
                                 plots_per_chart=plots_per_chart)
    plot_hist.write_figure(fhand)


def get_canvas_and_axes(figure_size=FIGURE_SIZE, left=0.1, right=0.9, top=0.9,
                        bottom=0.1, plot_type=111):
    'It returns a matplotlib canvas and axes instance'
    try:
        fig = Figure(figsize=FIGURE_SIZE)
        canvas = FigureCanvas(fig)
    except NameError:
        msg = 'Matplotlib module is required to draw graphical histograms'

        raise OptionalRequirementError(msg)