From c3a195c3f2b15cb3c75ff7763e61a55e223939e8 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 9 Feb 2023 09:10:53 -0700 Subject: [PATCH 1/5] Add easy refname input --- packages/core/ui/theme.ts | 5 + products/jbrowse-desktop/src/AdapterInput.tsx | 115 +++++++++ .../src/OpenSequenceDialog.tsx | 232 ++++++------------ 3 files changed, 193 insertions(+), 159 deletions(-) create mode 100644 products/jbrowse-desktop/src/AdapterInput.tsx diff --git a/packages/core/ui/theme.ts b/packages/core/ui/theme.ts index 05c3e132f0..091dd866fc 100644 --- a/packages/core/ui/theme.ts +++ b/packages/core/ui/theme.ts @@ -385,6 +385,11 @@ function createDefaultProps(theme?: ThemeOptions) { }, }, }, + MuiToggleButtonGroup: { + defaultProps: { + size: 'small' as const, + }, + }, }, } } diff --git a/products/jbrowse-desktop/src/AdapterInput.tsx b/products/jbrowse-desktop/src/AdapterInput.tsx new file mode 100644 index 0000000000..cd6e23c1ee --- /dev/null +++ b/products/jbrowse-desktop/src/AdapterInput.tsx @@ -0,0 +1,115 @@ +import React from 'react' +import { Grid } from '@mui/material' +import { FileSelector } from '@jbrowse/core/ui' +import { FileLocation } from '@jbrowse/core/util/types' + +export default function AdapterInput({ + adapterSelection, + fastaLocation, + setFastaLocation, + faiLocation, + setFaiLocation, + chromSizesLocation, + gziLocation, + setGziLocation, + twoBitLocation, + setTwoBitLocation, + setChromSizesLocation, +}: { + adapterSelection: string + fastaLocation: FileLocation + setFastaLocation: Function + faiLocation: FileLocation + setFaiLocation: Function + gziLocation: FileLocation + chromSizesLocation: FileLocation + setGziLocation: Function + twoBitLocation: FileLocation + setTwoBitLocation: Function + setChromSizesLocation: Function +}) { + if (adapterSelection === 'IndexedFastaAdapter') { + return ( + + + setFastaLocation(loc)} + /> + + + setFaiLocation(loc)} + /> + + + ) + } + if (adapterSelection === 'BgzipFastaAdapter') { + return ( + + + setFastaLocation(loc)} + /> + + + setFaiLocation(loc)} + /> + + + setGziLocation(loc)} + /> + + + ) + } + + if (adapterSelection === 'TwoBitAdapter') { + return ( + + + setTwoBitLocation(loc)} + /> + + + setChromSizesLocation(loc)} + /> + + + ) + } + + if (adapterSelection === 'FastaAdapter') { + return ( + + + setFastaLocation(loc)} + /> + + + ) + } + + return null +} diff --git a/products/jbrowse-desktop/src/OpenSequenceDialog.tsx b/products/jbrowse-desktop/src/OpenSequenceDialog.tsx index 2057ad08ed..bb4040f256 100644 --- a/products/jbrowse-desktop/src/OpenSequenceDialog.tsx +++ b/products/jbrowse-desktop/src/OpenSequenceDialog.tsx @@ -3,15 +3,15 @@ import { Button, DialogActions, DialogContent, - Grid, MenuItem, Paper, TextField, Typography, } from '@mui/material' import { makeStyles } from 'tss-react/mui' -import { FileSelector, Dialog, ErrorMessage } from '@jbrowse/core/ui' +import { Dialog, ErrorMessage, FileSelector } from '@jbrowse/core/ui' import { FileLocation } from '@jbrowse/core/util/types' +import AdapterInput from './AdapterInput' const { ipcRenderer } = window.require('electron') @@ -32,117 +32,6 @@ const useStyles = makeStyles()(theme => ({ }, })) -function AdapterInput({ - adapterSelection, - fastaLocation, - setFastaLocation, - faiLocation, - setFaiLocation, - chromSizesLocation, - gziLocation, - setGziLocation, - twoBitLocation, - setTwoBitLocation, - setChromSizesLocation, -}: { - adapterSelection: string - fastaLocation: FileLocation - setFastaLocation: Function - faiLocation: FileLocation - setFaiLocation: Function - gziLocation: FileLocation - chromSizesLocation: FileLocation - setGziLocation: Function - twoBitLocation: FileLocation - setTwoBitLocation: Function - setChromSizesLocation: Function -}) { - if (adapterSelection === 'IndexedFastaAdapter') { - return ( - - - setFastaLocation(loc)} - /> - - - setFaiLocation(loc)} - /> - - - ) - } - if (adapterSelection === 'BgzipFastaAdapter') { - return ( - - - setFastaLocation(loc)} - /> - - - setFaiLocation(loc)} - /> - - - setGziLocation(loc)} - /> - - - ) - } - - if (adapterSelection === 'TwoBitAdapter') { - return ( - - - setTwoBitLocation(loc)} - /> - - - setChromSizesLocation(loc)} - /> - - - ) - } - - if (adapterSelection === 'FastaAdapter') { - return ( - - - setFastaLocation(loc)} - /> - - - ) - } - - return null -} - const blank = { uri: '' } as FileLocation function isBlank(location: FileLocation) { @@ -174,6 +63,9 @@ const OpenSequenceDialog = ({ const [gziLocation, setGziLocation] = useState(blank) const [twoBitLocation, setTwoBitLocation] = useState(blank) const [chromSizesLocation, setChromSizesLocation] = useState(blank) + const [refNameAliasesLocation, setRefNameAliasesLocation] = useState(blank) + const [cytobandsLocation, setCytobandsLocation] = useState(blank) + const [showAdvanced, setShowAdvanced] = useState(false) function clearState() { setFastaLocation(blank) @@ -181,23 +73,21 @@ const OpenSequenceDialog = ({ setGziLocation(blank) setTwoBitLocation(blank) setChromSizesLocation(blank) + setRefNameAliasesLocation(blank) + setCytobandsLocation(blank) setAssemblyName('') setAssemblyDisplayName('') } - async function createAssemblyConfigHelper() { + async function createAssemblyAdapterConfig() { if (adapterSelection === 'FastaAdapter') { setLoading('Creating .fai file for FASTA') const faiLocation = await ipcRenderer.invoke('indexFasta', fastaLocation) return { - name: assemblyName, - displayName: assemblyDisplayName, - sequence: { - adapter: { - type: 'IndexedFastaAdapter', - fastaLocation, - faiLocation: { localPath: faiLocation }, - }, + adapter: { + type: 'IndexedFastaAdapter', + fastaLocation, + faiLocation: { localPath: faiLocation }, }, } } @@ -206,14 +96,10 @@ const OpenSequenceDialog = ({ throw new Error('Need both fastaLocation and faiLocation') } return { - name: assemblyName, - displayName: assemblyDisplayName, - sequence: { - adapter: { - type: 'IndexedFastaAdapter', - fastaLocation, - faiLocation, - }, + adapter: { + type: 'IndexedFastaAdapter', + fastaLocation, + faiLocation, }, } } else if (adapterSelection === 'BgzipFastaAdapter') { @@ -227,15 +113,11 @@ const OpenSequenceDialog = ({ ) } return { - name: assemblyName, - displayName: assemblyDisplayName, - sequence: { - adapter: { - type: 'BgzipFastaAdapter', - fastaLocation, - faiLocation, - gziLocation, - }, + adapter: { + type: 'BgzipFastaAdapter', + fastaLocation, + faiLocation, + gziLocation, }, } } else if (adapterSelection === 'TwoBitAdapter') { @@ -243,14 +125,10 @@ const OpenSequenceDialog = ({ throw new Error('Need twoBitLocation') } return { - name: assemblyName, - displayName: assemblyDisplayName, - sequence: { - adapter: { - type: 'TwoBitAdapter', - twoBitLocation, - chromSizesLocation, - }, + adapter: { + type: 'TwoBitAdapter', + twoBitLocation, + chromSizesLocation, }, } } @@ -258,24 +136,45 @@ const OpenSequenceDialog = ({ } async function createAssemblyConfig() { - const conf = await createAssemblyConfigHelper() - return { - ...conf, + name: assemblyName, + displayName: assemblyDisplayName, sequence: { type: 'ReferenceSequenceTrack', trackId: `${assemblyName}-${Date.now()}`, - ...conf.sequence, + ...(await createAssemblyAdapterConfig()), }, + ...(!isBlank(refNameAliasesLocation) + ? { + refNameAliases: { + adapter: { + type: 'RefNameAliasesAdapter', + location: refNameAliasesLocation, + }, + }, + } + : {}), + ...(!isBlank(cytobandsLocation) + ? { + cytobands: { + adapter: { + type: 'CytobandAdapter', + location: cytobandsLocation, + }, + }, + } + : {}), } } return ( onClose()} title="Open sequence(s)"> - Use this dialog to open one or more indexed FASTA files, - bgzipped+indexed FASTA files, or .2bit files of a genome assembly or - other sequence + Use this dialog to open one or more indexed FASTA files + (IndexedFastaAdapter), bgzipped+indexed FASTA files + (BgzipFastaAdapter), or .2bit files (TwoBitAdapter) of a genome + assembly or other sequence. A plain FASTA file can also be supplied + (FastaAdapter), which will be indexed on submit. {assemblyConfs.length ? ( @@ -293,7 +192,6 @@ const OpenSequenceDialog = ({ { - setAdapterSelection(event.target.value) - }} + onChange={event => setAdapterSelection(event.target.value)} > {adapterTypes.map(str => ( @@ -341,6 +236,24 @@ const OpenSequenceDialog = ({ setChromSizesLocation={setChromSizesLocation} /> + + + {showAdvanced ? ( + + + + + ) : null} From ca95dde5af96a56dec12067517dab2b23f116769 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 15 Feb 2023 14:21:44 -0700 Subject: [PATCH 2/5] Allow gzip cytoBands --- packages/core/.gitignore | 7 --- packages/core/CorePlugin.ts | 15 +----- .../core/data_adapters/CytobandAdapter.ts | 51 ------------------- .../CytobandAdapter/CytobandAdapter.ts | 39 ++++++++++++++ .../CytobandAdapter/configSchema.ts | 22 ++++++++ .../data_adapters/CytobandAdapter/index.ts | 14 +++++ packages/core/package.json | 1 + .../src/OpenSequenceDialog.tsx | 4 +- 8 files changed, 80 insertions(+), 73 deletions(-) delete mode 100644 packages/core/.gitignore delete mode 100644 packages/core/data_adapters/CytobandAdapter.ts create mode 100644 packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts create mode 100644 packages/core/data_adapters/CytobandAdapter/configSchema.ts create mode 100644 packages/core/data_adapters/CytobandAdapter/index.ts diff --git a/packages/core/.gitignore b/packages/core/.gitignore deleted file mode 100644 index 8ef21f5ae0..0000000000 --- a/packages/core/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -node_modules -coverage -dist -*.log -*.swp - diff --git a/packages/core/CorePlugin.ts b/packages/core/CorePlugin.ts index 791e78efac..6b765f8924 100644 --- a/packages/core/CorePlugin.ts +++ b/packages/core/CorePlugin.ts @@ -3,12 +3,8 @@ import { configSchema, stateModelFactory } from './BaseFeatureWidget' import Plugin from './Plugin' import PluginManager from './PluginManager' import * as coreRpcMethods from './rpc/coreRpcMethods' -import AdapterType from './pluggableElementTypes/AdapterType' import WidgetType from './pluggableElementTypes/WidgetType' -import { - configSchema as cytobandConfigSchema, - DataAdapter, -} from './data_adapters/CytobandAdapter' +import CytobandAdapterF from './data_adapters/CytobandAdapter' // the core plugin, which registers types that ALL JBrowse applications are // expected to need. @@ -21,14 +17,7 @@ export default class CorePlugin extends Plugin { pluginManager.addRpcMethod(() => new RpcMethod(pluginManager)) }) - pluginManager.addAdapterType( - () => - new AdapterType({ - name: 'CytobandAdapter', - configSchema: cytobandConfigSchema, - AdapterClass: DataAdapter, - }), - ) + CytobandAdapterF(pluginManager) pluginManager.addWidgetType(() => { return new WidgetType({ diff --git a/packages/core/data_adapters/CytobandAdapter.ts b/packages/core/data_adapters/CytobandAdapter.ts deleted file mode 100644 index e0183f573f..0000000000 --- a/packages/core/data_adapters/CytobandAdapter.ts +++ /dev/null @@ -1,51 +0,0 @@ -import SimpleFeature from '../util/simpleFeature' -import { ConfigurationSchema, readConfObject } from '../configuration' -import { openLocation } from '../util/io' -import { BaseAdapter } from './BaseAdapter' - -/** - * #config CytobandAdapter - */ -function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars - -const configSchema = ConfigurationSchema( - 'CytobandAdapter', - { - /** - * #slot - */ - cytobandLocation: { - type: 'fileLocation', - defaultValue: { uri: '/path/to/cytoband.txt.gz' }, - }, - }, - { explicitlyTyped: true }, -) - -class CytobandAdapter extends BaseAdapter { - async getData() { - const loc = readConfObject(this.config, 'cytobandLocation') - if (loc.uri === '' || loc.uri === '/path/to/cytoband.txt.gz') { - return [] - } - const data = await openLocation(loc).readFile('utf8') - return data - .split(/\n|\r\n|\r/) - .filter(f => !!f.trim()) - .map(line => { - const [refName, start, end, name, type] = line.split('\t') - return new SimpleFeature({ - uniqueId: line, - refName, - start: +start, - end: +end, - name, - type, - }) - }) - } - - freeResources(/* { region } */): void {} -} - -export { configSchema, CytobandAdapter as DataAdapter } diff --git a/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts b/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts new file mode 100644 index 0000000000..44c6842e92 --- /dev/null +++ b/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts @@ -0,0 +1,39 @@ +import { unzip } from '@gmod/bgzf-filehandle' + +// locals +import { SimpleFeature } from '../../util' +import { openLocation } from '../../util/io' +import { BaseAdapter } from '../BaseAdapter' + +export function isGzip(buf: Buffer) { + return buf[0] === 31 && buf[1] === 139 && buf[2] === 8 +} + +export default class CytobandAdapter extends BaseAdapter { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + async getData() { + const loc = this.getConf('cytobandLocation') + if (loc.uri === '' || loc.uri === '/path/to/cytoband.txt.gz') { + return [] + } + const buffer = (await openLocation(loc).readFile()) as Buffer + const buf = isGzip(buffer) ? await unzip(buffer) : buffer + const text = new TextDecoder('utf8', { fatal: true }).decode(buf) + return text + .split(/\n|\r\n|\r/) + .filter(f => !!f.trim()) + .map(line => { + const [refName, start, end, name, type] = line.split('\t') + return new SimpleFeature({ + uniqueId: line, + refName, + start: +start, + end: +end, + name, + type, + }) + }) + } + + freeResources(/* { region } */): void {} +} diff --git a/packages/core/data_adapters/CytobandAdapter/configSchema.ts b/packages/core/data_adapters/CytobandAdapter/configSchema.ts new file mode 100644 index 0000000000..166e3bb121 --- /dev/null +++ b/packages/core/data_adapters/CytobandAdapter/configSchema.ts @@ -0,0 +1,22 @@ +import { ConfigurationSchema } from '../../configuration' + +/** + * #config CytobandAdapter + */ +function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars + +const configSchema = ConfigurationSchema( + 'CytobandAdapter', + { + /** + * #slot + */ + cytobandLocation: { + type: 'fileLocation', + defaultValue: { uri: '/path/to/cytoband.txt.gz' }, + }, + }, + { explicitlyTyped: true }, +) + +export default configSchema diff --git a/packages/core/data_adapters/CytobandAdapter/index.ts b/packages/core/data_adapters/CytobandAdapter/index.ts new file mode 100644 index 0000000000..ea0e80650f --- /dev/null +++ b/packages/core/data_adapters/CytobandAdapter/index.ts @@ -0,0 +1,14 @@ +import { AdapterType } from '../../pluggableElementTypes' +import PluginManager from '../../PluginManager' +import configSchema from './configSchema' + +export default (pluginManager: PluginManager) => { + pluginManager.addAdapterType( + () => + new AdapterType({ + name: 'CytobandAdapter', + configSchema, + getAdapterClass: () => import('./CytobandAdapter').then(f => f.default), + }), + ) +} diff --git a/packages/core/package.json b/packages/core/package.json index 667dbd3783..f10fc3777f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "@babel/runtime": "^7.17.9", + "@gmod/bgzf-filehandle": "^1.4.3", "@mui/icons-material": "^5.0.1", "@types/clone": "^2.0.0", "abortable-promise-cache": "^1.5.0", diff --git a/products/jbrowse-desktop/src/OpenSequenceDialog.tsx b/products/jbrowse-desktop/src/OpenSequenceDialog.tsx index bb4040f256..117fc308dd 100644 --- a/products/jbrowse-desktop/src/OpenSequenceDialog.tsx +++ b/products/jbrowse-desktop/src/OpenSequenceDialog.tsx @@ -243,12 +243,12 @@ const OpenSequenceDialog = ({ {showAdvanced ? ( From 68928e687ac215c964f48abbae334ad48cd9c384 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 15 Feb 2023 14:23:11 -0700 Subject: [PATCH 3/5] Updates --- packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts | 1 - products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts b/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts index 44c6842e92..f67be6f219 100644 --- a/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts +++ b/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts @@ -10,7 +10,6 @@ export function isGzip(buf: Buffer) { } export default class CytobandAdapter extends BaseAdapter { - // eslint-disable-next-line @typescript-eslint/no-explicit-any async getData() { const loc = this.getConf('cytobandLocation') if (loc.uri === '' || loc.uri === '/path/to/cytoband.txt.gz') { diff --git a/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx b/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx index 21b86d3193..c493dec0c7 100644 --- a/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx +++ b/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx @@ -18,7 +18,7 @@ const useStyles = makeStyles()(theme => ({ display: 'block', marginBottom: theme.spacing(3), width: 200, - height: '3em', + padding: theme.spacing(1), }, })) From dc15af7ae1be5288c1eb805ec1e63ba1036fe9c7 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 15 Feb 2023 14:24:49 -0700 Subject: [PATCH 4/5] Update config docs --- website/docs/config/BaseChordDisplay.md | 2 +- website/docs/config/BaseLinearDisplay.md | 10 ++++ website/docs/config/CytobandAdapter.md | 2 +- .../docs/config/LinearAlignmentsDisplay.md | 9 +++ .../docs/config/MultiLinearWiggleDisplay.md | 9 +++ website/docs/config/SvgFeatureRenderer.md | 2 +- website/docs/models/BaseChordDisplay.md | 9 ++- website/docs/models/BaseLinearDisplay.md | 11 ++-- website/docs/models/CircularView.md | 36 ++++++++--- website/docs/models/Dotplot1DView.md | 60 +++++++++++++++++++ website/docs/models/DotplotDisplay.md | 9 ++- website/docs/models/DotplotView.md | 25 +++++--- website/docs/models/LGVSyntenyDisplay.md | 2 +- .../docs/models/LinearAlignmentsDisplay.md | 13 +++- website/docs/models/LinearSyntenyDisplay.md | 11 +++- website/docs/models/LinearWiggleDisplay.md | 2 +- 16 files changed, 179 insertions(+), 33 deletions(-) create mode 100644 website/docs/models/Dotplot1DView.md diff --git a/website/docs/config/BaseChordDisplay.md b/website/docs/config/BaseChordDisplay.md index da5355cc92..847812afe5 100644 --- a/website/docs/config/BaseChordDisplay.md +++ b/website/docs/config/BaseChordDisplay.md @@ -9,7 +9,7 @@ source code. See [Config guide](/docs/config_guide) for more info ## Source file -[plugins/circular-view/src/BaseChordDisplay/models/baseChordDisplayConfig.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/circular-view/src/BaseChordDisplay/models/baseChordDisplayConfig.ts) +[plugins/circular-view/src/BaseChordDisplay/models/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/circular-view/src/BaseChordDisplay/models/configSchema.ts) ## Docs diff --git a/website/docs/config/BaseLinearDisplay.md b/website/docs/config/BaseLinearDisplay.md index b66f18509b..bfce9a9461 100644 --- a/website/docs/config/BaseLinearDisplay.md +++ b/website/docs/config/BaseLinearDisplay.md @@ -44,3 +44,13 @@ fetchSizeLimit: { "maximum data to attempt to download for a given track, used if adapter doesn't specify one", } ``` + +#### slot: height + +```js +height: { + type: 'number', + defaultValue: 100, + description: 'default height for the track', + } +``` diff --git a/website/docs/config/CytobandAdapter.md b/website/docs/config/CytobandAdapter.md index 2c94ceaa2e..ce551a0bce 100644 --- a/website/docs/config/CytobandAdapter.md +++ b/website/docs/config/CytobandAdapter.md @@ -9,7 +9,7 @@ source code. See [Config guide](/docs/config_guide) for more info ## Source file -[packages/core/data_adapters/CytobandAdapter.ts](https://github.com/GMOD/jbrowse-components/blob/main/packages/core/data_adapters/CytobandAdapter.ts) +[packages/core/data_adapters/CytobandAdapter/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/packages/core/data_adapters/CytobandAdapter/configSchema.ts) ## Docs diff --git a/website/docs/config/LinearAlignmentsDisplay.md b/website/docs/config/LinearAlignmentsDisplay.md index c98f9f04e1..e2888e7a40 100644 --- a/website/docs/config/LinearAlignmentsDisplay.md +++ b/website/docs/config/LinearAlignmentsDisplay.md @@ -30,6 +30,15 @@ pileupDisplay: pm.getDisplayType('LinearPileupDisplay').configSchema snpCoverageDisplay: pm.getDisplayType('LinearSNPCoverageDisplay').configSchema ``` +#### slot: height + +```js +height: { + type: 'number', + defaultValue: 250, + } +``` + ## LinearAlignmentsDisplay - Derives from ```js diff --git a/website/docs/config/MultiLinearWiggleDisplay.md b/website/docs/config/MultiLinearWiggleDisplay.md index 9561667385..ba735cf181 100644 --- a/website/docs/config/MultiLinearWiggleDisplay.md +++ b/website/docs/config/MultiLinearWiggleDisplay.md @@ -123,6 +123,15 @@ renderers: ConfigurationSchema('RenderersConfiguration', { }) ``` +#### slot: height + +```js +height: { + type: 'number', + defaultValue: 200, + } +``` + ## MultiLinearWiggleDisplay - Derives from ```js diff --git a/website/docs/config/SvgFeatureRenderer.md b/website/docs/config/SvgFeatureRenderer.md index 72cfd25c68..87cd11f806 100644 --- a/website/docs/config/SvgFeatureRenderer.md +++ b/website/docs/config/SvgFeatureRenderer.md @@ -142,7 +142,7 @@ fontSize: { type: 'number', description: 'height in pixels of the text to use for names and descriptions', - defaultValue: 13, + defaultValue: 12, contextVariable: ['feature'], } ``` diff --git a/website/docs/models/BaseChordDisplay.md b/website/docs/models/BaseChordDisplay.md index 0d644fb5cd..947eff6dee 100644 --- a/website/docs/models/BaseChordDisplay.md +++ b/website/docs/models/BaseChordDisplay.md @@ -11,7 +11,7 @@ info ## Source file -[plugins/circular-view/src/BaseChordDisplay/models/BaseChordDisplayModel.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/circular-view/src/BaseChordDisplay/models/BaseChordDisplayModel.ts) +[plugins/circular-view/src/BaseChordDisplay/models/model.tsx](https://github.com/GMOD/jbrowse-components/blob/main/plugins/circular-view/src/BaseChordDisplay/models/model.tsx) ## Docs @@ -81,6 +81,13 @@ renderProps: () => any isCompatibleWithRenderer: (renderer: RendererType) => boolean ``` +#### method: renderSvg + +```js +// type signature +renderSvg: (opts: ExportSvgOptions & { theme: ThemeOptions; }) => Promise +``` + ### BaseChordDisplay - Actions #### action: onChordClick diff --git a/website/docs/models/BaseLinearDisplay.md b/website/docs/models/BaseLinearDisplay.md index fc5135e870..6ecf3d968a 100644 --- a/website/docs/models/BaseLinearDisplay.md +++ b/website/docs/models/BaseLinearDisplay.md @@ -19,19 +19,18 @@ extends `BaseDisplay` ### BaseLinearDisplay - Properties -#### property: height +#### property: heightPreConfig ```js // type signature -IOptionalIType, [undefined]> +IMaybe> // code -height: types.optional( +heightPreConfig: types.maybe( types.refinement( 'displayHeight', types.number, n => n >= minDisplayHeight, ), - defaultDisplayHeight, ) ``` @@ -256,7 +255,7 @@ renderProps: () => any ```js // type signature -renderSvg: (opts: ExportSvgOptions & { overrideHeight: number; }) => Promise +renderSvg: (opts: ExportSvgOptions & { overrideHeight: number; theme: ThemeOptions; }) => Promise ``` ### BaseLinearDisplay - Actions @@ -300,7 +299,7 @@ clearRegionStats: () => void ```js // type signature -setHeight: (displayHeight: number) => number +setHeight: (displayHeight: number) => any ``` #### action: resizeHeight diff --git a/website/docs/models/CircularView.md b/website/docs/models/CircularView.md index a42f222552..3019938520 100644 --- a/website/docs/models/CircularView.md +++ b/website/docs/models/CircularView.md @@ -143,13 +143,6 @@ scrollY: 0 number ``` -#### getter: staticSlices - -```js -// type -any[] -``` - #### getter: visibleSection ```js @@ -272,7 +265,7 @@ see reasonably ```js // type -({ elided: true; widthBp: number; regions: Region[]; } | { elided: false; widthBp: number; start: number; end: number; refName: string; })[] +SliceRegion[] ``` #### getter: assemblyNames @@ -289,6 +282,13 @@ string[] any ``` +#### getter: staticSlices + +```js +// type +any[] +``` + #### getter: visibleStaticSlices ```js @@ -296,6 +296,17 @@ any any[] ``` +### CircularView - Methods + +#### method: menuItems + +return the view menu items + +```js +// type signature +menuItems: () => MenuItem[] +``` + ### CircularView - Actions #### action: setWidth @@ -444,3 +455,12 @@ hideTrack: (trackId: string) => number // type signature toggleFitToWindowLock: () => boolean ``` + +#### action: exportSvg + +creates an svg export and save using FileSaver + +```js +// type signature +exportSvg: (opts?: ExportSvgOptions) => Promise +``` diff --git a/website/docs/models/Dotplot1DView.md b/website/docs/models/Dotplot1DView.md new file mode 100644 index 0000000000..e701c70a98 --- /dev/null +++ b/website/docs/models/Dotplot1DView.md @@ -0,0 +1,60 @@ +--- +id: dotplot1dview +title: Dotplot1DView +toplevel: true +--- + +Note: this document is automatically generated from mobx-state-tree objects in +our source code. See +[Core concepts and intro to pluggable elements](/docs/developer_guide/) for more +info + +## Source file + +[plugins/dotplot-view/src/DotplotView/1dview.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/dotplot-view/src/DotplotView/1dview.ts) + +## Docs + +ref https://mobx-state-tree.js.org/concepts/volatiles on volatile state used +here + +### Dotplot1DView - Getters + +#### getter: dynamicBlocks + +this uses padding=false and elision=false + +```js +// type +BlockSet +``` + +#### getter: scaleFactor + +```js +// type +number +``` + +#### getter: maxBpPerPx + +```js +// type +number +``` + +### Dotplot1DView - Actions + +#### action: setScaleFactor + +```js +// type signature +setScaleFactor: (n: number) => void +``` + +#### action: center + +```js +// type signature +center: () => void +``` diff --git a/website/docs/models/DotplotDisplay.md b/website/docs/models/DotplotDisplay.md index e49c9f6450..850f839a9e 100644 --- a/website/docs/models/DotplotDisplay.md +++ b/website/docs/models/DotplotDisplay.md @@ -11,7 +11,7 @@ info ## Source file -[plugins/dotplot-view/src/DotplotDisplay/stateModelFactory.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/dotplot-view/src/DotplotDisplay/stateModelFactory.ts) +[plugins/dotplot-view/src/DotplotDisplay/stateModelFactory.tsx](https://github.com/GMOD/jbrowse-components/blob/main/plugins/dotplot-view/src/DotplotDisplay/stateModelFactory.tsx) ## Docs @@ -53,6 +53,13 @@ any renderProps: () => any ``` +#### method: renderSvg + +```js +// type signature +renderSvg: (opts: ExportSvgOptions & { theme: ThemeOptions; }) => Promise +``` + ### DotplotDisplay - Actions #### action: setLoading diff --git a/website/docs/models/DotplotView.md b/website/docs/models/DotplotView.md index 2607ca7713..9ea9669d39 100644 --- a/website/docs/models/DotplotView.md +++ b/website/docs/models/DotplotView.md @@ -258,7 +258,7 @@ renderProps: () => any ```js // type signature -menuItems: () => ({ label: string; onClick: () => void; icon?: undefined; } | { label: string; onClick: () => any; icon: (props: SvgIconProps<"svg", {}>) => Element; })[] +menuItems: () => ({ label: string; onClick: () => void; icon: OverridableComponent> & { muiName: string; }; } | { label: string; onClick: () => void; icon?: undefined; } | { ...; })[] ``` ### DotplotView - Actions @@ -349,7 +349,7 @@ zoomInButton: () => void ```js // type signature -activateTrackSelector: () => any +activateTrackSelector: () => Widget ``` #### action: showTrack @@ -403,6 +403,13 @@ zooms into clicked and dragged region zoomIn: (mousedown: Coord, mouseup: Coord) => void ``` +#### action: showAllRegions + +```js +// type signature +showAllRegions: () => void +``` + #### action: onDotplotView creates a linear synteny view from the clicked and dragged region @@ -412,23 +419,25 @@ creates a linear synteny view from the clicked and dragged region onDotplotView: (mousedown: Coord, mouseup: Coord) => void ``` -#### action: squareView +#### action: exportSvg + +creates an svg export and save using FileSaver ```js // type signature -squareView: () => void +exportSvg: (opts?: ExportSvgOptions) => Promise ``` -#### action: squareViewProportional +#### action: squareView ```js // type signature -squareViewProportional: () => void +squareView: () => void ``` -#### action: showAllRegions +#### action: squareViewProportional ```js // type signature -showAllRegions: () => void +squareViewProportional: () => void ``` diff --git a/website/docs/models/LGVSyntenyDisplay.md b/website/docs/models/LGVSyntenyDisplay.md index f5cf955724..187d8cc24b 100644 --- a/website/docs/models/LGVSyntenyDisplay.md +++ b/website/docs/models/LGVSyntenyDisplay.md @@ -11,7 +11,7 @@ info ## Source file -[plugins/linear-comparative-view/src/LGVSyntenyDisplay/stateModelFactory.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/linear-comparative-view/src/LGVSyntenyDisplay/stateModelFactory.ts) +[plugins/linear-comparative-view/src/LGVSyntenyDisplay/model.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/linear-comparative-view/src/LGVSyntenyDisplay/model.ts) ## Docs diff --git a/website/docs/models/LinearAlignmentsDisplay.md b/website/docs/models/LinearAlignmentsDisplay.md index 77959e49a3..0772d25836 100644 --- a/website/docs/models/LinearAlignmentsDisplay.md +++ b/website/docs/models/LinearAlignmentsDisplay.md @@ -70,13 +70,13 @@ ITypeUnion configuration: ConfigurationReference(configSchema) ``` -#### property: height +#### property: heightPreConfig ```js // type signature -number +IMaybe> // code -height: 250 +heightPreConfig: types.maybe(types.number) ``` #### property: userFeatureScreenDensity @@ -99,6 +99,13 @@ lowerPanelType: 'LinearPileupDisplay' ### LinearAlignmentsDisplay - Getters +#### getter: height + +```js +// type +any +``` + #### getter: pileupConf ```js diff --git a/website/docs/models/LinearSyntenyDisplay.md b/website/docs/models/LinearSyntenyDisplay.md index e5ecc365e7..827ba74742 100644 --- a/website/docs/models/LinearSyntenyDisplay.md +++ b/website/docs/models/LinearSyntenyDisplay.md @@ -11,7 +11,7 @@ info ## Source file -[plugins/linear-comparative-view/src/LinearSyntenyDisplay/stateModelFactory.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/linear-comparative-view/src/LinearSyntenyDisplay/stateModelFactory.ts) +[plugins/linear-comparative-view/src/LinearSyntenyDisplay/model.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/linear-comparative-view/src/LinearSyntenyDisplay/model.ts) ## Docs @@ -60,6 +60,15 @@ string[] number ``` +#### getter: ready + +used for synteny svg rendering + +```js +// type +boolean +``` + #### getter: featMap ```js diff --git a/website/docs/models/LinearWiggleDisplay.md b/website/docs/models/LinearWiggleDisplay.md index 121d6a10a0..d17f943bb3 100644 --- a/website/docs/models/LinearWiggleDisplay.md +++ b/website/docs/models/LinearWiggleDisplay.md @@ -481,5 +481,5 @@ reload: () => Promise ```js // type signature -renderSvg: (opts: ExportSvgOptions & { overrideHeight: number; }) => Promise +renderSvg: (opts: ExportSvgOptions & { overrideHeight: number; theme: ThemeOptions; }) => Promise ``` From 93ceae9d3ec5fe7c935b5a1a8bfd1ec47c6a9922 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 15 Feb 2023 14:30:55 -0700 Subject: [PATCH 5/5] Pass pluginManager to the refname/cytoband openLocations --- .../core/data_adapters/CytobandAdapter/CytobandAdapter.ts | 7 ++++--- .../config/src/RefNameAliasAdapter/RefNameAliasAdapter.ts | 7 +++---- products/jbrowse-desktop/src/OpenSequenceDialog.tsx | 6 +++--- products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts b/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts index f67be6f219..507ec6bc09 100644 --- a/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts +++ b/packages/core/data_adapters/CytobandAdapter/CytobandAdapter.ts @@ -11,20 +11,21 @@ export function isGzip(buf: Buffer) { export default class CytobandAdapter extends BaseAdapter { async getData() { + const pm = this.pluginManager const loc = this.getConf('cytobandLocation') if (loc.uri === '' || loc.uri === '/path/to/cytoband.txt.gz') { return [] } - const buffer = (await openLocation(loc).readFile()) as Buffer + const buffer = (await openLocation(loc, pm).readFile()) as Buffer const buf = isGzip(buffer) ? await unzip(buffer) : buffer const text = new TextDecoder('utf8', { fatal: true }).decode(buf) return text .split(/\n|\r\n|\r/) .filter(f => !!f.trim()) - .map(line => { + .map((line, i) => { const [refName, start, end, name, type] = line.split('\t') return new SimpleFeature({ - uniqueId: line, + uniqueId: `${i}`, refName, start: +start, end: +end, diff --git a/plugins/config/src/RefNameAliasAdapter/RefNameAliasAdapter.ts b/plugins/config/src/RefNameAliasAdapter/RefNameAliasAdapter.ts index 4b92747b63..bb7b61af63 100644 --- a/plugins/config/src/RefNameAliasAdapter/RefNameAliasAdapter.ts +++ b/plugins/config/src/RefNameAliasAdapter/RefNameAliasAdapter.ts @@ -3,19 +3,18 @@ import { BaseAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter' import { openLocation } from '@jbrowse/core/util/io' -import { readConfObject } from '@jbrowse/core/configuration' export default class RefNameAliasAdapter extends BaseAdapter implements BaseRefNameAliasAdapter { async getRefNameAliases() { - const loc = readConfObject(this.config, 'location') + const loc = this.getConf('location') if (loc.uri === '' || loc.uri === '/path/to/my/aliases.txt') { return [] } - const results = await openLocation(loc).readFile('utf8') - const refColumn = readConfObject(this.config, 'refNameColumn') + const results = await openLocation(loc, this.pluginManager).readFile('utf8') + const refColumn = this.getConf('refNameColumn') return results .trim() .split(/\n|\r\n|\r/) diff --git a/products/jbrowse-desktop/src/OpenSequenceDialog.tsx b/products/jbrowse-desktop/src/OpenSequenceDialog.tsx index 117fc308dd..27b523d2c7 100644 --- a/products/jbrowse-desktop/src/OpenSequenceDialog.tsx +++ b/products/jbrowse-desktop/src/OpenSequenceDialog.tsx @@ -148,7 +148,7 @@ const OpenSequenceDialog = ({ ? { refNameAliases: { adapter: { - type: 'RefNameAliasesAdapter', + type: 'RefNameAliasAdapter', location: refNameAliasesLocation, }, }, @@ -159,7 +159,7 @@ const OpenSequenceDialog = ({ cytobands: { adapter: { type: 'CytobandAdapter', - location: cytobandsLocation, + cytobandsLocation: cytobandsLocation, }, }, } @@ -248,7 +248,7 @@ const OpenSequenceDialog = ({ setLocation={setRefNameAliasesLocation} /> diff --git a/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx b/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx index c493dec0c7..c89b7c017f 100644 --- a/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx +++ b/products/jbrowse-desktop/src/StartScreen/LauncherPanel.tsx @@ -22,7 +22,7 @@ const useStyles = makeStyles()(theme => ({ }, })) -export default function StartScreenOptionsPanel({ +export default function LauncherPanel({ setPluginManager, }: { setPluginManager: (arg0: PluginManager) => void