Skip to content

Commit 81ebef5

Browse files
Use "transcript" instead of "mRNA" for base ontology term (#516)
* Use "transcript" instead of "mRNA" for base term * Remove console logs
1 parent 02cc945 commit 81ebef5

File tree

7 files changed

+51
-34
lines changed

7 files changed

+51
-34
lines changed

packages/apollo-mst/src/AnnotationFeatureModel.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,21 @@ export const AnnotationFeatureModel = types
134134
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
135135
const { featureTypeOntology } = apolloDataStore.ontologyManager
136136
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
137-
if (!featureTypeOntology.isTypeOf(self.type, 'mRNA')) {
137+
if (!featureTypeOntology.isTypeOf(self.type, 'transcript')) {
138138
throw new Error(
139-
'Only features of type "mRNA" or equivalent can calculate CDS locations',
139+
'Only features of type "transcript" or equivalent can calculate CDS locations',
140140
)
141141
}
142142
const children = self.children as Children
143143
if (!children) {
144-
throw new Error('no CDS or exons in mRNA')
144+
throw new Error('no CDS or exons in transcript')
145145
}
146146
const cdsChildren = [...children.values()].filter(
147147
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
148148
(child) => featureTypeOntology.isTypeOf(child.type, 'CDS'),
149149
)
150150
if (cdsChildren.length === 0) {
151-
throw new Error('no CDS in mRNA')
151+
throw new Error('no CDS in transcript')
152152
}
153153
const transcriptParts: TranscriptParts[] = []
154154
for (const cds of cdsChildren) {

packages/jbrowse-plugin-apollo/src/FeatureDetailsWidget/TranscriptBasic.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ export const TranscriptBasicInformation = observer(
8383
return null
8484
}
8585

86-
const { strand, transcriptParts } = feature
86+
let strand, transcriptParts
87+
try {
88+
;({ strand, transcriptParts } = feature)
89+
} catch {
90+
return null
91+
}
8792
const [firstLocation] = transcriptParts
8893

8994
const locationData = firstLocation

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/BoxGlyph.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,14 @@ function getContextMenuItems(
389389
},
390390
},
391391
)
392-
if (sourceFeature.type === 'mRNA' && isSessionModelWithWidgets(session)) {
392+
const { featureTypeOntology } = session.apolloDataStore.ontologyManager
393+
if (!featureTypeOntology) {
394+
throw new Error('featureTypeOntology is undefined')
395+
}
396+
if (
397+
featureTypeOntology.isTypeOf(sourceFeature.type, 'transcript') &&
398+
isSessionModelWithWidgets(session)
399+
) {
393400
menuItems.push({
394401
label: 'Edit transcript details',
395402
onClick: () => {

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/glyphs/GeneGlyph.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,22 @@ function draw(
110110
topLevelFeatureHeight,
111111
)
112112

113-
// Draw lines on different rows for each mRNA
113+
// Draw lines on different rows for each transcript
114114
let currentRow = 0
115-
for (const [, mrna] of children) {
116-
const isMrna = featureTypeOntology.isTypeOf(mrna.type, 'mRNA')
117-
if (!isMrna) {
115+
for (const [, transcript] of children) {
116+
const isTranscript = featureTypeOntology.isTypeOf(
117+
transcript.type,
118+
'transcript',
119+
)
120+
if (!isTranscript) {
118121
currentRow += 1
119122
continue
120123
}
121-
const { children: childrenOfmRNA, min } = mrna
122-
if (!childrenOfmRNA) {
124+
const { children: childrenOfTranscript, min } = transcript
125+
if (!childrenOfTranscript) {
123126
continue
124127
}
125-
for (const [, cds] of childrenOfmRNA) {
128+
for (const [, cds] of childrenOfTranscript) {
126129
if (!featureTypeOntology.isTypeOf(cds.type, 'CDS')) {
127130
continue
128131
}
@@ -132,7 +135,7 @@ function draw(
132135
coord: min,
133136
regionNumber: displayedRegionIndex,
134137
})?.offsetPx ?? 0) - offsetPx
135-
const widthPx = mrna.length / bpPerPx
138+
const widthPx = transcript.length / bpPerPx
136139
const startPx = reversed ? minX - widthPx : minX
137140
const height =
138141
Math.round((currentRow + 1 / 2) * rowHeight) + row * rowHeight
@@ -149,20 +152,20 @@ function draw(
149152
theme?.palette.mode === 'dark' ? forwardFillDark : forwardFillLight
150153
const backwardFill =
151154
theme?.palette.mode === 'dark' ? backwardFillDark : backwardFillLight
152-
// Draw exon and CDS for each mRNA
155+
// Draw exon and CDS for each transcript
153156
currentRow = 0
154157
for (const [, child] of children) {
155-
if (!featureTypeOntology.isTypeOf(child.type, 'mRNA')) {
158+
if (!featureTypeOntology.isTypeOf(child.type, 'transcript')) {
156159
boxGlyph.draw(ctx, child, row, stateModel, displayedRegionIndex)
157160
currentRow += 1
158161
continue
159162
}
160163
for (const cdsRow of child.cdsLocations) {
161-
const { _id, children: childrenOfmRNA } = child
162-
if (!childrenOfmRNA) {
164+
const { _id, children: childrenOfTranscript } = child
165+
if (!childrenOfTranscript) {
163166
continue
164167
}
165-
for (const [, exon] of childrenOfmRNA) {
168+
for (const [, exon] of childrenOfTranscript) {
166169
if (!featureTypeOntology.isTypeOf(exon.type, 'exon')) {
167170
continue
168171
}
@@ -361,7 +364,7 @@ function getFeatureFromLayout(
361364
if (
362365
featureTypeOntology.isTypeOf(featureObj.type, 'CDS') &&
363366
featureObj.parent &&
364-
featureTypeOntology.isTypeOf(featureObj.parent.type, 'mRNA')
367+
featureTypeOntology.isTypeOf(featureObj.parent.type, 'transcript')
365368
) {
366369
const { cdsLocations } = featureObj.parent
367370
for (const cdsLoc of cdsLocations) {
@@ -372,7 +375,7 @@ function getFeatureFromLayout(
372375
}
373376
}
374377

375-
// If mouse position is in the intron region, return the mRNA
378+
// If mouse position is in the intron region, return the transcript
376379
return featureObj.parent
377380
}
378381
// If mouse position is in a feature that is not a CDS, return the feature
@@ -390,9 +393,9 @@ function getRowCount(
390393
if (!children) {
391394
return 1
392395
}
393-
const isMrna = featureTypeOntology.isTypeOf(type, 'mRNA')
396+
const isTranscript = featureTypeOntology.isTypeOf(type, 'transcript')
394397
let rowCount = 0
395-
if (isMrna) {
398+
if (isTranscript) {
396399
for (const [, child] of children) {
397400
const isCds = featureTypeOntology.isTypeOf(child.type, 'CDS')
398401
if (isCds) {
@@ -410,8 +413,8 @@ function getRowCount(
410413
/**
411414
* A list of all the subfeatures for each row for a given feature, as well as
412415
* the feature itself.
413-
* If the row contains an mRNA, the order is CDS -\> exon -\> mRNA -\> gene
414-
* If the row does not contain an mRNA, the order is subfeature -\> gene
416+
* If the row contains a transcript, the order is CDS -\> exon -\> transcript -\> gene
417+
* If the row does not contain an transcript, the order is subfeature -\> gene
415418
*/
416419
function featuresForRow(
417420
feature: AnnotationFeature,
@@ -427,7 +430,7 @@ function featuresForRow(
427430
}
428431
const features: AnnotationFeature[][] = []
429432
for (const [, child] of children) {
430-
if (!featureTypeOntology.isTypeOf(child.type, 'mRNA')) {
433+
if (!featureTypeOntology.isTypeOf(child.type, 'transcript')) {
431434
features.push([child, feature])
432435
continue
433436
}
@@ -534,9 +537,9 @@ function getDraggableFeatureInfo(
534537
throw new Error('featureTypeOntology is undefined')
535538
}
536539
const isGene = featureTypeOntology.isTypeOf(feature.type, 'gene')
537-
const isMrna = featureTypeOntology.isTypeOf(feature.type, 'mRNA')
540+
const isTranscript = featureTypeOntology.isTypeOf(feature.type, 'transcript')
538541
const isCds = featureTypeOntology.isTypeOf(feature.type, 'CDS')
539-
if (isGene || isMrna) {
542+
if (isGene || isTranscript) {
540543
return
541544
}
542545
const { bp, refName, regionNumber, x } = mousePosition
@@ -560,12 +563,12 @@ function getDraggableFeatureInfo(
560563
return { feature, edge: 'max' }
561564
}
562565
if (isCds) {
563-
const mRNA = feature.parent
564-
if (!mRNA?.children) {
566+
const transcript = feature.parent
567+
if (!transcript?.children) {
565568
return
566569
}
567570
const exonChildren: AnnotationFeature[] = []
568-
for (const child of mRNA.children.values()) {
571+
for (const child of transcript.children.values()) {
569572
const childIsExon = featureTypeOntology.isTypeOf(child.type, 'exon')
570573
if (childIsExon) {
571574
exonChildren.push(child)

packages/jbrowse-plugin-apollo/src/LinearApolloDisplay/stateModel/layouts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function layoutsModelFactory(
8686
return false
8787
}
8888
for (const [, child] of children) {
89-
if (featureTypeOntology.isTypeOf(child.type, 'mRNA')) {
89+
if (featureTypeOntology.isTypeOf(child.type, 'transcript')) {
9090
const { children: grandChildren } = child
9191
if (!grandChildren?.size) {
9292
return false

packages/jbrowse-plugin-apollo/src/SixFrameFeatureDisplay/stateModel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ export function stateModelFactory(
300300
},
301301
)) {
302302
for (const [, childFeature] of feature.children ?? new Map()) {
303-
if (featureTypeOntology.isTypeOf(childFeature.type, 'mRNA')) {
303+
if (
304+
featureTypeOntology.isTypeOf(childFeature.type, 'transcript')
305+
) {
304306
for (const [, grandChildFeature] of childFeature.children ||
305307
new Map()) {
306308
let startingRow

packages/jbrowse-plugin-apollo/src/TabularEditor/HybridGrid/featureContextMenuItems.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export function featureContextMenuItems(
142142
throw new Error('featureTypeOntology is undefined')
143143
}
144144
if (
145-
featureTypeOntology.isTypeOf(feature.type, 'mRNA') &&
145+
featureTypeOntology.isTypeOf(feature.type, 'transcript') &&
146146
isSessionModelWithWidgets(session)
147147
) {
148148
menuItems.push({

0 commit comments

Comments
 (0)