@apollo-annotation/shared 0.3.8 → 0.3.10
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/Changes/AddAssemblyAndFeaturesFromFileChange.d.ts +3 -0
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js +5 -4
- package/dist/Changes/AddAssemblyAndFeaturesFromFileChange.js.map +1 -1
- package/dist/Changes/AddFeatureChange.js +23 -4
- package/dist/Changes/AddFeatureChange.js.map +1 -1
- package/dist/Changes/AddFeaturesFromFileChange.d.ts +3 -0
- package/dist/Changes/AddFeaturesFromFileChange.js +5 -2
- package/dist/Changes/AddFeaturesFromFileChange.js.map +1 -1
- package/dist/Changes/AddRefSeqAliasesChange.js +1 -4
- package/dist/Changes/AddRefSeqAliasesChange.js.map +1 -1
- package/dist/Changes/FromFileBaseChange.d.ts +2 -0
- package/dist/Changes/FromFileBaseChange.js +26 -11
- package/dist/Changes/FromFileBaseChange.js.map +1 -1
- package/dist/Checks/CDSCheck.js +5 -4
- package/dist/Checks/CDSCheck.js.map +1 -1
- package/dist/Checks/TranscriptCheck.js +12 -12
- package/dist/Checks/TranscriptCheck.js.map +1 -1
- package/dist/Checks/util.d.ts +2 -0
- package/dist/Checks/util.js +15 -0
- package/dist/Checks/util.js.map +1 -0
- package/dist/GFF3/annotationFeatureToGFF3.js +3 -1
- package/dist/GFF3/annotationFeatureToGFF3.js.map +1 -1
- package/dist/GFF3/annotationFeatureToGFF3.test.js +19 -5
- package/dist/GFF3/annotationFeatureToGFF3.test.js.map +1 -1
- package/dist/GFF3/gff3ToAnnotationFeature.d.ts +1 -1
- package/dist/GFF3/gff3ToAnnotationFeature.js +9 -12
- package/dist/GFF3/gff3ToAnnotationFeature.js.map +1 -1
- package/dist/GFF3/gff3ToAnnotationFeature.test.d.ts +1 -2
- package/dist/GFF3/gff3ToAnnotationFeature.test.js +25 -98
- package/dist/GFF3/gff3ToAnnotationFeature.test.js.map +1 -1
- package/dist/GFF3/testUtil.d.ts +6 -0
- package/dist/GFF3/testUtil.js +24 -0
- package/dist/GFF3/testUtil.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/Changes/AddAssemblyAndFeaturesFromFileChange.ts +6 -5
- package/src/Changes/AddFeatureChange.ts +26 -4
- package/src/Changes/AddFeaturesFromFileChange.ts +6 -1
- package/src/Changes/AddRefSeqAliasesChange.ts +1 -5
- package/src/Changes/FromFileBaseChange.ts +28 -16
- package/src/Checks/CDSCheck.ts +6 -4
- package/src/Checks/TranscriptCheck.ts +11 -12
- package/src/Checks/util.ts +13 -0
- package/src/GFF3/annotationFeatureToGFF3.test.ts +24 -2
- package/src/GFF3/annotationFeatureToGFF3.ts +4 -1
- package/src/GFF3/gff3ToAnnotationFeature.test.ts +26 -97
- package/src/GFF3/gff3ToAnnotationFeature.ts +7 -16
- package/src/GFF3/testUtil.ts +25 -0
- package/test_data/gene_with_two_cds.gff3 +6 -0
- package/test_data/gene_with_two_cds.json +69 -0
- package/test_data/single_feature_no_children.gff3 +1 -0
- package/test_data/single_feature_no_children.json +14 -0
- package/test_data/single_feature_two_children.gff3 +3 -0
- package/test_data/single_feature_two_children.json +44 -0
- package/test_data/two_cds.gff3 +0 -9
- package/test_data/two_cds.json +0 -67
|
@@ -8,7 +8,6 @@ import { gffToInternal, isGFFReservedAttribute } from './gffReservedKeys'
|
|
|
8
8
|
export function gff3ToAnnotationFeature(
|
|
9
9
|
gff3Feature: GFF3Feature,
|
|
10
10
|
refSeq?: string,
|
|
11
|
-
featureIds?: string[],
|
|
12
11
|
): AnnotationFeatureSnapshot {
|
|
13
12
|
const [firstFeature] = gff3Feature
|
|
14
13
|
const { end, seq_id: refName, start, strand, type } = firstFeature
|
|
@@ -35,7 +34,7 @@ export function gff3ToAnnotationFeature(
|
|
|
35
34
|
|
|
36
35
|
const [min, max] = getFeatureMinMax(gff3Feature)
|
|
37
36
|
|
|
38
|
-
const convertedChildren = convertChildren(gff3Feature, refSeq
|
|
37
|
+
const convertedChildren = convertChildren(gff3Feature, refSeq)
|
|
39
38
|
|
|
40
39
|
const convertedAttributes = convertFeatureAttributes(gff3Feature)
|
|
41
40
|
|
|
@@ -61,9 +60,6 @@ export function gff3ToAnnotationFeature(
|
|
|
61
60
|
if (convertedAttributes) {
|
|
62
61
|
feature.attributes = convertedAttributes
|
|
63
62
|
}
|
|
64
|
-
if (featureIds) {
|
|
65
|
-
featureIds.push(feature._id)
|
|
66
|
-
}
|
|
67
63
|
return feature
|
|
68
64
|
}
|
|
69
65
|
|
|
@@ -115,7 +111,7 @@ function convertFeatureAttributes(
|
|
|
115
111
|
if (attributesCollections.length > 0) {
|
|
116
112
|
for (const attributesCollection of attributesCollections) {
|
|
117
113
|
for (const [key, val] of Object.entries(attributesCollection)) {
|
|
118
|
-
if (
|
|
114
|
+
if (key === 'Parent') {
|
|
119
115
|
continue
|
|
120
116
|
}
|
|
121
117
|
const newKey = isGFFReservedAttribute(key) ? gffToInternal[key] : key
|
|
@@ -182,13 +178,13 @@ function convertChildren(
|
|
|
182
178
|
if (firstChildFeatureLocation.type === 'CDS') {
|
|
183
179
|
cdsFeatures.push(childFeature)
|
|
184
180
|
} else {
|
|
185
|
-
const child = gff3ToAnnotationFeature(childFeature, refSeq
|
|
181
|
+
const child = gff3ToAnnotationFeature(childFeature, refSeq)
|
|
186
182
|
convertedChildren[child._id] = child
|
|
187
183
|
}
|
|
188
184
|
}
|
|
189
185
|
|
|
190
186
|
if (cdsFeatures.length > 0) {
|
|
191
|
-
const processedCDS = processCDS(cdsFeatures, refSeq
|
|
187
|
+
const processedCDS = processCDS(cdsFeatures, refSeq)
|
|
192
188
|
|
|
193
189
|
for (const cds of processedCDS) {
|
|
194
190
|
convertedChildren[cds._id] = cds
|
|
@@ -372,16 +368,13 @@ function mergeAnnotationFeatures(
|
|
|
372
368
|
function processCDS(
|
|
373
369
|
cdsFeatures: GFF3Feature[],
|
|
374
370
|
refSeq?: string,
|
|
375
|
-
featureIds?: string[],
|
|
376
371
|
): AnnotationFeatureSnapshot[] {
|
|
377
372
|
const locationCounts = cdsFeatures.map((cds) => cds.length)
|
|
378
373
|
// If any CDS have multiple locations, assume it really is multiple CDS
|
|
379
374
|
// (e.g. the mRNA has multiple alternative translational start sites)
|
|
380
375
|
// and process normally.
|
|
381
376
|
if (locationCounts.some((count) => count > 1)) {
|
|
382
|
-
return cdsFeatures.map((cds) =>
|
|
383
|
-
gff3ToAnnotationFeature(cds, refSeq, featureIds),
|
|
384
|
-
)
|
|
377
|
+
return cdsFeatures.map((cds) => gff3ToAnnotationFeature(cds, refSeq))
|
|
385
378
|
}
|
|
386
379
|
// If all CDS have a single location, we guess that this GFF3 represented CDS
|
|
387
380
|
// as multiple features instead of a single feature with multiple locations.
|
|
@@ -402,7 +395,7 @@ function processCDS(
|
|
|
402
395
|
})
|
|
403
396
|
// If no overlaps, assume it's a single CDS feature
|
|
404
397
|
if (!overlapping) {
|
|
405
|
-
return [gff3ToAnnotationFeature(sortedCDSLocations, refSeq
|
|
398
|
+
return [gff3ToAnnotationFeature(sortedCDSLocations, refSeq)]
|
|
406
399
|
}
|
|
407
400
|
// Some CDS locations overlap, the best we can do is use the original order to
|
|
408
401
|
// guess how to group the locations into features
|
|
@@ -430,7 +423,5 @@ function processCDS(
|
|
|
430
423
|
lastGroup.push(location)
|
|
431
424
|
}
|
|
432
425
|
}
|
|
433
|
-
return groupedLocations.map((group) =>
|
|
434
|
-
gff3ToAnnotationFeature(group, refSeq, featureIds),
|
|
435
|
-
)
|
|
426
|
+
return groupedLocations.map((group) => gff3ToAnnotationFeature(group, refSeq))
|
|
436
427
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
|
|
3
|
+
import { type AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
|
|
4
|
+
|
|
5
|
+
export function readAnnotationFeatureSnapshot(
|
|
6
|
+
fn: string,
|
|
7
|
+
): AnnotationFeatureSnapshot {
|
|
8
|
+
const lines = readFileSync(fn).toString()
|
|
9
|
+
return JSON.parse(lines) as AnnotationFeatureSnapshot
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const testCases: { filenameStem: string; description: string }[] = [
|
|
13
|
+
{
|
|
14
|
+
filenameStem: 'single_feature_no_children',
|
|
15
|
+
description: 'there is a single feature with no children',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
filenameStem: 'single_feature_two_children',
|
|
19
|
+
description: 'there is a single feature with two children',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
filenameStem: 'gene_with_two_cds',
|
|
23
|
+
description: 'Gene with two CDS',
|
|
24
|
+
},
|
|
25
|
+
]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
chr1 . gene 1000 9000 . + . testid=t003;ID=gene10001;Name=EDEN
|
|
2
|
+
chr1 . mRNA 1050 9000 . + . testid=t004,t001,t004;Parent=gene10001;ID=mRNA10001;Name=EDEN.1
|
|
3
|
+
chr1 . exon 1050 1500 . + . testid=t007;Parent=mRNA10001;ID=exon10001
|
|
4
|
+
chr1 . exon 5000 5500 . + . testid=t010;Parent=mRNA10001;ID=exon10004
|
|
5
|
+
chr1 . CDS 1201 1500 . + 0 testid=t012,t013,t014;Parent=mRNA10001;ID=cds10001;Name=edenprotein.1
|
|
6
|
+
chr1 . CDS 5000 5000 . + 0 testid=t012,t013,t014;Parent=mRNA10001;ID=cds10001;Name=edenprotein.1
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"_id": "66d70f3b9c7a7460925687a3",
|
|
4
|
+
"refSeq": "chr1",
|
|
5
|
+
"type": "gene",
|
|
6
|
+
"min": 999,
|
|
7
|
+
"max": 9000,
|
|
8
|
+
"strand": 1,
|
|
9
|
+
"children": {
|
|
10
|
+
"66d70f3b9c7a7460925687a2": {
|
|
11
|
+
"_id": "66d70f3b9c7a7460925687a2",
|
|
12
|
+
"refSeq": "chr1",
|
|
13
|
+
"type": "mRNA",
|
|
14
|
+
"min": 1049,
|
|
15
|
+
"max": 9000,
|
|
16
|
+
"strand": 1,
|
|
17
|
+
"children": {
|
|
18
|
+
"66d70f3b9c7a74609256879f": {
|
|
19
|
+
"_id": "66d70f3b9c7a74609256879f",
|
|
20
|
+
"refSeq": "chr1",
|
|
21
|
+
"type": "exon",
|
|
22
|
+
"min": 1049,
|
|
23
|
+
"max": 1500,
|
|
24
|
+
"strand": 1,
|
|
25
|
+
"attributes": {
|
|
26
|
+
"testid": ["t007"],
|
|
27
|
+
"gff_id": ["exon10001"]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"66d70f3b9c7a7460925687a0": {
|
|
31
|
+
"_id": "66d70f3b9c7a7460925687a0",
|
|
32
|
+
"refSeq": "chr1",
|
|
33
|
+
"type": "exon",
|
|
34
|
+
"min": 4999,
|
|
35
|
+
"max": 5500,
|
|
36
|
+
"strand": 1,
|
|
37
|
+
"attributes": {
|
|
38
|
+
"testid": ["t010"],
|
|
39
|
+
"gff_id": ["exon10004"]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"66d70f3b9c7a7460925687a1": {
|
|
43
|
+
"_id": "66d70f3b9c7a7460925687a1",
|
|
44
|
+
"refSeq": "chr1",
|
|
45
|
+
"type": "CDS",
|
|
46
|
+
"min": 1200,
|
|
47
|
+
"max": 5000,
|
|
48
|
+
"strand": 1,
|
|
49
|
+
"attributes": {
|
|
50
|
+
"testid": ["t012", "t013", "t014"],
|
|
51
|
+
"gff_id": ["cds10001"],
|
|
52
|
+
"gff_name": ["edenprotein.1"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"attributes": {
|
|
57
|
+
"testid": ["t004", "t001", "t004"],
|
|
58
|
+
"gff_id": ["mRNA10001"],
|
|
59
|
+
"gff_name": ["EDEN.1"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"attributes": {
|
|
64
|
+
"testid": ["t003"],
|
|
65
|
+
"gff_id": ["gene10001"],
|
|
66
|
+
"gff_name": ["EDEN"]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ctgA example remark 1000 2000 . . . Name=Remark:hga;Alias=hga
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"_id": "6931fc4f88722ca882ba334c",
|
|
4
|
+
"refSeq": "ctgA",
|
|
5
|
+
"type": "EST_match",
|
|
6
|
+
"min": 1049,
|
|
7
|
+
"max": 3202,
|
|
8
|
+
"strand": 1,
|
|
9
|
+
"children": {
|
|
10
|
+
"6931fc4f88722ca882ba334a": {
|
|
11
|
+
"_id": "6931fc4f88722ca882ba334a",
|
|
12
|
+
"refSeq": "ctgA",
|
|
13
|
+
"type": "match_part",
|
|
14
|
+
"min": 1049,
|
|
15
|
+
"max": 1500,
|
|
16
|
+
"strand": 1,
|
|
17
|
+
"attributes": {
|
|
18
|
+
"gff_source": ["est"],
|
|
19
|
+
"gff_name": ["agt830.5"],
|
|
20
|
+
"gff_target": ["agt830.5 1 451"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"6931fc4f88722ca882ba334b": {
|
|
24
|
+
"_id": "6931fc4f88722ca882ba334b",
|
|
25
|
+
"refSeq": "ctgA",
|
|
26
|
+
"type": "match_part",
|
|
27
|
+
"min": 2999,
|
|
28
|
+
"max": 3202,
|
|
29
|
+
"strand": 1,
|
|
30
|
+
"attributes": {
|
|
31
|
+
"gff_source": ["est"],
|
|
32
|
+
"gff_name": ["agt830.5"],
|
|
33
|
+
"gff_target": ["agt830.5 452 654"]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"attributes": {
|
|
38
|
+
"gff_source": ["est"],
|
|
39
|
+
"gff_id": ["Match1"],
|
|
40
|
+
"gff_name": ["agt830.5"],
|
|
41
|
+
"gff_target": ["agt830.5 1 654"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
package/test_data/two_cds.gff3
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
##gff-version 3
|
|
2
|
-
##sequence-region chr1 1000 9000
|
|
3
|
-
#example01
|
|
4
|
-
chr1 . gene 1000 9000 . + . ID=gene10001;Name=EDEN;testid=t003
|
|
5
|
-
chr1 . mRNA 1050 9000 . + . ID=mRNA10001;Parent=gene10001;Name=EDEN.1;testid=t004,t001,t004
|
|
6
|
-
chr1 . exon 1050 1500 . + . ID=exon10001;Parent=mRNA10001;testid=t007
|
|
7
|
-
chr1 . exon 5000 5500 . + . ID=exon10004;Parent=mRNA10001;testid=t010
|
|
8
|
-
chr1 . CDS 1201 1500 . + 0 ID=cds10001;Parent=mRNA10001;Name=edenprotein.1;testid=t012,t013,t014
|
|
9
|
-
chr1 . CDS 5000 5000 . + 0 ID=cds10001;Parent=mRNA10001;Name=edenprotein.1;testid=t014
|
package/test_data/two_cds.json
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_id": "66d70f3b9c7a7460925687a3",
|
|
3
|
-
"refSeq": "chr1",
|
|
4
|
-
"type": "gene",
|
|
5
|
-
"min": 999,
|
|
6
|
-
"max": 9000,
|
|
7
|
-
"strand": 1,
|
|
8
|
-
"children": {
|
|
9
|
-
"66d70f3b9c7a7460925687a2": {
|
|
10
|
-
"_id": "66d70f3b9c7a7460925687a2",
|
|
11
|
-
"refSeq": "chr1",
|
|
12
|
-
"type": "mRNA",
|
|
13
|
-
"min": 1049,
|
|
14
|
-
"max": 9000,
|
|
15
|
-
"strand": 1,
|
|
16
|
-
"children": {
|
|
17
|
-
"66d70f3b9c7a74609256879f": {
|
|
18
|
-
"_id": "66d70f3b9c7a74609256879f",
|
|
19
|
-
"refSeq": "chr1",
|
|
20
|
-
"type": "exon",
|
|
21
|
-
"min": 1049,
|
|
22
|
-
"max": 1500,
|
|
23
|
-
"strand": 1,
|
|
24
|
-
"attributes": {
|
|
25
|
-
"gff_id": ["exon10001"],
|
|
26
|
-
"testid": ["t007"]
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"66d70f3b9c7a7460925687a0": {
|
|
30
|
-
"_id": "66d70f3b9c7a7460925687a0",
|
|
31
|
-
"refSeq": "chr1",
|
|
32
|
-
"type": "exon",
|
|
33
|
-
"min": 4999,
|
|
34
|
-
"max": 5500,
|
|
35
|
-
"strand": 1,
|
|
36
|
-
"attributes": {
|
|
37
|
-
"gff_id": ["exon10004"],
|
|
38
|
-
"testid": ["t010"]
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"66d70f3b9c7a7460925687a1": {
|
|
42
|
-
"_id": "66d70f3b9c7a7460925687a1",
|
|
43
|
-
"refSeq": "chr1",
|
|
44
|
-
"type": "CDS",
|
|
45
|
-
"min": 1200,
|
|
46
|
-
"max": 5000,
|
|
47
|
-
"strand": 1,
|
|
48
|
-
"attributes": {
|
|
49
|
-
"gff_id": ["cds10001"],
|
|
50
|
-
"gff_name": ["edenprotein.1"],
|
|
51
|
-
"testid": ["t012", "t013", "t014"]
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"attributes": {
|
|
56
|
-
"gff_id": ["mRNA10001"],
|
|
57
|
-
"gff_name": ["EDEN.1"],
|
|
58
|
-
"testid": ["t004", "t001", "t004"]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"attributes": {
|
|
63
|
-
"gff_id": ["gene10001"],
|
|
64
|
-
"gff_name": ["EDEN"],
|
|
65
|
-
"testid": ["t003"]
|
|
66
|
-
}
|
|
67
|
-
}
|