def fetch_data(a):
    (bwpath, binsize, chromsizes, aggregation_mode, range_mode, cid, start, end) = a
    n_bins = int(np.ceil(((end - start) / binsize)))
    n_dim = 1
    if (range_mode == 'minMax'):
        n_dim = 2
    if (range_mode == 'whisker'):
        n_dim = 4
    x = (np.zeros((n_bins, n_dim)) if (n_dim > 1) else np.zeros(n_bins))
    try:
        chrom = chromsizes.index[cid]
        clen = chromsizes.values[cid]
        args = [bwpath, chrom, start, end]
        kwargs = {'bins': n_bins, 'missing': np.nan}
        if (range_mode == 'minMax'):
            x[:, 0] = bbi.fetch(*args, **dict(kwargs, summary='min'))
            x[:, 1] = bbi.fetch(*args, **dict(kwargs, summary='max'))
        elif (range_mode == 'whisker'):
            x[:, 0] = bbi.fetch(*args, **dict(kwargs, summary='min'))
            x[:, 1] = bbi.fetch(*args, **dict(kwargs, summary='max'))
            x[:, 2] = bbi.fetch(*args, **dict(kwargs, summary='mean'))
            x[:, 3] = bbi.fetch(*args, **dict(kwargs, summary='std'))
        else:
            x[:] = bbi.fetch(*args, **dict(kwargs, summary=aggregation_mode))
        if ((end == clen) and ((clen % binsize) != 0)):
            x = x[:(- 1)]
    except IndexError:
        x[:] = np.nan
    except KeyError:
        x[:] = np.nan
    return x
def fetch_data(a):
    (bwpath, binsize, chromsizes, aggregation_mode, range_mode, cid, start, end) = a
    n_bins = int(np.ceil(((end - start) / binsize)))
    n_dim = 1
    if (range_mode == 'minMax'):
        n_dim = 2
    if (range_mode == 'whisker'):
        n_dim = 4
    x = (np.zeros((n_bins, n_dim)) if (n_dim > 1) else np.zeros(n_bins))
    try:
        chrom = chromsizes.index[cid]
        clen = chromsizes.values[cid]
        args = [bwpath, chrom, start, end]
        kwargs = {'bins': n_bins, 'missing': np.nan}
        if (range_mode == 'minMax'):
            x[:, 0] = bbi.fetch(*args, **dict(kwargs, summary='min'))
            x[:, 1] = bbi.fetch(*args, **dict(kwargs, summary='max'))
        elif (range_mode == 'whisker'):
            x[:, 0] = bbi.fetch(*args, **dict(kwargs, summary='min'))
            x[:, 1] = bbi.fetch(*args, **dict(kwargs, summary='max'))
            x[:, 2] = bbi.fetch(*args, **dict(kwargs, summary='mean'))
            x[:, 3] = bbi.fetch(*args, **dict(kwargs, summary='std'))
        else:
            x[:] = bbi.fetch(*args, **dict(kwargs, summary=aggregation_mode))
        if ((end == clen) and ((clen % binsize) != 0)):
            x = x[:(- 1)]
    except IndexError:
        x[:] = np.nan
    except KeyError:
        x[:] = np.nan
    return x