code: def write_mates(self):
          '''Scan the current chromosome for matches to any of the reads stored
          in the read1s buffer'''
          if self.chrom is not None:
              U.debug("Dumping %i mates for contig %s" % (
                  len(self.read1s), self.chrom))
  
          for read in self.infile.fetch(reference=self.chrom, multiple_iterators=True):
              if any((read.is_unmapped, read.mate_is_unmapped, read.is_read1)):
                  continue
  
              key = read.query_name, read.reference_name, read.reference_start
              if key in self.read1s:
                  self.outfile.write(read)
                  self.read1s.remove(key)
  
          U.debug("%i mates remaining" % len(self.read1s)f write_mates(self):
          '''Scan the current chromosome for matches to any of the reads stored
          in the read1s buffer'''
          if self.chrom is not None:
              U.debug("Dumping %i mates for contig %s" % (
                  len(self.read1s), self.chrom))
  
          for read in self.infile.fetch(reference=self.chrom, multiple_iterators=True):
              if any((read.is_unmapped, read.mate_is_unmapped, read.is_read1)):
                  continue
  
              key = read.query_name, read.reference_name, read.reference_start
              if key in self.read1s:
                  self.outfile.write(read)
                  self.read1s.remove(key)
  
          U.debug("%i mates remaining" % len(self.read1s))
docs: Scan the current chromosome for matches to any of the reads stored
          in the read1s buffer