code: def estimate_read_length(fastq_file, quality_format="fastq-sanger", nreads=1000):
      
  
      in_handle = SeqIO.parse(open_fastq(fastq_file), quality_format)
      read = next(in_handle)
      average = len(read.seq)
      for _ in range(nreads):
          try:
              average = (average + len(next(in_handle).seq)) / 2
          except StopIteration:
              break
      in_handle.close()
      return average
docs: estimate average read length of a fastq file