def write_stats(datadfs, outputfile, names=[]):
if outputfile == '<STR_LIT>':<EOL><INDENT>output = sys.stdout<EOL><DEDENT>else:<EOL><INDENT>output = open(outputfile, '<STR_LIT>')<EOL><DEDENT>stats = [Stats(df) for df in datadfs]<EOL>features = {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>}<EOL>max_len = max([len(k) for k in features.keys()])<EOL>try:<EOL><INDENT>max_num = max(max([len(str(s.number_of_bases)) for s in stats]),<EOL>max([len(str(n)) for n in names])) + <NUM_LIT:6><EOL><DEDENT>except ValueError:<EOL><INDENT>max_num = max([len(str(s.number_of_bases)) for s in stats]) + <NUM_LIT:6><EOL><DEDENT>output.write("<STR_LIT>".format('<STR_LIT>', max_len,<EOL>"<STR_LIT:U+0020>".join(['<STR_LIT>'.format(n, max_num) for n in names])))<EOL>for f in sorted(features.keys()):<EOL><INDENT>try:<EOL><INDENT>output.write("<STR_LIT>".format(<EOL>f=f + '<STR_LIT::>',<EOL>pad=max_len,<EOL>v=feature_list(stats, features[f], padding=max_num)))<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if all(["<STR_LIT>" in df for df in datadfs]):<EOL><INDENT>long_features = {<EOL>"<STR_LIT>":<EOL>["<STR_LIT>", range(<NUM_LIT:1>, <NUM_LIT:6>)],<EOL>"<STR_LIT>":<EOL>["<STR_LIT>", range(<NUM_LIT:1>, <NUM_LIT:6>)],<EOL>"<STR_LIT>":<EOL>["<STR_LIT>", ["<STR_LIT>" + str(q) for q in stats[<NUM_LIT:0>].qualgroups]],<EOL>}<EOL>for lf in sorted(long_features.keys()):<EOL><INDENT>output.write(lf + "<STR_LIT:\n>")<EOL>for i in range(<NUM_LIT:5>):<EOL><INDENT>output.write("<STR_LIT>".format(<EOL>long_features[lf][<NUM_LIT:1>][i], feature_list(stats, long_features[lf][<NUM_LIT:0>], index=i)))<EOL><DEDENT><DEDENT><DEDENT>
Call calculation functions and write stats file.

    This function takes a list of DataFrames,
    and will create a column for each in the tab separated output.