def test_statsplot_info_binned(diskcaching): "test the view" fov, mdl = _Fig.create(withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.__dict__.update(xinfo=[AxisConfig("binnedz")], yaxis="distance") cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) _check_validity(cache, "Δ(closest binding - blockage) (bp)") vals = [float(i[0]) for i in cache['x_range']['factors']] assert_allclose(vals, np.round(vals, 2)) assert_allclose(np.diff(vals), np.round(np.diff(vals), 1)) assert .001 <= vals[0] <= .1 mdl.theme.__dict__.update(xinfo=[AxisConfig("binnedbp")], yaxis="distance") cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) _check_validity(cache, "Δ(closest binding - blockage) (bp)") assert all(i[0].endswith(".0") for i in cache['x_range']['factors']) vals = [float(i[0]) for i in cache['x_range']['factors']] assert_allclose(vals, np.round(vals)) assert_allclose(np.diff(vals), np.round(np.diff(vals))) assert 20 <= vals[0] <= 50 fov._fig.__dict__['x_range'] = Range1d() mdl.theme.linear = True cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) assert fov._fig.x_range in cache assert 'start' in cache[fov._fig.x_range] assert cache[_Fig.renderers[0].glyph]['width'] == 5.
def test_statsplot_info_reftrack(diskcaching): "test the view" fov, mdl = _Fig.create(beads=list(range(5)), withhp=True) _Fig.newtasks(mdl, beads=list(range(5, 10)), withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.xinfo = [AxisConfig('track')] mdl.theme.yaxis = 'hybridisationrate' cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) data = cache['_stats']['data'] assert list(data['x']) == [('track 0', '', ''), ('track 1', '', '')] mdl.display.reference = next(iter(mdl.tasks.roots)) cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) data2 = cache['_stats']['data'] assert np.isnan(data2['boxcenter']) == 1 assert len(data2['boxcenter']) == 1 assert list(data2['x']) == [('', '', '')] fov, mdl = _Fig.create(beads=list(range(5)), withhp=True) _Fig.newtasks(mdl, beads=list(range(1, 6)), withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.yaxis = 'hybridisationrate' cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) data = cache['_stats']['data'] assert list(data['x']) == [('track 0', '', ''), ('track 1', '', '')] beads = BeadsScatterPlotModel() wdg1 = PeakcallingPlotModel(beads, mdl) assert wdg1.reftrack == 0 mdl.display.reference = next(iter(mdl.tasks.roots)) wdg2 = PeakcallingPlotModel(beads, mdl) assert wdg2.reftrack == 1 assert wdg2.diff(PeakcallingPlotModel(beads, mdl), mdl) == dict(theme={}, display={}) assert wdg2.diff(wdg1, mdl) == dict(theme={}, display=dict(reference=None)) assert wdg1.diff(wdg2, mdl) == dict( theme={}, display=dict(reference=next(iter(mdl.tasks.roots)))) cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) data2 = cache['_stats']['data'] assert_allclose(data2['boxcenter'], [0.]) assert list(data2['x']) == [('', '', '')]
def test_statsplot_info_filter(diskcaching): "test the view" beads, mdl = _Fig.create(beads=[1, 7, 14, 33, 12], withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.__dict__.update( xinfo=[AxisConfig("hairpin"), AxisConfig("closest")], yaxis="fnperbp") cache = dict(_HairpinPlot(beads, mdl.tasks.processors)._reset()) assert cache['x_range']['factors'] == list( zip(repeat('GF1'), repeat(""), ['157.0', '258.0', '393.0', '503.0', '704.0', '795.0'])) mdl.display.ranges[('peaks', 'baseposition')] = Slice(200, 400) cache = dict(_HairpinPlot(beads, mdl.tasks.processors)._reset()) assert cache['x_range']['factors'] == list( zip(repeat('GF1'), repeat(""), ['258.0', '393.0']))
def test_statsplot_info_zmum_vsbp(diskcaching): "test the view" fov, mdl = _Fig.create(withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.__dict__.update( xinfo=[AxisConfig("closest"), AxisConfig("binnedz")], yaxis="baseposition") cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) _check_validity(cache, "z (bp)") assert np.abs(cache[_Fig.y_range]['max_interval'] - 1531) < 5
def test_statsplot_info_hpins1(diskcaching): "test the view" fov, mdl = _Fig.create(withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.__dict__.update(xinfo=[AxisConfig("status")], yaxis="averageduration") cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) _check_validity(cache, "binding duration (s)") assert cache['x_range']['factors'] == [ ('\u2063baseline', '', ''), ('\u2063\u2063identified', '', ''), ('\u2063\u2063\u2063\u2063unidentified', '', ''), ]
def test_statsplot_info_hpins3(diskcaching): "test the view" fov, mdl = _Fig.create(withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.__dict__.update(xinfo=[AxisConfig("closest")], yaxis="distance") cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) _check_validity(cache, "Δ(closest binding - blockage) (bp)") assert cache['x_range']['factors'] == list( zip( [ '38.0', '46.0', '151.0', '157.0', '222.0', '258.0', '274.0', '294.0', '347.0', '357.0', '379.0', '393.0', '503.0', '540.0', '569.0', '576.0', '659.0', '704.0', '738.0', '754.0', '784.0', '791.0', '795.0', '800.0' ], repeat(""), repeat(""), ))
def test_statsplot_info_fnperbp(diskcaching): "test the view" fov, mdl = _Fig.create(beads=[1, 7, 14, 33, 12], withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) mdl.theme.__dict__.update( xinfo=[AxisConfig("hairpin"), AxisConfig("closest")], yaxis="fnperbp") cache = dict(_HairpinPlot(fov, mdl.tasks.processors)._reset()) assert cache['x_range']['factors'] == list( zip(repeat('GF1'), repeat(""), ['157.0', '258.0', '393.0', '503.0', '704.0', '795.0'])) stats = cache['_stats']['data'] for i in ('bottom', 'top'): assert np.isnan(stats[i]).sum() == 0 assert np.all(stats['bottom'] <= stats['boxcenter']) assert np.all(stats['top'] >= stats['boxcenter'])
def test_statsplot_info_pkcount(diskcaching): "test the view" beads, mdl = _Fig.create(beads=[13, 3, 27], withhp=True) mdl.tasks.jobs.launch(list(mdl.tasks.processors.values())) for name in ('closest', 'exclusive'): mdl.theme.__dict__.update( xinfo=[AxisConfig("hairpin"), AxisConfig(name)], yaxis="bead") cache = dict(_HairpinPlot(beads, mdl.tasks.processors)._reset()) assert_allclose(cache['_stats']['data']['boxheight'], [100., *((200 / 3, ) * 3), *((100, ) * 3)]) assert cache['x_range']['factors'] == [('GF3', '', '46.0'), ('GF3', '', '274.0'), ('GF3', '', '357.0'), ('GF3', '', '576.0'), ('GF3', '', '659.0'), ('GF3', '', '754.0'), ('GF3', '', '784.0')]