Skip to content

Commit

Permalink
Merge pull request #322 from eweitz/fix-exon-utr-overlap
Browse files Browse the repository at this point in the history
Fix CDS size when on same exon as 3'-UTR
  • Loading branch information
eweitz authored Nov 6, 2022
2 parents 0937741 + 3a224dd commit 07744dd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/js/kit/gene-structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,25 @@ function spliceOut(subparts) {
const subpart = subparts[i];
const [subpartType, start, length] = subpart;
const isSpliceOverlap = start === prevStart;
const isOtherOverlap = i > 0 && start === subparts[i - 1][1];
let prevRawStart, prevRawLength;
if (i > 0) {
[, prevRawStart, prevRawLength] = subparts[i - 1];
}

// e.g. 5'-UTRs of OXTR
const isOtherOverlap = i > 0 && start === prevRawStart;

// e.g. 3'-UTR of LDLR, or 3'-UTR of CD44
const isOther3UTROverlap = i > 0 && start <= prevRawStart + prevRawLength;

let splicedStart;
if (isSpliceOverlap) {
splicedStart = start;
} else if (isOtherOverlap) {
// e.g. 5'-UTRs of OXTR
splicedStart = prevStart;
} else if (isOther3UTROverlap) {
splicedStart = prevStart + prevRawLength - length;
} else {
splicedStart = prevEnd;
}
Expand Down
19 changes: 19 additions & 0 deletions test/offline/gene-structure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ describe('Ideogram gene structure functionality', function() {
const subparts = document.querySelectorAll('rect.subpart');
assert.equal(subparts.length, 10); // includes introns

setTimeout(async function() {
// The last exon of gene LDLR includes both CDS and 3'-UTR
// There was a bug (see commit 7a43ba0) that caused drastically
// longer apparent CDS in these cases, whereas correct display
// has a relatively very small CDS compared to 3'-UTR.
const ldlrLabel = document.querySelector('#ideogramLabel__c18_a0');
ldlrLabel.dispatchEvent(new Event('mouseover'));

const lastExon = subparts[18];
const threePrimeUtr = subparts[19];

assert.equal(Math.round(lastExon.x.baseVal.value), 127);
assert.equal(Math.round(lastExon.width.baseVal.value), 123);

assert.equal(Math.round(threePrimeUtr.x.baseVal.value), 129);
assert.equal(Math.round(threePrimeUtr.width.baseVal.value), 121);

}, 500);

done();
}, 500);
}
Expand Down

0 comments on commit 07744dd

Please # to comment.