[Bioperl-guts-l] [14977] bioperl-live/trunk: restored the ability of add_feature() to set the feature's type.
Lincoln Stein
lstein at dev.open-bio.org
Sat Nov 1 14:46:31 EDT 2008
Revision: 14977
Author: lstein
Date: 2008-11-01 14:46:30 -0400 (Sat, 01 Nov 2008)
Log Message:
-----------
restored the ability of add_feature() to set the feature's type. Unfortunately side-effect: feature is actually altered during this operation
Modified Paths:
--------------
bioperl-live/trunk/Bio/Graphics/FeatureFile.pm
bioperl-live/trunk/t/BioGraphics.t
Modified: bioperl-live/trunk/Bio/Graphics/FeatureFile.pm
===================================================================
--- bioperl-live/trunk/Bio/Graphics/FeatureFile.pm 2008-11-01 18:28:15 UTC (rev 14976)
+++ bioperl-live/trunk/Bio/Graphics/FeatureFile.pm 2008-11-01 18:46:30 UTC (rev 14977)
@@ -673,8 +673,9 @@
=item $features-E<gt>add_feature($feature [=E<gt>$type])
Add a new Bio::FeatureI object to the set. If $type is specified, the
-object will be added with the indicated type. Otherwise, the
-feature's primary_tag() method will be invoked to get the type.
+object's primary_tag() will be set to that type. Otherwise, the method
+will use the feature's existing primary_tag() to index and store the
+feature.
=back
@@ -686,7 +687,7 @@
my $self = shift;
my ($feature,$type) = @_;
$feature->configurator($self) if $self->smart_features;
- $type = $feature->primary_tag unless defined $type;
+ $feature->primary_tag($type) if defined $type;
$self->db->store($feature);
}
Modified: bioperl-live/trunk/t/BioGraphics.t
===================================================================
--- bioperl-live/trunk/t/BioGraphics.t 2008-11-01 18:28:15 UTC (rev 14976)
+++ bioperl-live/trunk/t/BioGraphics.t 2008-11-01 18:46:30 UTC (rev 14977)
@@ -19,7 +19,7 @@
use lib 't/lib';
use BioperlTest;
- test_begin(-tests => 45 + (IMAGE_TESTS ? 3 : 0),
+ test_begin(-tests => 48 + (IMAGE_TESTS ? 3 : 0),
-requires_modules => [qw(GD)]);
use_ok('Bio::Graphics::FeatureFile');
@@ -76,6 +76,27 @@
is $data->setting(EST=>'fgcolor'),'#EE00FF';
is $data->setting(EST=>'link'),'http://www.google.com/search?q=$name#results';
+# test handling of adding features
+$data->add_type(TEST=>{bgcolor=>'green',
+ feature=>'test_feature',
+ glyph => 'generic'});
+is $data->setting(TEST=>'bgcolor'),'green';
+is $data->setting(TEST=>'feature'),'test_feature';
+$data->add_feature(Bio::Graphics::FeatureBase->new(-seq_id => 'chr1',
+ -start => 1,
+ -end => 1000,
+ -primary_tag=> 'test_feature'));
+$data->add_feature(Bio::Graphics::FeatureBase->new(-seq_id => 'chr2',
+ -start => 2,
+ -end => 2000,
+ -primary_tag=> 'test_feature'));
+$data->add_feature(Bio::Graphics::FeatureBase->new(-seq_id => 'chr3',
+ -start => 3,
+ -end => 3000),
+ 'test_feature');
+my @f = $data->features('test_feature');
+is scalar @f,3;
+
# test FeatureBase
my $bfg = 'Bio::Graphics::FeatureBase';
$feature = $bfg->new(-seq_id=>'chr2',-start=>201,-end=>300,-strand=>1);
More information about the Bioperl-guts-l
mailing list