Skip to content

Commit abdd4cc

Browse files
authored
Merge pull request #16 from stephenshank/master
v0.1.0
2 parents cbb01cf + 02584ab commit abdd4cc

File tree

19 files changed

+578
-156
lines changed

19 files changed

+578
-156
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ dist/alignment.js
1111
*.ttf
1212
*.eot
1313
tags*
14+
.tern-port

dist/data/sorted.bam

10.1 MB
Binary file not shown.

dist/data/sorted.bam.bai

96 Bytes
Binary file not shown.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
{
22
"name": "alignment.js",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"main": "lib/alignment.js",
55
"license": "MIT",
66
"dependencies": {
7-
"@babel/plugin-proposal-class-properties": "^7.4.4",
87
"@gmod/bam": "^1.0.18",
98
"bootstrap": "^4.1.1",
109
"d3": "5",
1110
"d3-save-svg": "^0.0.2",
1211
"express": "^4.16.4",
1312
"file-saver": "^2.0.0",
1413
"jquery": "^3.3.1",
15-
"phylotree": "1.0.0-alpha.14",
14+
"phylotree": "1.0.0-alpha.17",
1615
"popper.js": "^1.14.3",
1716
"react": "^16.2.0",
1817
"react-dom": "^16.2.0",
19-
"react-phylotree": "^0.0.1",
18+
"react-phylotree": "0.1.0",
2019
"react-router-dom": "^4.3.1",
2120
"save-svg-as-png": "^1.4.14",
2221
"text-width": "^1.2.0",
@@ -25,6 +24,7 @@
2524
"devDependencies": {
2625
"@babel/cli": "^7.4.4",
2726
"@babel/core": "^7.4.5",
27+
"@babel/plugin-proposal-class-properties": "^7.4.4",
2828
"@babel/preset-env": "^7.4.5",
2929
"@babel/preset-react": "^7.0.0",
3030
"autoprefixer": "^8.4.1",

src/Alignment.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Alignment extends Component {
4343
}
4444
initialize(props) {
4545
if (props.fasta) {
46-
const { fasta, site_size, width, height, axis_height } = props;
46+
const { fasta, site_size, width, height } = props;
4747
this.sequence_data = fastaParser(fasta);
4848
const { sequence_data } = this;
4949
const { label_padding } = this.props;
@@ -84,6 +84,7 @@ class Alignment extends Component {
8484
sequence_data={this.sequence_data}
8585
x_pixel={this.x_pixel}
8686
scroll_broadcaster={this.scroll_broadcaster}
87+
start_site={this.props.start_site}
8788
/>
8889
<SequenceAxis
8990
width={this.label_width}
@@ -92,6 +93,7 @@ class Alignment extends Component {
9293
site_size={this.props.site_size}
9394
y_pixel={this.y_pixel}
9495
scroll_broadcaster={this.scroll_broadcaster}
96+
onClick={this.props.onSequenceClick}
9597
/>
9698
<BaseAlignment
9799
width={width - this.label_width}
@@ -119,7 +121,9 @@ Alignment.defaultProps = {
119121
width: 960,
120122
height: 500,
121123
sender: "main",
122-
molecule: mol => mol
124+
molecule: mol => mol,
125+
start_site: 0,
126+
onSequenceClick: (label, i) => () => null
123127
};
124128

125129
export default Alignment;

src/TreeAlignment.jsx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import React, { Component } from "react";
2+
3+
import Placeholder from "./components/Placeholder.jsx";
4+
import SiteAxis from "./components/SiteAxis.jsx";
5+
import BaseAlignment from "./components/BaseAlignment.jsx";
6+
import Tree from "./components/Tree.jsx";
7+
import ScrollBroadcaster from "./helpers/ScrollBroadcaster";
8+
import { nucleotide_color, nucleotide_text_color } from "./helpers/colors";
9+
10+
function TreeAlignment(props) {
11+
const { sequence_data } = props;
12+
if (!sequence_data) return <div />;
13+
const { width, tree_width, height, axis_height, site_size } = props,
14+
full_pixel_width = sequence_data
15+
? sequence_data[0].seq.length * site_size
16+
: null,
17+
full_pixel_height = sequence_data ? sequence_data.length * site_size : null,
18+
alignment_width = full_pixel_width
19+
? Math.min(full_pixel_width, width - tree_width)
20+
: width,
21+
alignment_height = full_pixel_height
22+
? Math.min(full_pixel_height, height - axis_height)
23+
: height,
24+
scroll_broadcaster = new ScrollBroadcaster({
25+
width: full_pixel_width,
26+
height: full_pixel_height,
27+
x_pad: width - tree_width,
28+
y_pad: height - axis_height,
29+
bidirectional: [
30+
"alignmentjs-alignment",
31+
"alignmentjs-axis-div",
32+
"alignmentjs-tree-div"
33+
]
34+
});
35+
return (
36+
<div id="alignmentjs-main-div">
37+
<Placeholder width={tree_width} height={axis_height} />
38+
<SiteAxis
39+
width={alignment_width}
40+
height={axis_height}
41+
sequence_data={props.sequence_data}
42+
scroll_broadcaster={scroll_broadcaster}
43+
/>
44+
<Tree
45+
tree={props.tree}
46+
width={tree_width}
47+
height={alignment_height}
48+
site_size={props.site_size}
49+
scroll_broadcaster={scroll_broadcaster}
50+
/>
51+
<BaseAlignment
52+
sequence_data={props.sequence_data}
53+
width={alignment_width}
54+
height={alignment_height}
55+
site_size={props.site_size}
56+
site_color={props.site_color}
57+
scroll_broadcaster={scroll_broadcaster}
58+
molecule={props.molecule}
59+
/>
60+
</div>
61+
);
62+
}
63+
64+
TreeAlignment.defaultProps = {
65+
site_color: nucleotide_color,
66+
text_color: nucleotide_text_color,
67+
label_padding: 10,
68+
site_size: 20,
69+
axis_height: 25,
70+
width: 960,
71+
tree_width: 500,
72+
height: 500,
73+
sender: "main",
74+
molecule: mol => mol
75+
};
76+
77+
export default TreeAlignment;

src/app.jsx

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as FASTA from "./app/FASTA.jsx";
1010
import * as FNA from "./app/FNA.jsx";
1111
import * as BAM from "./app/BAM.jsx";
1212
import Components from "./app/Components.jsx";
13+
import PreventDefaultPatch from "./prevent_default_patch";
1314
import "./app/styles.scss";
1415

1516
function Divider(props) {
@@ -86,6 +87,7 @@ function BAMLinks(props) {
8687
<Link to="/sam-viewer" header="Viewer" />
8788
<Divider header="Examples" />
8889
<Link to="/sam-variantcaller" header="Variant caller" />
90+
<Link to="/sam-scaffold" header="Scaffold viewer" />
8991
</Dropdown>
9092
);
9193
}
@@ -136,6 +138,7 @@ class App extends Component {
136138
<Route path="/fna-basesvgtree" component={FNA.BaseSVGTreeInstance} />
137139

138140
<Route path="/sam-viewer" component={BAM.BAMViewer} />
141+
<Route path="/sam-scaffold" component={BAM.ScaffoldExample} />
139142
<Route path="/sam-variantcaller" component={BAM.VariantCaller} />
140143
</div>
141144
</div>
@@ -151,57 +154,7 @@ function Main(props) {
151154
);
152155
}
153156

154-
/* Temporary fix for a breaking change in Chrome to React
155-
* See https://github.com/facebook/react/issues/14856
156-
*/
157-
const EVENTS_TO_MODIFY = [
158-
"touchstart",
159-
"touchmove",
160-
"touchend",
161-
"touchcancel",
162-
"wheel"
163-
];
164-
165-
const originalAddEventListener = document.addEventListener.bind();
166-
document.addEventListener = (type, listener, options, wantsUntrusted) => {
167-
let modOptions = options;
168-
if (EVENTS_TO_MODIFY.includes(type)) {
169-
if (typeof options === "boolean") {
170-
modOptions = {
171-
capture: options,
172-
passive: false
173-
};
174-
} else if (typeof options === "object") {
175-
modOptions = {
176-
...options,
177-
passive: false
178-
};
179-
}
180-
}
181-
182-
return originalAddEventListener(type, listener, modOptions, wantsUntrusted);
183-
};
184-
185-
const originalRemoveEventListener = document.removeEventListener.bind();
186-
document.removeEventListener = (type, listener, options) => {
187-
let modOptions = options;
188-
if (EVENTS_TO_MODIFY.includes(type)) {
189-
if (typeof options === "boolean") {
190-
modOptions = {
191-
capture: options,
192-
passive: false
193-
};
194-
} else if (typeof options === "object") {
195-
modOptions = {
196-
...options,
197-
passive: false
198-
};
199-
}
200-
}
201-
return originalRemoveEventListener(type, listener, modOptions);
202-
};
203-
// End of temporary fix
204-
157+
PreventDefaultPatch(document);
205158
ReactDOM.render(
206159
<Main />,
207160
document.body.appendChild(document.createElement("div"))

0 commit comments

Comments
 (0)