From 9d8d6076eef416db7614bb55ff48cbd48dfb40d5 Mon Sep 17 00:00:00 2001 From: Marina Gourtovaia Date: Fri, 15 Dec 2023 10:13:01 +0000 Subject: [PATCH] Dropped platform-specific ACL rules. This pr builds on https://github.com/wtsi-npg/perl-irods-wrap/pull/297, where all existing rules are consolidated in one method. --- lib/WTSI/NPG/HTS/Illumina/AlnDataObject.pm | 66 ------------------- .../NPG/HTS/Illumina/AlnDataObjectTest.pm | 52 ++++----------- 2 files changed, 12 insertions(+), 106 deletions(-) diff --git a/lib/WTSI/NPG/HTS/Illumina/AlnDataObject.pm b/lib/WTSI/NPG/HTS/Illumina/AlnDataObject.pm index dabee96f..c2efff8f 100644 --- a/lib/WTSI/NPG/HTS/Illumina/AlnDataObject.pm +++ b/lib/WTSI/NPG/HTS/Illumina/AlnDataObject.pm @@ -156,72 +156,6 @@ sub reference { return $reference; } -=head2 contains_nonconsented_human - - Arg [1] None - - Example : $obj->contains_nonconsented_human - Description: Return true if the file contains human data not having - explicit consent. This is indicated by alignment results - returned by the subset method. - - Returntype : Bool - -=cut - -sub contains_nonconsented_human { - my ($self) = @_; - - my $contains_nonconsented_human = - any { $_->has_subset and ($_->subset eq $HUMAN or - $_->subset eq $XAHUMAN) - } $self->composition->components_list; - - if ($contains_nonconsented_human) { - $self->debug('subset indicates onconsented human sequence in ', - $self->str); - } - - return $contains_nonconsented_human; -} - -override 'update_group_permissions' => sub { - my ($self, $strict_groups) = @_; - - # super must be called explicitly in order to fire the before/after - # methods on update_group_permissions (these are defined in the - # superclass) - super(); - - if ($self->contains_nonconsented_human) { - my $path = $self->str; - - my @groups = $self->get_groups($WTSI::NPG::iRODS::READ_PERMISSION); - $self->info('Ensuring permissions removed for nonconsented human on ', - "'$path': for groups ", pp(\@groups)); - my @failed_groups; - - foreach my $group (@groups) { - try { - $self->set_permissions($WTSI::NPG::iRODS::NULL_PERMISSION, $group); - } catch { - push @failed_groups, $group; - $self->error("Failed to remove permissions for group '$group' from ", - "'$path': ", $_); - }; - } - - my $num_groups = scalar @groups; - my $num_errors = scalar @failed_groups; - if ($num_errors > 0) { - $self->logcroak("Failed to remove $num_errors / $num_groups group ", - "permissions from '$path': ", pp(\@failed_groups)); - } - } - - return $self; -}; - sub _build_composition { my ($self) = @_; diff --git a/t/lib/WTSI/NPG/HTS/Illumina/AlnDataObjectTest.pm b/t/lib/WTSI/NPG/HTS/Illumina/AlnDataObjectTest.pm index bf0865b9..b7db088c 100644 --- a/t/lib/WTSI/NPG/HTS/Illumina/AlnDataObjectTest.pm +++ b/t/lib/WTSI/NPG/HTS/Illumina/AlnDataObjectTest.pm @@ -179,13 +179,20 @@ sub setup_test : Test(setup) { my $num_reads = 10000; - my @avus; - push @avus, TestAnnotator->new->make_primary_metadata - ($obj->composition, + my $composition = $obj->composition; + my $component = $composition->get_component(0); + my %args = ( is_paired_read => 1, is_aligned => $obj->is_aligned, num_reads => $num_reads, - reference => $obj->reference); + reference => $obj->reference, + ); + my $ta = TestAnnotator->new(); + + my @avus; + push @avus, $ta->make_primary_metadata($composition, %args), + $ta->make_alignment_metadata( + $component, $num_reads, $obj->reference, $obj->is_aligned); foreach my $avu (@avus) { my $attribute = $avu->{attribute}; @@ -259,41 +266,6 @@ sub position : Test(12) { } } -sub contains_nonconsented_human : Test(12) { - my $irods = WTSI::NPG::iRODS->new(environment => \%ENV, - strict_baton_version => 0); - - foreach my $format (qw[bam cram]) { - foreach my $path (sort grep { /17550/ } keys %file_composition) { - my $full_path = "/seq/17550/$path.$format"; - my @initargs = _build_initargs(\%file_composition, $path); - - my $obj = WTSI::NPG::HTS::Illumina::AlnDataObject->new - ($irods, $full_path, @initargs); - - my $ss = $obj->subset; - if (not $ss) { - ok(!$obj->contains_nonconsented_human, - "$full_path is not nonconsented human"); - } - elsif ($ss eq 'nonhuman' or - $ss eq 'yhuman' or - $ss eq 'phix') { - ok(!$obj->contains_nonconsented_human, - "$full_path is not nonconsented human ($ss)"); - } - elsif ($ss eq 'human' or - $ss eq 'xahuman') { - ok($obj->contains_nonconsented_human, - "$full_path is nonconsented human ($ss)"); - } - else { - fail "Unexpected alignment_filter '$ss'"; - } - } - } -} - sub is_restricted_access : Test(12) { my $irods = WTSI::NPG::iRODS->new(environment => \%ENV, strict_baton_version => 0); @@ -423,7 +395,7 @@ sub nonconsented_human_access_revoked : Test(6) { expected_groups_before => [$public_group, 'ss_10', 'ss_100'], - expected_groups_after => [] # all access removed + expected_groups_after => ['ss_619_human'] }); } }