50
|
1 #!/usr/bin/perl -w
|
|
2 #Filename:
|
|
3 #Author: chentt
|
|
4 #Email:
|
|
5 #Date: 2012-4-6
|
|
6 #Modified:
|
|
7 #Description:
|
|
8 my $version=1.00;
|
|
9
|
|
10 use strict;
|
|
11 use Getopt::Long;
|
|
12
|
|
13 my %opts;
|
|
14 GetOptions(\%opts,"i=s","o=s","d=s","h");
|
|
15 if (!(defined $opts{i} and defined $opts{d} and defined $opts{o}) || defined $opts{h}) { #necessary arguments
|
|
16 &usage;
|
|
17 }
|
|
18
|
|
19 my $input=$opts{'i'};
|
|
20 my $output=$opts{'o'};
|
|
21 my $depth=$opts{'d'};
|
|
22
|
|
23 open (IN,"<$input")||die"$!";
|
|
24 open OUT,">$output";
|
|
25 #my @Total=qw(15797079 18042650 17455254 17295526 18791753 16719596 15150009 18451484 17402501 17729362 19347595 17518516 15699663 16589265 15442892 14012264 14190746 17280260 13213117 12390121 14874304 );
|
|
26 my @Total=split/\,/,$depth;
|
|
27 #print OUT "#clusterID\tmajor_length\tpercent\n";
|
|
28 while (my $aline=<IN>) {
|
|
29 chomp $aline;
|
|
30 if ($aline=~/^\"/){
|
|
31 my @title=split/\t/,$aline;
|
|
32 for (my $i=0;$i<@title ;$i++) {
|
|
33 $title[$i]=~s/^\"(\S+)\"$/$1/;
|
|
34 }
|
|
35 my $title=join "\t",@title;
|
|
36 print OUT "\#$title\n";
|
|
37 next;
|
|
38 }
|
|
39 my @temp=split/\t/,$aline;
|
|
40 print OUT "$temp[0]\t$temp[1]\t$temp[2]";
|
|
41 my @id=split/:/,$temp[0];
|
|
42 my @posi=split/-/,$id[1];
|
|
43 for (my $i=3;$i<@temp;$i++) {
|
|
44 my $rpkm=sprintf("%.2f",$temp[$i]/($posi[1]-$posi[0]+1)/$Total[$i-3]*1000000000);
|
|
45 print OUT "\t$rpkm";
|
|
46 }
|
|
47 print OUT "\n";
|
|
48 }
|
|
49 close IN;
|
|
50 close OUT;
|
|
51
|
|
52 sub usage{
|
|
53 print <<"USAGE";
|
|
54 Version $version
|
|
55 Usage:
|
|
56 $0 -i -o -h
|
|
57 options:
|
|
58 -i input cluster file
|
|
59 -o output file
|
|
60 -d depth
|
|
61 -h help
|
|
62 USAGE
|
|
63 exit(1);
|
|
64 } |