annotate quantify_siRNA.pl @ 0:87fe81de0931 draft default tip

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