Bio-Graphics
view release on metacpan or search on metacpan
lib/Bio/Graphics/Glyph/gene.pm view on Meta::CPAN
my $self = shift;
if ($self->feature->primary_tag eq 'gene') {
my @parts = $self->parts;
return if @parts && $parts[0]->feature->primary_tag =~ /rna|transcript|pseudogene/i;
}
$self->SUPER::draw_connectors(@_);
}
sub maxdepth {
my $self = shift;
my $md = $self->Bio::Graphics::Glyph::maxdepth;
return $md if defined $md;
return 2;
}
sub fixup_glyph {
my $self = shift;
return unless $self->level == 1;
$self->create_implied_utrs if $self->option('implied_utrs');
$self->adjust_exons if $self->option('implied_utrs') || $self->option('adjust_exons');
}
sub _subfeat {
my $class = shift;
my $feature = shift;
if ($feature->primary_tag =~ /^gene/i) {
my @transcripts;
for my $t (qw/mRNA tRNA snRNA snoRNA miRNA ncRNA pseudogene transcript/) {
push @transcripts, $feature->get_SeqFeatures($t);
}
return @transcripts if @transcripts;
my @features = $feature->get_SeqFeatures; # no transcripts?! return whatever's there
return @features if @features;
# fall back to drawing a solid box if no subparts and level 0
return ($feature) if $class->{level} == 0;
}
elsif ($feature->primary_tag =~ /^CDS/i) {
my @parts = $feature->get_SeqFeatures();
return ($feature) if $class->{level} == 0 and !@parts;
return @parts;
}
my @subparts;
if ($class->option('sub_part')) {
@subparts = $feature->get_SeqFeatures($class->option('sub_part'));
}
elsif ($feature->primary_tag =~ /^mRNA/i) {
if ($class->option('implied_utrs') || $class->option('adjust_exons')) {
@subparts = $feature->get_SeqFeatures(qw(CDS exon five_prime_UTR three_prime_UTR UTR));
} else {
@subparts = $feature->get_SeqFeatures(qw(CDS five_prime_UTR three_prime_UTR UTR));
}
}
else {
@subparts = $feature->get_SeqFeatures('exon');
}
# The CDS and UTRs may be represented as a single feature with subparts or as several features
# that have different IDs. We handle both cases transparently.
my @result;
foreach (@subparts) {
if ($_->primary_tag =~ /CDS|UTR/i) {
my @cds_seg = $_->get_SeqFeatures;
if (@cds_seg > 0) { push @result,@cds_seg } else { push @result,$_ }
} else {
push @result,$_;
}
}
# fall back to drawing a solid box if no subparts and level 0
return ($feature) if $class->{level} == 0 && !@result;
return @result;
}
1;
__END__
=head1 NAME
Bio::Graphics::Glyph::gene - A GFF3-compatible gene glyph
=head1 SYNOPSIS
See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
=head1 DESCRIPTION
This glyph is used for drawing genes that may have
alternatively-spliced transcripts. The various isoforms are stacked on
top of each other and given a single label and description that apply
to the entire stack. Each individual transcript's name is optionally
printed to the left of the transcript glyph.
Transcripts (splice isoforms) are drawn using the processed_transcript
glyph. CDS features are drawn in the background color, and the UTRs
are drawn in an alternate color selected by the utr_color option. In
addition, you can make the UTRs thinner than the CDS by setting the
"thin_utr" option.
This glyph is designed to work properly with GFF3-style three-tier
genes, in which the top level feature has the Sequence Ontology type
of "gene", the second level feature(s) have the SO type "mRNA", and
the third level feature(s) have the SO type "CDS", "five_prime_utr"
and "three_prime_utr." Subparts named "UTR" are also honored. The
feature can contain other subparts as well (e.g. exon, intron,
translation), but they are currently ignored unless the option
sub_part is supplied. If the sub_part option is used that feature
type will be used and CDS and UTR features will be excluded.
This could be used for specifying that exons be used instead,
for example.
This glyph is a subclass of processed_transcript, and recognizes the
same options.
=head2 OPTIONS
The following options are standard among all Glyphs. See
L<Bio::Graphics::Glyph> for a full explanation.
( run in 1.841 second using v1.01-cache-2.11-cpan-39bf76dae61 )