Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed May 28, 2024
1 parent cb5f3a3 commit 42cd6a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IAnyStateTreeNode } from 'mobx-state-tree'
import { makeStyles } from 'tss-react/mui'
import { saveAs } from 'file-saver'
import { observer } from 'mobx-react'
import { Dialog, ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui'
import { Dialog, ErrorMessage } from '@jbrowse/core/ui'
import {
getSession,
getContainingView,
Expand Down Expand Up @@ -96,9 +96,11 @@ const SaveTrackDataDialog = observer(function ({
// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
try {
const view = getContainingView(model)
const { visibleRegions } = getContainingView(model) as {
visibleRegions?: Region[]
}
const session = getSession(model)
if (!features) {
if (!features || !visibleRegions) {
return
}
const generator = options[type] || {
Expand All @@ -108,7 +110,7 @@ const SaveTrackDataDialog = observer(function ({
await generator.callback({
features,
session,
assemblyName: view.visibleRegions[0].assemblyName,
assemblyName: visibleRegions[0].assemblyName,
}),
)
} catch (e) {
Expand Down
10 changes: 9 additions & 1 deletion plugins/variants/src/VariantTrack/saveTrackFormats/vcf.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { Feature } from '@jbrowse/core/util'

function generateINFO(feature: Feature) {
return Object.entries(feature.get('INFO'))
.map(([key, value]) => `${key}=${value}`)
.join(';')
}
export function stringifyVCF({ features }: { features: Feature[] }) {
const fields = ['refName', 'start', 'name', 'REF', 'ALT', 'QUAL', 'FILTER']
return features
.map(feature => {
return `hello ${feature.get('name')}`
return `${fields
.map(field => feature.get(field) || '.')
.join('\t')}\t${generateINFO(feature)}`
})
.join('\n')
}

0 comments on commit 42cd6a2

Please sign in to comment.