Commit 43779e8f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '886-molart-is-missing-in-the-context-menu-right-click-minerva-v14' into 'master'

Resolve "MolArt is missing in the context menu (right click). // minerva v14"

Closes #886

See merge request !878
parents a53251e2 eaca1954
Pipeline #12737 failed with stage
in 11 minutes and 49 seconds
...@@ -10,6 +10,8 @@ minerva (14.0.0~alpha.1) unstable; urgency=low ...@@ -10,6 +10,8 @@ minerva (14.0.0~alpha.1) unstable; urgency=low
* Bug fix: problem with unloading plugin is properly handled (#884) * Bug fix: problem with unloading plugin is properly handled (#884)
* Bug fix: upload of invalid plugin doesn't add it to plugin tab and list of * Bug fix: upload of invalid plugin doesn't add it to plugin tab and list of
loaded plugins (#885) loaded plugins (#885)
* Bug fix: link to molart was brokwn (#886)
* Bug fix: context menu visualization fixed
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 12 Aug 2019 10:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 12 Aug 2019 10:00:00 +0200
......
...@@ -43,7 +43,7 @@ function ContextMenu(params) { ...@@ -43,7 +43,7 @@ function ContextMenu(params) {
self._documentClickListener = function (e) { self._documentClickListener = function (e) {
var className = e.target.className; var className = e.target.className;
if (typeof className === 'string' || className instanceof String) { if (typeof className === 'string' || className instanceof String) {
if (className.indexOf("dropdown-link") === -1) { if (className.indexOf("dropdown-item") === -1) {
self.hide(new Date().getTime() - self.MIN_SHOW_TIME); self.hide(new Date().getTime() - self.MIN_SHOW_TIME);
} }
} else { } else {
...@@ -83,13 +83,12 @@ ContextMenu.prototype.addOption = function (name, handler, disabled) { ...@@ -83,13 +83,12 @@ ContextMenu.prototype.addOption = function (name, handler, disabled) {
}); });
var link = Functions.createElement({ var link = Functions.createElement({
type: "a", type: "a",
className: "dropdown-link", className: "dropdown-item",
href: "#",
content: name content: name
}); });
if (!disabled) { if (disabled) {
link.href = "#"; link.className = 'dropdown-item disabled';
} else {
link.className = 'disabled-link';
} }
$(link).data("handler", handler); $(link).data("handler", handler);
option.appendChild(link); option.appendChild(link);
......
...@@ -30,7 +30,7 @@ SubMenu.prototype._createGui = function (params) { ...@@ -30,7 +30,7 @@ SubMenu.prototype._createGui = function (params) {
var link = Functions.createElement({ var link = Functions.createElement({
type: "a", type: "a",
href: "#", href: "#",
className: "dropdown-link", className: "dropdown-item",
content: params.name content: params.name
}); });
link.tabIndex = -1; link.tabIndex = -1;
...@@ -55,7 +55,7 @@ SubMenu.prototype.addOption = function (name, handler) { ...@@ -55,7 +55,7 @@ SubMenu.prototype.addOption = function (name, handler) {
var link = Functions.createElement({ var link = Functions.createElement({
type: "a", type: "a",
href: "#", href: "#",
className: "dropdown-link", className: "dropdown-item",
content: name content: name
}); });
$(link).data("handler", handler); $(link).data("handler", handler);
......
...@@ -285,7 +285,7 @@ function activateMolArtLink(coordinates, map) { ...@@ -285,7 +285,7 @@ function activateMolArtLink(coordinates, map) {
for (var i = 0; i < element.references.length; i++) { for (var i = 0; i < element.references.length; i++) {
var ref = element.references[i]; var ref = element.references[i];
if (ref.constructor.name === 'Annotation' && ref.getType() === 'UNIPROT') { if (ref.constructor.name === 'Annotation' && ref.getType() === 'UNIPROT') {
var uniprotId = ref.getResource() var uniprotId = ref.getResource();
if (uniprotIds.indexOf(uniprotId) < 0) { if (uniprotIds.indexOf(uniprotId) < 0) {
uniprotIds.push(ref.getResource()); uniprotIds.push(ref.getResource());
} }
......
...@@ -2,6 +2,7 @@ var Functions = require('../../Functions'); ...@@ -2,6 +2,7 @@ var Functions = require('../../Functions');
var SubMenu = require('../../gui/SubMenu'); var SubMenu = require('../../gui/SubMenu');
var Variant = require('./MolArtVariant'); var Variant = require('./MolArtVariant');
var getUniprotSequence = require('./UniprotQuery'); var getUniprotSequence = require('./UniprotQuery');
var $ = require('jquery');
/** /**
* *
...@@ -48,7 +49,7 @@ function removeFromContextMenu(menu) { ...@@ -48,7 +49,7 @@ function removeFromContextMenu(menu) {
/** /**
* *
* @returns {@link Alias} MINERVA element to which the instance of molart is bound * @returns {Alias} MINERVA element to which the instance of molart is bound
*/ */
MolArt.prototype.getAlias = function () { MolArt.prototype.getAlias = function () {
return this._alias; return this._alias;
...@@ -56,16 +57,16 @@ MolArt.prototype.getAlias = function () { ...@@ -56,16 +57,16 @@ MolArt.prototype.getAlias = function () {
/** /**
* *
* @param {@link Alias} MINERVA element to which the instance of molart is bound * @param {Alias} alias MINERVA element to which the instance of molart is bound
*/ */
MolArt.prototype.setAlias = function(alias) { MolArt.prototype.setAlias = function (alias) {
this._alias = alias; this._alias = alias;
} };
/** /**
* *
* @param {string[]} uniprotIds * @param {string[]} uniprotIds
* @param {@link Alias} minervaElement * @param {Alias} alias
*/ */
MolArt.prototype.activateInContextMenu = function (uniprotIds, alias) { MolArt.prototype.activateInContextMenu = function (uniprotIds, alias) {
...@@ -147,11 +148,11 @@ MolArt.prototype._activate = function (uniprotId) { ...@@ -147,11 +148,11 @@ MolArt.prototype._activate = function (uniprotId) {
var sequence; var sequence;
getUniprotSequence(uniprotId).then(function(_sequence){ return getUniprotSequence(uniprotId).then(function (_sequence) {
sequence = _sequence; sequence = _sequence;
return Promise.resolve(); return Promise.resolve();
}).then(function(){ }).then(function () {
retrieveVariants(self._customMap, self.getAlias().getId()).then(function(variants){ retrieveVariants(self._customMap, self.getAlias().getId()).then(function (variants) {
if (variants) { if (variants) {
var customDataSources = []; var customDataSources = [];
...@@ -173,40 +174,39 @@ MolArt.prototype._activate = function (uniprotId) { ...@@ -173,40 +174,39 @@ MolArt.prototype._activate = function (uniprotId) {
uniprotId: uniprotId, uniprotId: uniprotId,
containerId: container.id containerId: container.id
}); });
}; }
container.style.display = 'block'; container.style.display = 'block';
}); });
}); });
} };
var constructVariantsData = function(sequence, variants) { var constructVariantsData = function (sequence, variants) {
return { return {
sequence: sequence, sequence: sequence,
features: variants.map(v => { features: variants.map(v => {
return { return {
type: "VARIANT", type: "VARIANT",
category: "VARIATION", category: "VARIATION",
description: v.description, description: v.description,
begin: v.posFrom, begin: v.posFrom,
end: v.posTo ? v.posTo : v.posFrom, end: v.posTo ? v.posTo : v.posFrom,
wildType: v.aaFrom, wildType: v.aaFrom,
alternativeSequence: v.aaTo ? v.aaTo : 'd', alternativeSequence: v.aaTo ? v.aaTo : 'd',
consequence: v.varType, consequence: v.varType,
} }
}) })}
} };
}
var retrieveVariants = function(customMap, elementId) { var retrieveVariants = function (customMap, elementId) {
var overlays; var overlays;
return customMap.getTopMap().getVisibleDataOverlays().then(function(dataOverlays){ return customMap.getTopMap().getVisibleDataOverlays().then(function (dataOverlays) {
overlays = dataOverlays; overlays = dataOverlays;
var promises = []; var promises = [];
for (var i=0; i < dataOverlays.length; i++) { for (var i = 0; i < dataOverlays.length; i++) {
promises.push(dataOverlays[i].getFullAliasById(elementId)); promises.push(dataOverlays[i].getFullAliasById(elementId));
} }
...@@ -217,20 +217,20 @@ var retrieveVariants = function(customMap, elementId) { ...@@ -217,20 +217,20 @@ var retrieveVariants = function(customMap, elementId) {
var variants = []; var variants = [];
for (var i=0; i < aliasOverlayData.length; i++) { for (var i = 0; i < aliasOverlayData.length; i++) {
if (!aliasOverlayData[i]) continue; if (!aliasOverlayData[i]) continue;
var overlayVariants = []; var overlayVariants = [];
var geneVariants = aliasOverlayData[i].getGeneVariants(); var geneVariants = aliasOverlayData[i].getGeneVariants();
for (let i = 0; i < geneVariants.length; i++){ for (let i = 0; i < geneVariants.length; i++) {
var variant = geneVariants[i]; var variant = geneVariants[i];
if (variant.getAminoAcidChange() !== null) { if (variant.getAminoAcidChange() !== null) {
// not all variants need to have an aminoacid change associated // not all variants need to have an aminoacid change associated
overlayVariants = overlayVariants.concat(processGeneVariant(variant)); overlayVariants = overlayVariants.concat(processGeneVariant(variant));
} }
} }
if (overlayVariants.length > 0){ if (overlayVariants.length > 0) {
variants.push({ variants.push({
overlayName: overlays[i].getName(), overlayName: overlays[i].getName(),
variants: overlayVariants variants: overlayVariants
...@@ -242,7 +242,7 @@ var retrieveVariants = function(customMap, elementId) { ...@@ -242,7 +242,7 @@ var retrieveVariants = function(customMap, elementId) {
}); });
} }
var processGeneVariant = function(minervaVariant) { var processGeneVariant = function (minervaVariant) {
// synonymous_SNV LRRK2:NM_198578:exon1:c.T45C:p.T15T // synonymous_SNV LRRK2:NM_198578:exon1:c.T45C:p.T15T
// synonymous_SNV C20orf96:NM_080571:exon10:c.G1020A:p.R340R,C20orf96:NM_153269:exon10:c.G1023A:p.R341R // synonymous_SNV C20orf96:NM_080571:exon10:c.G1020A:p.R340R,C20orf96:NM_153269:exon10:c.G1023A:p.R341R
...@@ -253,7 +253,7 @@ var processGeneVariant = function(minervaVariant) { ...@@ -253,7 +253,7 @@ var processGeneVariant = function(minervaVariant) {
// frameshift insertion: LRRK2:NM_198578:exon1:c.151_152insCCTCCAAGTTATTTCAAGGCAAAAATATCCATGTGCCTCT:p.A51fs // frameshift insertion: LRRK2:NM_198578:exon1:c.151_152insCCTCCAAGTTATTTCAAGGCAAAAATATCCATGTGCCTCT:p.A51fs
// frameshift insertion: p.A51fsins // frameshift insertion: p.A51fsins
// frameshift insertion: NCOA3:NM_001174087:exon22:c.4171_4172insG:p.M1391fs,NCOA3:NM_001174088:exon22:c.4147_4148insG:p.M1383fs,NCOA3:NM_006534:exon22:c.4162_4163insG:p.M1388fs,NCOA3:NM_181659:exon22:c.4174_4175insG:p.M1392fs // frameshift insertion: NCOA3:NM_001174087:exon22:c.4171_4172insG:p.M1391fs,NCOA3:NM_001174088:exon22:c.4147_4148insG:p.M1383fs,NCOA3:NM_006534:exon22:c.4162_4163insG:p.M1388fs,NCOA3:NM_181659:exon22:c.4174_4175insG:p.M1392fs
// nonframeshift_insertion LRRK2:NM_198578:exon27:c.3777_3778insATTCCTCCT:p.E1259delinsEIPP // nonframeshift_insertion LRRK2:NM_198578:exon27:c.3777_3778insATTCCTCCT:p.E1259delinsEIPP
// nonframeshift_insertion p.E1259delinsEIPP // nonframeshift_insertion p.E1259delinsEIPP
// nonframeshift_insertion SYNJ1:NM_001160306:exon28:c.3957_3958insAATACT:p.L1320delinsNTL,SYNJ1:NM_003895:exon32:c.4215_4216insAATACT:p.L1406delinsNTL // nonframeshift_insertion SYNJ1:NM_001160306:exon28:c.3957_3958insAATACT:p.L1320delinsNTL,SYNJ1:NM_003895:exon32:c.4215_4216insAATACT:p.L1406delinsNTL
...@@ -265,58 +265,57 @@ var processGeneVariant = function(minervaVariant) { ...@@ -265,58 +265,57 @@ var processGeneVariant = function(minervaVariant) {
// nonframeshift_deletion LRRK2:NM_198578:exon9:c.1099_1101del:p.367_367del // nonframeshift_deletion LRRK2:NM_198578:exon9:c.1099_1101del:p.367_367del
// nonframeshift_deletion p.367_367del // nonframeshift_deletion p.367_367del
// nonframeshift_deletion RRBP1:NM_004587:exon15:c.2022_2024del:p.674_675del,RRBP1:NM_001042576:exon16:c.2022_2024del:p.674_675del // nonframeshift_deletion RRBP1:NM_004587:exon15:c.2022_2024del:p.674_675del,RRBP1:NM_001042576:exon16:c.2022_2024del:p.674_675del
var vars = []; var vars = [];
var change = minervaVariant.getAminoAcidChange(); var change = minervaVariant.getAminoAcidChange();
var sChange = change.split(','); var sChange = change.split(',');
for (var i =0; i < sChange.length; i++) { for (var i = 0; i < sChange.length; i++) {
try { try {
var aaChange = sChange[i].split('.').slice(-1)[0]; // LRRK2:NM_198578:exon1:c.T45C:p.T15T var aaChange = sChange[i].split('.').slice(-1)[0]; // LRRK2:NM_198578:exon1:c.T45C:p.T15T
var variant = new Variant(); var variant = new Variant();
if (aaChange.endsWith('del') > 0) { if (aaChange.endsWith('del') > 0) {
var m = aaChange.match( /(\d+)_(\d+)/ ); var m = aaChange.match(/(\d+)_(\d+)/);
[, variant.posFrom, variant.posTo] = m; [, variant.posFrom, variant.posTo] = m;
variant.varType = 'Nonframeshift deletion' variant.varType = 'Nonframeshift deletion'
}else if (aaChange.indexOf('delins') >=0) { } else if (aaChange.indexOf('delins') >= 0) {
var m = aaChange.match( /([A-Z])(\d+)delins([A-Z]+)/ ); var m = aaChange.match(/([A-Z])(\d+)delins([A-Z]+)/);
[ ,variant.aaFrom, variant.posFrom, variant.aaTo] = m; [, variant.aaFrom, variant.posFrom, variant.aaTo] = m;
variant.aaTo = 'delins: ' + variant.aaTo; //This is because ProtVista can't handle insertions so we need to prefix it by 'd' which will place the variant into the 'd' line variant.aaTo = 'delins: ' + variant.aaTo; //This is because ProtVista can't handle insertions so we need to prefix it by 'd' which will place the variant into the 'd' line
variant.varType = 'Nonframeshift insertion'; variant.varType = 'Nonframeshift insertion';
} } else if (aaChange.endsWith('fs')) {
else if (aaChange.endsWith('fs')) {
var m = aaChange.match(/([A-Z])(\d+)/);
var m = aaChange.match( /([A-Z])(\d+)/ ); [, variant.aaFrom, variant.posFrom] = m;
[ ,variant.aaFrom, variant.posFrom] = m; if (change.indexOf('del') >= 0) variant.varType = 'Frameshift deletion';
if (change.indexOf('del') >= 0) variant.varType = 'Frameshift deletion'; else variant.varType = 'Frameshift insertion';
else variant.varType = 'Frameshift insertion';
} else { } else {
var m = aaChange.match( /([a-zA-Z]+)(\d+)([a-zA-Z])+/ ); var m = aaChange.match(/([a-zA-Z]+)(\d+)([a-zA-Z])+/);
if (!m || m.length != 4) continue; if (!m || m.length != 4) continue;
[ ,variant.aaFrom, variant.posFrom, variant.aaTo] = m; [, variant.aaFrom, variant.posFrom, variant.aaTo] = m;
variant.varType = variant.aaFrom == variant.aaTo ? 'Synonymous SNV' : 'Nonsynonymous SNV'; variant.varType = variant.aaFrom == variant.aaTo ? 'Synonymous SNV' : 'Nonsynonymous SNV';
} }
vars.push(variant); vars.push(variant);
} catch (err) { } catch (err) {
console.error("Problem with parsing variant " + minervaVariant.getAminoAcidChange(), err); console.error("Problem with parsing variant " + minervaVariant.getAminoAcidChange(), err);
} }
} }
return vars; return vars;
} };
module.exports = MolArt; module.exports = MolArt;
var $ = require('jquery');
function ajaxQuery(url, type) { function ajaxQuery(url, type) {
if (type === undefined) type = "GET"; if (type === undefined) type = "GET";
return $.ajax({ return $.ajax({
type: type, type: type,
url: url url: url
}); });
} }
var getUniprotSequence = function(accession) { /**
return ajaxQuery('https://www.uniprot.org/uniprot/?query=accession%3A'+accession+'&columns=sequence&format=tab').then(function(data){ *
return data.split(/\r?\n/)[1]; * @param accession
}) * @return {Promise}
} */
var getUniprotSequence = function (accession) {
return ajaxQuery('https://www.uniprot.org/uniprot/?query=accession%3A' + accession + '&columns=sequence&format=tab').then(function (data) {
return data.split(/\r?\n/)[1];
})
};
module.exports = getUniprotSequence; module.exports = getUniprotSequence;
\ No newline at end of file \ No newline at end of file
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