How do I wrap Jbrowse as a custom component ? #4998
-
|
The example codes are: import '@fontsource/roboto'
import {
createViewState,
JBrowseLinearGenomeView,
} from '@jbrowse/react-linear-genome-view'
const assembly = {
name: 'GRCh38',
sequence: {
type: 'ReferenceSequenceTrack',
trackId: 'GRCh38-ReferenceSequenceTrack',
adapter: {
type: 'BgzipFastaAdapter',
fastaLocation: {
uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/fasta/GRCh38.fa.gz',
locationType: 'UriLocation',
},
faiLocation: {
uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/fasta/GRCh38.fa.gz.fai',
locationType: 'UriLocation',
},
gziLocation: {
uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/fasta/GRCh38.fa.gz.gzi',
locationType: 'UriLocation',
},
},
},
aliases: ['hg38'],
refNameAliases: {
adapter: {
type: 'RefNameAliasAdapter',
location: {
uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/hg38_aliases.txt',
locationType: 'UriLocation',
},
},
},
}
const tracks = [
{
type: 'FeatureTrack',
trackId: 'ncbi_refseq_109_hg38',
name: 'NCBI RefSeq (GFF3Tabix)',
assemblyNames: ['GRCh38'],
category: ['Annotation'],
adapter: {
type: 'Gff3TabixAdapter',
gffGzLocation: {
uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/ncbi_refseq/GCA_000001405.15_GRCh38_full_analysis_set.refseq_annotation.sorted.gff.gz',
locationType: 'UriLocation',
},
index: {
location: {
uri: 'https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/ncbi_refseq/GCA_000001405.15_GRCh38_full_analysis_set.refseq_annotation.sorted.gff.gz.tbi',
locationType: 'UriLocation',
},
},
},
},
]
const defaultSession = {
name: 'My session',
view: {
id: 'linearGenomeView',
type: 'LinearGenomeView',
tracks: [
{
type: 'ReferenceSequenceTrack',
configuration: 'GRCh38-ReferenceSequenceTrack',
displays: [
{
type: 'LinearReferenceSequenceDisplay',
configuration:
'GRCh38-ReferenceSequenceTrack-LinearReferenceSequenceDisplay',
},
],
},
{
type: 'FeatureTrack',
configuration: 'ncbi_refseq_109_hg38',
displays: [
{
type: 'LinearBasicDisplay',
configuration: 'ncbi_refseq_109_hg38-LinearBasicDisplay',
},
],
},
],
},
}
function View() {
const state = createViewState({
assembly,
tracks,
location: '10:29,838,737..29,838,819',
defaultSession,
})
return <JBrowseLinearGenomeView viewState={state} />
}
export default ViewI don't know how I should create viewState because I need to use a function called 'createViewState' to wrap some variables to make them as a state variable in the react app. and I also have to define a type for the result of 'createViewState' so the component can receive it as props, but it's quite difficult. Does anyone have good ideas to achieve it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 20 replies
-
|
can you do function View() {
return <JBrowseLinearGenomeView viewState={createViewState({
assembly,
tracks,
location: '10:29,838,737..29,838,819',
defaultSession,
})} />
}in which case if you have |
Beta Was this translation helpful? Give feedback.
-
|
@adhami3310 I've tried deploying the jbrowse2 demo using Next.js, and I've found that the app deployed with Next.js can correctly read the compressed files. However, when deployed with Reflex, it fails to read the compressed files, but it can correctly read the uncompressed files. We are using the same NPM and NodeJS versions, which is very strange. Could it be that Reflex's call to the Next.js configuration is preventing the reading of compressed files? |
Beta Was this translation helpful? Give feedback.


Yes, finally, with the help of the JBrowse author, the issue is because the version of Next.js in Reflex is a bit behind the latest version, so I simply changed the Next.js version in
.web/packages.json.and the go into
.webfolder, runand in main folder, run
Finally, JBrowse can fetch any compressed data files. So how can I easily change the Nextjs ve…