Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valis 8 prevent collision btw annot txts #39

Merged
merged 15 commits into from
Feb 4, 2022
76 changes: 60 additions & 16 deletions dist/valis-hpgv.js
Original file line number Diff line number Diff line change
Expand Up @@ -76672,7 +76672,8 @@ var AnnotationTrack = /** @class */ (function (_super) {
_this.macroLodBlendRange = 2;
_this.macroLodThresholdLow = 7;
_this.macroLodThresholdHigh = _this.macroLodThresholdLow + _this.macroLodBlendRange;
_this.namesLodBlendRange = 1;
//VALIS-8: increased 1->4 to show annotatation names at higher (zoomed out) LoD level
_this.namesLodBlendRange = 4;
_this.namesLodThresholdLow = 6;
_this.namesLodThresholdHigh = _this.namesLodThresholdLow + _this.namesLodBlendRange;
_this.annotationY = (_a = {},
Expand Down Expand Up @@ -76788,6 +76789,8 @@ var AnnotationTrack = /** @class */ (function (_super) {
namesOpacity = 0;
}
var microSamplingDensity = 1;
// VALIS-8: prevent collision between annotation names
var createdAnnotationNames = new Array();
this.getTileLoader().forEachTile(x0, x1, microSamplingDensity, true, function (tile) {
var e_1, _a;
// debug: draw red lines at tile boundaries
Expand All @@ -76805,6 +76808,7 @@ var AnnotationTrack = /** @class */ (function (_super) {
return;
}
var _loop_1 = function (gene) {
var e_2, _a;
// @! temp performance hack, only use node when visible
// (don't need to do this when using instancing)
{
Expand Down Expand Up @@ -76858,9 +76862,49 @@ var AnnotationTrack = /** @class */ (function (_super) {
annotation.gene.relativeX = (gene.startIndex - x0) / span;
annotation.gene.opacity = opacity;
annotation.name.visible = namesOpacity > 0;
annotation.name.opacity = namesOpacity;
// VALIS-8: no blending for gene name
annotation.name.opacity = Math.max(namesOpacity, 1.0);
annotation.name.x = 5;
annotation.name.relativeX = Math.max(annotation.gene.relativeX, 0);
// VALIS-8: prevent collision between annotation names
var annotationNameWidth = annotation.name.getComputedWidth();
if (annotation.name.visible && annotationNameWidth !== 0) {
try {
for (var createdAnnotationNames_1 = __values(createdAnnotationNames), createdAnnotationNames_1_1 = createdAnnotationNames_1.next(); !createdAnnotationNames_1_1.done; createdAnnotationNames_1_1 = createdAnnotationNames_1.next()) {
var name_1 = createdAnnotationNames_1_1.value;
if (annotation.name.y === name_1.y && gene.name !== name_1.geneName) {
// check gene's name to prevent multiple collision checking on the same gene
// this is because if we shift gene's name to the right and if it crosses
// the boundary of the current tile block then the gene is queued to the
// next tile block and then revisited in the next tile loop
if (annotation.name.relativeX >= name_1.relativeX &&
annotation.name.relativeX < name_1.relativeX + name_1.relativeW) {
annotation.name.relativeX = name_1.relativeX + name_1.relativeW;
}
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (createdAnnotationNames_1_1 && !createdAnnotationNames_1_1.done && (_a = createdAnnotationNames_1.return)) _a.call(createdAnnotationNames_1);
}
finally { if (e_2) throw e_2.error; }
}
var trackWidth = _this.getComputedWidth();
var spacingFactor = 0.1;
// 10% (based on left name's width) spacing between two overlapping annotation names
createdAnnotationNames.push({
geneName: gene.name,
y: annotation.name.y,
relativeX: annotation.name.relativeX,
relativeW: annotationNameWidth / trackWidth * (1.0 + spacingFactor)
});
}
else {
// hide names with zero width
annotation.name.visible = false;
}
// add to the scene graph (auto removed when unused)
_this._onStageAnnotations.get(annotationKey, function () {
_this.add(annotation.gene);
Expand Down Expand Up @@ -76942,7 +76986,7 @@ var AnnotationTrack = /** @class */ (function (_super) {
}
// Instance Rendering
var tileObject = _this._macroTileCache.get(_this.contig + ':' + tile.key, function () {
var e_2, _a;
var e_3, _a;
// initialize macro gene instances
// create array of gene annotation data
var instanceData = new Array();
Expand Down Expand Up @@ -76991,12 +77035,12 @@ var AnnotationTrack = /** @class */ (function (_super) {
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
finally { if (e_3) throw e_3.error; }
}
var geneInstances = new IntervalInstances_1.default(instanceData);
geneInstances.y = 0;
Expand Down Expand Up @@ -77074,20 +77118,20 @@ var GeneAnnotation = /** @class */ (function (_super) {
return this._opacity;
},
set: function (v) {
var e_3, _a;
var e_4, _a;
this._opacity = v;
try {
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
var child = _c.value;
child.opacity = v;
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_3) throw e_3.error; }
finally { if (e_4) throw e_4.error; }
}
},
enumerable: true,
Expand All @@ -77098,7 +77142,7 @@ var GeneAnnotation = /** @class */ (function (_super) {
var TranscriptAnnotation = /** @class */ (function (_super) {
__extends(TranscriptAnnotation, _super);
function TranscriptAnnotation(sharedState, transcript, strand, onAnnotationClicked) {
var e_4, _a, e_5, _b;
var e_5, _a, e_6, _b;
var _this = _super.call(this) || this;
_this.transcript = transcript;
_this._opacity = 1;
Expand Down Expand Up @@ -77161,12 +77205,12 @@ var TranscriptAnnotation = /** @class */ (function (_super) {
_this.add(exon);
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_4) throw e_4.error; }
finally { if (e_5) throw e_5.error; }
}
try {
// create untranslated regions
Expand All @@ -77180,12 +77224,12 @@ var TranscriptAnnotation = /** @class */ (function (_super) {
_this.add(utr);
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
catch (e_6_1) { e_6 = { error: e_6_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
}
finally { if (e_5) throw e_5.error; }
finally { if (e_6) throw e_6.error; }
}
// create protein coding sequences
// ! assuming CDS array is sorted from startIndex
Expand All @@ -77210,20 +77254,20 @@ var TranscriptAnnotation = /** @class */ (function (_super) {
return this._opacity;
},
set: function (v) {
var e_6, _a;
var e_7, _a;
this._opacity = v;
try {
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
var child = _c.value;
child.opacity = v;
}
}
catch (e_6_1) { e_6 = { error: e_6_1 }; }
catch (e_7_1) { e_7 = { error: e_7_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_6) throw e_6.error; }
finally { if (e_7) throw e_7.error; }
}
},
enumerable: true,
Expand Down
2 changes: 1 addition & 1 deletion dist/valis-hpgv.js.map

Large diffs are not rendered by default.

76 changes: 60 additions & 16 deletions dist/valis-hpgv.react-peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48397,7 +48397,8 @@ var AnnotationTrack = /** @class */ (function (_super) {
_this.macroLodBlendRange = 2;
_this.macroLodThresholdLow = 7;
_this.macroLodThresholdHigh = _this.macroLodThresholdLow + _this.macroLodBlendRange;
_this.namesLodBlendRange = 1;
//VALIS-8: increased 1->4 to show annotatation names at higher (zoomed out) LoD level
_this.namesLodBlendRange = 4;
_this.namesLodThresholdLow = 6;
_this.namesLodThresholdHigh = _this.namesLodThresholdLow + _this.namesLodBlendRange;
_this.annotationY = (_a = {},
Expand Down Expand Up @@ -48513,6 +48514,8 @@ var AnnotationTrack = /** @class */ (function (_super) {
namesOpacity = 0;
}
var microSamplingDensity = 1;
// VALIS-8: prevent collision between annotation names
var createdAnnotationNames = new Array();
this.getTileLoader().forEachTile(x0, x1, microSamplingDensity, true, function (tile) {
var e_1, _a;
// debug: draw red lines at tile boundaries
Expand All @@ -48530,6 +48533,7 @@ var AnnotationTrack = /** @class */ (function (_super) {
return;
}
var _loop_1 = function (gene) {
var e_2, _a;
// @! temp performance hack, only use node when visible
// (don't need to do this when using instancing)
{
Expand Down Expand Up @@ -48583,9 +48587,49 @@ var AnnotationTrack = /** @class */ (function (_super) {
annotation.gene.relativeX = (gene.startIndex - x0) / span;
annotation.gene.opacity = opacity;
annotation.name.visible = namesOpacity > 0;
annotation.name.opacity = namesOpacity;
// VALIS-8: no blending for gene name
annotation.name.opacity = Math.max(namesOpacity, 1.0);
annotation.name.x = 5;
annotation.name.relativeX = Math.max(annotation.gene.relativeX, 0);
// VALIS-8: prevent collision between annotation names
var annotationNameWidth = annotation.name.getComputedWidth();
if (annotation.name.visible && annotationNameWidth !== 0) {
try {
for (var createdAnnotationNames_1 = __values(createdAnnotationNames), createdAnnotationNames_1_1 = createdAnnotationNames_1.next(); !createdAnnotationNames_1_1.done; createdAnnotationNames_1_1 = createdAnnotationNames_1.next()) {
var name_1 = createdAnnotationNames_1_1.value;
if (annotation.name.y === name_1.y && gene.name !== name_1.geneName) {
// check gene's name to prevent multiple collision checking on the same gene
// this is because if we shift gene's name to the right and if it crosses
// the boundary of the current tile block then the gene is queued to the
// next tile block and then revisited in the next tile loop
if (annotation.name.relativeX >= name_1.relativeX &&
annotation.name.relativeX < name_1.relativeX + name_1.relativeW) {
annotation.name.relativeX = name_1.relativeX + name_1.relativeW;
}
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (createdAnnotationNames_1_1 && !createdAnnotationNames_1_1.done && (_a = createdAnnotationNames_1.return)) _a.call(createdAnnotationNames_1);
}
finally { if (e_2) throw e_2.error; }
}
var trackWidth = _this.getComputedWidth();
var spacingFactor = 0.1;
// 10% (based on left name's width) spacing between two overlapping annotation names
createdAnnotationNames.push({
geneName: gene.name,
y: annotation.name.y,
relativeX: annotation.name.relativeX,
relativeW: annotationNameWidth / trackWidth * (1.0 + spacingFactor)
});
}
else {
// hide names with zero width
annotation.name.visible = false;
}
// add to the scene graph (auto removed when unused)
_this._onStageAnnotations.get(annotationKey, function () {
_this.add(annotation.gene);
Expand Down Expand Up @@ -48667,7 +48711,7 @@ var AnnotationTrack = /** @class */ (function (_super) {
}
// Instance Rendering
var tileObject = _this._macroTileCache.get(_this.contig + ':' + tile.key, function () {
var e_2, _a;
var e_3, _a;
// initialize macro gene instances
// create array of gene annotation data
var instanceData = new Array();
Expand Down Expand Up @@ -48716,12 +48760,12 @@ var AnnotationTrack = /** @class */ (function (_super) {
}
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
finally { if (e_3) throw e_3.error; }
}
var geneInstances = new IntervalInstances_1.default(instanceData);
geneInstances.y = 0;
Expand Down Expand Up @@ -48799,20 +48843,20 @@ var GeneAnnotation = /** @class */ (function (_super) {
return this._opacity;
},
set: function (v) {
var e_3, _a;
var e_4, _a;
this._opacity = v;
try {
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
var child = _c.value;
child.opacity = v;
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_3) throw e_3.error; }
finally { if (e_4) throw e_4.error; }
}
},
enumerable: true,
Expand All @@ -48823,7 +48867,7 @@ var GeneAnnotation = /** @class */ (function (_super) {
var TranscriptAnnotation = /** @class */ (function (_super) {
__extends(TranscriptAnnotation, _super);
function TranscriptAnnotation(sharedState, transcript, strand, onAnnotationClicked) {
var e_4, _a, e_5, _b;
var e_5, _a, e_6, _b;
var _this = _super.call(this) || this;
_this.transcript = transcript;
_this._opacity = 1;
Expand Down Expand Up @@ -48886,12 +48930,12 @@ var TranscriptAnnotation = /** @class */ (function (_super) {
_this.add(exon);
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_4) throw e_4.error; }
finally { if (e_5) throw e_5.error; }
}
try {
// create untranslated regions
Expand All @@ -48905,12 +48949,12 @@ var TranscriptAnnotation = /** @class */ (function (_super) {
_this.add(utr);
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
catch (e_6_1) { e_6 = { error: e_6_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
}
finally { if (e_5) throw e_5.error; }
finally { if (e_6) throw e_6.error; }
}
// create protein coding sequences
// ! assuming CDS array is sorted from startIndex
Expand All @@ -48935,20 +48979,20 @@ var TranscriptAnnotation = /** @class */ (function (_super) {
return this._opacity;
},
set: function (v) {
var e_6, _a;
var e_7, _a;
this._opacity = v;
try {
for (var _b = __values(this.children), _c = _b.next(); !_c.done; _c = _b.next()) {
var child = _c.value;
child.opacity = v;
}
}
catch (e_6_1) { e_6 = { error: e_6_1 }; }
catch (e_7_1) { e_7 = { error: e_7_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_6) throw e_6.error; }
finally { if (e_7) throw e_7.error; }
}
},
enumerable: true,
Expand Down
2 changes: 1 addition & 1 deletion dist/valis-hpgv.react-peer.js.map

Large diffs are not rendered by default.

Loading