diff --git a/src/npg_irods/illumina.py b/src/npg_irods/illumina.py index 2067b9e..b714928 100644 --- a/src/npg_irods/illumina.py +++ b/src/npg_irods/illumina.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright © 2023 Genome Research Ltd. All rights reserved. +# Copyright © 2023, 2024 Genome Research Ltd. All rights reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -234,7 +234,7 @@ def empty_acl(*args): for fc in flowcells: secondary_metadata.extend(sample_fn(fc.sample)) secondary_metadata.extend(study_fn(fc.study)) - acl.extend(acl_fn(fc.sample, fc.study, zone=zone)) + acl.extend(acl_fn(fc.sample, fc.study, subset=c.subset, zone=zone)) # Remove duplicates secondary_metadata = sorted(set(secondary_metadata)) @@ -248,7 +248,7 @@ def empty_acl(*args): cons_update = ensure_consent_withdrawn(item) elif any(c.contains_nonconsented_human() for c in components): # Illumina specific log.info("Non-consented human data", path=item) - xahu_update = ensure_consent_withdrawn(item) + xahu_update = update_permissions(item, acl) else: perm_update = update_permissions(item, acl) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index 0346ddd..b283d8d 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright © 2021, 2022, 2023 Genome Research Ltd. All rights reserved. +# Copyright © 2021, 2022, 2023, 2024 Genome Research Ltd. All rights reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,6 +38,7 @@ from npg_irods.db.mlwh import Sample, Study from npg_irods.metadata.common import ( SeqConcept, + SeqSubset, ensure_avus_present, avu_if_value, ) @@ -168,7 +169,9 @@ def make_reduced_study_metadata(study: Study) -> list[AVU]: return [avu_if_value(TrackedStudy.ID, study.id_study_lims)] -def make_sample_acl(sample: Sample, study: Study, zone=None) -> list[AC]: +def make_sample_acl( + sample: Sample, study: Study, subset: SeqSubset = None, zone=None +) -> list[AC]: """Returns an ACL for a given Sample in a Study. This method takes into account all factors influencing access control, which are: @@ -187,12 +190,19 @@ def make_sample_acl(sample: Sample, study: Study, zone=None) -> list[AC]: sample: A sample, which will be used to confirm consent, which modifies the ACL. study: A study, which will provide permissions for the ACL. + subset: Subset of sequence reads. zone: The iRODS zone. Returns: An ACL """ - irods_group = f"{STUDY_IDENTIFIER_PREFIX}{study.id_study_lims}" + if subset is not None and subset is subset.XAHUMAN: + return [] + + if subset is not None and subset is subset.HUMAN: + irods_group = f"{STUDY_IDENTIFIER_PREFIX}{study.id_study_lims}_human" + else: + irods_group = f"{STUDY_IDENTIFIER_PREFIX}{study.id_study_lims}" perm = Permission.NULL if sample.consent_withdrawn else Permission.READ return [AC(irods_group, perm, zone=zone)] diff --git a/tests/conftest.py b/tests/conftest.py index 50b4219..0c6afba 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright © 2020, 2022, 2023 Genome Research Ltd. All rights reserved. +# Copyright © 2020, 2022, 2023, 2024 Genome Research Ltd. All rights reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1029,6 +1029,17 @@ def illumina_synthetic_irods(tmp_path): *run_pos, AVU(tag, 1), ), + "12345/12345#1_xahuman.cram": ( + AVU(idp, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), + AVU( + cmp, '{"id_run":12345, "position":1, "tag_index":1, "subset":"xahuman"}' + ), + AVU( + cmp, '{"id_run":12345, "position":2, "tag_index":1, "subset":"xahuman"}' + ), + *run_pos, + AVU(tag, 1), + ), "12345/12345#2.cram": ( AVU(idp, "0b3bd00f1d186247f381aa87e213940b8c7ab7e5"), AVU(cmp, '{"id_run":12345, "position":1, "tag_index":2}'), diff --git a/tests/test_illumina.py b/tests/test_illumina.py index dd51b9b..69eeff0 100644 --- a/tests/test_illumina.py +++ b/tests/test_illumina.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright © 2023 Genome Research Ltd. All rights reserved. +# Copyright © 2023, 2024 Genome Research Ltd. All rights reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -412,7 +412,7 @@ def test_updates_changed_study_permissions( @m.context("When data are multiplexed") @m.context("When data contain a human subset") - @m.it("Removes managed access permissions") + @m.it("Updates managed access permissions to restricted human access group") def test_updates_human_permissions_mx( self, illumina_synthetic_irods, illumina_synthetic_mlwh ): @@ -425,7 +425,10 @@ def test_updates_human_permissions_mx( AC("irods", perm=Permission.OWN, zone=zone), AC("ss_4000", perm=Permission.READ, zone=zone), ] - new_permissions = [AC("irods", perm=Permission.OWN, zone=zone)] + new_permissions = [ + AC("irods", perm=Permission.OWN, zone=zone), + AC("ss_4000_human", perm=Permission.READ, zone=zone), + ] for obj in [DataObject(path), DataObject(qc_path)]: obj.add_permissions(*old_permissions) diff --git a/tests/test_locate_data_objects.py b/tests/test_locate_data_objects.py index bf36ac7..4582be1 100644 --- a/tests/test_locate_data_objects.py +++ b/tests/test_locate_data_objects.py @@ -20,6 +20,7 @@ def test_illumina_updates( "12345#1.cram", "12345#1_human.cram", "12345#1_phix.cram", + "12345#1_xahuman.cram", "12345#2.cram", "12345#888.cram", "12345.cram", diff --git a/tests/test_pacbio.py b/tests/test_pacbio.py index 206c46a..95a1ba2 100644 --- a/tests/test_pacbio.py +++ b/tests/test_pacbio.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright © 2023 Genome Research Ltd. All rights reserved. +# Copyright © 2023, 2024 Genome Research Ltd. All rights reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by