-
Notifications
You must be signed in to change notification settings - Fork 0
/
step3.pl
executable file
·67 lines (57 loc) · 1.6 KB
/
step3.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
56
57
58
59
60
61
62
63
64
65
66
67
#!/import/bc2/soft/app/perl/5.10.1/Linux/bin/perl -w
use strict;
use lib '.';
use promoteromeLib;
use YAML::Any;
$| = 1;
# This file was written for clustering of data from Fantom 5.
# This script normalizes the tag counts using cumulative fits from step2.pl
######################## config
my $conf_file = shift @ARGV or die "specify a config file!\n";
my $theOnlyFile = shift @ARGV; # second parameter if not empty is just one file to run on: for parallelizing
my $config = YAML::Any::LoadFile($conf_file);
my $dir = $config->{dir};
my $tmpDir = $config->{tmpDir};
my $cumDir = $config->{cumDir};
my $mappedDir = $config->{mappedDir};
my $normDir = $config->{normDir};
my $normDirSplit = $config->{normDirSplit};
my $fitDir = $config->{fitDir};
##################### CODE
mkdir $tmpDir.$normDir;
mkdir $tmpDir.$normDirSplit;
if(defined $theOnlyFile)
{
process($theOnlyFile)
}
else
{
opendir(my $D, $dir) or die;
while(my $f = readdir $D)
{
if(-f $dir.$f || -l $dir.$f)
{
process($f);
}
}
close $D;
}
sub process
{
my($f) = @_;
my ($sampleDesc, $sampleID) = split(/\./, $f);
#my $outF = $tmpDir.$normDir.$sampleID;
#if(-f $dir.$f && ! -e $outF)
{
print STDERR $sampleID, "\n";
my %h;
my($f2, $a, $b, $beta, $lambda) = readFit($tmpDir.$fitDir.$sampleID);
print STDERR "Reading RAW expression\n";
processBed(\%h, $dir.$f);
print STDERR "Normalizing\n";
normalize(\%h, $beta, $lambda); #adds {norm} keys to the hash
print STDERR "Writing norm and raw\n";
writeNormRaw(\%h, $tmpDir.$normDir.$sampleID, $tmpDir.$normDirSplit, $sampleID);
system('gzip', $tmpDir.$normDir.$sampleID);
}
}