@apollo-annotation/mst 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo-annotation/mst",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc"
@@ -1,10 +1,10 @@
1
1
  import { getSession, intersection2 } from '@jbrowse/core/util'
2
2
  import {
3
- IAnyModelType,
4
- IMSTMap,
5
- Instance,
6
- SnapshotIn,
7
- SnapshotOrInstance,
3
+ type IAnyModelType,
4
+ type IMSTMap,
5
+ type Instance,
6
+ type SnapshotIn,
7
+ type SnapshotOrInstance,
8
8
  cast,
9
9
  getParentOfType,
10
10
  getSnapshot,
@@ -291,6 +291,48 @@ export const AnnotationFeatureModel = types
291
291
  transcript.filter((transcriptPart) => transcriptPart.type === 'CDS'),
292
292
  )
293
293
  },
294
+ get looksLikeGene(): boolean {
295
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
296
+ const session = getSession(self) as any
297
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
298
+ const { apolloDataStore } = session
299
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
300
+ const { featureTypeOntology } = apolloDataStore.ontologyManager
301
+ if (!featureTypeOntology) {
302
+ return false
303
+ }
304
+ const children = self.children as Children
305
+ if (!children?.size) {
306
+ return false
307
+ }
308
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
309
+ const isGene =
310
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
311
+ featureTypeOntology.isTypeOf(self.type, 'gene') ||
312
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
313
+ featureTypeOntology.isTypeOf(self.type, 'pseudogene')
314
+ if (!isGene) {
315
+ return false
316
+ }
317
+ for (const [, child] of children) {
318
+ if (
319
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
320
+ featureTypeOntology.isTypeOf(child.type, 'transcript') ||
321
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
322
+ featureTypeOntology.isTypeOf(child.type, 'pseudogenic_transcript')
323
+ ) {
324
+ const { children: grandChildren } = child
325
+ if (!grandChildren?.size) {
326
+ return false
327
+ }
328
+ return [...grandChildren.values()].some((grandchild) =>
329
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
330
+ featureTypeOntology.isTypeOf(grandchild.type, 'exon'),
331
+ )
332
+ }
333
+ }
334
+ return false
335
+ },
294
336
  }))
295
337
  .actions((self) => ({
296
338
  setAttributes(attributes: Map<string, string[]>) {
@@ -1,4 +1,4 @@
1
- import { Instance, SnapshotIn, types } from 'mobx-state-tree'
1
+ import { type Instance, type SnapshotIn, types } from 'mobx-state-tree'
2
2
 
3
3
  import { ApolloRefSeq } from './ApolloRefSeq'
4
4
 
@@ -1,14 +1,14 @@
1
1
  import { isContainedWithin } from '@jbrowse/core/util'
2
2
  import {
3
- Instance,
4
- SnapshotIn,
5
- SnapshotOrInstance,
3
+ type Instance,
4
+ type SnapshotIn,
5
+ type SnapshotOrInstance,
6
6
  types,
7
7
  } from 'mobx-state-tree'
8
8
 
9
9
  import {
10
10
  AnnotationFeatureModel,
11
- AnnotationFeatureSnapshot,
11
+ type AnnotationFeatureSnapshot,
12
12
  } from './AnnotationFeatureModel'
13
13
 
14
14
  export const Sequence = types.model({
@@ -1,4 +1,4 @@
1
- import { Instance, SnapshotIn, types } from 'mobx-state-tree'
1
+ import { type Instance, type SnapshotIn, types } from 'mobx-state-tree'
2
2
 
3
3
  import { AnnotationFeatureModel } from './AnnotationFeatureModel'
4
4