Skip to content
Snippets Groups Projects
Commit fc636c06 authored by Lukas Pravda's avatar Lukas Pravda
Browse files

add covalent links from bound molecules if they are missing

parent e2725c1f
No related branches found
No related tags found
No related merge requests found
Pipeline #89338 passed with stages
in 1 minute and 14 seconds
class Visualization {
// component related
private parent: HTMLElement;
......@@ -538,7 +537,6 @@ class Visualization {
tooltip: link.toTooltip()
}
});
this.parent.dispatchEvent(e);
}
......@@ -633,6 +631,7 @@ class Visualization {
if (!n.residue.isLigand) return;
this.nodeDim(n, i, g);
this.fireExternalNodeMouseLeaveEvent(n, i, g);
this.showLigandLabel(n);
......@@ -679,7 +678,7 @@ class Visualization {
.filter((x: Model.InteractionNode) => !x.residue.isLigand)
.forEach((x: Model.InteractionNode) => {
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)));
let concated = [].concat.apply([], lnks);
......
......@@ -15,14 +15,14 @@ namespace Model {
GroupGroup
}
/**
* What environment should be used
*
* @export
* @enum {number}
*/
export enum Environment {
export enum Environment {
Production,
Development,
Internal
......@@ -157,23 +157,46 @@ namespace Model {
}
}
export interface Link {
source: InteractionNode;
target: InteractionNode;
export abstract class Link {
public source: 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;
toTooltip(): string;
public containsNode(node: InteractionNode) {
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;
source: InteractionNode
interactions: Map<InteractionType, Array<string>>;
constructor(source: InteractionNode, target: InteractionNode, interactions: any) {
this.source = source;
this.target = target;
super(source, target);
this.interactions = new Map<InteractionType, Array<string>>();
Object.keys(interactions).forEach(x => {
......@@ -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 {
this.interactions.forEach(x => {
if (x.includes('clash')) {
......@@ -199,17 +214,6 @@ namespace Model {
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 {
return this.source.residue.isLigand && this.target.residue.isLigand && this.interactions.get(InteractionType.AtomAtom).includes('covalent');
}
......@@ -245,30 +249,20 @@ namespace Model {
}
export class LigandResidueLink implements Link {
source: InteractionNode;
target: InteractionNode;
export class LigandResidueLink extends Link {
interaction: Array<Interaction>;
constructor(begin: InteractionNode, end: InteractionNode, beginAtoms: string[], endAtoms: string[],
interactionType: string, interactionDetails: string[], distance: number) {
this.source = begin;
this.target = end;
super(begin, end);
this.interaction = new Array<Interaction>();
this.interaction.push(
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 {
this.interaction.push(
new Interaction(beginAtoms, endAtoms, InteractionTypeUtil.parse(interactionType.replace('-', '_')), interactionDetails, distance)
......@@ -293,10 +287,6 @@ namespace Model {
return 'other';
}
public containsInteractionNode(node: InteractionNode) {
return this.source.equals(node) || this.target.equals(node);
}
public hasClash(): boolean {
this.interaction.forEach(x => {
x.interactionsClases.forEach(y => {
......@@ -371,6 +361,19 @@ namespace Model {
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());
return this;
......@@ -424,7 +427,7 @@ namespace Model {
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) {
tmpLink.addInteraction(x.ligand_atoms, x.end.atom_names, x.interaction_type, x.interaction_details, x.distance);
......
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