From b76b352419e4c57d41d8fed8b7a07b983f22a76e Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 01/14] edit tests for human subset --- tests/test_illumina.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_illumina.py b/tests/test_illumina.py index dd51b9b5..e7bc33c2 100644 --- a/tests/test_illumina.py +++ b/tests/test_illumina.py @@ -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("Update managed access permissions to restricted human access group") def test_updates_human_permissions_mx( self, illumina_synthetic_irods, illumina_synthetic_mlwh ): From 6c16a95356e6284566bc2a11b55b6a4b8dc3ed5f Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 02/14] add new permissions for human --- tests/test_illumina.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_illumina.py b/tests/test_illumina.py index e7bc33c2..98012d86 100644 --- a/tests/test_illumina.py +++ b/tests/test_illumina.py @@ -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) From 43085968b84b6f998183dcfa9c8c8052937e9a12 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 03/14] add human irods group for human subset --- src/npg_irods/illumina.py | 4 ++-- src/npg_irods/metadata/lims.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/npg_irods/illumina.py b/src/npg_irods/illumina.py index 2067b9ed..4cf1a59c 100644 --- a/src/npg_irods/illumina.py +++ b/src/npg_irods/illumina.py @@ -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(c.subset, fc.sample, fc.study, 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 0346ddda..c618df07 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -168,7 +168,7 @@ 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(seq:SeqConcept, sample: Sample, study: Study, 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: @@ -192,8 +192,12 @@ def make_sample_acl(sample: Sample, study: Study, zone=None) -> list[AC]: Returns: An ACL """ - irods_group = f"{STUDY_IDENTIFIER_PREFIX}{study.id_study_lims}" - perm = Permission.NULL if sample.consent_withdrawn else Permission.READ + print(seq) + if seq is not None and seq.value == "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 or (seq is not None and seq.value == "xahuman") else Permission.READ return [AC(irods_group, perm, zone=zone)] From 70cf526d38ffc112dad1627c7ff93d6d95e95867 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 04/14] add xahuman to testing config --- tests/conftest.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 50b42191..832bb0f1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1029,6 +1029,13 @@ 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}'), From 34b0fca32a04592932fead13183f82b5ccf346ae Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 05/14] reformatted with black ahhhhhhhhhhhh --- src/npg_irods/metadata/lims.py | 10 ++++++++-- tests/conftest.py | 8 ++++++-- tests/test_illumina.py | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index c618df07..384369ed 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -168,7 +168,9 @@ def make_reduced_study_metadata(study: Study) -> list[AVU]: return [avu_if_value(TrackedStudy.ID, study.id_study_lims)] -def make_sample_acl(seq:SeqConcept, sample: Sample, study: Study, zone=None) -> list[AC]: +def make_sample_acl( + seq: SeqConcept, sample: Sample, study: Study, 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: @@ -197,7 +199,11 @@ def make_sample_acl(seq:SeqConcept, sample: Sample, study: Study, zone=None) -> 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 or (seq is not None and seq.value == "xahuman") else Permission.READ + perm = ( + Permission.NULL + if sample.consent_withdrawn or (seq is not None and seq.value == "xahuman") + else Permission.READ + ) return [AC(irods_group, perm, zone=zone)] diff --git a/tests/conftest.py b/tests/conftest.py index 832bb0f1..e7520c16 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1031,8 +1031,12 @@ def illumina_synthetic_irods(tmp_path): ), "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"}'), + 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), ), diff --git a/tests/test_illumina.py b/tests/test_illumina.py index 98012d86..035f61e9 100644 --- a/tests/test_illumina.py +++ b/tests/test_illumina.py @@ -427,7 +427,7 @@ def test_updates_human_permissions_mx( ] new_permissions = [ AC("irods", perm=Permission.OWN, zone=zone), - AC("ss_4000_human", perm=Permission.READ, zone=zone), + AC("ss_4000_human", perm=Permission.READ, zone=zone), ] for obj in [DataObject(path), DataObject(qc_path)]: From bcb0804090bdb512025e8234628aecdacc94e702 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 06/14] seqconcept unique to illumina --- src/npg_irods/ont.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/npg_irods/ont.py b/src/npg_irods/ont.py index 3ebfb82e..bbe88956 100644 --- a/src/npg_irods/ont.py +++ b/src/npg_irods/ont.py @@ -505,7 +505,7 @@ def _do_secondary_metadata_and_perms_update( acl = [] for fc in flowcells: - acl.extend(make_sample_acl(fc.sample, fc.study, zone=zone)) + acl.extend(make_sample_acl(None, fc.sample, fc.study, zone=zone)) recurse = item.rods_type == Collection cons_update = perm_update = False From e6d96461a679db17202777cf596d32848188c0c4 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 07/14] add arg to method comment --- src/npg_irods/metadata/lims.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index 384369ed..a141ecc7 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -186,6 +186,7 @@ def make_sample_acl( Note that this function does not check that the sample is in the study. Args: + seq: Sequencing terminology, unique to illumina sample: A sample, which will be used to confirm consent, which modifies the ACL. study: A study, which will provide permissions for the ACL. @@ -194,7 +195,6 @@ def make_sample_acl( Returns: An ACL """ - print(seq) if seq is not None and seq.value == "human": irods_group = f"{STUDY_IDENTIFIER_PREFIX}{study.id_study_lims}_human" else: From 5225c1a381e19b3e540046899481cedc8bb7cdcf Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 08/14] black apaaaaaain --- src/npg_irods/metadata/lims.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index a141ecc7..e18ef556 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -186,7 +186,7 @@ def make_sample_acl( Note that this function does not check that the sample is in the study. Args: - seq: Sequencing terminology, unique to illumina + seq: Sequencing terminology, unique to illumina sample: A sample, which will be used to confirm consent, which modifies the ACL. study: A study, which will provide permissions for the ACL. From c3986ec73e79279ddf0f8e6abe0b4f902f342fae Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 09/14] add xahuman --- tests/test_locate_data_objects.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_locate_data_objects.py b/tests/test_locate_data_objects.py index bf36ac71..4582be1e 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", From 0179b839846ee8da4f10deb8ecde87703c1437c8 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 10/14] update comment for right info --- src/npg_irods/metadata/lims.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index e18ef556..f8a67d2e 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -186,7 +186,7 @@ def make_sample_acl( Note that this function does not check that the sample is in the study. Args: - seq: Sequencing terminology, unique to illumina + seq: Platform-independent concepts sample: A sample, which will be used to confirm consent, which modifies the ACL. study: A study, which will provide permissions for the ACL. From e7365d6a7e843d532de24577b54adb4350daf1d9 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 10:54:07 +0000 Subject: [PATCH 11/14] make seqsubset optional argument --- src/npg_irods/illumina.py | 2 +- src/npg_irods/metadata/lims.py | 17 ++++++++--------- src/npg_irods/ont.py | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/npg_irods/illumina.py b/src/npg_irods/illumina.py index 4cf1a59c..1f42adc7 100644 --- a/src/npg_irods/illumina.py +++ b/src/npg_irods/illumina.py @@ -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(c.subset, fc.sample, fc.study, zone=zone)) + acl.extend(acl_fn(fc.sample, fc.study, c.subset, zone=zone)) # Remove duplicates secondary_metadata = sorted(set(secondary_metadata)) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index f8a67d2e..9961ca80 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -37,7 +37,7 @@ from npg_irods.db.mlwh import Sample, Study from npg_irods.metadata.common import ( - SeqConcept, + SeqSubset, ensure_avus_present, avu_if_value, ) @@ -169,7 +169,7 @@ def make_reduced_study_metadata(study: Study) -> list[AVU]: def make_sample_acl( - seq: SeqConcept, sample: Sample, study: Study, zone=None + sample: Sample, study: Study, subset: SeqSubset=None, zone=None ) -> list[AC]: """Returns an ACL for a given Sample in a Study. @@ -186,7 +186,7 @@ def make_sample_acl( Note that this function does not check that the sample is in the study. Args: - seq: Platform-independent concepts + subset: Subset of sequence reads sample: A sample, which will be used to confirm consent, which modifies the ACL. study: A study, which will provide permissions for the ACL. @@ -195,15 +195,14 @@ def make_sample_acl( Returns: An ACL """ - if seq is not None and seq.value == "human": + 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 or (seq is not None and seq.value == "xahuman") - else Permission.READ - ) + perm = Permission.NULL if sample.consent_withdrawn else Permission.READ return [AC(irods_group, perm, zone=zone)] diff --git a/src/npg_irods/ont.py b/src/npg_irods/ont.py index bbe88956..3ebfb82e 100644 --- a/src/npg_irods/ont.py +++ b/src/npg_irods/ont.py @@ -505,7 +505,7 @@ def _do_secondary_metadata_and_perms_update( acl = [] for fc in flowcells: - acl.extend(make_sample_acl(None, fc.sample, fc.study, zone=zone)) + acl.extend(make_sample_acl(fc.sample, fc.study, zone=zone)) recurse = item.rods_type == Collection cons_update = perm_update = False From b19b85ba4b1585cbd241c04a36be424acecaea34 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 12:10:45 +0000 Subject: [PATCH 12/14] black = pain --- src/npg_irods/metadata/lims.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index 9961ca80..5fbea4e8 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -169,7 +169,7 @@ def make_reduced_study_metadata(study: Study) -> list[AVU]: def make_sample_acl( - sample: Sample, study: Study, subset: SeqSubset=None, zone=None + sample: Sample, study: Study, subset: SeqSubset = None, zone=None ) -> list[AC]: """Returns an ACL for a given Sample in a Study. From a61a36c4d8efbf1452932f4880951880be8009c9 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Wed, 24 Jan 2024 13:41:25 +0000 Subject: [PATCH 13/14] import SeqConcept --- src/npg_irods/metadata/lims.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index 5fbea4e8..bb265319 100644 --- a/src/npg_irods/metadata/lims.py +++ b/src/npg_irods/metadata/lims.py @@ -37,6 +37,7 @@ from npg_irods.db.mlwh import Sample, Study from npg_irods.metadata.common import ( + SeqConcept, SeqSubset, ensure_avus_present, avu_if_value, From c138254c14da8528f7b2cbb763867499a53d67c7 Mon Sep 17 00:00:00 2001 From: zaynab butt Date: Thu, 25 Jan 2024 11:43:16 +0000 Subject: [PATCH 14/14] update comments --- src/npg_irods/illumina.py | 4 ++-- src/npg_irods/metadata/lims.py | 4 ++-- tests/conftest.py | 2 +- tests/test_illumina.py | 4 ++-- tests/test_pacbio.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/npg_irods/illumina.py b/src/npg_irods/illumina.py index 1f42adc7..b7149281 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, c.subset, zone=zone)) + acl.extend(acl_fn(fc.sample, fc.study, subset=c.subset, zone=zone)) # Remove duplicates secondary_metadata = sorted(set(secondary_metadata)) diff --git a/src/npg_irods/metadata/lims.py b/src/npg_irods/metadata/lims.py index bb265319..b283d8da 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 @@ -187,10 +187,10 @@ def make_sample_acl( Note that this function does not check that the sample is in the study. Args: - subset: Subset of sequence reads 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: diff --git a/tests/conftest.py b/tests/conftest.py index e7520c16..0c6afba8 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 diff --git a/tests/test_illumina.py b/tests/test_illumina.py index 035f61e9..69eeff0a 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("Update managed access permissions to restricted human access group") + @m.it("Updates managed access permissions to restricted human access group") def test_updates_human_permissions_mx( self, illumina_synthetic_irods, illumina_synthetic_mlwh ): diff --git a/tests/test_pacbio.py b/tests/test_pacbio.py index 206c46a4..95a1ba29 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