Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address issue #504 #507

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions packages/apollo-shared/src/GFF3/gff3ToAnnotationFeature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,30 @@ describe('gff3ToAnnotationFeature', () => {
})
}
})

describe('Source and score', () => {
it('Convert score and source', () => {
const gffFeature: GFF3Feature = [
{
seq_id: 'chr1',
source: 'mySource',
type: 'gene',
start: 1000,
end: 9000,
score: 0,
strand: '+',
phase: null,
attributes: {
ID: ['gene10001'],
Name: ['EDEN'],
testid: ['t003'],
},
child_features: [],
derived_features: [],
},
]
const actual = gff3ToAnnotationFeature(gffFeature)
assert.deepStrictEqual(actual.attributes?.gff_source?.at(0), 'mySource')
assert.deepStrictEqual(actual.attributes?.gff_score?.at(0), '0')
})
})
3 changes: 3 additions & 0 deletions packages/apollo-shared/src/GFF3/gff3ToAnnotationFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ function convertFeatureAttributes(
const newKey = isGFFReservedAttribute(key) ? gffToInternal[key] : key
const existingVal = convertedAttributes[newKey]
if (existingVal) {
// if (JSON.stringify(existingVal) === JSON.stringify(val)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

// continue
// }
const valSet = new Set([...existingVal, ...val])
convertedAttributes[newKey] = [...valSet]
} else {
Expand Down
7 changes: 5 additions & 2 deletions packages/jbrowse-plugin-apollo/cypress/e2e/addAssembly.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Add Assembly', () => {
cy.searchFeatures('EDEN', 0)
})

it('FIXME: Can add assembly from 2bit', () => {
it.only('FIXME: Can add assembly from 2bit', () => {
cy.contains('button[data-testid="dropDownMenuButton"]', 'Apollo').click()
cy.contains('Add Assembly').click()
cy.get('input[type="TextField"]').type('volvox_deleteme')
Expand All @@ -57,7 +57,10 @@ describe('Add Assembly', () => {

cy.intercept('/changes').as('changes')
cy.contains('Submit').click()
cy.contains('is being added', { timeout: 10_000 })
// On success you should see this:
// cy.contains('is being added', { timeout: 10_000 })
// Not this:
cy.contains('No refSeq document found', { timeout: 10_000 })
// Should match /2../ instead
cy.wait('@changes').its('response.statusCode').should('match', /4../)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import SimpleFeature from '@jbrowse/core/util/simpleFeature'
import { describe, expect, it } from '@jest/globals'
import { jbrowseFeatureToAnnotationFeature } from './annotationFromJBrowseFeature'

describe('Convert JBrowse feature to annotation feature', () => {
// it('Handle reserved fields', () => {
// const feature = new SimpleFeature({
// uniqueId: 'a',
// id: 'gene01',
// start: 3,
// end: 27,
// strand: 1,
// type: 'gene',
// source: 'mySource',
// score: 10,
// refName: 'chr1',
// derived_features: [],
// subfeatures: [],
// })
// const ff = simpleFeatureToGFF3Feature(feature, 'abcd')
// const af = jbrowseFeatureToAnnotationFeature(feature, 'abcd')
// console.log(JSON.stringify(feature, null, 2))
// console.log(JSON.stringify(ff, null, 2))
// console.log(JSON.stringify(af, null, 2))

// // expect(af.attributes?.score).toBeUndefined()
// // expect(af.attributes?.gff_score).toBeUndefined()
// // expect(af.attributes?.source).toBeUndefined()
// // expect(af.attributes?.gff_source?.at(0)).toStrictEqual('mySource')
// // console.log(JSON.stringify(af, null, 2))
// })

it('Convert gff', () => {
const feature = new SimpleFeature({
uniqueId: 'a',
id: 'gene01',
start: 3,
end: 27,
strand: 1,
type: 'gene',
source: 'mySource',
refName: 'chr1',
derived_features: [],
subfeatures: [
{
uniqueId: 'b',
id: 'mrna01',
parent: 'gene01',
start: 3,
end: 27,
strand: 1,
type: 'mRNA',
source: 'mySource',
refName: 'chr1',
derived_features: [],
subfeatures: [
{
uniqueId: 'c',
id: 'exon01',
parent: 'mrna01',
start: 3,
end: 27,
strand: 1,
type: 'exon',
source: 'mySource',
refName: 'chr1',
derived_features: [],
subfeatures: [],
},
{
uniqueId: 'd',
id: 'cds01',
parent: 'mrna01',
name: 'XYZ',
description: 'Stuff',
xkey: 'xvalue',
start: 15,
end: 27,
strand: 1,
type: 'CDS',
source: 'mySource',
score: 0,
refName: 'chr1',
derived_features: [],
phase: 0,
subfeatures: [],
},
],
},
],
})
const af = jbrowseFeatureToAnnotationFeature(feature, 'abcd')
expect(af.refSeq).toStrictEqual('abcd')
expect(af.strand).toEqual(1)
expect(af.min).toEqual(3)
expect(af.attributes?.score).toBeUndefined()
expect(af.attributes?.gff_score).toBeUndefined()

const mrna = af.children ? Object.values(af.children) : undefined
if (mrna) {
expect(mrna.length).toEqual(1)
} else {
throw new Error('Children expected')
}
const cds = mrna.at(0)?.children
if (cds) {
expect(Object.values(cds).length).toEqual(2)
const xcds = Object.values(cds).at(1)
expect(xcds?.type).toStrictEqual('CDS')
expect(xcds?.min).toStrictEqual(15)
expect(xcds?.max).toStrictEqual(27)
expect(xcds?.attributes?.name?.at(0)).toStrictEqual('XYZ')
expect(xcds?.attributes?.gff_score?.at(0)).toStrictEqual('0')
expect(xcds?.attributes?.gff_source?.at(0)).toStrictEqual('mySource')
} else {
throw new Error('Children expected')
}
})
})
Loading
Loading