diff quantify_siRNA.pl @ 50:7b5a48b972e9 draft

Uploaded
author big-tiandm
date Fri, 05 Dec 2014 00:11:02 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/quantify_siRNA.pl	Fri Dec 05 00:11:02 2014 -0500
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+#Filename:
+#Author: chentt
+#Email:
+#Date: 2012-4-6
+#Modified:
+#Description:
+my $version=1.00;
+
+use strict;
+use Getopt::Long;
+
+my %opts;
+GetOptions(\%opts,"i=s","o=s","d=s","h");
+if (!(defined $opts{i} and defined $opts{d} and defined $opts{o}) || defined $opts{h}) { #necessary arguments
+&usage;
+}
+
+my $input=$opts{'i'};
+my $output=$opts{'o'};
+my $depth=$opts{'d'};
+
+open (IN,"<$input")||die"$!";
+open OUT,">$output";
+#my @Total=qw(15797079 18042650 17455254 17295526 18791753 16719596 15150009 18451484 17402501 17729362 19347595 17518516 15699663 16589265 15442892 14012264 14190746 17280260 13213117 12390121 14874304 );
+my @Total=split/\,/,$depth;
+#print OUT "#clusterID\tmajor_length\tpercent\n";
+while (my $aline=<IN>) {
+	chomp $aline;
+	if ($aline=~/^\"/){
+		my @title=split/\t/,$aline;
+		for (my $i=0;$i<@title ;$i++) {
+			$title[$i]=~s/^\"(\S+)\"$/$1/;
+		}
+		my $title=join "\t",@title;
+		print OUT "\#$title\n";
+		next;
+	}
+	my @temp=split/\t/,$aline;
+	print OUT "$temp[0]\t$temp[1]\t$temp[2]";
+	my @id=split/:/,$temp[0];
+	my @posi=split/-/,$id[1];
+	for (my $i=3;$i<@temp;$i++) {
+		my $rpkm=sprintf("%.2f",$temp[$i]/($posi[1]-$posi[0]+1)/$Total[$i-3]*1000000000);
+		print OUT "\t$rpkm";
+	}
+	print OUT "\n";
+}
+close IN;
+close OUT;
+
+sub usage{
+print <<"USAGE";
+Version $version
+Usage:
+$0 -i -o -h
+options:
+-i input cluster file
+-o output file
+-d depth
+-h help
+USAGE
+exit(1);
+}
\ No newline at end of file