Skip to content

Commit

Permalink
Merge pull request #439 from mgcam/human_data_acls_update
Browse files Browse the repository at this point in the history
Dropped platform-specific ACL rules.
  • Loading branch information
mgcam authored Jan 18, 2024
2 parents 79066ad + 57dab2e commit 6c6685e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 111 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
10 changes: 5 additions & 5 deletions lib/WTSI/NPG/HTS/Illumina/Annotator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ with qw[
=head2 make_primary_metadata
Arg [1] : Biomaterial composition, npg_tracking::glossary::composition.
Arg [2] : Total number of reads (non-secondary/supplementary), Int.
Named args : tag_index Tag index, Int. Optional.
is_paired_read Run is paired, Bool. Optional.
Named args : is_paired_read Run is paired, Bool. Optional.
is_aligned Run is aligned, Bool. Optional.
reference Reference file path, Str. Optional.
alt_process Alternative process name, Str. Optional.
alignment_filter Alignment filter name, Str. Optional.
num_reads Total number of reads
(non-secondary/supplementary), Int. Optional.
seqchksum Seqchksum digestgg112, Str. Optional.
lims_factory Factory for st:api::lims objects,
WTSI::NPG::HTS::LIMSFactory. Optional.
Example : my @avus = $ann->make_primary_metadata
($id_run, $position, $num_reads,
($composition,
num_reads => 100,
tag_index => $tag_index,
is_paired_read => 1,
is_aligned => 1,
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 6c6685e

Please sign in to comment.