def writeExpressionResults(outfile, result):
    '''output expression results table.'''
    if outfile == sys.stdout:
        outf = outfile
    else:
        outf = IOTools.openFile(outfile, "w")

    outf.write("%s\n" % "\t".join(GeneExpressionResult._fields))
    for x in sorted(result):
        outf.write("%s\n" % "\t".join(map(str, x)))

    if outf != sys.stdout:
        outf.close()
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Expression.py/writeExpressionResults/original