UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

46 lines (45 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDisplayStr = getDisplayStr; exports.getId = getId; exports.getFeatureDensityStatsPre = getFeatureDensityStatsPre; const util_1 = require("@jbrowse/core/util"); const tracks_1 = require("@jbrowse/core/util/tracks"); const mobx_state_tree_1 = require("mobx-state-tree"); function getDisplayStr(totalBytes) { if (Math.floor(totalBytes / 1000000) > 0) { return `${Number.parseFloat((totalBytes / 1000000).toPrecision(3))} Mb`; } else if (Math.floor(totalBytes / 1000) > 0) { return `${Number.parseFloat((totalBytes / 1000).toPrecision(3))} Kb`; } else { return `${Math.floor(totalBytes)} bytes`; } } function getId(id, index) { const notJest = typeof jest === 'undefined'; return ['clip', notJest ? id : 'jest', index, notJest ? Math.random() : ''] .filter(f => !!f) .join('-'); } async function getFeatureDensityStatsPre(self) { const view = (0, util_1.getContainingView)(self); const regions = view.staticBlocks.contentBlocks; const { rpcManager } = (0, util_1.getSession)(self); const { adapterConfig } = self; if (!adapterConfig) { return {}; } const sessionId = (0, tracks_1.getRpcSessionId)(self); return rpcManager.call(sessionId, 'CoreGetFeatureDensityStats', { sessionId, regions, adapterConfig, statusCallback: (message) => { if ((0, mobx_state_tree_1.isAlive)(self)) { self.setMessage(message); } }, }); }