Skip to content

Commit 59f49d4

Browse files
committed
add target genome rough alignment block
1 parent 7932d29 commit 59f49d4

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

frontend/src/components/trackVis/GenomeAlignTrack.tsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ export class GenomeAlignTrack extends React.Component<PropsFromTrackContainer> {
187187
}
188188
}
189189
// Add arrow to query region, arrow direction is determined by plotReverse.
190-
renderRoughStrand(strand: string, viewWindow: OpenInterval) {
190+
renderRoughStrand(strand: string, height: number, viewWindow: OpenInterval) {
191191
const plotReverse = strand === '-'?true:false;
192192
return <AnnotationArrows
193193
key={"roughArrow" + viewWindow.start}
194194
startX={viewWindow.start}
195195
endX={viewWindow.end}
196-
y={ROUGH_MODE_HEIGHT - RECT_HEIGHT}
196+
y={height}
197197
height={RECT_HEIGHT}
198198
opacity={0.75}
199199
isToRight={!plotReverse}
@@ -202,8 +202,17 @@ export class GenomeAlignTrack extends React.Component<PropsFromTrackContainer> {
202202
}
203203

204204
renderRoughAlignment(placement: PlacedMergedAlignment, plotReverse: boolean) {
205-
const {queryFeature, queryXSpan, segments} = placement;
205+
const {queryFeature, queryXSpan, segments,targetXSpan} = placement;
206206
const queryRectTopY = ROUGH_MODE_HEIGHT - RECT_HEIGHT;
207+
const targetGenomeRect = <rect
208+
x={targetXSpan.start}
209+
y={0}
210+
width={targetXSpan.getLength()}
211+
height={RECT_HEIGHT}
212+
fill={PRIMARY_COLOR}
213+
// tslint:disable-next-line:jsx-no-lambda
214+
onClick={() => alert("You clicked on " + queryFeature.getLocus().toString())}
215+
/>;
207216
const queryGenomeRect = <rect
208217
x={queryXSpan.start}
209218
y={queryRectTopY}
@@ -231,10 +240,10 @@ export class GenomeAlignTrack extends React.Component<PropsFromTrackContainer> {
231240

232241
const segmentPolygons = segments.map((segment, i) => {
233242
const points = [
234-
[Math.floor(segment.targetXSpan.start), 0],
243+
[Math.floor(segment.targetXSpan.start), RECT_HEIGHT],
235244
[Math.floor(segment.queryXSpan.start), queryRectTopY],
236245
[Math.ceil(segment.queryXSpan.end), queryRectTopY],
237-
[Math.ceil(segment.targetXSpan.end), 0],
246+
[Math.ceil(segment.targetXSpan.end), RECT_HEIGHT],
238247
];
239248
if ((!plotReverse && segment.record.queryStrand === '-') ||
240249
(plotReverse && segment.record.queryStrand === '+')) {
@@ -252,6 +261,7 @@ export class GenomeAlignTrack extends React.Component<PropsFromTrackContainer> {
252261
});
253262

254263
return <React.Fragment key={queryFeature.getLocus().toString()} >
264+
{targetGenomeRect}
255265
{queryGenomeRect}
256266
{label}
257267
{ensureMaxListLength(segmentPolygons, MAX_POLYGONS)}
@@ -283,7 +293,7 @@ export class GenomeAlignTrack extends React.Component<PropsFromTrackContainer> {
283293
* @inheritdoc
284294
*/
285295
render() {
286-
const {width, trackModel, alignment} = this.props;
296+
const {width, trackModel, alignment, viewWindow} = this.props;
287297
let height, svgElements = [];
288298
const hoverHeight = FINE_MODE_HEIGHT - ALIGN_TRACK_MARGIN;
289299
let visualizer;
@@ -320,9 +330,11 @@ export class GenomeAlignTrack extends React.Component<PropsFromTrackContainer> {
320330
const queryXSpanArray = [].concat.apply([], queryXSpanArrayArray);
321331
const strand = alignment.plotStrand;
322332
svgElements = drawData.map(placement => this.renderRoughAlignment(placement, strand==='-'));
323-
const viewWindow = alignment.primaryVisData.viewWindow;
324-
const arrow = this.renderRoughStrand(strand, viewWindow);
325-
svgElements.push(arrow);
333+
const arrows = this.renderRoughStrand("+", 0, viewWindow);
334+
svgElements.push(arrows);
335+
const primaryViewWindow = alignment.primaryVisData.viewWindow;
336+
const primaryArrows = this.renderRoughStrand(strand, ROUGH_MODE_HEIGHT - RECT_HEIGHT, primaryViewWindow);
337+
svgElements.push(primaryArrows);
326338
visualizer=(
327339
<React.Fragment>
328340
<HorizontalFragment

0 commit comments

Comments
 (0)