Ewan Birney


Bio::SearchIO::blastxml - A SearchIO implementation of NCBI Blast XML parsing.


    use Bio::SearchIO;
    my $searchin = new Bio::SearchIO(-format => 'blastxml',
                                     -file   => 't/data/plague_yeast.bls.xml');
    while( my $result = $searchin->next_result ) {

    # one can also request that the parser NOT keep the XML data in memory
    # by using the tempfile initialization flag.
    my $searchin = new Bio::SearchIO(-tempfile => 1,
                                     -format => 'blastxml',
                                     -file   => 't/data/plague_yeast.bls.xml');
    while( my $result = $searchin->next_result ) {


This object implements a NCBI Blast XML parser.

There is one additional initialization flag from the SearchIO defaults - that is the -tempfile flag. If specified as true, then the parser will write out each report to a temporary filehandle rather than holding the entire report as a string in memory. The reason this is done in the first place is NCBI reports have an uncessary <?xml version="1.0"?> at the beginning of each report and RPS-BLAST reports have an additional unecessary RPS-BLAST tag at the top of each report. So we currently have implemented the work around by preparsing the file (yes it makes the process slower, but it works).


Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to the Bioperl mailing list. Your participation is much appreciated.

  bioperl-l@bioperl.org              - General discussion
  http://bioperl.org/MailList.shtml  - About the mailing lists

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track of the bugs and their resolution. Bug reports can be submitted via email or the web:


AUTHOR - Jason Stajich

Email jason@bioperl.org

Describe contact details here


Additional contributors names and emails here


The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _


 Title   : new
 Usage   : my $searchio = new Bio::SearchIO(-format => 'blastxml',
                                            -file   => 'filename',
                                            -tempfile => 1);
 Function: Initializes the object - this is chained through new in SearchIO
 Returns : Bio::SearchIO::blastxml object
 Args    : One additional argument from the format and file/fh parameters.
           -tempfile => boolean.  Defaults to false.  Write out XML data
                                  to a temporary filehandle to send to 
                                  PerlSAX parser.


 Title   : _initialize
 Usage   : private
 Function: Initializes the object - this is chained through new in SearchIO


 Title   : next_result
 Usage   : my $hit = $searchio->next_result;
 Function: Returns the next Result from a search
 Returns : Bio::Search::Result::ResultI object
 Args    : none

SAX methods


 Title   : start_document
 Usage   : $parser->start_document;
 Function: SAX method to indicate starting to parse a new document
 Returns : none
 Args    : none


 Title   : end_document
 Usage   : $parser->end_document;
 Function: SAX method to indicate finishing parsing a new document
 Returns : Bio::Search::Result::ResultI object
 Args    : none


 Title   : start_element
 Usage   : $parser->start_element($data)
 Function: SAX method to indicate starting a new element
 Returns : none
 Args    : hash ref for data


 Title   : end_element
 Usage   : $parser->end_element($data)
 Function: Signals finishing an element
 Returns : Bio::Search object dpending on what type of element
 Args    : hash ref for data


 Title   : characters
 Usage   : $parser->characters($data)
 Function: Signals new characters to be processed
 Returns : characters read
 Args    : hash ref with the key 'Data'


 Title   : use_tempfile
 Usage   : $obj->use_tempfile($newval)
 Function: Get/Set boolean flag on whether or not use a tempfile
 Example : 
 Returns : value of use_tempfile
 Args    : newvalue (optional)