Skip to content

Commit af3faad

Browse files
committed
change to https json service for uniprot data
1 parent a628ef5 commit af3faad

6 files changed

Lines changed: 109 additions & 101 deletions

File tree

build/complexviewer.js

Lines changed: 55 additions & 51 deletions
Large diffs are not rendered by default.

src/controller/Controller.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ xiNET.Controller.prototype.setAnnotations = function(annotationChoice) {
992992

993993
var colourScheme;// = null;
994994
if (catCount < 3){catCount = 3;}
995-
if (catCount < 21) {
995+
//~ if (catCount < 21) {
996996
if (catCount < 6) {
997997
//~ var reversed = colorbrewer.Accent[catCount].slice().reverse();
998998
//~ colourScheme = d3.scale.ordinal().range(reversed);
@@ -1012,16 +1012,17 @@ xiNET.Controller.prototype.setAnnotations = function(annotationChoice) {
10121012
var mol = mols[m];
10131013
for (a = 0; a < mol.annotations.length; a++) {
10141014
var anno = mol.annotations[a];
1015-
if (anno.name == "No annotations") {
1015+
if (anno.description == "No annotations") {
10161016
var c = "#cccccc";
10171017
} else {
1018-
var c = colourScheme(anno.name);
1018+
console.log(">" + anno.description);
1019+
var c = colourScheme(anno.description);
10191020
}
10201021
anno.pieSlice.setAttribute("fill", c);
10211022
anno.pieSlice.setAttribute("stroke", c);
10221023
}
10231024
}
1024-
}
1025+
//~ }
10251026
self.legendChanged(colourScheme);
10261027
}
10271028
};

src/controller/xiNET_Storage.js

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ xiNET_Storage.accessionFromId = function (id){
4040
xiNET_Storage.getUniProtTxt = function (id, callback){
4141
var accession = xiNET_Storage.accessionFromId(id);
4242
function uniprotWebService(){
43-
var url = "http://www.uniprot.org/uniprot/" + accession + ".txt";
44-
d3.text(url, function (txt){
43+
var url = "https://www.ebi.ac.uk/proteins/api/proteins/" + accession;
44+
d3.json(url, function (txt){
4545
//~ // console.log(accession + " retrieved from UniProt.");
4646
//~ if(typeof(Storage) !== "undefined") {
4747
//~ localStorage.setItem(xiNET_Storage.ns + "UniProtKB."+ accession, txt);
@@ -73,45 +73,47 @@ xiNET_Storage.getUniProtTxt = function (id, callback){
7373

7474
xiNET_Storage.getSequence = function (id, callback){
7575
//~ var accession = xiNET_Storage.accessionFromId(id);
76-
xiNET_Storage.getUniProtTxt(id, function(noNeed, txt){
77-
var sequence = "";
78-
var lines = txt.split('\n');
79-
var lineCount = lines.length;
80-
for (var l = 0; l < lineCount; l++){
81-
var line = lines[l];
82-
if (line.indexOf("SQ") === 0){
83-
//sequence = line;
84-
l++;
85-
for (l; l < lineCount; l++){
86-
line = lines[l];
87-
sequence += line;
88-
}
89-
}
90-
}
91-
callback(id, sequence.replace(/[^A-Z]/g, ''));
76+
xiNET_Storage.getUniProtTxt(id, function(noNeed, json){
77+
//~ var sequence = "";
78+
//~ var lines = txt.split('\n');
79+
//~ var lineCount = lines.length;
80+
//~ for (var l = 0; l < lineCount; l++){
81+
//~ var line = lines[l];
82+
//~ if (line.indexOf("SQ") === 0){
83+
//~ //sequence = line;
84+
//~ l++;
85+
//~ for (l; l < lineCount; l++){
86+
//~ line = lines[l];
87+
//~ sequence += line;
88+
//~ }
89+
//~ }
90+
//~ }
91+
callback(id, json.sequence.replace(/[^A-Z]/g, ''));
9292
}
9393
);
9494
}
9595

9696
xiNET_Storage.getUniProtFeatures = function (id, callback){
9797
var accession = xiNET_Storage.accessionFromId(id);
98-
xiNET_Storage.getUniProtTxt(id, function(id, txt){
99-
var features = new Array();
100-
var lines = txt.split('\n');
101-
var lineCount = lines.length;
102-
for (var l = 0; l < lineCount; l++){
103-
var line = lines[l];
104-
if (line.indexOf("FT") === 0){
105-
var fields = line.split(/\s{2,}/g);
106-
if (fields.length > 4 && fields[1] === 'DOMAIN') {
107-
//console.log(fields[1]);fields[4].substring(0, fields[4].indexOf("."))
108-
var name = fields[4].substring(0, fields[4].indexOf("."));
109-
features.push(new Annotation (name, fields[2], fields[3], null, fields[4]));
110-
}
111-
}
112-
}
113-
callback(id, features);
114-
}
98+
xiNET_Storage.getUniProtTxt(id, function(id, json){
99+
//~ var features = new Array();
100+
//~ var lines = txt.split('\n');
101+
//~ var lineCount = lines.length;
102+
//~ for (var l = 0; l < lineCount; l++){
103+
//~ var line = lines[l];
104+
//~ if (line.indexOf("FT") === 0){
105+
//~ var fields = line.split(/\s{2,}/g);
106+
//~ if (fields.length > 4 && fields[1] === 'DOMAIN') {
107+
//~ //console.log(fields[1]);fields[4].substring(0, fields[4].indexOf("."))
108+
//~ var name = fields[4].substring(0, fields[4].indexOf("."));
109+
//~ features.push(new Annotation (name, fields[2], fields[3], null, fields[4]));
110+
//~ }
111+
//~ }
112+
//~ }
113+
callback(id, json.features.filter(function(ft){
114+
return ft.type == "DOMAIN";
115+
}));
116+
}
115117
);
116118
}
117119

src/model/interactor/Annotation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
//constructor for annotations
1212
function Annotation(annotName, startRes, endRes, colour, notes) {
13-
this.name = annotName;
14-
this.start = startRes;
13+
this.description = annotName;
14+
this.begin = startRes;
1515
this.end = endRes;
1616
if (colour !== undefined && colour !== null) {
1717
this.colour = colour;
1818
}
19-
this.notes = notes;
19+
//~ this.description = notes;
2020
}
2121

2222
module.exports = Annotation;

src/model/interactor/Molecule.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,16 @@ Molecule.prototype.setPositionalFeatures = function(posFeats) {
206206
var y = -Molecule.STICKHEIGHT / 2;
207207
//draw longest regions first
208208
posFeats.sort(function(a, b) {
209-
return (b.end - b.start) - (a.end - a.start);
209+
return (b.end - b.begin) - (a.end - a.begin);
210210
});
211211
this.annotations = posFeats;
212212
if (this.annotations.length == 0) {
213213
//~ alert("no annot");
214-
this.annotations.push({start: 1, end: this.size, name: "No annotations"});
214+
this.annotations.push({begin: 1, end: this.size, description: "No annotations"});
215215
}
216216
for (var i = 0; i < posFeats.length; i++) {
217217
var anno = posFeats[i];
218-
anno.start = anno.start - 0;
218+
anno.begin = anno.begin - 0;
219219
anno.end = anno.end - 0;
220220
anno.pieSlice = document.createElementNS(Config.svgns, "path");
221221
if (this.form === 0) {
@@ -225,7 +225,7 @@ Molecule.prototype.setPositionalFeatures = function(posFeats) {
225225
}
226226
anno.pieSlice.setAttribute("stroke-width", 1);
227227
anno.pieSlice.setAttribute("fill-opacity", "0.6");
228-
var text = anno.name + " [" + anno.start + " - " + anno.end + "]";
228+
var text = anno.description + " [" + anno.begin + " - " + anno.end + "]";
229229
anno.pieSlice.name = text;
230230
var xlv = this.controller;
231231
var self = this;

src/model/interactor/Polymer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ Polymer.prototype.getResidueCoordinates = function(r, yOff) {
558558
Polymer.stepsInArc = 5;
559559

560560
Polymer.prototype.getAnnotationPieSliceArcPath = function(annotation) {
561-
var startAngle = ((annotation.start - 1) / this.size) * 360;
561+
console.log(">>" + annotation.begin);
562+
var startAngle = ((annotation.begin - 1) / this.size) * 360;
562563
var endAngle = ((annotation.end - 1) / this.size) * 360;
563564
var radius = this.getBlobRadius() - 2;
564565
var arcStart = Molecule.trig(radius, startAngle - 90);
@@ -573,7 +574,7 @@ Polymer.prototype.getAnnotationPieSliceArcPath = function(annotation) {
573574

574575
Polymer.prototype.getAnnotationPieSliceApproximatePath = function(annotation) {
575576
//approximate pie slice
576-
var startAngle = ((annotation.start - 1) / this.size) * 360;
577+
var startAngle = ((annotation.begin - 1) / this.size) * 360;
577578
var endAngle = ((annotation.end) / this.size) * 360;
578579
var pieRadius = this.getBlobRadius() - 2;
579580
var arcStart = Molecule.trig(pieRadius, startAngle - 90);
@@ -593,8 +594,8 @@ Polymer.prototype.getAnnotationPieSliceApproximatePath = function(annotation) {
593594
Polymer.prototype.getAnnotationRectPath = function(annotation) {
594595
//domain as rectangle path
595596
var bottom = Polymer.STICKHEIGHT / 2, top = -Polymer.STICKHEIGHT / 2;
596-
var annotX = this.getResXwithStickZoom(annotation.start - 0.5);
597-
var annotSize = (1 + (annotation.end - annotation.start));
597+
var annotX = this.getResXwithStickZoom(annotation.begin - 0.5);
598+
var annotSize = (1 + (annotation.end - annotation.begin));
598599
var annotLength = annotSize * Polymer.UNITS_PER_RESIDUE * this.stickZoom;
599600
var rectPath = "M " + annotX + "," + bottom;
600601
for (var sia = 0; sia <= Polymer.stepsInArc; sia++) {

0 commit comments

Comments
 (0)