Commit fc636c06 authored by Lukas Pravda's avatar Lukas Pravda
Browse files

add covalent links from bound molecules if they are missing

parent e2725c1f
Pipeline #89338 passed with stages
in 1 minute and 14 seconds
class Visualization { class Visualization {
// component related // component related
private parent: HTMLElement; private parent: HTMLElement;
...@@ -538,7 +537,6 @@ class Visualization { ...@@ -538,7 +537,6 @@ class Visualization {
tooltip: link.toTooltip() tooltip: link.toTooltip()
} }
}); });
this.parent.dispatchEvent(e); this.parent.dispatchEvent(e);
} }
...@@ -633,6 +631,7 @@ class Visualization { ...@@ -633,6 +631,7 @@ class Visualization {
if (!n.residue.isLigand) return; if (!n.residue.isLigand) return;
this.nodeDim(n, i, g);
this.fireExternalNodeMouseLeaveEvent(n, i, g); this.fireExternalNodeMouseLeaveEvent(n, i, g);
this.showLigandLabel(n); this.showLigandLabel(n);
...@@ -679,7 +678,7 @@ class Visualization { ...@@ -679,7 +678,7 @@ class Visualization {
.filter((x: Model.InteractionNode) => !x.residue.isLigand) .filter((x: Model.InteractionNode) => !x.residue.isLigand)
.forEach((x: Model.InteractionNode) => { .forEach((x: Model.InteractionNode) => {
let lnks = this.presentBindingSite.links let lnks = this.presentBindingSite.links
.filter((y: Model.LigandResidueLink) => y.containsInteractionNode(x)) .filter((y: Model.LigandResidueLink) => y.containsNode(x))
.map((y: Model.LigandResidueLink) => [].concat.apply([], y.interaction.map(z => z.sourceAtoms))); .map((y: Model.LigandResidueLink) => [].concat.apply([], y.interaction.map(z => z.sourceAtoms)));
let concated = [].concat.apply([], lnks); let concated = [].concat.apply([], lnks);
......
...@@ -15,14 +15,14 @@ namespace Model { ...@@ -15,14 +15,14 @@ namespace Model {
GroupGroup GroupGroup
} }
/** /**
* What environment should be used * What environment should be used
* *
* @export * @export
* @enum {number} * @enum {number}
*/ */
export enum Environment { export enum Environment {
Production, Production,
Development, Development,
Internal Internal
...@@ -157,23 +157,46 @@ namespace Model { ...@@ -157,23 +157,46 @@ namespace Model {
} }
} }
export interface Link { export abstract class Link {
source: InteractionNode; public source: InteractionNode;
target: InteractionNode; public target: InteractionNode;
constructor(source: InteractionNode, target: InteractionNode) {
this.source = source;
this.target = target;
}
public containsBothNodes(a: InteractionNode, b: InteractionNode): boolean {
let condA = this.source.equals(a) && this.target.equals(b);
let condB = this.source.equals(b) && this.target.equals(a);
return condA || condB;
}
getLinkClass(): string;
hasClash(): boolean; public containsNode(node: InteractionNode) {
toTooltip(): string; return this.source.equals(node) || this.target.equals(node);
}
public containsResidue(n: Residue): boolean {
return (this.target.residue.equals(n) || this.source.residue.equals(n));
}
abstract getLinkClass(): string;
abstract hasClash(): boolean;
abstract toTooltip(): string;
} }
export class ResidueResidueLink implements Link { export class ResidueResidueLink extends Link {
target: InteractionNode; target: InteractionNode;
source: InteractionNode source: InteractionNode
interactions: Map<InteractionType, Array<string>>; interactions: Map<InteractionType, Array<string>>;
constructor(source: InteractionNode, target: InteractionNode, interactions: any) { constructor(source: InteractionNode, target: InteractionNode, interactions: any) {
this.source = source; super(source, target);
this.target = target;
this.interactions = new Map<InteractionType, Array<string>>(); this.interactions = new Map<InteractionType, Array<string>>();
Object.keys(interactions).forEach(x => { Object.keys(interactions).forEach(x => {
...@@ -182,14 +205,6 @@ namespace Model { ...@@ -182,14 +205,6 @@ namespace Model {
}); });
} }
/**
* Checks if the link contains a given node.
*/
public containsNode(n: InteractionNode): boolean {
return this.target.equals(n) || this.source.equals(n);
}
public hasClash(): boolean { public hasClash(): boolean {
this.interactions.forEach(x => { this.interactions.forEach(x => {
if (x.includes('clash')) { if (x.includes('clash')) {
...@@ -199,17 +214,6 @@ namespace Model { ...@@ -199,17 +214,6 @@ namespace Model {
return false; return false;
} }
/**
* Shorthand to check if the link contains particular underlying
* residue.
*/
public containsResidue(n: Residue): boolean {
return (this.target.residue.equals(n) || this.source.residue.equals(n));
}
public isBoundMoleculeLink(): boolean { public isBoundMoleculeLink(): boolean {
return this.source.residue.isLigand && this.target.residue.isLigand && this.interactions.get(InteractionType.AtomAtom).includes('covalent'); return this.source.residue.isLigand && this.target.residue.isLigand && this.interactions.get(InteractionType.AtomAtom).includes('covalent');
} }
...@@ -245,30 +249,20 @@ namespace Model { ...@@ -245,30 +249,20 @@ namespace Model {
} }
export class LigandResidueLink implements Link { export class LigandResidueLink extends Link {
source: InteractionNode;
target: InteractionNode;
interaction: Array<Interaction>; interaction: Array<Interaction>;
constructor(begin: InteractionNode, end: InteractionNode, beginAtoms: string[], endAtoms: string[], constructor(begin: InteractionNode, end: InteractionNode, beginAtoms: string[], endAtoms: string[],
interactionType: string, interactionDetails: string[], distance: number) { interactionType: string, interactionDetails: string[], distance: number) {
this.source = begin; super(begin, end);
this.target = end;
this.interaction = new Array<Interaction>(); this.interaction = new Array<Interaction>();
this.interaction.push( this.interaction.push(
new Interaction(beginAtoms, endAtoms, InteractionTypeUtil.parse(interactionType.replace('-', '_')), interactionDetails, distance) new Interaction(beginAtoms, endAtoms, InteractionTypeUtil.parse(interactionType.replace('-', '_')), interactionDetails, distance)
); );
} }
public containsBothNodes(a: InteractionNode, b: InteractionNode): boolean {
let condA = this.source.equals(a) && this.target.equals(b);
let condB = this.source.equals(b) && this.target.equals(a);
return condA || condB;
}
public addInteraction(beginAtoms: string[], endAtoms: string[], interactionType: string, interactionDetails: string[], distance: number): void { public addInteraction(beginAtoms: string[], endAtoms: string[], interactionType: string, interactionDetails: string[], distance: number): void {
this.interaction.push( this.interaction.push(
new Interaction(beginAtoms, endAtoms, InteractionTypeUtil.parse(interactionType.replace('-', '_')), interactionDetails, distance) new Interaction(beginAtoms, endAtoms, InteractionTypeUtil.parse(interactionType.replace('-', '_')), interactionDetails, distance)
...@@ -293,10 +287,6 @@ namespace Model { ...@@ -293,10 +287,6 @@ namespace Model {
return 'other'; return 'other';
} }
public containsInteractionNode(node: InteractionNode) {
return this.source.equals(node) || this.target.equals(node);
}
public hasClash(): boolean { public hasClash(): boolean {
this.interaction.forEach(x => { this.interaction.forEach(x => {
x.interactionsClases.forEach(y => { x.interactionsClases.forEach(y => {
...@@ -371,6 +361,19 @@ namespace Model { ...@@ -371,6 +361,19 @@ namespace Model {
this.links.push(link); this.links.push(link);
}); });
let searchableNodes = Array.from(this.tmpNodesSet);
data.composition.connections.forEach(pair => {
let bgn = searchableNodes.find(x => x.residue.id === pair[0]);
let end = searchableNodes.find(x => x.residue.id === pair[1]);
let result = this.links.find(x => x.containsBothNodes(bgn, end));
if (result === undefined) {
let link = new ResidueResidueLink(bgn, end, { 'atom_atom': ['covalent'] });
this.links.push(link);
}
});
this.interactionNodes = Array.from(this.tmpNodesSet.values()); this.interactionNodes = Array.from(this.tmpNodesSet.values());
return this; return this;
...@@ -424,7 +427,7 @@ namespace Model { ...@@ -424,7 +427,7 @@ namespace Model {
return; // we do not want to show 'self interactions' return; // we do not want to show 'self interactions'
} }
let tmpLink = tmpLinks.find(x => (<LigandResidueLink>x).containsBothNodes(bgnNode, endNode)) as LigandResidueLink; let tmpLink = tmpLinks.find(x => x.containsBothNodes(bgnNode, endNode));
if (tmpLink !== undefined) { if (tmpLink !== undefined) {
tmpLink.addInteraction(x.ligand_atoms, x.end.atom_names, x.interaction_type, x.interaction_details, x.distance); tmpLink.addInteraction(x.ligand_atoms, x.end.atom_names, x.interaction_type, x.interaction_details, x.distance);
......
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