import NCListStore from '@gmod/nclist' ; import { Region } from '@jbrowse/core/util/types' ; import { BaseFeatureDataAdapter , BaseOptions , } from '@jbrowse/core/data_adapters/BaseAdapter' ; import { Feature } from '@jbrowse/core/util/simpleFeature' ; import { ObservableCreate } from '@jbrowse/core/util/rxjs' ; import { checkAbortSignal } from '@jbrowse/core/util' ; import { RemoteFile } from 'generic-filehandle' ; import { Instance } from 'mobx-state-tree' ; import { readConfObject } from '@jbrowse/core/configuration' ; import NCListFeature from './NCListFeature' ; import MyConfigSchema from './configSchema' ; import PluginManager from '@jbrowse/core/PluginManager' ; import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache' ; export default class NCListAdapter extends BaseFeatureDataAdapter { private nclist : any ; private configRefNames ? : string [ ] ; constructor ( config , getSubAdapter ? , pluginManager ? ) { super ( config , getSubAdapter , pluginManager ) ; const refNames = readConfObject ( config , 'refNames' ) ; const rootUrlTemplate = readConfObject ( config , 'rootUrlTemplate' ) ; this . configRefNames = refNames ; this . nclist = new NCListStore ( { baseUrl : '' , urlTemplate : rootUrlTemplate . uri , readFile : ( url ) => new RemoteFile ( String ( rootUrlTemplate . baseUri ? new URL ( url , rootUrlTemplate . baseUri ) . toString ( ) : url ) ) . readFile ( ) , } ) ; } param region param opts returns getFeatures ( region , opts = { } ) { return ObservableCreate < Feature > ( async ( observer ) => { const { signal } = opts ; for await ( const feature of this . nclist . getFeatures ( region , opts ) ) { checkAbortSignal ( signal ) ; observer . next ( this . wrapFeature ( feature ) ) ; } observer . complete ( ) ; } ) ; } wrapFeature ( ncFeature ) { return new NCListFeature ( ncFeature , undefined , `${ this . id }-${ ncFeature . id ( ) }` ) ; } async hasDataForRefName ( refName ) { const root = await this . nclist . getDataRoot ( refName ) ; return ! ! ( root && root . stats && root . stats . featureCount ) ; } getRefNames ( ) { return Promise . resolve ( this . configRefNames || [ ] ) ; } /**
     * called to provide a hint that data tied to a certain region
     * will not be needed for the forseeable future and can be purged
     * from caches, etc
     */ freeResources ( ) { } }