Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ jobs:
- name: Upload
working-directory: packages/website
run: |
aws s3 sync --delete build/ s3://apollo.jbrowse.org/
aws s3 sync --exclude "demo/*" --delete build/ s3://apollo.jbrowse.org/
aws cloudfront create-invalidation --distribution-id EL84YTOVCGNJZ --paths '/*'
21 changes: 21 additions & 0 deletions packages/jbrowse-plugin-apollo/local.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@
}
}
}
},
{
"type": "AlignmentsTrack",
"trackId": "paired_end_stranded_rnaseq",
"name": "volvox-stranded-rnaseq",
"category": ["Alignments"],
"adapter": {
"type": "BamAdapter",
"bamLocation": {
"uri": "test_data/paired_end_stranded_rnaseq.bam",
"locationType": "UriLocation"
},
"index": {
"location": {
"uri": "test_data/paired_end_stranded_rnaseq.bam.bai",
"locationType": "UriLocation"
},
"indexType": "BAI"
}
},
"assemblyNames": ["volvox"]
}
],
"plugins": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* eslint-disable @typescript-eslint/require-await */
import {
type Change,
FeatureChange,
type SerializedChange,
checkRegistry,
isFeatureChange,
Expand Down Expand Up @@ -162,14 +161,9 @@ export class LocalDriver extends BackendDriver {
const regions = await this.getRegions(assembly)
const refNames = regions.map((r) => r.refName)
const db = await openDb(assembly, refNames)
const storeNames = refNames.flatMap((r) => [
`features-${r}`,
`checkresults-${r}`,
])
storeNames.push('changes')
const tx = db.transaction(storeNames, 'readwrite')
const topLevelFeatures = new Set<AnnotationFeature>()
const deletedFeatureIds: { refSeq: string; featureId: string }[] = []
const neededRefNames = new Set<string>()
if (isDeleteFeatureChange(change)) {
for (const c of change.changes) {
if (c.parentFeatureId) {
Expand All @@ -179,18 +173,28 @@ export class LocalDriver extends BackendDriver {
}
} else {
const { refSeq, _id } = c.deletedFeature
void tx.objectStore(`features-${refSeq}`).delete(c.deletedFeature._id)
deletedFeatureIds.push({ refSeq, featureId: _id })
neededRefNames.add(refSeq)
}
}
} else {
for (const changedId of changedIds) {
const feature = this.clientStore.getFeature(changedId)
if (feature) {
topLevelFeatures.add(feature.topLevelFeature)
neededRefNames.add(feature.refSeq)
}
}
}
const storeNames = [...neededRefNames].flatMap((r) => [
`features-${r}`,
`checkresults-${r}`,
])
storeNames.push('changes')
const tx = db.transaction(storeNames, 'readwrite')
for (const { refSeq, featureId } of deletedFeatureIds) {
void tx.objectStore(`features-${refSeq}`).delete(featureId)
}
for (const feature of topLevelFeatures) {
const snapshot = getSnapshot<AnnotationFeatureSnapshot>(feature)
void tx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */
import type { AnnotationFeatureSnapshot } from '@apollo-annotation/mst'
import type { Assembly } from '@jbrowse/core/assemblyManager/assembly'
import type {
DisplayType,
PluggableElementType,
Expand All @@ -14,11 +13,14 @@ import {
getContainingView,
getSession,
} from '@jbrowse/core/util'
import type { Feature } from '@jbrowse/core/util/simpleFeature'
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
import AddIcon from '@mui/icons-material/Add'
import ObjectID from 'bson-objectid'

import { CollaborationServerDriver } from '../BackendDrivers'
import { CreateApolloAnnotation } from '../components/CreateApolloAnnotation'
import type { ApolloSessionModel } from '../session'

function parseCigar(cigar: string): [string, number][] {
const regex = /(\d+)([MIDNSHPX=])/g
Expand All @@ -44,7 +46,7 @@ export function annotationFromPileup(pluggableElement: PluggableElementType) {
return lgv.dynamicBlocks.contentBlocks[0]
},
getAssembly() {
const firstRegion = self.getFirstRegion()
const firstRegion = this.getFirstRegion()
const session = getSession(self)
const { assemblyManager } = session
const { assemblyName } = firstRegion
Expand All @@ -54,35 +56,13 @@ export function annotationFromPileup(pluggableElement: PluggableElementType) {
}
return assembly
},
getRefSeqId(assembly: Assembly) {
const firstRegion = self.getFirstRegion()
const { refName } = firstRegion
const { refNameAliases } = assembly
if (!refNameAliases) {
throw new Error(`Could not find aliases for ${assembly.name}`)
}
const newRefNames = [...Object.entries(refNameAliases)]
.filter(([id, refName]) => id !== refName)
.map(([id, refName]) => ({
_id: id,
name: refName,
}))
const refSeqId = newRefNames.find((item) => item.name === refName)?._id
if (!refSeqId) {
throw new Error(`Could not find refSeqId named ${refName}`)
}
return refSeqId
},
getAnnotationFeature() {
const feature = self.contextMenuFeature
const assembly = self.getAssembly()
const refSeqId = self.getRefSeqId(assembly)
const start: number = feature.get('start')
const end: number = feature.get('end')
const strand = feature.get('strand')
const name = feature.get('name')
getAnnotationFeature(jbrowseFeature: Feature, refSeqId: string) {
const start: number = jbrowseFeature.get('start')
const end: number = jbrowseFeature.get('end')
const strand = jbrowseFeature.get('strand') as 1 | -1 | undefined
const name = jbrowseFeature.get('name') as string | undefined

const cigarData: string = feature.get('CIGAR')
const cigarData = jbrowseFeature.get('CIGAR') as string
const ops = parseCigar(cigarData)
let position = start
let currentExonStart: number | undefined
Expand Down Expand Up @@ -151,9 +131,10 @@ export function annotationFromPileup(pluggableElement: PluggableElementType) {
max: end,
type: 'mRNA',
strand,
attributes: {
name: [name],
},
}
if (name) {
newFeature.attributes = {}
newFeature.attributes.gff_name = [name]
}
if (exons.length === 0) {
return newFeature
Expand Down Expand Up @@ -183,16 +164,32 @@ export function annotationFromPileup(pluggableElement: PluggableElementType) {
const session = getSession(self)
const assembly = self.getAssembly()
const region = self.getFirstRegion()
const feature = self.contextMenuFeature
if (!feature) {
const jbrowseFeature = self.contextMenuFeature
if (!jbrowseFeature) {
return superContextMenuItems()
}
return [
...superContextMenuItems(),
{
label: 'Create Apollo annotation',
icon: AddIcon,
onClick: () => {
onClick: async () => {
const backendDriver = (
session as unknown as ApolloSessionModel
).apolloDataStore.getBackendDriver(region.assemblyName)
let refSeqId = region.refName
if (backendDriver instanceof CollaborationServerDriver) {
const backendRefSeqId = await backendDriver.getRefSeqId(
region.assemblyName,
region.refName,
)
if (!backendRefSeqId) {
throw new Error(
`Could not find refSeq for "${region.refName}"`,
)
}
refSeqId = backendRefSeqId
}
;(session as unknown as AbstractSessionModel).queueDialog(
(doneCallback) => [
CreateApolloAnnotation,
Expand All @@ -201,9 +198,12 @@ export function annotationFromPileup(pluggableElement: PluggableElementType) {
handleClose: () => {
doneCallback()
},
annotationFeature: self.getAnnotationFeature(assembly),
annotationFeature: self.getAnnotationFeature(
jbrowseFeature,
refSeqId,
),
assembly,
refSeqId: self.getRefSeqId(assembly),
refSeqId,
region,
},
],
Expand Down
Binary file not shown.
Binary file not shown.
Loading