Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Graphics.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 package Bio::Graphics; | |
2 | |
3 use Bio::Graphics::Panel; | |
4 use strict; | |
5 | |
6 use vars '$VERSION'; | |
7 $VERSION = 1.2003; | |
8 | |
9 1; | |
10 | |
11 =head1 NAME | |
12 | |
13 Bio::Graphics - Generate GD images of Bio::Seq objects | |
14 | |
15 =head1 SYNOPSIS | |
16 | |
17 # This script generates a PNG picture of a 10K region containing a | |
18 # set of red features and a set of blue features. Call it like this: | |
19 # red_and_blue.pl > redblue.png | |
20 # you can now view the picture with your favorite image application | |
21 | |
22 | |
23 # This script parses a GenBank or EMBL file named on the command | |
24 # line and produces a PNG rendering of it. Call it like this: | |
25 # render.pl my_file.embl | display - | |
26 | |
27 use strict; | |
28 use Bio::Graphics; | |
29 use Bio::SeqIO; | |
30 | |
31 my $file = shift or die "provide a sequence file as the argument"; | |
32 my $io = Bio::SeqIO->new(-file=>$file) or die "could not create Bio::SeqIO"; | |
33 my $seq = $io->next_seq or die "could not find a sequence in the file"; | |
34 | |
35 my @features = $seq->all_SeqFeatures; | |
36 | |
37 # sort features by their primary tags | |
38 my %sorted_features; | |
39 for my $f (@features) { | |
40 my $tag = $f->primary_tag; | |
41 push @{$sorted_features{$tag}},$f; | |
42 } | |
43 | |
44 my $wholeseq = Bio::SeqFeature::Generic->new(-start=>1,-end=>$seq->length); | |
45 | |
46 my $panel = Bio::Graphics::Panel->new( | |
47 -length => $seq->length, | |
48 -key_style => 'between', | |
49 -width => 800, | |
50 -pad_left => 10, | |
51 -pad_right => 10, | |
52 ); | |
53 $panel->add_track($wholeseq, | |
54 -glyph => 'arrow', | |
55 -bump => 0, | |
56 -double=>1, | |
57 -tick => 2); | |
58 | |
59 $panel->add_track($seq, | |
60 -glyph => 'generic', | |
61 -bgcolor => 'blue', | |
62 -label => 1, | |
63 ); | |
64 | |
65 # general case | |
66 my @colors = qw(cyan orange blue purple green chartreuse magenta yellow aqua); | |
67 my $idx = 0; | |
68 for my $tag (sort keys %sorted_features) { | |
69 my $features = $sorted_features{$tag}; | |
70 $panel->add_track($features, | |
71 -glyph => 'generic', | |
72 -bgcolor => $colors[$idx++ % @colors], | |
73 -fgcolor => 'black', | |
74 -font2color => 'red', | |
75 -key => "${tag}s", | |
76 -bump => +1, | |
77 -height => 8, | |
78 -label => 1, | |
79 -description => 1, | |
80 ); | |
81 } | |
82 | |
83 print $panel->png; | |
84 exit 0; | |
85 | |
86 =head1 DESCRIPTION | |
87 | |
88 Please see L<Bio::Graphics::Panel> for the full interface. | |
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 | |
101 =head1 AUTHOR | |
102 | |
103 Lincoln Stein E<lt>lstein@cshl.orgE<gt>. | |
104 | |
105 Copyright (c) 2001 Cold Spring Harbor Laboratory | |
106 | |
107 This library is free software; you can redistribute it and/or modify | |
108 it under the same terms as Perl itself. See DISCLAIMER.txt for | |
109 disclaimers of warranty. | |
110 | |
111 =cut | |
112 |