[Bioperl-l] Inheritance Bio::Map::Physical
Sendu Bala
bix at sendu.me.uk
Tue Nov 14 08:49:52 UTC 2006
Keith Anthony Boroevich wrote:
> Hi,
>
> I am using an up-to-date bioperl-live. The precise code is
> insignificant so I wrote some additional (shorter) code to attempt to
> explain my problem. What I want to do is the following. I want to add
> some functionality to the Bio::Map::Physical module so i created a
> module that inherits Physical module, Extended::FPC.pm.
>
> #----Test.pl-BEGIN---#
> use strict;
> use diagnostics;
> use Extended::FPC;
> my $mapio = new Extended::FPC(-format => "fpc",-file =>
> $ARGV[0],-readcor => 1);
> my $map = $mapio->next_map();
> $map->fpc_test();
> exit 0;
> #---Test.pl-END------#
>
> #----Extended::FPC.pm-BEGIN---#
> package Extended::FPC;
> use strict;
> use base qw(Bio::Map::Physical Bio::MapIO);
>
> sub fpc_test {
> print STDERR "testing\n";
> return 0;
> }
>
> 1;
> #----Extended::FPC.pm-END-----#
>
> The execution of test.pl results in a "Can't locate object method
> "next_map" via package "Extended::FPC"" error;
> Then I added the "Bio::MapIO" module to the "use base
> qw(Bio::Map::Physical Bio::MapIO);", because that is the module in which
> next_map is declared.
Well I think alarm bells should have been ringing at that point. I think
you're trying to inherit from the wrong module to do whatever it is you
want to do. Bio::Map::Physical has no next_map() because it isn't a
Map::IO module. It represents a /single/ map (only), and is the sort of
object you might /receive/ as the result of calling next_map() on an
actual Map::IO module.
So perhaps you should take another look at the various Map modules and
figure out the correct thing to inherit from, or you just need to
correct your usage (only call next_map() on a Map::IO).
More information about the Bioperl-l
mailing list