Skip to content

Commit

Permalink
IGVF-1074-matrix-content-summary (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-whaling authored Sep 19, 2023
1 parent bce34f9 commit 83fc59b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/igvfd/mappings/matrix_file.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
4 changes: 2 additions & 2 deletions src/igvfd/tests/fixtures/schemas/matrix_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
],
Expand Down
21 changes: 17 additions & 4 deletions src/igvfd/tests/test_types_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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'
10 changes: 3 additions & 7 deletions src/igvfd/types/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
'hdf5': '.h5',
'idat': '.idat',
'PWM': '.pwm',
'mtx': '.mtx',
'rcc': '.rcc',
'sra': '.sra',
'tagAlign': '.tagAlign.gz',
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 83fc59b

Please sign in to comment.