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