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
* 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
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
......
......@@ -43,7 +43,7 @@ function ContextMenu(params) {
self._documentClickListener = function (e) {
var className = e.target.className;
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);
}
} else {
......@@ -83,13 +83,12 @@ ContextMenu.prototype.addOption = function (name, handler, disabled) {
});
var link = Functions.createElement({
type: "a",
className: "dropdown-link",
className: "dropdown-item",
href: "#",
content: name
});
if (!disabled) {
link.href = "#";
} else {
link.className = 'disabled-link';
if (disabled) {
link.className = 'dropdown-item disabled';
}
$(link).data("handler", handler);
option.appendChild(link);
......
......@@ -30,7 +30,7 @@ SubMenu.prototype._createGui = function (params) {
var link = Functions.createElement({
type: "a",
href: "#",
className: "dropdown-link",
className: "dropdown-item",
content: params.name
});
link.tabIndex = -1;
......@@ -55,7 +55,7 @@ SubMenu.prototype.addOption = function (name, handler) {
var link = Functions.createElement({
type: "a",
href: "#",
className: "dropdown-link",
className: "dropdown-item",
content: name
});
$(link).data("handler", handler);
......
......@@ -285,7 +285,7 @@ function activateMolArtLink(coordinates, map) {
for (var i = 0; i < element.references.length; i++) {
var ref = element.references[i];
if (ref.constructor.name === 'Annotation' && ref.getType() === 'UNIPROT') {
var uniprotId = ref.getResource()
var uniprotId = ref.getResource();
if (uniprotIds.indexOf(uniprotId) < 0) {
uniprotIds.push(ref.getResource());
}
......
......@@ -2,6 +2,7 @@ var Functions = require('../../Functions');
var SubMenu = require('../../gui/SubMenu');
var Variant = require('./MolArtVariant');
var getUniprotSequence = require('./UniprotQuery');
var $ = require('jquery');
/**
*
......@@ -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 () {
return this._alias;
......@@ -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;
}
};
/**
*
* @param {string[]} uniprotIds
* @param {@link Alias} minervaElement
* @param {Alias} alias
*/
MolArt.prototype.activateInContextMenu = function (uniprotIds, alias) {
......@@ -147,11 +148,11 @@ MolArt.prototype._activate = function (uniprotId) {
var sequence;
getUniprotSequence(uniprotId).then(function(_sequence){
return getUniprotSequence(uniprotId).then(function (_sequence) {
sequence = _sequence;
return Promise.resolve();
}).then(function(){
retrieveVariants(self._customMap, self.getAlias().getId()).then(function(variants){
}).then(function () {
retrieveVariants(self._customMap, self.getAlias().getId()).then(function (variants) {
if (variants) {
var customDataSources = [];
......@@ -173,40 +174,39 @@ MolArt.prototype._activate = function (uniprotId) {
uniprotId: uniprotId,
containerId: container.id
});
};
}
container.style.display = 'block';
});
});
}
});
};
var constructVariantsData = function(sequence, variants) {
var constructVariantsData = function (sequence, variants) {
return {
sequence: sequence,
features: variants.map(v => {
return {
type: "VARIANT",
category: "VARIATION",
description: v.description,
begin: v.posFrom,
end: v.posTo ? v.posTo : v.posFrom,
wildType: v.aaFrom,
alternativeSequence: v.aaTo ? v.aaTo : 'd',
consequence: v.varType,
}
})
}
}
return {
type: "VARIANT",
category: "VARIATION",
description: v.description,
begin: v.posFrom,
end: v.posTo ? v.posTo : v.posFrom,
wildType: v.aaFrom,
alternativeSequence: v.aaTo ? v.aaTo : 'd',
consequence: v.varType,
}
})}
};
var retrieveVariants = function(customMap, elementId) {
var retrieveVariants = function (customMap, elementId) {
var overlays;
return customMap.getTopMap().getVisibleDataOverlays().then(function(dataOverlays){
return customMap.getTopMap().getVisibleDataOverlays().then(function (dataOverlays) {
overlays = dataOverlays;
var promises = [];
for (var i=0; i < dataOverlays.length; i++) {
for (var i = 0; i < dataOverlays.length; i++) {
promises.push(dataOverlays[i].getFullAliasById(elementId));
}
......@@ -217,20 +217,20 @@ var retrieveVariants = function(customMap, elementId) {
var variants = [];
for (var i=0; i < aliasOverlayData.length; i++) {
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];
for (let i = 0; i < geneVariants.length; i++) {
var variant = geneVariants[i];
if (variant.getAminoAcidChange() !== null) {
// not all variants need to have an aminoacid change associated
overlayVariants = overlayVariants.concat(processGeneVariant(variant));
}
}
if (overlayVariants.length > 0){
if (overlayVariants.length > 0) {
variants.push({
overlayName: overlays[i].getName(),
variants: overlayVariants
......@@ -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 C20orf96:NM_080571:exon10:c.G1020A:p.R340R,C20orf96:NM_153269:exon10:c.G1023A:p.R341R
......@@ -253,7 +253,7 @@ var processGeneVariant = function(minervaVariant) {
// frameshift insertion: LRRK2:NM_198578:exon1:c.151_152insCCTCCAAGTTATTTCAAGGCAAAAATATCCATGTGCCTCT:p.A51fs
// 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
// nonframeshift_insertion LRRK2:NM_198578:exon27:c.3777_3778insATTCCTCCT: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
......@@ -265,58 +265,57 @@ var processGeneVariant = function(minervaVariant) {
// nonframeshift_deletion LRRK2:NM_198578:exon9:c.1099_1101del: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
var vars = [];
var change = minervaVariant.getAminoAcidChange();
var sChange = change.split(',');
for (var i =0; i < sChange.length; i++) {
for (var i = 0; i < sChange.length; i++) {
try {
var aaChange = sChange[i].split('.').slice(-1)[0]; // LRRK2:NM_198578:exon1:c.T45C:p.T15T
var variant = new Variant();
if (aaChange.endsWith('del') > 0) {
var m = aaChange.match( /(\d+)_(\d+)/ );
if (aaChange.endsWith('del') > 0) {
var m = aaChange.match(/(\d+)_(\d+)/);
[, variant.posFrom, variant.posTo] = m;
variant.varType = 'Nonframeshift deletion'
}else if (aaChange.indexOf('delins') >=0) {
var m = aaChange.match( /([A-Z])(\d+)delins([A-Z]+)/ );
[ ,variant.aaFrom, variant.posFrom, variant.aaTo] = m;
variant.varType = 'Nonframeshift deletion'
} else if (aaChange.indexOf('delins') >= 0) {
var m = aaChange.match(/([A-Z])(\d+)delins([A-Z]+)/);
[, 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.varType = 'Nonframeshift insertion';
}
else if (aaChange.endsWith('fs')) {
var m = aaChange.match( /([A-Z])(\d+)/ );
[ ,variant.aaFrom, variant.posFrom] = m;
if (change.indexOf('del') >= 0) variant.varType = 'Frameshift deletion';
else variant.varType = 'Frameshift insertion';
variant.varType = 'Nonframeshift insertion';
} else if (aaChange.endsWith('fs')) {
var m = aaChange.match(/([A-Z])(\d+)/);
[, variant.aaFrom, variant.posFrom] = m;
if (change.indexOf('del') >= 0) variant.varType = 'Frameshift deletion';
else variant.varType = 'Frameshift insertion';
} 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;
[ ,variant.aaFrom, variant.posFrom, variant.aaTo] = m;
variant.varType = variant.aaFrom == variant.aaTo ? 'Synonymous SNV' : 'Nonsynonymous SNV';
[, variant.aaFrom, variant.posFrom, variant.aaTo] = m;
variant.varType = variant.aaFrom == variant.aaTo ? 'Synonymous SNV' : 'Nonsynonymous SNV';
}
vars.push(variant);
} catch (err) {
console.error("Problem with parsing variant " + minervaVariant.getAminoAcidChange(), err);
}
}
}
return vars;
}
};
module.exports = MolArt;
var $ = require('jquery');
function ajaxQuery(url, type) {
if (type === undefined) type = "GET";
return $.ajax({
type: type,
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];
})
}
if (type === undefined) type = "GET";
return $.ajax({
type: type,
url: url
});
}
/**
*
* @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;
\ No newline at end of file
module.exports = getUniprotSequence;
\ 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