Skip to content

Commit

Permalink
Fix some links, modularize a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Apr 18, 2023
1 parent 711850b commit 0caede6
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 175 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* eslint-disable no-console */
import React from 'react'
import { createViewState, JBrowseLinearGenomeView } from '../src'
import { getVolvoxConfig } from './util'

export const OneLinearGenomeView = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
// use 1-based coordinates for locstring
location: 'ctgA:1105..1221',
onChange: patch => {
console.log('patch', patch)
},
})
return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/BasicUsage.stories.tsx">
Source code
</a>
</div>
)
}

export const UsingLocObject = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
// use 0-based coordinates for "location object" here
location: { refName: 'ctgA', start: 10000, end: 20000 },
})
return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/BasicUsage.stories.tsx">
Source code
</a>
</div>
)
}

export const DisableAddTracks = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
disableAddTracks: true,
})
return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/BasicUsage.stories.tsx">
Source code
</a>
</div>
)
}

export const WithShowTrack = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
location: 'ctgA:1105..1221',
})
// this is the 'showTrack' method on the linear genome view
// full reference https://jbrowse.org/jb2/docs/models/lineargenomeview/#action-showtrack
state.session.view.showTrack('volvox-long-reads-sv-bam')

return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/BasicUsage.stories.tsx">
Source code
</a>
</div>
)
}

export default { title: 'Source: Basic usage' }
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ are open is stored in a session. It is possible to configure a JB2 app with a
Here is an example LGV with a long reads alignment track loaded in the
`defaultSession`:

<Story id="source-other-miscellaneous-examples--with-long-reads" />
<Story id="source-with-default-session--with-long-reads" />

## Creating a default session

Expand Down Expand Up @@ -78,10 +78,11 @@ For example, to display a ReferenceSequenceTrack with the id
## Exporting sessions from JBrowse Web/Desktop for use in @jbrowse/react-linear-genome-view

A powerful tool for learning about track types and display types for default
sessions is the feature for exporting sessions in the main JBrowse 2 app (File >
Export session). This feature exports a JSON file of the current session in the
app. This feature can also be used to graphically generate the desired view
configuration for the React LGV component.
sessions is the feature for exporting sessions in the main JBrowse 2 app (File

> Export session). This feature exports a JSON file of the current session in
> the app. This feature can also be used to graphically generate the desired
> view configuration for the React LGV component.
To create a default session using JB2, load whatever tracks and data you want to
be displayed into a session with a single linear genome view open. Export the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react'
import { createViewState, JBrowseLinearGenomeView } from '../src'
import { getVolvoxConfig } from './util'

export const WithLongReads = () => {
// this default session loads an alignments track at startup
const defaultSession = {
id: 'wBejr9mPa',
name: 'Integration test example 2/25/2021, 9:11:35 AM',
view: {
id: 'integration_test',
type: 'LinearGenomeView',
offsetPx: 2000,
bpPerPx: 0.05,
displayedRegions: [
{
refName: 'ctgA',
start: 0,
end: 50001,
reversed: false,
assemblyName: 'volvox',
},
],
tracks: [
{
id: 'mCKjn5ta9',
type: 'AlignmentsTrack',
configuration: 'volvox-long-reads-sv-bam',
displays: [
{
id: 'CGblPB7sB0',
type: 'LinearAlignmentsDisplay',
configuration: 'volvox-long-reads-sv-bam-LinearAlignmentsDisplay',
},
],
},
],
},
}
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
defaultSession,
location: 'ctgA:1105..1221',
})

return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/DefaultSessions.stories.tsx">
Source code
</a>
</div>
)
}

export default { title: 'Source: With default session' }
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ demonstration of how the component looks and works.

This is an example of what a story looks like:

<Story id="linear-view--one-linear-genome-view" name="One linear genome view" />
<Story id="source-basic-usage--one-linear-genome-view" />

You can test out the various features of the component, and open tracks and
interact with it as you would in your app. You can also click on the code button
Expand Down Expand Up @@ -77,7 +77,7 @@ const state = createViewState({

Example

<Story id="linear-view--using-loc-object" name="Using location" />
<Story id="source-basic-usage--using-loc-object" name="Using location" />

## Disabling the ability to add tracks

Expand All @@ -97,17 +97,15 @@ const state = createViewState({

Example

<Canvas>
<Story id="linear-view--disable-add-tracks" name="Disable add tracks" />
</Canvas>
<Story id="source-basic-usage--disable-add-tracks" name="Disable add tracks" />

## Opening up tracks by default

You can use the "showTrack" function on the object returned by createViewState
You can use the `showTrack` function on the object returned by `createViewState`
to show a track with a given trackId. This can be easier than using the
defaultSession.

<Canvas>
<Story id="linear-view--with-show-track" name="Show track" />
</Canvas>
<Story id="source-basic-usage--with-show-track" name="Show track" />

## An overview of the LGV API

Expand Down Expand Up @@ -150,23 +148,6 @@ The LGV component only accepts a single assembly object instead of an array:
}
```

You can also set an initial location for when the browser first loads on the
package when you initialize the state of the component with your configuration
values:

```js
const state = createViewState({
assembly,
tracks,
location: '10:29,838,737..29,838,819',
defaultSession,
})
```

Example

<Story id="linear-view--using-loc-object" name="Using loc object" />

## Additional resources

This overview is intended as a launching point for initial use of the LGV
Expand All @@ -175,6 +156,10 @@ for what is possible with the component.

Here are a few more resources that may help:

- [The guide for creating default sessions](/?path=/story/default-sessions--page)
- [The guide for creating default sessions](?path=/docs/default-sessions--docs)
- [Code example](https://github.com/GMOD/jbrowse-components/blob/HEAD/products/jbrowse-react-linear-genome-view/docs/example.md)
- [Story source code](https://github.com/GMOD/jbrowse-components/tree/main/products/jbrowse-react-linear-genome-view/stories)
for using @jbrowse/react-linear-genome-view
- [Source code for all the storybook examples](https://github.com/GMOD/jbrowse-components/tree/main/products/jbrowse-react-linear-genome-view/stories)
- Examples of using @jbrowse/react-linear-genome-view in create-react-app, vite,
and next.js
[https://jbrowse.org/jb2/docs/embedded_components/](https://jbrowse.org/jb2/docs/embedded_components/)
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const Example = () => {
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/gmod/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/HumanExomeExample.stories.tsx">
source code
Source code
</a>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,82 +1,7 @@
/* eslint-disable no-console */
import React from 'react'
import { createViewState, JBrowseLinearGenomeView } from '../src'
import { getVolvoxConfig } from './util'

export const OneLinearGenomeView = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
// use 1-based coordinates for locstring
location: 'ctgA:1105..1221',
onChange: patch => {
console.log('patch', patch)
},
})
return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/Miscellaneous.stories.tsx">
Source code
</a>
</div>
)
}

export const UsingLocObject = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
// use 0-based coordinates for "location object" here
location: { refName: 'ctgA', start: 10000, end: 20000 },
})
return (
<div>
<JBrowseLinearGenomeView viewState={state} />
</div>
)
}

export const DisableAddTracks = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
disableAddTracks: true,
})
return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/Miscellaneous.stories.tsx">
Source code
</a>
</div>
)
}

export const WithShowTrack = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
location: 'ctgA:1105..1221',
})
// this is the 'showTrack' method on the linear genome view
// full reference https://jbrowse.org/jb2/docs/models/lineargenomeview/#action-showtrack
state.session.view.showTrack('volvox-long-reads-sv-bam')

return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/Miscellaneous.stories.tsx">
Source code
</a>
</div>
)
}

export const WithOutsideStyling = () => {
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
Expand Down Expand Up @@ -128,57 +53,4 @@ export const WithTwoLinearGenomeViews = () => {
)
}

export const WithLongReads = () => {
// this default session loads an alignments track at startup
const defaultSession = {
id: 'wBejr9mPa',
name: 'Integration test example 2/25/2021, 9:11:35 AM',
view: {
id: 'integration_test',
type: 'LinearGenomeView',
offsetPx: 2000,
bpPerPx: 0.05,
displayedRegions: [
{
refName: 'ctgA',
start: 0,
end: 50001,
reversed: false,
assemblyName: 'volvox',
},
],
tracks: [
{
id: 'mCKjn5ta9',
type: 'AlignmentsTrack',
configuration: 'volvox-long-reads-sv-bam',
displays: [
{
id: 'CGblPB7sB0',
type: 'LinearAlignmentsDisplay',
configuration: 'volvox-long-reads-sv-bam-LinearAlignmentsDisplay',
},
],
},
],
},
}
const { assembly, tracks } = getVolvoxConfig()
const state = createViewState({
assembly,
tracks,
defaultSession,
location: 'ctgA:1105..1221',
})

return (
<div>
<JBrowseLinearGenomeView viewState={state} />
<a href="https://github.com/GMOD/jbrowse-components/blob/main/products/jbrowse-react-linear-genome-view/stories/Miscellaneous.stories.tsx">
Source code
</a>
</div>
)
}

export default { title: 'Source: Other miscellaneous examples' }
Loading

0 comments on commit 0caede6

Please sign in to comment.