def fastqIteratorComplex(fn, useMutableString=False, verbose=False):
fh = fn<EOL>if type(fh).__name__ == "<STR_LIT:str>":<EOL><INDENT>fh = open(fh)<EOL><DEDENT>prevLine = None<EOL>pind = None<EOL>if verbose:<EOL><INDENT>try:<EOL><INDENT>totalLines = linesInFile(fh.name)<EOL>pind = ProgressIndicator(totalToDo=totalLines,<EOL>messagePrefix="<STR_LIT>",<EOL>messageSuffix="<STR_LIT>"<EOL>+ fh.name)<EOL><DEDENT>except AttributeError:<EOL><INDENT>sys.stderr.write("<STR_LIT>"<EOL>+ "<STR_LIT>")<EOL>verbose = False<EOL><DEDENT><DEDENT>while True:<EOL><INDENT>name, prevLine = fastq_complex_parse_seq_header(fh, prevLine,<EOL>pind, verbose)<EOL>seqdata, line = fastq_complex_parse_seq(fh, pind, verbose)<EOL>qualdata, line, prevLine = fastq_complex_parse_qual(fh, line, prevLine,<EOL>verbose, pind)<EOL>yield NGSRead(seqdata, name, qualdata, useMutableString)<EOL>if verbose:<EOL><INDENT>pind.showProgress()<EOL><DEDENT>prevLine = line<EOL>if prevLine == "<STR_LIT>":<EOL><INDENT>break<EOL><DEDENT><DEDENT>
A generator function which yields FastqSequence objects read from a file or
stream. This iterator can handle fastq files that have their sequence
and/or their quality data split across multiple lines (i.e. there are
newline characters in the sequence and quality strings).

:param fn:                 A file-like stream or a string; if this is a
                           string, it's treated as a filename specifying
                           the location of an input fastq file, else it's
                           treated as a file-like object, which must have a
                           readline() method.
:param useMustableString:  if True, construct sequences from lists of
                           chars, rather than python string objects, to
                           allow more efficient editing. Use with caution.
:param verbose:            if True, print messages on progress to stderr.
:param debug:              if True, print debugging messages to stderr.
:param sanger:             if True, assume quality scores are in sanger
                           format. Otherwise, assume they're in Illumina
                           format.