From 84931541984119635f492d220baf1c2f76d4d9db Mon Sep 17 00:00:00 2001
From: Remi  PLANEL <rplanel@pasteur.fr>
Date: Wed, 13 Dec 2023 16:04:21 +0100
Subject: [PATCH] add pvc for structure data

---
 components/content/MolstarPdbePlugin.vue      | 24 +++++++++++++++----
 components/content/StructureDb.vue            |  7 +++++-
 deploy/df-wiki/templates/deployment.yaml      |  6 ++++-
 deploy/df-wiki/templates/pvc-structure.yaml   | 12 ++++++++++
 .../df-wiki-cli/df_wiki_cli/content/main.py   |  2 +-
 5 files changed, 43 insertions(+), 8 deletions(-)
 create mode 100644 deploy/df-wiki/templates/pvc-structure.yaml

diff --git a/components/content/MolstarPdbePlugin.vue b/components/content/MolstarPdbePlugin.vue
index 2cc1e5ca..731bccde 100644
--- a/components/content/MolstarPdbePlugin.vue
+++ b/components/content/MolstarPdbePlugin.vue
@@ -104,9 +104,20 @@ const selectedPaePath = computed(() => {
 const paeData = ref([])
 watch(selectedPaePath, async (newPaePath) => {
     if (newPaePath !== null) {
-        const data = await d3.tsv(newPaePath);
-        // console.log(data)
-        paeData.value = data
+        try {
+            const data = await d3.tsv(newPaePath);
+            console.log(data.length)
+            if (data.length > 500) {
+                paeData.value = []
+            }
+            else {
+                paeData.value = data
+            }
+
+        }
+        catch (error) {
+            console.log(error)
+        }
     } else {
         paeData.value = []
     }
@@ -116,9 +127,11 @@ watch(selectedPaePath, async (newPaePath) => {
 const sanitizedPaeData = computed(() => {
     return paeData.value.reduce((acc, curr, index) => {
         const scoredResidue = index
+        // let newAcc = [...acc]
         for (const [alignedResidue, value] of Object.entries(curr)) {
             // console.log(value)
             acc.push({ alignedResidue: parseInt(alignedResidue), scoredResidue: parseInt(scoredResidue), value: parseFloat(value) })
+            // newAcc = [...newAcc, ...[{ alignedResidue: parseInt(alignedResidue), scoredResidue: parseInt(scoredResidue), value: parseFloat(value) }]]
         }
 
         return acc
@@ -188,8 +201,9 @@ watch(selectedPdb, (selectedPdb, prevSelectPdb) => {
                                     custom-data-format="cif"></pdbe-molstar>
                             </v-sheet>
                         </v-col>
-                        <v-col v-if="sanitizedPaeData?.length > 0">
-                            <PlotFigure defer :options="plotPaeOptions"></PlotFigure>
+                        <v-col >
+                            <PlotFigure v-if="sanitizedPaeData?.length > 0" defer :options="plotPaeOptions"></PlotFigure>
+                            <v-alert type="warning">The PAE is to large</v-alert>
                             <v-card flat color="transparent">
 
                                 <v-card-title>Model Confidence</v-card-title>
diff --git a/components/content/StructureDb.vue b/components/content/StructureDb.vue
index 4757a267..bf0ba15a 100644
--- a/components/content/StructureDb.vue
+++ b/components/content/StructureDb.vue
@@ -43,6 +43,11 @@ function pdbNameToCif(pdbPath: string) {
     return `${cifPath}.cif`
 }
 
+
+function toSystemName(rawName: string) {
+    return rawName.split(/_|-0/)[0].toLocaleLowerCase()
+
+}
 </script>
 <template>
     <ServerDbTable title="Predicted Structures" db="structure" :sortBy="sortBy" :facets="facets"
@@ -58,7 +63,7 @@ function pdbNameToCif(pdbPath: string) {
                 <td :colspan="columns.length">
                     <v-card flat color="transparent">
                         <v-card-text>
-                            <MolstarPdbePlugin :data-urls="[`/${item.system.toLowerCase()}/${pdbNameToCif(item.pdb)}`]">
+                            <MolstarPdbePlugin :data-urls="[`/${toSystemName(item.system)}/${pdbNameToCif(item.pdb)}`]">
                             </MolstarPdbePlugin>
                         </v-card-text>
                     </v-card>
diff --git a/deploy/df-wiki/templates/deployment.yaml b/deploy/df-wiki/templates/deployment.yaml
index 6ac7bd19..10e0c872 100644
--- a/deploy/df-wiki/templates/deployment.yaml
+++ b/deploy/df-wiki/templates/deployment.yaml
@@ -54,6 +54,8 @@ spec:
             name: tmp
           - name: nginx-config
             mountPath: /etc/nginx/conf.d/
+          - name: structure-data-pvc
+            mountPath: /structure-data
 
 
       {{- with .Values.nodeSelector }}
@@ -74,4 +76,6 @@ spec:
       - name: nginx-config
         configMap:
           name: nginx-config
-
+      - name: structure-data-pvc
+        persistentVolumeClaim:
+            claimName: structure-data-pvc
diff --git a/deploy/df-wiki/templates/pvc-structure.yaml b/deploy/df-wiki/templates/pvc-structure.yaml
new file mode 100644
index 00000000..ec9612a0
--- /dev/null
+++ b/deploy/df-wiki/templates/pvc-structure.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: structure-data-pvc
+spec:
+  accessModes:
+  - ReadWriteMany
+  resources:
+    requests:
+      storage: 40Gi
+  storageClassName: isilon
+  volumeMode: Filesystem
\ No newline at end of file
diff --git a/packages/df-wiki-cli/df_wiki_cli/content/main.py b/packages/df-wiki-cli/df_wiki_cli/content/main.py
index d01337bc..32333d16 100644
--- a/packages/df-wiki-cli/df_wiki_cli/content/main.py
+++ b/packages/df-wiki-cli/df_wiki_cli/content/main.py
@@ -105,7 +105,7 @@ def structure(
     for f in dir.iterdir():
         console.print(f"[green] {f.name}")
         # get the system name
-        system = re.split("_|\.", f.name)[0].lower()
+        system = re.split("_|\.|-0", f.name)[0].lower()
 
         console.print(system)
         systemDir = output / system
-- 
GitLab