class DpxToolbar(Widget):
    "Toolbar model"
    __css__ = route("view.css", "icons.css", "toolbar.css")
    __implementation__ = 'toolbar.ts'
    __javascript__ = route()
    frozen = props.Bool(True)
    open = props.Int(0)
    save = props.Int(0)
    doc = props.Int(0)
    quit = props.Int(0)
    bead = props.Int(-1)
    discarded = props.String('')
    accepted = props.String('')
    currentbead = props.Bool(True)
    currentfile = props.Int(-1)
    delfile = props.Int(-1)
    filelist = props.List(props.String)
    seltype = props.Bool(True)
    message = props.String('')
    helpmessage = props.String('')
    hasquit = props.Bool(False)
    hasdoc = props.Bool(False)

    def __init__(self, **kwa):
        super().__init__(name='Main:toolbar', **kwa)
Exemple #2
0
class FastTextAreaInput(_BkTextAreaInput):
    """The FastTextAreaInput enables using the `fast-textarea-input` with Bokeh."""

    # value  is inherited
    # placeholder is inherited
    # max_length is inherited
    # cols is inherited
    # rows is inherited
    appearance = properties.String(
        help=
        """Determines the appearance of the textinput. One of `outline` or `filled`.
        Defaults to outlined""", )
    autofocus = properties.Bool(
        help="""The autofocus attribute. Defaults to `False`""", )
    resize = properties.String(help="""The resize attribute. One of
        `None`, `both`, `horizontal` or `vertical`. Defaults to `None`.""", )

    min_length = properties.Int(
        help="""The minimum length of the text string""", )

    spellcheck = properties.Bool(
        help="""Whether or not the spell check is enabled. Default is False""")
    required = properties.Bool(
        help=
        """Whether or not the FastTextInput is required. Default is False""")
    readonly = properties.Bool(
        help=
        """Whether or not the FastTextInput is readonly. Default is False""")
class FastTextInput(_BkTextInput):
    # value  is inherited
    # placeholder is inherited
    # list is not supported
    appearance = properties.String(
        help=
        """Determines the appearance of the textinput. One of `outline` or `filled`.
        Defaults to outlined""", )
    autofocus = properties.Bool(
        help="""The autofocus attribute. Defaults to `False`""", )
    type_of_text = properties.String(
        help=
        """Determines the type of text accepted. One of `email`, `password`, `tel`, `text` or `url`.
        Defaults to text.
        """)
    max_length = properties.Int(
        help="""The maximum length of the text string""", )
    min_length = properties.Int(
        help="""The minimum length of the text string""", )
    pattern = properties.String(
        help=
        """A regular expression that the input's value must match in order for the value to pass constraint validation"""
    )
    size = properties.Int(
        help=
        """Valid for email, password, tel, and text input types only. Specifies how much of the input is shown""",
    )
    spellcheck = properties.Bool(
        help="""Whether or not the spell check is enabled. Default is False""")
    required = properties.Bool(
        help=
        """Whether or not the FastTextInput is required. Default is False""")
    readonly = properties.Bool(
        help=
        """Whether or not the FastTextInput is readonly. Default is False""")
Exemple #4
0
class DpxFitParams(Widget):
    "Interface to filters needed for cleaning"
    __css__ = route("peaksplot.css")
    __javascript__ = [ROUTE + "/jquery.min.js", ROUTE + "/jquery-ui.min.js"]
    __implementation__ = "_widget.ts"
    frozen = props.Bool(True)
    stretch = props.String("")
    bias = props.String("")
    locksequence = props.Bool(False)
Exemple #5
0
class Icon(AbstractIcon):
    """The Icon can be used to add SVG based icons to buttons, menus etc."""

    label = properties.String()
    text = properties.String(
        default="", help="""The text or HTML contents of the widget.""")
    size = properties.Float()
    fill_color = properties.String()
    spin_duration = properties.Int()
class DpxDiscardedBeads(Widget):
    "Toolbar model"
    __css__ = route("groupedbeads.css", "icons.css")
    __implementation__ = '_widget.ts'
    __javascript__ = route()
    frozen = props.Bool(True)
    hassequence = props.Bool(False)
    discarded = props.String('')
    discardedhelp = props.String('')
    forced = props.String('')
    forcedhelp = props.String('')
Exemple #7
0
class FastAnchor(Widget):
    """Bokeh model wrapping the fast-anchor component"""

    appearance = properties.String()
    download = properties.String()
    href = properties.String()
    hreflang = properties.String()
    ping = properties.String()
    referrerpolicy = properties.String()
    referrer = properties.String()  # cannot call this ref
    rel = properties.String()
    target = properties.String()
    mimetype = properties.String()
Exemple #8
0
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()
Exemple #10
0
class FastButton(_BkButton):
    appearance = properties.String(
        default="neutral",
        help="The appearance attribute",
    )
    autofocus = properties.Bool(
        default=False,
        help="The autofocus attribute",
    )
class FastButton(_BkButton):
    """The FastButton enables using the `fast-button` with Bokeh."""

    appearance = properties.String(
        default="neutral",
        help="The appearance attribute",
    )
    autofocus = properties.Bool(
        default=False,
        help="The autofocus attribute",
    )
class DpxCleaning(Widget):
    "Interface to filters needed for cleaning"
    __css__ = route("cleaning.css")
    __javascript__ = route()
    __implementation__ = "_widget.ts"
    frozen = props.Bool(True)
    framerate = props.Float(30.)
    figure = props.Instance(Figure)
    fixedbeads = props.String("")
    subtracted = props.String("")
    subtractcurrent = props.Int(0)

    maxabsvalue = props.Float(getattr(DataCleaningTask, 'maxabsvalue'))
    maxderivate = props.Float(getattr(DataCleaningTask, 'maxderivate'))
    minpopulation = props.Float(getattr(DataCleaningTask, 'minpopulation'))
    minhfsigma = props.Float(getattr(DataCleaningTask, 'minhfsigma'))
    maxhfsigma = props.Float(getattr(DataCleaningTask, 'maxhfsigma'))
    minextent = props.Float(getattr(DataCleaningTask, 'minextent'))
    maxextent = props.Float(getattr(DataCleaningTask, 'maxextent'))
    maxsaturation = props.Float(getattr(DataCleaningTask, 'maxsaturation'))
Exemple #13
0
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))
Exemple #14
0
class KeyModResponder(LayoutDOM):
    """capture all aspects of keydown/up events"""
    #__implementation__ = TypeScript(KEYBOARDRESPONDERCODE_TS)
    __implementation__ = "keymodresponder.ts"
    # can use # __css__ = '<a css file.css>'
    # can use # __javascript__ = 'katex.min.js' # for additional javascript
    # this should match with javascript/typescript implementation 
    key = properties.String(default="")
    keyCode = properties.Int(default=0) 
    altKey = properties.Bool(default=False)
    ctrlKey = properties.Bool(default=False)
    metaKey = properties.Bool(default=False)
    shiftKey = properties.Bool(default=False)
    
    key_num_presses = properties.Int(default=0)
    
    keypress_callback = properties.Instance(bokeh.models.callbacks.Callback,
                                   help=""" A callback to run in the browser whenever a key is pressed
                                   """)
Exemple #15
0
    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:
    lambda p, kwargs: bp.Tuple(*(bp.Any for p in p.length), **kwargs),
}


def construct_data_model(parameterized, name=None, ignore=[], types={}):
    """
    Dynamically creates a Bokeh DataModel class from a Parameterized
    object.

    Arguments
    ---------
    parameterized: param.Parameterized
        The Parameterized class or instance from which to create the
        DataModel
Exemple #16
0
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 DpxHoverModel(
        HoverTool,  # pylint: disable=too-many-instance-attributes,too-many-ancestors
        SequenceHoverMixin):
    "controls keypress actions"
    maxcount = props.Int(3)
    framerate = props.Float(1.)
    shape = props.Tuple(props.Int, props.Int, default=(0, 0))
    cycle = props.Int(-1)
    bias = props.Float(0.)
    stretch = props.Float(0.)
    updating = props.String('')
    rawrend = props.Instance(Renderer)
    impl = SequenceHoverMixin.impl
    __implementation__ = impl(
        'DpxHoverModel', {
            '_hvr_cnt': ('[p.Number, -1]', 'number'),
            'shape': ('[p.Array, [2,1]]', 'number[]'),
            'cycle': ('[p.Int, -1]', 'number'),
            'rawrend': ('[p.Instance, null]', 'any')
        }, __file__)

    @staticmethod
    def _createrawdata(data, shape):
        return dict(t=data['t'][:shape[1]], z=data['z'][:shape[1]])

    @staticmethod
    def __settooltips(fig, theme):
        tooltips = theme.tooltips
        hover = fig.select(DpxHoverTool)

        if tooltips is None or len(tooltips) == 0:
            if len(hover):
                hover[0].tooltips = None

        elif len(hover):
            name = theme.raw.glyph
            rend = [
                i for i in fig.renderers if hasattr(i, 'glyph')
                and type(i.glyph).__name__.lower() == name
            ][0]
            hover[0].tooltips = tooltips
            hover[0].renderers = [rend]
            rend.selection_glyph = None
            rend.nonselection_glyph = None
            rend.glyph.radius_dimension = 'x'
            rend.glyph.radius = theme.radius

    def __settap(self, mdl, fig, source, theme):
        tap = fig.select(TapTool)
        if tap is not None and len(tap):
            src = ColumnDataSource(self._createrawdata(source.data,
                                                       self.shape))
            sel = themed(mdl, theme.selection)
            glyph = PlotAttrsView(sel).addto(fig, x='t', y='z', source=src)
            args = dict(hvr=self, hvrsrc=src, rawsrc=source, glyph=glyph)
            code = "hvr.launch_hover(rawsrc, hvrsrc, glyph)"
            self.rawrend = glyph
            source.callback = CustomJS(code=code, args=args)

    def createraw(self, mdl, fig, source, shape, theme):  # pylint: disable=too-many-arguments
        "creates the hover tool"
        self.shape = tuple(shape)
        self.__settooltips(fig, theme)
        self.__settap(mdl, fig, source, theme)

    def slaveaxes(self, fig, src):
        "slaves a histogram's axes to its y-axis"
        fig.y_range.callback = CustomJS(
            code="hvr.on_change_hist_bounds(fig, src)",
            args=dict(hvr=self, fig=fig, src=src))

    def resetraw(self, fig, rdata, shape, resets):
        "updates the tooltips for a new file"
        hover = fig.select(DpxHoverTool)
        if len(hover) == 0:
            return

        resets[self]['shape'] = shape
        if self.rawrend is not None:
            resets[self.rawrend]['visible'] = False
            resets[self.rawrend.data_source]['data'] = self._createrawdata(
                rdata, shape)