[Bioperl-l] GFF, seq features and Bio::Graphics

Lincoln Stein lstein@cshl.org
Sun, 21 Jul 2002 10:03:15 -0700


Hi Fernan,

What you are requesting is very reasonable.  I will make a change to
the behavior of Panel so that instead of a size zero track, you will
get a track containing a single thin line.  Please comment on this
API:

my $panel = Bio::Graphics::Panel->new(
				      -gridcolor    => 'lightcyan',
				      -grid         => 1,
				      -segment      => $segment,
				      -spacing      => 15,
				      -width        => 600,
				      -key_style    => 'between',
				      -empty_tracks => 'line',
				     );

where -empty_tracks is one of "line", "dotted_line", or "empty".

This will go into bioperl-live at some point in the next week, but
might take a long time to get into the bioperl release (1.2).  If you
are uncomfortable working with prerelease software, I suggest you try
a workaround like the following:

  if (@features) {
    $panel->add_track(generic => \@features);
  } else {
    my $dummy = Bio::Graphics::Feature->new(-start=>1,-end=>$whole_length);
    $panel->add_track(generic => [$dummy],
                      -height => 1,
                      -fgcolor => 'grey');
 }

Lincoln


Fernan Aguero writes:
 > Hi!
 > 
 > After a hard time trying to make sense of internal relationships
 > between bioperl (I haven't had worked much with seqfeatures before in
 > bioperl) ... I basically got things working, but there are some
 > gotchas still around.
 > 
 > Basically I have some contigs, blast info summarized into GFF files
 > and sequences independently stored as fasta files.
 > 
 > Contig1.gff
 > Contig1.fa
 > 
 > 
 > With this I drawed a nice graphic using Bio::Graphics::Panel (see
 > Script 1 below).
 > 
 > However, I'd like to have more control on the output (and draw
 > features on their corresponding strands and translation frames,
 > perhaps). 
 > 
 > I'm trying to:
 > 
 > read the whole GFF file like this:
 > while (<GFF>) {
 > 	$feat = new Bio::SeqFeature::Generic (-gff_string	=> $_ );
 > 	$seq->add_SeqFeature($feat);
 > }
 > 
 > I then get an array of features for each strand and,
 > foreach feature on each strand
 > 	if $frame = 0 -> add_track (\@features)
 > 	if $frame = 1 -> add_track ...
 > 	...
 > 	and so on.
 > 
 > The idea is to have 3 tracks above and 3 tracks below the sequence
 > (the sequence itself is the track in the middle).
 > 
 > The problem I'm having is that empty tracks don't get drawed in the
 > graphic (i.e. if there are no features in a particular strand/frame).
 > Personally it is a lot clearer if all strands/frames are in the
 > graphic (no glyphs in case there are no features).
 > 
 > Is is possible to draw a thin line without glyphs for an empty
 > strand/frame? (Is it possible to create an empty or fake seq feature
 > object? Currently I don't imagine how to do it ...)
 > 
 > Thanks in advance for any tip or suggestion,
 > 
 > Fernan
 > 
 > 
 > ===========
 > =-Script1-=
 > ===========
 > 
 > use Bio::Graphics::FeatureFile;
 > use Bio::Graphics::Panel;
 > use Bio::SeqIO;
 > 
 > my $seqio = new Bio::SeqIO ( -file => $seqFile, -format => 'fasta');
 > my $seq   = $seqio->next_seq();
 > 															
 > # create the panel
 > my $panel = new Bio::Graphics::Panel ( -segment			=> $seq,
 >                                        -key_style		=> 'between',
 > 																			 -key_color		=> '#cccccc',
 > 																			 -pad_top			=> 5,
 > 																			 -pad_bottom	=> 5,
 > 																			 -pad_left		=> 5,
 > 																			 -pad_right		=> 95,
 > 																			 -grid				=> 1,
 > 																			 -grid_color	=> '#ff0000',
 > 																			 -width				=> 500);
 > 																			 
 > # add the sequence first to the panel
 > $panel->add_track(  generic => $seq,
 >     								-glyph  => 'arrow',
 >     								-tick   => 2,
 >     								-label  => 1,
 >     								-key    => $seq->id() );
 > 
 > my $data  = Bio::Graphics::FeatureFile->new(-file => $gffFile);
 > $data->render($panel);
 > # print the image
 > open PNG, ">$pngFile";
 > print PNG $panel->png;
 > close PNG;
 > 
 > 
 > -- 
 > 
 > |  F e r n a n   A g u e r o  |  B i o i n f o r m a t i c s  |
 > |   fernan@iib.unsam.edu.ar   |      genoma.unsam.edu.ar      |
 > _______________________________________________
 > Bioperl-l mailing list
 > Bioperl-l@bioperl.org
 > http://bioperl.org/mailman/listinfo/bioperl-l

-- 
========================================================================
Lincoln D. Stein                           Cold Spring Harbor Laboratory
lstein@cshl.org			                  Cold Spring Harbor, NY
Positions available at my lab: see http://stein.cshl.org/#hire
========================================================================