|
4 | 4 | import pandas as pd |
5 | 5 | from collections import OrderedDict |
6 | 6 |
|
7 | | -VERSION = "1.0.1" |
| 7 | +VERSION = "1.0.2" |
8 | 8 |
|
9 | 9 | ## A function to return the number of lines of a file |
10 | 10 | def file_len(fname): |
@@ -50,19 +50,20 @@ def get_ind_names(indf): |
50 | 50 | parser.add_argument("-i", "--Input", type = str, metavar = "<INPUT FILES PREFIX>", required = True, help = "The desired input file prefix. Input files are assumed to be <INPUT PREFIX>.geno, <INPUT PREFIX>.snp and <INPUT PREFIX>.ind .") |
51 | 51 | parser.add_argument("-s", "--Suffix", type = str, metavar = "<INPUT FILE SUFFIX>", required = False, default = '', help = "The suffix (if any) that follows .geno/.snp/.ind in the input files. For example, specifying '-s .txt' will treat <INPUT PREFIX>.{geno,snp,ind}.txt as the desired input files.") |
52 | 52 | parser.add_argument("-o", "--Output", type = str, metavar = "<OUTPUT FILEPATH>", required = False, help = "The filepath where the output table should be saved. Omit to print to stdout.") |
53 | | -parser.add_argument("-j", "--json", action = "store_true", help = "Create additional json formatted output file named <OUTPUT FILE>.json . [Default: '<INPUT FILES PREFIX>_eigenstrat_coverage_mqc.json']") |
| 53 | +parser.add_argument("-j", "--json", type = str, metavar = "<JSON OUTPUT FILEPATH>", default = None, help = "Create additional json formatted output file named <JSON OUTPUT FILEPATH> .") |
54 | 54 | parser.add_argument("-v", "--version", action='version', version="%(prog)s {}".format(VERSION), help="Print the version and exit.") |
55 | 55 | args = parser.parse_args() |
56 | 56 |
|
57 | 57 | ## Set dynamic output files |
58 | 58 | if args.Output == None: |
59 | 59 | out_file = sys.stdout |
60 | | - if args.json: |
61 | | - json_output = args.Input+'_eigenstrat_coverage.json' |
62 | 60 | else: |
63 | 61 | out_file = open(args.Output, 'w') |
64 | | - if args.json: |
65 | | - json_output = args.Output+'.json' |
| 62 | + |
| 63 | +if args.json == None: |
| 64 | + json_output = None |
| 65 | +else: |
| 66 | + json_output = args.json |
66 | 67 |
|
67 | 68 | ## Initialise empty data table as dictionary |
68 | 69 | data = {} |
@@ -94,7 +95,7 @@ def get_ind_names(indf): |
94 | 95 | for ind in ind_list: |
95 | 96 | print(ind, data[ind]["Covered_Snps"], data[ind]["Total_Snps"], sep="\t", file=out_file) |
96 | 97 |
|
97 | | -if args.json: |
| 98 | +if json_output != None: |
98 | 99 | with open(json_output, 'w') as json_outfile: |
99 | 100 | json.dump(data, json_outfile) |
100 | 101 |
|
0 commit comments