annotate FCSstats_txt.py @ 0:2916b895840f draft default tip

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
author azomics
date Mon, 22 Jun 2020 20:32:32 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
1 #!/usr/bin/env python
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
2
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
3 ######################################################################
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
4 # Copyright (c) 2016 Northrop Grumman.
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
5 # All rights reserved.
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
6 ######################################################################
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
7
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
8 from __future__ import print_function
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
9 import pandas as pd
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
10 from argparse import ArgumentParser
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
11
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
12
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
13 def get_txt_stats(in_file, out_file):
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
14 df = pd.read_table(in_file)
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
15 summary = df.describe().round(1)
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
16 df1 = summary[1:]
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
17 x = summary[:1].values.tolist()
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
18 df1.to_csv(out_file, sep="\t")
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
19 with open(out_file, "a") as ot:
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
20 ot.write("\n\n" + str(int(x[0][0])) + " events\n")
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
21 return
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
22
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
23
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
24 if __name__ == "__main__":
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
25 parser = ArgumentParser(
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
26 prog="getTxtStats",
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
27 description="Prints summary statistics from given file.")
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
28
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
29 parser.add_argument(
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
30 '-i',
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
31 dest="input_file",
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
32 required=True,
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
33 help="File location for the text file.")
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
34
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
35 parser.add_argument(
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
36 '-o',
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
37 dest="output_file",
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
38 required=True,
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
39 help="Name of the output file.")
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
40
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
41 args = parser.parse_args()
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
42
2916b895840f "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowtext_summary commit 2a47c0c1e27462d21098006ba4fe0789b1ed37ec"
azomics
parents:
diff changeset
43 get_txt_stats(args.input_file, args.output_file)