[Bioperl-l] Inheritance Bio::Map::Physical

Nancy Hansen nhansen at nhgri.nih.gov
Wed Nov 15 10:52:05 EST 2006

Keith Anthony Boroevich wrote:
> 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------#

You're right that your Extended::FPC should inherit from
Bio::Map::Physical, but you really don't want to use it to parse the fpc
file (Bio::MapIO does that just fine, and gets all the data you need into
the Bio::Map::Physical object).  Try retrieving a Bio::Map::Physical
object using Bio::MapIO, then forcing it to be an Extended::FPC, which
will allow it to use your method(s):

my $mapio = Bio::MapIO->new(-format => 'fpc',
                            -file => $ARGV[0],
                            -readcor => 1);

my $fpc_map = $mapio->next_map();

bless $fpc_map, Extended::FPC;
my $ra_bands = $fpc_map->my_new_extended_method();

I've actually written my own method to return the band sizes as well, so
it would probably make a good enhancement to Bio::Map::Physical, which
already has a "matching_bands" method that returns the (scalar) number of
bands that match at a given tolerance.  If that method were "enhanced" to
return an array of matching band sizes rather than the scalar number of
bands, it would still return the number in scalar context, but give you
the matching band info in list context.  I'd be happy to submit a patch
for this if others think it's backwardly-compatible enough.


Nancy F. Hansen, PhD	nhansen at nhgri.nih.gov
Bioinformatics Group
NIH Intramural Sequencing Center (NISC)
5625 Fishers Lane
Rockville, MD 20852
Phone: (301) 435-1560	Fax: (301) 435-6170

More information about the Bioperl-l mailing list