Commit 9ea3929d authored by jdurrant's avatar jdurrant
Browse files

Removed unused files.

parent 00b9e8ae
...@@ -35,7 +35,6 @@ self.onmessage = function(e) { ...@@ -35,7 +35,6 @@ self.onmessage = function(e) {
let fakeFS = binana["fs"]["shim"]["fake_fs"]; let fakeFS = binana["fs"]["shim"]["fake_fs"];
let newFS = {}; let newFS = {};
for (let flnm of Object.keys(fakeFS)) { for (let flnm of Object.keys(fakeFS)) {
// if (["/vmd/output.json", "/vmd/log.txt"].indexOf(flnm) !== -1) {
if (flnm.startsWith("/vmd/")) { if (flnm.startsWith("/vmd/")) {
let content = fakeFS[flnm]; let content = fakeFS[flnm];
flnm = flnm.slice(5); flnm = flnm.slice(5);
......
...@@ -252,23 +252,6 @@ export function getInfoForHighlight(interactionName: string): IHighlightInfo { ...@@ -252,23 +252,6 @@ export function getInfoForHighlight(interactionName: string): IHighlightInfo {
// make an array for the interactions // make an array for the interactions
let interactionType = binanaData[interactionName]; let interactionType = binanaData[interactionName];
// if (interactionName === "metalCoordinations") {
// // In this case, organized by "coordinatingAtoms" and "metalAtoms".
// // Trick it into using "ligandAtoms" and "receptorAtoms" so below code
// // will work without modification.
// let newInteractionType = [];
// for (let idx in interactionType) {
// let metalAtomInf = interactionType[idx]["metalAtoms"][0];
// for (let coordinatingAtom of interactionType[idx]["coordinatingAtoms"]) {
// newInteractionType.push({
// "ligandAtoms": [metalAtomInf],
// "receptorAtoms": [coordinatingAtom]
// })
// }
// }
// interactionType = newInteractionType;
// }
// A single atom may participate in multiple interactions with other // A single atom may participate in multiple interactions with other
// atoms. Make sure each atom is rendered in the viewer only once. // atoms. Make sure each atom is rendered in the viewer only once.
idxOfAtomsSeen = new Set([]); idxOfAtomsSeen = new Set([]);
...@@ -318,11 +301,6 @@ export function getInfoForHighlight(interactionName: string): IHighlightInfo { ...@@ -318,11 +301,6 @@ export function getInfoForHighlight(interactionName: string): IHighlightInfo {
} }
} }
// Store.store.commit("setVar", {
// name: "colorMessage",
// val: colorMsg
// });
ligAtomInfs = ligAtomInfs.concat( ligAtomInfs = ligAtomInfs.concat(
getAtomObjRadiusColor(ligandMol, ligandAtomInfs, ligColor) getAtomObjRadiusColor(ligandMol, ligandAtomInfs, ligColor)
); );
...@@ -559,11 +537,6 @@ function getAtomObjRadiusColor(mol: any, atomInfs: any, color: string): any[] { ...@@ -559,11 +537,6 @@ function getAtomObjRadiusColor(mol: any, atomInfs: any, color: string): any[] {
* @returns void * @returns void
*/ */
export function clearInteraction(): void { export function clearInteraction(): void {
// Store.store.commit("setVar", {
// name: "colorMessage",
// val: Store.defaultColorMsg
// });
if (viewer === undefined) { if (viewer === undefined) {
return; return;
} }
...@@ -577,13 +550,11 @@ export function clearInteraction(): void { ...@@ -577,13 +550,11 @@ export function clearInteraction(): void {
export function highlightAll(): void { export function highlightAll(): void {
let interactionVisibilityStatus = JSON.parse(Store.store.state["interactionVisibilityStatus"]); let interactionVisibilityStatus = JSON.parse(Store.store.state["interactionVisibilityStatus"]);
// if (interactionName !== undefined) {
clearInteraction(); clearInteraction();
let highlightInfos = []; let highlightInfos = [];
let tableData = []; let tableData = [];
for (let interactionName of renderOrder) { for (let interactionName of renderOrder) {
// for (let interactionName in interactionVisibilityStatus) {
if (interactionVisibilityStatus[interactionName]) { if (interactionVisibilityStatus[interactionName]) {
highlightInfos.push( highlightInfos.push(
getInfoForHighlight(interactionName) getInfoForHighlight(interactionName)
...@@ -612,6 +583,4 @@ export function highlightAll(): void { ...@@ -612,6 +583,4 @@ export function highlightAll(): void {
}) })
highlight(highlightInfos); highlight(highlightInfos);
// }
} }
\ No newline at end of file
// This file is part of BINANA, released under the Apache 2.0 License. See
// LICENSE.md or go to https://opensource.org/licenses/Apache-2.0 for full
// details. Copyright 2021 Jacob D. Durrant.
declare var Vue;
declare var jQuery;
/** An object containing the vue-component computed functions. */
let computedFunctions = {};
/** An object containing the vue-component methods functions. */
let methodsFunctions = {};
/** An object containing the vue-component watch functions. */
let watchFunctions = {}
/**
* The vue-component mounted function.
* @returns void
*/
function mountedFunction(): void {}
/**
* Setup the check-mark Vue commponent.
* @returns void
*/
export function setup(): void {
Vue.component("check-mark", {
/**
* Get the data associated with this component.
* @returns any The data.
*/
"data"(): any {
return {};
},
"methods": methodsFunctions,
"template": /* html */ `
<span>
<div class="spacer25px" v-if="value">✔️</div>
<div class="spacer25px" v-else></div>
<slot></slot>
<div class="spacer25px"></div>
</span>
`,
"props": {
"value": Boolean,
},
"computed": computedFunctions,
/**
* Runs when the vue component is mounted.
* @returns void
*/
"mounted": mountedFunction,
"watch": watchFunctions
});
}
// This file is part of BINANA, released under the Apache 2.0 License. See
// LICENSE.md or go to https://opensource.org/licenses/Apache-2.0 for full
// details. Copyright 2021 Jacob D. Durrant.
declare var Vue;
declare var jQuery;
/** An object containing the vue-component computed functions. */
let computedFunctions = {
/** Gets and sets the file. On setting, also checks for a valid extension
* and opens the convert modal if necessary. */
"val": {
get(): any {
if (this["file"] === false) {
return [];
}
return this["file"];
},
set(val: any): void {
if (val === null) {
// Reseting the value. Nothing to do here.
return;
}
// Check if the file extension is ok.
let namePts = val["name"].toLowerCase().split(/\./g);
let ext = namePts[namePts.length - 1];
let acceptableExt = this["accept"]
.toLowerCase()
.split(/,/g)
.map((e) => e.replace(/ /g, "").replace(/\./, ""));
let convertExt = this["convert"]
.toLowerCase()
.split(/,/g)
.map((e) => e.replace(/ /g, "").replace(/\./, ""));
if (convertExt.indexOf(ext) !== -1) {
// TODO: Cruft?
// Set the filename.
debugger;
this.$store.commit("updateFileName", {
type: this["id"],
filename: val.name,
});
return;
} else if (acceptableExt.indexOf(ext) === -1) {
// It is not one of the acceptable extensions that can be
// converted. Need to cancel.
let extsAllowed = acceptableExt.concat(convertExt);
let msg = "The file must end in ";
if (extsAllowed.length > 1) {
extsAllowed[extsAllowed.length - 1] =
"or " + extsAllowed[extsAllowed.length - 1];
}
let okFilesString: string;
if (extsAllowed.length > 2) {
okFilesString = extsAllowed.join('," "');
} else {
okFilesString = extsAllowed.join('" "');
}
okFilesString = okFilesString.replace(/"or /g, 'or "');
msg +=
'"' + okFilesString + '." Your file ends in "' + ext + '."';
this.$store.commit("openModal", {
title: "Invalid File Extension!",
body: "<p>" + msg + "</p>",
});
this["file"] = null;
return;
}
this["file"] = val;
this.$store.commit("setValidationParam", {
name: this["id"],
val: true,
});
this.$store.commit("updateFileName", {
type: this["id"],
filename: val.name,
});
this.getModelFileContents(this["file"]).then((text: string) => {
this.$store.commit("setVar", {
name: this["id"] + "Contents",
val: text,
});
});
},
},
/**
* Generates a string describing all the acceptable file formats.
* @returns string The string.
*/
"allAcceptableFiles"(): string {
return (
this["accept"] +
(this["convert"] === "" ? "" : ", " + this["convert"])
);
},
/**
* Determine whether the component value is valid.
* @returns boolean True if it is valid, false otherwise.
*/
"isValid"(): boolean {
if (this["file"] !== false && this["file"] !== null) {
return true;
} else if (this.$store.state[this["id"] + "ForceValidate"] === true) {
// This runs when you convert from a non-pdbqt file
// converted to pdbqt.
let flnm = this.$store.state[this["id"] + "FileName"];
this["file"] = new File([], flnm);
this["placeholder"] = flnm;
return true;
}
return false;
},
};
/** An object containing the vue-component methods functions. */
let methodsFunctions = {
/**
* Given a file object, returns a promise that resolves the text
* in that file.
* @param {*} fileObj The file object.
* @returns Promise
*/
getModelFileContents(fileObj): Promise<any> {
return new Promise((resolve, reject) => {
var fr = new FileReader();
fr.onload = () => {
// @ts-ignore: Not sure why this causes Typescript problems.
var data = new Uint8Array(fr.result);
resolve(new TextDecoder("utf-8").decode(data));
};
fr.readAsArrayBuffer(fileObj);
});
},
"getDisplayFileNames"(files: any[], filesTraversed: any[], names: string[]): string[] {
if (names !== undefined) {
return names.map(n => this.$store.state[this["id"] + "FileName"]);
}
return [""];
}
};
/** An object containing the vue-component watch functions. */
let watchFunctions = {
/**
* Watch when the receptorContents computed property.
* @param {string} newForceFileName The new value of the property.
* @param {string} oldForceFileName The old value of the property.
* @returns void
*/
"forceFileName": function (newForceFileName: string, oldForceFileName: string): void {
if (newForceFileName !== null) {
// this["placeholder"] = newForceFileName;
this.$store.state[this["id"] + "ForceValidate"] = true;
this["file"] = null;
}
}
// /**
// * Watch when the receptorContents computed property.
// * @param {*} newFile The new value of the property.
// * @param {*} oldFile The old value of the property.
// * @returns void
// */
// "forcedFile": function (newFile: Blob, oldFile: Blob): void {
// if (newFile !== null) {
// this["file"] = newFile;
// // Read from blob (for debugging)
// // var fr = new FileReader();
// // fr.onload = () => {
// // // @ts-ignore: Not sure why this causes Typescript problems.
// // var data = new Uint8Array(fr.result);
// // let ggg = new TextDecoder("utf-8").decode(data);
// // debugger;
// // };
// // fr.readAsArrayBuffer(newFile);
// }
// }
}
/**
* The vue-component mounted function.
* @returns void
*/
function mountedFunction(): void {
// Make default validation entry.
if (this.$store.state["validation"][this["id"]] === undefined) {
this.$store.commit("setValidationParam", {
name: this["id"],
val: false,
});
}
// If it's not required, automatically validate.
if (this["required"] === false) {
this.$store.commit("setValidationParam", {
name: this["id"],
val: true,
});
jQuery("." + this["id"])
.find("input")
.removeClass("is-invalid");
}
}
/**
* Setup the file-input Vue commponent.
* @returns void
*/
export function setup(): void {
Vue.component("file-input", {
/**
* Get the data associated with this component.
* @returns any The data.
*/
"data"(): any {
return {
file: false,
"placeholder": "Choose a file or drop it here...",
};
},
"methods": methodsFunctions,
"template": `
<form-group
:label="label"
:id="'input-group-' + id"
:description="description"
styl="line-height:0;"
>
<template v-slot:extraDescription>
<slot name="extraDescription"></slot>
</template>
<b-form-file
v-model="val"
:state="Boolean(file)"
:placeholder="placeholder"
drop-placeholder="Drop file here..."
:class="id"
:accept="allAcceptableFiles"
:required="required"
:file-name-formatter="getDisplayFileNames"
></b-form-file>
<small v-if="(!isValid) && (required === true)" alert tabindex="-1" class="text-danger form-text">{{invalidMsg}}</small>
</form-group>
`,
"props": {
"label": String,
"id": String, // "receptor" or "ligand"
"description": String,
"invalidMsg": {
"type": String,
"default": "This field is required!",
},
"required": {
"type": Boolean,
"default": true,
},
"accept": {
"type": String,
"default": ".pdbqt, .out, .pdb",
},
"convert": {
"type": String,
"default": "",
},
// If you want to update filename externally
"forceFileName": {
"type": String,
"default": null
}
// // If you want to impose a file externally.
// "forcedFile": {
// "type": Object,
// "default": null
// }
},
"computed": computedFunctions,
/**
* Runs when the vue component is mounted.
* @returns void
*/
"mounted": mountedFunction,
"watch": watchFunctions
});
}
...@@ -43,26 +43,6 @@ let computedFunctions = { ...@@ -43,26 +43,6 @@ let computedFunctions = {
} }
}, },
/**
* Whether to show a link allowing the user to separate a ligand from the
* protein structure.
* @returns boolean True if it should be shown. False otherwise.
*/
// "showKeepProteinOnlyLink"(): boolean {
// let ligLines = Utils.keepOnlyProteinAtoms(this.$store.state["receptorContents"], true);
// let allResidues = ligLines.split("\n").map(l => l.substr(17,3).trim());
// let residues = allResidues.filter(function(item, pos) {
// return allResidues.indexOf(item) == pos;
// }).filter(r => r !== "").sort();
// // Don't include waters.
// residues = residues.filter(r => Utils.waterResidues.indexOf(r) === -1);
// this["nonProteinResidues"] = ": " + residues.join(", ");
// return ligLines.length > 0;
// },
interactionVisibilityStatus: { interactionVisibilityStatus: {
get(): string { get(): string {
return this.$store.state["interactionVisibilityStatus"]; return this.$store.state["interactionVisibilityStatus"];
...@@ -326,35 +306,6 @@ let methodsFunctions = { ...@@ -326,35 +306,6 @@ let methodsFunctions = {
"log.txt", this.$store.state["filesToSave"]["log.txt"] "log.txt", this.$store.state["filesToSave"]["log.txt"]
); );
// let ligTxt = Store.store.state.ligandContents;
// let recepTxt = Store.store.state.receptorContents;
// let models = binana.load_ligand_receptor.from_texts(ligTxt, recepTxt)
// let ligand, receptor;
// [ligand, receptor] = models;
// let data = JSON.parse(Store.store.state["filesToSave"]["output.json"]);
// console.log(data)
// let hbondInf = binana.interactions.get_hydrogen_or_halogen_bonds(ligand, receptor);
// console.log(hbondInf);
// console.log(data["hydrogenBonds"]);
// ["closestContacts",
// "closeContacts",
// "hydrophobicContacts",
// "hydrogenBonds",
// "piPiStackingInteractions",
// "tStackingInteractions",
// "cationPiInteractions",
// "saltBridges",
// "activeSiteFlexibility",
// "electrostaticEnergies",
// "ligandAtomTypes"]
// let pdbTxt = binana.output.pdb_file.write(ligand, receptor, null, null, null, data["hydrogenBonds"], null, null, null, null, null, true);
// debugger;
for (let flnm in this.$store.state["filesToSave"]) { for (let flnm in this.$store.state["filesToSave"]) {
zip["folder"]("binana_output")["file"]( zip["folder"]("binana_output")["file"](
"vmd/" + flnm, this.$store.state["filesToSave"][flnm] "vmd/" + flnm, this.$store.state["filesToSave"][flnm]
...@@ -418,58 +369,6 @@ let methodsFunctions = { ...@@ -418,58 +369,6 @@ let methodsFunctions = {
return pass; return pass;
}, },
/**
* Removes residues from protein model that are not protein amino acids.
* @param {any} e The click event.
* @returns void
*/
// "onShowKeepProteinOnlyClick"(e: any): void {
// // let proteinLinesToKeep = Utils.keepOnlyProteinAtoms(this.$store.state["receptorContents"]);
// // let ligandLinesToKeep = Utils.keepOnlyProteinAtoms(this.$store.state["receptorContents"], true);
// let proteinLinesToKeep = this.$store.state["receptorContents"];
// let ligandLinesToKeep = this.$store.state["receptorContents"];
// // Get new ligand filename
// let receptorExt = Utils.getExt(this.$store.state["receptorFileName"]);
// let newLigFilename = Utils.replaceExt(
// this.$store.state["receptorFileName"],
// "ligand." + receptorExt
// );
// // Update receptor contents.
// this.$store.commit("setVar", {
// name: "receptorContents",
// val: proteinLinesToKeep
// });
// // Update receptor filename
// this.$store.commit("updateFileName", {
// type: "receptor",
// filename: Utils.replaceExt(
// this.$store.state["receptorFileName"],
// "protein." + receptorExt
// )
// });
// // Update ligand contents
// this.$store.commit("setVar", {
// name: "ligandContents",
// val: ligandLinesToKeep
// });
// this.$store.commit("updateFileName", {
// type: "ligand",
// filename: newLigFilename
// });
// this["forceLigandFileName"] = newLigFilename;
// e.preventDefault();
// e.stopPropagation();
// },
"getInteractionVisibility"(interactionID: string): boolean { "getInteractionVisibility"(interactionID: string): boolean {
let interactionVisibilityStatus = JSON.parse(this.interactionVisibilityStatus); let interactionVisibilityStatus = JSON.parse(this.interactionVisibilityStatus);
if (interactionVisibilityStatus[interactionID] === undefined) { if (interactionVisibilityStatus[interactionID] === undefined) {
...@@ -509,21 +408,9 @@ let methodsFunctions = { ...@@ -509,21 +408,9 @@ let methodsFunctions = {
"onExtractReceptorAtomsToLigand"(residueInfo: IResidueInfo): void { "onExtractReceptorAtomsToLigand"(residueInfo: IResidueInfo): void {
// Get the existing ligand contents // Get the existing ligand contents
// let ligContents: string = this.$store.state["ligandContents"];
// let ligFilename: string = this.$store.state["ligandFileName"]
let ligContents = residueInfo.residuePdbLines; let ligContents = residueInfo.residuePdbLines;
let ligFilename = residueInfo.residueId.filter(r => [undefined, ""].indexOf(r) === -1).join("-") + ".pdb";