Commit 91202fa8 authored by Marek Szuba's avatar Marek Szuba
Browse files

MicroRNA: enforce hairpin-arm correctness in constructor and setter

parent b09454db
...@@ -112,6 +112,9 @@ sub new { ## no critic (Subroutines::RequireArgUnpacking) ...@@ -112,6 +112,9 @@ sub new { ## no critic (Subroutines::RequireArgUnpacking)
my $type_id = 2; my $type_id = 2;
my ($arm) = rearrange(["ARM"], @_); my ($arm) = rearrange(["ARM"], @_);
if (defined($arm)) {
_validate_arm_value($arm);
}
$self->{'arm'} = $arm; $self->{'arm'} = $arm;
return $self; return $self;
...@@ -135,6 +138,7 @@ sub arm { ...@@ -135,6 +138,7 @@ sub arm {
my ($self, $arm) = @_; my ($self, $arm) = @_;
if (defined $arm) { if (defined $arm) {
_validate_arm_value($arm);
$self->{'arm'} = $arm; $self->{'arm'} = $arm;
} elsif (!defined($self->{'arm'})) { } elsif (!defined($self->{'arm'})) {
my $arm_attrs = $self->get_all_Attributes('mirna_arm'); my $arm_attrs = $self->get_all_Attributes('mirna_arm');
...@@ -171,4 +175,25 @@ sub summary_as_hash { ...@@ -171,4 +175,25 @@ sub summary_as_hash {
return $summary; return $summary;
} }
# _validate_arm_value
# Arg [1] : int $arm which arm of the hairpin precursor this miRNA
# comes from
# Description: PRIVATE validates if its argument has one of the accepted
# values for specifying the miRNA hairpin arm.
# Returntype : none
# Exceptions : throw if the argument is out of bounds
# Caller : internal
# Status : Stable
sub _validate_arm_value {
my ($arm) = @_;
if (($arm != 3) && ($arm != 5)) {
throw("'$arm' is not a valid miRNA hairpin-arm specification");
}
return;
}
1; 1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment