code: def collect_gaps(blast, use_subject=False):
      
      key = lambda x: x.sstart if use_subject else x.qstart
      blast.sort(key=key)
  
      for a, b in zip(blast, blast[1:]):
          if use_subject:
              if a.sstop < b.sstart:
                  yield b.sstart - a.sstop
          else:
              if a.qstop < b.qstart:
                  yield b.qstart - a.qstop
docs: Collect the gaps between adjacent HSPs in the BLAST file.