Skip to content
Snippets Groups Projects
Commit ef64d0ff authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

In fetch_all_by_Gene(): Go through the list of fetched transcripts

and mark the canonical one as canonical.  Solves issue raised
by Will McLaren where none of the transcripts returned from
$gene->get_all_Transcripts() would be marked as canonical.
parent a0df70c7
No related branches found
No related tags found
No related merge requests found
......@@ -294,26 +294,27 @@ sub fetch_by_translation_id {
=cut
sub fetch_all_by_Gene {
my $self = shift;
my $gene = shift;
my ( $self, $gene ) = @_;
my $constraint = "t.gene_id = ".$gene->dbID();
my $constraint = "t.gene_id = " . $gene->dbID();
# Use the fetch_all_by_Slice_constraint method because it
# handles the difficult Haps/PARs and coordinate remapping
# Use the fetch_all_by_Slice_constraint method because it handles the
# difficult Haps/PARs and coordinate remapping.
# Get a slice that entirely overlaps the gene. This is because we
# want all transcripts to be retrieved, not just ones overlapping
# the slice the gene is on (the gene may only partially overlap the slice)
# For speed reasons, only use a different slice if necessary though.
# the slice the gene is on (the gene may only partially overlap the
# slice). For speed reasons, only use a different slice if necessary
# though.
my $gslice = $gene->slice();
my $slice;
if (!$gslice) {
if ( !defined($gslice) ) {
throw("Gene must have attached slice to retrieve transcripts.");
}
my $slice;
if ( $gene->start() < 1 || $gene->end() > $gslice->length() ) {
if ( $gslice->is_circular() ) {
$slice = $gslice;
......@@ -324,18 +325,28 @@ sub fetch_all_by_Gene {
$slice = $gslice;
}
my $transcripts = $self->fetch_all_by_Slice_constraint($slice, $constraint);
my $transcripts =
$self->fetch_all_by_Slice_constraint( $slice, $constraint );
if ($slice != $gslice) {
if ( $slice != $gslice ) {
my @out;
foreach my $tr (@$transcripts) {
push @out, $tr->transfer($gslice);
foreach my $tr ( @{$transcripts} ) {
push( @out, $tr->transfer($gslice) );
}
$transcripts = \@out;
}
my $canonical_t = $gene->canonical_transcript();
foreach my $t ( @{$transcripts} ) {
if ( $t->equals($canonical_t) ) {
$t->is_canonical(1);
last;
}
}
return $transcripts;
}
} ## end sub fetch_all_by_Gene
=head2 fetch_all_by_Slice
......
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