Mercurial > repos > earlhaminst > hcluster_sg_parser
diff hcluster_sg_parser.py @ 4:02d73e6ca869 draft
planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/hcluster_sg_parser commit e35f2ea026b79daaced9a2a50da02b4881d6154b
author | earlhaminst |
---|---|
date | Fri, 19 Jul 2019 11:44:07 -0400 |
parents | f9e418125021 |
children | 07f5b2c5ac10 |
line wrap: on
line diff
--- a/hcluster_sg_parser.py Fri Apr 28 12:51:35 2017 -0400 +++ b/hcluster_sg_parser.py Fri Jul 19 11:44:07 2019 -0400 @@ -17,20 +17,23 @@ parser.add_option('-M', '--max', type='int', default=sys.maxsize, help='Maximum number of cluster elements') options, args = parser.parse_args() - with open(args[1], 'w') as discarded_out: - with open(args[0]) as fh: - for line in fh: - line = line.rstrip() - line_cols = line.split('\t') - cluster_id = line_cols[0] - n_ids = int(line_cols[-2]) - id_list = line_cols[-1].replace(',', '\n') - if n_ids >= options.min and n_ids <= options.max: - outfile = cluster_id + '_output.txt' - with open(outfile, 'w') as f: - f.write(id_list) - else: - discarded_out.write(id_list) + with open(args[2], 'w') as discarded_max_out: + with open(args[1], 'w') as discarded_min_out: + with open(args[0]) as fh: + for line in fh: + line = line.rstrip() + line_cols = line.split('\t') + cluster_id = line_cols[0] + n_ids = int(line_cols[-2]) + id_list = line_cols[-1].replace(',', '\n') + if n_ids < options.min: + discarded_min_out.write(id_list) + elif n_ids > options.max: + discarded_max_out.write(id_list) + else: + outfile = cluster_id + '_output.txt' + with open(outfile, 'w') as f: + f.write(id_list) if __name__ == "__main__":