annotate quantify.pl @ 8:d317cee86d4b draft

Deleted selected files
author big-tiandm
date Thu, 23 Oct 2014 22:46:39 -0400
parents 07745c0958dd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
2 #Filename:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
3 #Author: chentt
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
4 #Email:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
5 #Date: 2012-4-6
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
6 #Modified:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
7 #Description:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
8 my $version=1.00;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
9
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
10 use strict;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
11 use Getopt::Long;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
12
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
13 my %opts;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
14 GetOptions(\%opts,"i=s","o=s","d=s","h");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
15 if (!(defined $opts{i} and defined $opts{d} and defined $opts{o}) || defined $opts{h}) { #necessary arguments
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
16 &usage;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
17 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
18
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
19 my $input=$opts{'i'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
20 my $output=$opts{'o'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
21 my $depth=$opts{'d'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
22
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
23 open (IN,"<$input")||die"$!";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
24 open OUT,">$output";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
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 );
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
26 my @Total=split/\,/,$depth;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
27 #print OUT "#clusterID\tmajor_length\tpercent\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
28 while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
29 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
30 if ($aline=~/^\"/){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
31 my @title=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
32 for (my $i=0;$i<@title ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
33 $title[$i]=~s/^\"(\S+)\"$/$1/;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
34 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
35 my $title=join "\t",@title;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
36 print OUT "\#$title\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
37 next;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
38 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
39 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
40 print OUT "$temp[0]\t$temp[1]\t$temp[2]";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
41 my @id=split/:/,$temp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
42 my @posi=split/-/,$id[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
43 for (my $i=3;$i<@temp;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
44 my $rpkm=sprintf("%.2f",$temp[$i]/($posi[1]-$posi[0]+1)/$Total[$i-3]*1000000000);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
45 print OUT "\t$rpkm";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
46 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
47 print OUT "\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
48 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
49 close IN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
50 close OUT;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
51
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
52 sub usage{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
53 print <<"USAGE";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
54 Version $version
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
55 Usage:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
56 $0 -i -o -h
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
57 options:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
58 -i input cluster file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
59 -o output file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
60 -d depth
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
61 -h help
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
62 USAGE
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
63 exit(1);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
64 }