# HG changeset patch # User earlhaminst # Date 1631286486 0 # Node ID 07f5b2c5ac1090b726706aafebe8f05723055c72 # Parent 02d73e6ca86919a17877ef911e921b2be5b4f54e "planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/hcluster_sg_parser commit e015ac3e0d8c1bc62b1301527241ee5e377b91db" diff -r 02d73e6ca869 -r 07f5b2c5ac10 hcluster_sg_parser.py --- a/hcluster_sg_parser.py Fri Jul 19 11:44:07 2019 -0400 +++ b/hcluster_sg_parser.py Fri Sep 10 15:08:06 2021 +0000 @@ -5,9 +5,10 @@ Usage: -python hcluster_sg_parser.py [-m ] [-M ] +python hcluster_sg_parser.py [-m ] [-M ] """ import optparse +import os import sys @@ -15,8 +16,11 @@ parser = optparse.OptionParser() parser.add_option('-m', '--min', type='int', default=0, help='Minimum number of cluster elements') parser.add_option('-M', '--max', type='int', default=sys.maxsize, help='Maximum number of cluster elements') + parser.add_option('-d', '--dir', type='string', help="Absolute or relative path to output directory. If the directory does not exist, it will be created") options, args = parser.parse_args() + if options.dir and not os.path.exists(options.dir): + os.mkdir(options.dir) with open(args[2], 'w') as discarded_max_out: with open(args[1], 'w') as discarded_min_out: with open(args[0]) as fh: @@ -32,6 +36,8 @@ discarded_max_out.write(id_list) else: outfile = cluster_id + '_output.txt' + if options.dir: + outfile = os.path.join(options.dir, outfile) with open(outfile, 'w') as f: f.write(id_list)