modified: Makefile
[GalaxyCodeBases.git] / perl / etc / ifollowQplot.pl
blobf1053fc35223e7e29fa4463b52f3bfb9a621eeb7
1 #!/bin/env perl
2 use strict;
3 use warnings;
5 die "Usage: $0 <in.fQdat> > Output_to_STDOUT\n" if @ARGV != 1;
6 my ($in)=@ARGV;
8 my $MaxQ=40;
10 my %Dat;
11 open I,'<',$in or die $!;
12 while(<I>){
13 next if /^#/;
14 chomp;
15 #s/\t\-(\t|$)/\t0\1/g;
16 s/-/0/g;
17 my @a=split /\t/;
18 my $Qin=shift @a;
19 my $Qlen=scalar @a;
20 shift @a;
21 $MaxQ=$Qlen if $Qlen>$MaxQ;
22 my $Sum=0;
23 $Sum += $_ for @a;
24 if ($Sum>0) {
25 $_ /= $Sum for @a;
27 $Dat{$Qin}=\@a;
30 for my $i (sort {$a<=>$b} keys %Dat) {
31 for my $j (2..$MaxQ) {
32 print "$i\t$j\t$Dat{$i}->[$j-2]\n"
34 print "\n";