Skip to content

Commit

Permalink
default chrom alias unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Nov 7, 2024
1 parent 80fb505 commit ccabeff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
40 changes: 12 additions & 28 deletions js/genome/chromAliasDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class ChromAliasDefaults {
continue;
}

let skipRest = false
const record = {chr: name}
aliasRecords.push(record)

Expand All @@ -66,38 +65,43 @@ class ChromAliasDefaults {
record["ncbi-gi"] = alias
}
} else {

if (name === "chrM") {
record["ncbi"] = "MT"
} else if (name === "MT") {
record["ucsc"] = "chrM"
} else if (name.toLowerCase().startsWith("chr") && Number.isInteger(Number(name.substring(3)))) {
record["ncbi"] = name.substring(3)
} else if (Number.isInteger(Number(name))) {
record["ucsc"] = "chr" + name
}

// 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"
record["assembly"] = "X"
skipRest = true
break
case "24":
record["ucsc"] = "chrY"
record["assembly"] = "Y"
skipRest = true
break
case "chrX":
record["ncbi"] = "23"
record["assembly"] = "X"
skipRest = true
break
case "chrY":
record["ncbi"] = "24"
record["assembly"] = "y"
skipRest = true
record["assembly"] = "Y"
break
case "X":
record["ucsc"] = "chrX"
record["ncbi"] = "23"
skipRest = true
break
case "Y":
record["ucsc"] = "chrY"
record["ncbi"] = "24"
skipRest = true
break

}
Expand All @@ -106,50 +110,30 @@ class ChromAliasDefaults {
case "21":
record["ucsc"] = "chrX"
record["assembly"] = "X"
skipRest = true
break
case "22":
record["ucsc"] = "chrY"
record["assembly"] = "Y"
skipRest = true
break
case "chrX":
record["ncbi"] = "21"
record["assembly"] = "X"
skipRest = true
break
case "chrY":
record["ncbi"] = "22"
record["assembly"] = "Y"
skipRest = true
break
case "X":
record["ucsc"] = "chrX"
record["ncbi"] = "21"
skipRest = true
break
case "Y":
record["ucsc"] = "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
}


}
}

Expand Down
5 changes: 3 additions & 2 deletions test/testChromAlias.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ suite("chromAlias", function () {
assert.equal(chromAlias.getChromosomeName("23"), "chrX")
assert.equal(chromAlias.getChromosomeName("MT"), "chrM")

// Defaults don't support name sets,
assert.equal(chromAlias.getChromosomeAlias("NC_007194.1", "genbank"), "NC_007194.1")
// Other
assert.equal(chromAlias.getChromosomeName("X"), "chrX")
assert.equal(chromAlias.getChromosomeName("Y"), "chrY")

})
})

0 comments on commit ccabeff

Please sign in to comment.