@apollo-annotation/mst 0.3.6 → 0.3.8

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,12 +1,12 @@
1
1
  {
2
2
  "name": "@apollo-annotation/mst",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc"
7
7
  },
8
8
  "dependencies": {
9
- "@jbrowse/core": "^3.0.1",
9
+ "@jbrowse/core": "^3.6.5",
10
10
  "mobx": "^6.6.1",
11
11
  "mobx-state-tree": "^5.4.0",
12
12
  "react-dom": "^18.2.0",
@@ -1,3 +1,6 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
3
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
1
4
  import { getSession, intersection2 } from '@jbrowse/core/util'
2
5
  import {
3
6
  type IAnyModelType,
@@ -127,14 +130,14 @@ export const AnnotationFeatureModel = types
127
130
  return false
128
131
  },
129
132
  get transcriptExonParts(): TranscriptParts {
130
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
134
  const session = getSession(self) as any
132
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
133
135
  const { apolloDataStore } = session
134
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
135
136
  const { featureTypeOntology } = apolloDataStore.ontologyManager
136
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
137
- if (!featureTypeOntology.isTypeOf(self.type, 'transcript')) {
137
+ if (
138
+ !featureTypeOntology.isTypeOf(self.type, 'transcript') &&
139
+ !featureTypeOntology.isTypeOf(self.type, 'pseudogenic_transcript')
140
+ ) {
138
141
  throw new Error(
139
142
  'Feature is not a transcript or equivalent, cannot calculate exon locations',
140
143
  )
@@ -144,7 +147,6 @@ export const AnnotationFeatureModel = types
144
147
  throw new Error('No exons in transcript')
145
148
  }
146
149
  const sortedChildren = [...children.values()]
147
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
148
150
  .filter((child) => featureTypeOntology.isTypeOf(child.type, 'exon'))
149
151
  .sort((a, b) => a.min - b.min)
150
152
  let lastMax = self.min
@@ -177,14 +179,14 @@ export const AnnotationFeatureModel = types
177
179
  return parts
178
180
  },
179
181
  get transcriptParts(): TranscriptParts[] {
180
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
182
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
181
183
  const session = getSession(self) as any
182
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
183
184
  const { apolloDataStore } = session
184
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
185
185
  const { featureTypeOntology } = apolloDataStore.ontologyManager
186
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
187
- if (!featureTypeOntology.isTypeOf(self.type, 'transcript')) {
186
+ if (
187
+ !featureTypeOntology.isTypeOf(self.type, 'transcript') &&
188
+ !featureTypeOntology.isTypeOf(self.type, 'pseudogenic_transcript')
189
+ ) {
188
190
  throw new Error(
189
191
  'Only features of type "transcript" or equivalent can calculate CDS locations',
190
192
  )
@@ -193,9 +195,8 @@ export const AnnotationFeatureModel = types
193
195
  if (!children) {
194
196
  throw new Error('no CDS or exons in transcript')
195
197
  }
196
- const cdsChildren = [...children.values()].filter(
197
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
198
- (child) => featureTypeOntology.isTypeOf(child.type, 'CDS'),
198
+ const cdsChildren = [...children.values()].filter((child) =>
199
+ featureTypeOntology.isTypeOf(child.type, 'CDS'),
199
200
  )
200
201
  const transcriptParts: TranscriptParts[] = []
201
202
  if (cdsChildren.length === 0) {
@@ -208,7 +209,6 @@ export const AnnotationFeatureModel = types
208
209
  let hasIntersected = false
209
210
  const exonLocations: TranscriptPartLocation[] = []
210
211
  for (const [, child] of children) {
211
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
212
212
  if (featureTypeOntology.isTypeOf(child.type, 'exon')) {
213
213
  exonLocations.push({ min: child.min, max: child.max })
214
214
  }
@@ -292,11 +292,9 @@ export const AnnotationFeatureModel = types
292
292
  )
293
293
  },
294
294
  get looksLikeGene(): boolean {
295
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
295
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
296
296
  const session = getSession(self) as any
297
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
298
297
  const { apolloDataStore } = session
299
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
300
298
  const { featureTypeOntology } = apolloDataStore.ontologyManager
301
299
  if (!featureTypeOntology) {
302
300
  return false
@@ -305,20 +303,15 @@ export const AnnotationFeatureModel = types
305
303
  if (!children?.size) {
306
304
  return false
307
305
  }
308
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
309
306
  const isGene =
310
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
311
307
  featureTypeOntology.isTypeOf(self.type, 'gene') ||
312
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
313
308
  featureTypeOntology.isTypeOf(self.type, 'pseudogene')
314
309
  if (!isGene) {
315
310
  return false
316
311
  }
317
312
  for (const [, child] of children) {
318
313
  if (
319
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
320
314
  featureTypeOntology.isTypeOf(child.type, 'transcript') ||
321
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
322
315
  featureTypeOntology.isTypeOf(child.type, 'pseudogenic_transcript')
323
316
  ) {
324
317
  const { children: grandChildren } = child
@@ -326,7 +319,6 @@ export const AnnotationFeatureModel = types
326
319
  return false
327
320
  }
328
321
  return [...grandChildren.values()].some((grandchild) =>
329
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
330
322
  featureTypeOntology.isTypeOf(grandchild.type, 'exon'),
331
323
  )
332
324
  }
@@ -352,7 +344,7 @@ export const AnnotationFeatureModel = types
352
344
  },
353
345
  setMin(min: number) {
354
346
  if (min > self.max) {
355
- throw new Error(`Min "${min}" is greater than max "${self.max}"`)
347
+ throw new Error(`Min "${min + 1}" is greater than max "${self.max}"`)
356
348
  }
357
349
  if (self.min !== min) {
358
350
  self.min = min
@@ -1,4 +1,4 @@
1
- import { isContainedWithin } from '@jbrowse/core/util'
1
+ import { doesIntersect2, isContainedWithin } from '@jbrowse/core/util'
2
2
  import {
3
3
  type Instance,
4
4
  type SnapshotIn,
@@ -7,6 +7,7 @@ import {
7
7
  } from 'mobx-state-tree'
8
8
 
9
9
  import {
10
+ type AnnotationFeature,
10
11
  AnnotationFeatureModel,
11
12
  type AnnotationFeatureSnapshot,
12
13
  } from './AnnotationFeatureModel'
@@ -124,6 +125,15 @@ export const ApolloRefSeq = types
124
125
  }
125
126
  return ''
126
127
  },
128
+ getFeatures(min: number, max: number): AnnotationFeature[] {
129
+ const features: AnnotationFeature[] = []
130
+ for (const [, feature] of self.features) {
131
+ if (doesIntersect2(feature.min, feature.max, min, max)) {
132
+ features.push(feature)
133
+ }
134
+ }
135
+ return features
136
+ },
127
137
  }))
128
138
 
129
139
  // eslint disables because of
@@ -20,3 +20,5 @@ export const CheckResult = types.model('CheckResult', {
20
20
  export interface CheckResultI extends Instance<typeof CheckResult> {}
21
21
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
22
22
  export interface CheckResultSnapshot extends SnapshotIn<typeof CheckResult> {}
23
+
24
+ export type CheckResultIdsType = Instance<typeof CheckResult>['ids']