add addiitional refresh option for all views except genoview
[sgn.git] / bin / transpose_matrix.pl
blob1346bca1837ff6e0467722d17a3505eab2c0d7c3
1 #!/usr/bin/perl
2 # 'transpose' swaps rows and columns in the given tab-delimited table.
3 # syntax perl transpose.pl input.txt > output.txt
5 while (<>) {
6 chomp;
7 @line = split /\t/;
8 $oldlastcol = $lastcol;
9 $lastcol = $#line if $#line > $lastcol;
10 for (my $i=$oldlastcol; $i < $lastcol; $i++) {
11 $outline[$i] = "\t" x $oldlastcol;
13 for (my $i=0; $i <=$lastcol; $i++) {
14 if ($outline[$i] =~ /\w/) {
15 $outline[$i] .= "\t$line[$i]";
16 } else {
17 $outline[$i] = $line[$i];
21 for (my $i=0; $i <= $lastcol; $i++) {
22 $outline[$i] =~ s/[\f\n\r]*$//g;
23 print $outline[$i]."\n";