higlass
Version:
HiGlass Hi-C / genomic / large data viewer
152 lines (151 loc) • 6.77 kB
TypeScript
/** @implements {AbstractDataFetcher<Tile | DividedTile, ResolvedDataConfig>} */
export default class DataFetcher implements AbstractDataFetcher {
/**
* @param {DataConfig} dataConfig
* @param {PubSub} pubSub
* @param {TileSource<Tile>} [tileSource]
*/
constructor(dataConfig: DataConfig, pubSub: PubSub, tileSource?: TileSource<Tile>);
_tileSource: TileSource<Tile>;
/** @type {boolean} */
tilesetInfoLoading: boolean;
/** @type {ResolvedDataConfig} */
dataConfig: ResolvedDataConfig;
/** @type {string} */
uuid: string;
/** @type {PubSub} */
pubSub: PubSub;
/**
* We don't a have a tilesetUid for this track. But we do have a url, filetype
* and server. Using these, we can use the server to fullfill tile requests
* from this dataset.
*
* @param {object} opts
* @param {string} opts.server - The server api location (e.g. 'localhost:8000/api/v1')
* @param {string} opts.url - The location of the data file (e.g. 'encode.org/my.file.bigwig')
* @param {string} opts.filetype - The type of file being served (e.g. 'bigwig')
* @param {string=} opts.coordSystem - The coordinate system being served (e.g. 'hg38')
*/
registerFileUrl({ server, url, filetype, coordSystem }: {
server: string;
url: string;
filetype: string;
coordSystem?: string | undefined;
}): Promise<Response>;
/**
* Obtain tileset infos for all of the tilesets listed
* @param {HandleTilesetInfoFinished} finished - A callback that will be called
*/
tilesetInfo(finished: HandleTilesetInfoFinished): Promise<any>;
/**
* Obtain tileset infos for all of the tilesets listed
*
* If there is more than one tileset info, this function
* should (not currently implemented) check if the tileset
* infos have the same dimensions and then return a common
* one.
*
* @param {HandleTilesetInfoFinished} finished - A callback that will be called
* when all tileset infos are loaded
*/
tilesetInfoAfterRegister(finished: HandleTilesetInfoFinished): void;
/**
* @param {string} tilesetUid - Uid of the tileset on the server
* @param {string} tileId - The tileId of the tile
* @returns {string} The full tile id that the server will parse.
*
* @example
* ```javascript
* // returns 'xyxx.0.0.0'
* fullTileId('xyxx', '0.0.0');
* ```
*/
fullTileId(tilesetUid: string, tileId: string): string;
/**
* Fetch a set of tiles.
*
* Because the track shouldn't care about tileset ids, the tile ids
* should just include positions and any necessary transforms.
*
* @param {(tiles: Record<string, DividedTile | Tile>) => void} receivedTiles - A function to call once the tiles have been fetched
* @param {string[]} tileIds - The tile ids to fetch
* @returns {Promise<Record<string, DividedTile | Tile>>}
*/
fetchTilesDebounced(receivedTiles: (tiles: Record<string, DividedTile | Tile>) => void, tileIds: string[]): Promise<Record<string, DividedTile | Tile>>;
/**
* Return an array consisting of the division of the numerator
* array by the denominator array
*
* @param {ArrayLike<number>} numeratorData - An array of numerical values
* @param {ArrayLike<number>} denominatorData - An array of numerical values
*
* @returns {Float32Array} An array consisting of the division of the numerator by the denominator
*/
divideData(numeratorData: ArrayLike<number>, denominatorData: ArrayLike<number>): Float32Array;
horizontalSlice(): null;
/**
* Extract a slice from a matrix at a given position.
*
* @param {Array<number> | Float32Array} inputData - An array containing a matrix stored row-wise
* @param {Array<number>} arrayShape - The shape of the array, should be a
* two element array e.g. [256,256].
* @param {number} sliceIndex - The index across which to take the slice
* @param {number=} axis - The axis along which to take the slice
* @returns {Array<number> | Float32Array} an array corresponding to a slice of this matrix
*/
extractDataSlice(inputData: Array<number> | Float32Array, arrayShape: Array<number>, sliceIndex: number, axis?: number | undefined): Array<number> | Float32Array;
/**
* Fetch a horizontal section of a 2D dataset
* @param {(tiles: Record<string, Tile>) => void} receivedTiles - A function to call once the tiles have been fetched
* @param {string[]} tileIds - The tile ids to fetch
* @param {boolean=} vertical - Whether to fetch a vertical section
* @returns {Promise<Record<string, Tile>>}
*/
fetchHorizontalSection(receivedTiles: (tiles: Record<string, Tile>) => void, tileIds: string[], vertical?: boolean | undefined): Promise<Record<string, Tile>>;
/**
* @typedef {{ zoomLevel: number, tilePos: number[], dense?: ArrayLike<number> }} Dividable
* @param {[Record<string, Dividable>, Record<string, Dividable>]} returnedTiles
* @param {string[]} tileIds
* @returns {Record<string, DividedTile>}
*/
makeDivided(returnedTiles: [Record<string, {
zoomLevel: number;
tilePos: number[];
dense?: ArrayLike<number>;
}>, Record<string, {
zoomLevel: number;
tilePos: number[];
dense?: ArrayLike<number>;
}>], tileIds: string[]): Record<string, DividedTile>;
}
export type Tile = {
min_value: number;
max_value: number;
denseDataExtrema: DenseDataExtrema1D | DenseDataExtrema2D;
minNonZero: number;
maxNonZero: number;
dense: Array<number> | Float32Array;
dtype: string;
server: string;
tilePos: number[];
tilePositionId: string;
tilesetUid: string;
zoomLevel: number;
};
export type DividedTileA = Pick<Tile, "zoomLevel" | "tilePos" | "tilePositionId">;
export type DividedTileB = Pick<Tile, "zoomLevel" | "tilePos" | "tilePositionId" | "dense" | "denseDataExtrema" | "minNonZero" | "maxNonZero">;
export type DividedTile = DividedTileA | DividedTileB;
export type ResolvedDataConfig = Omit<DataConfig, "children"> & {
children?: DataFetcher[];
tilesetUid?: string;
tilesetInfo: TilesetInfo;
};
import type { AbstractDataFetcher } from '../types';
import type { TileSource } from '../types';
import type { PubSub } from 'pub-sub-es';
import type { HandleTilesetInfoFinished } from '../types';
import type { DataConfig } from '../types';
import DenseDataExtrema1D from '../utils/DenseDataExtrema1D';
import DenseDataExtrema2D from '../utils/DenseDataExtrema2D';
import type { DataConfig as DataConfig_1 } from '../types';
import type { TilesetInfo } from '../types';