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