in client/client/modules/render/tracks/gene/internal/renderer/features/drawing/aminoacidFeatureRenderer.js [150:326]
render(feature, viewport, graphicsObj, labelContainer, dockableElementsContainer, attachedElementsContainer, position) {
super.render(feature, viewport, graphicsObj, labelContainer, dockableElementsContainer, attachedElementsContainer, position);
const {
graphics,
hoveredGraphics
} = graphicsObj || {};
feature.aminoacidSequence = feature.aminoacidSequence || [];
const minStartIndex = viewport.project.pixel2brushBP(-viewport.canvasSize);
const maxEndIndex = viewport.project.pixel2brushBP(2 * viewport.canvasSize);
const height = this.config.transcript.height;
const pixelsInBp = viewport.factor;
const shouldDisplayAminoacidLabels = viewport.convert.brushBP2pixel(AMINOACID_LENGTH_IN_BASE_PAIRS) >= this._aminoacidLabelWidth;
const shouldDisplayStartLabel = viewport.convert.brushBP2pixel(AMINOACID_LENGTH_IN_BASE_PAIRS) >= this._startLabelWidth;
const shouldDisplayStopLabel = viewport.convert.brushBP2pixel(AMINOACID_LENGTH_IN_BASE_PAIRS) >= this._stopLabelWidth;
const strandDirection = AminoacidFeatureRenderer.getStrandDirectionEnumValue(feature);
for (let i = 0; i < feature.aminoacidSequence.length; i++) {
const acid = feature.aminoacidSequence[i];
if (acid.startIndex < minStartIndex || acid.startIndex > maxEndIndex) {
continue;
}
if (
this.gffShowNumbersAminoacid &&
this.shouldNumberAminoacids(viewport) &&
this.labelsManager
) {
const indexAcid = acid.index + 1;
const aminoacidNumber = this.labelsManager.getLabel(indexAcid, this.config.aminoacid.number, true);
if (aminoacidNumber) {
const aminoacidNumberPosition = {
x: viewport.project.brushBP2pixel(acid.startIndex) +
viewport.convert.brushBP2pixel(acid.endIndex - acid.startIndex + 1) / 2 - aminoacidNumber.width / 2,
y: Math.round(position.y - height / 2 - aminoacidNumber.height)
};
aminoacidNumber.x = Math.round(aminoacidNumberPosition.x);
aminoacidNumber.y = Math.round(aminoacidNumberPosition.y);
labelContainer.addChild(aminoacidNumber);
this.registerLabel(
aminoacidNumber,
aminoacidNumberPosition,
{
end: acid.endIndex,
start: acid.startIndex,
},
false,
true
);
}
}
let startStrandFactor = 0;
let endStrandFactor = 0;
let startDiff = 0;
let endDiff = 0;
const startEndDiffHeightFactor = 4;
if (!((strandDirection > 0 && i === 0) || (strandDirection < 0 && i === feature.aminoacidSequence.length - 1))) {
startDiff = -strandDirection * this.config.transcript.features.strand.arrow.height / startEndDiffHeightFactor;
startStrandFactor = strandDirection;
}
if (!((strandDirection < 0 && i === 0) || (strandDirection > 0 && i === feature.aminoacidSequence.length - 1))) {
endDiff = -strandDirection * this.config.transcript.features.strand.arrow.height / startEndDiffHeightFactor;
endStrandFactor = strandDirection;
}
const {fill, labelStyle, shouldDisplayLabel} = this._getLabelStyleConfig(acid, shouldDisplayStopLabel, shouldDisplayStartLabel);
graphics
.beginFill(fill, 1)
.lineStyle(0, fill, 0)
.moveTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff,
position.y - height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff +
startStrandFactor * this.config.transcript.features.strand.arrow.height / 2,
position.y
)
.lineTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff,
position.y + height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.endIndex) + pixelsInBp / 2 + endDiff,
position.y + height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.endIndex) + pixelsInBp / 2 + endDiff +
endStrandFactor * this.config.transcript.features.strand.arrow.height / 2,
position.y
)
.lineTo(
viewport.project.brushBP2pixel(acid.endIndex) + pixelsInBp / 2 + endDiff,
position.y - height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff,
position.y - height / 2
)
.endFill();
hoveredGraphics
.beginFill(ColorProcessor.darkenColor(fill, 0.2), 1)
.lineStyle(0, ColorProcessor.darkenColor(fill, 0.2), 0)
.moveTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff,
position.y - height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff +
startStrandFactor * this.config.transcript.features.strand.arrow.height / 2,
position.y
)
.lineTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff,
position.y + height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.endIndex) + pixelsInBp / 2 + endDiff,
position.y + height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.endIndex) + pixelsInBp / 2 + endDiff +
endStrandFactor * this.config.transcript.features.strand.arrow.height / 2,
position.y
)
.lineTo(
viewport.project.brushBP2pixel(acid.endIndex) + pixelsInBp / 2 + endDiff,
position.y - height / 2
)
.lineTo(
viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff,
position.y - height / 2
)
.endFill();
this.updateTextureCoordinates(
{
x: viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2 + startDiff,
y: position.y - height / 2
});
if (
shouldDisplayLabel &&
shouldDisplayAminoacidLabels &&
acid.endIndex - acid.startIndex >= 1 &&
this.labelsManager
) {
const label = this.labelsManager.getLabel(acid.text.toUpperCase(), labelStyle, true);
if (label) {
const yOffset = 0.5;
const labelPosition = {
x: viewport.project.brushBP2pixel(acid.startIndex) +
viewport.convert.brushBP2pixel(acid.endIndex - acid.startIndex + 1) / 2 - label.width / 2,
y: Math.round(position.y - label.height / 2 - yOffset)
};
label.x = Math.round(labelPosition.x);
label.y = Math.round(labelPosition.y);
labelContainer.addChild(label);
this.registerLabel(
label,
labelPosition,
{
end: acid.endIndex,
start: acid.startIndex,
},
false,
true);
}
this.registerFeaturePosition(AminoacidFeatureRenderer.getAminoacidInfo(acid), {
x1: viewport.project.brushBP2pixel(acid.startIndex) - pixelsInBp / 2,
x2: viewport.project.brushBP2pixel(acid.endIndex) + pixelsInBp / 2,
y1: position.y - height / 2,
y2: position.y + height / 2
}, null, FEATURE_INDEX_AMINOACID);
}
}
}