Bio::G...dwidth(3pm)

πŸ“¦
version 2.40 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– Bio::Graphics::Glyph::fixedwidth β€” the perl manual, but make it cute πŸ’–

okay bestie, gather round, because this is Bio::Graphics::Glyph::fixedwidth(3pm) from the User Contributed Perl Documentation and it's literally the blueprint for every glyph that wants to be a fixed-size icon instead of a stretchy noodle. no cap. πŸŽ€


✨ NAME ✨

Bio::Graphics::Glyph::fixedwidth β€” a base class for fixed width glyphs. it's giving "template", it's giving "your fave is a subclass of me". πŸ‘‘


🌸 SYNOPSIS 🌸

here's the whole vibe in code, verbatim, don't touch a character:

use Bio::Graphics;
use Bio::Seq;
use Bio::SeqFeature::Generic;

my $bsg = 'Bio::SeqFeature::Generic';

my $seq    = Bio::Seq->new(-length=>1000);

my $whole  = $bsg->new(-display_name => 'Clone82',
                       -start        => 1,
                       -end          => $seq->length);

my $f1     = $bsg->new(-start        => 100,
                       -end          => 300,
                       -display_name => 'feature 1',
                      );

my $f2      = $bsg->new(-start        => 500,
                        -end          => 800,
                        -display_name => 'feature 2',
                      );

my $panel = Bio::Graphics::Panel->new(-length    => $seq->length,
                                      -width     => 800,
                                      -key_style => 'between',
                                      -pad_left  => 10,
                                      -pad_right => 10,
                                     );

$panel->add_track($whole,
                  -glyph    => 'arrow',
                  -double   => 1,
                  -tick     => 2,
                  -label    => 1,
                  );

$panel->add_track([$f1,$f2],
                  -glyph    => 'fixedwidth',
                  -label    => 1,
                  -fixed_height => 20,
                  -fixed_width  => 20,
                  -key       => 'fixed width');

binmode STDOUT;
print $panel->png;

slay. run that and you get a whole PNG, no thoughts head empty. πŸ¦‹


πŸ’… DESCRIPTION πŸ’…

so this glyph is a base class for glyphs that wanna draw fixed width content β€” think icons, images, scatterplots β€” and it would be so wrong for that content to get stretched out to match the start and end points of its feature. like, imagine being stretched to fit someone else's timeline. no thank you. πŸ™ˆ

instead, the glyph draws:

  • a simple box that spans the feature's start:end region,
  • two diagonal connecting lines,
  • and then a fixed width rectangle sitting beneath the box.

and honestly? this glyph does nothing very interesting by itself. it's the canvas, not the painting. the whole point is that subclasses should override the draw_contents() method to draw something interesting. wanna see how? peek at "Subclassing" for a simple example. iykyk. πŸ’œ


✨ OPTIONS ✨

the standard ones every Glyph gets (yes, all of them)

these are standard among all Glyphs. for the full explanation, go read Bio::Graphics::Glyph. πŸ“–

  • -fgcolor β€” the foreground color β€” default is black
  • -outlinecolor β€” literally a synonym for -fgcolor
  • -bgcolor β€” the background color β€” default is turquoise
  • -fillcolor β€” literally a synonym for -bgcolor
  • -linewidth β€” line width β€” default is 1
  • -height β€” height of the glyph β€” default is 10
  • -font β€” the glyph font β€” default is gdSmallFont
  • -connector β€” connector type β€” default is 0 (false)
  • -connector_color β€” connector color β€” default is black
  • -label β€” whether to draw a label β€” default is 0 (false)
  • -description β€” whether to draw a description β€” default is 0 (false)
  • -hilite β€” highlight color β€” default is undef (no color)

the extra ones that only the fixedwidth glyph gets 🎁

  • -fixed_width β€” width of the content β€” default is 0
  • -fixed_height β€” height of the content β€” default is Same as -height
  • -fixed_gap β€” the vertical gap between the box that shows the extent of the feature and the fixed-width content β€” default is 8
⚠️ heads up bestie: if -fixed_gap is less than 8, then the diagonal connecting lines are not drawn. that's just how it is. πŸ’€

🧚 EXAMPLE SUBCLASS 🧚

wanna draw something interesting inside that fixed rectangle? override the draw_contents method, periodt. it takes four arguments, which are the GD object plus the left, top, right and bottom coordinates of the fixed rectangle. like so:

package Bio::Graphics::Glyph::fixedexample;
use strict;
use base 'Bio::Graphics::Glyph::fixedwidth';

sub draw_contents {
  my $self = shift;
  my ($gd,$left,$top,$right,$bottom) = @_;
  $self->unfilled_box($gd,$left,$top,$right,$bottom);
  $gd->line($left,$top,$right,$bottom,$self->fgcolor);
  $gd->line($left,$bottom,$right,$top,$self->fgcolor);
}

1;

this draws the outline of the fixed rectangle, and the rectangle contains two diagonal lines. not very interesting, but an example, nonetheless. it's giving "hello world" energy and honestly? valid. ✨

for a more interesting subclass, go look at the stackedplot glyph. that one ate. πŸ”₯


😭 BUGS AND LIMITATIONS 😭

this glyph should be used as the base for the image glyph, but isn't. this will be fixed. (we've all been there, bestie β€” the glow-up is pending.) 🫢


🌈 SEE ALSO 🌈

go read all of these, they're the whole friend group:

Bio::Graphics::Panel, Bio::Graphics::Glyph, Bio::Graphics::Glyph::arrow, Bio::Graphics::Glyph::cds, Bio::Graphics::Glyph::crossbox, Bio::Graphics::Glyph::diamond, Bio::Graphics::Glyph::dna, Bio::Graphics::Glyph::dot, Bio::Graphics::Glyph::ellipse, Bio::Graphics::Glyph::extending_arrow, Bio::Graphics::Glyph::generic, Bio::Graphics::Glyph::graded_segments, Bio::Graphics::Glyph::heterogeneous_segments, Bio::Graphics::Glyph::line, Bio::Graphics::Glyph::pinsertion, Bio::Graphics::Glyph::primers, Bio::Graphics::Glyph::rndrect, Bio::Graphics::Glyph::segments, Bio::Graphics::Glyph::ruler_arrow, Bio::Graphics::Glyph::toomany, Bio::Graphics::Glyph::transcript, Bio::Graphics::Glyph::transcript2, Bio::Graphics::Glyph::translation, Bio::Graphics::Glyph::triangle, Bio::DB::GFF, Bio::SeqI, Bio::SeqFeatureI, Bio::Das, GD


πŸ‘‘ AUTHOR πŸ‘‘

Lincoln Stein <lstein@cshl.org>

Copyright (c) 2007 Cold Spring Harbor Laboratory

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.


and that's the whole page, bestie πŸ’– this was perl v5.30.0, dated 2019-11-25, from the Bio::G...dwidth(3pm) manpage. mwah, go forth and subclass responsibly. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from