-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_asa_residues.js
55 lines (52 loc) · 1.93 KB
/
add_asa_residues.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"use strict";
var add_asa_residues = function (_n){
var asa_res = null;
if( !imported_flag && top.asa_residues ){
var n_model = top.n_model_main_frame-1;
if(_n)n_model = _n-1;
var asa_res = ["RESIDUE_ASA",[]];
var n = 1;
for(var i = 0;i<__alignment.uniprotLength+1;i++){
var __f = { type: "VARIANT", pos: i, variants: [] };
asa_res[1].push(__f);
n++;
}
var chain = JSON.parse( getParameterByName('alignment') )['chain'];
if(top.asa_residues[n_model][chain]){
var n = 0;
top.asa_residues[n_model][chain].forEach(function(i){
var r = parseInt(i[1]*255);
if(r>255)r=255;
var b = 255-r;
if(b<0)b = 0;
var color = 'rgb('+r+',0,'+b+')';
var rasa = parseFloat(i[1]*100).toFixed(2);
if(asa_res[1][ parseInt(i[0]) ]){
asa_res[1][ parseInt(i[0]) ].variants = [{ color:color,
alternativeSequence:'',
type:'measure',
begin: i[0],
end: i[0],
score:i[1],
internalId:'asa_'+n,
description:'<b style=\"color:grey;\">Relative accessible surface area</b><br/>Residue accesibility '+rasa+'%'
}];
}
n++;
});
}
}
return asa_res;
};
function getParameterByName(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
module.exports = add_asa_residues;