-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrpkm_script_beta.pl
57 lines (51 loc) · 1.11 KB
/
rpkm_script_beta.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/perl
#use strict;
#use warnings;
#Author: Santhilal Subhash
#Contact: santhilal.subhash@gu.se
#RPKM for RNAseq V1.3
#USAGE for sample input provided: perl rpkm_script_beta.pl sample_count_test.count 2:9 15 > sample_count_test.rpkm
#USAGE: perl rpkm_script_beta.pl input_count_file.txt ActualColumnStart:ActualColumnEnd ColumnGeneLength > results.rpkm
open $fh1, '<', $ARGV[0] or die $!;
open $fh2, '<', $ARGV[0] or die $!;
$total = 0;
$count = 0;
$cols=$ARGV[1];
$len_col=$ARGV[2];
while (<$fh1>)
{
@array=split("\t");
($cstart,$cend)=split(":",$cols);
for($i=$cstart-1;$i<=$cend-1;$i++)
{
$libarray[$i] += $array[$i];
}
}
while (<$fh2>)
{
$next = <>;
if ($next =~ /^#/)
{
$header=$next;
$header =~ s/#//;
print "$header";
}
if ($next !~ /^#/)
{
@array=split("\t");
($cstart,$cend)=split(":",$cols);
for($i=$cstart-1;$i<=$cend-1;$i++)
{
if($array[$i]!=0)
{
$array_rpkm[$i]=((1000000*$array[$i])/($libarray[$i]*$array[$len_col-1]));
}
else
{
$array_rpkm[$i]=0;
}
}
local $" = "\t";
print "$array[$cstart-2]@array_rpkm\t@array[$cend..$#array]";
}
}