def mean_length(infile, limit=None):
total = <NUM_LIT:0><EOL>count = <NUM_LIT:0><EOL>seq_reader = sequences.file_reader(infile)<EOL>for seq in seq_reader:<EOL><INDENT>total += len(seq)<EOL>count += <NUM_LIT:1><EOL>if limit is not None and count >= limit:<EOL><INDENT>break<EOL><DEDENT><DEDENT>assert count > <NUM_LIT:0><EOL>return total / count<EOL>
Returns the mean length of the sequences in the input file. By default uses all sequences. To limit to the first N sequences, use limit=N