Commit bedf6357 authored by David Hoksza's avatar David Hoksza
Browse files

Ability to show multiple overlays

parent 59956216
Pipeline #6587 failed with stage
in 7 minutes and 43 seconds
......@@ -154,20 +154,22 @@ MolArt.prototype._activate = function (uniprotId) {
retrieveVariants(self._customMap, self.getAlias().getId()).then(function(variants){
if (variants) {
const customDataSources = [
{
source: 'MINERVA overlay',
useExtension: false,
data: constructVariantsData(sequence, variants)
}];
this.molArt = new MolArtPlugin({
uniprotId: uniprotId,
containerId: container.id,
customDataSources: customDataSources
var customDataSources = [];
for (var i = 0; i < variants.length; i++) {
customDataSources.push({
source: 'MINERVA overlay <br/>' + variants[i].overlayName,
useExtension: false,
data: constructVariantsData(sequence, variants[i].variants)
});
}
self.molArt = new MolArtPlugin({
uniprotId: uniprotId,
containerId: container.id,
customDataSources: customDataSources
});
} else {
this.molArt = new MolArtPlugin({
self.molArt = new MolArtPlugin({
uniprotId: uniprotId,
containerId: container.id
});
......@@ -197,29 +199,42 @@ var constructVariantsData = function(sequence, variants) {
}
var retrieveVariants = function(customMap, elementId) {
var overlays;
return customMap.getTopMap().getVisibleDataOverlays().then(function(dataOverlays){
if (dataOverlays.length > 0) {
var overlay = dataOverlays[0];
return overlay.getFullAliasById(elementId);
} else {
return undefined;
}
}).then(function(aliasOverlayData){
if (aliasOverlayData) {
// here you have access to all gene variants for element elementId that are available in
// the first visible data overlay (there is aminoAcidChange property defined for a single variant)
var variants = [];
var geneVariants = aliasOverlayData.getGeneVariants();
overlays = dataOverlays;
var promises = [];
for (var i=0; i < dataOverlays.length; i++) {
promises.push(dataOverlays[i].getFullAliasById(elementId));
}
return Promise.all(promises);
}).then(function (aliasOverlayData) {
//The resolved promises should be in the same order in which the corresponding promisses were stored
var variants = [];
for (var i=0; i < aliasOverlayData.length; i++) {
if (!aliasOverlayData[i]) continue;
var overlayVariants = [];
var geneVariants = aliasOverlayData[i].getGeneVariants();
for (let i = 0; i < geneVariants.length; i++){
var variant = geneVariants[i];
variants = variants.concat(processGeneVariant(variant));
var variant = geneVariants[i];
overlayVariants = overlayVariants.concat(processGeneVariant(variant));
}
return variants;
} else {
return undefined;
if (overlayVariants.length > 0){
variants.push({
overlayName: overlays[i].getName(),
variants: overlayVariants
});
}
}
return variants;
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment