#!/usr/bin/perl -w use strict; use Bio::Graphics; use Bio::SeqFeature::Generic; chomp (my $file = shift(@ARGV)); open(INPUT, "<$file") or die "Cannot open \"$file\": $!\n"; my @data = ; close INPUT; my $panel; my $flag = 1; my ($feature, $track); foreach(@data) { chomp; next if /^\#/; # ignore comments my ($name, $length, $domain, $score, $start, $end) = split /\t+/; if($flag == 1) { # draw panel $panel = Bio::Graphics::Panel->new(-length => $length, -width => 800, -pad_left => 10, -pad_right => 10, ); # draw reference ruler of size sequence my $full_length = Bio::SeqFeature::Generic->new(-start=>1,-end=>$length); $panel->add_track($full_length, -glyph => 'arrow', -tick => 2, -fgcolor => 'black', -double => 1, -label => "$name", ); $flag = 0; $track = $panel -> add_track(-glyph => sub { my $feat = shift; return ($feat->display_name() eq 'DUMMY1') ? 'line' : 'rndrect'; }, -label => sub { my $feat = shift; my $name = $feat->display_name(); # HACK - returning a space ' ' ensures that the line feature will be centered vertically return ($name eq 'DUMMY1') ? ' ' : $name; }, -bump => 0, -bgcolor => 'blue', -min_score => 0, -max_score => 1000, -font2color => 'red', -sort_order => 'high_score', -description => sub { my $feature = shift; my $score = $feature->score; if ($score =~ /E/) { return "e-value=$score"; } else { return "score=$score"; } }); $feature = Bio::SeqFeature::Generic->new(-display_name=>'DUMMY1', -score=>$score, -start=>1, -end=>$length); } my $subfeature = Bio::SeqFeature::Generic->new(-label =>$domain, -display_name=>$domain, -score=>$score, -start=>$start, -end=>$end); $track->add_feature($subfeature); } $track->add_feature($feature); print $panel -> png; exit;