From a386d3ff5de25d9c765605f2449726ef4d0e9763 Mon Sep 17 00:00:00 2001 From: Colin Diesh Date: Tue, 2 Jan 2024 14:18:12 -0500 Subject: [PATCH] Fix subfeature refNames on BED and BEDTabix parsers (#4158) --- .../__snapshots__/BedAdapter.test.ts.snap | 23 +++++++++++++++++++ .../BedTabixAdapter.test.ts.snap | 23 +++++++++++++++++++ .../__snapshots__/BigBedAdapter.test.ts.snap | 22 ++++++++++++++++++ plugins/bed/src/util.ts | 22 ++++++++++++++++-- 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/plugins/bed/src/BedAdapter/__snapshots__/BedAdapter.test.ts.snap b/plugins/bed/src/BedAdapter/__snapshots__/BedAdapter.test.ts.snap index 2f5f70a16d..3582b841c8 100644 --- a/plugins/bed/src/BedAdapter/__snapshots__/BedAdapter.test.ts.snap +++ b/plugins/bed/src/BedAdapter/__snapshots__/BedAdapter.test.ts.snap @@ -112,6 +112,7 @@ exports[`adapter can fetch features bed with autosql 1`] = ` { "end": 2, "parentId": "test-ctgA-0", + "refName": "ctgA", "start": 1, "strand": 0, "type": "three_prime_UTR", @@ -215,6 +216,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 1200, "parentId": "test-ctgA-0", + "refName": "ctgA", "start": 1049, "strand": 1, "type": "five_prime_UTR", @@ -223,6 +225,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 1500, "parentId": "test-ctgA-0", + "refName": "ctgA", "start": 1200, "strand": 1, "type": "CDS", @@ -231,6 +234,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 3902, "parentId": "test-ctgA-0", + "refName": "ctgA", "start": 2999, "strand": 1, "type": "CDS", @@ -239,6 +243,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 5500, "parentId": "test-ctgA-0", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -247,6 +252,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 7608, "parentId": "test-ctgA-0", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -255,6 +261,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 9000, "parentId": "test-ctgA-0", + "refName": "ctgA", "start": 7608, "strand": 1, "type": "three_prime_UTR", @@ -276,6 +283,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 1200, "parentId": "test-ctgA-1", + "refName": "ctgA", "start": 1049, "strand": 1, "type": "five_prime_UTR", @@ -284,6 +292,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 1500, "parentId": "test-ctgA-1", + "refName": "ctgA", "start": 1200, "strand": 1, "type": "CDS", @@ -292,6 +301,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 5500, "parentId": "test-ctgA-1", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -300,6 +310,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 7608, "parentId": "test-ctgA-1", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -308,6 +319,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 9000, "parentId": "test-ctgA-1", + "refName": "ctgA", "start": 7608, "strand": 1, "type": "three_prime_UTR", @@ -329,6 +341,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 1500, "parentId": "test-ctgA-2", + "refName": "ctgA", "start": 1299, "strand": 1, "type": "five_prime_UTR", @@ -337,6 +350,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 3300, "parentId": "test-ctgA-2", + "refName": "ctgA", "start": 2999, "strand": 1, "type": "five_prime_UTR", @@ -345,6 +359,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 3902, "parentId": "test-ctgA-2", + "refName": "ctgA", "start": 3300, "strand": 1, "type": "CDS", @@ -353,6 +368,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 5500, "parentId": "test-ctgA-2", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -361,6 +377,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 7600, "parentId": "test-ctgA-2", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -369,6 +386,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 9000, "parentId": "test-ctgA-2", + "refName": "ctgA", "start": 7600, "strand": 1, "type": "three_prime_UTR", @@ -390,6 +408,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 17999, "parentId": "test-ctgA-3", + "refName": "ctgA", "start": 17399, "strand": 1, "type": "five_prime_UTR", @@ -398,6 +417,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 18800, "parentId": "test-ctgA-3", + "refName": "ctgA", "start": 17999, "strand": 1, "type": "CDS", @@ -406,6 +426,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 19500, "parentId": "test-ctgA-3", + "refName": "ctgA", "start": 18999, "strand": 1, "type": "CDS", @@ -414,6 +435,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 21200, "parentId": "test-ctgA-3", + "refName": "ctgA", "start": 20999, "strand": 1, "type": "CDS", @@ -422,6 +444,7 @@ exports[`adapter can fetch features from volvox-bed12.bed 1`] = ` { "end": 23000, "parentId": "test-ctgA-3", + "refName": "ctgA", "start": 21200, "strand": 1, "type": "three_prime_UTR", diff --git a/plugins/bed/src/BedTabixAdapter/__snapshots__/BedTabixAdapter.test.ts.snap b/plugins/bed/src/BedTabixAdapter/__snapshots__/BedTabixAdapter.test.ts.snap index 81c018c932..41ad07f635 100644 --- a/plugins/bed/src/BedTabixAdapter/__snapshots__/BedTabixAdapter.test.ts.snap +++ b/plugins/bed/src/BedTabixAdapter/__snapshots__/BedTabixAdapter.test.ts.snap @@ -112,6 +112,7 @@ exports[`adapter can fetch features bed with autosql 1`] = ` { "end": 2, "parentId": "test-52986", + "refName": "ctgA", "start": 1, "strand": 0, "type": "three_prime_UTR", @@ -215,6 +216,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 1200, "parentId": "test-45690", + "refName": "ctgA", "start": 1049, "strand": 1, "type": "five_prime_UTR", @@ -223,6 +225,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 1500, "parentId": "test-45690", + "refName": "ctgA", "start": 1200, "strand": 1, "type": "CDS", @@ -231,6 +234,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 3902, "parentId": "test-45690", + "refName": "ctgA", "start": 2999, "strand": 1, "type": "CDS", @@ -239,6 +243,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 5500, "parentId": "test-45690", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -247,6 +252,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 7608, "parentId": "test-45690", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -255,6 +261,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 9000, "parentId": "test-45690", + "refName": "ctgA", "start": 7608, "strand": 1, "type": "three_prime_UTR", @@ -276,6 +283,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 1200, "parentId": "test-45787", + "refName": "ctgA", "start": 1049, "strand": 1, "type": "five_prime_UTR", @@ -284,6 +292,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 1500, "parentId": "test-45787", + "refName": "ctgA", "start": 1200, "strand": 1, "type": "CDS", @@ -292,6 +301,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 5500, "parentId": "test-45787", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -300,6 +310,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 7608, "parentId": "test-45787", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -308,6 +319,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 9000, "parentId": "test-45787", + "refName": "ctgA", "start": 7608, "strand": 1, "type": "three_prime_UTR", @@ -329,6 +341,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 1500, "parentId": "test-45875", + "refName": "ctgA", "start": 1299, "strand": 1, "type": "five_prime_UTR", @@ -337,6 +350,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 3300, "parentId": "test-45875", + "refName": "ctgA", "start": 2999, "strand": 1, "type": "five_prime_UTR", @@ -345,6 +359,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 3902, "parentId": "test-45875", + "refName": "ctgA", "start": 3300, "strand": 1, "type": "CDS", @@ -353,6 +368,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 5500, "parentId": "test-45875", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -361,6 +377,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 7600, "parentId": "test-45875", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -369,6 +386,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 9000, "parentId": "test-45875", + "refName": "ctgA", "start": 7600, "strand": 1, "type": "three_prime_UTR", @@ -390,6 +408,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 17999, "parentId": "test-45972", + "refName": "ctgA", "start": 17399, "strand": 1, "type": "five_prime_UTR", @@ -398,6 +417,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 18800, "parentId": "test-45972", + "refName": "ctgA", "start": 17999, "strand": 1, "type": "CDS", @@ -406,6 +426,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 19500, "parentId": "test-45972", + "refName": "ctgA", "start": 18999, "strand": 1, "type": "CDS", @@ -414,6 +435,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 21200, "parentId": "test-45972", + "refName": "ctgA", "start": 20999, "strand": 1, "type": "CDS", @@ -422,6 +444,7 @@ exports[`adapter can fetch features from volvox-bed12.bed.gz 1`] = ` { "end": 23000, "parentId": "test-45972", + "refName": "ctgA", "start": 21200, "strand": 1, "type": "three_prime_UTR", diff --git a/plugins/bed/src/BigBedAdapter/__snapshots__/BigBedAdapter.test.ts.snap b/plugins/bed/src/BigBedAdapter/__snapshots__/BigBedAdapter.test.ts.snap index 4667e1634e..57471ffacc 100644 --- a/plugins/bed/src/BigBedAdapter/__snapshots__/BigBedAdapter.test.ts.snap +++ b/plugins/bed/src/BigBedAdapter/__snapshots__/BigBedAdapter.test.ts.snap @@ -18,6 +18,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 1200, "parentId": "test-bb-358912", + "refName": "ctgA", "start": 1049, "strand": 1, "type": "five_prime_UTR", @@ -26,6 +27,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 1500, "parentId": "test-bb-358912", + "refName": "ctgA", "start": 1200, "strand": 1, "type": "CDS", @@ -34,6 +36,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 3902, "parentId": "test-bb-358912", + "refName": "ctgA", "start": 2999, "strand": 1, "type": "CDS", @@ -42,6 +45,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 5500, "parentId": "test-bb-358912", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -50,6 +54,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 7608, "parentId": "test-bb-358912", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -58,6 +63,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 9000, "parentId": "test-bb-358912", + "refName": "ctgA", "start": 7608, "strand": 1, "type": "three_prime_UTR", @@ -84,6 +90,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 1200, "parentId": "test-bb-359006", + "refName": "ctgA", "start": 1049, "strand": 1, "type": "five_prime_UTR", @@ -92,6 +99,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 1500, "parentId": "test-bb-359006", + "refName": "ctgA", "start": 1200, "strand": 1, "type": "CDS", @@ -100,6 +108,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 5500, "parentId": "test-bb-359006", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -108,6 +117,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 7608, "parentId": "test-bb-359006", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -116,6 +126,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 9000, "parentId": "test-bb-359006", + "refName": "ctgA", "start": 7608, "strand": 1, "type": "three_prime_UTR", @@ -142,6 +153,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 1500, "parentId": "test-bb-359091", + "refName": "ctgA", "start": 1299, "strand": 1, "type": "five_prime_UTR", @@ -150,6 +162,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 3300, "parentId": "test-bb-359091", + "refName": "ctgA", "start": 2999, "strand": 1, "type": "five_prime_UTR", @@ -158,6 +171,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 3902, "parentId": "test-bb-359091", + "refName": "ctgA", "start": 3300, "strand": 1, "type": "CDS", @@ -166,6 +180,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 5500, "parentId": "test-bb-359091", + "refName": "ctgA", "start": 4999, "strand": 1, "type": "CDS", @@ -174,6 +189,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 7600, "parentId": "test-bb-359091", + "refName": "ctgA", "start": 6999, "strand": 1, "type": "CDS", @@ -182,6 +198,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 9000, "parentId": "test-bb-359091", + "refName": "ctgA", "start": 7600, "strand": 1, "type": "three_prime_UTR", @@ -208,6 +225,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 17999, "parentId": "test-bb-359185", + "refName": "ctgA", "start": 17399, "strand": 1, "type": "five_prime_UTR", @@ -216,6 +234,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 18800, "parentId": "test-bb-359185", + "refName": "ctgA", "start": 17999, "strand": 1, "type": "CDS", @@ -224,6 +243,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 19500, "parentId": "test-bb-359185", + "refName": "ctgA", "start": 18999, "strand": 1, "type": "CDS", @@ -232,6 +252,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 21200, "parentId": "test-bb-359185", + "refName": "ctgA", "start": 20999, "strand": 1, "type": "CDS", @@ -240,6 +261,7 @@ exports[`adapter can fetch features from volvox.bb 1`] = ` { "end": 23000, "parentId": "test-bb-359185", + "refName": "ctgA", "start": 21200, "strand": 1, "type": "three_prime_UTR", diff --git a/plugins/bed/src/util.ts b/plugins/bed/src/util.ts index dc4024e613..dcfff210a0 100644 --- a/plugins/bed/src/util.ts +++ b/plugins/bed/src/util.ts @@ -1,11 +1,19 @@ import { SimpleFeature, Feature } from '@jbrowse/core/util' import BED from '@gmod/bed' +interface MinimalFeature { + type: string + start: number + end: number + refName: string +} + export function ucscProcessedTranscript(feature: Feature) { const children = feature.children() // split the blocks into UTR, CDS, and exons const thickStart = feature.get('thickStart') const thickEnd = feature.get('thickEnd') + const refName = feature.get('refName') if (!thickStart && !thickEnd) { return feature @@ -17,8 +25,7 @@ export function ucscProcessedTranscript(feature: Feature) { .sort((a, b) => a.get('start') - b.get('start')) : [] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const newChildren: Record = [] + const newChildren: MinimalFeature[] = [] blocks.forEach(block => { const start = block.get('start') const end = block.get('end') @@ -29,6 +36,7 @@ export function ucscProcessedTranscript(feature: Feature) { type: `${prime}_prime_UTR`, start, end, + refName, }) } else if (thickStart > start && thickStart < end && thickEnd >= end) { // UTR | CDS @@ -38,11 +46,13 @@ export function ucscProcessedTranscript(feature: Feature) { type: `${prime}_prime_UTR`, start, end: thickStart, + refName, }, { type: 'CDS', start: thickStart, end, + refName, }, ) } else if (thickStart <= start && thickEnd >= end) { @@ -51,6 +61,7 @@ export function ucscProcessedTranscript(feature: Feature) { type: 'CDS', start, end, + refName, }) } else if (thickStart > start && thickStart < end && thickEnd < end) { // UTR | CDS | UTR @@ -61,16 +72,19 @@ export function ucscProcessedTranscript(feature: Feature) { type: `${leftPrime}_prime_UTR`, start, end: thickStart, + refName, }, { type: `CDS`, start: thickStart, end: thickEnd, + refName, }, { type: `${rightPrime}_prime_UTR`, start: thickEnd, end, + refName, }, ) } else if (thickStart <= start && thickEnd > start && thickEnd < end) { @@ -81,11 +95,13 @@ export function ucscProcessedTranscript(feature: Feature) { type: `CDS`, start, end: thickEnd, + refName, }, { type: `${prime}_prime_UTR`, start: thickEnd, end, + refName, }, ) } else if (thickEnd <= start) { @@ -95,6 +111,7 @@ export function ucscProcessedTranscript(feature: Feature) { type: `${prime}_prime_UTR`, start, end, + refName, }) } }) @@ -158,6 +175,7 @@ export function featureData( uniqueId: `${uniqueId}-${b}`, start: bmin, end: bmax, + refName, type: 'block', }) }