Skip to content

Commit

Permalink
v2.2.2, suplicate complxes same colour, stoich expand complexes,toolt…
Browse files Browse the repository at this point in the history
…ip bug fix
  • Loading branch information
colin-combe committed Jul 4, 2024
1 parent a4f5a59 commit 5e38e02
Show file tree
Hide file tree
Showing 10 changed files with 1,627 additions and 8,561 deletions.
1,336 changes: 1,336 additions & 0 deletions data/CPX-7083.json

Large diffs are not rendered by default.

416 changes: 208 additions & 208 deletions data/EBI-25570228.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const exampleIndex = [
"name": "CPX-5897",
"url": "https://www.ebi.ac.uk/complexportal/complex/CPX-5897",
},
{
"ac": "CPX-7083",
"name": "CPX-7083",
"url": "https://www.ebi.ac.uk/complexportal/complex/CPX-7083",
},
{
"ac": "EBI-25776165",
"name": "EBI-25776165",
Expand Down
8,312 changes: 11 additions & 8,301 deletions dist/complexviewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "complexviewer",
"version": "2.2.2dev",
"version": "2.2.2",
"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.",
"author": {
"name": "Colin Combe",
Expand Down
17 changes: 9 additions & 8 deletions src/js/clone-complex-refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ export function cloneComplexRefs(json) {
interactions.forEach(function (interaction) {

// Get a collection of participants with 'complex' in interactorRef - not ideal way to get complexes
const complexesToCloneParticipantsOf = interaction.participants.filter(function (participant) {
const complexesToClone = interaction.participants.filter(function (participant) {
if (participant.interactorRef.indexOf("complex") !== -1) {
return participant;
}
});

// Loop through our participants that need expanding
complexesToCloneParticipantsOf.forEach(function (complexToCloneParticipantsOf) {
complexesToClone.forEach(function (complexToClone) {

// Do we have an interaction
const foundInteraction = findFirstObjWithAttr(interactions, "id", complexToCloneParticipantsOf.interactorRef);
const foundInteraction = findFirstObjWithAttr(interactions, "id", complexToClone.interactorRef);

// If we found an interaction then we need to clone it.
if (foundInteraction) {

let count = instanceCount.get(complexToCloneParticipantsOf.interactorRef);
let count = instanceCount.get(complexToClone.interactorRef);
if (count) {
count = count + 1;
} else {
count = 1;
}
instanceCount.set(complexToCloneParticipantsOf.interactorRef, count);
instanceCount.set(complexToClone.interactorRef, count);

let i = count;

if (i > 1) {
// this looks weird, don't think it'll work if more than 2 refs to complex?
complexToCloneParticipantsOf.interactorRef = `${complexToCloneParticipantsOf.interactorRef}_${i}`;
complexToClone.interactorRef = `${complexToClone.interactorRef}_${i}`;

// update features of complex
if (complexToCloneParticipantsOf.features) {
complexToCloneParticipantsOf.features.forEach(function (feature) {
if (complexToClone.features) {
complexToClone.features.forEach(function (feature) {
feature.copiedfrom = feature.id;
// feature.id = `${feature.id}_${i}`;
// Also, adjust our sequence data
Expand All @@ -54,6 +54,7 @@ export function cloneComplexRefs(json) {
}

const clonedInteraction = JSON.parse(JSON.stringify(foundInteraction));
clonedInteraction.sourceId = clonedInteraction.id;
clonedInteraction.id = `${clonedInteraction.id}_${i}`;

json.data.push(clonedInteraction);
Expand Down
1 change: 1 addition & 0 deletions src/js/clone-complex-stoich.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function cloneComplexesStoich(json) {
}

const clonedInteraction = JSON.parse(JSON.stringify(foundInteraction));
clonedInteraction.sourceId = clonedInteraction.id;
clonedInteraction.id = `${clonedInteraction.id}_${i}`;
clonedInteraction.interactorRef = `${complexToClone.interactorRef}_${i}`;

Expand Down
2 changes: 1 addition & 1 deletion src/js/read-mijson.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function readMijson(/*miJson*/miJson, /*App*/ app, expand = true) {
let nLink = app.allNaryLinks.get(nLinkId);
if (typeof nLink === "undefined") {
//doesn't already exist, make new nLink
nLink = new NaryLink(nLinkId, app);
nLink = new NaryLink(nLinkId, app, datum.sourceId);
app.allNaryLinks.set(nLinkId, nLink);
//alot of time is being spent on creating these IDs, stash them in the interaction object?
datum.naryId = nLinkId;
Expand Down
7 changes: 5 additions & 2 deletions src/js/viz/link/nary-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import {Link} from "./link";
import {rotatePointAboutPoint} from "../../geom";

export class NaryLink extends Link {
constructor(id, app) {
constructor(id, app, sourceId) {
super(id, app);
if (sourceId) {
this.sourceId = sourceId;
}
this.binaryLinks = new Map();
this.unaryLinks = new Map();
}
Expand All @@ -31,7 +34,7 @@ export class NaryLink extends Link {
if (!this._path) {
this._path = this._createElement("path");
if (this.app.stoichiometryExpanded) {
this.color = NaryLink.naryColors(this.id);
this.color = NaryLink.naryColors(this.sourceId?this.sourceId:this.id);
this._path.setAttribute("fill", this.color);
} else {
this._path.setAttribute("fill", "none");
Expand Down
90 changes: 50 additions & 40 deletions src/js/viz/sequence-datum.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,60 @@ export class SequenceDatum {
const firstPart = sequenceDatumString.substring(0, dashPosition);
const secondPart = sequenceDatumString.substring(dashPosition + 1);

let firstDotPosition;
if (firstPart.indexOf(".") === -1) {
this.begin = tidyPosition(firstPart);
} else {
firstDotPosition = firstPart.indexOf(".");
this.uncertainBegin = tidyPosition(firstPart.substring(0, firstDotPosition));
this.begin = tidyPosition(firstPart.substring(firstDotPosition + 2));
}

if (secondPart.indexOf(".") === -1) {
this.end = tidyPosition(secondPart);
} else {
firstDotPosition = secondPart.indexOf(".");
this.end = tidyPosition(secondPart.substring(0, firstDotPosition));
this.uncertainEnd = tidyPosition(secondPart.substring(firstDotPosition + 2));
}

if (this.begin === "n") {
if (firstPart == '?') {
this.uncertainBegin = 1;
this.begin = tidyPosition(this.end);
// this.uncertainEnd = this.end;
this.begin = tidyPosition(secondPart);
this.end = null;
}

if (this.end === "c") {
} else if (secondPart == '?') {
this.uncertainEnd = participant.size;
this.end = tidyPosition(this.begin);
// this.uncertainBegin = this.begin;
this.end = tidyPosition(firstPart);
this.begin = null;
}

if (firstPart.indexOf("<") > -1) {
this.uncertainBegin = 0;
this.begin = tidyPosition(firstPart.substring(1, firstPart.length));
}
if (secondPart.indexOf(">") > -1) {
this.end = tidyPosition(secondPart.substring(1, firstPart.length));
this.uncertainEnd = participant.size;
}

if (firstPart.indexOf(">") > -1 && secondPart.indexOf("<") > -1) {
this.uncertainBegin = tidyPosition(firstPart.substring(1, firstPart.length));
this.begin = tidyPosition(secondPart.substring(1, firstPart.length));
this.end = null;//this.begin;
} else {
let firstDotPosition;
if (firstPart.indexOf(".") === -1) {
this.begin = tidyPosition(firstPart);
} else {
firstDotPosition = firstPart.indexOf(".");
this.uncertainBegin = tidyPosition(firstPart.substring(0, firstDotPosition));
this.begin = tidyPosition(firstPart.substring(firstDotPosition + 2));
}

if (secondPart.indexOf(".") === -1) {
this.end = tidyPosition(secondPart);
} else {
firstDotPosition = secondPart.indexOf(".");
this.end = tidyPosition(secondPart.substring(0, firstDotPosition));
this.uncertainEnd = tidyPosition(secondPart.substring(firstDotPosition + 2));
}

if (this.begin === "n") {
this.uncertainBegin = 1;
this.begin = tidyPosition(this.end);
// this.uncertainEnd = this.end;
this.end = null;
}

if (this.end === "c") {
this.uncertainEnd = participant.size;
this.end = tidyPosition(this.begin);
// this.uncertainBegin = this.begin;
this.begin = null;
}

if (firstPart.indexOf("<") > -1) {
this.uncertainBegin = 1;
this.begin = tidyPosition(firstPart.substring(1, firstPart.length));
}
if (secondPart.indexOf(">") > -1) {
this.end = tidyPosition(secondPart.substring(1, firstPart.length));
this.uncertainEnd = participant.size;
}

if (firstPart.indexOf(">") > -1 && secondPart.indexOf("<") > -1) {
this.uncertainBegin = tidyPosition(firstPart.substring(1, firstPart.length));
this.begin = tidyPosition(secondPart.substring(1, firstPart.length));
this.end = null;//this.begin;
}
}
}
}
Expand Down

0 comments on commit 5e38e02

Please sign in to comment.