From 83fc59b83c3f44fcb52884e3aba9e72da86acdab Mon Sep 17 00:00:00 2001 From: Ian Whaling <78115078+ian-whaling@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:50:41 -0700 Subject: [PATCH] IGVF-1074-matrix-content-summary (#561) --- src/igvfd/mappings/matrix_file.json | 4 ++-- .../tests/fixtures/schemas/matrix_file.py | 4 ++-- src/igvfd/tests/test_types_file.py | 21 +++++++++++++++---- src/igvfd/types/file.py | 10 +++------ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/igvfd/mappings/matrix_file.json b/src/igvfd/mappings/matrix_file.json index 8599eca098..dd21906860 100644 --- a/src/igvfd/mappings/matrix_file.json +++ b/src/igvfd/mappings/matrix_file.json @@ -1,6 +1,6 @@ { - "hash": "b767a0bcf0eef30b08783183aec26a58", - "index_name": "matrix_file_b767a0bc", + "hash": "a79f62652a66ba16923ef19aab86eb29", + "index_name": "matrix_file_a79f6265", "item_type": "matrix_file", "mapping": { "dynamic_templates": [ diff --git a/src/igvfd/tests/fixtures/schemas/matrix_file.py b/src/igvfd/tests/fixtures/schemas/matrix_file.py index e08998c7e4..cbe5004b58 100644 --- a/src/igvfd/tests/fixtures/schemas/matrix_file.py +++ b/src/igvfd/tests/fixtures/schemas/matrix_file.py @@ -6,11 +6,11 @@ def matrix_file(testapp, lab, award, analysis_set_with_sample, reference_file): item = { 'award': award['@id'], 'lab': lab['@id'], - 'md5sum': 'b64eed10-78b9-4674-95e5-dae39f35f132', + 'md5sum': '01b08bb5485ac730df19af55ba4bb01c', 'file_format': 'hdf5', 'file_set': analysis_set_with_sample['@id'], 'file_size': 8491803, - 'content_type': 'parse gene count matrix', + 'content_type': 'sparse gene count matrix', 'reference_files': [ reference_file['@id'] ], diff --git a/src/igvfd/tests/test_types_file.py b/src/igvfd/tests/test_types_file.py index 2cfd1e1849..880092fcd9 100644 --- a/src/igvfd/tests/test_types_file.py +++ b/src/igvfd/tests/test_types_file.py @@ -73,8 +73,7 @@ def test_types_file_s3_uri_non_submittable(testapp, analysis_set_with_sample, aw def test_types_aligment_file_content_summary(testapp, alignment_file): res = testapp.get(alignment_file['@id']) assert res.json.get('content_summary') == 'unfiltered alignments' - - res = testapp.patch_json( + testapp.patch_json( alignment_file['@id'], { 'redacted': True, @@ -88,8 +87,7 @@ def test_types_aligment_file_content_summary(testapp, alignment_file): def test_types_signal_file_content_summary(testapp, signal_file): res = testapp.get(signal_file['@id']) assert res.json.get('content_summary') == 'plus strand signal of all reads' - - res = testapp.patch_json( + testapp.patch_json( signal_file['@id'], { 'filtered': True, @@ -99,3 +97,18 @@ def test_types_signal_file_content_summary(testapp, signal_file): ) res = testapp.get(signal_file['@id']) assert res.json.get('content_summary') == 'filtered normalized unstranded signal of all reads' + + +def test_types_matrix_file_content_summary(testapp, matrix_file): + res = testapp.get(matrix_file['@id']) + assert res.json.get('content_summary') == 'cell by gene sparse gene count matrix' + testapp.patch_json( + matrix_file['@id'], + { + 'dimension1': 'variant', + 'dimension2': 'treatment', + 'content_type': 'transcriptome annotations' + } + ) + res = testapp.get(matrix_file['@id']) + assert res.json.get('content_summary') == 'variant by treatment transcriptome annotations' diff --git a/src/igvfd/types/file.py b/src/igvfd/types/file.py index 7b88e43ead..667512a307 100644 --- a/src/igvfd/types/file.py +++ b/src/igvfd/types/file.py @@ -62,6 +62,7 @@ 'hdf5': '.h5', 'idat': '.idat', 'PWM': '.pwm', + 'mtx': '.mtx', 'rcc': '.rcc', 'sra': '.sra', 'tagAlign': '.tagAlign.gz', @@ -331,13 +332,8 @@ def unique_keys(self, properties): 'notSubmittable': True } ) - def content_summary(self, request, content_type, file_format): - phrases = [ - file_format, - content_type - ] - non_empty_phrases = [x for x in phrases if x != ''] - return ' '.join(non_empty_phrases) + def content_summary(self, request, dimension1, dimension2, content_type): + return f'{dimension1} by {dimension2} {content_type}' @collection(