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

Passing variants to molart working

parent c9591851
Pipeline #6582 failed with stage
in 7 minutes and 35 seconds
This diff is collapsed.
......@@ -17,14 +17,13 @@
},
"author": "Piotr Gawron",
"devDependencies": {
"molart": "1.0.3",
"assert": "1.4.1",
"bluebird": "^3.4.6",
"bluebird": "^3.5.2",
"bootstrap": "^3.3.7",
"browserify": "^13.1.1",
"chai": "^3.5.0",
"clean-css-cli": "^4.1.10",
"datatables.net": "^1.10.13",
"clean-css-cli": "^4.2.1",
"datatables.net": "^1.10.19",
"del": "^3.0.0",
"exorcist": "^0.4.0",
"file-url": "^2.0.0",
......@@ -32,29 +31,30 @@
"jquery": "1.12.1",
"jquery-ui-dist": "1.12.1",
"jsdom": "11.7.0",
"jshint": "^2.9.4",
"jshint": "^2.9.6",
"log4js-memory-appender": "1.0.5",
"mkdirp": "^0.5.1",
"mocha": "^3.5.3",
"molart": "1.1.0",
"uglifyjs": "^2.4.10"
},
"dependencies": {
"datatables.net-rowreorder": "^1.2.3",
"datatables.net-rowreorder": "^1.2.5",
"dual-listbox": "1.0.7",
"file-saver": "^1.3.3",
"file-saver": "^1.3.8",
"http-status-codes": "^1.3.0",
"is-url": "^1.2.2",
"js-cookie": "^2.1.3",
"jstree": "^3.3.4",
"jszip": "^3.1.4",
"is-url": "^1.2.4",
"js-cookie": "^2.2.0",
"jstree": "^3.3.5",
"jszip": "^3.1.5",
"log4js": "0.6.38",
"multi-checkbox-list": "^0.2.0",
"openlayers": "^4.6.5",
"pileup": "^0.6.9",
"request": "^2.82.0",
"request": "^2.88.0",
"spectrum-colorpicker": "^1.8.0",
"text-encoding": "^0.6.4",
"xss": "^0.3.7"
"xss": "^0.3.8"
},
"license": "AGPL-3.0",
"bugs": {
......
......@@ -271,7 +271,7 @@ function activateMolArtLink(coordinates, map) {
}
}
}
if (uniprotIds.length > 0) map.getTopMap().getContextMenu().getMolArt().activateInContextMenu(uniprotIds);
if (uniprotIds.length > 0) map.getTopMap().getContextMenu().getMolArt().activateInContextMenu(uniprotIds, element);
else map.getTopMap().getContextMenu().getMolArt().deactivateInContextMenu();
}).catch(function () {
return map.getTopMap().getContextMenu().getMolArt().deactivateInContextMenu();
......
var Functions = require('../../Functions');
var SubMenu = require('../../gui/SubMenu');
var Variant = require('./MolArtVariant');
var getUniprotSequence = require('./UniprotQuery');
/**
*
......@@ -44,16 +46,35 @@ function removeFromContextMenu(menu) {
$(menu.getElement()).find('li:contains("MolArt")').remove();
}
/**
*
* @returns {@link Alias} MINERVA element to which the instance of molart is bound
*/
MolArt.prototype.getAlias = function () {
return this._alias;
};
/**
*
* @param {@link Alias} MINERVA element to which the instance of molart is bound
*/
MolArt.prototype.setAlias = function(alias) {
this._alias = alias;
}
/**
*
* @param {string[]} uniprotIds
* @param {@link Alias} minervaElement
*/
MolArt.prototype.activateInContextMenu = function (uniprotIds) {
MolArt.prototype.activateInContextMenu = function (uniprotIds, alias) {
var self = this;
var menu = this._customMap.getContextMenu();
removeFromContextMenu(menu);
self.setAlias(alias);
var submenu = new SubMenu({
element: Functions.createElement({type: "li"}),
name: "Open MolArt",
......@@ -124,12 +145,145 @@ MolArt.prototype._activate = function (uniprotId) {
var MolArtPlugin = require('molart');
this.molArt = new MolArtPlugin({
uniprotId: uniprotId,
containerId: container.id
var sequence;
getUniprotSequence(uniprotId).then(function(_sequence){
sequence = _sequence;
return Promise.resolve();
}).then(function(){
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
});
} else {
this.molArt = new MolArtPlugin({
uniprotId: uniprotId,
containerId: container.id
});
};
container.style.display = 'block';
});
});
}
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,
}
})
}
}
var retrieveVariants = function(customMap, elementId) {
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();
for (let i = 0; i < geneVariants.length; i++){
var variant = geneVariants[i];
variants = variants.concat(processGeneVariant(variant));
}
return variants;
} else {
return undefined;
}
});
container.style.display = 'block';
};
}
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
// nonsynonymous_SNV LRRK2:NM_198578:exon4:c.T356C:p.L119P
// nonsynonymous_SNV TRIB3:NM_001301188:exon2:c.G82A:p.E28K,TRIB3:NM_001301190:exon2:c.G82A:p.E28K,TRIB3:NM_001301193:exon2:c.G82A:p.E28K,TRIB3:NM_001301196:exon2:c.G82A:p.E28K,TRIB3:NM_021158:exon2:c.G82A:p.E28K,TRIB3:NM_001301201:exon3:c.G163A:p.E55K
// frameshift insertion: LRRK2:NM_198578:exon1:c.151_152insCCTCCAAGTTATTTCAAGGCAAAAATATCCATGTGCCTCT:p.A51fs
// 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 SYNJ1:NM_001160306:exon28:c.3957_3958insAATACT:p.L1320delinsNTL,SYNJ1:NM_003895:exon32:c.4215_4216insAATACT:p.L1406delinsNTL
// frameshift_deletion LRRK2:NM_198578:exon17:c.2069_2070del:p.Q690fs
// frameshift_deletion ESF1:NM_001276380:exon14:c.2519_2520del:p.E840fs,ESF1:NM_016649:exon14:c.2519_2520del:p.E840fs
// nonframeshift_deletion LRRK2:NM_198578:exon9:c.1099_1101del: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++) {
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+)/ );
[, variant.posFrom, variant.posTo] = m;
variant.varType = 'Nonframeshift deletion'
} else if (aaChange.endsWith('fs') || aaChange.indexOf('delins') >=0) {
var m = aaChange.match( /([A-Z])(\d+)/ );
[ ,variant.aaFrom, variant.posFrom] = m;
if (change.indexOf('delins') >= 0 ) variant.varType = 'Nonframeshift insertion';
else 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])+/ );
if (!m || m.length != 4) continue;
[ ,variant.aaFrom, variant.posFrom, variant.aaTo] = m;
variant.varType = variant.aaFrom == variant.aaTo ? 'Synonymous SNV' : 'Nonsynonymous SNV';
}
vars.push(variant);
}
return vars;
}
module.exports = MolArt;
function MolArtVariant() {
this.posFrom = undefined;
this.posTo = undefined;
this.aaFrom = undefined;
this.aaTo = undefined;
this.varType = undefined;
this.description = undefined;
}
module.exports = MolArtVariant;
\ No newline at end of file
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];
})
}
module.exports = getUniprotSequence;
\ No newline at end of file
......@@ -19,8 +19,6 @@ import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import com.sun.xml.ws.policy.privateutil.PolicyUtils.Collections;
import lcsb.mapviewer.annotation.services.MiriamConnector;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.Pair;
......
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