Commit 7b4fadb6 authored by Marek Szuba's avatar Marek Szuba
Browse files

Implement Transcript::get_all_RNAProducts() + its tests

The optional argument allows the user to only retrieve RNA products of
specific type, e.g. microRNAs. At the moment the type has to be
specified by a numerical ID, in the future this will be changed to allow
the passing of string codes.
parent 169e8488
......@@ -3003,6 +3003,43 @@ sub get_all_DAS_Features {
}
=head2 get_all_RNAProducts
Arg [1] : optional int $type_id
The numerical ID of the rnaproduct type to retrieve values for.
FIXME: this should definitely take string codes instead.
Example : @transc_mirnas = @{$transcript->get_all_RNAProducts(1)};
@transc_rnaproducts = @{$transcript->get_all_RNAProducts()};
Description: Gets a list of RNAProducts of this transcript.
Optionally just get RNAProducts for given type ID.
Returntype : listref Bio::EnsEMBL::RNAProduct
Exceptions : none
Caller : general
Status : In Development
=cut
sub get_all_RNAProducts {
my ($self, $type_id) = @_;
if (!exists $self->{'rnaproducts'}) {
if (!$self->adaptor()) {
return [];
}
my $rnaproduct_adaptor = $self->adaptor->db->get_RNAProductAdaptor();
$self->{'rnaproducts'} = $rnaproduct_adaptor->fetch_all_by_Transcript($self);
}
if (defined $type_id) {
my @results = grep { $_->type_id() == $type_id } @{$self->{'rnaproducts'}};
return \@results;
} else {
return $self->{'rnaproducts'};
}
}
=head2 _compare_xrefs
......
......@@ -1028,6 +1028,18 @@ for (my $i = 0; $i < scalar(@absolute_coords); $i++) {
}
}
## Test retrieval of mature RNA products
{
$tr = $ta->fetch_by_stable_id('ENST00000278995');
my $rps_all = $tr->get_all_RNAProducts();
my $rps_micro = $tr->get_all_RNAProducts(1);
my $rps_circ = $tr->get_all_RNAProducts(2);
cmp_ok(scalar @{$rps_all}, '>', 0, 'Have RNA products');
is_deeply($rps_all, $rps_micro, 'All RNA products are microRNAs');
cmp_ok(scalar @{$rps_circ}, '==', 0, 'Have no circRNAs');
}
done_testing();
#
......
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