# Path: snakemakelib/log.py
# class LoggerManager(object):
#     __metaclass__ = Singleton
# 
#     _loggers = {}
#     _fmt = "%(asctime)s (%(levelname)s) %(name)s :  %(message)s"
#     _ch = logging.StreamHandler()
#     _formatter = logging.Formatter(_fmt)
#     _ch.setFormatter(_formatter)
#     _has_loaded_config = False
# 
#     def __init__(self, *args, **kwargs):
#         if not LoggerManager._has_loaded_config:
#             # Add snakemakelib root handler
#             LoggerManager._loggers['snakemakelib'] = logging.getLogger('snakemakelib')
#             LoggerManager._loggers['snakemakelib'].setLevel(logging.WARNING)
#             LoggerManager._loggers['snakemakelib'].addHandler(LoggerManager._ch)
#             self._load_config()
#             LoggerManager._has_loaded_config = True
# 
#     def _load_config(self):
#         conf = {}
#         if os.path.exists("logconf.yaml"):
#             with open ("logconf.yaml", "r") as fh:
#                 conf = yaml.load(fh)
#         else:
#             conf = self._load_sml_config()
#         if conf:
#             logging.config.dictConfig(conf)
#      
#     def _load_sml_config(self):
#         cfg = {}
#         for fn in [os.path.join(os.getenv("HOME"), ".smlconf.yaml"),
#                    os.path.join(os.curdir, "smlconf.yaml")]:
#             if (fn is None):
#                 continue
#             if not os.path.exists(fn):
#                 continue
#             with open(fn, "r") as fh:
#                 cfg_tmp = yaml.load(fh)
#             if cfg_tmp:
#                 cfg.update(cfg_tmp)
#         return cfg.get("logging", {})
# 
#     @staticmethod
#     def getLogger(name=None):
#         if not name:
#             smllogger = logging.getLogger()
#             return logging.getLogger()
#         elif name not in LoggerManager._loggers.keys():
#             LoggerManager._loggers[name] = logging.getLogger(str(name))
#             LoggerManager._loggers[name].addHandler(LoggerManager._ch)
#             return LoggerManager._loggers[name]
#         else:
#             logging.warn("Trying to get already existing logger")


import re
import pickle
import pandas as pd
import numpy as np
from sklearn.decomposition import PCA
from bokeh.plotting import figure, gridplot
from bokeh.io import vform
from bokeh.models import ColumnDataSource, DataTable, TableColumn, HoverTool, BoxSelectTool, CustomJS
from bokeh.models.widgets import Dropdown, Toggle
from bokehutils.axes import xaxis, yaxis
from bokehutils.geom import dotplot, points
from bokehutils.tools import tooltips
from bokehutils.color import colorbrewer
from snakemakelib.log import LoggerManager
        for (i = 0; i < data[label].length; i++) {
              data['color'][i] = colors[colormap[data[label][i]]]
        }
        source.trigger('change');
    }
    """)
    if not md is None:
        # Waiting for callbacks to be implemented upstream in bokeh
        # rbg = RadioButtonGroup(labels=list(md.columns),
        #                        callback=callback)
        toggle_buttons = [Toggle(label=x, callback=callback) for x in list(md.columns)]
    else:
        toggle_buttons = []
        # rbg = RadioButtonGroup()
    # PC components
    xcallback = CustomJS(args=dict(source=source), code="""
        var data = source.get('data');
        var active = cb_obj.get('active')
        var value = cb_obj.get('value')
        x = data['x']
        for (i = 0; i < x.length; i++) {
              x[i] = data[value][i]
              data['sample'][i] = value
              data['FileID'][i] = active
        }

        source.trigger('change');
    """)
    ycallback = CustomJS(args=dict(source=source), code="""
        var data = source.get('data');

# Path: snakemakelib/log.py
# class LoggerManager(object):
#     __metaclass__ = Singleton
# 
#     _loggers = {}
#     _fmt = "%(asctime)s (%(levelname)s) %(name)s :  %(message)s"
#     _ch = logging.StreamHandler()
#     _formatter = logging.Formatter(_fmt)
#     _ch.setFormatter(_formatter)
#     _has_loaded_config = False
# 
#     def __init__(self, *args, **kwargs):
#         if not LoggerManager._has_loaded_config:
#             # Add snakemakelib root handler
#             LoggerManager._loggers['snakemakelib'] = logging.getLogger('snakemakelib')
#             LoggerManager._loggers['snakemakelib'].setLevel(logging.WARNING)
#             LoggerManager._loggers['snakemakelib'].addHandler(LoggerManager._ch)
#             self._load_config()
#             LoggerManager._has_loaded_config = True
# 
#     def _load_config(self):
#         conf = {}
#         if os.path.exists("logconf.yaml"):
#             with open ("logconf.yaml", "r") as fh:
#                 conf = yaml.load(fh)
#         else:
#             conf = self._load_sml_config()
#         if conf:
#             logging.config.dictConfig(conf)
#      
#     def _load_sml_config(self):
#         cfg = {}
#         for fn in [os.path.join(os.getenv("HOME"), ".smlconf.yaml"),
#                    os.path.join(os.curdir, "smlconf.yaml")]:
#             if (fn is None):
#                 continue
#             if not os.path.exists(fn):
#                 continue
#             with open(fn, "r") as fh:
#                 cfg_tmp = yaml.load(fh)
#             if cfg_tmp:
#                 cfg.update(cfg_tmp)
#         return cfg.get("logging", {})
# 
#     @staticmethod
#     def getLogger(name=None):
#         if not name:
#             smllogger = logging.getLogger()
#             return logging.getLogger()
#         elif name not in LoggerManager._loggers.keys():
#             LoggerManager._loggers[name] = logging.getLogger(str(name))
#             LoggerManager._loggers[name].addHandler(LoggerManager._ch)
#             return LoggerManager._loggers[name]
#         else:
#             logging.warn("Trying to get already existing logger")


# Path: snakemakelib/workflow/scrnaseq.py
import re
import pickle
import pandas as pd
import numpy as np
from sklearn.decomposition import PCA
from bokeh.plotting import figure, gridplot
from bokeh.io import vform
from bokeh.models import ColumnDataSource, DataTable, TableColumn, HoverTool, BoxSelectTool, CustomJS
from bokeh.models.widgets import Dropdown, Toggle
from bokehutils.axes import xaxis, yaxis
from bokehutils.geom import dotplot, points
from bokehutils.tools import tooltips
from bokehutils.color import colorbrewer
from snakemakelib.log import LoggerManager

        for (i = 0; i < data[label].length; i++) {
              data['color'][i] = colors[colormap[data[label][i]]]
        }
        source.trigger('change');
    }
    """)
    if not md is None:
        # Waiting for callbacks to be implemented upstream in bokeh
        # rbg = RadioButtonGroup(labels=list(md.columns),
        #                        callback=callback)
        toggle_buttons = [Toggle(label=x, callback=callback) for x in list(md.columns)]
    else:
        toggle_buttons = []
        # rbg = RadioButtonGroup()
    # PC components
    xcallback = CustomJS(args=dict(source=source), code="""
        var data = source.get('data');
        var active = cb_obj.get('active')
        var value = cb_obj.get('value')
        x = data['x']
        for (i = 0; i < x.length; i++) {
              x[i] = data[value][i]
              data['sample'][i] = value
              data['FileID'][i] = active
        }

        source.trigger('change');
    """)
    ycallback = CustomJS(args=dict(source=source), code="""
        var data = source.get('data');

        var value = cb_obj.get('value')