Skip to content

Commit dabf37d

Browse files
authored
Merge pull request #34 from colin-combe/dev
Dev
2 parents b3ff6d3 + 58903ac commit dabf37d

10 files changed

Lines changed: 31 additions & 76 deletions

File tree

dist/complexviewer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,38 @@
4444
<table class="symbols">
4545
<tr>
4646
<td>
47-
<img src="./src/imgs/key-svg/molecule-set.svg">
47+
<img src="./src/imgs/key-svg/molecule-set.svg" alt="molecule set">
4848
</td>
4949
<td>Molecule Set</td>
5050
</tr>
5151
<tr>
5252
<td>
53-
<img src="./src/imgs/key-svg/small-molecule.svg">
53+
<img src="./src/imgs/key-svg/small-molecule.svg" alt="small molecule">
5454
</td>
5555
<td>Bioactive Entity</td>
5656
</tr>
5757
<tr>
5858
<td>
59-
<img src="./src/imgs/key-svg/gene.svg">
59+
<img src="./src/imgs/key-svg/gene.svg" alt="gene">
6060
</td>
6161
<td>Gene</td>
6262
</tr>
6363
<tr>
6464
<td>
65-
<img src="./src/imgs/key-svg/dna.svg">
65+
<img src="./src/imgs/key-svg/dna.svg" alt="dna">
6666
</td>
6767
<td>DNA</td>
6868
</tr>
6969
<tr>
7070
<td>
71-
<img src="./src/imgs/key-svg/rna.svg">
71+
<img src="./src/imgs/key-svg/rna.svg" alt="rna">
7272
</td>
7373
<td>RNA</td>
7474
</tr>
7575
<tr>
7676
<td>
77-
<img src="./src/imgs/key-svg/protein-circle.svg">
78-
<img src="./src/imgs/key-svg/protein-bar.svg">
77+
<img src="./src/imgs/key-svg/protein-circle.svg" alt="protein circle">
78+
<img src="./src/imgs/key-svg/protein-bar.svg" alt="protein bar">
7979
</td>
8080
<td>Protein <br> (click to toggle)</td>
8181
</tr>
@@ -143,8 +143,8 @@
143143
<script type="text/javascript">
144144
//<![CDATA[
145145

146-
for (var i = 0; i < exampleIndex.length; i++) {
147-
var example = exampleIndex[i];
146+
for (let i = 0; i < exampleIndex.length; i++) {
147+
const example = exampleIndex[i];
148148
const dataSetsSelect = document.getElementById("dataSets");
149149
const opt = document.createElement("option");
150150
opt.value = example.ac;
@@ -178,7 +178,7 @@
178178
}
179179

180180
function setAnnotations(checkbox) {
181-
var json = cv.showAnnotations(checkbox.value, checkbox.checked);
181+
const json = cv.showAnnotations(checkbox.value, checkbox.checked);
182182
console.log(json);
183183
makeLegend(json);
184184
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "complexviewer",
3-
"version": "2.2.8",
3+
"version": "2.2.9",
44
"description": "A network visualisation that displays molecular interaction data, including detailed residue-level information such as binding sites. Used in EBI's Complex Portal and elsewhere.",
55
"author": {
66
"name": "Colin Combe",

src/js/viz/interactor/annotation.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export class Annotation {
22
constructor(annotationName, seqDatum) {
3-
// console.log("**", annotationName, seqDatum);
43
this.description = annotationName.trim();
54
this.seqDatum = seqDatum;
65
}

src/js/viz/interactor/complex.js

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@ export class Complex extends Interactor {
1313
this.upperGroup = document.createElementNS(svgns, "g");
1414
this.initLabel();
1515
this.padding = 28;
16-
17-
// const self = this;
18-
// // its bad if you end up with these getting called
19-
// Object.defineProperty(this, "width", {
20-
// get: function height() {
21-
// return self.naryLink.path.getBBox().width;
22-
// //return 160;
23-
// }
24-
// });
25-
// Object.defineProperty(this, "height", {
26-
// get: function height() {
27-
// return self.naryLink.path.getBBox().height;
28-
// //return 160;
29-
// }
30-
// });
3116
}
3217

3318
initLink(naryLink) {
@@ -36,15 +21,14 @@ export class Complex extends Interactor {
3621
}
3722

3823
setLinked() {
39-
4024
this.naryLink.path2.classList.add("linked-complex");
4125
}
4226

4327
getPosition(originPoint) {
44-
let mapped = this.naryLink.mapped;//getMappedCoordinates();
28+
let mapped = this.naryLink.mapped;
4529
if (!mapped) {
4630
this.naryLink.setLinkCoordinates();
47-
mapped = this.naryLink.mapped;//this.naryLink.orbitNodeCount(this.naryLink.getMappedCoordinates());
31+
mapped = this.naryLink.mapped;
4832
}
4933
const mc = mapped.length;
5034
let xSum = 0,
@@ -55,8 +39,6 @@ export class Complex extends Interactor {
5539
}
5640
let center = [xSum / mc, ySum / mc];
5741
if (originPoint) {
58-
// if (participant.type === "complex"){
59-
// startPoint = participant.getPosition();
6042
let naryPath = this.naryLink.hull;
6143
let iPath = [];
6244
for (let p of naryPath) {
@@ -100,15 +82,15 @@ export class Complex extends Interactor {
10082
const args = cmd.slice(1).trim().split(/[\s,]+/).map(Number);
10183

10284
switch (type) {
103-
case 'M':
104-
case 'L':
85+
case "M":
86+
case "L":
10587
for (let i = 0; i < args.length; i += 2) {
10688
const [x, y] = [args[i], args[i + 1]];
10789
updateHighest(x, y);
10890
currentPoint = [x, y];
10991
}
11092
break;
111-
case 'C':
93+
case "C":
11294
for (let i = 0; i < args.length; i += 6) {
11395
const [x1, y1, x2, y2, x, y] = args.slice(i, i + 6);
11496
updateHighest(x1, y1);
@@ -117,21 +99,21 @@ export class Complex extends Interactor {
11799
currentPoint = [x, y];
118100
}
119101
break;
120-
case 'Q':
102+
case "Q":
121103
for (let i = 0; i < args.length; i += 4) {
122104
const [x1, y1, x, y] = args.slice(i, i + 4);
123105
updateHighest(x1, y1);
124106
updateHighest(x, y);
125107
currentPoint = [x, y];
126108
}
127109
break;
128-
case 'H':
110+
case "H":
129111
for (const x of args) {
130112
updateHighest(x, currentPoint[1]);
131113
currentPoint[0] = x;
132114
}
133115
break;
134-
case 'V':
116+
case "V":
135117
for (const y of args) {
136118
updateHighest(currentPoint[0], y);
137119
currentPoint[1] = y;
@@ -154,4 +136,9 @@ export class Complex extends Interactor {
154136
getResidueCoordinates () {
155137
return this.getPosition();
156138
}
139+
140+
setAllLinkCoordinates() {
141+
this.setLabelPosition();
142+
super.setAllLinkCoordinates();
143+
}
157144
}

src/js/viz/interactor/interactor.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class Interactor {
5757
this.labelText = this.id;
5858
}
5959
if (this.labelText.length > 25) {
60-
this.labelText = `${this.labelText.substr(0, 16)}...`;
60+
this.labelText = `${this.labelText.substring(0, 16)}...`;
6161
}
6262
this.labelText = this.name;
6363
this.labelTextNode = document.createTextNode(this.labelText);
@@ -194,9 +194,6 @@ export class Interactor {
194194

195195
// update all lines (e.g after a move)
196196
setAllLinkCoordinates() {
197-
if (typeof this.setLabelPosition === "function") {
198-
this.setLabelPosition();
199-
}
200197
for (let link of this.naryLinks.values()) {
201198
link.setLinkCoordinates();
202199
if (link.complex){

src/js/viz/interactor/polymer.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {easeCubicInOut} from "d3-ease";
44
import {rotatePointAboutPoint} from "../../geom";
55
import {svgns} from "../../svgns";
66
import {Interactor} from "./interactor";
7-
// import {Annotation} from "./annotation";
8-
// import {SequenceDatum} from "../sequence-datum";
97

108
export class Polymer extends Interactor {
119
constructor() {
@@ -202,10 +200,8 @@ export class Polymer extends Interactor {
202200
const labelTranslateInterpol = d3.interpolate(labelStartPoint, -(r + 5));
203201

204202
let xInterpol = null;//,
205-
// yInterpol = null;
206203
if (typeof svgP !== "undefined" && svgP !== null) {
207204
xInterpol = d3.interpolate(this.ix, svgP.x);
208-
// yInterpol = d3.interpolate(this.iy, svgP.y);
209205
}
210206

211207
const self = this;
@@ -255,7 +251,7 @@ export class Polymer extends Interactor {
255251
self.labelSVG.transform.baseVal.initialize(self.app.svgElement.createSVGTransformFromMatrix(k));
256252

257253
if (xInterpol !== null) {
258-
self.setPosition(xInterpol(cubicInOut(interp)), self.iy);//yInterpol(cubicInOut(interp)));
254+
self.setPosition(xInterpol(cubicInOut(interp)), self.iy);
259255
}
260256

261257
self.stickZoom = stickZoomInterpol(cubicInOut(interp));
@@ -625,8 +621,7 @@ export class Polymer extends Interactor {
625621
let top, bottom, rungHeight;
626622
const rung = annotation.rung;
627623
if (rung === -1) {
628-
bottom = 0;
629-
top = radius;
624+
console.error("Error: rung is -1 for annotation: " + annotation);
630625
} else if (startRes === "n-n") {
631626
rungHeight = radius / this.nTermFeatures.length;
632627
} else if (endRes === "c-c") {

src/js/viz/link/nary-link.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// import * as d3 from "d3"; //used for d3.geom.hull
21
import {polygonHull} from "d3-polygon";
32
import {Link} from "./link";
43
import {rotatePointAboutPoint} from "../../geom";
@@ -13,23 +12,6 @@ export class NaryLink extends Link {
1312
this.unaryLinks = new Map();
1413
}
1514

16-
/*
17-
NaryLink.prototype.getTotalParticipantCount = function () {
18-
let result = 0;
19-
const c = this.participants.length;
20-
for (let p = 0; p < c; p++) {
21-
const participant = this.participants[p];
22-
//console.log("! " + typeof participant);
23-
if (participant.type !== "complex") {
24-
result++;
25-
} else {
26-
result += participant.naryLink.getTotalParticipantCount();
27-
}
28-
}
29-
return result;
30-
};
31-
*/
32-
3315
get path () {
3416
if (!this._path) {
3517
this._path = this._createElement("path");
@@ -65,7 +47,7 @@ export class NaryLink extends Link {
6547

6648
show() {
6749
// this.path.setAttribute("stroke-width", this.app.z);
68-
// this.setLinkCoordinates(); // todo - having this here slows down start up. instead see lines 41-44 complex.js
50+
// this.setLinkCoordinates(); // having this here slows down start up. instead see getPosition in complex.js
6951
this.app.naryLinks.appendChild(this.path);
7052
this.app.naryLinks.appendChild(this.path2);
7153
}

src/js/viz/link/unary-link.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//todo - is this even working? you never see it
2-
31
import {HideableLink} from "./hideable-link";
42

53
export class UnaryLink extends HideableLink {

src/js/viz/sequence-datum.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class SequenceDatum {
2222
}
2323

2424
if (this.sequenceDatumString === "?-?") {
25-
//this.begin = 1;
2625
this.end = 1; //todo - having it at begining is affecting shape of line, look at why
2726
this.uncertainEnd = participant.size ? participant.size : 1;
2827
} else if (this.sequenceDatumString === "n-n") {
@@ -34,11 +33,11 @@ export class SequenceDatum {
3433
const firstPart = sequenceDatumString.substring(0, dashPosition);
3534
const secondPart = sequenceDatumString.substring(dashPosition + 1);
3635

37-
if (firstPart == '?') {
36+
if (firstPart === "?") {
3837
this.uncertainBegin = 1;
3938
this.begin = tidyPosition(secondPart);
4039
this.end = null;
41-
} else if (secondPart == '?') {
40+
} else if (secondPart === "?") {
4241
this.uncertainEnd = participant.size;
4342
this.end = tidyPosition(firstPart);
4443
this.begin = null;
@@ -63,14 +62,12 @@ export class SequenceDatum {
6362
if (this.begin === "n") {
6463
this.uncertainBegin = 1;
6564
this.begin = tidyPosition(this.end);
66-
// this.uncertainEnd = this.end;
6765
this.end = null;
6866
}
6967

7068
if (this.end === "c") {
7169
this.uncertainEnd = participant.size;
7270
this.end = tidyPosition(this.begin);
73-
// this.uncertainBegin = this.begin;
7471
this.begin = null;
7572
}
7673

0 commit comments

Comments
 (0)