Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time



Provides a libxml-based lazy parser for reading through large blast xml files with a small memory footprint.


  • Ruby 1.9.x

  • libxml

If you're on ubuntu, libxml is most easily installed with:

sudo apt-get install libxml-ruby

And then install the gem with

gem install bio-lazyblastxml
# If you need to be root to install gems, try:
sudo gem install bio-lazyblastxml


The parsers uses a LibXML::Reader instance to read the XML file one line at a time, keeping very little in memory. You can think of the parser as having a very short memory, only able to recall the object that it happens to be looking at right now. The parser only runs through the document once unless Bio::LazyBlast#rewind is called.

Example Usage

Each report is an enumerable that yields iterations. Each iteration is an enumerable that yields hits (if there are any hits).

require 'bio-lazyblastxml'

# Generate your new report object
report ='my_huge_blastfile.xml')

# How many hits does each query have?
report.each_iteration do |iteration|
  puts [iteration.query_def, iteration.count].join("\t")

Each hit is an enumerable that yields hsps:

require 'bio-lazyblastxml'

# Generate your new report object
report ='my_huge_blastfile.xml')

report.each_iteration do |iteration|
  iteration.each_hit do |hit|
    # Sum up the lengths of all the hsps
    hsp_length_sum = hit.inject(0){|count,hsp| count += hsp.align_len}
    puts [iteration.query_def, hit.definition, hsp_length_sum].join("\t")

Contributing to bio-lazyblastxml

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 robsyme. See LICENSE.txt for further details.


A plugin that allows you to parse large blast XML output files lazily, reading only what you need.




No packages published


You can’t perform that action at this time.