Mercurial > repos > earlhaminst > hcluster_sg_parser
diff hcluster_sg_parser.pl @ 0:dbc49bd1a3e9 draft
planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/hcluster_sg_parser commit 75c6b4d9bd23cdd5f8e5626b1b01f2abba32c274-dirty
author | earlhaminst |
---|---|
date | Mon, 12 Dec 2016 07:12:23 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hcluster_sg_parser.pl Mon Dec 12 07:12:23 2016 -0500 @@ -0,0 +1,25 @@ +#!/usr/bin/perl +# +use strict; +use warnings; +# A simple perl parser to convert hcluster_sg 3-column output into list of ids in separate files +# hcluster_sg_parser.pl <file> + +my $file1 = $ARGV[0]; +open my $fh1, '<', $file1; + +while (my $line = <$fh1>) { + chomp $line; + my @row = split(/\t/, $line); + + my $cluster_id = $row[0]; + my $id_list = $row[2]; + # Change commas to newlines + $id_list =~ s/\,/\n/g; + + my $outfile = $cluster_id."_output.txt"; + open(my $fh, '>', $outfile) or die "Could not open file '$outfile' for writing: $!"; + print $fh $id_list; + close $fh; +} +close $fh1;