# Path: metatlas/io/write_utils.py
# def make_dir_for(file_path):
# def check_existing_file(file_path, overwrite=False):
# def export_dataframe(dataframe, file_path, description, overwrite=False, **kwargs):
# def raise_on_diff(dataframe, file_path, description, **kwargs):
# def export_dataframe_die_on_diff(dataframe, file_path, description, overwrite=False, **kwargs):


import logging
import numpy as np
from textwrap import wrap
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib import collections as mc
from scipy.interpolate import interp1d
from six.moves import range
from six.moves import zip
from metatlas.io import write_utils
def chromplotplus(kwargs):
    ChromPlotPlus(**kwargs)

class CompoundFileEIC:
    def __init__(self, compound_file_data, rt_bounds, rt_min, rt_max, shortname):
        self.group_name = compound_file_data['group'].name
        self.file_name = compound_file_data['lcmsrun'].name
        if not shortname.empty:
            self.file_name = shortname.loc[compound_file_data['lcmsrun'].name.split('.')[0], 'shortname'][0]
        try:
            self.eic = np.asarray([compound_file_data['data']['eic']['rt'],
                                   compound_file_data['data']['eic']['intensity']]).astype(float)
            self.eic = self.eic[:, (rt_min <= self.eic[0]) & (self.eic[0] <= rt_max)]

            try:
                self.intensity_max_inbounds = self.eic[1, (rt_bounds[0] <= self.eic[0]) & (self.eic[0] <= rt_bounds[1])].max()
            except ValueError:
                self.intensity_max_inbounds = np.nan

        except (KeyError, AttributeError, TypeError):
            self.eic = np.array([[],[]])
            self.intensity_max_inbounds = np.nan

class ChromPlotPlus:

    def __init__(self, data, shortname,
                 group, file_name, rt_buffer = .5,
                 x_scale = .8, y_scale = .75,
                 x_ratio = 13.0, y_ratio=11.0,
                 num_x_hashes=4, num_y_hashes=4,

# Path: metatlas/io/write_utils.py
# def make_dir_for(file_path):
# def check_existing_file(file_path, overwrite=False):
# def export_dataframe(dataframe, file_path, description, overwrite=False, **kwargs):
# def raise_on_diff(dataframe, file_path, description, **kwargs):
# def export_dataframe_die_on_diff(dataframe, file_path, description, overwrite=False, **kwargs):


# Path: metatlas/plots/chromplotplus.py
import logging
import numpy as np
from textwrap import wrap
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib import collections as mc
from scipy.interpolate import interp1d
from six.moves import range
from six.moves import zip
from metatlas.io import write_utils

def chromplotplus(kwargs):
    ChromPlotPlus(**kwargs)

class CompoundFileEIC:
    def __init__(self, compound_file_data, rt_bounds, rt_min, rt_max, shortname):
        self.group_name = compound_file_data['group'].name
        self.file_name = compound_file_data['lcmsrun'].name
        if not shortname.empty:
            self.file_name = shortname.loc[compound_file_data['lcmsrun'].name.split('.')[0], 'shortname'][0]
        try:
            self.eic = np.asarray([compound_file_data['data']['eic']['rt'],
                                   compound_file_data['data']['eic']['intensity']]).astype(float)
            self.eic = self.eic[:, (rt_min <= self.eic[0]) & (self.eic[0] <= rt_max)]

            try:
                self.intensity_max_inbounds = self.eic[1, (rt_bounds[0] <= self.eic[0]) & (self.eic[0] <= rt_bounds[1])].max()
            except ValueError:
                self.intensity_max_inbounds = np.nan

        except (KeyError, AttributeError, TypeError):
            self.eic = np.array([[],[]])
            self.intensity_max_inbounds = np.nan

class ChromPlotPlus:

    def __init__(self, data, shortname,
                 group, file_name, rt_buffer = .5,
                 x_scale = .8, y_scale = .75,
                 x_ratio = 13.0, y_ratio=11.0,
                 num_x_hashes=4, num_y_hashes=4,

                 overwrite=False, share_y=False,