def caf_to_fastq(infile, outfile, min_length=<NUM_LIT:0>, trim=False):
caf_reader = caf.file_reader(infile)<EOL>fout = utils.open_file_write(outfile)<EOL>for c in caf_reader:<EOL><INDENT>if trim:<EOL><INDENT>if c.clip_start is not None and c.clip_end is not None:<EOL><INDENT>c.seq.seq = c.seq.seq[c.clip_start:c.clip_end + <NUM_LIT:1>]<EOL>c.seq.qual = c.seq.qual[c.clip_start:c.clip_end + <NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>', c.id, file=sys.stderr)<EOL><DEDENT><DEDENT>if len(c.seq) >= min_length:<EOL><INDENT>print(c.seq, file=fout)<EOL><DEDENT><DEDENT>utils.close(fout)<EOL>
Convert a CAF file to fastq. Reads shorter than min_length are not output. If clipping information is in the CAF file (with a line Clipping QUAL ...) and trim=True, then trim the reads