From af9277d73242f7c360d00eb6f06370d6eb4216eb Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Thu, 16 Nov 2023 15:51:44 +0000 Subject: [PATCH 1/8] column rename symbol to disease --- .../AssociationsToolkit/utils/downloads.js | 68 ++++++++----------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/utils/downloads.js b/apps/platform/src/components/AssociationsToolkit/utils/downloads.js index 1e3009d01..347659b32 100644 --- a/apps/platform/src/components/AssociationsToolkit/utils/downloads.js +++ b/apps/platform/src/components/AssociationsToolkit/utils/downloads.js @@ -1,14 +1,14 @@ -import _ from 'lodash'; +import _ from "lodash"; const targetName = { - id: 'symbol', - label: 'Symbol', + id: "symbol", + label: "Symbol", exportValue: data => data.target.approvedSymbol, }; const diseaseName = { - id: 'symbol', - label: 'Symbol', + id: "disease", + label: "Disease", exportValue: data => data.disease.name, }; @@ -17,15 +17,13 @@ const asJSON = (columns, rows) => { columns.reduce((accumulator, newKey) => { if (newKey.exportValue === false) return accumulator; - const newLabel = _.camelCase( - newKey.exportLabel || newKey.label || newKey.id - ); + const newLabel = _.camelCase(newKey.exportLabel || newKey.label || newKey.id); return { ...accumulator, [newLabel]: newKey.exportValue ? newKey.exportValue(row) - : _.get(row, newKey.propertyPath || newKey.id, ''), + : _.get(row, newKey.propertyPath || newKey.id, ""), }; }, {}) ); @@ -38,25 +36,23 @@ const getHeaderString = ({ columns, quoteString, separator }) => .reduce((headerString, column) => { if (column.exportValue === false) return headerString; - const newLabel = quoteString( - _.camelCase(column.exportLabel || column.label || column.id) - ); + const newLabel = quoteString(_.camelCase(column.exportLabel || column.label || column.id)); return [...headerString, newLabel]; }, []) .join(separator); -const asDSV = (columns, rows, separator = ',', quoteStrings = true) => { +const asDSV = (columns, rows, separator = ",", quoteStrings = true) => { const quoteString = d => { let result = d; // converts arrays to strings if (Array.isArray(d)) { - result = d.join(','); + result = d.join(","); } - return quoteStrings && typeof result === 'string' ? `"${result}"` : result; + return quoteStrings && typeof result === "string" ? `"${result}"` : result; }; - const lineSeparator = '\n'; + const lineSeparator = "\n"; const headerString = getHeaderString({ columns, quoteString, separator }); @@ -69,7 +65,7 @@ const asDSV = (columns, rows, separator = ',', quoteStrings = true) => { const newValue = quoteString( column.exportValue ? column.exportValue(row) - : _.get(row, column.propertyPath || column.id, '') + : _.get(row, column.propertyPath || column.id, "") ); return [...rowString, newValue]; @@ -82,12 +78,10 @@ const asDSV = (columns, rows, separator = ',', quoteStrings = true) => { }; export const getRowsQuerySelector = entityToGet => - entityToGet === 'target' - ? 'data.disease.associatedTargets' - : 'data.target.associatedDiseases'; + entityToGet === "target" ? "data.disease.associatedTargets" : "data.target.associatedDiseases"; export const getExportedColumns = (entityToGet, assocArr, prioArr) => { - const nameColumn = entityToGet === 'target' ? targetName : diseaseName; + const nameColumn = entityToGet === "target" ? targetName : diseaseName; let exportedColumns = []; const sources = assocArr.map(({ id }) => ({ id, @@ -95,22 +89,20 @@ export const getExportedColumns = (entityToGet, assocArr, prioArr) => { const datatypeScore = data.datasourceScores.find( datasourceScore => datasourceScore.componentId === id ); - return datatypeScore ? parseFloat(datatypeScore.score) : 'No data'; + return datatypeScore ? parseFloat(datatypeScore.score) : "No data"; }, })); exportedColumns = [...sources]; - if (entityToGet === 'target') { + if (entityToGet === "target") { const prioritisationExportCols = prioArr.map(({ id }) => ({ id, exportValue: data => { const prioritisationScore = data.target.prioritisation.items.find( prioritisationItem => prioritisationItem.key === id ); - return prioritisationScore - ? parseFloat(prioritisationScore.value) - : 'No data'; + return prioritisationScore ? parseFloat(prioritisationScore.value) : "No data"; }, })); @@ -120,8 +112,8 @@ export const getExportedColumns = (entityToGet, assocArr, prioArr) => { return [ nameColumn, { - id: 'score', - label: 'Score', + id: "globalScore", + label: "Global Score", exportValue: data => data.score, }, ...exportedColumns, @@ -137,9 +129,7 @@ export const getExportedPrioritisationColumns = arr => { const prioritisationScore = data.target.prioritisation.items.find( prioritisationItem => prioritisationItem.key === id ); - return prioritisationScore - ? parseFloat(prioritisationScore.value) - : 'No data'; + return prioritisationScore ? parseFloat(prioritisationScore.value) : "No data"; }, })); @@ -148,8 +138,8 @@ export const getExportedPrioritisationColumns = arr => { return [ targetName, { - id: 'score', - label: 'Score', + id: "score", + label: "Score", exportValue: data => data.score, }, ...exportedColumns, @@ -160,22 +150,20 @@ export const createBlob = format => ({ json: (columns, rows) => new Blob([asJSON(columns, rows)], { - type: 'application/json;charset=utf-8', + type: "application/json;charset=utf-8", }), csv: (columns, rows) => new Blob([asDSV(columns, rows)], { - type: 'text/csv;charset=utf-8', + type: "text/csv;charset=utf-8", }), tsv: (columns, rows) => - new Blob([asDSV(columns, rows, '\t', false)], { - type: 'text/tab-separated-values;charset=utf-8', + new Blob([asDSV(columns, rows, "\t", false)], { + type: "text/tab-separated-values;charset=utf-8", }), }[format]); export const getFilteredColumnArray = (selectArray, requestArray) => { - const arr = selectArray - .map(ag => requestArray.filter(e => e.aggregation === ag)) - .flat(1); + const arr = selectArray.map(ag => requestArray.filter(e => e.aggregation === ag)).flat(1); return arr.length > 0 ? arr : []; }; From 21d3a9a00af67cc911fed63f0065fd044d0b383d Mon Sep 17 00:00:00 2001 From: Chintan Mehta Date: Thu, 16 Nov 2023 15:55:08 +0000 Subject: [PATCH 2/8] prioritisation typo fix --- .../src/components/AssociationsToolkit/DataDownloader.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx index 132aa65bc..97ace52d5 100644 --- a/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx +++ b/apps/platform/src/components/AssociationsToolkit/DataDownloader.jsx @@ -348,14 +348,14 @@ function DataDownloader({ fileStem }) { {entity === "disease" && ( - Prioritization Aggregation + Prioritisation Aggregation selected.join(", ")} onChange={e => { dispatch( @@ -354,14 +354,14 @@ function DataDownloader({ fileStem }) { {entity === "disease" && ( - Prioritisation Aggregation + Select prioritisation data type