@apollo-annotation/shared 0.2.1 → 0.3.0

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/src/util.ts CHANGED
@@ -1,105 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
-
3
- import { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
4
- import { GFF3Feature } from '@gmod/gff'
5
-
6
- export function makeGFF3Feature(
7
- feature: AnnotationFeatureSnapshot,
8
- parentId?: string,
9
- refSeqNames?: Record<string, string | undefined>,
10
- ): GFF3Feature {
11
- const locations = [{ start: feature.min, end: feature.max }]
12
- // const locations = feature.discontinuousLocations?.length
13
- // ? feature.discontinuousLocations
14
- // : [{ start: feature.start, end: feature.end, phase: feature.phase }]
15
- const attributes: Record<string, string[] | undefined> = JSON.parse(
16
- JSON.stringify(feature.attributes),
17
- )
18
- const ontologyTerms: string[] = []
19
- const source = feature.attributes?.source?.[0] ?? null
20
- delete attributes.source
21
- if (parentId) {
22
- attributes.Parent = [parentId]
23
- }
24
- if (attributes._id) {
25
- attributes.ID = attributes._id
26
- delete attributes._id
27
- }
28
- if (attributes.gff_name) {
29
- attributes.Name = attributes.gff_name
30
- delete attributes.gff_name
31
- }
32
- if (attributes.gff_alias) {
33
- attributes.Alias = attributes.gff_alias
34
- delete attributes.gff_alias
35
- }
36
- if (attributes.gff_target) {
37
- attributes.Target = attributes.gff_target
38
- delete attributes.gff_target
39
- }
40
- if (attributes.gff_gap) {
41
- attributes.Gap = attributes.gff_gap
42
- delete attributes.gff_gap
43
- }
44
- if (attributes.gff_derives_from) {
45
- attributes.Derives_from = attributes.gff_derives_from
46
- delete attributes.gff_derives_from
47
- }
48
- if (attributes.gff_note) {
49
- attributes.Note = attributes.gff_note
50
- delete attributes.gff_note
51
- }
52
- if (attributes.gff_dbxref) {
53
- attributes.Dbxref = attributes.gff_dbxref
54
- delete attributes.gff_dbxref
55
- }
56
- if (attributes.gff_is_circular) {
57
- attributes.Is_circular = attributes.gff_is_circular
58
- delete attributes.gff_is_circular
59
- }
60
- if (attributes.gff_ontology_term) {
61
- ontologyTerms.push(...attributes.gff_ontology_term)
62
- delete attributes.gff_ontology_term
63
- }
64
- if (attributes['Gene Ontology']) {
65
- ontologyTerms.push(...attributes['Gene Ontology'])
66
- delete attributes['Gene Ontology']
67
- }
68
- if (attributes['Sequence Ontology']) {
69
- ontologyTerms.push(...attributes['Sequence Ontology'])
70
- delete attributes['Sequence Ontology']
71
- }
72
- if (ontologyTerms.length > 0) {
73
- attributes.Ontology_term = ontologyTerms
74
- }
75
- return locations.map((location) => ({
76
- start: location.start + 1,
77
- end: location.end,
78
- seq_id: refSeqNames ? refSeqNames[feature.refSeq] ?? null : feature.refSeq,
79
- source,
80
- type: feature.type,
81
- score: null,
82
- // score: feature.score ?? null,
83
- strand: feature.strand ? (feature.strand === 1 ? '+' : '-') : null,
84
- phase: null,
85
- // phase:
86
- // location.phase === 0
87
- // ? '0'
88
- // : location.phase === 1
89
- // ? '1'
90
- // : location.phase === 2
91
- // ? '2'
92
- // : null,
93
- attributes: Object.keys(attributes).length > 0 ? attributes : null,
94
- derived_features: [],
95
- child_features: feature.children
96
- ? Object.values(feature.children).map((child) =>
97
- makeGFF3Feature(child, attributes.ID?.[0], refSeqNames),
98
- )
99
- : [],
100
- }))
101
- }
102
-
103
1
  export function splitStringIntoChunks(
104
2
  input: string,
105
3
  chunkSize: number,
@@ -0,0 +1,117 @@
1
+ {
2
+ "_id": "66d70e4ccc30b55b65e5f619",
3
+ "refSeq": "chr1",
4
+ "type": "gene",
5
+ "min": 999,
6
+ "max": 9000,
7
+ "strand": 1,
8
+ "attributes": {
9
+ "gff_id": ["gene10001"],
10
+ "gff_name": ["EDEN"],
11
+ "gff_score": ["123"],
12
+ "gff_source": ["test_data"],
13
+ "testid": ["t001", "t003"],
14
+ "gff_ontology_term": ["GO1234"],
15
+ "Gene Ontology": ["GO4567"],
16
+ "Sequence Ontology": ["SO1234"],
17
+ "gff_alias": ["myalias"],
18
+ "gff_target": ["mytarget"],
19
+ "gff_gap": ["mygap"],
20
+ "gff_derives_from": ["myderives"],
21
+ "gff_note": ["mynote"],
22
+ "gff_dbxref": ["mydbxref"],
23
+ "gff_is_circular": ["true"]
24
+ },
25
+ "children": {
26
+ "66d70e4ccc30b55b65e5f618": {
27
+ "_id": "66d70e4ccc30b55b65e5f618",
28
+ "refSeq": "chr1",
29
+ "type": "mRNA",
30
+ "min": 1049,
31
+ "max": 9000,
32
+ "strand": 1,
33
+ "attributes": {
34
+ "gff_id": ["mRNA10001"],
35
+ "gff_name": ["EDEN.1"],
36
+ "testid": ["t004", "t001", "t004"]
37
+ },
38
+ "children": {
39
+ "66d70e4ccc30b55b65e5f615": {
40
+ "_id": "66d70e4ccc30b55b65e5f615",
41
+ "refSeq": "chr1",
42
+ "type": "exon",
43
+ "min": 1049,
44
+ "max": 1500,
45
+ "strand": 1,
46
+ "attributes": {
47
+ "gff_id": ["exon10001"],
48
+ "testid": ["t007"]
49
+ }
50
+ },
51
+ "66d70e4ccc30b55b65e5f616": {
52
+ "_id": "66d70e4ccc30b55b65e5f616",
53
+ "refSeq": "chr1",
54
+ "type": "exon",
55
+ "min": 4999,
56
+ "max": 5500,
57
+ "strand": 1,
58
+ "attributes": {
59
+ "gff_id": ["exon10004"],
60
+ "testid": ["t010"]
61
+ },
62
+ "children": {
63
+ "xyz": {
64
+ "_id": "xyz",
65
+ "refSeq": "chr1",
66
+ "type": "exon_region",
67
+ "min": 5300,
68
+ "max": 5400,
69
+ "strand": 1,
70
+ "attributes": {
71
+ "gff_id": ["exon_region10001"]
72
+ }
73
+ }
74
+ }
75
+ },
76
+ "66d70e4ccc30b55b65e5f617": {
77
+ "_id": "66d70e4ccc30b55b65e5f617",
78
+ "refSeq": "chr1",
79
+ "type": "CDS",
80
+ "min": 1200,
81
+ "max": 5100,
82
+ "strand": 1,
83
+ "attributes": {
84
+ "gff_id": ["cds10001"],
85
+ "gff_name": ["edenprotein.1"],
86
+ "testid": ["t012", "t013", "t014", "t015"]
87
+ },
88
+ "children": {
89
+ "abc": {
90
+ "id": "abc",
91
+ "refSeq": "chr1",
92
+ "type": "CDS_region",
93
+ "min": "1350",
94
+ "max": "1400",
95
+ "strand": 1,
96
+ "attributes": {
97
+ "gff_id": ["cds_region10001"]
98
+ }
99
+ }
100
+ }
101
+ },
102
+ "66e049f17b9cedae9ad89106": {
103
+ "_id": "66e049f17b9cedae9ad89106",
104
+ "refSeq": "chr1",
105
+ "type": "CDS",
106
+ "min": 1300,
107
+ "max": 5200,
108
+ "strand": 1,
109
+ "attributes": {
110
+ "gff_id": ["cds10004"],
111
+ "gff_name": ["edenprotein.4"]
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }