-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* misc bug fixes * hub updates * fix unit test
- Loading branch information
Showing
17 changed files
with
335 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>twobit</title> | ||
</head> | ||
|
||
<body> | ||
|
||
<select id="select"> | ||
<option value=""></option> | ||
<option value="gorGor4">gorGor4</option> | ||
<option value="gorGor6">gorGor6</option> | ||
</select> | ||
<button id="load-genome">Load genome</button> | ||
<br> | ||
|
||
|
||
<div id="igvDiv" style="padding-top: 50px;padding-bottom: 20px; height: auto"></div> | ||
|
||
<script type="module"> | ||
|
||
import igv from "../../js/index.js" | ||
import Hub from "../../js/ucsc/ucscHub.js" | ||
|
||
|
||
const igvConfig = { | ||
genome: "gorGor4", | ||
listeners: { | ||
'genomechange': ({genome, trackConfigurations}) => { | ||
console.log('genomechange') | ||
console.log(genome) | ||
console.log(trackConfigurations) | ||
} | ||
} | ||
} | ||
|
||
|
||
const browser = await igv.createBrowser(document.getElementById('igvDiv'), igvConfig) | ||
|
||
document.getElementById("load-genome").addEventListener("click", async () => { | ||
await browser.loadGenome(document.getElementById("select").value) | ||
}) | ||
|
||
|
||
</script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/** | ||
* Default chromosome aliases, mostly 1<->chr1 etc. Used if chrom alias file is not supplied. | ||
* | ||
*/ | ||
import {isNumber, buildOptions} from "../util/igvUtils.js" | ||
import {igvxhr, StringUtils} from "../../node_modules/igv-utils/src/index.js" | ||
|
||
class ChromAliasDefaults { | ||
|
||
aliasRecordCache = new Map() | ||
|
||
constructor(id, chromosomeNames) { | ||
this.init(id, chromosomeNames) | ||
} | ||
|
||
/** | ||
* Return the canonical chromosome name for the alias. If none found return the alias | ||
* | ||
* @param alias | ||
* @returns {*} | ||
*/ | ||
getChromosomeName(alias) { | ||
return this.aliasRecordCache.has(alias) ? this.aliasRecordCache.get(alias).chr : alias | ||
} | ||
|
||
/** | ||
* Return an alternate chromosome name (alias). | ||
* | ||
* @param chr | ||
* @param nameSet -- The name set, e.g. "ucsc" | ||
* @returns {*|undefined} | ||
*/ | ||
getChromosomeAlias(chr, nameSet) | ||
{ | ||
const aliasRecord = this.aliasRecordCache.get(chr) | ||
return aliasRecord ? aliasRecord[nameSet] || chr : chr | ||
} | ||
|
||
init(id, chromosomeNames) { | ||
|
||
const aliasRecords = [] | ||
for (let name of chromosomeNames) { | ||
|
||
let skipRest = false | ||
const record = {chr: name} | ||
aliasRecords.push(record) | ||
|
||
if (name.startsWith("gi|")) { | ||
// NCBI | ||
const alias = ChromAliasDefaults.getNCBIName(name) | ||
record["ncbi-gi-versioned"] = alias | ||
|
||
// Also strip version number out, if present | ||
const dotIndex = alias.lastIndexOf('.') | ||
if (dotIndex > 0) { | ||
const alias = alias.substring(0, dotIndex) | ||
record["ncbi-gi"] = alias | ||
} | ||
} else { | ||
// Special cases for human and mouse | ||
if (id.startsWith("hg") || id.startsWith("GRCh") || id === "1kg_ref" || id === "b37") { | ||
switch (name) { | ||
case "23": | ||
record["ucsc"] = "chrX" | ||
skipRest = true | ||
break | ||
case "24": | ||
record["ucsc"] = "chrY" | ||
skipRest = true | ||
break | ||
case "chrX": | ||
record["ncbi"] = "23" | ||
skipRest = true | ||
break | ||
case "chrY": | ||
record["ncbi"] = "24" | ||
skipRest = true | ||
break | ||
} | ||
} else if (id.startsWith("mm") || id.startsWith("GRCm") || id.startsWith("rheMac")) { | ||
switch (name) { | ||
case "21": | ||
record["ucsc"] = "chrX" | ||
skipRest = true | ||
break | ||
case "22": | ||
record["ucsc"] = "chrY" | ||
skipRest = true | ||
break | ||
case "chrX": | ||
record["ncbi"] = "21" | ||
skipRest = true | ||
break | ||
case "chrY": | ||
record["ncbi"] = "22" | ||
skipRest = true | ||
break | ||
} | ||
} | ||
if (skipRest) continue | ||
|
||
// | ||
if (name === "chrM") { | ||
record["ncbi"] = "MT" | ||
} else if (name === "MT") { | ||
record["ucsc"] = "chrM" | ||
} else if (name.toLowerCase().startsWith("chr")) { | ||
record["ncbi"] = name.substring(3) | ||
} else if (Number.isInteger(Number(name))) { | ||
record["ucsc"] = "chr" + name | ||
} | ||
} | ||
} | ||
|
||
for (let rec of aliasRecords) { | ||
for (let a of Object.values(rec)) { | ||
this.aliasRecordCache.set(a, rec) | ||
} | ||
} | ||
} | ||
|
||
search(alias) { | ||
return this.aliasRecordCache.get(alias) | ||
|
||
} | ||
|
||
/** | ||
* Extract the user friendly name from an NCBI accession | ||
* example: gi|125745044|ref|NC_002229.3| => NC_002229.3 | ||
*/ | ||
static getNCBIName(name) { | ||
const tokens = name.split("\\|") | ||
return tokens[tokens.length - 1] | ||
} | ||
|
||
} | ||
|
||
export default ChromAliasDefaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.