@apollo-annotation/mst 0.3.5 → 0.3.7
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/dist/AnnotationFeatureModel.d.ts +2 -1
- package/dist/AnnotationFeatureModel.js +40 -16
- package/dist/AnnotationFeatureModel.js.map +1 -1
- package/dist/ApolloAssembly.d.ts +13 -1
- package/dist/ApolloAssembly.js.map +1 -1
- package/dist/ApolloRefSeq.d.ts +6 -4
- package/dist/ApolloRefSeq.js +9 -0
- package/dist/ApolloRefSeq.js.map +1 -1
- package/dist/CheckResult.d.ts +2 -1
- package/dist/CheckResult.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/AnnotationFeatureModel.ts +55 -21
- package/src/ApolloAssembly.ts +1 -1
- package/src/ApolloRefSeq.ts +15 -5
- package/src/CheckResult.ts +1 -1
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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
|
-
IAnyModelType,
|
|
4
|
-
IMSTMap,
|
|
5
|
-
Instance,
|
|
6
|
-
SnapshotIn,
|
|
7
|
-
SnapshotOrInstance,
|
|
6
|
+
type IAnyModelType,
|
|
7
|
+
type IMSTMap,
|
|
8
|
+
type Instance,
|
|
9
|
+
type SnapshotIn,
|
|
10
|
+
type SnapshotOrInstance,
|
|
8
11
|
cast,
|
|
9
12
|
getParentOfType,
|
|
10
13
|
getSnapshot,
|
|
@@ -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-
|
|
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
|
-
|
|
137
|
-
|
|
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-
|
|
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
|
-
|
|
187
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -291,6 +291,40 @@ 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-explicit-any
|
|
296
|
+
const session = getSession(self) as any
|
|
297
|
+
const { apolloDataStore } = session
|
|
298
|
+
const { featureTypeOntology } = apolloDataStore.ontologyManager
|
|
299
|
+
if (!featureTypeOntology) {
|
|
300
|
+
return false
|
|
301
|
+
}
|
|
302
|
+
const children = self.children as Children
|
|
303
|
+
if (!children?.size) {
|
|
304
|
+
return false
|
|
305
|
+
}
|
|
306
|
+
const isGene =
|
|
307
|
+
featureTypeOntology.isTypeOf(self.type, 'gene') ||
|
|
308
|
+
featureTypeOntology.isTypeOf(self.type, 'pseudogene')
|
|
309
|
+
if (!isGene) {
|
|
310
|
+
return false
|
|
311
|
+
}
|
|
312
|
+
for (const [, child] of children) {
|
|
313
|
+
if (
|
|
314
|
+
featureTypeOntology.isTypeOf(child.type, 'transcript') ||
|
|
315
|
+
featureTypeOntology.isTypeOf(child.type, 'pseudogenic_transcript')
|
|
316
|
+
) {
|
|
317
|
+
const { children: grandChildren } = child
|
|
318
|
+
if (!grandChildren?.size) {
|
|
319
|
+
return false
|
|
320
|
+
}
|
|
321
|
+
return [...grandChildren.values()].some((grandchild) =>
|
|
322
|
+
featureTypeOntology.isTypeOf(grandchild.type, 'exon'),
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return false
|
|
327
|
+
},
|
|
294
328
|
}))
|
|
295
329
|
.actions((self) => ({
|
|
296
330
|
setAttributes(attributes: Map<string, string[]>) {
|
|
@@ -310,7 +344,7 @@ export const AnnotationFeatureModel = types
|
|
|
310
344
|
},
|
|
311
345
|
setMin(min: number) {
|
|
312
346
|
if (min > self.max) {
|
|
313
|
-
throw new Error(`Min "${min}" is greater than max "${self.max}"`)
|
|
347
|
+
throw new Error(`Min "${min + 1}" is greater than max "${self.max}"`)
|
|
314
348
|
}
|
|
315
349
|
if (self.min !== min) {
|
|
316
350
|
self.min = min
|
package/src/ApolloAssembly.ts
CHANGED
package/src/ApolloRefSeq.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { isContainedWithin } from '@jbrowse/core/util'
|
|
1
|
+
import { doesIntersect2, 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
|
+
type AnnotationFeature,
|
|
10
11
|
AnnotationFeatureModel,
|
|
11
|
-
AnnotationFeatureSnapshot,
|
|
12
|
+
type AnnotationFeatureSnapshot,
|
|
12
13
|
} from './AnnotationFeatureModel'
|
|
13
14
|
|
|
14
15
|
export const Sequence = types.model({
|
|
@@ -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
|
package/src/CheckResult.ts
CHANGED