Bioperl: SeqIO drivers
hilmar.lapp@pharma.Novartis.com
hilmar.lapp@pharma.Novartis.com
Wed, 10 May 2000 17:58:30 +0100
Ewan Birney <birney@ebi.ac.uk> on 10.05.2000 12:06:54
> # install a driver for your own format, which you've put in mydriver.pm
> # and the files end in .fmt, you call the format myfmt
> %driver_spec = ('MODULE' => 'mydriver.pm', 'REGEXP' => "\\.fmt\$");
> Bio::SeqIO->registerDriver("myfmt", %driver_spec);
> # then from anywhere in the program
> $seqin = Bio::SeqIO->new('-file' => 'input.fmt'); # will return an object
> # of mydriver.pm
Hilmar - as far as I can see the only change you are making is that you
can change the hash of
file_extension => SeqIO/xxxxxx.pm
is that correct? Is there something I am missing here?
First, my version of SeqIO does not use such a key at all nor is there
anything in the documentation, but maybe I've messed my source dist (main
trunk). (BTW it is even better that it doesn't provide this because the
present code makes some undocumented and subtle assumptions, namely that
the 'driver' does not implement new() but _new() instead.)
Second, provided that I understand correctly what you mean, your suggestion
would be static. That is, first I have to name the driver explicitely each
time I open a stream, and second, any 'internal' code opening such a stream
are unaffected, they'd still use the builtin driver. By internal I mean any
code behind an API (of course, in perl you can always hack the code,
because there's no binary, but that's not what you're supposed to do). To
give an example, if I wished to replace the GenBank parser with my own one,
I can specify it this way as an hard-coded argument to Bio::SeqIO->new(),
but I cannot interfere with the way the Bio::DB objects turn (=parse) an
entry retrieved from GenBank into a Bio::Seq object. The latter would still
use the builtin parser.
Is there something I'm missing?
Hilmar
>
> # to replace a driver for an existing format with your own:
> %driver_spec = Bio::SeqIO->getDriver("fasta");
> # retain the format recognition expression, just replace the module name
> $driver_spec{'MODULE'} = "myfasta.pm";
> # and re-install
> Bio::SeqIO->registerDriver("fasta", %driver_spec);
> # then from anyhwere in your program
> $seqin = Bio::SeqIO->new('-file' => 'seqs.fasta'); # will now return an object
> # of myfasta.pm
>
=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================