~ubuntu-branches/ubuntu/trusty/bioperl/trusty-proposed

« back to all changes in this revision

Viewing changes to Bio/Graphics.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package Bio::Graphics;
2
 
 
3
 
use Bio::Graphics::Panel;
4
 
use strict;
5
 
 
6
 
1;
7
 
 
8
 
=head1 NAME
9
 
 
10
 
Bio::Graphics - Generate GD images of Bio::Seq objects
11
 
 
12
 
=head1 SYNOPSIS
13
 
 
14
 
 # This script generates a PNG picture of a 10K region containing a
15
 
 # set of red features and a set of blue features. Call it like this:
16
 
 #         red_and_blue.pl > redblue.png
17
 
 # you can now view the picture with your favorite image application
18
 
 
19
 
 
20
 
 # This script parses a GenBank or EMBL file named on the command
21
 
 # line and produces a PNG rendering of it.  Call it like this:
22
 
 # render.pl my_file.embl | display -
23
 
 
24
 
 use strict;
25
 
 use Bio::Graphics;
26
 
 use Bio::SeqIO;
27
 
 
28
 
 my $file = shift                       or die "provide a sequence file as the argument";
29
 
 my $io = Bio::SeqIO->new(-file=>$file) or die "could not create Bio::SeqIO";
30
 
 my $seq = $io->next_seq                or die "could not find a sequence in the file";
31
 
 
32
 
 my @features = $seq->all_SeqFeatures;
33
 
 
34
 
 # sort features by their primary tags
35
 
 my %sorted_features;
36
 
 for my $f (@features) {
37
 
   my $tag = $f->primary_tag;
38
 
   push @{$sorted_features{$tag}},$f;
39
 
 }
40
 
 
41
 
 my $wholeseq = Bio::SeqFeature::Generic->new(-start=>1,-end=>$seq->length);
42
 
 
43
 
 my $panel = Bio::Graphics::Panel->new(
44
 
                                      -length    => $seq->length,
45
 
                                      -key_style => 'between',
46
 
                                      -width     => 800,
47
 
                                      -pad_left  => 10,
48
 
                                      -pad_right => 10,
49
 
                                      );
50
 
 $panel->add_track($wholeseq,
51
 
                  -glyph => 'arrow',
52
 
                  -bump => 0,
53
 
                  -double=>1,
54
 
                  -tick => 2);
55
 
 
56
 
 $panel->add_track($wholeseq,
57
 
                  -glyph  => 'generic',
58
 
                  -bgcolor => 'blue',
59
 
                  -label  => 1,
60
 
                 );
61
 
 
62
 
 # general case
63
 
 my @colors = qw(cyan orange blue purple green chartreuse magenta yellow aqua);
64
 
 my $idx    = 0;
65
 
 for my $tag (sort keys %sorted_features) {
66
 
   my $features = $sorted_features{$tag};
67
 
   $panel->add_track($features,
68
 
                    -glyph    =>  'generic',
69
 
                    -bgcolor  =>  $colors[$idx++ % @colors],
70
 
                    -fgcolor  => 'black',
71
 
                    -font2color => 'red',
72
 
                    -key      => "${tag}s",
73
 
                    -bump     => +1,
74
 
                    -height   => 8,
75
 
                    -label    => 1,
76
 
                    -description => 1,
77
 
                   );
78
 
 }
79
 
 
80
 
 print $panel->png;
81
 
 exit 0;
82
 
 
83
 
=head1 DESCRIPTION
84
 
 
85
 
Please see L<Bio::Graphics::Panel> for the full interface.
86
 
 
87
 
=head1 SEE ALSO
88
 
 
89
 
L<Bio::Graphics::Panel>,
90
 
L<Bio::Graphics::Glyph>,
91
 
L<Bio::SeqI>,
92
 
L<Bio::SeqFeatureI>,
93
 
L<Bio::Das>,
94
 
L<Bio::DB::GFF::Feature>,
95
 
L<Ace::Sequence>,
96
 
L<GD>
97
 
 
98
 
=head1 FEEDBACK
99
 
 
100
 
=head2 Mailing Lists
101
 
 
102
 
User feedback is an integral part of the evolution of this and other
103
 
Bioperl modules. Send your comments and suggestions preferably to
104
 
the Bioperl mailing list.  Your participation is much appreciated.
105
 
 
106
 
  bioperl-l@bioperl.org                  - General discussion
107
 
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
108
 
 
109
 
=head2 Reporting Bugs
110
 
 
111
 
Report bugs to the Bioperl bug tracking system to help us keep track
112
 
of the bugs and their resolution. Bug reports can be submitted via the
113
 
web:
114
 
 
115
 
  http://bugzilla.open-bio.org/
116
 
 
117
 
=head1 AUTHOR
118
 
 
119
 
Lincoln Stein E<lt>lstein@cshl.orgE<gt>.
120
 
 
121
 
Copyright (c) 2001 Cold Spring Harbor Laboratory
122
 
 
123
 
This library is free software; you can redistribute it and/or modify
124
 
it under the same terms as Perl itself.  See DISCLAIMER.txt for
125
 
disclaimers of warranty.
126
 
 
127
 
=cut
128