| <template> |
| <span v-if="countsTableData !== null" > |
| <Table :tableData="lipinskiTableData" caption="Lipinski Properties" downloadFilenameBase="lipinski-properties" /> |
| <Table :tableData="otherTableData" caption="Other Properties" downloadFilenameBase="other-properties" /> |
| <Table :tableData="countsTableData" caption="Counts" downloadFilenameBase="counts" /> |
| </span> |
| </template> |
|
|
| <script lang="ts"> |
| import { |
| calcMolProps, |
| ICalcMolProps, |
| } from "@/Plugins/Optional/MolProps/CalcMolProps"; |
| import { TreeNode } from "@/TreeNodes/TreeNode/TreeNode"; |
| import { Options, Vue } from "vue-class-component"; |
| import { Prop, Watch } from "vue-property-decorator"; |
| import Table from "./Table/Table.vue"; |
| import { ITableData } from "./Table/Types"; |
| |
| const alreadyCalculatedLipinski: {[key: string]: any} = {} |
| const alreadyCalculatedCounts: {[key: string]: any} = {} |
| const alreadyCalculatedOther: {[key: string]: any} = {} |
| |
| |
| |
| |
| @Options({ |
| components: { |
| Table, |
| }, |
| }) |
| export default class MolProps extends Vue { |
| @Prop({ default: "" }) smiles!: string; |
| @Prop({ default: undefined }) treeNode!: TreeNode | undefined; |
| |
| lipinskiTableData: ITableData | null = null; |
| countsTableData: ITableData | null = null; |
| otherTableData: ITableData | null = null; |
| |
| props = ""; |
| |
| |
| |
| |
| |
| @Watch("smiles") |
| onSmiles() { |
| |
| |
| |
| |
| |
| |
| |
| if (alreadyCalculatedLipinski[this.smiles]) { |
| this.lipinskiTableData = this.convertDescriptorsToTableData( |
| alreadyCalculatedLipinski[this.smiles] |
| ); |
| this.countsTableData = this.convertDescriptorsToTableData( |
| alreadyCalculatedCounts[this.smiles] |
| ); |
| this.otherTableData = this.convertDescriptorsToTableData( |
| alreadyCalculatedOther[this.smiles] |
| ); |
| |
| return; |
| } |
| |
| calcMolProps([this.smiles], [this.treeNode]) |
| .then((resps: ICalcMolProps[]) => { |
| |
| const resp = resps[0]; |
| this.lipinskiTableData = this.convertDescriptorsToTableData( |
| resp.lipinski |
| ); |
| alreadyCalculatedLipinski[this.smiles] = resp.lipinski; |
| |
| this.countsTableData = this.convertDescriptorsToTableData( |
| resp.counts |
| ); |
| alreadyCalculatedCounts[this.smiles] = resp.counts; |
| |
| this.otherTableData = this.convertDescriptorsToTableData( |
| resp.other |
| ); |
| alreadyCalculatedOther[this.smiles] = resp.other; |
| |
| return; |
| }) |
| .catch((err: Error) => { |
| throw err; |
| }); |
| } |
| |
| |
| |
| |
| |
| |
| |
| convertDescriptorsToTableData( |
| descriptors: [string, number, string][] |
| ): ITableData | null { |
| if (!descriptors.map) { |
| return null; |
| } |
| |
| if (descriptors.length === 0) { |
| return null; |
| } |
| |
| const headers = descriptors.map((d: any[]) => { |
| return { text: d[0], note: d[2] }; |
| }); |
| const row: { [key: string]: any } = {}; |
| for (let descriptor of descriptors) { |
| row[descriptor[0] as string] = descriptor[1]; |
| } |
| |
| return { headers: headers, rows: [row] }; |
| } |
| |
| |
| |
| |
| mounted() { |
| this.onSmiles(); |
| } |
| } |
| </script> |
|
|
| |
| <style scoped lang="scss"></style> |
|
|