diff --git a/clodius/tiles/bigwig.py b/clodius/tiles/bigwig.py index 4d74bdd6..333263eb 100644 --- a/clodius/tiles/bigwig.py +++ b/clodius/tiles/bigwig.py @@ -65,7 +65,8 @@ def natcmp(x, y): [int(a) if a.isdigit() else a for a in _NS_REGEX.split(y) if a] ) - # order of these parameters is purposefully reverse how they should be ordered + # order of these parameters is purposefully reverse how they should be + # ordered for key in ['m', 'y', 'x']: if key in y.lower(): return -1 @@ -230,7 +231,6 @@ def get_bigwig_tile( aggregation_mode='mean', range_mode=None ): - if chromsizes is None: chromsizes = get_chromsizes(bwpath) diff --git a/test/tiles/bigwig_test.py b/test/tiles/bigwig_test.py index ed275812..80444b1f 100644 --- a/test/tiles/bigwig_test.py +++ b/test/tiles/bigwig_test.py @@ -54,6 +54,45 @@ def test_bigwig_tiles(): dtype=min_max_tile[0][1]['dtype'] ) + mean_tile = hgbi.tiles(filename, ['x.0.0']) + mean_mean_tile = hgbi.tiles(filename, ['x.0.0.mean']) + min_tile = hgbi.tiles(filename, ['x.0.0.min']) + max_tile = hgbi.tiles(filename, ['x.0.0.max']) + std_tile = hgbi.tiles(filename, ['x.0.0.std']) + + assert mean_tile[0][1]['max_value'] == mean_mean_tile[0][1]['max_value'] + assert mean_tile[0][1]['max_value'] > min_tile[0][1]['max_value'] + assert max_tile[0][1]['max_value'] > mean_tile[0][1]['max_value'] + assert max_tile[0][1]['max_value'] > mean_tile[0][1]['max_value'] + std_tile[0][1]['max_value'] + + min_max_tile = hgbi.tiles(filename, ['x.0.0.minMax']) + whisker_tile = hgbi.tiles(filename, ['x.0.0.whisker']) + + mean_val = np.frombuffer( + base64.b64decode(mean_tile[0][1]['dense']), + dtype=mean_tile[0][1]['dtype'] + ) + + min_val = np.frombuffer( + base64.b64decode(min_tile[0][1]['dense']), + dtype=min_tile[0][1]['dtype'] + ) + + max_val = np.frombuffer( + base64.b64decode(max_tile[0][1]['dense']), + dtype=max_tile[0][1]['dtype'] + ) + + std_val = np.frombuffer( + base64.b64decode(std_tile[0][1]['dense']), + dtype=std_tile[0][1]['dtype'] + ) + + min_max_val = np.frombuffer( + base64.b64decode(min_max_tile[0][1]['dense']), + dtype=min_max_tile[0][1]['dtype'] + ) + whisker_val = np.frombuffer( base64.b64decode(whisker_tile[0][1]['dense']), dtype=whisker_tile[0][1]['dtype']