9
use vars qw( $USAGE %VALIDFORMATS);
11
%VALIDFORMATS = ( 'png' => 1,
18
$USAGE = "usage:\tchaos_plot -i/--input=INPUTFILE -f/--format=SEQFORMAT \n".
19
"\t-o/--output=OUTPUTFILE -g/--graphics=GRAPHIC TYPE\n".
20
"\t-w/--width=600 -h/--height=400\n";
22
$USAGE .= "\tValid graphics formats: (" . join(",", ( keys %VALIDFORMATS )) .")\n";
23
$USAGE .= "\tImage size defaults to 600x400, SEQFORMAT to fasta\n";
24
$USAGE .= "\tINPUTFILE can also be read from STDIN\n";
26
my ($format,$graph,$width,$height,$seqfile,$output) = ('fasta', 'png', 600, 400);
27
GetOptions( "i|input:s" => \$seqfile,
28
"f|format:s" => \$format,
29
"o|output:s" => \$output,
30
"g|graph|graphics:s" => \$graph,
32
"height:i" => \$height
35
if( ! $output || ! $VALIDFORMATS{$graph} ) {
39
$seqfile = shift unless $seqfile;
40
if( defined $seqfile ) {
41
print "Could not open file [$seqfile]\n$USAGE" and exit unless -e $seqfile;
42
$seqin = new Bio::SeqIO(-format => $format,
45
$seqin = new Bio::SeqIO(-format => $format,
49
my $img = new GD::Image($width,$height);
50
my $white = $img->colorAllocate(255,255,255);
51
my $black = $img->colorAllocate(0,0,0);
53
my $seq = $seqin->next_seq;
54
die("Sequence type must be DNA not " . $seq->alphabet())
55
unless $seq->alphabet ne 'dna' or $seq->alphabet ne 'rna';
57
my $len = $seq->length();
60
my ($x,$y) = ( 0.5, 0.5);
61
$img->string(gdGiantFont, 1,1, 'A', $black);
62
$img->string(gdGiantFont, 0,$height - 15, 'C', $black);
63
$img->string(gdGiantFont, $width - 15,1, 'T', $black);
64
$img->string(gdGiantFont, $width - 15,$height -20, 'G', $black);
66
for( my $i = 1; $i <= $len; $i++ ) {
68
my $base = lc $seq->subseq($i,$i);
72
} elsif ( $base eq 'g' ) {
73
$x = ( $x + 1.0 ) * 0.5;
74
$y = ( $y + 1.0 ) * 0.5;
75
} elsif ( $base eq 'c' ) {
77
$y = ( $y + 1.0 ) * 0.5;
78
} elsif ( $base eq 't' or $base eq 'u' ) {
79
$x = ( $x + 1.0 ) * 0.5;
83
$img->setPixel($x * $width,$y * $height, $black);
85
open(OUT, ">$output");
87
$graph =~ s/jpg/jpeg/;
89
print OUT $img->$graph();
96
chaos_plot - a chaos plot from DNA and RNA sequences
100
chaos_plot.pl -i/--input=INPUTFILE -f/--format=SEQFORMAT
101
-o/--output=OUTPUTFILE -g/--graphics=GRAPHIC FORMAT
102
-w/--width=WIGHT -h/--height=HEIGHT
106
This scripts generates image files using GD image library to visualize
107
nucleotide sequences using chaos plot.
111
Valid graphics formats are currently gd, gd2, png, wbmp, jpeg and gif.
113
The default size of the image file is 600x400.
115
The sequence input can be provided using any of the three methods:
119
=item unnamed argument
125
chaos_plot -i filename
129
chaos_plot < filename
137
User feedback is an integral part of the evolution of this and other
138
Bioperl modules. Send your comments and suggestions preferably to
139
the Bioperl mailing list. Your participation is much appreciated.
141
bioperl-l@bioperl.org - General discussion
142
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
144
=head2 Reporting Bugs
146
Report bugs to the Bioperl bug tracking system to help us keep track
147
of the bugs and their resolution. Bug reports can be submitted via the
150
https://redmine.open-bio.org/projects/bioperl/
152
=head1 AUTHOR - Jason Stajich
154
Email jason@bioperl.org
158
This code is based on EMBOSS C code for chaos.c by Ian Longden.
159
Included are documentation from EMBOSS code:
161
Chaos produces a chaos plot. The original application is part of the
162
ACEDB genome database package, written by ** Richard Durbin (MRC LMB,
163
UK) rd@mrc-lmba.cam.ac.uk, and Jean Thierry-Mieg (CRBM du CNRS,
164
France) mieg@crbm1.cnusc.fr