@rnacanvas/code 1.4.0 → 1.6.0
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 +67 -0
- package/_config.yml +1 -0
- package/dist/main.js +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Console Interaction
|
|
2
|
+
|
|
3
|
+
RNAcanvas Code can be interacted with using the web browser console.
|
|
4
|
+
|
|
5
|
+
The web browser console can be opened with `Ctrl+Shift+J` (or `Cmd+Option+J` on Mac).
|
|
6
|
+
|
|
7
|
+
# Quickstart
|
|
8
|
+
|
|
9
|
+
### Drawing a structure
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
// the structure to draw
|
|
13
|
+
var seq = 'AGAGUAGCAUUCUGCUUUAGACUGUUAACUUUAUGAACCACGCGUGUCACGUGGGGAGAGUUAACAGCGCCC';
|
|
14
|
+
var dotBracket = '(((((((....)))))))...(((((((((((.....(((((.......)))))..))))))))))).....';
|
|
15
|
+
|
|
16
|
+
app.drawDotBracket(seq, dotBracket);
|
|
17
|
+
|
|
18
|
+
// add some extra space around the drawn structure
|
|
19
|
+
// (and ensure that the drawing is big enough for the drawn structure)
|
|
20
|
+
app.drawing.setPadding(500);
|
|
21
|
+
|
|
22
|
+
// fit the user's view of the drawing to the drawn structure
|
|
23
|
+
app.drawingView.fitToContent();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Controlling the layout of bases
|
|
27
|
+
|
|
28
|
+
See the [full documentation](https://pzhaojohnson.github.io/rnacanvas.bases-layout/)
|
|
29
|
+
for the `@rnacanvas/bases-layout` package.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// all bases in the drawing
|
|
33
|
+
var bases = [...app.drawing.bases];
|
|
34
|
+
|
|
35
|
+
// shift the bases by the given vector
|
|
36
|
+
shift(bases, { x: 500, y: -350 });
|
|
37
|
+
|
|
38
|
+
// rotate the bases by 120 degrees clockwise
|
|
39
|
+
rotate(bases, 2 * Math.PI / 3);
|
|
40
|
+
|
|
41
|
+
// represents the central point of all bases
|
|
42
|
+
let centroid = new Centroid(bases);
|
|
43
|
+
|
|
44
|
+
// recenter the bases at (912, 204)
|
|
45
|
+
centroid.set({ x: 912, y: 204 });
|
|
46
|
+
centroid.get(); // { x: 912, y: 204 }
|
|
47
|
+
|
|
48
|
+
// all base-pairs in the secondary structure of the drawing
|
|
49
|
+
var basePairs = [...app.drawing.secondaryBonds].map(sb => [...sb.basePair]];
|
|
50
|
+
|
|
51
|
+
// radialize the bases
|
|
52
|
+
// (the default layout for the bases in a structure)
|
|
53
|
+
radialize(bases, basePairs, { spacing: 20, basePairSpacing: 10, hairpinLoopSpacing: 10 });
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Exporting a drawing
|
|
57
|
+
|
|
58
|
+
Drawings can be exported in SVG format,
|
|
59
|
+
which can be opened (and edited further) in vector graphics softwares
|
|
60
|
+
like Adobe Illustrator and Inkscape.
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// the outer HTML of the drawing is SVG XML that can be exported
|
|
64
|
+
var file = new DownloadableFile(app.drawing.outerHTML);
|
|
65
|
+
|
|
66
|
+
file.downloadAs('drawing.svg', { type: 'text/plain' });
|
|
67
|
+
```
|
package/_config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: jekyll-theme-minimal
|