Mercurial > repos > big-tiandm > sirna_plant
view quantify.pl @ 14:36ba71d63988 draft
Uploaded
author | big-tiandm |
---|---|
date | Wed, 29 Oct 2014 04:19:59 -0400 |
parents | 07745c0958dd |
children |
line wrap: on
line source
#!/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); }