Bio::SeqFeature::Generic add_track duplicate labels

View: New views
2 Messages — Rating Filter:   Alert me  

Bio::SeqFeature::Generic add_track duplicate labels

by Mark Lewis-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello,

I've been looking for quite some time into a why I'm getting duplicate
labels on sequence features I'm creating with the loop below.  An image of
the output is here:

http://interspersedata.com/pure/pureOTRACK-30449039-CRSPLOT-9973-1.png


The loop:

for ($i = 1; $i <= $numImg; $i++) {
## make a panel to store all the glyphs in this row.  multiple glyphs occur
is they collide due to
## the use of the bump feature.
#
$panel = Bio::Graphics::Panel->new(-length        => $zoom,                
# length of panel in nucleotides
-width         => $imgWidth,               # physical width of img in px
-pad_top       => 10,                      # padding
-pad_bottom    => 10,
-pad_left      => 10,
-pad_right     => 10,
-bgcolor       => $bgColour,              # colors
-grid          => 'true',
-gridcolor     => '#cccccc',
-gridmajorcolor => '#888888',
-all_callbacks => 'true',                  # for coloured URE bars
                                                                                                                               -key_font => 'gdTinyFont',
                                                 -offset        => $offset,              
# decremented by $zoom at loop end
);

## create current scale
#
$end = $offset + $zoom;
if ($end >= 0) {                           # we've gone past the end, so we
go *to* the end of the rope
$end    = -1;
$numImg = 0;                             # this iteration will proceed, but
the next redundant one won't
}

                ## create new generic sequence feature and attach dna
                #
$segment = Bio::SeqFeature::Generic->new(-start=>$offset,-end=>$end);

$panel->add_track($segment,
-glyph     => 'anchored_arrow',
-tick      => 2,
-fontcolor => '#333333', # reference track font colour
-fgcolor   => '#333333', # reference track colour
-bgcolor   => $bgColour
        );

## define glyph track - this contains the glyphs (UREs) - you can have >1
tracks # # # # # # # # # # # #
#
my($track) = $panel->add_track(
                                                                      -glyph     => 'segments',
                                                                      -linewidth => 2,
                                                                      -height    => 8,
                                                                      -fontcolor => $txtCol,
                                                                      -label     => 1,
                                                                                        -description => 1,
                                                                      -bgcolor   => sub {
                                                                        my($feat)  = shift;
                                                                        my($score) = $feat->score;
                                                                        return ($cols[$score]);
                                                                      },
                                                                      -bump        => 1
                                                                    );

## get the data from hash and add it
                ## tabulated results with alternating coloured rows
#
foreach $ure (sort(keys %{$results{$rec}{$str}{ures}})) {
foreach $instance (sort(keys %{$results{$rec}{$str}{ures}{$ure}})) {
#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
## start loc = end location = length = name of URE = sequence of URE =
category of URE = colour
#
#
if ($results{$rec}{$str}{'ures'}{$ure}{$instance} =~
/^(-\d+)=(-\d+)=(\d+)=(.+?)=(.+?)=(.+?)=(.+?)$/) {
$SEQlen   = $3;
$SEQname  = $4;
$SEQstart = $1;
$SEQseq   = $5;
$trueEnd  = $2;
$SEQend   = $2 - 1; # -1 as only 5 segments between start and end
#$SEQcat   = $6;
$SEQcol   = $colours{$7};    # get number from the colours hash
}

if ($SEQstart <= ($offset - ($SEQlen - 1)) || $SEQstart > $end) {    # only
deal with UREs in range
next;
}

## if the sequence is unnamed, use the sequence in the image, its more help
#
if ($SEQname eq "unnamed") {
$SEQname = $SEQseq;
}

                                my($featureId) = "Name: $SEQname<br />Sequence: $SEQseq<br />Location:
$SEQstart → $trueEnd";
my($feature) =
Bio::SeqFeature::Generic->new(-display_name => $SEQname,
-score        => $SEQcol,
-start        => $SEQstart,
-end          => $SEQend,
-tag          => { new => 1,
                                                                                                                                                                                                                                   id => $featureId }
);
$track->add_feature($feature);       ## THIS ADDS A FEATURE WITH
DOUBLE-THE-LABELS
} ## end foreach $instance (sort(keys...
} ## end foreach $ure (keys %ureLocs)

I've been racking my brains for a long time and haven't found a solution.
If I remove the label, both labels are removed.  I'd be over the moon if
someone could at least comment on where they think I might be going wrong
or where I can look.  I've read the CPAN docs several times and cannot see
anything new to try.

Many thanks IA
Mark
--
mq
mindrail.net

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Gmod-gbrowse mailing list
Gmod-gbrowse@...
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse

Re: Bio::SeqFeature::Generic add_track duplicate labels

by Scott Cain-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mark,

This is really a Bio::Graphics question and should probably be asked  
on the bioperl mailing list.  I've seen similar things when I was  
developing the Chado adaptor for GBrowse, but I don't remember what I  
did to cause it or how I fixed it.  When you ask on the bioperl  
mailing list, pleas include sample data that can reproduce the behavior.

Scott


On Oct 29, 2009, at 10:21 PM, mark lewis wrote:

>
> Hello,
>
> I've been looking for quite some time into a why I'm getting duplicate
> labels on sequence features I'm creating with the loop below.  An  
> image of
> the output is here:
>
> http://interspersedata.com/pure/pureOTRACK-30449039-CRSPLOT-9973-1.png
>
>
> The loop:
>
> for ($i = 1; $i <= $numImg; $i++) {
> ## make a panel to store all the glyphs in this row.  multiple  
> glyphs occur
> is they collide due to
> ## the use of the bump feature.
> #
> $panel = Bio::Graphics::Panel->new(-length        => $zoom,
> # length of panel in nucleotides
> -width         => $imgWidth,               # physical width of img  
> in px
> -pad_top       => 10,                      # padding
> -pad_bottom    => 10,
> -pad_left      => 10,
> -pad_right     => 10,
> -bgcolor       => $bgColour,              # colors
> -grid          => 'true',
> -gridcolor     => '#cccccc',
> -gridmajorcolor => '#888888',
> -all_callbacks => 'true',                  # for coloured URE bars
>       -key_font => 'gdTinyFont',
>                                 -offset        => $offset,
> # decremented by $zoom at loop end
> );
>
> ## create current scale
> #
> $end = $offset + $zoom;
> if ($end >= 0) {                           # we've gone past the  
> end, so we
> go *to* the end of the rope
> $end    = -1;
> $numImg = 0;                             # this iteration will  
> proceed, but
> the next redundant one won't
> }
>
> ## create new generic sequence feature and attach dna
> #
> $segment = Bio::SeqFeature::Generic->new(-start=>$offset,-end=>$end);
>
> $panel->add_track($segment,
> -glyph     => 'anchored_arrow',
> -tick      => 2,
> -fontcolor => '#333333', # reference track font colour
> -fgcolor   => '#333333', # reference track colour
> -bgcolor   => $bgColour
> );
>
> ## define glyph track - this contains the glyphs (UREs) - you can  
> have >1
> tracks # # # # # # # # # # # #
> #
> my($track) = $panel->add_track(
>      -glyph     => 'segments',
>      -linewidth => 2,
>      -height    => 8,
>      -fontcolor => $txtCol,
>      -label     => 1,
> -description => 1,
>      -bgcolor   => sub {
>        my($feat)  = shift;
>        my($score) = $feat->score;
>        return ($cols[$score]);
>      },
>      -bump        => 1
>    );
>
> ## get the data from hash and add it
> ## tabulated results with alternating coloured rows
> #
> foreach $ure (sort(keys %{$results{$rec}{$str}{ures}})) {
> foreach $instance (sort(keys %{$results{$rec}{$str}{ures}{$ure}})) {
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=
> #=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
> ## start loc = end location = length = name of URE = sequence of URE =
> category of URE = colour
> #
> #
> if ($results{$rec}{$str}{'ures'}{$ure}{$instance} =~
> /^(-\d+)=(-\d+)=(\d+)=(.+?)=(.+?)=(.+?)=(.+?)$/) {
> $SEQlen   = $3;
> $SEQname  = $4;
> $SEQstart = $1;
> $SEQseq   = $5;
> $trueEnd  = $2;
> $SEQend   = $2 - 1; # -1 as only 5 segments between start and end
> #$SEQcat   = $6;
> $SEQcol   = $colours{$7};    # get number from the colours hash
> }
>
> if ($SEQstart <= ($offset - ($SEQlen - 1)) || $SEQstart > $end)  
> {    # only
> deal with UREs in range
> next;
> }
>
> ## if the sequence is unnamed, use the sequence in the image, its  
> more help
> #
> if ($SEQname eq "unnamed") {
> $SEQname = $SEQseq;
> }
>
> my($featureId) = "Name: $SEQname<br />Sequence: $SEQseq<br /
> >Location:
> $SEQstart → $trueEnd";
> my($feature) =
> Bio::SeqFeature::Generic->new(-display_name => $SEQname,
> -score        => $SEQcol,
> -start        => $SEQstart,
> -end          => $SEQend,
> -tag          => { new => 1,
>   id => $featureId }
> );
> $track->add_feature($feature);       ## THIS ADDS A FEATURE WITH
> DOUBLE-THE-LABELS
> } ## end foreach $instance (sort(keys...
> } ## end foreach $ure (keys %ureLocs)
>
> I've been racking my brains for a long time and haven't found a  
> solution.
> If I remove the label, both labels are removed.  I'd be over the  
> moon if
> someone could at least comment on where they think I might be going  
> wrong
> or where I can look.  I've read the CPAN docs several times and  
> cannot see
> anything new to try.
>
> Many thanks IA
> Mark
> --
> mq
> mindrail.net
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart  
> your
> developing skills, take BlackBerry mobile applications to market and  
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Gmod-gbrowse mailing list
> Gmod-gbrowse@...
> https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse

-----------------------------------------------------------------------
Scott Cain, Ph. D. scott at scottcain dot net
GMOD Coordinator (http://gmod.org/) 216-392-3087
Ontario Institute for Cancer Research





------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gmod-gbrowse mailing list
Gmod-gbrowse@...
https://lists.sourceforge.net/lists/listinfo/gmod-gbrowse