~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to doc/howto/examples/graphics/render_features.pl

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
# file: embl2picture.pl
4
 
# This is code example 5 in the Graphics-HOWTO
5
 
# Author: Lincoln Stein
6
 
 
7
 
use strict;
8
 
use lib "$ENV{HOME}/projects/bioperl-live";
9
 
use Bio::Graphics;
10
 
use Bio::SeqIO;
11
 
use Bio::SeqFeature::Generic;
12
 
 
13
 
my $file = shift                       or die "provide a sequence file as the argument";
14
 
my $io = Bio::SeqIO->new(-file=>$file) or die "couldn't create Bio::SeqIO";
15
 
my $seq = $io->next_seq                or die "couldn't find a sequence in the file";
16
 
my $wholeseq = Bio::SeqFeature::Generic->new(-start=>1,-end=>$seq->length,
17
 
                                             -display_name=>$seq->display_name);
18
 
 
19
 
my @features = $seq->all_SeqFeatures;
20
 
 
21
 
# sort features by their primary tags
22
 
my %sorted_features;
23
 
for my $f (@features) {
24
 
  my $tag = $f->primary_tag;
25
 
  push @{$sorted_features{$tag}},$f;
26
 
}
27
 
 
28
 
my $panel = Bio::Graphics::Panel->new(
29
 
                                      -length    => $seq->length,
30
 
                                      -key_style => 'between',
31
 
                                      -width     => 800,
32
 
                                      -pad_left  => 10,
33
 
                                      -pad_right => 10,
34
 
                                      );
35
 
$panel->add_track($wholeseq,
36
 
                  -glyph => 'arrow',
37
 
                  -bump => 0,
38
 
                  -double=>1,
39
 
                  -tick => 2);
40
 
 
41
 
$panel->add_track($wholeseq,
42
 
                  -glyph  => 'generic',
43
 
                  -bgcolor => 'blue',
44
 
                  -label  => 1,
45
 
                 );
46
 
 
47
 
# general case
48
 
my @colors = qw(cyan orange blue purple green chartreuse magenta yellow aqua);
49
 
my $idx    = 0;
50
 
for my $tag (sort keys %sorted_features) {
51
 
  my $features = $sorted_features{$tag};
52
 
  $panel->add_track($features,
53
 
                    -glyph    =>  'generic',
54
 
                    -bgcolor  =>  $colors[$idx++ % @colors],
55
 
                    -fgcolor  => 'black',
56
 
                    -font2color => 'red',
57
 
                    -key      => "${tag}s",
58
 
                    -bump     => +1,
59
 
                    -height   => 8,
60
 
                    -label    => 1,
61
 
                    -description => 1,
62
 
                   );
63
 
}
64
 
 
65
 
print $panel->png;
66
 
exit 0;
67