comparison flowclrstats.py @ 1:7a889f2f2e15 draft default tip

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowclr_summary commit ce895377ed593ace77016bd019a7998e13e470cc"
author azomics
date Mon, 22 Jun 2020 19:55:57 -0400
parents
children
comparison
equal deleted inserted replaced
0:479ff3a9023c 1:7a889f2f2e15
1 #!/usr/bin/env python
2
3 ######################################################################
4 # Copyright (c) 2016 Northrop Grumman.
5 # All rights reserved.
6 ######################################################################
7
8 from __future__ import print_function
9 from argparse import ArgumentParser
10 import pandas as pd
11
12
13 def get_FLOCK_stats(input_file, output_file, out_file2):
14 df = pd.read_table(input_file)
15 summary = df.groupby('Population').describe().round(1)
16 counts = df['Population'].value_counts()
17 percent = (df['Population'].value_counts(normalize=True) * 100).round(decimals=2)
18 tot_count = len(df['Population'])
19
20 to_rm = summary.loc(axis=0)[:, ['count']].index.tolist()
21 df1 = summary[~summary.index.isin(to_rm)]
22 df1.to_csv(out_file2, sep="\t")
23
24 with open(output_file, "w") as outf:
25 outf.write("Population\tCount\tPercentage\n")
26 for pops in set(df.Population):
27 outf.write("\t".join([str(pops), str(counts.loc[pops]), str(percent.loc[pops])]) + "\n")
28 outf.write("Total\t" + str(tot_count) + "\t \n")
29 return
30
31
32 if __name__ == '__main__':
33 parser = ArgumentParser(
34 prog="flowstats",
35 description="Gets statistics on FLOCK run")
36
37 parser.add_argument(
38 '-i',
39 dest="input_file",
40 required=True,
41 help="File locations for flow clr file.")
42
43 parser.add_argument(
44 '-o',
45 dest="out_file",
46 required=True,
47 help="Path to the directory for the output file.")
48
49 parser.add_argument(
50 '-p',
51 dest="out_file2",
52 required=True,
53 help="Path to the directory for the output file.")
54 args = parser.parse_args()
55
56 get_FLOCK_stats(args.input_file, args.out_file, args.out_file2)