view release on metacpan or search on metacpan
- Fixed problem of mismatch and indel colors leaking off ends of feature arrows.
2.14
- Fixes to the way that "fast bump" works so that tracks never fast bump.
This fixes problems when using groups to simulate subtracks, and the
groups are of different heights.
- The group glyph will now add the group labels to the list of track keys
stored in the panel and retrieved from the call to $panel->key_boxes().
2.13
- Changed default namespace for callbacks to make them portable across freeze/thaw
cycles.
2.12 Tue Aug 31 10:42:06 EDT 2010
- Created a read_pairs glyph that contains the settings most often used for SAM paired end reads/mate pairs;
this fixes the mate-pairs overlap bug.
- xyplot glyph now obeys "flip" setting.
2.11 Tue Jun 29 15:37:03 EDT 2010
- Cleaned up stylesheet-based rendering of features when the main glyph has a type of
"hat" and subfeatures overlap with each other. This occurred when rendering certain
DAS sources.
2.10 Mon May 24 13:58:26 PDT 2010
- Fixed a long-standing but rarely-seen bug in layout algorithm that
caused some features to be displaced downward further than they should
be.
- Added support for labeling groups (on the left side). This is used by
GBrowse to create subtracks.
2.09 Fri May 14 11:46:51 EDT 2010
- Fixed Bio::Graphics::FeatureFile cached callbacks so that they are evaluated
in the same package as they were when the file was originally evaluated and cached.
2.08 Thu May 13 17:06:29 EDT 2010
- Fixed Bio::Graphics::FeatureFile init_code so that it is reinvoked when retrieving a
cached copy of parsed featurefiles.
2.07 Sun May 9 11:56:10 EDT 2010
- Added FeatureFile->cachedir argument to help with GBrowse tests.
2.06 Wed May 5 00:51:00 EDT 2010
eg/testit.pl view on Meta::CPAN
);
$panel->unshift_track(generic => [$segment,$zk154_1,$zk154_2,$zk154_3,[$xyz4,$zed_27]],
-label => sub { my $feature = shift; $feature->sub_SeqFeature>0},
-bgcolor => sub { shift->primary_tag eq 'predicted' ? 'olive' : 'red'},
-connector => sub { my $feature = shift;
my $type = $feature->primary_tag;
$type eq 'group' ? 'dashed'
: $type eq 'transcript' ? 'hat'
: $type eq 'alignment' ? 'solid'
: undef},
-all_callbacks => 1,
-connector_color => 'black',
-height => 10,
-bump => 1,
-linewidth=>2,
# -tkcolor => $colors[rand @colors],
-key => 'Signs',
);
my $track = $panel->add_track('transcript2',
-label => sub { $_[-1]->level == 0 } ,
-connector => sub { return shift->type eq 'group' ? 'dashed' : ''},
-point => 0,
-orient => 'N',
-height => 8,
-base => 1,
-relative_coords => 1,
-tick => 2,
-all_callbacks => 1,
-bgcolor => 'red',
-key => 'Dynamically Added');
$track->add_feature($bigone,$zed_27,$abc3);
$track->add_group($predicted_exon1,$predicted_exon2,$confirmed_exon3);
$panel->add_track(
[$abc3,$zed_27,$partial_gene],
-bgcolor => sub { shift->source_tag eq 'predicted' ? 'green' : 'blue'},
-glyph => 'transcript',
# -glyph => sub { my $feature = shift;
lib/Bio/Graphics/Glyph.pm view on Meta::CPAN
# breaking encapsulation - this should be handled by the panel
my $key = $self->option('key') || '';
return $key unless $self->panel->add_category_labels;
my $category = $self->option('category');
my $name = defined $category ? "$key ($category)" : $key;
return $name;
}
sub all_callbacks {
my $self = shift;
return $self->{all_callbacks} if exists $self->{all_callbacks}; # memoize
return $self->{all_callbacks} = $self->_all_callbacks;
}
sub _all_callbacks {
my $self = shift;
my $track_level = $self->option('all_callbacks');
return $track_level if defined $track_level;
return $self->panel->all_callbacks;
}
sub subpart_callbacks {
my $self = shift;
return $self->{subpart_callbacks} if exists $self->{subpart_callbacks}; # memoize
return $self->{subpart_callbacks} = $self->_subpart_callbacks;
}
sub _subpart_callbacks {
my $self = shift;
return 1 if $self->all_callbacks;
my $do_subparts = $self->option('subpart_callbacks');
return $self->{level} == 0 || ($self->{level} > 0 && $do_subparts);
}
sub default_factory {
croak "no default factory implemented";
}
sub finished {
my $self = shift;
delete $self->{factory};
lib/Bio/Graphics/Glyph.pm view on Meta::CPAN
Get the Bio::Graphics::Panel associated with this object. This cannot
be changed once it is set.
=item $feature = $glyph-E<gt>feature
Get the sequence feature associated with this object. This cannot be
changed once it is set.
=item $feature = $glyph-E<gt>parent_feature()
Within callbacks only, the parent_feature() method returns the parent
of the current feature, if there is one. Called with a numeric
argument, ascends the parentage tree: parent_feature(1) will return
the parent, parent_feature(2) will return the grandparent, etc. If
there is no parent, returns undef.
=item $feature = $glyph-E<gt>add_feature(@features)
Add the list of features to the glyph, creating subparts. This is
most common done with the track glyph returned by
Bio::Graphics::Panel-E<gt>add_track().
lib/Bio/Graphics/Glyph/cds.pm view on Meta::CPAN
-name => $self->option('key'),
-phase=> 1,
-strand=> +1,
));
$feature;
}
# never allow our components to bump
sub bump {
my $self = shift;
return $self->SUPER::bump(@_) if $self->all_callbacks;
return 0;
}
1;
__END__
=head1 NAME
Bio::Graphics::Glyph::cds - The "cds" glyph
lib/Bio/Graphics/Glyph/decorated_transcript.pm view on Meta::CPAN
chr1 my_source mRNA 74796 75599 . + . ID=rna_gene-1;protein_decorations=SignalP40:SP:1:23:0:my_comment,TMHMM:TM:187:209:0
Each protein decoration consists of six fields separated by a colon:
1) Type. For example used to specify decoration source (e.g. 'SignalP40')
2) Name. Decoration name. Used as decoration label by default (e.g. 'SP' for signal peptide)
3) Start. Start coordinate at the protein-level (1-based coordinate)
4) End. End coordinate at the protein-level
5) Score. Optional. Score associated with a decoration (e.g. Pfam E-value). This score can be used
to dynamically filter or color decorations via callbacks (see glyph options).
6) Description. Optional. User-defined description of decoration. The glyph ignores this description,
but it will be made available to callback functions for inspection. Special characters
like ':' or ',' that might interfere with the GFF tag parser should be avoided.
If callback functions are used as glyph parameters (see below), the callback is called for each
decoration separately. That is, the callback can be called multiple times for the same CDS feature,
but each time with a different decoration. The currently drawn (active) decoration is made available
to the callback via the glyph method 'active_decoration'. The active decoration is returned in form
of a Bio::Graphics::Feature object, with decoration data fields mapped to corresponding feature
attributes in the following way:
lib/Bio/Graphics/Glyph/decorated_transcript.pm view on Meta::CPAN
my $f = Bio::Graphics::Feature->new
(
-type => $type,
-name => $name,
-start => $nt_start,
-end => $nt_end,
-score => $score,
-desc => $desc,
-seq_id => $feature->seq_id,
-strand => $feature->strand,
-attributes => { # remember protein coordinates for callbacks
'p_start' => $p_start,
'p_end' => $p_end
}
);
# my $mapped_decoration = "$h:$nt_start:$nt_end";
push( @mapped_decorations, $f );
# init stack offset for stacked decorations
if ($self->decoration_position($f) eq 'stacked_bottom')
lib/Bio/Graphics/Glyph/decorated_transcript.pm view on Meta::CPAN
Start coordinate at the protein-level (1-based coordinate)
=item 4. end
End coordinate at the protein-level
=item 5. score
Optional. Score associated with a decoration (e.g. Pfam E-value). This score can be used
to dynamically filter or color decorations via callbacks (see glyph options).
=item 6. description
Optional. User-defined description of decoration. The glyph ignores this description,
but it will be made available to callback functions for inspection. Special characters
like ':' or ',' that might interfere with the GFF tag parser should be avoided.
=back
If callback functions are used as glyph parameters (see below), the callback is called for each
lib/Bio/Graphics/Glyph/generic.pm view on Meta::CPAN
return $self->{labelheight} ||= $self->string_height($self->labelfont);
}
sub label_position {
my $self = shift;
return $self->{labelposition} ||= $self->option('label_position') || 'top';
}
sub label {
my $self = shift;
return if $self->{overbumped}; # set by the bumper when we have hit bump limit
return unless $self->subpart_callbacks; # returns true if this is level 0 or if subpart callbacks allowed
return $self->_label if $self->{level} >= 0;
return exists $self->{label} ? $self->{label}
: ($self->{label} = $self->_label);
}
sub description {
my $self = shift;
return if $self->{overbumped}; # set by the bumper when we have hit bump limit
return unless $self->subpart_callbacks; # returns true if this is level 0 or if subpart callbacks allowed
return $self->_description if $self->{level} > 0;
return exists $self->{description} ? $self->{description}
: ($self->{description} = $self->_description);
}
sub part_labels {
my $self = shift;
my @parts = $self->parts;
return ($self->{level} == 0) && @parts && @parts>1 && $self->option('part_labels');
}
lib/Bio/Graphics/Glyph/group.pm view on Meta::CPAN
'left',
'Position in which to draw the group label.'
],
}
}
# group sets connector to 'dashed'
sub connector {
my $self = shift;
my $super = $self->SUPER::connector(@_);
return $super if $self->all_callbacks;
return 'dashed' unless defined($super) && ($super eq 'none' or !$super);
}
# we don't label group (yet)
sub label { my $self = shift;
return $self->{_group_label} if exists $self->{_group_label};
return $self->{_group_label} = $self->option('group_label') ? $self->feature->display_name : ''
}
sub labelfont {
lib/Bio/Graphics/Glyph/rndrect.pm view on Meta::CPAN
$poly->addPt($x1, $y2);
}
$gd->filledPolygon($poly,$self->fillcolor);
$gd->polygon($poly,$self->fgcolor);
}
# group sets connector to 'solid'
sub connector {
my $self = shift;
return $self->SUPER::connector(@_) if $self->all_callbacks;
return 'solid';
}
sub bump {
my $self = shift;
return $self->SUPER::bump(@_) if $self->all_callbacks;
return 0;
}
1;
=head1 NAME
Bio::Graphics::Glyph::rndrect - The "round rect" glyph
lib/Bio/Graphics/Glyph/segments.pm view on Meta::CPAN
if ($self->draw_protein_target) {
return $height unless $self->protein_fits;
}
my $fontheight = $self->mono_font->height;
return $fontheight if $fontheight > $height;
}
# group sets connector to 'solid'
sub connector {
my $self = shift;
return $self->SUPER::connector(@_) if $self->all_callbacks;
return ($self->SUPER::connector(@_) || 'solid');
}
# never allow our components to bump
sub bump {
my $self = shift;
my $bump = $self->SUPER::bump(@_);
return $bump if $self->all_callbacks;
return $self->parts_overlap ? $bump : 0;
}
sub maxdepth {
my $self = shift;
my $md = $self->Bio::Graphics::Glyph::maxdepth;
return $md if defined $md;
return 1;
}
lib/Bio/Graphics/Glyph/track.pm view on Meta::CPAN
package Bio::Graphics::Glyph::track;
use strict;
use base qw(Bio::Graphics::Glyph);
# track sets connector to empty
sub connector {
my $self = shift;
return $self->SUPER::connector(@_) if $self->all_callbacks;
return 'none';
}
sub draw {
my $self = shift;
my ($gd,$left,$top,$partno,$total_parts) = @_;
# the clipping code here prevents poorly-behaving glyphs from
# drawing outside the track
my @clip;
lib/Bio/Graphics/Glyph/transcript.pm view on Meta::CPAN
}
sub arrow_length {
my $self = shift;
return $self->option('arrow_length') || 8;
}
# override option() for force the "hat" type of connector
sub connector {
my $self = shift;
return $self->SUPER::connector(@_) if $self->all_callbacks;
return ($self->option('connector') || 'hat');
}
1;
__END__
=head1 NAME
lib/Bio/Graphics/Glyph/transcript2.pm view on Meta::CPAN
$self->filled_box($gd,@rect);
}
# copied from generic::draw_component
$self->draw_translation($gd,@_) if $self->{cds_translation}; # created earlier by calculate_cds()
$self->draw_sequence($gd,@_) if $self->option('draw_dna') && $self->dna_fits;
}
sub bump {
my $self = shift;
return $self->SUPER::bump(@_) if $self->all_callbacks;
return 0; # never allow our components to bump
}
1;
__END__
=head1 NAME
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
my $length = $options{-length} || 0;
my $offset = $options{-offset} || 0;
my $spacing = $options{-spacing} || 5;
my $bgcolor = $options{-bgcolor} || 'white';
my $keyfont = $options{-key_font} || KEYLABELFONT;
my $keycolor = $options{-key_color} || KEYCOLOR;
my $keyspacing = $options{-key_spacing} || KEYSPACING;
my $keystyle = $options{-key_style} || KEYSTYLE;
my $keyalign = $options{-key_align} || KEYALIGN;
my $suppress_key = $options{-suppress_key} || 0;
my $allcallbacks = $options{-all_callbacks} || 0;
my $gridcolor = $options{-gridcolor} || GRIDCOLOR;
my $gridmajorcolor = $options{-gridmajorcolor} || GRIDMAJORCOLOR;
my $grid = $options{-grid} || 0;
my $extend_grid = $options{-extend_grid}|| 0;
my $flip = $options{-flip} || 0;
my $empty_track_style = $options{-empty_tracks} || 'key';
my $autopad = defined $options{-auto_pad} ? $options{-auto_pad} : 1;
my $truecolor = $options{-truecolor} || 0;
my $truetype = $options{-truetype} || 0;
my $image_class = ($options{-image_class} && $options{-image_class} =~ /SVG/)
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
spacing => $spacing,
key_font => $keyfont,
key_color => $keycolor,
key_spacing => $keyspacing,
key_style => $keystyle,
key_align => $keyalign,
suppress_key => $suppress_key,
background => $background,
postgrid => $postgrid,
autopad => $autopad,
all_callbacks => $allcallbacks,
truecolor => $truecolor,
truetype => $truetype,
flip => $flip,
linkrule => $linkrule,
titlerule => $titlerule,
targetrule => $targetrule,
empty_track_style => $empty_track_style,
image_class => $image_class,
image_package => $image_class . '::Image', # Accessors
polygon_package => $image_class . '::Polygon',
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
$l = $l->length if ref($l) && $l->can('length');
$self->{length} = $l;
}
$d;
}
sub gridcolor {shift->{gridcolor}}
sub gridmajorcolor {shift->{gridmajorcolor}}
sub all_callbacks { shift->{all_callbacks} }
sub add_track {
my $self = shift;
$self->_do_add_track(scalar(@{$self->{tracks}}),@_);
}
sub unshift_track {
my $self = shift;
$self->_do_add_track(0,@_);
}
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
the key in "between" mode ("key"),
to draw a thin grey line ("line"),
or to draw a dashed line ("dashed").
-flip flip the drawing coordinates left false
to right, so that lower coordinates
are to the right. This can be
useful for drawing (-) strand
features.
-all_callbacks Whether to invoke callbacks on false
the automatic "track" and "group"
glyphs.
-grid Whether to draw a vertical grid in false
the background. Pass a scalar true
value to have a grid drawn at
regular intervals (corresponding
to the minor ticks of the arrow
glyph). Pass an array reference
to draw the grid at the specified
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
-part_label_merge Whether to merge undef (false)
adjacent subparts when
labeling.
-connector Type of connector to none
use to connect related
features. Options are
"solid," "hat", "dashed",
"quill" and "none".
-all_callbacks Whether to invoke undef
callbacks for autogenerated
"track" and "group" glyphs
-subpart_callbacks Whether to invoke false
callbacks for subparts of
the glyph.
-box_subparts Return boxes around feature 0
subparts rather than around the
feature itself.
-link, -title, -target
These options are used when creating imagemaps
for display on the web. See L</"Creating Imagemaps">.
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
}
When you install a callback for a feature that contains subparts, the
callback will be invoked first for the top-level feature, and then for
each of its subparts (recursively). You should make sure to examine
the feature's type to determine whether the option is appropriate.
Also be aware that some options are only called for subfeatures. For
example, when using multi-segmented features, the "bgcolor" and
"fgcolor" options apply to the subfeatures and not to the whole
feature; therefore the corresponding callbacks will only be invoked
for the subfeatures and not for the top-level feature. To get
information that applies to the top-level feature, use the glyph's
parent_feature() method. This returns:
* the parent if called with no arguments or with an argument of (1)
* the parent's parent if called with an argument of (2)
* the parent's parent's parent if called with an argument of (3)
* etc.
The general way to take advantage of this feature is:
lib/Bio/Graphics/Panel.pm view on Meta::CPAN
# do something which results in $option_value being set
return $option_value;
}
Some glyphs deliberately disable recursion into subparts. The
"track", "group", "transcript", "transcript2" and "segments" glyphs
selectively disable the -bump, -label and -description options. This
is to avoid, for example, a label being attached to each exon in a
transcript, or the various segments of a gapped alignment bumping each
other. You can override this behavior and force your callback to be
invoked by providing add_track() with a true B<-all_callbacks>
argument. In this case, you must be prepared to handle configuring
options for the "group" and "track" glyphs.
In particular, this means that in order to control the -bump option
with a callback, you should specify -all_callbacks=E<gt>1, and turn on
bumping when the callback is in the track or group glyphs.
The -subpart_callbacks options is similar, except that when this is
set to true callbacks are invoked for the main glyph and its
subparts. This option only affects the -label and -description
options.
=head2 ACCESSORS
The following accessor methods provide access to various attributes of
the panel object. Called with no arguments, they each return the
current value of the attribute. Called with a single argument, they
set the attribute and return its previous value.
t/BioGraphics.t view on Meta::CPAN
is $feature->end,100;
is $feature->strand,-1;
# minus strand feature, minus strand ref
$ref = $bfg->new(-seq_id=>'chr2',-start=>201,-end=>300,-strand=>-1);
$feature->refseq($ref);
is $feature->start,100; # expect flipping so that start > end
is $feature->end,1;
is $feature->strand,1;
# test safety of callbacks
is $data->safe,0;
is ref $data->setting(SwissProt=>'fill'),'';
is eval{ref $data->code_setting(SwissProt=>'fill')},undef;
$data = Bio::Graphics::FeatureFile->new(-file => File::Spec->catfile($Bin,'data', 'feature_data.txt'),
-safe => 1,
) or die;
is $data->safe,1;
is ref $data->setting(SwissProt=>'fill'),'CODE';
t/BioGraphics.t view on Meta::CPAN
);
$panel->unshift_track(generic => [$segment,$zk154_1,$zk154_2,$zk154_3,[$xyz4,$zed_27]],
-label => sub { my $feature = shift; $feature->sub_SeqFeature>0},
-bgcolor => sub { shift->primary_tag eq 'predicted' ? 'olive' : 'red'},
-connector => sub { my $feature = shift;
my $type = $feature->primary_tag;
$type eq 'group' ? 'dashed'
: $type eq 'transcript' ? 'hat'
: $type eq 'alignment' ? 'solid'
: undef},
-all_callbacks => 1,
-connector_color => 'black',
-height => 10,
-bump => 1,
-linewidth=>2,
-key => 'Signs',
-empty_tracks => 'suppress',
);
my $track = $panel->add_track(-glyph=> sub { shift->primary_tag =~ /transcript|alignment/ ? 'transcript2': 'generic'},
-label => sub { $_[-1]->level == 0 } ,
-connector => sub { return shift->type eq 'group' ? 'dashed' : 'hat'},
-point => 0,
-orient => 'N',
-height => 8,
-base => 1,
-relative_coords => 1,
-tick => 2,
-all_callbacks => 1,
-bgcolor => 'red',
-key => 'Dynamically Added');
$track->add_feature($bigone,$zed_27,$abc3);
$track->add_group($predicted_exon1,$predicted_exon2,$confirmed_exon3);
$panel->add_track(
[$abc3,$zed_27,$partial_gene],
-bgcolor => sub { shift->source_tag eq 'predicted' ? 'green' : 'blue'},
-glyph => 'transcript',
-label => sub { shift->sub_SeqFeature > 0 },