Skip to content

Commit ee2668f

Browse files
committed
Change to v2 api by Deepak, merge Xiaoyu's genome align track change about block on primary genome, with height/color fix
2 parents af6a69a + 59f49d4 commit ee2668f

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

frontend/src/components/trackVis/GenomeAlignTrack.tsx

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ class GenomeAlignTrackWithoutOptions extends React.Component<PropsFromTrackConta
200200
}
201201

202202
// Add arrow to query region, arrow direction is determined by plotReverse.
203-
renderRoughStrand(strand: string, viewWindow: OpenInterval, roughHeight: number) {
203+
renderRoughStrand(strand: string, topY: number, viewWindow: OpenInterval, isPrimary: boolean) {
204204
const plotReverse = strand === '-' ? true : false;
205205
return <AnnotationArrows
206-
key={"roughArrow" + viewWindow.start}
206+
key={"roughArrow" + viewWindow.start + isPrimary}
207207
startX={viewWindow.start}
208208
endX={viewWindow.end}
209-
y={roughHeight - RECT_HEIGHT}
209+
y={topY}
210210
height={RECT_HEIGHT}
211211
opacity={0.75}
212212
isToRight={!plotReverse}
@@ -215,15 +215,24 @@ class GenomeAlignTrackWithoutOptions extends React.Component<PropsFromTrackConta
215215
}
216216

217217
renderRoughAlignment(placement: PlacedMergedAlignment,
218-
plotReverse: boolean, roughHeight: number, fillColor: string) {
219-
const { queryFeature, queryXSpan, segments } = placement;
218+
plotReverse: boolean, roughHeight: number) {
219+
const { queryFeature, queryXSpan, segments, targetXSpan } = placement;
220220
const queryRectTopY = roughHeight - RECT_HEIGHT;
221+
const targetGenomeRect = <rect
222+
x={targetXSpan.start}
223+
y={0}
224+
width={targetXSpan.getLength()}
225+
height={RECT_HEIGHT}
226+
fill={this.props.options.primaryColor}
227+
// tslint:disable-next-line:jsx-no-lambda
228+
onClick={() => alert("You clicked on " + queryFeature.getLocus().toString())}
229+
/>;
221230
const queryGenomeRect = <rect
222231
x={queryXSpan.start}
223232
y={queryRectTopY}
224233
width={queryXSpan.getLength()}
225234
height={RECT_HEIGHT}
226-
fill={fillColor}
235+
fill={this.props.options.queryColor}
227236
// tslint:disable-next-line:jsx-no-lambda
228237
onClick={() => alert("You clicked on " + queryFeature.getLocus().toString())}
229238
/>;
@@ -245,10 +254,10 @@ class GenomeAlignTrackWithoutOptions extends React.Component<PropsFromTrackConta
245254

246255
const segmentPolygons = segments.map((segment, i) => {
247256
const points = [
248-
[Math.floor(segment.targetXSpan.start), 0],
257+
[Math.floor(segment.targetXSpan.start), RECT_HEIGHT],
249258
[Math.floor(segment.queryXSpan.start), queryRectTopY],
250259
[Math.ceil(segment.queryXSpan.end), queryRectTopY],
251-
[Math.ceil(segment.targetXSpan.end), 0],
260+
[Math.ceil(segment.targetXSpan.end), RECT_HEIGHT],
252261
];
253262
if ((!plotReverse && segment.record.queryStrand === '-') ||
254263
(plotReverse && segment.record.queryStrand === '+')) {
@@ -258,14 +267,15 @@ class GenomeAlignTrackWithoutOptions extends React.Component<PropsFromTrackConta
258267
return <polygon
259268
key={i}
260269
points={points as any} // Contrary to what Typescript thinks, you CAN pass a number[][].
261-
fill={fillColor}
270+
fill={this.props.options.queryColor}
262271
fillOpacity={0.5}
263272
// tslint:disable-next-line:jsx-no-lambda
264273
onClick={() => alert("You clicked on " + segment.record.getLocus())}
265274
/>;
266275
});
267276

268277
return <React.Fragment key={queryFeature.getLocus().toString()} >
278+
{targetGenomeRect}
269279
{queryGenomeRect}
270280
{label}
271281
{ensureMaxListLength(segmentPolygons, MAX_POLYGONS)}
@@ -297,7 +307,7 @@ class GenomeAlignTrackWithoutOptions extends React.Component<PropsFromTrackConta
297307
* @inheritdoc
298308
*/
299309
render() {
300-
const { width, trackModel, alignment, options } = this.props;
310+
const { width, trackModel, alignment, options, viewWindow } = this.props;
301311
const { height, queryColor, primaryColor } = options;
302312
let drawheight, svgElements = [];
303313
const hoverHeight = height - ALIGN_TRACK_MARGIN;
@@ -331,12 +341,15 @@ class GenomeAlignTrackWithoutOptions extends React.Component<PropsFromTrackConta
331341
const queryXSpanArray = [].concat.apply([], queryXSpanArrayArray);
332342
const strand = alignment.plotStrand;
333343
svgElements = drawData.map(placement =>
334-
this.renderRoughAlignment(placement, strand === '-', height, queryColor));
335-
const viewWindow = alignment.primaryVisData.viewWindow;
336-
const arrow = this.renderRoughStrand(strand, viewWindow, height);
337-
svgElements.push(arrow);
344+
this.renderRoughAlignment(placement, strand === '-', height));
345+
const arrows = this.renderRoughStrand("+", 0, viewWindow, false);
346+
svgElements.push(arrows);
347+
const primaryViewWindow = alignment.primaryVisData.viewWindow;
348+
const primaryArrows = this.renderRoughStrand(strand, height - RECT_HEIGHT, primaryViewWindow, true);
349+
svgElements.push(primaryArrows);
338350
visualizer = <HorizontalFragment
339-
height={height - RECT_HEIGHT}
351+
height={height}
352+
rectHeight={RECT_HEIGHT}
340353
primaryColor={primaryColor}
341354
queryColor={queryColor}
342355
targetXSpanList={targetXSpanArray}

frontend/src/components/trackVis/commonComponents/AlignmentCoordinates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AlignmentSequence extends React.Component {
2626
render() {
2727
const {alignment, x, halfLength, target, query, basesPerPixel} = this.props;
2828
if (!alignment) {
29-
return <div>{"No alignment available"}</div>;
29+
return <div>No alignment available</div>;
3030
}
3131
else {
3232
const highlightLength = Math.max(Math.round(basesPerPixel), 1);

frontend/src/components/trackVis/commonComponents/HorizontalFragment.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class HorizontalFragment extends React.Component {
5555
* @inheritdoc
5656
*/
5757
render() {
58-
const {height, targetXSpanList, queryXSpanList, primaryColor, queryColor, onMouseMove, onMouseLeave, style, children, ...otherProps} = this.props;
58+
const {height, targetXSpanList, queryXSpanList, primaryColor, queryColor,
59+
onMouseMove, onMouseLeave, style, children, rectHeight, ...otherProps} = this.props;
5960
// calculate xSpanIndex by comparing relativeX with tangetXSpan.
6061
const relativeX = this.state.relativeX;
6162
const xSpanIndex = targetXSpanList.reduce((iCusor, x, i) => x.start < relativeX && x.end >= relativeX ? i : iCusor, NaN);
@@ -73,8 +74,8 @@ class HorizontalFragment extends React.Component {
7374
lines = (
7475
<React.Fragment>
7576
{<HorizontalLine relativeY={LINE_MARGIN} xSpan={targetXSpan} color={primaryColor} />}
76-
{<Triangle relativeX={relativeX - TRIANGLE_SIZE} relativeY={LINE_MARGIN + LINE_WIDTH} color={primaryColor} direction={"down"}/>}
77-
{<Triangle relativeX={queryX - TRIANGLE_SIZE} relativeY={height - LINE_MARGIN - LINE_WIDTH - TRIANGLE_SIZE} color={queryColor} direction={"up"}/>}
77+
{<Triangle relativeX={relativeX - TRIANGLE_SIZE} relativeY={LINE_MARGIN + LINE_WIDTH + rectHeight} color={primaryColor} direction={"down"}/>}
78+
{<Triangle relativeX={queryX - TRIANGLE_SIZE} relativeY={height - rectHeight - LINE_MARGIN - LINE_WIDTH - TRIANGLE_SIZE} color={queryColor} direction={"up"}/>}
7879
{<HorizontalLine relativeY={height - LINE_MARGIN - LINE_WIDTH} xSpan={queryXSpan} color={queryColor} />}
7980
</React.Fragment>
8081
)

frontend/src/dataSources/GeneSource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import _ from 'lodash';
33
import DataSource from './DataSource';
44

55

6-
export const AWS_API = "https://lambda.epigenomegateway.org";
6+
export const AWS_API = "https://lambda.epigenomegateway.org/v2";
77
/**
88
* A DataSource that calls our backend API for gene annotations.
99
*

0 commit comments

Comments
 (0)