Skip to content

Commit

Permalink
Test expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
dariober committed Nov 27, 2024
1 parent 0a10d98 commit 781e330
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 13 deletions.
49 changes: 42 additions & 7 deletions packages/apollo-shared/src/GFF3/annotationFeatureToGFF3.test.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,69 @@
/* eslint-disable prefer-destructuring */
/* eslint-disable @typescript-eslint/no-floating-promises */

import { describe, it } from 'node:test'
import { assert } from 'chai'
import { readAnnotationFeatureSnapshot } from './gff3ToAnnotationFeature.test'
import { annotationFeatureToGFF3 } from './annotationFeatureToGFF3'

describe('annotationFeatureToGFF3', () => {
it('Convert one gene', () => {
it('Convert one gene test fields', () => {
const annotationFeature = readAnnotationFeatureSnapshot(
'test_data/gene.json',
)
const [gff3Feature] = annotationFeatureToGFF3(annotationFeature)

assert.deepEqual(gff3Feature.seq_id, 'chr1')
assert.deepEqual(gff3Feature.type, 'gene')
assert.deepEqual(gff3Feature.start, 1000)
assert.deepEqual(gff3Feature.end, 9000)
assert.deepEqual(gff3Feature.strand, '+')
assert.deepEqual(gff3Feature.score, 123)
assert.deepEqual(gff3Feature.source, 'test_data')
})
it.skip('Convert one gene test phase', () => {
const annotationFeature = readAnnotationFeatureSnapshot(
'test_data/gene.json',
)
const [gff3Feature] = annotationFeatureToGFF3(annotationFeature)
const cds = gff3Feature.child_features[0][0].child_features[2][0]
assert.deepEqual(cds.start, 1201)
assert.deepEqual(cds.phase, '0')
})
it('Convert one gene test attributes', () => {
const annotationFeature = readAnnotationFeatureSnapshot(
'test_data/gene.json',
)
const [gff3Feature] = annotationFeatureToGFF3(annotationFeature)

assert.deepEqual(gff3Feature.attributes?.Name, ['EDEN'])
assert.deepEqual(gff3Feature.attributes?.testid, ['t003'])
assert.deepEqual(gff3Feature.attributes?.testid, ['t001', 't003'])
assert.deepEqual(gff3Feature.attributes?.ID, ['gene10001'])

assert.deepEqual(gff3Feature.attributes?.Ontology_term, [
'GO1234',
'GO4567',
'SO1234',
])
assert.deepEqual(gff3Feature.attributes?.Alias, ['myalias'])
assert.deepEqual(gff3Feature.attributes?.Target, ['mytarget'])
assert.deepEqual(gff3Feature.attributes?.Gap, ['mygap'])
assert.deepEqual(gff3Feature.attributes?.Derives_from, ['myderives'])
assert.deepEqual(gff3Feature.attributes?.Note, ['mynote'])
assert.deepEqual(gff3Feature.attributes?.Dbxref, ['mydbxref'])
assert.deepEqual(gff3Feature.attributes?.Is_circular, ['true'])
})
it('Convert one gene test children', () => {
const annotationFeature = readAnnotationFeatureSnapshot(
'test_data/gene.json',
)
const [gff3Feature] = annotationFeatureToGFF3(annotationFeature)
const [children] = gff3Feature.child_features
const [mrna] = children
assert.deepEqual(mrna.type, 'mRNA')
assert.deepEqual(mrna.attributes?.Parent, ['gene10001'])

// Sanity check the annotationFeature does have a score, etc.
// assert.deepEqual(annotationFeature.attributes?.gff_score, ['123'])
// assert.deepEqual(annotationFeature.attributes?.gff_source, ['test_data'])
const [cds] = mrna.child_features[2]
assert.deepEqual(cds.type, 'CDS')
assert.deepEqual(cds.attributes?.ID, ['cds10001'])
assert.deepEqual(cds.attributes?.Parent, ['mRNA10001'])
})
})
22 changes: 16 additions & 6 deletions packages/apollo-shared/test_data/gene.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
"gff_name": ["EDEN"],
"gff_score": ["123"],
"gff_source": ["test_data"],
"testid": ["t003"]
"testid": ["t001", "t003"],
"gff_ontology_term": ["GO1234"],
"Gene Ontology": ["GO4567"],
"Sequence Ontology": ["SO1234"],
"gff_alias": ["myalias"],
"gff_target": ["mytarget"],
"gff_gap": ["mygap"],
"gff_derives_from": ["myderives"],
"gff_note": ["mynote"],
"gff_dbxref": ["mydbxref"],
"gff_is_circular": ["true"]
},
"children": {
"66d70e4ccc30b55b65e5f618": {
Expand All @@ -20,6 +30,11 @@
"min": 1049,
"max": 9000,
"strand": 1,
"attributes": {
"gff_id": ["mRNA10001"],
"gff_name": ["EDEN.1"],
"testid": ["t004", "t001", "t004"]
},
"children": {
"66d70e4ccc30b55b65e5f615": {
"_id": "66d70e4ccc30b55b65e5f615",
Expand Down Expand Up @@ -58,11 +73,6 @@
"testid": ["t012", "t013", "t014", "t015"]
}
}
},
"attributes": {
"gff_id": ["mRNA10001"],
"gff_name": ["EDEN.1"],
"testid": ["t004", "t001", "t004"]
}
}
}
Expand Down

0 comments on commit 781e330

Please sign in to comment.