Mercurial > repos > earlhaminst > hcluster_sg_parser
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dbc49bd1a3e9 |
---|---|
1 #!/usr/bin/perl | |
2 # | |
3 use strict; | |
4 use warnings; | |
5 # A simple perl parser to convert hcluster_sg 3-column output into list of ids in separate files | |
6 # hcluster_sg_parser.pl <file> | |
7 | |
8 my $file1 = $ARGV[0]; | |
9 open my $fh1, '<', $file1; | |
10 | |
11 while (my $line = <$fh1>) { | |
12 chomp $line; | |
13 my @row = split(/\t/, $line); | |
14 | |
15 my $cluster_id = $row[0]; | |
16 my $id_list = $row[2]; | |
17 # Change commas to newlines | |
18 $id_list =~ s/\,/\n/g; | |
19 | |
20 my $outfile = $cluster_id."_output.txt"; | |
21 open(my $fh, '>', $outfile) or die "Could not open file '$outfile' for writing: $!"; | |
22 print $fh $id_list; | |
23 close $fh; | |
24 } | |
25 close $fh1; |