diff --git a/CHANGELOG.md b/CHANGELOG.md index e3e2a81b48..90e053108c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -272,7 +272,7 @@ yarn run v1.22.22 $ lerna-changelog --silent --silent --next-version 2.13.1 track selector in linear synteny view causing crash in v2.13.0 ([@cmdcolin](https://github.com/cmdcolin)) - [#4495](https://github.com/GMOD/jbrowse-components/pull/4495) Fix log scale - for some types of stopToken tracks ([@cmdcolin](https://github.com/cmdcolin)) + for some types of signal tracks ([@cmdcolin](https://github.com/cmdcolin)) #### Committers: 1 @@ -6437,7 +6437,7 @@ Broken releases missing some packages rendering outside it's allowed bounds ([@cmdcolin](https://github.com/cmdcolin)) - [#1783](https://github.com/GMOD/jbrowse-components/pull/1783) Add hic - aborting and fix remoteAbort stopToken propagation + aborting and fix remoteAbort signal propagation ([@cmdcolin](https://github.com/cmdcolin)) - [#1723](https://github.com/GMOD/jbrowse-components/pull/1723) A few bugfixes ([@garrettjstevens](https://github.com/garrettjstevens)) diff --git a/packages/core/assemblyManager/assembly.ts b/packages/core/assemblyManager/assembly.ts index b070d9f310..a4e987d43a 100644 --- a/packages/core/assemblyManager/assembly.ts +++ b/packages/core/assemblyManager/assembly.ts @@ -62,7 +62,6 @@ async function loadRefNameMap( ) { const { sessionId } = options await when(() => !!(assembly.regions && assembly.refNameAliases), { - stopToken, name: 'when assembly ready', }) @@ -157,11 +156,29 @@ export default function assemblyFactory( configuration: types.safeReference(assemblyConfigType), }) .volatile(() => ({ + /** + * #volatile + */ error: undefined as unknown, + /** + * #volatile + */ loadingP: undefined as Promise | undefined, + /** + * #volatile + */ volatileRegions: undefined as BasicRegion[] | undefined, + /** + * #volatile + */ refNameAliases: undefined as RefNameAliases | undefined, + /** + * #volatile + */ lowerCaseRefNameAliases: undefined as RefNameAliases | undefined, + /** + * #volatile + */ cytobands: undefined as Feature[] | undefined, })) .views(self => ({ @@ -175,6 +192,8 @@ export default function assemblyFactory( .views(self => ({ /** * #getter + * this is a getter with a side effect of loading the data. not the best + * practice, but it helps to lazy load the assembly */ get initialized() { // @ts-expect-error @@ -212,7 +231,7 @@ export default function assemblyFactory( return self.getConf('displayName') }, /** - * #getter + * #method */ hasName(name: string) { return this.allAliases.includes(name) diff --git a/packages/core/util/when.ts b/packages/core/util/when.ts index 8b3414012b..e7c01625db 100644 --- a/packages/core/util/when.ts +++ b/packages/core/util/when.ts @@ -1,85 +1 @@ -import { when as mobxWhen, IWhenOptions } from 'mobx' -import { checkStopToken } from './stopToken' - -interface WhenOpts extends IWhenOptions { - stopToken?: string -} - -/** - * Wrapper for mobx `when` that adds timeout and aborting support. - */ -export function when( - getter: () => boolean, - { timeout, stopToken, name }: WhenOpts = {}, -) { - return new Promise((resolve, reject) => { - let finished = false - - const whenPromise = mobxWhen(getter) - - // set up timeout - let timeoutId: ReturnType | undefined - let finishTimeout = () => {} - if (timeout) { - timeoutId = setTimeout(() => { - if (!finished) { - finished = true - whenPromise.cancel() - reject(new Error(`timed out waiting for ${name || 'whenPresent'}`)) - } - }, timeout) - finishTimeout = () => { - if (timeoutId) { - clearTimeout(timeoutId) - } - } - } - - // set up aborting - if (stopToken !== undefined) { - try { - checkStopToken(stopToken) - } catch (e) { - finished = true - whenPromise.cancel() - finishTimeout() - reject(new Error('aborted')) - } - } - - whenPromise - .then(() => { - if (!finished) { - finished = true - finishTimeout() - - resolve(true) - } - }) - .catch((err: unknown) => { - if (!finished) { - finished = true - finishTimeout() - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors - reject(err) - } - }) - }) -} - -/** - * Wrapper for mobx `when` that makes a promise for the return value - * of the given function at the point in time when it becomes not - * undefined and not null. - */ -export async function whenPresent unknown>( - getter: FUNCTION, - opts: WhenOpts = {}, -): Promise>> { - await when(() => { - const val = getter() - return val !== undefined && val !== null - }, opts) - - return getter() as NonNullable> -} +export { when } from 'mobx' diff --git a/plugins/bed/src/generateBedMethylFeature.ts b/plugins/bed/src/generateBedMethylFeature.ts index 960e0abad3..db7faec2c9 100644 --- a/plugins/bed/src/generateBedMethylFeature.ts +++ b/plugins/bed/src/generateBedMethylFeature.ts @@ -44,13 +44,14 @@ export function generateBedMethylFeature({ n_diff, n_nocall, ] = line.split('\t') + return { uniqueId, refName, start, end, code, - score: fraction_modified, + score: +fraction_modified! || 0, strand, color, source: code, diff --git a/plugins/wiggle/src/getMultiWiggleSourcesAutorun.ts b/plugins/wiggle/src/getMultiWiggleSourcesAutorun.ts index b07f1ac19b..c0f0417dae 100644 --- a/plugins/wiggle/src/getMultiWiggleSourcesAutorun.ts +++ b/plugins/wiggle/src/getMultiWiggleSourcesAutorun.ts @@ -1,14 +1,11 @@ import { autorun } from 'mobx' import { addDisposer, isAlive } from 'mobx-state-tree' // jbrowse -import { - getContainingView, - getSession, - isAbortException, -} from '@jbrowse/core/util' +import { getContainingView, getSession } from '@jbrowse/core/util' import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view' import { AnyConfigurationModel } from '@jbrowse/core/configuration' import { getRpcSessionId } from '@jbrowse/core/util/tracks' +import { isAbortException } from '@jbrowse/core/util/aborting' export interface Source { name: string @@ -51,8 +48,8 @@ export function getMultiWiggleSourcesAutorun(self: { self.setSources(sources) } } catch (e) { + console.error(e) if (!isAbortException(e) && isAlive(self)) { - console.error(e) getSession(self).notifyError(`${e}`, e) } } diff --git a/test_data/hs1/config.json b/test_data/hs1/config.json index 2ee6df7c37..d3ea117d3b 100644 --- a/test_data/hs1/config.json +++ b/test_data/hs1/config.json @@ -57,6 +57,19 @@ } }, "assemblyNames": ["hs1"] + }, + { + "type": "FeatureTrack", + "trackId": "chm13v2.0_rmsk", + "name": "chm13v2.0_rmsk", + "adapter": { + "type": "BigBedAdapter", + "bigBedLocation": { + "uri": "https://hgdownload.soe.ucsc.edu/gbdb/hs1/t2tRepeatMasker/chm13v2.0_rmsk.bb", + "locationType": "UriLocation" + } + }, + "assemblyNames": ["hs1"] } ] }