class TabulatorModel(HTMLBox): """A Bokeh Model that enables easy use of Tabulator tables See http://tabulator.info/ """ __javascript__ = [ MOMENT_SRC, JS_SRC, ] # I could not get Tabulator loaded in Notebook # I found a working solution using requirejs the notebook # I'm working on getting the below working. # See https://github.com/holoviz/panel/issues/1529 __js_skip__ = {"Tabulator": __javascript__[1:]} __js_require__ = { "paths": { "tabulator": ["https://unpkg.com/[email protected]/dist/js/tabulator.min"] }, "exports": { "tabulator": "Tabulator" }, } # __css__ = [CSS_HREFS["default"]] configuration = properties.Dict(properties.String, properties.Any) source = properties.Instance(ColumnDataSource) _cell_change = properties.Dict(properties.String, properties.Any)
class PeaksSequenceHover( # pylint: disable=too-many-instance-attributes,too-many-ancestors HoverTool, SequenceHoverMixin ): "tooltip over peaks" maxcount = props.Int(3) framerate = props.Float(1.) bias = props.Float(0.) stretch = props.Float(0.) updating = props.String('') biases = props.Dict(props.String, props.Float) stretches = props.Dict(props.String, props.Float) __implementation__ = SequenceHoverMixin.impl( 'PeaksSequenceHover', { 'stretches': ('[p.Any, {}]', 'any'), 'biases': ('[p.Any, {}]', 'any') }, __file__ ) @classmethod def create(cls, ctrl, doc, fig, mdl, xrng = None): # pylint: disable=too-many-arguments "Creates the hover tool for histograms" self = super().create(ctrl, doc, fig, mdl, xrng = xrng) jsc = CustomJS(args = {'fig': fig, 'source': self.source}, code = 'cb_obj.apply_update(fig, source)') self.js_on_change("updating", jsc) return self def reset(self, resets, ctrl, mdl): # pylint: disable=arguments-differ "Creates the hover tool for histograms" super().reset(resets, ctrl, mdl, biases = {i: j.bias for i, j in mdl.distances.items()}, stretches = {i: j.stretch for i, j in mdl.distances.items()}) def jsslaveaxes(self, fig, src): # pylint: disable=arguments-differ "slaves a histogram's axes to its y-axis" rng = fig.y_range rng.callback = CustomJS(code = "hvr.on_change_bounds(fig, src)", args = dict(fig = fig, src = src, hvr = self)) rng = fig.extra_y_ranges["bases"] rng.callback = CustomJS(code = "hvr.on_change_bases(fig)", args = dict(fig = fig, hvr = self))
class ReactiveHTML(HTMLBox): attrs = bp.Dict( bp.String, bp.List(bp.Tuple(bp.String, bp.List(bp.String), bp.String))) callbacks = bp.Dict(bp.String, bp.List(bp.Tuple(bp.String, bp.String))) children = bp.Dict(bp.String, bp.List(bp.Either(bp.Instance(LayoutDOM), bp.String))) data = bp.Instance(DataModel) events = bp.Dict(bp.String, bp.Dict(bp.String, bp.Bool)) html = bp.String() looped = bp.List(bp.String) nodes = bp.List(bp.String) scripts = bp.Dict(bp.String, bp.List(bp.String)) def __init__(self, **props): if 'attrs' not in props and 'html' in props: props['attrs'] = find_attrs(props['html']) super().__init__(**props)
class WebComponent(HTMLBox): """A Bokeh Model that enables easily creating new Panel components from web components See https://www.predix-ui.com/#/elements/px-app-nav""" componentType = properties.String("htmlbox") innerHTML = properties.String("") attributesToWatch = properties.Dict(properties.String, properties.Any) attributesLastChange = properties.Dict(properties.String, properties.Any) propertiesToWatch = properties.Dict(properties.String, properties.Any) propertiesLastChange = properties.Dict(properties.String, properties.Any) eventsToWatch = properties.Dict(properties.String, properties.Any) eventsCountLastChange = properties.Dict(properties.String, properties.Int) columnDataSource = properties.Instance(ColumnDataSource) columnDataSourceOrient = properties.String() columnDataSourceLoadFunction = properties.String()
pm.ClassSelector: lambda p, kwargs: ((bp.Instance(DataModel, **kwargs), [ (Parameterized, create_linked_datamodel) ]) if isinstance(p.class_, type) and issubclass( p.class_, param.Parameterized) else bp.Any(**kwargs)), pm.Color: lambda p, kwargs: bp.Color(**kwargs), pm.DataFrame: lambda p, kwargs: (bp.ColumnData(bp.Any, bp.Seq(bp.Any), **kwargs), [( bp.PandasDataFrame, lambda x: ColumnDataSource._data_from_df(x))]), pm.DateRange: lambda p, kwargs: bp.Tuple(bp.Datetime, bp.Datetime, **kwargs), pm.Date: lambda p, kwargs: bp.Datetime(**kwargs), pm.Dict: lambda p, kwargs: bp.Dict(bp.String, bp.Any, **kwargs), pm.Event: lambda p, kwargs: bp.Bool(**kwargs), pm.Integer: lambda p, kwargs: bp.Int(**kwargs), pm.List: lambda p, kwargs: bp.List(bp.Any, **kwargs), pm.Number: lambda p, kwargs: bp.Float(**kwargs), pm.NumericTuple: lambda p, kwargs: bp.Tuple(*(bp.Float for p in p.length), **kwargs), pm.Range: lambda p, kwargs: bp.Tuple(bp.Float, bp.Float, **kwargs), pm.String: lambda p, kwargs: bp.String(**kwargs), pm.Tuple:
class SequenceTicker(BasicTicker): # pylint: disable=too-many-ancestors "Generate ticks at fixed, explicitly supplied locations." major = props.Dict(props.String, props.Seq(props.Float), default={'': []}) minor = props.Dict(props.String, props.Seq(props.Float), default={'': []}) key = props.String(default='') usedefault = props.Bool(default=True) __defaults: dict __withbase: list __model: Any __theme: SequenceTickerTheme __fig: Figure __axis: 'SequenceTicker' __implementation__ = "sequenceticker.ts" def __init__( # pylint: disable=too-many-arguments self, ctrl=None, fig=None, mdl=None, axlabel=None, loc='right', **kwa): "Sets the ticks according to the configuration" super().__init__(**kwa) self.__defaults = dict() self.__withbase = [] if ctrl: self.__theme = ctrl.theme.add(SequenceTickerTheme(), False) else: self.__theme = SequenceTickerTheme() if mdl is None: return self.__model = mdl self.__fig = fig self.__axis = type(self)(ctrl) if 'bases' not in fig.extra_y_ranges: fig.extra_y_ranges = dict(fig.extra_y_ranges, bases=Range1d(start=0., end=0.)) fig.add_layout( LinearAxis(y_range_name="bases", axis_label=axlabel, ticker=self.__axis), loc) # bokehjs will never draw minor lines unless the color is # is set at startup fig.ygrid[0].update(minor_grid_line_color='navy', minor_grid_line_alpha=0., ticker=self, y_range_name='bases') order = tuple('grid_line_' + i for i in ('color', 'width', 'dash', 'alpha')) order += tuple('minor_' + i for i in order) # type: ignore self.__defaults = {i: getattr(fig.ygrid[0], i) for i in order} self.__withbase = dict() theme = self.__model.themename for name in ('color', 'dash', 'width', 'alpha'): gridprops = themed(theme, self.__theme.grid[name]) self.__withbase['grid_line_' + name] = gridprops[0] self.__withbase['minor_grid_line_' + name] = gridprops[1] @staticmethod def init(ctrl): "init private fields" ctrl.theme.add(SequenceTickerTheme(), False) @property def axis(self): u"returns the fixed axis" return self.__axis def reset(self, resets): "Updates the ticks according to the configuration" mdl = self.__model fig = self.__fig key = (mdl.sequencemodel.currentkey if mdl.sequencemodel.currentkey is not None and len(mdl.oligos) else 'NONE') majors = {} minors = {} axis = next(i for i in fig.right if isinstance(i, LinearAxis)) resets[axis].update(axis_label_standoff=self.__theme.standoff) if key == 'NONE': resets[fig.ygrid[0]].update(self.__defaults) else: resets[fig.ygrid[0]].update(self.__withbase) for name, peaks in self.__model.hybridisations(...).items(): majors[name] = tuple(peaks['position'][peaks['orientation']]) minors[name] = tuple(peaks['position'][~peaks['orientation']]) resets[self].update(major=majors, minor=minors, key=key) minor = dict.fromkeys(majors.keys(), tuple()) # type:ignore major = {i: majors[i] + minors[i] for i in majors} resets[self.__axis].update(major=major, minor=minor, key=key)
class PeaksStatsDiv(Div): # pylint: disable = too-many-ancestors "div for displaying stats" data = props.Dict(props.String, props.String) __implementation__ = "peakstats.ts"