[Bioperl-l] Another GuessSeqFormat question

Tim Erwin taerwin at tpg.com.au
Wed Aug 17 03:15:03 EDT 2005


Hi,

Is there a way to determine which parser to use based on the guess from
Bio::Tools::GuessSeqFormat without hard coding a hash? I am interested
in parsing and storing various files to a database.

I was wondering if it is a good idea to make a some extra functions so that files could be parsed automatically.

i.e for a fasta file

my $obj = new Bio::Tools::GuessSeqFormat( -file => $filename );
my $format = $obj->guess;
my $parser = $obj->parser;              #RETURNS Bio::SeqIO
my $next_method = $obj->next_method;    #RETURNS next_seq
my $write_method = $obj->write_method;  #RETURNS write_seq

#PARSE FILE
my $infile = new $parser(-file => $filename, -format => $format);
while (my $result = $infile->$next_method) {

  #DO STUFF HERE
  #ADD $result TO DATABASE

}

Perhaps there is a better way to do this? Any suggestions would be great.

Regards,

Tim



More information about the Bioperl-l mailing list