Commit a85f6b1e authored by Kieron Taylor's avatar Kieron Taylor 😠
Browse files

Copied fetch_all_by_biotype from GeneAdaptor to TranscriptAdaptor.

parent f99c5816
......@@ -684,6 +684,53 @@ sub fetch_all_by_exon_stable_id {
return \@trans;
}
=head2 fetch_all_by_biotype
Arg [1] : String $biotype
listref of $biotypes
The biotype of the gene to retrieve. You can also have a reference
to a list of biotypes in the event of needing several.
Example : $transcript = $transcript_adaptor->fetch_all_by_biotype('pseudogene');
$transcript = $transcript_adaptor->fetch_all_by_biotype(['protein_coding','ambiguous_orf']);
Description: Retrieves an array reference of transcript objects from the
database via its biotype or biotypes.
The transcript will be retrieved in its native coordinate system
(i.e. in the coordinate system it is stored in the database).
It may be converted to a different coordinate system through a
call to transform() or transfer(). If the transcript is not found
undef is returned instead.
Returntype : listref of Bio::EnsEMBL::Transcript
Exceptions : if we cant get the transcript in given coord system
Caller : general
Status : Stable
=cut
sub fetch_all_by_biotype {
my ($self, $biotype) = @_;
if (!defined $biotype){
throw("Biotype or listref of biotypes expected");
}
my $constraint;
if (ref($biotype) eq 'ARRAY'){
$constraint = "t.biotype IN (";
foreach my $b (@{$biotype}){
$constraint .= "?,";
$self->bind_param_generic_fetch($b,SQL_VARCHAR);
}
chop($constraint); #remove last , from expression
$constraint .= ") and t.is_current = 1";
}
else{
$constraint = "t.biotype = ? and t.is_current = 1";
$self->bind_param_generic_fetch($biotype,SQL_VARCHAR);
}
my @transcripts = @{ $self->generic_fetch($constraint) };
return \@transcripts ;
}
=head2 store
......
......@@ -258,6 +258,17 @@ ok($tr && $tr->stable_id eq 'ENST00000201961');
ok($tr->display_id() eq $tr->stable_id());
#
# test TranscriptAdaptor::fetch_all_by_biotype
#
debug("Test fetch_all_by_biotype");
my @transcripts = @{$ta->fetch_all_by_biotype('protein_coding')};
ok(@transcripts == 25);
@transcripts = @{$ta->fetch_all_by_biotype(['protein_coding','pseudogene'])};
warn "Got ".scalar(@transcripts)." transcripts\n";
ok(@transcripts == 25);
#
# Test get_all_Introns by joining Exons and introns
# and comparing it to the original
......@@ -506,7 +517,7 @@ $tr = $ta->fetch_by_stable_id('ENST00000355555');
debug("fetch_by_stable_id");
ok( $tr->dbID == 21740 );
my @transcripts = @{ $ta->fetch_all_versions_by_stable_id('ENST00000355555') };
@transcripts = @{ $ta->fetch_all_versions_by_stable_id('ENST00000355555') };
debug("fetch_all_versions_by_stable_id");
ok( scalar(@transcripts) == 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