Skip to content

Commit

Permalink
Merge branch 'master' into share_url_edits
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso authored Jul 12, 2024
2 parents c96966e + de80176 commit fe9f249
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 31 deletions.
4 changes: 1 addition & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,11 @@
Load URL ...
</button>

<!-- Session List -->
<div id="igv-session-list-divider" class="dropdown-divider"></div>

<div class="dropdown-divider"></div>

<!-- Save local session file -->
<button class="dropdown-item" type="button" data-toggle="modal"
id="save-session-button"
data-target="#igv-app-session-save-modal">
Save ...
</button>
Expand Down
73 changes: 56 additions & 17 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ import * as GooglePicker from '../node_modules/google-utils/src/googleFilePicker
import makeDraggable from "./widgets/utils/draggable.js"
import AlertSingleton from "./widgets/alertSingleton.js"
import {createSessionWidgets} from "./widgets/sessionWidgets.js"
import {updateTrackMenusWithTrackConfigurations, createTrackWidgetsWithTrackRegistry, getPathsWithTrackRegistryFile} from "./widgets/trackWidgets.js"
import {dropboxDropdownItem, dropboxButtonImageBase64, googleDriveButtonImageBase64, googleDriveDropdownItem} from "./widgets/markupFactory.js"
import {
updateTrackMenusWithTrackConfigurations,
createTrackWidgetsWithTrackRegistry,
getPathsWithTrackRegistryFile
} from "./widgets/trackWidgets.js"
import {
dropboxDropdownItem,
dropboxButtonImageBase64,
googleDriveButtonImageBase64,
googleDriveDropdownItem
} from "./widgets/markupFactory.js"
import GenomeFileLoad from "./widgets/genomeFileLoad.js"
import FileLoadManager from "./widgets/fileLoadManager.js"
import FileLoadWidget from "./widgets/fileLoadWidget.js"
Expand Down Expand Up @@ -294,7 +303,7 @@ async function initializationHelper(browser, container, options) {
sessionSaver)

if (options.sessionRegistryFile) {
await createSessionMenu('igv-session-list-divider', options.sessionRegistryFile, sessionLoader)
await createSessionMenu('save-session-button', options.sessionRegistryFile, sessionLoader)
} else {
document.querySelector('#igv-session-list-divider').style.display = 'none'
}
Expand Down Expand Up @@ -393,7 +402,9 @@ function createSampleInfoMenu(igvMain,
{
success: dbFiles => {

const configList = dbFiles.map(({link}) => { return {url: link} })
const configList = dbFiles.map(({link}) => {
return {url: link}
})

sampleInfoFileLoadHandler(configList[0])
},
Expand Down Expand Up @@ -480,7 +491,7 @@ function createSampleInfoMenu(igvMain,

Utils.configureModal(fileLoadWidget, urlModal, async fileLoadWidget => {
const paths = fileLoadWidget.retrievePaths()
await sampleInfoFileLoadHandler({url:paths[0]})
await sampleInfoFileLoadHandler({url: paths[0]})
return true
})

Expand Down Expand Up @@ -555,33 +566,61 @@ async function createSessionMenu(sessionListDivider, sessionRegistryFile, sessio
if (sessionJSON) {

const sessions = sessionJSON['sessions']

for (let {name, url} of sessions.reverse()) {

const referenceNode = document.getElementById(sessionListDivider)

const button_id = `${id_prefix}_${guid()}`
const html = `<button id="${button_id}" class="dropdown-item" type="button">${name}</button>`
const fragment = document.createRange().createContextualFragment(html)
if (url) {
const button_id = `${id_prefix}_${guid()}`
const html = `<button id="${button_id}" class="dropdown-item" type="button">${name}</button>`
const fragment = document.createRange().createContextualFragment(html)

referenceNode.after(fragment.firstChild)
referenceNode.after(fragment.firstChild)

const button = document.getElementById(button_id)
button.addEventListener('click', () => {
const button = document.getElementById(button_id)
button.addEventListener('click', () => {

const config = {}
const key = true === isFile(url) ? 'file' : 'url'
config[key] = url
const config = {}
const key = true === isFile(url) ? 'file' : 'url'
config[key] = url

sessionLoader(config)
sessionLoader(config)

})
})
} else {
const html = `<h6 class="dropdown-header">${name}</h6>`
const el = fromHTML(html)
referenceNode.after(el)
referenceNode.after(fromHTML('<div class="dropdown-divider"/>'))
}
}

}

}

/**
* @param {String} HTML representing a single element.
* @param {Boolean} flag representing whether or not to trim input whitespace, defaults to true.
* @return {Element | HTMLCollection | null}
*/
function fromHTML(html, trim = true) {
// Process the HTML string.
html = trim ? html.trim() : html
if (!html) return null

// Then set up a new template element.
const template = document.createElement('template')
template.innerHTML = html
const result = template.content.children

// Then return either an HTMLElement or HTMLCollection,
// based on whether the input HTML had one or more roots.
if (result.length === 1) return result[0]
return result
}

function createAppBookmarkHandler($bookmark_button) {

$bookmark_button.on('click', (e) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"fs-extra": "^8.1.0",
"igv": "github:igvteam/igv.js#master",
"data-modal": "github:igvteam/data-modal#v1.5.0",
"igv-utils": "github:igvteam/igv-utils#v1.5.4",
"igv-utils": "github:igvteam/igv-utils#v1.5.8",
"google-utils": "github:igvteam/google-utils#v1.0.2",
"rollup": "^2.28.1",
"rollup-plugin-copy": "^3.3.0",
Expand Down
25 changes: 25 additions & 0 deletions resources/sessions/1kg-variants-session.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"genome": "hg38",
"locus": "chr22:36,655,100-36,656,016",
"sampleinfo": [
{
"url": "https://igv-genepattern-org.s3.amazonaws.com/demo/integrated_call_samples_v3.20130502.ALL.panel"
}
],
"tracks": [
{
"url": "https://igv-genepattern-org.s3.amazonaws.com/demo/ALL.apol1.sample.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz",
"name": "1KG Variants",
"format": "vcf",
"type": "variant",
"height": 700,
"sort": {
"option": "ATTRIBUTE",
"attribute": "pop",
"direction": "ASC"
},
"order": 1,
"displayMode": "SQUISHED"
}
]
}
38 changes: 38 additions & 0 deletions resources/sessions/6mA_pacbio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"genome": "hg38",
"locus": "chr11:119094729-119094804",
"tracks": [
{
"type": "alignment",
"format": "bam",
"url": "https://igv-genepattern-org.s3.amazonaws.com/test/baseMods/6mA/pacbio/HG002_chr11_119076212_119102218.bam",
"indexURL": "https://igv-genepattern-org.s3.amazonaws.com/test/baseMods/6mA/pacbio/HG002_chr11_119076212_119102218.bam.bai",
"height": 300,
"name": "Base modifications",
"colorBy": "basemod",
"groupBy": "strand"
},
{
"type": "alignment",
"format": "bam",
"url": "https://igv-genepattern-org.s3.amazonaws.com/test/baseMods/6mA/pacbio/HG002_chr11_119076212_119102218.bam",
"indexURL": "https://igv-genepattern-org.s3.amazonaws.com/test/baseMods/6mA/pacbio/HG002_chr11_119076212_119102218.bam.bai",
"height": 300,
"name": "Base modifications - 2 Color",
"colorBy": "basemod2",
"groupBy": "strand",
"baseModificationThreshold": 0
},
{
"type": "alignment",
"format": "bam",
"url": "https://igv-genepattern-org.s3.amazonaws.com/test/baseMods/6mA/pacbio/HG002_chr11_119076212_119102218.bam",
"indexURL": "https://igv-genepattern-org.s3.amazonaws.com/test/baseMods/6mA/pacbio/HG002_chr11_119076212_119102218.bam.bai",
"height": 300,
"name": "5mC modifications - 2 Color",
"colorBy": "basemod2:m",
"groupBy": "strand",
"baseModificationThreshold": 0
}
]
}
25 changes: 25 additions & 0 deletions resources/sessions/gbm-copynumber.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"genome": "hg38",
"locus": "chr7:52,338,217-57,756,711",
"sampleinfo": [
{
"url": "https://igv-genepattern-org.s3.amazonaws.com/demo/GBM-sampletable-samplemapping-colors.txt"
}
],
"tracks": [
{
"url": "https://igv-genepattern-org.s3.amazonaws.com/demo/GBMCopyNumber.seg.gz",
"name": "GBM Copy Number",
"order": 1,
"format": "seg",
"type": "seg",
"height": 400,
"displayMode": "SQUISHED",
"sort": {
"option": "ATTRIBUTE",
"attribute": "Subtype",
"direction": "ASC"
}
}
]
}
34 changes: 24 additions & 10 deletions resources/sessions/sessionRegistry.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
{
"sessions": [
{
"name": "Examples - Sample Information"
},
{
"name": "Segmented Copy Number",
"description": "Segmented copy number for TCGA GBM data",
"url": "resources/sessions/gbm-copynumber.json"
},
{
"name": "1KG Variants",
"description": "1000 genomes variants",
"url": "resources/sessions/1kg-variants-session.json"
},
{
"name": "Examples - Base Modifications"
},
{
"name": "5mC and 6mA Modifications",
"description": "5mC and 6mA Modifications",
"url": "resources/sessions/6mA_pacbio.json"
},
{
"name": "Examples - Circular View"
},
{
"name": "SKBR3 - Illumina (Schatz)",
"description": "SKBR3 - Illumina (Schatz)",
Expand All @@ -9,16 +33,6 @@
"name": "SKBR3 - Pacbio (Schatz)",
"description": "SKBR3 - Pacbio (Schatz)",
"url": "resources/sessions/SKBR3-pacbio-session.json"
},
{
"name": "SKBR3 - Sniffles and Delly VCF (Schatz)",
"description": "SKBR3 - Sniffles and Delly VCF (Schatz)",
"url": "resources/sessions/SKBR3-vcf-session.json"
},
{
"name": "ChIA-Pet - Wei lab GSM3553630",
"description": "ChIA-Pet - Wei lab GSM3553630",
"url": "resources/sessions/ChIA-Pet-GSM3553630.json"
}
]
}

0 comments on commit fe9f249

Please sign in to comment.