Commit 1b6c096d authored by Marek Szuba's avatar Marek Szuba
Browse files

RNAProductAdaptor: replace fetch_all_by_type_id() with fetch_all_by_type()

The type in this case is expressed using human-readable code, which is
then translated to numerical ID using data from the rnaproduct_type
table.
parent a7f99bd9
......@@ -160,26 +160,26 @@ sub fetch_all_by_external_name {
}
=head2 fetch_all_by_type_id
=head2 fetch_all_by_type
Arg [1] : int
Example : $rps = $rnaproduct_adaptor->fetch_by_type_id(1);
Arg [1] : string $type_code
Example : $rps = $rp_a->fetch_all_by_type('miRNA');
Description: Retrieves RNAProducts via their type (e.g. miRNA, circRNA).
The type is presently expressed as numerical ID, which is
of limited usefulness; support for human-readable forms
will follow (FIXME).
If no RNAProducts are found, an empty list is returned.
If no matching RNAProducts are found, an empty list is
returned.
Returntype : arrayref of Bio::EnsEMBL::RNAProducts
Exceptions : none
Exceptions : throws if type code is undefined
Caller : ?
Status : In Development
=cut
sub fetch_all_by_type_id {
my ($self, $type_id) = @_;
sub fetch_all_by_type {
my ($self, $type_code) = @_;
throw("type code argument is required") unless $type_code;
return $self->_fetch_direct_query(['rnaproduct_type_id', $type_id, SQL_INTEGER]);
return ($self->_fetch_direct_query(['pt.code', $type_code, SQL_VARCHAR]));
}
......
......@@ -191,16 +191,16 @@ subtest 'fetch_all_by_Transcript() functionality' => sub {
cmp_ok(scalar @{$rps}, '>', 0, 'Non-empty list for Transcript with RNA products');
};
subtest 'fetch_all_by_type_id() functionality' => sub {
subtest 'fetch_all_by_type() functionality' => sub {
my $n_rps;
# At the moment we have only got miRNA in the homo_sapiens test database
# FIXME: compare this to the total number of RNAProducts?
$n_rps = scalar @{$rp_a->fetch_all_by_type_id(2)};
cmp_ok($n_rps, '>', 0, 'Got non-empty list of type_id==2 rnaproducts');
$n_rps = scalar @{$rp_a->fetch_all_by_type_id(3)};
cmp_ok($n_rps, '==', 0, 'Got empty list of type_id==3 rnaproducts');
$n_rps = scalar @{$rp_a->fetch_all_by_type('miRNA')};
cmp_ok($n_rps, '>', 0, 'Got non-empty list of miRNA rnaproducts');
$n_rps = scalar @{$rp_a->fetch_all_by_type('generic')};
cmp_ok($n_rps, '==', 0, 'Got empty list of generic rnaproducts');
};
$rp = undef;
......
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