@galaxyproject/igv 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/static/igv.xml +2 -2
- package/static/index.js +1 -1
package/package.json
CHANGED
package/static/igv.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<!DOCTYPE visualization SYSTEM "../../visualization.dtd">
|
|
3
|
-
<visualization name="IGV">
|
|
3
|
+
<visualization name="IGV" embeddable="true">
|
|
4
4
|
<description>Interactive Genome Visualization</description>
|
|
5
5
|
<data_sources>
|
|
6
6
|
<data_source>
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<params>
|
|
30
30
|
<param required="true">dataset_id</param>
|
|
31
31
|
</params>
|
|
32
|
-
<entry_point entry_point_type="script" src="
|
|
32
|
+
<entry_point entry_point_type="script" src="index.js" css="index.css" />
|
|
33
33
|
<settings>
|
|
34
34
|
<input>
|
|
35
35
|
<label>Genome</label>
|
package/static/index.js
CHANGED
|
@@ -2449,4 +2449,4 @@ ${c.map(p=>` ${p}`).join(`
|
|
|
2449
2449
|
`)}`);const d=a.filter(p=>p.file===void 0);let u=1;for(let p of d)p.order===void 0&&(p.order=u++);const f=d.filter(p=>p.hidden===!0);for(const p of f)await ji(p,this.genome).getFeatures({chr:"1",start:0,end:Number.MAX_SAFE_INTEGER});await this.loadTrackList(d)}cleanHouseForSession(){for(let t of this.trackViews)t.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-axis-column, .igv-column-shim, .igv-column, .igv-sample-info-column, .igv-sample-name-column, .igv-scrollbar-column, .igv-track-drag-column, .igv-gear-menu-column").forEach(t=>t.remove()),this.trackViews=[],this.circularView&&this.circularView.clearChords()}async loadReference(e,t){this.removeAllTracks(),this.roiManager.clearROIs(),this.navbar.setEnableTrackSelection(!1);let r;e.gbkURL?r=await I_(e.gbkURL):r=await Wm.createGenome(e,this);const n=this.genome===void 0||this.genome.id!==r.id;this.genome=r,this.navbar.updateGenome(r);let o=t||r.initialLocus;return Array.isArray(o)&&(o=o.join(" ")),await this.search(o,!0)||(console.error(`Cannot set initial locus ${o}`),o!==r.initialLocus&&await this.search(r.initialLocus)),n&&(this.fireEvent("genomechange",[{genome:r}]),this.circularView&&this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:pF(this.genome)})),r}async loadGenome(e){e.genarkAccession&&(e.url=R_(e.genarkAccession)),e.url&&(Yt(e.url)&&e.url.endsWith("/hub.txt")?(e.hubURL=e.url,delete e.url):OZ(e.url)==="gbk"&&(e.gbkURL=e.url,delete e.url));let t;e.hubURL||e.url&&Yt(e.url)&&e.url.endsWith("/hub.txt")?t=(await fu(e.hubURL||e.url)).getGenomeConfig():Yt(e)||!(e.url||e.fastaURL||e.twoBitURL||e.gbkURL)?t=await ci.expandReference(this.alert,e):t=e,await this.loadReference(t);let n;return t.gbkURL||t.format==="gbk"?n=[{name:"Annotations",format:"gbk",url:t.gbkURL}]:n=t.tracks||[],n.filter(s=>s.type==="sequence").length===0&&n.push({type:"sequence",order:uu}),await this.loadTrackList(n),this.genome}updateUIWithReferenceFrameList(){const e=this.referenceFrameList;this.isMultiLocusWholeGenomeView()||ci.isWholeGenomeView(e[0].chr),this.navbar.navbarDidResize(),yg(this.trackViews,this.doShowTrackLabels),this.doShowCenterLine&&ci.isWholeGenomeView(e[0].chr)&&this.navbar.centerLineButton.boundMouseClickHandler(),this.doShowCursorGuide&&ci.isWholeGenomeView(e[0].chr)&&this.navbar.cursorGuideButton.boundMouseClickHandler(),this.setCenterLineAndCenterLineButtonVisibility(ci.isWholeGenomeView(e[0].chr))}setCenterLineAndCenterLineButtonVisibility(e){e?this.navbar.centerLineButton.setVisibility(!1):this.navbar.centerLineButton.setVisibility(this.config.showCenterGuideButton);for(let t of this.centerLineList)e?this.setCenterLineVisibility(!e):this.setCenterLineVisibility(this.doShowCenterLine)}setTrackLabelVisibility(e){yg(this.trackViews,e)}setROITableVisibility(e){e===!0?this.roiManager.presentTable():this.roiManager.dismissTable()}setCursorGuideVisibility(e){e?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(e){this.cursorGuide.customMouseHandler=e}setCenterLineVisibility(e){for(let t of this.centerLineList)e===!0?(t.show(),t.repaint()):t.hide()}async loadTrackList(e){let t=this.trackViews.length+1;for(let o of e)o.order===void 0&&(o.order=t++);const r=[];for(const o of e)r.push(lt(this,Nu,NA).call(this,o));const n=await Promise.all(r);return this.trackViews.some(({track:o})=>o.selected)&&this.navbar.setEnableTrackSelection(!0),this.reorderTracks(),await sd.call(this),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),n}async loadTrack(e){const t=await this.loadTrackList([e]);return e.autoscaleGroup&&this.updateViews(),t[0]}async addTrack(e){e.order===void 0&&(e.order=this.trackViews.length);const t=new qp(this,this.columnContainer,e);if(this.trackViews.push(t),yg(this.trackViews,this.doShowTrackLabels),typeof e.postInit=="function")try{t.startSpinner(),await e.postInit()}finally{t.stopSpinner()}return typeof e.hasSamples=="function"&&e.hasSamples()&&(this.sampleInfo.hasAttributes()&&this.sampleInfoControl.setButtonVisibility(!0),this.config.showSampleNameButton!==!1&&this.sampleNameControl.show()),e.trackView.enableTrackSelection(this.navbar.getEnableTrackSelection()),e}async loadROI(e){return this.roiManager.loadROI(e,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const e=this.roiManager.getUserDefinedROISet();if(e===void 0)return[];const t=await e.getAllFeatures(),r=[];for(let n of Object.values(t))r.push(...n);return r}else return[]}getRulerTrackView(){const e=this.trackViews.filter(({track:t})=>t.id==="ruler");return e.length>0?e[0]:void 0}async createTrack(e){let t=await fz(e.url||e.fastaURL);if(Yt(t)&&(t=t.trim()),t)if(e.format)e.format=e.format.toLowerCase();else if(e.fastaURL)e.format="fasta";else if(e.sourceType)e.sourceType==="htsget"&&await c2.inferFormat(e);else{const o=await nx(e);o&&(e.format=o)}e.type&&X_(e);let r=e.type?e.type.toLowerCase():void 0;if(!r){if(e.format){if(e.format==="hic"){const o=new SA(e);if(await o.readHeaderAndFooter(),o.chromosomeIndexMap.celltype)r="shoebox",e._hicFile=o;else throw Error("'.hic' files not supported")}else if(r=Y_(e.format),r==="bedtype"){const o=ji(e,this.genome);e._featureSource=o;const s=await o.trackType();s&&pX().has(s)?r=s:r="annotation"}}else throw Error(`Unrecognized track: ${JSON.stringify(e)}`);e.type=r}if(this.trackDefaults&&r){const o=this.trackDefaults[r];if(o)for(let s in o)o.hasOwnProperty(s)&&e[s]===void 0&&(e[s]=o[s])}const n=gX(r,e,this);if(n===void 0)this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${e.url||e}`),void 0);else return e.roi&&e.roi.length>0&&(n.roiSets=e.roi.map(o=>new oZ(o,this.genome))),n}reorderTracks(){this.trackViews.sort(function(t,r){const n=a=>a.track.id==="ideogram"?1:a.track.id==="ruler"?2:3,o=n(t),s=n(r);if(o===s){const a=t.track.order||0,l=r.track.order||0;return a-l}else return o-s});for(let{axis:t,viewports:r,sampleInfoViewport:n,sampleNameViewport:o,outerScroll:s,dragHandle:a,gearContainer:l}of this.trackViews){t.remove();for(let{viewportElement:c}of r)c.parentNode.removeChild(c);n.viewport.remove(),o.viewport.remove(),s.remove(),a.remove(),l.remove()}const e=this.columnContainer.querySelectorAll(".igv-column");for(let{axis:t,viewports:r,sampleInfoViewport:n,sampleNameViewport:o,outerScroll:s,dragHandle:a,gearContainer:l}of this.trackViews){this.columnContainer.querySelector(".igv-axis-column").appendChild(t);for(let c=0;c<e.length;c++){const{viewportElement:h}=r[c];e[c].appendChild(h)}this.columnContainer.querySelector(".igv-sample-info-column").appendChild(n.viewport),this.columnContainer.querySelector(".igv-sample-name-column").appendChild(o.viewport),this.columnContainer.querySelector(".igv-scrollbar-column").appendChild(s),this.columnContainer.querySelector(".igv-track-drag-column").appendChild(a),this.columnContainer.querySelector(".igv-gear-menu-column").appendChild(l)}}getTrackOrder(){return this.trackViews.filter(e=>e.track&&e.track.name).map(e=>e.track.name)}getSelectedTrackViews(){return this.trackViews.filter(e=>e.track.selected===!0)}removeTrackByName(e){const t=this.trackViews.slice();for(let r of t)e===r.track.name&&this.removeTrack(r.track)}removeTrack(e){for(let t of this.trackViews)if(e===t.track){this._removeTrack(t.track);break}}_removeTrack(e){e.disposed||(this.trackViews.splice(this.trackViews.indexOf(e.trackView),1),this.fireEvent("trackremoved",[e]),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),e.trackView&&e.trackView.dispose())}removeAllTracks(){const e=this.trackViews;this.trackViews=[];for(let t of e)t.track.id!=="ruler"&&t.track.id!=="ideogram"?(this.fireEvent("trackremoved",[t.track]),t.dispose()):this.trackViews.push(t)}get ideogramTrackView(){return this.trackViews[0]}get rulerTrackView(){return this.trackViews[1]}findTracks(e,t){let r=typeof e=="function"?n=>e(n.track):n=>t===n.track[e];return this.trackViews.filter(r).map(n=>n.track)}get tracks(){return this.trackViews.map(e=>e.track).filter(e=>e!==void 0)}setTrackHeight(e){this.trackHeight=e,this.trackViews.forEach(function(t){t.setTrackHeight(e)})}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find(t=>t.bpPerPixel<0)){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let r of this.referenceFrameList)r.bpPerPixel=(r.end-r.start)/t}this.referenceFrameList&&this.navbar.navbarDidResize(),sd.call(this),this.roiManager.updateROIRegionPositions(),await this.updateViews()}async updateViews(){const e=this.trackViews;this.updateLocusSearchWidget();for(const{bpPerPixel:t,chr:r,start:n}of this.referenceFrameList)t<=f2&&await this.genome.getSequence(r,n,n+1);for(const t of this.centerLineList)t.repaint();if(this.dragObject)for(const t of e)await t.updateViews();else{const t={},r=[];for(const n of e)if(n.track.autoscaleGroup){const o=n.track.autoscaleGroup;t[o]||(t[o]=[]),t[o].push(n)}else r.push(n);if(Object.entries(t).length>0)for(const[n,o]of Object.entries(t)){const s=await Promise.all(o.map(l=>l.getInViewFeatures())),a=Ac(s.flat());for(const l of o)l.track.dataRange=Object.assign({},a),l.track.autoscale=!1;await Promise.all(o.map(l=>l.updateViews()))}await Promise.all(r.map(n=>n.updateViews()))}}repaintViews(){for(let e of this.trackViews)e.repaintViews()}updateLocusSearchWidget(){if(!this.referenceFrameList)return;const e=this.referenceFrameList,t=this.calculateViewportWidth(this.referenceFrameList.length);for(let o of e)o.end=o.start+o.bpPerPixel*t;const r=this.referenceFrameList.map(o=>o.getLocusString()).join(" "),n=e.length===1?this.genome.getChromosomeDisplayName(this.referenceFrameList[0].chr):"";this.navbar.updateLocus(r,n),this.fireEvent("locuschange",[this.referenceFrameList])}calculateViewportWidth(e){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=aj+this.getSampleInfoViewportWidth()+this.getSampleNameViewportWidth()+DZ+zZ+LZ,t-=PZ*(e-1),Math.floor(t/e)}updateReferenceFrames(e){for(const t of this.referenceFrameList)t.updateForViewportWidth(e)}updateViewportElements(e){for(let t=0;t<this.referenceFrameList.length;t++){for(const{viewports:r}of this.trackViews)r[t].setWidth(e);for(const{sampleInfoViewport:r}of this.trackViews)r.setWidth(this.getSampleInfoColumnWidth()),r.repaint()}}async syncUIState(){this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(e,t,r){if(!this.referenceFrameList)return;const n=this.calculateViewportWidth(this.referenceFrameList.length);let o=r?[r]:this.referenceFrameList;for(let s of o)s.zoomWithScaleFactor(this,e,n,t)}async addMultiLocusPanel(e,t,r,n){if(!this.referenceFrameList)return;const o=this.calculateViewportWidth(1+this.referenceFrameList.length),s=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let f of this.referenceFrameList)f.bpPerPixel*=s;const a=(r-t)/o,l=new vA(this.genome,e,t,r,a),c=n?this.referenceFrameList.indexOf(n):this.referenceFrameList.length-1,h=1+c,{viewportElement:d}=this.trackViews[0].viewports[c],u=mg.insertAfter(d.parentElement);if(this.fireEvent("didchangecolumnlayout"),h===this.referenceFrameList.length){this.referenceFrameList.push(l);for(let f of this.trackViews){const p=Nm(f,u,l);f.viewports.push(p)}}else{this.referenceFrameList.splice(h,0,l);for(let f of this.trackViews){const p=Nm(f,u,l);f.viewports.splice(h,0,p)}}this.centerLineList=this.createCenterLineList(this.columnContainer),sd.call(this),await this.updateViews(!0)}createCenterLineList(e){const t=e.querySelectorAll(".igv-center-line");for(let o=0;o<t.length;o++)t[o].remove();const r=[],n=e.querySelectorAll(".igv-column");for(let o=0;o<n.length;o++)r.push(new JX(this,this.referenceFrameList[o],n[o]));return r}async removeMultiLocusPanel(e){const t=this.referenceFrameList.indexOf(e),{viewportElement:r}=this.trackViews[0].viewports[t];mg.removeColumnAtIndex(t,r.parentElement),this.fireEvent("didchangecolumnlayout");for(let{viewports:o}of this.trackViews)o[t].dispose(),o.splice(t,1);if(this.referenceFrameList.splice(t,1),this.referenceFrameList.length===1&&this.getRulerTrackView())for(let o of this.getRulerTrackView().viewports)o.dismissLocusLabel();const n=this.calculateViewportWidth(1+this.referenceFrameList.length)/this.calculateViewportWidth(this.referenceFrameList.length);await this.rescaleForMultiLocus(n)}async gotoMultilocusPanel(e){const t=this.referenceFrameList.indexOf(e);this.columnContainer.querySelectorAll(".igv-column").forEach((n,o)=>{o===t||n.remove()}),this.columnContainer.querySelectorAll(".igv-column-shim").forEach(n=>n.remove());for(let n of this.trackViews){const o=n.viewports[t];n.viewports.filter((s,a)=>a!==t).forEach(s=>s.dispose()),n.viewports=[o]}const r=this.calculateViewportWidth(1);e.bpPerPixel=(e.end-e.start)/r,this.referenceFrameList=[e],this.trackViews.forEach(({viewports:n})=>n.forEach(o=>o.setWidth(r))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(e){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let r of this.referenceFrameList)r.bpPerPixel*=e;for(let{viewports:r}of this.trackViews)for(let n of r)n.setWidth(t);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(e,t,r){await this.search(e+":"+t+"-"+r)}async search(e,t){const r=await XY(this,e);return this.updateLoci(r,t)}async updateLoci(e,t){if(e&&e.length>0){this.referenceFrameList=vX(e,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(e.length),this.isSoftclipped());for(let r of this.trackViews)r.removeViewportsFromColumnContainer();this.columnContainer.querySelectorAll(".igv-column-shim, .igv-column").forEach(r=>r.remove()),mg.insertBefore(this.columnContainer.querySelector(".igv-sample-info-column"),this.referenceFrameList.length),this.fireEvent("didchangecolumnlayout");for(let r of this.trackViews)r.createViewports(this,this.columnContainer,this.referenceFrameList);return this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),t||await this.updateViews(),!0}else return!1}async loadSampleInfo(e){await this.sampleInfo.loadSampleInfo(e),this.config.sampleinfo?this.config.sampleinfo.push(e):this.config.sampleinfo=[e];for(const{sampleInfoViewport:r}of this.trackViews)r.setWidth(this.getSampleInfoColumnWidth());this.findTracks(r=>typeof r.getSamples=="function").length>0&&(this.sampleInfoControl.performClickWithState(this,!0),this.sampleInfoControl.setButtonVisibility(!0));for(const{sampleInfoViewport:r}of this.trackViews)r.repaint()}async discardSampleInfo(){this.sampleInfo.discard();for(const{sampleInfoViewport:t}of this.trackViews)t.setWidth(this.getSampleInfoColumnWidth());this.findTracks(t=>typeof t.getSamples=="function").length>0&&(this.sampleInfoControl.performClickWithState(this,!1),this.sampleInfoControl.setButtonVisibility(!1));for(const{sampleInfoViewport:t}of this.trackViews)t.repaint();await this.layoutChange()}getSampleInfoColumnWidth(){if(this.sampleInfo.attributeCount){const t=this.findTracks(s=>typeof s.getSamples=="function").length>0,r=this.sampleInfo.hasAttributes(),n=this.sampleInfoControl.showSampleInfo;return t&&r&&n?this.sampleInfo.attributeCount*Zs+Mm:0}else return 0}on(e,t){this.eventHandlers[e]||(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)}un(e,t){this.off(e,t)}off(e,t){if(!e)this.eventHandlers={};else if(!t)this.eventHandlers[e]=[];else{const r=this.eventHandlers[e];if(!r||r.length===0)console.warn("No handlers to remove for event: "+e);else{const n=r.indexOf(t);n!==-1&&this.eventHandlers[e].splice(n,1)}}}fireEvent(e,t,r){const n=this.eventHandlers[e];if(n===void 0||n.length===0)return;const o=r||window;return n.map(function(a){return a.apply(o,t)})[0]}dispose(){this.removeEventHandlers();for(let e of this.trackViews)e.dispose();this.roiManager&&this.roiManager.dispose()}toJSON(){const e={version:FA()};if(this.showSampleNames!==void 0&&(e.showSampleNames=this.showSampleNames),this.sampleNameViewportWidth&&(e.sampleNameViewportWidth=this.sampleNameViewportWidth),e.reference=this.genome.toJSON(),e.reference.fastaURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.fastaURL.name}.`);if(e.reference.indexURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${e.reference.indexURL.name}.`);const t=[];let r=this.trackViews[0];for(let{referenceFrame:c}of r.viewports){const h=c.getLocusString();t.push(h)}e.locus=t.length===1?t[0]:t;const n=this.roiManager.toJSON();n&&(e.roi=n,this.roiManager.showOverlays||(e.showROIOverlays=!1)),this.qtlSelections.isEmpty()||(e.qtlSelections=this.qtlSelections.toJSON());const o=[],s=[];for(const{track:c}of this.trackViews)try{let h;typeof c.getState=="function"?h=Qt.localFileInspection(c.getState()):c.config&&(h=Qt.localFileInspection(c.config)),h&&(h.browser&&delete h.browser,h.order=c.order,o.push(h))}catch(h){const d=`Track: ${c.name}: ${h}`;console.error(d),s.push(d)}if(s.length>0){let c=1,h="Errors encountered saving session: </br>";for(let d of s)h+=` (${c++}) ${d.toString()} <br/>`;throw Error(h)}e.tracks=o;const a=[];for(const c of o)for(const h of Object.keys(c))(h==="file"||h==="indexFile")&&a.push(c[h]);const l=[];if(this.config.sampleinfo){e.sampleinfo=this.config.sampleinfo;for(const c of this.sampleInfo.sampleInfoFiles){const h=Qt.localFileInspection({url:c});h.file&&l.push(h.file)}l.length>0&&a.push(...l)}return a.length>0&&alert(`This session includes reference(s) to local file(s):
|
|
2450
2450
|
${a.map(c=>` ${c}`).join(`
|
|
2451
2451
|
`)}
|
|
2452
|
-
Local files cannot be loaded automatically when a saved session is restored.`),e}compressedSession(){const e=JSON.stringify(this.toJSON());return XP(e)}sessionURL(){const e=window.location.href.slice(),t=e.indexOf("?");return(t>0?e.substring(0,t):e)+"?sessionURL=blob:"+this.compressedSession()}mouseDownOnViewport(e,t){var r;r=fc(e),this.vpMouseDown={viewport:t,lastMouseX:r.x,mouseDownX:r.x,lastMouseY:r.y,mouseDownY:r.y,referenceFrame:t.referenceFrame}}cancelTrackPan(){const e=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,e&&e.viewport.referenceFrame.start!==e.start&&(this.updateViews(),this.fireEvent("trackdragend",[e.viewport]))}isTrackPanning(){return this.dragObject}isSoftclipped(){return this.trackViews.find(t=>t.track.showSoftClips===!0)!==void 0}startTrackDrag(e){this.dragTrack=e}updateTrackDrag(e){if(e&&this.dragTrack){const t=this.dragTrack,r=this.trackViews.indexOf(e),n=this.trackViews.indexOf(t),o=this.trackViews;o[r]=t,o[n]=e;const s=this.trackViews[r].track.order;this.trackViews[n].track.order=s;const a=o.length;let l=s;if(r<n)for(let c=r+1;c<a;c++){const h=o[c].track;if(h.order<=l)h.order=Math.min(Number.MAX_SAFE_INTEGER,l+1),l=h.order;else break}else for(let c=r-1;c>0;c--){const h=o[c].track;if(h.order>=l)h.order=Math.max(-Number.MAX_SAFE_INTEGER,l-1),l=h.order;else break}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent("trackorderchanged",[this.getTrackOrder()])):this.dragTrack=void 0}addEventHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers(),this.addKeyboardHandler()}removeEventHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers(),this.removeKeyboardHandler()}addWindowResizeHandler(){this.boundWindowResizeHandler=sd.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=yl.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=yl.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=$y.bind(this),this.boundColumnContainerTouchMoveHandler=$y.bind(this),this.boundColumnContainerMouseLeaveHandler=yl.bind(this),this.boundColumnContainerMouseUpHandler=yl.bind(this),this.boundColumnContainerTouchEndHandler=yl.bind(this),this.columnContainer.addEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener("touchend",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener("touchend",this.boundColumnContainerTouchEndHandler)}addKeyboardHandler(){this.keyUpHandler=HZ.bind(this),document.addEventListener("keyup",this.keyUpHandler)}removeKeyboardHandler(){console.log("Remove handler"),document.addEventListener("keyup",this.keyUpHandler)}static uncompressSession(e){let t;if(e.indexOf("/gzip;base64")>0){t=Po(e);let r="";for(let n of t)r+=String.fromCharCode(n);return r}else{let r=e.substring(5);return ZP(r)}}createCircularView(e,t){return t=t===!0,this.circularView=uG(e,this),this.circularViewControl=new th(this.navbar.toggleButtonContainer,this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:pF(this.genome)}),this.circularViewVisible=t,this.circularView}get circularViewVisible(){return this.circularView!==void 0&&this.circularView.visible}set circularViewVisible(e){this.circularView&&(this.circularView.visible=e,this.circularViewControl.setState(e))}get overlayTrackButton(){return this.navbar.overlayTrackButton}get roiTableControl(){return this.navbar.roiTableControl}get sampleNameControl(){return this.navbar.sampleNameControl}get sampleInfoControl(){return this.navbar.sampleInfoControl}async blat(e){return pa({sequence:e,browser:this,name:"Blat",title:"Blat"})}};Nu=new WeakSet,NA=async function(e){Yt(e)&&(e=JSON.parse(e));let t;try{t=await this.createTrack(e)}catch(r){let n=r.message||r.error||r.toString();const o={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};o.hasOwnProperty(n)&&(n=o[n]),n=`${n} : ${Io(e.url)?e.url.name:e.url}`;const s=new Error(n);throw console.error(s),s}if(t)return await this.addTrack(t)};let Dc=Mu;function OZ(i){let e;if(i instanceof File)e=i.name;else if(typeof i=="string")e=i;else throw new Error("Input must be a File object or a URL string");return e.split(".").pop().split("?")[0]}async function sd(i){if(this.referenceFrameList===void 0||this.referenceFrameList.length===0)return;const e=this.calculateViewportWidth(this.referenceFrameList.length);this.updateReferenceFrames(e),this.updateViewportElements(e),await this.syncUIState()}function $y(i){i.preventDefault();const{x:e,y:t}=fc(i);if(this.vpMouseDown){const{viewport:r,referenceFrame:n}=this.vpMouseDown,o=Math.abs(e-this.vpMouseDown.mouseDownX)>Math.abs(t-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling){if(o)this.vpMouseDown.mouseDownX&&Math.abs(e-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:r,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(t-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const s=r.viewportElement.clientHeight,a=r.trackView.maxViewportContentHeight();this.vpMouseDown.r=s/a}}if(this.dragObject){const s=!this.isSoftclipped();let a=this.vpMouseDown.lastMouseX-e;n.shiftPixels(a,r.viewportElement.clientWidth,s)&&this.updateViews(),this.fireEvent("trackdrag")}if(this.isScrolling){const s=this.vpMouseDown.lastMouseY-t;r.trackView.scrollByPixels(s)}this.vpMouseDown.lastMouseX=e,this.vpMouseDown.lastMouseY=t}}function yl(i){this.cancelTrackPan(),this.endTrackDrag()}async function HZ(i){if(!(!this.referenceFrameList||this.referenceFrameList.length>1)&&(i.code==="KeyF"||i.code==="KeyB")){const e=this.getSelectedTrackViews();if(e.length>0){const t=e[0].track;if(typeof t.nextFeatureAfter=="function"){const r=this.referenceFrameList[0],n=r.viewport?r.viewport.getWidth():this.calculateViewportWidth(this.referenceFrameList.length),o=r.chr.toLowerCase()==="all",s=t.visibilityWindow;if(o||s&&s>0&&r.bpPerPixel*n>s)return;const a=i.code==="KeyF",l=r.chr,c=r.center,h=await t.nextFeatureAfter(l,c,a);if(h){const d=await this.genome.getChromosomeName(h.chr);if(l===d){const u=(h.start+h.end)/2;if(i.shiftKey){const f=this.config.minimumBases||40,p=Math.max(f,1.1*(h.end-h.start));r.start=Math.max(0,u-p/2),r.end=u+p/2,r.bpPerPixel=(r.end-r.start)/n}else r.shift(u-c);this.updateViews()}else{r.chr=d;const u=(h.start+h.end)/2;if(i.shiftKey){const f=this.config.minimumBases||40,p=Math.max(f,1.1*(h.end-h.start));r.start=Math.max(0,u-p/2),r.end=r.start+p,r.bpPerPixel=(r.end-r.start)/n}else r.start=u-n*r.bpPerPixel/2,r.end=r.start+n*r.bpPerPixel;this.updateViews()}}}}}}function yg(i,e){for(let{viewports:t}of i)for(let r of t)r.trackLabelElement&&(t.indexOf(r)===0&&e===!0?r.trackLabelElement.style.display="block":r.trackLabelElement.style.display="none")}let za=[];async function $Z(i,e){e===void 0&&(e={}),ci.KNOWN_GENOMES||await ci.initializeGenomes(e),MA(e),e.queryParametersSupported&&qZ(e),e.apiKey&&Ee.setApiKey(e.apiKey),e.oauthToken&&Ee.setOauthToken(e.oauthToken),e.clientId&&!zs()&&await oO({client_id:e.clientId,apiKey:e.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const t=new Dc(e,i);za.push(t);const r=e.sessionURL||e.session||e.hubURL;return r?await t.loadSession({url:r}):await t.loadSessionObject(e),t.navbar.navbarDidResize(),t}function UZ(i){i.dispose(),i.root.remove(),za=za.filter(e=>e!==i)}function VZ(){for(let i of za)i.dispose(),i.root.remove();za=[]}async function jZ(){for(let i of za)await i.visibilityChange()}function MA(i){return i.minimumBases===void 0&&(i.minimumBases=40),i.showIdeogram===void 0&&(i.showIdeogram=!0),i.showCytobandNames==null&&(i.showCytobandNames=!1),i.showCircularView===void 0&&(i.showCircularView=!1),i.showCircularViewButton===void 0&&(i.showCircularViewButton=!1),i.showTrackLabelButton===void 0&&(i.showTrackLabelButton=!0),i.showTrackLabels===void 0&&(i.showTrackLabels=!0),i.showCursorTrackingGuideButton===void 0&&(i.showCursorTrackingGuideButton=!0),i.showCursorGuide===void 0&&(i.showCursorGuide=i.showCursorTrackingGuide||!1),i.showCenterGuideButton===void 0&&(i.showCenterGuideButton=!0),i.showCenterGuide===void 0&&(i.showCenterGuide=!1),i.showSampleNames===void 0&&(i.showSampleNames=!1),i.showSVGButton===void 0&&(i.showSVGButton=!0),i.showControls===void 0&&(i.showControls=!0),i.showNavigation===void 0&&(i.showNavigation=!0),i.showRuler===void 0&&(i.showRuler=!0),i.flanking===void 0&&(i.flanking=1e3),i.pairsSupported===void 0&&(i.pairsSupported=!0),i.tracks||(i.tracks=[]),i}function qZ(i){var e,t,r,n,o,s,a,l,c,h;l=window.location.href,s={},e=l.indexOf("?"),t=l.lastIndexOf("#");let d,u,f;if(e>=0)for(t<0&&(t=l.length),r=e+1;r<t;)n=l.indexOf("&",r),n<0&&(n=t),o=l.substring(r,n),a=o.split("=",2),a.length===2?(c=a[0],h=decodeURIComponent(a[1]),c==="file"?d=h.split(","):c==="index"?u=h.split(","):c==="name"?f=h.split(","):c==="genome"?(h.startsWith("https://")||h.startsWith("http://"))&&!h.endsWith(".json")?i.reference={fastaURL:h,indexURL:h+".fai"}:(i[c]=h,i.reference=void 0):(c==="reference"&&(i.genome=void 0),i[c]=h),r=n+1):r++;if(d){i.tracks||(i.tracks=[]);for(let p=0;p<d.length;p++){if(d[p].endsWith(".xml")||d[p].endsWith(".json")){i.sessionURL=d[p];break}const m={url:d[p]};u&&u.length>p&&(m.indexURL=u[p]),f&&f.length>p&&(m.name=f[p]),i.tracks.push(m)}}return s}async function GZ(i,e){return await Dc.prototype.createTrack.call(e,i)}const WZ=Ee.setApiKey;function QZ(i){return Ee.setOauthToken(i)}function KZ(i,e){return Ee.setOauthToken(i,e)}const YZ=Ee.oauth;var XZ={AlertDialog:e2,TrackUtils:xj,IGVGraphics:ge,MenuUtils:Q_,DataRangeDialog:K_,createTrack:GZ,createBrowser:$Z,removeBrowser:UZ,removeAllBrowsers:VZ,visibilityChange:jZ,setGoogleOauthToken:QZ,setOauthToken:KZ,oauth:YZ,version:FA,setApiKey:WZ,TrackBase:Qt,registerTrackClass:mX,registerTrackCreatorFunction:bX,registerFileFormats:HH,loadSessionFile:Dc.loadSessionFile,loadHub:fu};class ZZ extends Error{}class JZ{constructor(e=1e3,t=!1){xe(this,"throttlePeriod");xe(this,"rejectSkipped");xe(this,"queuedPromises",{});xe(this,"pendingPromise",!1);this.throttlePeriod=e,this.rejectSkipped=t}skipPromise(e){if(!this.rejectSkipped)return;const t=this.queuedPromises[e];t==null||t.reject(new ZZ)}async enqueue(e,t,r=0){return new Promise((n,o)=>{this.skipPromise(r),this.queuedPromises[r]={action:e,arg:t,resolve:n,reject:o},this.dequeue()})}async dequeue(){const e=Object.keys(this.queuedPromises);if(!this.pendingPromise&&e.length>0){const t=e[0],r=this.queuedPromises[t];delete this.queuedPromises[t],this.pendingPromise=!0;try{const n=await r.action(r.arg);r.resolve(n)}catch(n){r.reject(n)}finally{setTimeout(()=>{this.pendingPromise=!1,this.dequeue()},this.throttlePeriod)}}}}const Uy={"2bit":{type:"sequence"},bam:{type:"alignment",index:"bam_index"},bcf:{type:"variant"},bed:{type:"annotation"},bedgraph:{type:"wig"},bigbed:{type:"annotation"},bigwig:{type:"wig"},broadpeak:{type:"annotation"},bw:{type:"wig"},cram:{type:"alignment",index:"cram_index"},fa:{type:"sequence"},fasta:{type:"sequence"},gff:{type:"annotation"},gff3:{type:"annotation"},gtf:{type:"annotation"},narrowpeak:{type:"annotation"},vcf:{type:"variant"},vcf_bgzip:{type:"variant",index:"tabix_index"},wig:{type:"wig"}},eJ={class:"h-screen overflow-auto"},tJ={key:0,class:"bg-sky-100 border border-sky-200 p-1 rounded text-sky-800 text-sm"},iJ="annotation",rJ=500,nJ=Re({__name:"Plugin",props:{datasetId:{},datasetUrl:{},root:{},settings:{},specs:{},tracks:{}},setup(i){const e=new JZ(rJ),t=i,r=de(""),n=de(null),o=de(null),s=de([]),a=de(null);let l=null,c=[];xi(()=>{h()}),Ri(()=>{l&&typeof l.dispose=="function"&&l.dispose()}),st(()=>t,()=>{var C,x;n.value=(C=t.settings)==null?void 0:C.locus,o.value=(x=t.settings)==null?void 0:x.genome},{deep:!0,immediate:!0}),st(()=>t.tracks,()=>e.enqueue(S,void 0,"tracksParse"),{deep:!0,immediate:!0}),st(()=>o.value,()=>e.enqueue(p,void 0,"loadGenome")),st(()=>n.value,()=>e.enqueue(m,void 0,"locusSearch")),st(()=>s.value,()=>e.enqueue(F,void 0,"tracksLoad"),{deep:!0});async function h(){try{l=await XZ.createBrowser(a.value,{genome:o.value}),await F(!0),await m();const C=l.root.querySelector(".igv-navbar");C&&Object.assign(C.style,{flexFlow:"column",height:"unset",paddingBottom:"3px"})}catch(C){r.value="Failed to create browser",console.error(r.value,C)}}async function d(C){try{const{data:x}=await Ha().GET(`/api/datasets/${C}`);return x.extension}catch(x){return r.value=`Failed to retrieve dataset type for: ${C}`,console.error(r.value,x),null}}function u(C){return`${t.root}api/datasets/${C}/display`}function f(C,x){var y;const I=x?(y=Uy[x])==null?void 0:y.index:null;return I?`${t.root}api/datasets/${C}/metadata_file?metadata_file=${I}`:null}async function p(){if(l){try{await l.loadGenome({genome:o.value}),await F(!0),r.value=""}catch(C){r.value="Failed to load genome",console.error(r.value,o.value,C)}await m()}}async function m(){if(l){if(!n.value)await l.search("all");else if(v(n.value))try{await l.search(n.value)}catch{console.warn("[IGV] Invalid locus ignored:",n.value)}}else r.value="Failed to search.",console.error("[IGV] Browser not available.")}function v(C){const x=/^[\w.-]+$/,I=/^[\w.-]+:\d{1,3}(,\d{3})*-\d{1,3}(,\d{3})*$/;return x.test(C)||I.test(C)}function g(C){const x=Object.keys(C).sort(),I=JSON.stringify(C,x);let y=2166136261;for(let A=0;A<I.length;A++)y^=I.charCodeAt(A),y+=(y<<1)+(y<<4)+(y<<7)+(y<<8)+(y<<24);return(y>>>0).toString(36)}function b(C){const x=C==null?void 0:C.toLowerCase();if(x){const I=Uy[x];if(I!=null&&I.type)return I.type}return iJ}function w(C,x,I=!1){const y=new Map(x.map(T=>[T.name,T])),A=x.filter(T=>{const R=C.find(N=>N.name===T.name);return I||!R||g(R)!==g(T)});return{toAdd:C.filter(T=>{const R=y.get(T.name);return I||!R||g(T)!==g(R)}),toRemove:A}}async function F(C=!1){if(l){const x=E(s.value);console.debug("[IGV] Resolved Tracks",x);const{toAdd:I,toRemove:y}=w(x,c,C);for(const A of y){const _=l.trackViews.find(T=>T.track.name===A.name);_&&(console.debug(`[IGV] Removing existing track '${_.track.name}'`),l.removeTrack(_.track))}for(const A of I)try{console.debug(`[IGV] Adding new track '${A.name}'`),await l.loadTrack(A)}catch(_){console.error(`[IGV] Failed to load track '${A.name}'`,_)}l.reorderTracks(),c=x.map(A=>({...A}))}}async function S(){const C=[];if(t.tracks)for(const x of t.tracks){const I=x.urlDataset,y=x.displayMode,A=x.color,_=I?await d(I.id):null,T=x.indexUrlDataset,R=x.name,N=x.type&&x.type!=="auto"?x.type:b(_),P=I?u(I.id):null,z=T?u(T.id):f(I==null?void 0:I.id,_),V={color:A,displayMode:y,format:_,indexURL:z,name:R,type:N,url:P};console.debug("[IGV] Track:",V),C.push(V)}s.value=C}function E(C){const x=new Set,I=new Map,y=[];return C.forEach((A,_)=>{const T=A.name||`track-${g(A)}`,R=JSON.stringify({...A,name:T}),N=typeof(A==null?void 0:A.url)=="string"&&A.url.trim().length>0,P=x.has(R);if(N&&!P){const z=I.get(T)??0;let V=T;z>0&&(V=`${T} ~ ${z}`),I.set(T,z+1),x.add(R),y.push({...A,name:V,order:_})}else console.warn(N?`[IGV] Duplicate track skipped: '${T}'`:`[IGV] Invalid track skipped: '${T}'`)}),y}return(C,x)=>(He(),gt("div",eJ,[r.value?(He(),gt("div",tJ,On(r.value),1)):tr("",!0),tt("div",{ref_key:"viewport",ref:a},null,512)]))}}),oJ=Re({__name:"App",props:{container:{},credentials:{},incoming:{}},setup(i){return(e,t)=>(He(),jt($e(rz),{container:e.container,credentials:e.credentials,incoming:e.incoming},{default:ft(({datasetId:r,datasetUrl:n,root:o,settings:s,specs:a,tracks:l})=>[Ve(nJ,{"dataset-id":r,"dataset-url":n,root:o,settings:s,specs:a,tracks:l},null,8,["dataset-id","dataset-url","root","settings","specs","tracks"])]),_:1},8,["container","credentials","incoming"]))}});async function sJ(){var o;const e=new URL(import.meta.url).searchParams.get("container")||"app",t=document.getElementById(e),r=JSON.parse(t.dataset.incoming),n=(o=r==null?void 0:r.visualization_config)==null?void 0:o.dataset_id;n?(r.visualization_config.tracks=[{urlDataset:{id:n,name:"Selected History Dataset"}}],console.debug(`[IGV] Populated incoming dataset ${n}.`),t.setAttribute("data-incoming",JSON.stringify(r))):console.error("[IGV] No dataset id available."),R9({render:()=>L(oJ,{container:e,credentials:"include"})}).mount(`#${e}`)}sJ();
|
|
2452
|
+
Local files cannot be loaded automatically when a saved session is restored.`),e}compressedSession(){const e=JSON.stringify(this.toJSON());return XP(e)}sessionURL(){const e=window.location.href.slice(),t=e.indexOf("?");return(t>0?e.substring(0,t):e)+"?sessionURL=blob:"+this.compressedSession()}mouseDownOnViewport(e,t){var r;r=fc(e),this.vpMouseDown={viewport:t,lastMouseX:r.x,mouseDownX:r.x,lastMouseY:r.y,mouseDownY:r.y,referenceFrame:t.referenceFrame}}cancelTrackPan(){const e=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,e&&e.viewport.referenceFrame.start!==e.start&&(this.updateViews(),this.fireEvent("trackdragend",[e.viewport]))}isTrackPanning(){return this.dragObject}isSoftclipped(){return this.trackViews.find(t=>t.track.showSoftClips===!0)!==void 0}startTrackDrag(e){this.dragTrack=e}updateTrackDrag(e){if(e&&this.dragTrack){const t=this.dragTrack,r=this.trackViews.indexOf(e),n=this.trackViews.indexOf(t),o=this.trackViews;o[r]=t,o[n]=e;const s=this.trackViews[r].track.order;this.trackViews[n].track.order=s;const a=o.length;let l=s;if(r<n)for(let c=r+1;c<a;c++){const h=o[c].track;if(h.order<=l)h.order=Math.min(Number.MAX_SAFE_INTEGER,l+1),l=h.order;else break}else for(let c=r-1;c>0;c--){const h=o[c].track;if(h.order>=l)h.order=Math.max(-Number.MAX_SAFE_INTEGER,l-1),l=h.order;else break}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent("trackorderchanged",[this.getTrackOrder()])):this.dragTrack=void 0}addEventHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers(),this.addKeyboardHandler()}removeEventHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers(),this.removeKeyboardHandler()}addWindowResizeHandler(){this.boundWindowResizeHandler=sd.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=yl.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=yl.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=$y.bind(this),this.boundColumnContainerTouchMoveHandler=$y.bind(this),this.boundColumnContainerMouseLeaveHandler=yl.bind(this),this.boundColumnContainerMouseUpHandler=yl.bind(this),this.boundColumnContainerTouchEndHandler=yl.bind(this),this.columnContainer.addEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener("touchend",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener("touchend",this.boundColumnContainerTouchEndHandler)}addKeyboardHandler(){this.keyUpHandler=HZ.bind(this),document.addEventListener("keyup",this.keyUpHandler)}removeKeyboardHandler(){console.log("Remove handler"),document.addEventListener("keyup",this.keyUpHandler)}static uncompressSession(e){let t;if(e.indexOf("/gzip;base64")>0){t=Po(e);let r="";for(let n of t)r+=String.fromCharCode(n);return r}else{let r=e.substring(5);return ZP(r)}}createCircularView(e,t){return t=t===!0,this.circularView=uG(e,this),this.circularViewControl=new th(this.navbar.toggleButtonContainer,this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:pF(this.genome)}),this.circularViewVisible=t,this.circularView}get circularViewVisible(){return this.circularView!==void 0&&this.circularView.visible}set circularViewVisible(e){this.circularView&&(this.circularView.visible=e,this.circularViewControl.setState(e))}get overlayTrackButton(){return this.navbar.overlayTrackButton}get roiTableControl(){return this.navbar.roiTableControl}get sampleNameControl(){return this.navbar.sampleNameControl}get sampleInfoControl(){return this.navbar.sampleInfoControl}async blat(e){return pa({sequence:e,browser:this,name:"Blat",title:"Blat"})}};Nu=new WeakSet,NA=async function(e){Yt(e)&&(e=JSON.parse(e));let t;try{t=await this.createTrack(e)}catch(r){let n=r.message||r.error||r.toString();const o={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};o.hasOwnProperty(n)&&(n=o[n]),n=`${n} : ${Io(e.url)?e.url.name:e.url}`;const s=new Error(n);throw console.error(s),s}if(t)return await this.addTrack(t)};let Dc=Mu;function OZ(i){let e;if(i instanceof File)e=i.name;else if(typeof i=="string")e=i;else throw new Error("Input must be a File object or a URL string");return e.split(".").pop().split("?")[0]}async function sd(i){if(this.referenceFrameList===void 0||this.referenceFrameList.length===0)return;const e=this.calculateViewportWidth(this.referenceFrameList.length);this.updateReferenceFrames(e),this.updateViewportElements(e),await this.syncUIState()}function $y(i){i.preventDefault();const{x:e,y:t}=fc(i);if(this.vpMouseDown){const{viewport:r,referenceFrame:n}=this.vpMouseDown,o=Math.abs(e-this.vpMouseDown.mouseDownX)>Math.abs(t-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling){if(o)this.vpMouseDown.mouseDownX&&Math.abs(e-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:r,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(t-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const s=r.viewportElement.clientHeight,a=r.trackView.maxViewportContentHeight();this.vpMouseDown.r=s/a}}if(this.dragObject){const s=!this.isSoftclipped();let a=this.vpMouseDown.lastMouseX-e;n.shiftPixels(a,r.viewportElement.clientWidth,s)&&this.updateViews(),this.fireEvent("trackdrag")}if(this.isScrolling){const s=this.vpMouseDown.lastMouseY-t;r.trackView.scrollByPixels(s)}this.vpMouseDown.lastMouseX=e,this.vpMouseDown.lastMouseY=t}}function yl(i){this.cancelTrackPan(),this.endTrackDrag()}async function HZ(i){if(!(!this.referenceFrameList||this.referenceFrameList.length>1)&&(i.code==="KeyF"||i.code==="KeyB")){const e=this.getSelectedTrackViews();if(e.length>0){const t=e[0].track;if(typeof t.nextFeatureAfter=="function"){const r=this.referenceFrameList[0],n=r.viewport?r.viewport.getWidth():this.calculateViewportWidth(this.referenceFrameList.length),o=r.chr.toLowerCase()==="all",s=t.visibilityWindow;if(o||s&&s>0&&r.bpPerPixel*n>s)return;const a=i.code==="KeyF",l=r.chr,c=r.center,h=await t.nextFeatureAfter(l,c,a);if(h){const d=await this.genome.getChromosomeName(h.chr);if(l===d){const u=(h.start+h.end)/2;if(i.shiftKey){const f=this.config.minimumBases||40,p=Math.max(f,1.1*(h.end-h.start));r.start=Math.max(0,u-p/2),r.end=u+p/2,r.bpPerPixel=(r.end-r.start)/n}else r.shift(u-c);this.updateViews()}else{r.chr=d;const u=(h.start+h.end)/2;if(i.shiftKey){const f=this.config.minimumBases||40,p=Math.max(f,1.1*(h.end-h.start));r.start=Math.max(0,u-p/2),r.end=r.start+p,r.bpPerPixel=(r.end-r.start)/n}else r.start=u-n*r.bpPerPixel/2,r.end=r.start+n*r.bpPerPixel;this.updateViews()}}}}}}function yg(i,e){for(let{viewports:t}of i)for(let r of t)r.trackLabelElement&&(t.indexOf(r)===0&&e===!0?r.trackLabelElement.style.display="block":r.trackLabelElement.style.display="none")}let za=[];async function $Z(i,e){e===void 0&&(e={}),ci.KNOWN_GENOMES||await ci.initializeGenomes(e),MA(e),e.queryParametersSupported&&qZ(e),e.apiKey&&Ee.setApiKey(e.apiKey),e.oauthToken&&Ee.setOauthToken(e.oauthToken),e.clientId&&!zs()&&await oO({client_id:e.clientId,apiKey:e.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const t=new Dc(e,i);za.push(t);const r=e.sessionURL||e.session||e.hubURL;return r?await t.loadSession({url:r}):await t.loadSessionObject(e),t.navbar.navbarDidResize(),t}function UZ(i){i.dispose(),i.root.remove(),za=za.filter(e=>e!==i)}function VZ(){for(let i of za)i.dispose(),i.root.remove();za=[]}async function jZ(){for(let i of za)await i.visibilityChange()}function MA(i){return i.minimumBases===void 0&&(i.minimumBases=40),i.showIdeogram===void 0&&(i.showIdeogram=!0),i.showCytobandNames==null&&(i.showCytobandNames=!1),i.showCircularView===void 0&&(i.showCircularView=!1),i.showCircularViewButton===void 0&&(i.showCircularViewButton=!1),i.showTrackLabelButton===void 0&&(i.showTrackLabelButton=!0),i.showTrackLabels===void 0&&(i.showTrackLabels=!0),i.showCursorTrackingGuideButton===void 0&&(i.showCursorTrackingGuideButton=!0),i.showCursorGuide===void 0&&(i.showCursorGuide=i.showCursorTrackingGuide||!1),i.showCenterGuideButton===void 0&&(i.showCenterGuideButton=!0),i.showCenterGuide===void 0&&(i.showCenterGuide=!1),i.showSampleNames===void 0&&(i.showSampleNames=!1),i.showSVGButton===void 0&&(i.showSVGButton=!0),i.showControls===void 0&&(i.showControls=!0),i.showNavigation===void 0&&(i.showNavigation=!0),i.showRuler===void 0&&(i.showRuler=!0),i.flanking===void 0&&(i.flanking=1e3),i.pairsSupported===void 0&&(i.pairsSupported=!0),i.tracks||(i.tracks=[]),i}function qZ(i){var e,t,r,n,o,s,a,l,c,h;l=window.location.href,s={},e=l.indexOf("?"),t=l.lastIndexOf("#");let d,u,f;if(e>=0)for(t<0&&(t=l.length),r=e+1;r<t;)n=l.indexOf("&",r),n<0&&(n=t),o=l.substring(r,n),a=o.split("=",2),a.length===2?(c=a[0],h=decodeURIComponent(a[1]),c==="file"?d=h.split(","):c==="index"?u=h.split(","):c==="name"?f=h.split(","):c==="genome"?(h.startsWith("https://")||h.startsWith("http://"))&&!h.endsWith(".json")?i.reference={fastaURL:h,indexURL:h+".fai"}:(i[c]=h,i.reference=void 0):(c==="reference"&&(i.genome=void 0),i[c]=h),r=n+1):r++;if(d){i.tracks||(i.tracks=[]);for(let p=0;p<d.length;p++){if(d[p].endsWith(".xml")||d[p].endsWith(".json")){i.sessionURL=d[p];break}const m={url:d[p]};u&&u.length>p&&(m.indexURL=u[p]),f&&f.length>p&&(m.name=f[p]),i.tracks.push(m)}}return s}async function GZ(i,e){return await Dc.prototype.createTrack.call(e,i)}const WZ=Ee.setApiKey;function QZ(i){return Ee.setOauthToken(i)}function KZ(i,e){return Ee.setOauthToken(i,e)}const YZ=Ee.oauth;var XZ={AlertDialog:e2,TrackUtils:xj,IGVGraphics:ge,MenuUtils:Q_,DataRangeDialog:K_,createTrack:GZ,createBrowser:$Z,removeBrowser:UZ,removeAllBrowsers:VZ,visibilityChange:jZ,setGoogleOauthToken:QZ,setOauthToken:KZ,oauth:YZ,version:FA,setApiKey:WZ,TrackBase:Qt,registerTrackClass:mX,registerTrackCreatorFunction:bX,registerFileFormats:HH,loadSessionFile:Dc.loadSessionFile,loadHub:fu};class ZZ extends Error{}class JZ{constructor(e=1e3,t=!1){xe(this,"throttlePeriod");xe(this,"rejectSkipped");xe(this,"queuedPromises",{});xe(this,"pendingPromise",!1);this.throttlePeriod=e,this.rejectSkipped=t}skipPromise(e){if(!this.rejectSkipped)return;const t=this.queuedPromises[e];t==null||t.reject(new ZZ)}async enqueue(e,t,r=0){return new Promise((n,o)=>{this.skipPromise(r),this.queuedPromises[r]={action:e,arg:t,resolve:n,reject:o},this.dequeue()})}async dequeue(){const e=Object.keys(this.queuedPromises);if(!this.pendingPromise&&e.length>0){const t=e[0],r=this.queuedPromises[t];delete this.queuedPromises[t],this.pendingPromise=!0;try{const n=await r.action(r.arg);r.resolve(n)}catch(n){r.reject(n)}finally{setTimeout(()=>{this.pendingPromise=!1,this.dequeue()},this.throttlePeriod)}}}}const Uy={"2bit":{type:"sequence"},bam:{type:"alignment",index:"bam_index"},bcf:{type:"variant"},bed:{type:"annotation"},bedgraph:{type:"wig"},bigbed:{type:"annotation"},bigwig:{type:"wig"},broadpeak:{type:"annotation"},bw:{type:"wig"},cram:{type:"alignment",index:"cram_index"},fa:{type:"sequence"},fasta:{type:"sequence"},gff:{type:"annotation"},gff3:{type:"annotation"},gtf:{type:"annotation"},narrowpeak:{type:"annotation"},vcf:{type:"variant"},vcf_bgzip:{type:"variant",index:"tabix_index"},wig:{type:"wig"}},eJ={class:"h-screen overflow-auto"},tJ={key:0,class:"bg-sky-100 border border-sky-200 p-1 rounded text-sky-800 text-sm"},iJ="annotation",rJ=500,nJ=Re({__name:"Plugin",props:{datasetId:{},datasetUrl:{},root:{},settings:{},specs:{},tracks:{}},setup(i){const e=new JZ(rJ),t=i,r=de(""),n=de(null),o=de(null),s=de([]),a=de(null);let l=null,c=[];xi(()=>{h()}),Ri(()=>{l&&typeof l.dispose=="function"&&l.dispose()}),st(()=>t,()=>{var C,x;n.value=(C=t.settings)==null?void 0:C.locus,o.value=(x=t.settings)==null?void 0:x.genome},{deep:!0,immediate:!0}),st(()=>t.tracks,()=>e.enqueue(S,void 0,"tracksParse"),{deep:!0,immediate:!0}),st(()=>o.value,()=>e.enqueue(p,void 0,"loadGenome")),st(()=>n.value,()=>e.enqueue(m,void 0,"locusSearch")),st(()=>s.value,()=>e.enqueue(F,void 0,"tracksLoad"),{deep:!0});async function h(){try{l=await XZ.createBrowser(a.value,{genome:o.value}),await F(!0),await m();const C=l.root.querySelector(".igv-navbar");C&&Object.assign(C.style,{flexFlow:"column",height:"unset",paddingBottom:"3px"})}catch(C){r.value="Failed to create browser",console.error(r.value,C)}}async function d(C){try{const{data:x}=await Ha().GET(`/api/datasets/${C}`);return x.extension}catch(x){return r.value=`Failed to retrieve dataset type for: ${C}`,console.error(r.value,x),null}}function u(C){return`${t.root}api/datasets/${C}/display`}function f(C,x){var y;const I=x?(y=Uy[x])==null?void 0:y.index:null;return I?`${t.root}api/datasets/${C}/metadata_file?metadata_file=${I}`:null}async function p(){if(l){try{await l.loadGenome({genome:o.value}),await F(!0),r.value=""}catch(C){r.value="Failed to load genome",console.error(r.value,o.value,C)}await m()}}async function m(){if(l){if(!n.value)await l.search("all");else if(v(n.value))try{await l.search(n.value)}catch{console.warn("[IGV] Invalid locus ignored:",n.value)}}else r.value="Failed to search.",console.error("[IGV] Browser not available.")}function v(C){const x=/^[\w.-]+$/,I=/^[\w.-]+:\d{1,3}(,\d{3})*-\d{1,3}(,\d{3})*$/;return x.test(C)||I.test(C)}function g(C){const x=Object.keys(C).sort(),I=JSON.stringify(C,x);let y=2166136261;for(let A=0;A<I.length;A++)y^=I.charCodeAt(A),y+=(y<<1)+(y<<4)+(y<<7)+(y<<8)+(y<<24);return(y>>>0).toString(36)}function b(C){const x=C==null?void 0:C.toLowerCase();if(x){const I=Uy[x];if(I!=null&&I.type)return I.type}return iJ}function w(C,x,I=!1){const y=new Map(x.map(T=>[T.name,T])),A=x.filter(T=>{const R=C.find(N=>N.name===T.name);return I||!R||g(R)!==g(T)});return{toAdd:C.filter(T=>{const R=y.get(T.name);return I||!R||g(T)!==g(R)}),toRemove:A}}async function F(C=!1){if(l){const x=E(s.value);console.debug("[IGV] Resolved Tracks",x);const{toAdd:I,toRemove:y}=w(x,c,C);for(const A of y){const _=l.trackViews.find(T=>T.track.name===A.name);_&&(console.debug(`[IGV] Removing existing track '${_.track.name}'`),l.removeTrack(_.track))}for(const A of I)try{console.debug(`[IGV] Adding new track '${A.name}'`),await l.loadTrack(A)}catch(_){console.error(`[IGV] Failed to load track '${A.name}'`,_)}l.reorderTracks(),c=x.map(A=>({...A}))}}async function S(){const C=[];if(t.tracks)for(const x of t.tracks){const I=x.urlDataset,y=x.displayMode,A=x.color,_=I?await d(I.id):null,T=x.indexUrlDataset,R=x.name,N=x.type&&x.type!=="auto"?x.type:b(_),P=I?u(I.id):null,z=T?u(T.id):f(I==null?void 0:I.id,_),V={color:A,displayMode:y,format:_,indexURL:z,name:R,type:N,url:P};console.debug("[IGV] Track:",V),C.push(V)}s.value=C}function E(C){const x=new Set,I=new Map,y=[];return C.forEach((A,_)=>{const T=A.name||`track-${g(A)}`,R=JSON.stringify({...A,name:T}),N=typeof(A==null?void 0:A.url)=="string"&&A.url.trim().length>0,P=x.has(R);if(N&&!P){const z=I.get(T)??0;let V=T;z>0&&(V=`${T} ~ ${z}`),I.set(T,z+1),x.add(R),y.push({...A,name:V,order:_})}else console.warn(N?`[IGV] Duplicate track skipped: '${T}'`:`[IGV] Invalid track skipped: '${T}'`)}),y}return(C,x)=>(He(),gt("div",eJ,[r.value?(He(),gt("div",tJ,On(r.value),1)):tr("",!0),tt("div",{ref_key:"viewport",ref:a},null,512)]))}}),oJ=Re({__name:"App",props:{container:{},credentials:{},incoming:{}},setup(i){return(e,t)=>(He(),jt($e(rz),{container:e.container,credentials:e.credentials,incoming:e.incoming},{default:ft(({datasetId:r,datasetUrl:n,root:o,settings:s,specs:a,tracks:l})=>[Ve(nJ,{"dataset-id":r,"dataset-url":n,root:o,settings:s,specs:a,tracks:l},null,8,["dataset-id","dataset-url","root","settings","specs","tracks"])]),_:1},8,["container","credentials","incoming"]))}});async function sJ(){var o;const e=new URL(import.meta.url).searchParams.get("container")||"app",t=document.getElementById(e),r=JSON.parse(t.dataset.incoming),n=(o=r==null?void 0:r.visualization_config)==null?void 0:o.dataset_id;n?(r.visualization_config.tracks||[]).length===0&&(r.visualization_config.tracks=[{urlDataset:{id:n,name:"Selected History Dataset"}}],console.debug(`[IGV] Populated incoming dataset ${n}.`),t.setAttribute("data-incoming",JSON.stringify(r))):console.error("[IGV] No dataset id available."),R9({render:()=>L(oJ,{container:e,credentials:"include"})}).mount(`#${e}`)}sJ();
|