Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGVF-2342-calc-mux-samp-class #1315

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/igvfd/mappings/multiplexed_sample.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"hash": "21e8f10a20a106a41987067591c7a652",
"index_name": "multiplexed_sample_21e8f10a",
"hash": "a93dd9b7b3a5f012161d0fb62b9269bb",
"index_name": "multiplexed_sample_a93dd9b7",
"item_type": "multiplexed_sample",
"mapping": {
"dynamic_templates": [
Expand Down
3 changes: 2 additions & 1 deletion src/igvfd/tests/test_types_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ def test_classifications(testapp, primary_cell, technical_sample, whole_organism
assert res.json.get('classifications') == ['tissue']
res = testapp.get(in_vitro_cell_line['@id'])
assert res.json.get('classifications') == ['cell line']
# This fixutre has one cell line and one tissue
res = testapp.get(multiplexed_sample['@id'])
assert res.json.get('classifications') == ['multiplexed sample']
assert res.json.get('classifications') == ['cell line', 'tissue', 'multiplexed sample']


def test_sorted_fractions(testapp, primary_cell, tissue, in_vitro_cell_line):
Expand Down
17 changes: 13 additions & 4 deletions src/igvfd/types/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@
)


def collect_multiplexed_samples_prop(request, multiplexed_samples, property_name):
def collect_multiplexed_samples_prop(request, multiplexed_samples, property_name, skip_calculated=True):
property_set = set()
for sample in multiplexed_samples:
sample_props = request.embed(sample, '@@object?skip_calculated=true')
# If to get a specific calculated property
if skip_calculated is False:
sample_props = request.embed(sample, f'@@object_with_select_calculated_properties?field={property_name}')
# If to get non-calculated properties
else:
sample_props = request.embed(sample, '@@object?skip_calculated=true')
property_contents = sample_props.get(property_name, None)
if property_contents:
if type(property_contents) == list:
Expand Down Expand Up @@ -1059,5 +1064,9 @@ def institutional_certificates(self, request, multiplexed_samples):
'notSubmittable': True,
}
)
def classifications(self):
return [self.item_type.replace('_', ' ')]
def classifications(self, request, multiplexed_samples):
# Get unique properties of individual samples' item types
sample_classfications = collect_multiplexed_samples_prop(
request, multiplexed_samples, 'classifications', skip_calculated=False)
self_classification = [self.item_type.replace('_', ' ')]
return sample_classfications + self_classification