File size: 8,678 Bytes
71174bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | <template>
<PluginComponent :infoPayload="infoPayload" v-model="open" cancelBtnTxt="Cancel" actionBtnTxt="Append Example Data"
@onPopupDone="onPopupDone" :isActionBtnEnabled="true" @onUserArgChanged="onUserArgChanged"
@onMolCountsChanged="onMolCountsChanged">
</PluginComponent>
</template>
<script lang="ts">
import { Options } from "vue-class-component";
import { IContributorCredit, ISoftwareCredit } from "../../PluginInterfaces";
import FormFile from "@/UI/Forms/FormFile.vue";
import PluginComponent from "@/Plugins/Parents/PluginComponent/PluginComponent.vue";
import { PluginParentClass } from "@/Plugins/Parents/PluginParentClass/PluginParentClass";
import {
IUserArgAlert,
IUserArgSelect,
UserArg,
UserArgType,
} from "@/UI/Forms/FormFull/FormFullInterfaces";
import { ITest } from "@/Testing/TestInterfaces";
import { FileInfo } from "@/FileSystem/FileInfo";
import { TestCmdList } from "@/Testing/TestCmdList";
import { filesToFileInfos } from "@/FileSystem/FileUtils";
import { appName } from "@/Core/GlobalVars";
import { ResponseType, fetcher } from "@/Core/Fetcher";
import { Tag } from "@/Plugins/Core/ActivityFocus/ActivityFocusUtils";
/**
* ExampleDataPlugin
*/
@Options({
components: {
PluginComponent,
FormFile,
},
})
export default class ExampleDataPlugin extends PluginParentClass {
menuPath = "Help/[6] Example Data/[6] Example Data...";
title = "Append Example Data";
softwareCredits: ISoftwareCredit[] = [];
contributorCredits: IContributorCredit[] = [];
filesToLoad: FileInfo[] = [];
pluginId = "openexampleproject";
tags = [Tag.All];
exampleDescriptions: { [key: string]: string } = {
"1INW_just_prot_lig.molmoda":
"Influenza neuraminidase bound to a sialic-acid analog (PDB: 1INW). All molecular components except the protein and analog have been removed.",
"1INW_pocket.molmoda":
"Influenza neuraminidase bound to a sialic-acid analog, with the binding pocket identified using Proteins → Detect Pockets...",
"1INW_pocket_prot_protonated.molmoda":
"Influenza neuraminidase bound to a sialic-acid analog, with the protein protonated at pH 7 using Proteins → Protonation...",
"1INW_pocket_prot_protonated_pubchem_ligs.molmoda":
"Protonated influenza neuraminidase bound to a sialic-acid analog, with additional neuraminidase ligands imported via File → PubChem...",
"1INW_pocket_prot_protonated_ligs_protonated.molmoda":
"Protonated influenza neuraminidase, with known ligands protonated at pH 7 using Compounds → Protonation... (Use this example data to test docking.)",
"1INW_pocket_prot_protonated_ligs_protonated_docked.molmoda":
"Protonated influenza neuraminidase, with known ligands docked into the neuraminidase pocket using Docking → Compound Docking...",
"TGFR1_docked.molmoda": `Virtual screen targeting TGFβ Type I Receptor Kinase, described in the ${appName} publication. (Use this example data to calculate ROC and EF curves.)`,
"LARP1_leadopt.molmoda": `m7G and analogs bound to LARP1 DM15. Shows how ${appName} can assist in lead optimization, as described in the ${appName} publication.`,
};
userArgDefaults: UserArg[] = [
{
id: "which_example_data",
type: UserArgType.Select,
label: "Example data to append",
options: [
{
description: "1INW protein/ligand complex",
val: "1INW_just_prot_lig.molmoda",
},
{
description: "1INW, binding pocket identified",
val: "1INW_pocket.molmoda",
},
{
description: "1INW, pocket, protein protonated",
val: "1INW_pocket_prot_protonated.molmoda",
},
{
description:
"1INW, pocket, protein protonated, PubChem ligands",
val: "1INW_pocket_prot_protonated_pubchem_ligs.molmoda",
},
{
description: "1INW, pocket, protein and ligands protonated",
val: "1INW_pocket_prot_protonated_ligs_protonated.molmoda",
},
{
description:
"1INW, pocket, protein and ligands protonated, docked",
val: "1INW_pocket_prot_protonated_ligs_protonated_docked.molmoda",
},
{
description: `TGFR1 virtual screen (from ${appName} publication)`,
val: "TGFR1_docked.molmoda",
},
{
description: `LARP1 lead optimization (from ${appName} publication)`,
val: "LARP1_leadopt.molmoda",
},
],
val: "1INW_just_prot_lig.molmoda",
} as IUserArgSelect,
{
id: "descript",
type: UserArgType.Alert,
val: this.exampleDescriptions["1INW_just_prot_lig.molmoda"],
alertType: "info",
} as IUserArgAlert,
];
intro = `Append example data to the current project.`;
details = `This plugin provides example data for exploring and testing the ${appName} interface.`;
/**
* Detects when user arguments have changed, and updates UI accordingly.
*/
onUserArgChange() {
let whichExample = this.getUserArg("which_example_data") as string;
this.setUserArg("descript", this.exampleDescriptions[whichExample]);
console.log(this.exampleDescriptions[whichExample]);
// // this.setUserArgEnabled("molMergingGroup", !useMolModa);
// this.setUserArgEnabled("whichMolsGroup", !useMolModa);
// this.setUserArgEnabled("separateCompounds", !useMolModa);
// // Show onemol format or protein format, depending on whether
// // mergeAllMolecules is true.
// let separateCompounds = this.getUserArg("separateCompounds") as boolean;
// this.setUserArgEnabled(
// "oneMolFileFormat",
// !separateCompounds && !useMolModa
// );
// this.setUserArgEnabled(
// "nonCompoundFormat",
// separateCompounds && !useMolModa
// );
// // If separating out compounds, show compound format.
// this.setUserArgEnabled(
// "compoundFormat",
// separateCompounds && !useMolModa
// );
}
/**
* Runs when the user presses the action button and the popup closes.
*/
onPopupDone() {
this.closePopup();
this.submitJobs();
}
/**
* Every plugin runs some job. This is the function that does the job running.
*/
async runJobInBrowser(): Promise<void> {
// Load the example project
// Fetch the file "./example.molmoda" file using fetch. It is a binary
// file.
const path = this.getUserArg("which_example_data");
const data = await fetcher(path, {
responseType: ResponseType.ARRAY_BUFFER,
});
// Convert to blob
const blob = new Blob([data], {
type: "application/octet-stream",
}); // You can adjust the type if needed.
// Convert to a file
const file = new File([blob], "example.molmoda");
// Convert file to fileInfo
return filesToFileInfos([file], false, ["MOLMODA"]).then(
(fileInfos: (FileInfo | string)[] | undefined) => {
if (fileInfos === undefined) return;
this.addFileInfoToViewer({
fileInfo: fileInfos[0] as FileInfo,
tag: this.pluginId,
});
return;
}
);
}
/**
* Gets the test commands for the plugin. For advanced use.
*
* @gooddefault
* @document
* @returns {ITest[]} The selenium test commandss.
*/
async getTests(): Promise<ITest[]> {
return [
// First test without saving first
{
pluginOpen: () => new TestCmdList().setUserArg("which_example_data", "1INW_pocket.molmoda", this.pluginId),
afterPluginCloses: () => new TestCmdList().waitUntilRegex(
"#navigator",
"Pockets:1INW"
),
},
];
}
}
</script>
<style scoped lang="scss">
.inverse-indent {
text-indent: -1em;
padding-left: 1em;
}
</style>
|