NAME

Bio::Das::Stylesheet - Access to DAS stylesheets

SYNOPSIS

  use Bio::Das;

  # contact the DAS server at wormbase.org (0.18 version API)
  my $das      = Bio::Das->new('http://www.wormbase.org/db/das'=>'elegans');

  # get the stylesheet
  my $style    = $das->stylesheet;

  # get features
  my @features = $das->segment(-ref=>'Locus:unc-9')->features;

  # for each feature, ask the stylesheet what glyph to use
  for my $f (@features) {
    my ($glyph_name,@attributes) = $style->glyph($f);
  }

DESCRIPTION

The Bio::Das::Stylesheet class contains information about a remote DAS server's preferred visualization style for sequence features. Each server has zero or one stylesheets for each of the data sources it is responsible for. Stylesheets can provide stylistic guidelines for broad feature categories (such as "transcription"), or strict guidelines for particular feature types (such as "Prosite motif").

The glyph names and attributes are broadly compatible with the Bio::Graphics library.

OBJECT CREATION

Bio::Das::Stylesheets are created by the Bio::Das object in response to a call to the stylesheet() method. The Bio::Das object must previously have been associated with a data source.

METHODS

($glyph,@attributes) = $stylesheet->glyph($feature)

The glyph() method takes a Bio::Das::Segment::Feature object and returns the name of a suggested glyph to use, plus zero or more attributes to apply to the glyph. Glyphs names are described in the DAS specification, and include terms like "box" and "arrow".

Attributes are name/value pairs, for instance:

   (-width => '10', -outlinecolor => 'black')

The initial "-" is added to the attribute names to be consistent with the Perl name/value calling style. The attribute list can be passed directly to the Ace::Panel->add_track() method.

In a scalar context, glyph() will return just the name of the glyph without the attribute list.

@categories = $stylesheet->categories

Return a list of all the categories known to the stylesheet.

$source = $stylesheet->source

Return the Bio::Das object associated with the stylesheet.

HOW GLYPH() RESOLVES FEATURES

When a feature is passed to glyph(), the method checks the feature's type ID and category against the stylesheet. If an exact match is found, then the method returns the corresponding glyph name and attributes. Otherwise, glyph() looks for a default style for the category and returns the glyph and attributes for that. If no category default is found, then glyph() returns its global default.

USING Bio::Das::Stylesheet WITH Bio::Graphics::Panel

The stylesheet class was designed to work hand-in-glove with Bio::Graphics::Panel. You can rely entirely on the stylesheet to provide the glyph name and attributes, or provide your own default attributes to fill in those missing from the stylesheet.

It is important to bear in mind that Bio::Graphics::Panel only allows a single glyph type to occupy a horizontal track. This means that you must sort the different features by type, determine the suggested glyph for each type, and then create the tracks.

The following code fragment illustrates the idiom. After sorting the features by type, we pass the first instance of each type to glyph() in order to recover a glyph name and attributes applicable to the entire track.

  use Bio::Das;
  use Bio::Graphics::Panel;

  my $das        = Bio::Das->new('http://www.wormbase.org/db/das'=>'elegans');
  my $stylesheet = $das->stylesheet;
  my $segment    = $das->segment(-ref=>'Locus:unc-9');
  @features      = $segment->features;

  my %sort;
  for my $f (@features) {
     my $type = $f->type;
     # sort features by their type, and push them onto anonymous
     # arrays in the %sort hash.
     push @{$sort{$type}},$f;   
  }
  my $panel = Bio::Graphics::Panel->new( -segment => $segment,
                                         -width   => 800 );
  for my $type (keys %sort) {
      my $features = $sort{$type};
      my ($glyph,@attributes) = $stylesheet->glyph($features->[0]);
      $panel->add_track($features=>$glyph,@attributes);
  }

To provide your own default attributes to be used in place of those omitted by the stylesheet, just change the last line so that your own attributes follow those provided by the stylesheet:

      $panel->add_track($features=>$glyph,
                        @attributes,
                        -connectgroups => 1,
                        -key           => 1,
                        -labelcolor    => 'chartreuse'
                        );

AUTHOR

Lincoln Stein <lstein@cshl.org>.

Copyright (c) 2001 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.

SEE ALSO

Bio::Das, Bio::Graphics::Panel, Bio::Graphics::Track

1 POD Error

The following errors were encountered while parsing the POD:

Around line 227:

You forgot a '=back' before '=head2'