From b6049948853d5e0da47e295c367025908c4a7623 Mon Sep 17 00:00:00 2001 From: Remi PLANEL <rplanel@pasteur.fr> Date: Thu, 25 Apr 2024 18:03:16 +0200 Subject: [PATCH] handle case when seperator in gene_name is _ instead of __ --- components/content/ArticleStructure.vue | 14 ++++++++-- components/content/PdockqMatrix.vue | 28 +++++++++++++------- components/content/StructureDb.vue | 13 +++++++-- components/content/SystemOperonStructure.vue | 20 +++++++++----- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/components/content/ArticleStructure.vue b/components/content/ArticleStructure.vue index 814b1da0..85e97f86 100644 --- a/components/content/ArticleStructure.vue +++ b/components/content/ArticleStructure.vue @@ -45,11 +45,21 @@ onMounted(() => { fetchStructures() }) +function extractGeneName(name: string) { + if (name.includes("__")) { + return name.split("__")[1] + } + if (name.includes("_")) { + return name.split("_")[1] + } + return undefined +} + function namesToCollapsibleChips(names: string[], systemDir: string, file: string | null = null) { if (file === null) { - return names.filter((it) => it !== "").map(it => ({ title: it.split("__")[1] })) + return names.filter((it) => it !== "").map(it => ({ title: extractGeneName(it) })) } else { - return names.filter((it) => it !== "").map(it => ({ title: it.split("__")[1], href: `/wiki/${systemDir}/${file}` })) + return names.filter((it) => it !== "").map(it => ({ title: extractGeneName(it), href: `/wiki/${systemDir}/${file}` })) } } function pdbNameToCif(pdbPath: string) { diff --git a/components/content/PdockqMatrix.vue b/components/content/PdockqMatrix.vue index f39b4ffc..aa22e4f0 100644 --- a/components/content/PdockqMatrix.vue +++ b/components/content/PdockqMatrix.vue @@ -65,22 +65,30 @@ const computedSystem = computed(() => { return toValPage?.system ?? toValPage?.title ?? undefined }) - +function extractGeneName(name: string) { + if (name.includes("__")) { + return name.split("__")[1] + } + if (name.includes("_")) { + return name.split("_")[1] + } + return undefined +} const groupedPdocks = computed(() => { const toValData = toValue(data) - const getSeqName = (d) => { - if (d.includes("__")) { - return d.split("__")[1] - } else { - return d - } - } + // const getSeqName = (d) => { + // if (d.includes("__")) { + // return d.split("__")[1] + // } else { + // return d + // } + // } if (toValData?.hits) { return d3.groups(toValData.hits.flatMap(({ system, pDockQ, pdb, nb_sys, proteins_in_the_prediction, system_genes }) => { if (proteins_in_the_prediction.length === 2) { - const sanitizedSystemGenes = system_genes.map(getSeqName) - const sanitizedProteins = proteins_in_the_prediction.map(getSeqName) + const sanitizedSystemGenes = system_genes.map(extractGeneName) + const sanitizedProteins = proteins_in_the_prediction.map(extractGeneName) const setProteins = new Set(sanitizedProteins) const key = system_genes.sort().join(" / ") if (setProteins.size === 2) { diff --git a/components/content/StructureDb.vue b/components/content/StructureDb.vue index 5af72db9..417a7e70 100644 --- a/components/content/StructureDb.vue +++ b/components/content/StructureDb.vue @@ -137,12 +137,21 @@ function toFolseekUrl(item: Item) { return toValue(refinedUrl) } +function extractGeneName(name: string) { + if (name.includes("__")) { + return name.split("__")[1] + } + if (name.includes("_")) { + return name.split("_")[1] + } + return undefined +} function namesToCollapsibleChips(names: string[], systemDir: string, file: string | null = null) { if (file === null) { - return names.filter((it) => it !== "").map(it => ({ title: it.split("__")[1] })) + return names.filter((it) => it !== "").map(it => ({ title: extractGeneName(it) })) } else { - return names.filter((it) => it !== "").map(it => ({ title: it.split("__")[1], href: `/wiki/${systemDir}/${file}` })) + return names.filter((it) => it !== "").map(it => ({ title: extractGeneName(it), href: `/wiki/${systemDir}/${file}` })) } } diff --git a/components/content/SystemOperonStructure.vue b/components/content/SystemOperonStructure.vue index 379be425..1a149736 100644 --- a/components/content/SystemOperonStructure.vue +++ b/components/content/SystemOperonStructure.vue @@ -34,29 +34,37 @@ const monomerStructures = computed(() => { structImg: `${struct.pdb.split(".pdb")[0]}.png`, structPath: struct.pdb, proteins_in_the_prediction: struct.proteins_in_the_prediction.map(prot => { - return prot.split("__")[1] + return extractGeneName(prot) }) } }) } }) + +function extractGeneName(name: string) { + if (name.includes("__")) { + return name.split("__")[1] + } + if (name.includes("_")) { + return name.split("_")[1] + } + return undefined +} + const sanitizedHits = computed<StructureOperonGeneWithImg[]>(() => { const toValMsResponse = toValue(msResponse) if (toValMsResponse && toValMsResponse?.hits?.length > 0) { return toValMsResponse.hits.map(hit => { // get structure information for this prot const monomerStructuresVal = toValue(monomerStructures) - const sanitizedGene = hit.gene.split("__")[1] - const sanitizedExangeableGenes = hit.exchangeables.map(g => g.split("__")[1]) + const sanitizedGene = extractGeneName(hit.gene) + const sanitizedExangeableGenes = hit.exchangeables.map(extractGeneName) const genesAndSynonymous = new Set([sanitizedGene, ...sanitizedExangeableGenes]) if (monomerStructuresVal) { const struct = monomerStructuresVal.find((struct) => { return genesAndSynonymous.has(struct.proteins_in_the_prediction[0]) }) - if (struct === undefined) { - console.log(hit) - } const rawImgUrl = joinURL(`/${system.toLowerCase()}`, struct?.structImg ?? '') const rawStructUrl = joinURL(`/${system.toLowerCase()}`, struct?.structPath ?? '') const { refinedUrl: structImgHref } = useRefinedUrl(rawImgUrl) -- GitLab