dash-seqviz 0.1.0__tar.gz
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.
- dash_seqviz-0.1.0/LICENSE +21 -0
- dash_seqviz-0.1.0/MANIFEST.in +11 -0
- dash_seqviz-0.1.0/PKG-INFO +300 -0
- dash_seqviz-0.1.0/README.md +283 -0
- dash_seqviz-0.1.0/dash_seqviz/SeqViz.py +319 -0
- dash_seqviz-0.1.0/dash_seqviz/__init__.py +87 -0
- dash_seqviz-0.1.0/dash_seqviz/_imports_.py +5 -0
- dash_seqviz-0.1.0/dash_seqviz/async-SeqViz.js +3 -0
- dash_seqviz-0.1.0/dash_seqviz/async-SeqViz.js.map +1 -0
- dash_seqviz-0.1.0/dash_seqviz/dash_seqviz.min.js +2 -0
- dash_seqviz-0.1.0/dash_seqviz/dash_seqviz.min.js.map +1 -0
- dash_seqviz-0.1.0/dash_seqviz/metadata.json +1 -0
- dash_seqviz-0.1.0/dash_seqviz/package-info.json +59 -0
- dash_seqviz-0.1.0/dash_seqviz.egg-info/PKG-INFO +300 -0
- dash_seqviz-0.1.0/dash_seqviz.egg-info/SOURCES.txt +19 -0
- dash_seqviz-0.1.0/dash_seqviz.egg-info/dependency_links.txt +1 -0
- dash_seqviz-0.1.0/dash_seqviz.egg-info/top_level.txt +1 -0
- dash_seqviz-0.1.0/package.json +59 -0
- dash_seqviz-0.1.0/setup.cfg +4 -0
- dash_seqviz-0.1.0/setup.py +26 -0
- dash_seqviz-0.1.0/tests/test_usage.py +43 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Evan Roy Rees
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
include dash_seqviz/dash_seqviz.min.js
|
|
2
|
+
include dash_seqviz/dash_seqviz.min.js.map
|
|
3
|
+
include dash_seqviz/async-*.js
|
|
4
|
+
include dash_seqviz/async-*.js.map
|
|
5
|
+
include dash_seqviz/*-shared.js
|
|
6
|
+
include dash_seqviz/*-shared.js.map
|
|
7
|
+
include dash_seqviz/metadata.json
|
|
8
|
+
include dash_seqviz/package-info.json
|
|
9
|
+
include README.md
|
|
10
|
+
include LICENSE
|
|
11
|
+
include package.json
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dash_seqviz
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A wrapper of the javascript DNA, RNA and protein sequence viewer
|
|
5
|
+
Author: Evan Rees <evanroyrees@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Framework :: Dash
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: classifier
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: description-content-type
|
|
14
|
+
Dynamic: license
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
# Dash SeqViz
|
|
19
|
+
|
|
20
|
+
Dash SeqViz is a Dash component library that provides a Python wrapper for the [SeqViz](https://github.com/Lattice-Automation/seqviz) JavaScript library. SeqViz is a powerful DNA, RNA, and protein sequence visualization tool that supports circular and linear viewers, annotations, primers, restriction enzymes, and more.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- **Multiple Viewer Types**: Support for linear, circular, and both viewers
|
|
25
|
+
- **Rich Annotations**: Add annotations, primers, highlights, and translations to sequences
|
|
26
|
+
- **Restriction Enzymes**: Visualize restriction enzyme cut sites
|
|
27
|
+
- **Interactive**: Full interactivity including selection, search, and zooming
|
|
28
|
+
- **Custom Styling**: Comprehensive styling options
|
|
29
|
+
- **Dash Integration**: Seamless integration with Dash applications and callbacks
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from dash_seqviz import SeqViz
|
|
35
|
+
from dash import Dash, html
|
|
36
|
+
|
|
37
|
+
app = Dash(__name__)
|
|
38
|
+
|
|
39
|
+
app.layout = html.Div([
|
|
40
|
+
SeqViz(
|
|
41
|
+
id='my-seqviz',
|
|
42
|
+
seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC",
|
|
43
|
+
name="J23100",
|
|
44
|
+
viewer="both",
|
|
45
|
+
annotations=[
|
|
46
|
+
{
|
|
47
|
+
"start": 0,
|
|
48
|
+
"end": 22,
|
|
49
|
+
"name": "Strong promoter",
|
|
50
|
+
"direction": 1,
|
|
51
|
+
"color": "blue"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
style={"height": "500px", "width": "100%"}
|
|
55
|
+
)
|
|
56
|
+
])
|
|
57
|
+
|
|
58
|
+
if __name__ == '__main__':
|
|
59
|
+
app.run(debug=True)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## API Reference
|
|
63
|
+
|
|
64
|
+
### SeqViz Properties
|
|
65
|
+
|
|
66
|
+
#### Required Properties
|
|
67
|
+
|
|
68
|
+
- **`seq`** (string): The sequence to render. Can be DNA, RNA, or amino acid sequence.
|
|
69
|
+
|
|
70
|
+
#### Optional Properties
|
|
71
|
+
|
|
72
|
+
- **`id`** (string): The ID used to identify this component in Dash callbacks.
|
|
73
|
+
|
|
74
|
+
- **`name`** (string): The name of the sequence/plasmid. Shown at the center of the circular viewer.
|
|
75
|
+
|
|
76
|
+
- **`viewer`** (string): The type and orientation of the sequence viewers.
|
|
77
|
+
- Options: `"linear"`, `"circular"`, `"both"`, `"both_flip"`
|
|
78
|
+
- Default: `"both"`
|
|
79
|
+
|
|
80
|
+
- **`annotations`** (list): Array of annotation objects to render.
|
|
81
|
+
- Each annotation: `{"start": int, "end": int, "name": str, "direction"?: int, "color"?: str}`
|
|
82
|
+
|
|
83
|
+
- **`primers`** (list): Array of primer objects to render.
|
|
84
|
+
- Each primer: `{"start": int, "end": int, "name": str, "direction": int, "color"?: str}`
|
|
85
|
+
|
|
86
|
+
- **`highlights`** (list): Array of highlight objects.
|
|
87
|
+
- Each highlight: `{"start": int, "end": int, "color"?: str}`
|
|
88
|
+
|
|
89
|
+
- **`translations`** (list): Array of translation objects.
|
|
90
|
+
- Each translation: `{"start": int, "end": int, "direction": int, "name"?: str, "color"?: str}`
|
|
91
|
+
|
|
92
|
+
- **`enzymes`** (list): Array of restriction enzymes.
|
|
93
|
+
- Can be enzyme names (strings) or custom enzyme objects.
|
|
94
|
+
- Custom enzyme: `{"name": str, "rseq": str, "fcut": int, "rcut": int, "color"?: str, "range"?: {"start": int, "end": int}}`
|
|
95
|
+
|
|
96
|
+
- **`search`** (dict): Search configuration object.
|
|
97
|
+
- Format: `{"query": str, "mismatch"?: int}`
|
|
98
|
+
|
|
99
|
+
- **`selection`** (dict): Selection state object.
|
|
100
|
+
- Format: `{"start": int, "end": int, "clockwise"?: bool}`
|
|
101
|
+
|
|
102
|
+
- **`colors`** (list): Array of colors for annotations, translations, and highlights.
|
|
103
|
+
|
|
104
|
+
- **`bpColors`** (dict): Object mapping base pairs or indexes to custom colors.
|
|
105
|
+
- Example: `{"A": "#FF0000", "T": "#00FF00", 12: "#0000FF"}`
|
|
106
|
+
|
|
107
|
+
- **`style`** (dict): CSS styles for the outer container div.
|
|
108
|
+
- Example: `{"height": "500px", "width": "100%"}`
|
|
109
|
+
|
|
110
|
+
- **`zoom`** (dict): Zoom configuration object.
|
|
111
|
+
- Format: `{"linear": int}` (0-100)
|
|
112
|
+
- Default: `{"linear": 50}`
|
|
113
|
+
|
|
114
|
+
- **`showComplement`** (bool): Whether to show the complement sequence.
|
|
115
|
+
- Default: `true`
|
|
116
|
+
|
|
117
|
+
- **`rotateOnScroll`** (bool): Whether the circular viewer rotates on scroll.
|
|
118
|
+
- Default: `true`
|
|
119
|
+
|
|
120
|
+
- **`disableExternalFonts`** (bool): Whether to disable downloading external fonts.
|
|
121
|
+
- Default: `false`
|
|
122
|
+
|
|
123
|
+
- Deprecated (prefer parsing externally with `seqparse`):
|
|
124
|
+
- **`file`** (string | File): FASTA, GenBank, SnapGene, JBEI, or SBOL file
|
|
125
|
+
- **`accession`** (string): NCBI accession-ID
|
|
126
|
+
|
|
127
|
+
- Events / Read-only:
|
|
128
|
+
- **`onSelection`** (function): Called after selection events; selection returned also via `selection`
|
|
129
|
+
- **`onSearch`** (function): Called after search; results returned also via `searchResults` (read-only)
|
|
130
|
+
|
|
131
|
+
## Examples
|
|
132
|
+
|
|
133
|
+
### Basic Sequence Viewer
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
dash_seqviz.SeqViz(
|
|
137
|
+
seq="ATCGATCGATCGATCG",
|
|
138
|
+
name="Simple Sequence",
|
|
139
|
+
viewer="linear"
|
|
140
|
+
)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Advanced Sequence with Annotations
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
dash_seqviz.SeqViz(
|
|
147
|
+
seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC",
|
|
148
|
+
name="J23100 Promoter",
|
|
149
|
+
viewer="both",
|
|
150
|
+
annotations=[
|
|
151
|
+
{
|
|
152
|
+
"start": 0,
|
|
153
|
+
"end": 22,
|
|
154
|
+
"name": "Strong promoter",
|
|
155
|
+
"direction": 1,
|
|
156
|
+
"color": "blue"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"start": 23,
|
|
160
|
+
"end": 43,
|
|
161
|
+
"name": "RBS",
|
|
162
|
+
"direction": 1,
|
|
163
|
+
"color": "green"
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
primers=[
|
|
167
|
+
{
|
|
168
|
+
"start": 0,
|
|
169
|
+
"end": 20,
|
|
170
|
+
"name": "Forward Primer",
|
|
171
|
+
"direction": 1,
|
|
172
|
+
"color": "red"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
highlights=[
|
|
176
|
+
{
|
|
177
|
+
"start": 10,
|
|
178
|
+
"end": 30,
|
|
179
|
+
"color": "yellow"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
style={"height": "500px", "width": "100%"}
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### With Restriction Enzymes
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
dash_seqviz.SeqViz(
|
|
190
|
+
seq="GAATTCCTGCAGTTAA", # Contains EcoRI and PstI sites
|
|
191
|
+
name="Enzyme Test",
|
|
192
|
+
viewer="circular",
|
|
193
|
+
enzymes=["EcoRI", "PstI"],
|
|
194
|
+
style={"height": "400px", "width": "400px"}
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### With Search Functionality
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
dash_seqviz.SeqViz(
|
|
202
|
+
seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC",
|
|
203
|
+
name="Search Example",
|
|
204
|
+
viewer="both",
|
|
205
|
+
search={
|
|
206
|
+
"query": "GCTAGC",
|
|
207
|
+
"mismatch": 1
|
|
208
|
+
},
|
|
209
|
+
style={"height": "500px", "width": "100%"}
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Contributing
|
|
214
|
+
|
|
215
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
216
|
+
|
|
217
|
+
### Install dependencies
|
|
218
|
+
|
|
219
|
+
If you have selected install_dependencies during the prompt, you can skip this part.
|
|
220
|
+
|
|
221
|
+
1. Install npm packages
|
|
222
|
+
```
|
|
223
|
+
$ npm install
|
|
224
|
+
```
|
|
225
|
+
2. Create a virtual env and activate.
|
|
226
|
+
```
|
|
227
|
+
$ virtualenv venv
|
|
228
|
+
$ . venv/bin/activate
|
|
229
|
+
```
|
|
230
|
+
_Note: venv\Scripts\activate for windows_
|
|
231
|
+
|
|
232
|
+
3. Install python packages required to build components.
|
|
233
|
+
```
|
|
234
|
+
$ pip install -r requirements.txt
|
|
235
|
+
```
|
|
236
|
+
4. Install the python packages for testing (optional)
|
|
237
|
+
```
|
|
238
|
+
$ pip install -r tests/requirements.txt
|
|
239
|
+
```
|
|
240
|
+
(Includes biopython for demo/testing of FASTA/GenBank parsing.)
|
|
241
|
+
|
|
242
|
+
### Write your component code in `src/lib/components/SeqViz.react.js`.
|
|
243
|
+
|
|
244
|
+
- The demo app is in `src/demo` and you will import your example component code into your demo app.
|
|
245
|
+
- Test your code in a Python environment:
|
|
246
|
+
1. Build your code
|
|
247
|
+
```
|
|
248
|
+
$ npm run build
|
|
249
|
+
```
|
|
250
|
+
2. Run and modify the `usage.py` sample dash app:
|
|
251
|
+
```
|
|
252
|
+
$ python usage.py
|
|
253
|
+
```
|
|
254
|
+
- Write tests for your component.
|
|
255
|
+
- A sample test is available in `tests/test_usage.py`, it will load `usage.py` and you can then automate interactions with selenium.
|
|
256
|
+
- Run the tests with `$ pytest tests`.
|
|
257
|
+
- The Dash team uses these types of integration tests extensively. Browse the Dash component code on GitHub for more examples of testing (e.g. https://github.com/plotly/dash-core-components)
|
|
258
|
+
- Add custom styles to your component by putting your custom CSS files into your distribution folder (`dash_seqviz`).
|
|
259
|
+
- Make sure that they are referenced in `MANIFEST.in` so that they get properly included when you're ready to publish your component.
|
|
260
|
+
- Make sure the stylesheets are added to the `_css_dist` dict in `dash_seqviz/__init__.py` so dash will serve them automatically when the component suite is requested.
|
|
261
|
+
- [Review your code](./review_checklist.md)
|
|
262
|
+
|
|
263
|
+
### Create a production build and publish:
|
|
264
|
+
|
|
265
|
+
1. Build your code:
|
|
266
|
+
```
|
|
267
|
+
$ npm run build
|
|
268
|
+
```
|
|
269
|
+
2. Create a Python distribution
|
|
270
|
+
```
|
|
271
|
+
$ python setup.py sdist bdist_wheel
|
|
272
|
+
```
|
|
273
|
+
This will create source and wheel distribution in the generated the `dist/` folder.
|
|
274
|
+
See [PyPA](https://packaging.python.org/guides/distributing-packages-using-setuptools/#packaging-your-project)
|
|
275
|
+
for more information.
|
|
276
|
+
|
|
277
|
+
3. Test your tarball by copying it into a new environment and installing it locally:
|
|
278
|
+
```
|
|
279
|
+
$ pip install dash_seqviz-0.0.1.tar.gz
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
4. If it works, then you can publish the component to NPM and PyPI:
|
|
283
|
+
1. Publish on PyPI
|
|
284
|
+
```
|
|
285
|
+
$ twine upload dist/*
|
|
286
|
+
```
|
|
287
|
+
2. Cleanup the dist folder (optional)
|
|
288
|
+
```
|
|
289
|
+
$ rm -rf dist
|
|
290
|
+
```
|
|
291
|
+
3. Publish on NPM (Optional if chosen False in `publish_on_npm`)
|
|
292
|
+
```
|
|
293
|
+
$ npm publish
|
|
294
|
+
```
|
|
295
|
+
_Publishing your component to NPM will make the JavaScript bundles available on the unpkg CDN. By default, Dash serves the component library's CSS and JS locally, but if you choose to publish the package to NPM you can set `serve_locally` to `False` and you may see faster load times._
|
|
296
|
+
|
|
297
|
+
5. Share your component with the community! https://community.plotly.com/c/dash
|
|
298
|
+
1. Publish this repository to GitHub
|
|
299
|
+
2. Tag your GitHub repository with the plotly-dash tag so that it appears here: https://github.com/topics/plotly-dash
|
|
300
|
+
3. Create a post in the Dash community forum: https://community.plotly.com/c/dash
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# Dash SeqViz
|
|
2
|
+
|
|
3
|
+
Dash SeqViz is a Dash component library that provides a Python wrapper for the [SeqViz](https://github.com/Lattice-Automation/seqviz) JavaScript library. SeqViz is a powerful DNA, RNA, and protein sequence visualization tool that supports circular and linear viewers, annotations, primers, restriction enzymes, and more.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Multiple Viewer Types**: Support for linear, circular, and both viewers
|
|
8
|
+
- **Rich Annotations**: Add annotations, primers, highlights, and translations to sequences
|
|
9
|
+
- **Restriction Enzymes**: Visualize restriction enzyme cut sites
|
|
10
|
+
- **Interactive**: Full interactivity including selection, search, and zooming
|
|
11
|
+
- **Custom Styling**: Comprehensive styling options
|
|
12
|
+
- **Dash Integration**: Seamless integration with Dash applications and callbacks
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from dash_seqviz import SeqViz
|
|
18
|
+
from dash import Dash, html
|
|
19
|
+
|
|
20
|
+
app = Dash(__name__)
|
|
21
|
+
|
|
22
|
+
app.layout = html.Div([
|
|
23
|
+
SeqViz(
|
|
24
|
+
id='my-seqviz',
|
|
25
|
+
seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC",
|
|
26
|
+
name="J23100",
|
|
27
|
+
viewer="both",
|
|
28
|
+
annotations=[
|
|
29
|
+
{
|
|
30
|
+
"start": 0,
|
|
31
|
+
"end": 22,
|
|
32
|
+
"name": "Strong promoter",
|
|
33
|
+
"direction": 1,
|
|
34
|
+
"color": "blue"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
style={"height": "500px", "width": "100%"}
|
|
38
|
+
)
|
|
39
|
+
])
|
|
40
|
+
|
|
41
|
+
if __name__ == '__main__':
|
|
42
|
+
app.run(debug=True)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API Reference
|
|
46
|
+
|
|
47
|
+
### SeqViz Properties
|
|
48
|
+
|
|
49
|
+
#### Required Properties
|
|
50
|
+
|
|
51
|
+
- **`seq`** (string): The sequence to render. Can be DNA, RNA, or amino acid sequence.
|
|
52
|
+
|
|
53
|
+
#### Optional Properties
|
|
54
|
+
|
|
55
|
+
- **`id`** (string): The ID used to identify this component in Dash callbacks.
|
|
56
|
+
|
|
57
|
+
- **`name`** (string): The name of the sequence/plasmid. Shown at the center of the circular viewer.
|
|
58
|
+
|
|
59
|
+
- **`viewer`** (string): The type and orientation of the sequence viewers.
|
|
60
|
+
- Options: `"linear"`, `"circular"`, `"both"`, `"both_flip"`
|
|
61
|
+
- Default: `"both"`
|
|
62
|
+
|
|
63
|
+
- **`annotations`** (list): Array of annotation objects to render.
|
|
64
|
+
- Each annotation: `{"start": int, "end": int, "name": str, "direction"?: int, "color"?: str}`
|
|
65
|
+
|
|
66
|
+
- **`primers`** (list): Array of primer objects to render.
|
|
67
|
+
- Each primer: `{"start": int, "end": int, "name": str, "direction": int, "color"?: str}`
|
|
68
|
+
|
|
69
|
+
- **`highlights`** (list): Array of highlight objects.
|
|
70
|
+
- Each highlight: `{"start": int, "end": int, "color"?: str}`
|
|
71
|
+
|
|
72
|
+
- **`translations`** (list): Array of translation objects.
|
|
73
|
+
- Each translation: `{"start": int, "end": int, "direction": int, "name"?: str, "color"?: str}`
|
|
74
|
+
|
|
75
|
+
- **`enzymes`** (list): Array of restriction enzymes.
|
|
76
|
+
- Can be enzyme names (strings) or custom enzyme objects.
|
|
77
|
+
- Custom enzyme: `{"name": str, "rseq": str, "fcut": int, "rcut": int, "color"?: str, "range"?: {"start": int, "end": int}}`
|
|
78
|
+
|
|
79
|
+
- **`search`** (dict): Search configuration object.
|
|
80
|
+
- Format: `{"query": str, "mismatch"?: int}`
|
|
81
|
+
|
|
82
|
+
- **`selection`** (dict): Selection state object.
|
|
83
|
+
- Format: `{"start": int, "end": int, "clockwise"?: bool}`
|
|
84
|
+
|
|
85
|
+
- **`colors`** (list): Array of colors for annotations, translations, and highlights.
|
|
86
|
+
|
|
87
|
+
- **`bpColors`** (dict): Object mapping base pairs or indexes to custom colors.
|
|
88
|
+
- Example: `{"A": "#FF0000", "T": "#00FF00", 12: "#0000FF"}`
|
|
89
|
+
|
|
90
|
+
- **`style`** (dict): CSS styles for the outer container div.
|
|
91
|
+
- Example: `{"height": "500px", "width": "100%"}`
|
|
92
|
+
|
|
93
|
+
- **`zoom`** (dict): Zoom configuration object.
|
|
94
|
+
- Format: `{"linear": int}` (0-100)
|
|
95
|
+
- Default: `{"linear": 50}`
|
|
96
|
+
|
|
97
|
+
- **`showComplement`** (bool): Whether to show the complement sequence.
|
|
98
|
+
- Default: `true`
|
|
99
|
+
|
|
100
|
+
- **`rotateOnScroll`** (bool): Whether the circular viewer rotates on scroll.
|
|
101
|
+
- Default: `true`
|
|
102
|
+
|
|
103
|
+
- **`disableExternalFonts`** (bool): Whether to disable downloading external fonts.
|
|
104
|
+
- Default: `false`
|
|
105
|
+
|
|
106
|
+
- Deprecated (prefer parsing externally with `seqparse`):
|
|
107
|
+
- **`file`** (string | File): FASTA, GenBank, SnapGene, JBEI, or SBOL file
|
|
108
|
+
- **`accession`** (string): NCBI accession-ID
|
|
109
|
+
|
|
110
|
+
- Events / Read-only:
|
|
111
|
+
- **`onSelection`** (function): Called after selection events; selection returned also via `selection`
|
|
112
|
+
- **`onSearch`** (function): Called after search; results returned also via `searchResults` (read-only)
|
|
113
|
+
|
|
114
|
+
## Examples
|
|
115
|
+
|
|
116
|
+
### Basic Sequence Viewer
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
dash_seqviz.SeqViz(
|
|
120
|
+
seq="ATCGATCGATCGATCG",
|
|
121
|
+
name="Simple Sequence",
|
|
122
|
+
viewer="linear"
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Advanced Sequence with Annotations
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
dash_seqviz.SeqViz(
|
|
130
|
+
seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC",
|
|
131
|
+
name="J23100 Promoter",
|
|
132
|
+
viewer="both",
|
|
133
|
+
annotations=[
|
|
134
|
+
{
|
|
135
|
+
"start": 0,
|
|
136
|
+
"end": 22,
|
|
137
|
+
"name": "Strong promoter",
|
|
138
|
+
"direction": 1,
|
|
139
|
+
"color": "blue"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"start": 23,
|
|
143
|
+
"end": 43,
|
|
144
|
+
"name": "RBS",
|
|
145
|
+
"direction": 1,
|
|
146
|
+
"color": "green"
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
primers=[
|
|
150
|
+
{
|
|
151
|
+
"start": 0,
|
|
152
|
+
"end": 20,
|
|
153
|
+
"name": "Forward Primer",
|
|
154
|
+
"direction": 1,
|
|
155
|
+
"color": "red"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
highlights=[
|
|
159
|
+
{
|
|
160
|
+
"start": 10,
|
|
161
|
+
"end": 30,
|
|
162
|
+
"color": "yellow"
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
style={"height": "500px", "width": "100%"}
|
|
166
|
+
)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### With Restriction Enzymes
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
dash_seqviz.SeqViz(
|
|
173
|
+
seq="GAATTCCTGCAGTTAA", # Contains EcoRI and PstI sites
|
|
174
|
+
name="Enzyme Test",
|
|
175
|
+
viewer="circular",
|
|
176
|
+
enzymes=["EcoRI", "PstI"],
|
|
177
|
+
style={"height": "400px", "width": "400px"}
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### With Search Functionality
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
dash_seqviz.SeqViz(
|
|
185
|
+
seq="TTGACGGCTAGCTCAGTCCTAGGTACAGTGCTAGC",
|
|
186
|
+
name="Search Example",
|
|
187
|
+
viewer="both",
|
|
188
|
+
search={
|
|
189
|
+
"query": "GCTAGC",
|
|
190
|
+
"mismatch": 1
|
|
191
|
+
},
|
|
192
|
+
style={"height": "500px", "width": "100%"}
|
|
193
|
+
)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Contributing
|
|
197
|
+
|
|
198
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
199
|
+
|
|
200
|
+
### Install dependencies
|
|
201
|
+
|
|
202
|
+
If you have selected install_dependencies during the prompt, you can skip this part.
|
|
203
|
+
|
|
204
|
+
1. Install npm packages
|
|
205
|
+
```
|
|
206
|
+
$ npm install
|
|
207
|
+
```
|
|
208
|
+
2. Create a virtual env and activate.
|
|
209
|
+
```
|
|
210
|
+
$ virtualenv venv
|
|
211
|
+
$ . venv/bin/activate
|
|
212
|
+
```
|
|
213
|
+
_Note: venv\Scripts\activate for windows_
|
|
214
|
+
|
|
215
|
+
3. Install python packages required to build components.
|
|
216
|
+
```
|
|
217
|
+
$ pip install -r requirements.txt
|
|
218
|
+
```
|
|
219
|
+
4. Install the python packages for testing (optional)
|
|
220
|
+
```
|
|
221
|
+
$ pip install -r tests/requirements.txt
|
|
222
|
+
```
|
|
223
|
+
(Includes biopython for demo/testing of FASTA/GenBank parsing.)
|
|
224
|
+
|
|
225
|
+
### Write your component code in `src/lib/components/SeqViz.react.js`.
|
|
226
|
+
|
|
227
|
+
- The demo app is in `src/demo` and you will import your example component code into your demo app.
|
|
228
|
+
- Test your code in a Python environment:
|
|
229
|
+
1. Build your code
|
|
230
|
+
```
|
|
231
|
+
$ npm run build
|
|
232
|
+
```
|
|
233
|
+
2. Run and modify the `usage.py` sample dash app:
|
|
234
|
+
```
|
|
235
|
+
$ python usage.py
|
|
236
|
+
```
|
|
237
|
+
- Write tests for your component.
|
|
238
|
+
- A sample test is available in `tests/test_usage.py`, it will load `usage.py` and you can then automate interactions with selenium.
|
|
239
|
+
- Run the tests with `$ pytest tests`.
|
|
240
|
+
- The Dash team uses these types of integration tests extensively. Browse the Dash component code on GitHub for more examples of testing (e.g. https://github.com/plotly/dash-core-components)
|
|
241
|
+
- Add custom styles to your component by putting your custom CSS files into your distribution folder (`dash_seqviz`).
|
|
242
|
+
- Make sure that they are referenced in `MANIFEST.in` so that they get properly included when you're ready to publish your component.
|
|
243
|
+
- Make sure the stylesheets are added to the `_css_dist` dict in `dash_seqviz/__init__.py` so dash will serve them automatically when the component suite is requested.
|
|
244
|
+
- [Review your code](./review_checklist.md)
|
|
245
|
+
|
|
246
|
+
### Create a production build and publish:
|
|
247
|
+
|
|
248
|
+
1. Build your code:
|
|
249
|
+
```
|
|
250
|
+
$ npm run build
|
|
251
|
+
```
|
|
252
|
+
2. Create a Python distribution
|
|
253
|
+
```
|
|
254
|
+
$ python setup.py sdist bdist_wheel
|
|
255
|
+
```
|
|
256
|
+
This will create source and wheel distribution in the generated the `dist/` folder.
|
|
257
|
+
See [PyPA](https://packaging.python.org/guides/distributing-packages-using-setuptools/#packaging-your-project)
|
|
258
|
+
for more information.
|
|
259
|
+
|
|
260
|
+
3. Test your tarball by copying it into a new environment and installing it locally:
|
|
261
|
+
```
|
|
262
|
+
$ pip install dash_seqviz-0.0.1.tar.gz
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
4. If it works, then you can publish the component to NPM and PyPI:
|
|
266
|
+
1. Publish on PyPI
|
|
267
|
+
```
|
|
268
|
+
$ twine upload dist/*
|
|
269
|
+
```
|
|
270
|
+
2. Cleanup the dist folder (optional)
|
|
271
|
+
```
|
|
272
|
+
$ rm -rf dist
|
|
273
|
+
```
|
|
274
|
+
3. Publish on NPM (Optional if chosen False in `publish_on_npm`)
|
|
275
|
+
```
|
|
276
|
+
$ npm publish
|
|
277
|
+
```
|
|
278
|
+
_Publishing your component to NPM will make the JavaScript bundles available on the unpkg CDN. By default, Dash serves the component library's CSS and JS locally, but if you choose to publish the package to NPM you can set `serve_locally` to `False` and you may see faster load times._
|
|
279
|
+
|
|
280
|
+
5. Share your component with the community! https://community.plotly.com/c/dash
|
|
281
|
+
1. Publish this repository to GitHub
|
|
282
|
+
2. Tag your GitHub repository with the plotly-dash tag so that it appears here: https://github.com/topics/plotly-dash
|
|
283
|
+
3. Create a post in the Dash community forum: https://community.plotly.com/c/dash
|