view x/static/js/937.4f610bdf.chunk.js.map @ 125:49f3d3878413 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5ea1f9c1eef1de76232e69aa6d34cda77d90d566
author fubar
date Sat, 05 Oct 2024 23:58:05 +0000
parents
children
line wrap: on
line source

{"version":3,"file":"static/js/937.4f610bdf.chunk.js","mappings":"4OA0CA,MAAMA,EACJC,WAAAA,CAAoBC,GAA+B,KAA/BA,WAAAA,CAAgC,CAEpD,UAAMC,CAAKC,EAAkBC,GAC3B,MAAM,OAAEC,SAAiBC,KAAKL,WAAWC,KACvCK,EAAAA,GAAOC,MAAMJ,GACb,EACAA,EACAD,GAEF,OAAOE,EAAOA,OAAOI,MACnBJ,EAAOK,WACPL,EAAOK,WAAaL,EAAOM,WAE/B,EAEK,SAASC,EACdC,EACAC,GAEA,OAAO,IAAIf,GAAyBgB,EAAAA,EAAAA,cAAaF,EAAUC,GAC7D,CAae,MAAME,UAAmBC,EAAAA,uBAG/BjB,WAAAA,CACLkB,EACAC,EACAL,GAEAM,MAAMF,EAAQC,EAAeL,GAC7B,MAAMO,EAAcf,KAAKgB,QAAQ,eACjChB,KAAKiB,IAAM,IAAIC,EAAAA,EAAS,CACtBC,KAAMb,EAAsBS,EAAaf,KAAKQ,gBAElD,CAEA,WAAcY,CAAMC,GAClB,MAAM,eAAEC,EAAiBA,QAAaD,GAAQ,CAAC,EAC/CC,EAAe,2BACf,MAAMC,QAAevB,KAAKiB,IAAIO,cAE9B,OADAF,EAAe,IACRC,CACT,CAEA,eAAaE,CAAUJ,GACrB,MAAMK,QAAY1B,KAAKoB,MAAMC,IACvB,YAAEM,KAAgBC,GAASF,EACjC,OAAOE,CACT,CAEA,iBAAMC,CAAYR,GAEhB,aADuBrB,KAAKoB,MAAMC,IAClBM,YAAYG,KAAIC,GAAOA,EAAIC,MAC7C,CAEA,mBAAMC,CAAcC,EAAiBb,GACnC,MAAM,YAAEc,SAAsBnC,KAAKoB,MAAMC,GAEzC,IAAIe,EAAmBD,EAAYE,IAAI,GAEvC,IAAK,IAAIC,EAAIH,EAAYrC,OAAS,EAAGwC,GAAK,EAAGA,GAAK,EAAG,CACnD,MAAMC,EAAIJ,EAAYG,GAClBC,GAAK,EAAIL,IACXE,EAAmBG,EAEvB,CACA,OAAOH,CACT,CAEAI,WAAAA,CAAYC,EAAgBpB,EAAmB,CAAC,GAC9C,OAAOqB,EAAAA,EAAAA,mBAAgCC,UACrC,MAAQC,QAASb,EAAG,MAAEc,EAAK,IAAEC,GAAQL,GAC/B,WAAEM,EAAU,QAAEb,EAAU,EAAC,eAAEZ,EAAiBA,QAAaD,EACzD2B,QAAYhD,KAAKiC,cAAcC,GAAWa,GAAc,KAAO1B,GACrEC,EAAe,yBAEf,MAAM2B,QAAgBjD,KAAKiB,IAAIiC,kBAC7B,KACA,CAAEL,QAAOd,MAAKe,OACd,CAAED,QAAOd,MAAKe,OACd,KACAE,GAEF,IAAK,MAAMG,KAAUF,EACnBG,EAASC,KAAKF,GAEhB7B,EAAe,IACf8B,EAASE,UAAU,GAClBjC,EAAKkC,OACV,CAGA,uCAAMC,CAAkCC,GACtC,MAAO,CAAEC,eAAgB,EAC3B,CAEAC,aAAAA,GAAuC,E","sources":["../../../plugins/hic/src/HicAdapter/HicAdapter.ts"],"sourcesContent":["import {\n  BaseFeatureDataAdapter,\n  BaseOptions,\n} from '@jbrowse/core/data_adapters/BaseAdapter'\nimport { Region, FileLocation } from '@jbrowse/core/util/types'\nimport { ObservableCreate } from '@jbrowse/core/util/rxjs'\nimport { openLocation } from '@jbrowse/core/util/io'\nimport type { GenericFilehandle } from 'generic-filehandle'\nimport HicStraw from 'hic-straw'\nimport PluginManager from '@jbrowse/core/PluginManager'\nimport { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'\nimport { AnyConfigurationModel } from '@jbrowse/core/configuration'\nimport { Buffer } from 'buffer'\n\ninterface ContactRecord {\n  bin1: number\n  bin2: number\n  counts: number\n}\n\ninterface HicMetadata {\n  chromosomes: {\n    name: string\n    length: number\n    id: number\n  }[]\n  resolutions: number[]\n}\ninterface Ref {\n  chr: string\n  start: number\n  end: number\n}\n\ninterface HicOptions extends BaseOptions {\n  resolution?: number\n  bpPerPx?: number\n}\n\n// wraps generic-filehandle so the read function only takes a position and\n// length in some ways, generic-filehandle wishes it was just this but it has\n// to adapt to the node.js fs promises API\nclass GenericFilehandleWrapper {\n  constructor(private filehandle: GenericFilehandle) {}\n\n  async read(position: number, length: number) {\n    const { buffer } = await this.filehandle.read(\n      Buffer.alloc(length),\n      0,\n      length,\n      position,\n    )\n    return buffer.buffer.slice(\n      buffer.byteOffset,\n      buffer.byteOffset + buffer.byteLength,\n    )\n  }\n}\nexport function openFilehandleWrapper(\n  location: FileLocation,\n  pluginManager?: PluginManager,\n) {\n  return new GenericFilehandleWrapper(openLocation(location, pluginManager))\n}\n\ninterface HicParser {\n  getContactRecords: (\n    normalize: string,\n    ref: Ref,\n    ref2: Ref,\n    units: string,\n    binsize: number,\n  ) => Promise<ContactRecord[]>\n  getMetaData: () => Promise<HicMetadata>\n}\n\nexport default class HicAdapter extends BaseFeatureDataAdapter {\n  private hic: HicParser\n\n  public constructor(\n    config: AnyConfigurationModel,\n    getSubAdapter?: getSubAdapterType,\n    pluginManager?: PluginManager,\n  ) {\n    super(config, getSubAdapter, pluginManager)\n    const hicLocation = this.getConf('hicLocation')\n    this.hic = new HicStraw({\n      file: openFilehandleWrapper(hicLocation, this.pluginManager),\n    })\n  }\n\n  private async setup(opts?: BaseOptions) {\n    const { statusCallback = () => {} } = opts || {}\n    statusCallback('Downloading .hic header')\n    const result = await this.hic.getMetaData()\n    statusCallback('')\n    return result\n  }\n\n  public async getHeader(opts?: BaseOptions) {\n    const ret = await this.setup(opts)\n    const { chromosomes, ...rest } = ret\n    return rest\n  }\n\n  async getRefNames(opts?: BaseOptions) {\n    const metadata = await this.setup(opts)\n    return metadata.chromosomes.map(chr => chr.name)\n  }\n\n  async getResolution(bpPerPx: number, opts?: BaseOptions) {\n    const { resolutions } = await this.setup(opts)\n\n    let chosenResolution = resolutions.at(-1)!\n\n    for (let i = resolutions.length - 1; i >= 0; i -= 1) {\n      const r = resolutions[i]!\n      if (r <= 2 * bpPerPx) {\n        chosenResolution = r\n      }\n    }\n    return chosenResolution\n  }\n\n  getFeatures(region: Region, opts: HicOptions = {}) {\n    return ObservableCreate<ContactRecord>(async observer => {\n      const { refName: chr, start, end } = region\n      const { resolution, bpPerPx = 1, statusCallback = () => {} } = opts\n      const res = await this.getResolution(bpPerPx / (resolution || 1000), opts)\n      statusCallback('Downloading .hic data')\n\n      const records = await this.hic.getContactRecords(\n        'KR',\n        { start, chr, end },\n        { start, chr, end },\n        'BP',\n        res,\n      )\n      for (const record of records) {\n        observer.next(record)\n      }\n      statusCallback('')\n      observer.complete()\n    }, opts.signal) as any\n  }\n\n  // don't do feature stats estimation, similar to bigwigadapter\n  async getMultiRegionFeatureDensityStats(_regions: Region[]) {\n    return { featureDensity: 0 }\n  }\n\n  freeResources(/* { region } */): void {}\n}\n"],"names":["GenericFilehandleWrapper","constructor","filehandle","read","position","length","buffer","this","Buffer","alloc","slice","byteOffset","byteLength","openFilehandleWrapper","location","pluginManager","openLocation","HicAdapter","BaseFeatureDataAdapter","config","getSubAdapter","super","hicLocation","getConf","hic","HicStraw","file","setup","opts","statusCallback","result","getMetaData","getHeader","ret","chromosomes","rest","getRefNames","map","chr","name","getResolution","bpPerPx","resolutions","chosenResolution","at","i","r","getFeatures","region","ObservableCreate","async","refName","start","end","resolution","res","records","getContactRecords","record","observer","next","complete","signal","getMultiRegionFeatureDensityStats","_regions","featureDensity","freeResources"],"sourceRoot":""}