Skip to content

Commit

Permalink
Dropped platform-specific ACL rules.
Browse files Browse the repository at this point in the history
This pr builds on
wtsi-npg/perl-irods-wrap#297,
where all existing rules are consolidated in one method.
  • Loading branch information
mgcam committed Jan 12, 2024
1 parent ae9010d commit 9d8d607
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 106 deletions.
66 changes: 0 additions & 66 deletions lib/WTSI/NPG/HTS/Illumina/AlnDataObject.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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) = @_;

Expand Down
52 changes: 12 additions & 40 deletions t/lib/WTSI/NPG/HTS/Illumina/AlnDataObjectTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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']
});
}
}
Expand Down

0 comments on commit 9d8d607

Please sign in to comment.