This glyph is used for drawing features that consist of discontinuous
segments. Unlike "graded_segments" or "alignment", the segments are a
uniform color and not dependent on the score of the segment.
The following options are standard among all Glyphs. See
Bio::Graphics::Glyph for a full explanation.
Option Description Default
------ ----------- -------
-fgcolor Foreground color black
-outlinecolor Synonym for -fgcolor
-bgcolor Background color turquoise
-fillcolor Synonym for -bgcolor
-linewidth Line width 1
-height Height of glyph 10
-font Glyph font gdSmallFont
-connector Connector type 0 (false)
-connector_color
Connector color black
-label Whether to draw a label 0 (false)
-description Whether to draw a description 0 (false)
-strand_arrow Whether to indicate 0 (false)
strandedness
-draw_dna If true, draw the dna residues 0 (false)
when magnification level
allows.
-draw_target If true, draw the dna residues 0 (false)
of the TARGET sequence when
magnification level allows.
SEE NOTE.
-ragged_start When combined with -draw_target, 0 (false)
draw a few bases beyond the end
of the alignment. SEE NOTE.
-show_mismatch When combined with -draw_target, 0 (false)
highlights mismatched bases in
pink. SEE NOTE.
The -draw_target and -ragged_start options only work with seqfeatures
that implement the hit() method (Bio::SeqFeature::SimilarityPair).
The -ragged_start option is mostly useful for looking for polyAs and
cloning sites at the beginning of ESTs and cDNAs. Currently there is
no way of activating ragged ends. The length of the ragged starts is
hard-coded at 25 bp, and the color of mismatches is hard-coded as
light pink.
None available.
sub draw_component
{ my $self = shift;
my ($draw_dna,$draw_target) = ($self->option('draw_dna'),$self->option('draw_target'));
return $self->SUPER::draw_component(@_)
unless $draw_dna || $draw_target;
return $self->SUPER::draw_component(@_) unless $self->dna_fits;
my $dna = $draw_target ? eval {$self->feature->hit->seq}
: eval {$self->feature->seq};
return $self->SUPER::draw_component(@_) unless length $dna > 0;
my $show_mismatch = $draw_target && $self->option('show_mismatch');
my $genomic = eval {$self->feature->seq} if $show_mismatch;
my $gd = shift;
my ($x1,$y1,$x2,$y2) = $self->bounds(@_);
my $offset = 0;
eval { if ($draw_target && $self->option('ragged_start')){
my $target = $self->feature->hit;
if ($target->start < $target->end && $target->start < RAGGED_START_FUZZ
&& $self->{partno} == 0) {
$offset = $target->start - 1;
if ($offset > 0) {
$dna = $target->subseq(1-$offset,0)->seq . $dna;
$genomic = $self->feature->subseq(1-$offset,0)->seq . $genomic;
$x1 -= $offset * $self->scale;
}
}
elsif ($target->end < $target->start &&
$target->end < RAGGED_START_FUZZ && $self->{partno} == $self->{total_parts}) {
$offset = $target->end - 1;
if ($offset > 0) {
$dna .= $target->factory->get_dna($target,$offset,1);
$genomic = $self->feature->subseq(-$offset,0)->seq . $genomic;
$x2 += $offset * $self->scale;
$offset = 0;
}
}
}
};
$self->draw_dna($gd,$offset,lc $dna,lc $genomic,$x1,$y1,$x2,$y2); } |
sub draw_dna
{ my $self = shift;
my ($gd,$start_offset,$dna,$genomic,$x1,$y1,$x2,$y2) = @_;
my $pixels_per_base = $self->scale;
my $feature = $self->feature;
my $target = $feature->target;
my $strand = $feature->strand;
my @segs;
my $complement = $strand < 0;
if ($self->{flip}) {
$dna = $self->reversec($dna);
$genomic = $self->reversec($genomic);
$strand *= -1;
}
warn "strand = $strand, complement = $complement" if DEBUG;
if ($genomic && length($genomic) != length($dna) && eval { require Bio::Graphics::Browser::Realign}) {
warn "$genomic\n$dna\n" if DEBUG;
warn "strand = $strand" if DEBUG;
@segs = Bio::Graphics::Browser::Realign::align_segs($genomic,$dna);
for my $seg (@segs) {
my $src = substr($genomic,$seg->[0],$seg->[1]-$seg->[0]+1);
my $tgt = substr($dna, $seg->[2],$seg->[3]-$seg->[2]+1);
warn "@$seg\n$src\n$tgt" if DEBUG;
}
} else {
@segs = [0,length($genomic)-1,0,length($dna)-1];
}
my $color = $self->fgcolor;
my $font = $self->font;
my $lineheight = $font->height;
my $fontwidth = $font->width;
$y1 -= $lineheight/2 - 3; my $pink = $self->factory->translate_color('lightpink');
my $panel_end = $self->panel->right;
my $start = $self->map_no_trunc($self->feature->start- $start_offset);
my $end = $self->map_no_trunc($self->feature->end - $start_offset);
my ($last,$tlast);
for my $seg (@segs) {
if (defined $last) {
my $delta = $seg->[0] - $last - 1;
my $tdelta = $seg->[2] - $tlast - 1;
warn "src gap [$last,$seg->[0]], tgt gap [$tlast,$seg->[2]], delta = $delta, tdelta = $tdelta\n" if DEBUG;
my $gaps = $delta - $tdelta;
my @fill_in = split '',substr($dna,$tlast+1,$tdelta) if $tdelta > 0;
unshift @fill_in,('-')x$gaps if $gaps > 0;
warn "gaps = $gaps, fill_in = @fill_in\n" if DEBUG;
my $distance = $pixels_per_base * ($delta+1);
my $pixels_per_target = $gaps >= 0 ? $pixels_per_base : $distance/(@fill_in+1);
warn "pixels_per_base = $pixels_per_base, pixels_per_target=$pixels_per_target\n" if DEBUG;
my $offset = $self->{flip} ? $end + ($last-1)*$pixels_per_base : $start + $last*$pixels_per_base;
for (my $i=0; $i<@fill_in; $i++) {
my $x = $self->{flip} ? int($offset + ($i+1)*$pixels_per_target + 0.5)
: int($offset + ($i+1)*$pixels_per_target + 0.5);
$self->filled_box($gd,$x,$y1+3,$x+$fontwidth,$y1+$lineheight-3,$pink,$pink) unless $gaps;
$gd->char($font,$x,$y1,$complement? $complement{$fill_in[$i]} : $fill_in[$i],$color);
}
}
my @genomic = split '',substr($genomic,$seg->[0],$seg->[1]-$seg->[0]+1);
my @bases = split '',substr($dna, $seg->[2],$seg->[3]-$seg->[2]+1);
for (my $i = 0; $i<@bases; $i++) {
my $x = $self->{flip} ? int($end + ($seg->[0] + $i - 1)*$pixels_per_base + 0.5)
: int($start + ($seg->[0] + $i) *$pixels_per_base + 0.5);
next if $x+1 < $x1;
last if $x+1 > $x2;
if ($genomic[$i] && lc($bases[$i]) ne lc($complement ? $complement{$genomic[@genomic - $i - 1]} : $genomic[$i])) {
$self->filled_box($gd,$x,$y1+3,$x+$fontwidth,$y1+$lineheight-3,$pink,$pink);
}
$gd->char($font,$x,$y1,$complement ? $complement{$bases[$i]} || $bases[$i] : $bases[$i],$color);
}
$last = $seg->[1];
$tlast = $seg->[3];
}
}
} |
Please report them.