# HG changeset patch # User earlhaminst # Date 1563551047 14400 # Node ID 02d73e6ca86919a17877ef911e921b2be5b4f54e # Parent f9e4181250215ca4671995dabe6ff813f7a252dc planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/hcluster_sg_parser commit e35f2ea026b79daaced9a2a50da02b4881d6154b diff -r f9e418125021 -r 02d73e6ca869 hcluster_sg_parser.py --- 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__": diff -r f9e418125021 -r 02d73e6ca869 hcluster_sg_parser.xml --- a/hcluster_sg_parser.xml Fri Apr 28 12:51:35 2017 -0400 +++ b/hcluster_sg_parser.xml Fri Jul 19 11:44:07 2019 -0400 @@ -1,4 +1,4 @@ - + converts hcluster_sg 3-column output into lists of IDs @@ -21,7 +22,8 @@ - + + @@ -32,7 +34,8 @@ - + + @@ -41,10 +44,11 @@ - + + - + @@ -56,7 +60,8 @@ - + + diff -r f9e418125021 -r 02d73e6ca869 test-data/hcluster_sg1.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/hcluster_sg1.tabular Fri Jul 19 11:44:07 2019 -0400 @@ -0,0 +1,9 @@ +0 0 57 1.000 0 13 11,0,4,3,5,12,7,10,13,2,1,6,9, +1 0 23 0.671 0 46 45,39,71,83,49,61,64,38,25,72,44,29,90,35,30,28,62,65,63,88,89,34,82,73,52,74,17,55,41,56,59,51,32,33,87,31,85,27,48,66,50,37,60,77,26,54, +2 0 0 1.000 0 1 84, +3 0 33 1.000 0 8 101,96,92,98,94,100,91,99, +4 0 28 1.000 0 4 40,43,76,42, +5 0 0 1.000 0 1 8, +6 0 54 1.000 0 8 18,23,21,15,22,20,14,16, +7 0 15 0.596 0 17 24,95,58,69,78,36,68,70,57,67,97,79,53,47,75,86,46, +8 0 0 1.000 0 1 102, diff -r f9e418125021 -r 02d73e6ca869 test-data/hcluster_sg1.txt --- a/test-data/hcluster_sg1.txt Fri Apr 28 12:51:35 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -0 0 57 1.000 0 13 11,0,4,3,5,12,7,10,13,2,1,6,9, -1 0 23 0.671 0 46 45,39,71,83,49,61,64,38,25,72,44,29,90,35,30,28,62,65,63,88,89,34,82,73,52,74,17,55,41,56,59,51,32,33,87,31,85,27,48,66,50,37,60,77,26,54, -2 0 0 1.000 0 1 84, -3 0 33 1.000 0 8 101,96,92,98,94,100,91,99, -4 0 28 1.000 0 4 40,43,76,42, -5 0 0 1.000 0 1 8, -6 0 54 1.000 0 8 18,23,21,15,22,20,14,16, -7 0 15 0.596 0 17 24,95,58,69,78,36,68,70,57,67,97,79,53,47,75,86,46, -8 0 0 1.000 0 1 102,