Beispiel #1
0
#!/net/em-stor4/Volumes/data/wangyr/local/bin/python2.7
from argparse import ArgumentParser
from sys import stderr, stdout
import myutil


if __name__=="__main__":
    parser = ArgumentParser()
    parser.add_argument("infile", help="")
    parser.add_argument("-c", "--column", default=2, type=int, help="")
    opts = parser.parse_args()

    data = myutil.get_column_as_list( opts.infile, opts.column, "float" )
    zscore = myutil.cal_zscores_from_list( data )
    lines = open( opts.infile, "r" ).readlines()
    assert len(lines) == len(data), "discrepancy in lines( %s ) and data( %s )" %(len(lines), len(data))

    for idx in range( 0, len(lines) ):
        print lines[idx].strip(), zscore[idx]
    parser = ArgumentParser()
    parser.add_argument("-f", "--files", nargs="+", required=True, help="structures you would like to superimpose to")
    parser.add_argument("-c", "--column", required=True, type=int, help="column")
    parser.add_argument(
        "-m",
        "--stats_funcnames",
        nargs="+",
        default=["mean", "median", "min", "max", "sum"],
        help="stats you would like to calculate: mean/ median/ min/ max/ percentile/",
    )
    parser.add_argument("-l", "--label", action="store_true")
    # parser.add_argument("-p", "--percentile", help="what percentile?")
    opts = parser.parse_args()

    stdout.write("#filename %s\n" % " ".join(opts.stats_funcnames))
    # stdout.write( opts.tag )
    for f in opts.files:
        assert exists(f)
        stdout.write(f)
        nums = myutil.floatList(myutil.get_column_as_list(f, opts.column))
        for stats_funcname in opts.stats_funcnames:
            if nums:
                stdout.write(" %5.1f" % cal_stats(stats_funcname, nums))
            else:
                stdout.write(" NA")

            if opts.label:
                stdout.write(" (%s)" % stats_funcname)

        stdout.write("\n")