From a77926e9cfc9c859a4a55037257e7f6b00107ff3 Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Fri, 27 Aug 2021 12:19:34 -0700 Subject: [PATCH 01/10] ENCD-6126--add-element-ref-to-file-details --- src/encoded/static/components/filegallery.js | 7 +++++++ src/encoded/types/dataset.py | 1 + .../types/functional_characterization_experiment.py | 1 + 3 files changed, 9 insertions(+) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index 6167526e5a4..631ea8fb3b7 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -463,6 +463,13 @@ export class FileTable extends React.Component { return analysisObjectsAccession || nonAnalysisObjectPrefix; }); + const elementsReferences = context.elements_references; + + if (elementsReferences) { + const elementsReferenceFiles = elementsReferences.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []); + files.ref?.concat(elementsReferenceFiles); + } + // Get unique analyses for series object const analysesSeries = files.series ? [...new Set(files.series.map((a) => (a.analyses && a.analyses.length > 0 ? a.analyses[0] : '')).filter((a) => a !== ''))] : []; diff --git a/src/encoded/types/dataset.py b/src/encoded/types/dataset.py index 8c8b3bde388..624f043399e 100644 --- a/src/encoded/types/dataset.py +++ b/src/encoded/types/dataset.py @@ -1370,6 +1370,7 @@ class FunctionalCharacterizationSeries(Series): 'related_datasets.elements_references.examined_loci', 'elements_references', 'elements_references.examined_loci', + 'elements_references.files', ] @calculated_property(condition='related_datasets', schema={ diff --git a/src/encoded/types/functional_characterization_experiment.py b/src/encoded/types/functional_characterization_experiment.py index aeacb221c07..0c5d6754c65 100644 --- a/src/encoded/types/functional_characterization_experiment.py +++ b/src/encoded/types/functional_characterization_experiment.py @@ -54,6 +54,7 @@ class FunctionalCharacterizationExperiment( 'biosample_ontology', 'examined_loci', 'examined_loci.gene', + 'elements_references.files', 'elements_references.examined_loci', 'elements_references.examined_regions', 'files.platform', From 433784f4feed3c951f3c7a81c1886c8d4f87e7bb Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 10:13:42 -0700 Subject: [PATCH 02/10] fix issue with file.ref not being defined --- src/encoded/static/components/filegallery.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index 631ea8fb3b7..f4fca0dd53d 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -467,6 +467,11 @@ export class FileTable extends React.Component { if (elementsReferences) { const elementsReferenceFiles = elementsReferences.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []); + + if (!files.ref) { + files.ref = []; + } + files.ref?.concat(elementsReferenceFiles); } From 1cd0f4b48e8568012ade18c650d4fb84a2bdfe28 Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 10:26:27 -0700 Subject: [PATCH 03/10] fixed ref --- src/encoded/static/components/filegallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index f4fca0dd53d..fb6c8abccd3 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -472,7 +472,7 @@ export class FileTable extends React.Component { files.ref = []; } - files.ref?.concat(elementsReferenceFiles); + files.ref.concat(elementsReferenceFiles); } // Get unique analyses for series object From 149381af0431f8883b45658cb30c76d16f5b833c Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 10:46:51 -0700 Subject: [PATCH 04/10] t --- src/encoded/static/components/filegallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index fb6c8abccd3..05c300b9865 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -472,7 +472,7 @@ export class FileTable extends React.Component { files.ref = []; } - files.ref.concat(elementsReferenceFiles); + files.ref.push(...elementsReferenceFiles); } // Get unique analyses for series object From 5120ce9ee359a3221e5bb723d43c55330343ec66 Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 11:43:05 -0700 Subject: [PATCH 05/10] t --- src/encoded/static/components/objectutils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoded/static/components/objectutils.js b/src/encoded/static/components/objectutils.js index 6139b27e910..5c94934c553 100644 --- a/src/encoded/static/components/objectutils.js +++ b/src/encoded/static/components/objectutils.js @@ -384,7 +384,7 @@ export const RestrictedDownloadButton = (props) => {
{buttonEnabled ? - + {downloadComponent} From 24631fbd4638f97dd5ecee840f1904d173d5f961 Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 11:59:33 -0700 Subject: [PATCH 06/10] removed check for empty file.href --- src/encoded/static/components/objectutils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoded/static/components/objectutils.js b/src/encoded/static/components/objectutils.js index 5c94934c553..6139b27e910 100644 --- a/src/encoded/static/components/objectutils.js +++ b/src/encoded/static/components/objectutils.js @@ -384,7 +384,7 @@ export const RestrictedDownloadButton = (props) => {
{buttonEnabled ? - + {downloadComponent} From cf51ecf00acf5f22c898fd9fd248a6c32ffa8594 Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 12:30:12 -0700 Subject: [PATCH 07/10] t --- src/encoded/static/components/filegallery.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index 05c300b9865..b2ebd45b9bc 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -2987,7 +2987,9 @@ class FileGalleryRendererComponent extends React.Component { this.experimentType = props.context['@type'][0]; const seriesFiles = getSeriesFiles(props.context) || []; - const datasetFiles = [...props.data, ...seriesFiles]; + const elementsReferenceFiles = context.elements_references?.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []) || []; + + const datasetFiles = [...props.data, ...seriesFiles, ...elementsReferenceFiles]; // Initialize React state variables. this.state = { From d979f414880dc49c7908c9f7f602210c260898ec Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 18:51:12 -0700 Subject: [PATCH 08/10] fixed elementReference error --- src/encoded/static/components/filegallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index b2ebd45b9bc..044ceb051ce 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -2987,7 +2987,7 @@ class FileGalleryRendererComponent extends React.Component { this.experimentType = props.context['@type'][0]; const seriesFiles = getSeriesFiles(props.context) || []; - const elementsReferenceFiles = context.elements_references?.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []) || []; + const elementsReferenceFiles = props.context?.elements_references?.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []) || []; const datasetFiles = [...props.data, ...seriesFiles, ...elementsReferenceFiles]; From 6dc1ef8b3c5609c8df862d8181952ae954e2e676 Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Mon, 30 Aug 2021 19:21:31 -0700 Subject: [PATCH 09/10] fixed context --- src/encoded/static/components/filegallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index 044ceb051ce..db7c06ce329 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -2987,7 +2987,7 @@ class FileGalleryRendererComponent extends React.Component { this.experimentType = props.context['@type'][0]; const seriesFiles = getSeriesFiles(props.context) || []; - const elementsReferenceFiles = props.context?.elements_references?.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []) || []; + const elementsReferenceFiles = props.context.elements_references?.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []) || []; const datasetFiles = [...props.data, ...seriesFiles, ...elementsReferenceFiles]; From 5d22b140c5a595d8af6c4b359569e86605dea5f1 Mon Sep 17 00:00:00 2001 From: Philip Adenekan Date: Thu, 2 Sep 2021 14:18:51 -0700 Subject: [PATCH 10/10] t --- src/encoded/static/components/filegallery.js | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/encoded/static/components/filegallery.js b/src/encoded/static/components/filegallery.js index db7c06ce329..a9fc762eb8d 100644 --- a/src/encoded/static/components/filegallery.js +++ b/src/encoded/static/components/filegallery.js @@ -302,6 +302,18 @@ const filterDownloadableFilesByStatus = (context, files) => { return []; }; +const getElementReferencesFiles = (elementsReferences) => { + let elementsReferenceFiles = []; + if (elementsReferences) { + elementsReferenceFiles = elementsReferences.map((elementsReference) => elementsReference.files) + .reduce((acc, val) => acc.concat(val), []) + .map((elementReferenceFile) => { + elementReferenceFile.isElementReferenceFile = true; + return elementReferenceFile; + }); + } + return elementsReferenceFiles; +}; export class FileTable extends React.Component { static rowClasses() { @@ -453,7 +465,7 @@ export class FileTable extends React.Component { } return 'rawArray'; } - if (file.output_category === 'reference') { + if (file.output_category === 'reference' || file.isElementReferenceFile) { return 'ref'; } @@ -463,18 +475,6 @@ export class FileTable extends React.Component { return analysisObjectsAccession || nonAnalysisObjectPrefix; }); - const elementsReferences = context.elements_references; - - if (elementsReferences) { - const elementsReferenceFiles = elementsReferences.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []); - - if (!files.ref) { - files.ref = []; - } - - files.ref.push(...elementsReferenceFiles); - } - // Get unique analyses for series object const analysesSeries = files.series ? [...new Set(files.series.map((a) => (a.analyses && a.analyses.length > 0 ? a.analyses[0] : '')).filter((a) => a !== ''))] : []; @@ -1482,14 +1482,16 @@ export const FileGallery = ({ }); React.useEffect(() => { + const elementsReferenceFiles = getElementReferencesFiles(context.elements_references); + if (files) { // Array of files provided, so set without a request to the server. - setData(files); + setData([...files, ...elementsReferenceFiles]); } else { // Request files from the server. const query = fileQuery || `limit=all&type=File&dataset=${context['@id']}`; requestSearch(query).then((requestedData) => { - setData(requestedData['@graph']); + setData([...requestedData['@graph'], ...elementsReferenceFiles]); }); } }, [fileQuery, files]); @@ -2987,9 +2989,7 @@ class FileGalleryRendererComponent extends React.Component { this.experimentType = props.context['@type'][0]; const seriesFiles = getSeriesFiles(props.context) || []; - const elementsReferenceFiles = props.context.elements_references?.map((elementsReference) => elementsReference.files).reduce((acc, val) => acc.concat(val), []) || []; - - const datasetFiles = [...props.data, ...seriesFiles, ...elementsReferenceFiles]; + const datasetFiles = [...props.data, ...seriesFiles]; // Initialize React state variables. this.state = {