Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > c0b2316b5320756fc35b43f35335d7ce > files > 144

perl-AcePerl-1.920.0-1mdv2010.0.i586.rpm

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ace::Graphics::Panel - PNG graphics of Ace::Sequence::Feature objects</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">


<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<!--

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#methods">METHODS</a></li>
	<ul>

		<li><a href="#constructors">CONSTRUCTORS</a></li>
		<li><a href="#object_methods">OBJECT METHODS</a></li>
		<li><a href="#accessors">ACCESSORS</a></li>
		<li><a href="#internal_methods">INTERNAL METHODS</a></li>
	</ul>

	<li><a href="#bugs">BUGS</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
	<li><a href="#author">AUTHOR</a></li>
</ul>

-->


</div>
<!-- INDEX END -->

<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Ace::Graphics::Panel - PNG graphics of Ace::Sequence::Feature objects</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
  use Ace::Sequence;
  use Ace::Graphics::Panel;</pre>
<pre>
  my $db     = Ace-&gt;connect(-host=&gt;'brie2.cshl.org',-port=&gt;2005) or die;
  my $cosmid = Ace::Sequence-&gt;new(-seq=&gt;'Y16B4A',
                                  -db=&gt;$db,-start=&gt;-15000,-end=&gt;15000) or die;</pre>
<pre>
  my @transcripts = $cosmid-&gt;transcripts;</pre>
<pre>
  my $panel = Ace::Graphics::Panel-&gt;new(
                                      -segment =&gt; $cosmid,
                                      -width  =&gt; 800
                                     );</pre>
<pre>
  $panel-&gt;add_track(arrow =&gt; $cosmid,
                  -bump =&gt; 0,
                  -tick=&gt;2);</pre>
<pre>
  $panel-&gt;add_track(transcript =&gt; \@transcripts,
                    -fillcolor =&gt;  'wheat',
                    -fgcolor   =&gt;  'black',
                    -key       =&gt; 'Curated Genes',
                    -bump      =&gt;  +1,
                    -height    =&gt;  10,
                    -label     =&gt;  1);</pre>
<pre>
  my $boxes = $panel-&gt;boxes;
  print $panel-&gt;png;</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The Ace::Graphics::Panel class provides drawing and formatting
services for Ace::Sequence::Feature objects or Das::Segment::Feature
objects.</p>
<p>Typically you will begin by creating a new Ace::Graphics::Panel
object, passing it the width of the visual display and the length of
the segment.</p>
<p>You will then call <a href="#add_track"><code>add_track()</code></a> one or more times to add sets of
related features to the picture.  When you have added all the features
you desire, you may call <a href="#png"><code>png()</code></a> to convert the image into a PNG-format
image, or <a href="#boxes"><code>boxes()</code></a> to return coordinate information that can be used to
create an imagemap.</p>
<p>Note that this modules depends on GD.</p>
<p>
</p>
<hr />
<h1><a name="methods">METHODS</a></h1>
<p>This section describes the class and object methods for
Ace::Graphics::Panel.</p>
<p>
</p>
<h2><a name="constructors">CONSTRUCTORS</a></h2>
<p>There is only one constructor, the <a href="#new"><code>new()</code></a> method.</p>
<dl>
<dt><strong><a name="new" class="item">$panel = Ace::Graphics::Panel-&gt;<code>new(@options)</code></a></strong>

<dd>
<p>The <a href="#new"><code>new()</code></a> method creates a new panel object.  The options are
a set of tag/value pairs as follows:</p>
</dd>
<dd>
<pre>
  Option      Value                                Default
  ------      -----                                -------</pre>
</dd>
<dd>
<pre>
  -length     Length of sequence segment, in bp    0</pre>
</dd>
<dd>
<pre>
  -segment    An Ace::Sequence or Das::Segment     none
              object, used to derive length if
              not provided</pre>
</dd>
<dd>
<pre>
  -offset     Base pair to place at extreme left   $segment-&gt;start
              of image.</pre>
</dd>
<dd>
<pre>
  -width      Desired width of image, in pixels    600</pre>
</dd>
<dd>
<pre>
  -spacing    Spacing between tracks, in pixels    5</pre>
</dd>
<dd>
<pre>
  -pad_top    Additional whitespace between top    0
              of image and contents, in pixels</pre>
</dd>
<dd>
<pre>
  -pad_bottom Additional whitespace between top    0
              of image and bottom, in pixels</pre>
</dd>
<dd>
<pre>
  -pad_left   Additional whitespace between left   0
              of image and contents, in pixels</pre>
</dd>
<dd>
<pre>
  -pad_right  Additional whitespace between right  0
              of image and bottom, in pixels</pre>
</dd>
<dd>
<pre>
  -keycolor   Background color for the key printed 'cornsilk'
              at bottom of panel (if any)</pre>
</dd>
<dd>
<pre>
  -keyspacing Spacing between key glyphs in the    10
              key printed at bottom of panel
              (if any)</pre>
</dd>
<dd>
<p>Typically you will pass <a href="#new"><code>new()</code></a> an object that implements the
Bio::RangeI interface, providing a <code>length()</code> method, from which the
panel will derive its scale.</p>
</dd>
<dd>
<pre>
  $panel = Ace::Graphics::Panel-&gt;new(-segment =&gt; $sequence,
                                     -width   =&gt; 800);</pre>
</dd>
<dd>
<p><a href="#new"><code>new()</code></a> will return undef in case of an error. If the specified glyph
name is not a valid one, <a href="#new"><code>new()</code></a> will throw an exception.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="object_methods">OBJECT METHODS</a></h2>
<dl>
<dt><strong><a name="add_track" class="item">$track = $panel-&gt;<code>add_track($glyph,$features,@options)</code></a></strong>

<dd>
<p>The <a href="#add_track"><code>add_track()</code></a> method adds a new track to the image.</p>
</dd>
<dd>
<p>Tracks are horizontal bands which span the entire width of the panel.
Each track contains a number of graphical elements called &quot;glyphs&quot;,
each corresponding to a sequence feature. There are different glyph
types, but each track can only contain a single type of glyph.
Options passed to the track control the color and size of the glyphs,
whether they are allowed to overlap, and other formatting attributes.
The height of a track is determined from its contents and cannot be
directly influenced.</p>
</dd>
<dd>
<p>The first two arguments are the glyph name and an array reference
containing the list of features to display.  The order of the
arguments is irrelevant, allowing either of these idioms:</p>
</dd>
<dd>
<pre>
  $panel-&gt;add_track(arrow =&gt; \@features);
  $panel-&gt;add_track(\@features =&gt; 'arrow');</pre>
</dd>
<dd>
<p>The glyph name indicates how each feature is to be rendered.  A
variety of glyphs are available, and the number is growing.
Currently, the following glyphs are available:</p>
</dd>
<dd>
<pre>
  Name        Description
  ----        -----------</pre>
</dd>
<dd>
<pre>
  box         A filled rectangle, nondirectional.</pre>
</dd>
<dd>
<pre>
  ellipse     A filled ellipse, nondirectional.</pre>
</dd>
<dd>
<pre>
  arrow       An arrow; can be unidirectional or bidirectional.
              It is also capable of displaying a scale with
              major and minor tickmarks, and can be oriented
              horizontally or vertically.</pre>
</dd>
<dd>
<pre>
  segments    A set of filled rectangles connected by solid lines.
              Used for interrupted features, such as gapped
              alignments.</pre>
</dd>
<dd>
<pre>
  transcript  Similar to segments, but the connecting line is
              a &quot;hat&quot; shape, and the direction of transcription
              is indicated by a small arrow.</pre>
</dd>
<dd>
<pre>
  transcript2 Similar to transcript, but the arrow that indicates
              the direction of transcription is the last exon
              itself.</pre>
</dd>
<dd>
<pre>
  primers     Two inward pointing arrows connected by a line.
              Used for STSs.</pre>
</dd>
<dd>
<pre>
  toomany     A &quot;cloud&quot;, to indicate too many features to show
              individually.  This is a placeholder that will be
              replaced by something more clever, such as a histogram
              or density plot.</pre>
</dd>
<dd>
<pre>
  group       A group of related features connected by a dashed line.
              This is used internally by the Track class and should
              not be called explicitly.</pre>
</dd>
<dd>
<p>If the glyph name is omitted from <a href="#add_track"><code>add_track()</code></a>, the &quot;box&quot; glyph will be
used by default.</p>
</dd>
<dd>
<p>The @options array is a list of name/value pairs that control the
attributes of the track.  The options are in turn passed to the
glyphs.  Each glyph has its own specialized subset of options, but
some are shared by all glyphs:</p>
</dd>
<dd>
<pre>
  Option      Description               Default
  ------      -----------               -------</pre>
</dd>
<dd>
<pre>
  -glyph      Glyph to use              none</pre>
</dd>
<dd>
<pre>
  -fgcolor    Foreground color          black</pre>
</dd>
<dd>
<pre>
  -outlinecolor                         black
              Synonym for -fgcolor</pre>
</dd>
<dd>
<pre>
  -bgcolor    Background color          white</pre>
</dd>
<dd>
<pre>
  -fillcolor  Interior color of filled  turquoise
              images</pre>
</dd>
<dd>
<pre>
  -linewidth  Width of lines drawn by   1
                    glyph</pre>
</dd>
<dd>
<pre>
  -height     Height of glyph           10</pre>
</dd>
<dd>
<pre>
  -font       Glyph font                gdSmallFont</pre>
</dd>
<dd>
<pre>
  -label      Whether to draw a label   false</pre>
</dd>
<dd>
<pre>
  -bump       Bump direction            0</pre>
</dd>
<dd>
<pre>
  -connect_groups                       false
              Connect groups by a
              dashed line (see below)</pre>
</dd>
<dd>
<pre>
  -key        Show this track in the    undef
              key</pre>
</dd>
<dd>
<p>Colors can be expressed in either of two ways: as symbolic names such
as &quot;cyan&quot; and as HTML-style #RRGGBB triples.  The symbolic names are
the 140 colors defined in the Netscape/Internet Explorer color cube,
and can be retrieved using the Ace::Graphics::Panel-&gt;<a href="#color_names"><code>color_names()</code></a>
method.</p>
</dd>
<dd>
<p>The background color is used for the background color of the track
itself.  The foreground color controls the color of lines and strings.
The interior color is used for filled objects such as boxes.</p>
</dd>
<dd>
<p>The -label argument controls whether or not the ID of the feature
should be printed next to the feature.  It is accepted by most, but
not all of the glyphs.</p>
</dd>
<dd>
<p>The -bump argument controls what happens when glyphs collide.  By
default, they will simply overlap (value 0).  A -bump value of +1 will
cause overlapping glyphs to bump downwards until there is room for
them.  A -bump value of -1 will cause overlapping glyphs to bump
upwards.</p>
</dd>
<dd>
<p>The -key argument declares that the track is to be shown in a key
appended to the bottom of the image.  The key contains a picture of a
glyph and a label describing what the glyph means.  The label is
specified in the argument to -key.</p>
</dd>
<dd>
<p>If present, the -glyph argument overrides the glyph given in the first
or second argument.</p>
</dd>
<dd>
<p><a href="#add_track"><code>add_track()</code></a> returns an Ace::Graphics::Track object.  You can use this
object to add additional features or to control the appearance of the
track with greater detail, or just ignore it.  Tracks are added in
order from the top of the image to the bottom.  To add tracks to the
top of the image, use <a href="#unshift_track"><code>unshift_track()</code></a>.</p>
</dd>
<dd>
<p>Typical usage is:</p>
</dd>
<dd>
<pre>
 $panel-&gt;add_track( thistle    =&gt; \@genes,
                    -fillcolor =&gt;  'green',
                    -fgcolor   =&gt;  'black',
                    -bump      =&gt;  +1,
                    -height    =&gt; 10,
                    -label     =&gt; 1);</pre>
</dd>
</li>
<dt><strong><a name="unshift_track" class="item">$track = <code>unshift_track($glyph,$features,@options)</code></a></strong>

<dd>
<p><a href="#unshift_track"><code>unshift_track()</code></a> works like <a href="#add_track"><code>add_track()</code></a>, except that the new track is
added to the top of the image rather than the bottom.</p>
</dd>
<dd>
<p><strong>Adding groups of features:</strong> It is not uncommon to add a group of
features which are logically connected, such as the 5' and 3' ends of
EST reads.  To group features into sets that remain on the same
horizontal position and bump together, pass the sets as an anonymous
array.  To connect the groups by a dashed line, pass the
-connect_groups argument with a true value.  For example:</p>
</dd>
<dd>
<pre>
  $panel-&gt;add_track(segments =&gt; [[$abc_5,$abc_3],
                                 [$xxx_5,$xxx_3],
                                 [$yyy_5,$yyy_3]],
                    -connect_groups =&gt; 1);</pre>
</dd>
</li>
<dt><strong><a name="gd" class="item">$gd = $panel-&gt;gd</a></strong>

<dd>
<p>The <a href="#gd"><code>gd()</code></a> method lays out the image and returns a GD::Image object
containing it.  You may then call the GD::Image object's <a href="#png"><code>png()</code></a> or
<code>jpeg()</code> methods to get the image data.</p>
</dd>
</li>
<dt><strong><a name="png" class="item">$png = $panel-&gt;png</a></strong>

<dd>
<p>The <a href="#png"><code>png()</code></a> method returns the image as a PNG-format drawing, without
the intermediate step of returning a GD::Image object.</p>
</dd>
</li>
<dt><strong><a name="boxes" class="item">$boxes = $panel-&gt;boxes</a></strong>

<dt><strong>@boxes = $panel-&gt;boxes</strong>

<dd>
<p>The <a href="#boxes"><code>boxes()</code></a> method returns the coordinates of each glyph, useful for
constructing an image map.  In a scalar context, <a href="#boxes"><code>boxes()</code></a> returns an
array ref.  In an list context, the method returns the array directly.</p>
</dd>
<dd>
<p>Each member of the list is an anonymous array of the following format:</p>
</dd>
<dd>
<pre>
  [ $feature, $x1, $y1, $x2, $y2 ]</pre>
</dd>
<dd>
<p>The first element is the feature object; either an
Ace::Sequence::Feature, a Das::Segment::Feature, or another Bioperl
Bio::SeqFeatureI object.  The coordinates are the topleft and
bottomright corners of the glyph, including any space allocated for
labels.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="accessors">ACCESSORS</a></h2>
<p>The following accessor methods provide access to various attributes of
the panel object.  Called with no arguments, they each return the
current value of the attribute.  Called with a single argument, they
set the attribute and return its previous value.</p>
<p>Note that in most cases you must change attributes prior to invoking
<a href="#gd"><code>gd()</code></a>, <a href="#png"><code>png()</code></a> or <a href="#boxes"><code>boxes()</code></a>.  These three methods all invoke an internal
<code>layout()</code> method which places the tracks and the glyphs within them,
and then caches the result.</p>
<pre>
   Accessor Name      Description
   -------------      -----------</pre>
<pre>
   width()            Get/set width of panel
   spacing()          Get/set spacing between tracks
   length()           Get/set length of segment (bp)
   pad_top()          Get/set top padding
   pad_left()         Get/set left padding
   pad_bottom()       Get/set bottom padding
   pad_right()        Get/set right padding</pre>
<p>
</p>
<h2><a name="internal_methods">INTERNAL METHODS</a></h2>
<p>The following methods are used internally, but may be useful for those
implementing new glyph types.</p>
<dl>
<dt><strong><a name="color_names" class="item">@names = Ace::Graphics::Panel-&gt;color_names</a></strong>

<dd>
<p>Return the symbolic names of the colors recognized by the panel
object.  In a scalar context, returns an array reference.</p>
</dd>
</li>
<dt><strong><a name="rgb" class="item">@rgb = $panel-&gt;<code>rgb($index)</code></a></strong>

<dd>
<p>Given a GD color index (between 0 and 140), returns the RGB triplet
corresponding to this index.  This method is only useful within a
glyph's <code>draw()</code> routine, after the panel has allocated a GD::Image and
is populating it.</p>
</dd>
</li>
<dt><strong><a name="translate" class="item">$index = $panel-&gt;<code>translate($color)</code></a></strong>

<dd>
<p>Given a color, returns the GD::Image index.  The color may be
symbolic, such as &quot;turquoise&quot;, or a #RRGGBB triple, as in #F0E0A8.
This method is only useful within a glyph's <code>draw()</code> routine, after the
panel has allocated a GD::Image and is populating it.</p>
</dd>
</li>
<dt><strong><a name="set_pen" class="item">$panel-&gt;<code>set_pen($width,$color)</code></a></strong>

<dd>
<p>Changes the width and color of the GD drawing pen to the values
indicated.  This is called automatically by the GlyphFactory <code>fgcolor()</code>
method.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p>Please report them.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="/AcePerl/docs/./Ace/Sequence.html">the Ace::Sequence manpage</a>,<a href="/AcePerl/docs/./Ace/Sequence/Feature.html">the Ace::Sequence::Feature manpage</a>,
<a href="/AcePerl/docs/./Ace/Graphics/Track.html">the Ace::Graphics::Track manpage</a>,<a href="/AcePerl/docs/./Ace/Graphics/Glyph.html">the Ace::Graphics::Glyph manpage</a>,
<em>GD</em></p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Lincoln Stein &lt;<a href="mailto:lstein@cshl.org">lstein@cshl.org</a>&gt;.</p>
<p>Copyright (c) 2001 Cold Spring Harbor Laboratory</p>
<p>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.</p>

</body>

</html>