code: def chain(args):
      
      p = OptionParser(chain.__doc__)
      p.add_option("--dist", dest="dist",
              default=100, type="int",
              help="extent of flanking regions to search [default: %default]")
  
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      blastfile, = args
      dist = opts.dist
      assert dist > 0
  
      blast = BlastSlow(blastfile)
      logging.debug("A total of {} records imported".format(len(blast)))
      chained_hsps = chain_HSPs(blast, xdist=dist, ydist=dist)
      logging.debug("A total of {} records after chaining".format(len(chained_hsps)))
  
      for b in chained_hsps:
          print(b)
docs: %prog chain blastfile
  
      Chain adjacent HSPs together to form larger HSP.