8 my $USAGE = <<END_USAGE;
11 This simple example script reads the ABI data and uses the trace data to
12 generate a SVG-formatted chromatogram. Requires the CPAN SVG module and
13 Bio::SeqIO::staden::read (from bioperl-ext), which itself requires io_lib from
18 my $file = shift || die $USAGE;
23 my $svg = SVG->new(width => $img_width, height => $img_height, xmlns => "http://www.w3.org/2000/svg");
25 my $seq_io = Bio::SeqIO->new( -file => $file, -format => 'abi', -get_trace_data => 1);
27 my $seq = $seq_io->next_seq;
29 my $points = scalar($seq->get_trace_graph( -trace => 'a' ));
31 my @xdata = map { $_ / $points * $img_width } (0..$points-1);
33 my %colours = ( 'a' => 'green', 'c' => 'blue', 'g' => 'black', 't' => 'red' );
34 foreach my $element ('a', 'c', 'g', 't')
36 my @trace = $seq->get_trace_graph( -trace => $element, -scale => $img_height);
37 @trace = map { $img_height - $_ } @trace;
38 my $points = $svg->get_path(-type => 'polyline', -closed => 0, x => \@xdata, y => \@trace);
39 $svg->polyline(%$points, id=> $element, 'stroke-width' => 0.5, stroke => $colours{$element}, 'fill-opacity' => 0, 'fill' => 'white');
43 my $text_group = $svg->group( id => 'text_layer');
44 foreach my $base_loc (@{$seq->trace})
46 $text_group->text(x => ($base_loc / $points * $img_width), y => 50, 'text-anchor' => 'middle', fill => 'black', 'font-size' => '5pt')->cdata(substr($seq->seq,$count,1));