@weng-lab/genomebrowser 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,125 +1,125 @@
1
- # Genome Browser Component Library
2
-
3
- ## Installation
4
- `yarn add @weng-lab/genomebrowser`
5
-
6
- `npm install @weng-lab/genomebrowser`
7
-
8
- ## Usage
9
-
10
- The library revolves around creating tracks and adding them to the browser. To do this, first you import the Genome Browser component, creating the browser state and dispatch function, and adding your tracks to the state. Then you pass the state and dispatch function to the GenomeBrowser component as props.
11
-
12
- ### Walkthrough
13
- First, import the Genome Browser component:
14
- ```tsx
15
- import { GenomeBrowser } from '@weng-lab/genomebrowser';
16
- ```
17
- Then you create the browser state and dispatch function with the `useBrowserState` hook:
18
-
19
- ```tsx
20
- import { useBrowserState } from '@weng-lab/genomebrowser';
21
- const [browserState, browserDispatch] = useBrowserState({
22
- domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
23
- preRenderedWidth: 1350,
24
- width: 1500,
25
- zoomLevel: 148,
26
- delta: 0,
27
- tracks: []
28
- });
29
- ```
30
-
31
- There are a few ways to add tracks to the browser.
32
- 1. You can add a track by dispatching the `ADD_TRACK` action:
33
- ```tsx
34
- import { BigWigTrackProps } from '@weng-lab/genomebrowser';
35
- const myBigWig: BigWigTrackProps = { ... }
36
- browserDispatch({ type: BrowserActionType.ADD_TRACK, track: myBigWig });
37
- ```
38
- 2. You can add a track by passing a track component as a child to the GenomeBrowser component:
39
- ```tsx
40
- import { BigBedTrack } from '@weng-lab/genomebrowser';
41
- <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
42
- <BigBedTrack ... />
43
- </GenomeBrowser>
44
- ```
45
- 3. You can also add a track by appending it to the 'tracks' array in the browser state:
46
- ```tsx
47
- import { BigWigTrackProps, BrowserState } from '@weng-lab/genomebrowser';
48
- const myBigWig: BigWigTrackProps = { ... }
49
- const myState: BrowserState = {
50
- domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
51
- ... // initialize the rest of the state
52
- tracks: [myBigWig] // add the track to the state
53
- }
54
- ```
55
-
56
- ## Full Example
57
-
58
- ```tsx
59
- // in trackExamples.ts
60
- export const bigWigExample: BigWigTrackProps = {
61
- ...DefaultBigWig,
62
- id: "1",
63
- title: "bigwig",
64
- height: 100,
65
- url: "https://downloads.wenglab.org/DNAse_All_ENCODE_MAR20_2024_merged.bw",
66
- color: "blue"
67
- }
68
- export const bigBedExample: BigBedTrackProps = {
69
- ...DefaultBigBed,
70
- id: "2",
71
- title: "bigbed",
72
- height: 75,
73
- rowHeight: 12,
74
- color: "red",
75
- url: "https://downloads.wenglab.org/GRCh38-cCREs.DCC.bigBed"
76
- }
77
- export const transcriptExample: TranscriptTrackProps = {
78
- ...DefaultTranscript,
79
- id: "3",
80
- title: "transcript",
81
- rowHeight: 12,
82
- assembly: "GRCh38",
83
- queryType: "gene",
84
- version: TranscriptHumanVersion.V47,
85
- height: 100,
86
- color: "green"
87
- }
88
- ```
89
-
90
- ```tsx
91
- // in main.tsx
92
- import { useEffect } from 'react'
93
- import {
94
- GenomeBrowser, BrowserState, BrowserActionType, useBrowserState,
95
- BigBedTrack
96
- } from '../lib'
97
- import { bigWigExample, bigBedExample, transcriptExample } from './trackExamples'
98
-
99
- const defaultState: BrowserState = {
100
- domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
101
- preRenderedWidth: 1350,
102
- width: 1500,
103
- zoomLevel: 148,
104
- delta: 0,
105
- tracks: [bigWigExample] // addS a BigWig track to the state
106
- }
107
-
108
- function Main() {
109
- const [browserState, browserDispatch] = useBrowserState(defaultState)
110
-
111
- useEffect(() => {
112
- // add a Transcript track to the state
113
- browserDispatch({ type: BrowserActionType.ADD_TRACK, track: transcriptExample })
114
- }, [])
115
-
116
- return (
117
- <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
118
- <BigBedTrack {...bigBedExample} /> // add a BigBed track to the browser
119
- </GenomeBrowser>
120
- )
121
- }
122
- ```
123
-
124
- The browser will look something like this:
1
+ # Genome Browser Component Library
2
+
3
+ ## Installation
4
+ `yarn add @weng-lab/genomebrowser`
5
+
6
+ `npm install @weng-lab/genomebrowser`
7
+
8
+ ## Usage
9
+
10
+ The library revolves around creating tracks and adding them to the browser. To do this, first you import the Genome Browser component, creating the browser state and dispatch function, and adding your tracks to the state. Then you pass the state and dispatch function to the GenomeBrowser component as props.
11
+
12
+ ### Walkthrough
13
+ First, import the Genome Browser component:
14
+ ```tsx
15
+ import { GenomeBrowser } from '@weng-lab/genomebrowser';
16
+ ```
17
+ Then you create the browser state and dispatch function with the `useBrowserState` hook:
18
+
19
+ ```tsx
20
+ import { useBrowserState } from '@weng-lab/genomebrowser';
21
+ const [browserState, browserDispatch] = useBrowserState({
22
+ domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
23
+ preRenderedWidth: 1350,
24
+ width: 1500,
25
+ zoomLevel: 148,
26
+ delta: 0,
27
+ tracks: []
28
+ });
29
+ ```
30
+
31
+ There are a few ways to add tracks to the browser.
32
+ 1. You can add a track by dispatching the `ADD_TRACK` action:
33
+ ```tsx
34
+ import { BigWigTrackProps } from '@weng-lab/genomebrowser';
35
+ const myBigWig: BigWigTrackProps = { ... }
36
+ browserDispatch({ type: BrowserActionType.ADD_TRACK, track: myBigWig });
37
+ ```
38
+ 2. You can add a track by passing a track component as a child to the GenomeBrowser component:
39
+ ```tsx
40
+ import { BigBedTrack } from '@weng-lab/genomebrowser';
41
+ <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
42
+ <BigBedTrack ... />
43
+ </GenomeBrowser>
44
+ ```
45
+ 3. You can also add a track by appending it to the 'tracks' array in the browser state:
46
+ ```tsx
47
+ import { BigWigTrackProps, BrowserState } from '@weng-lab/genomebrowser';
48
+ const myBigWig: BigWigTrackProps = { ... }
49
+ const myState: BrowserState = {
50
+ domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
51
+ ... // initialize the rest of the state
52
+ tracks: [myBigWig] // add the track to the state
53
+ }
54
+ ```
55
+
56
+ ## Full Example
57
+
58
+ ```tsx
59
+ // in trackExamples.ts
60
+ export const bigWigExample: BigWigTrackProps = {
61
+ ...DefaultBigWig,
62
+ id: "1",
63
+ title: "bigwig",
64
+ height: 100,
65
+ url: "https://downloads.wenglab.org/DNAse_All_ENCODE_MAR20_2024_merged.bw",
66
+ color: "blue"
67
+ }
68
+ export const bigBedExample: BigBedTrackProps = {
69
+ ...DefaultBigBed,
70
+ id: "2",
71
+ title: "bigbed",
72
+ height: 75,
73
+ rowHeight: 12,
74
+ color: "red",
75
+ url: "https://downloads.wenglab.org/GRCh38-cCREs.DCC.bigBed"
76
+ }
77
+ export const transcriptExample: TranscriptTrackProps = {
78
+ ...DefaultTranscript,
79
+ id: "3",
80
+ title: "transcript",
81
+ rowHeight: 12,
82
+ assembly: "GRCh38",
83
+ queryType: "gene",
84
+ version: TranscriptHumanVersion.V47,
85
+ height: 100,
86
+ color: "green"
87
+ }
88
+ ```
89
+
90
+ ```tsx
91
+ // in main.tsx
92
+ import { useEffect } from 'react'
93
+ import {
94
+ GenomeBrowser, BrowserState, BrowserActionType, useBrowserState,
95
+ BigBedTrack
96
+ } from '../lib'
97
+ import { bigWigExample, bigBedExample, transcriptExample } from './trackExamples'
98
+
99
+ const defaultState: BrowserState = {
100
+ domain: { chromosome: "chr11", start: 5220000, end: 5420000 },
101
+ preRenderedWidth: 1350,
102
+ width: 1500,
103
+ zoomLevel: 148,
104
+ delta: 0,
105
+ tracks: [bigWigExample] // adds a BigWig track to the state
106
+ }
107
+
108
+ function Main() {
109
+ const [browserState, browserDispatch] = useBrowserState(defaultState)
110
+
111
+ useEffect(() => {
112
+ // add a Transcript track to the state
113
+ browserDispatch({ type: BrowserActionType.ADD_TRACK, track: transcriptExample })
114
+ }, [])
115
+
116
+ return (
117
+ <GenomeBrowser browserState={browserState} browserDispatch={browserDispatch}>
118
+ <BigBedTrack {...bigBedExample} /> // add a BigBed track to the browser
119
+ </GenomeBrowser>
120
+ )
121
+ }
122
+ ```
123
+
124
+ The browser will look something like this:
125
125
  ![Browser Example](image.png)
@@ -1,9 +1,8 @@
1
1
  import { BrowserAction, BrowserState } from '../context/browserContext';
2
2
  import { default as React } from 'react';
3
- declare function GenomeBrowser({ children, browserState, browserDispatch, externalFetch }: {
3
+ declare function GenomeBrowser({ children, browserState, browserDispatch }: {
4
4
  children?: React.ReactNode;
5
5
  browserState: BrowserState;
6
6
  browserDispatch: React.Dispatch<BrowserAction>;
7
- externalFetch?: boolean;
8
7
  }): import("react/jsx-runtime").JSX.Element;
9
8
  export default GenomeBrowser;
@@ -1,4 +1,5 @@
1
- import { BrowserAction, BrowserState } from '../context/browserContext';
1
+ import { ReactElement } from 'react';
2
+ import { BrowserState } from '../context/browserContext';
2
3
  export type TranscriptRequest = {
3
4
  chromosome: string;
4
5
  assembly: string;
@@ -6,8 +7,9 @@ export type TranscriptRequest = {
6
7
  end: number;
7
8
  version: number;
8
9
  };
9
- declare function GQLTracks({ browserState, browserDispatch }: {
10
+ declare function GQLTracks({ children, browserState, rulerHeight }: {
11
+ children: ReactElement[];
10
12
  browserState: BrowserState;
11
- browserDispatch: React.Dispatch<BrowserAction>;
12
- }): null;
13
+ rulerHeight: number;
14
+ }): import("react/jsx-runtime").JSX.Element;
13
15
  export default GQLTracks;
@@ -10,7 +10,6 @@ export type BrowserState = {
10
10
  preRenderedWidth: number;
11
11
  width: number;
12
12
  zoomLevel: number;
13
- delta: number;
14
13
  tracks: TrackProps[];
15
14
  };
16
15
  export declare enum BrowserActionType {
@@ -30,14 +29,9 @@ export declare enum BrowserActionType {
30
29
  TRANSLATE_TRACK = "translateTrack",
31
30
  SET_RANGE = "setRange",
32
31
  UPDATE_PROPS = "updateProps",
33
- BRING_TO_TOP = "bringToTop",
34
- SET_DELTA = "setDelta"
32
+ BRING_TO_TOP = "bringToTop"
35
33
  }
36
- export type BrowserAction = SetDomain | AddTrack | UpdateTrack | SetTrackHeight | SetTrackData | SwapTracks | ShiftDomain | SetLoading | ShiftTrack | RemoveTranslation | InsertTrack | DeleteTrack | TranslateTrack | SetRange | UpdateProps | BringToTop | SetDelta;
37
- export type SetDelta = {
38
- type: BrowserActionType.SET_DELTA;
39
- delta: number;
40
- };
34
+ export type BrowserAction = SetDomain | AddTrack | UpdateTrack | SetTrackHeight | SetTrackData | SwapTracks | ShiftDomain | SetLoading | ShiftTrack | RemoveTranslation | InsertTrack | DeleteTrack | TranslateTrack | SetRange | UpdateProps | BringToTop;
41
35
  export type SetDomain = {
42
36
  type: BrowserActionType.SET_DOMAIN;
43
37
  domain: Domain;