diff --git a/packages/core/pluggableElementTypes/models/components/SaveTrackData.tsx b/packages/core/pluggableElementTypes/models/components/SaveTrackData.tsx index 4ad64eb1bf..7105a4882d 100644 --- a/packages/core/pluggableElementTypes/models/components/SaveTrackData.tsx +++ b/packages/core/pluggableElementTypes/models/components/SaveTrackData.tsx @@ -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, @@ -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] || { @@ -108,7 +110,7 @@ const SaveTrackDataDialog = observer(function ({ await generator.callback({ features, session, - assemblyName: view.visibleRegions[0].assemblyName, + assemblyName: visibleRegions[0].assemblyName, }), ) } catch (e) { diff --git a/plugins/variants/src/VariantTrack/saveTrackFormats/vcf.ts b/plugins/variants/src/VariantTrack/saveTrackFormats/vcf.ts index 3bcf751ab8..59a927efbb 100644 --- a/plugins/variants/src/VariantTrack/saveTrackFormats/vcf.ts +++ b/plugins/variants/src/VariantTrack/saveTrackFormats/vcf.ts @@ -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') }