annotate quantify_siRNA.pl @ 53:f5a2e8308836 draft default tip

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