Skip to content

Commit

Permalink
Refactor multi_assay_category to is_component
Browse files Browse the repository at this point in the history
  • Loading branch information
lchoy committed Feb 22, 2024
1 parent 471ba9d commit 6b5ee01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,16 @@ def _is_component_dataset(doc):
def _add_multi_assay_fields(doc, assay_details):
if _is_component_dataset(doc):
doc['assay_modality'] = 'multiple'
doc['multi_assay_category'] = 'component'
doc['is_component'] = True
return

if assay_details.get('is-multi-assay', False):
doc['assay_modality'] = 'multiple'
creation_action = doc.get('creation_action', None)
if creation_action == CreationAction.CREATE_DATASET:
doc['multi_assay_category'] = 'primary'
elif creation_action == CreationAction.CENTRAL_PROCESS:
doc['multi_assay_category'] = 'processed'
if creation_action in [CreationAction.CREATE_DATASET, CreationAction.CENTRAL_PROCESS]:
doc['is_component'] = False
else:
error_msg = f"Unexpected creation_action={creation_action}. multi_assay_category will not be set."
error_msg = f"Unexpected creation_action={creation_action}. is_component will not be set."
_log_transformation_error(doc, error_msg)
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,26 +226,26 @@ def test_creation_action(creation_action, expected_error):


@pytest.mark.parametrize(
"creation_action,is_multi_assay,expected_category,expected_modality,expected_processing",
"creation_action,is_multi_assay,expected_component_bool,expected_modality,expected_processing",
[
pytest.param(
"Create Dataset Activity", None, None, "single", "raw", id="primary single assay"
),
pytest.param(
"Create Dataset Activity", True, "primary", "multiple", "raw", id="primary multiassay"
"Create Dataset Activity", True, False, "multiple", "raw", id="primary multiassay"
),
pytest.param(
"Multi-Assay Split", None, "component", "multiple", "raw", id="component"
"Multi-Assay Split", None, True, "multiple", "raw", id="component"
),
pytest.param(
"Central Process", True, "processed", "multiple", "processed", id="processed multiassay"
"Central Process", True, False, "multiple", "processed", id="processed multiassay"
),
pytest.param(
"Central Process", None, None, "single", "processed", id="processed single assay"
),
]
)
def test_assay_modality_fields(creation_action, is_multi_assay, expected_category, expected_modality, expected_processing):
def test_assay_modality_fields(creation_action, is_multi_assay, expected_component_bool, expected_modality, expected_processing):
input_doc = {
'creation_action': creation_action,
'entity_type': 'Dataset',
Expand All @@ -268,8 +268,8 @@ def test_assay_modality_fields(creation_action, is_multi_assay, expected_categor
if expected_processing == "processed":
output_doc['processing_type'] = "hubmap"

if expected_category:
output_doc['multi_assay_category'] = expected_category
if expected_modality == 'multiple':
output_doc['is_component'] = expected_component_bool

_add_dataset_categories(input_doc, assay_details)
assert input_doc == output_doc

0 comments on commit 6b5ee01

Please sign in to comment.