-
Notifications
You must be signed in to change notification settings - Fork 0
/
FactorStateTable.pl
97 lines (66 loc) · 2.68 KB
/
FactorStateTable.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/perl
use warnings;
# use integer;
use List::Util qw(sum);
use Math::BigFloat;
open runfile, "stats/run.txt";
$writeTablePath = "stats/factor-state-table.txt";
$writeTablePercentPath = "stats/factor-state-percent-table.txt";
open (writeFactorStateTableFile, ">".$writeTablePath);
open (writeFactorStateTablePercentFile, ">".$writeTablePercentPath);
print writeFactorStateTableFile "factor\t1_Active_Promoter\t2_Weak_Promoter\t3_Poised_Promoter\t4_Strong_Enhancer\t5_Strong_Enhancer\t6_Weak_Enhancer\t7_Weak_Enhancer\t8_Insulator\t9_Txn_Transition\t10_Txn_Elongation\t11_Weak_Txn\t12_Repressed\t13_Heterochrom/lo\t14_Repetitive/CNV\t15_Repetitive/CNV\n";
# print writeFactorStateTableFile "state1\tstate2\tstate3\tstate4\tstate5\tstate6\tstate7\tstate8\tstate9\tstate10\tstate11\tstate12\tstate13\tstate14\tstate15\n";
# print writeFactorStateTablePercentFile "factor\tstate1\tstate2\tstate3\tstate4\tstate5\tstate6\tstate7\tstate8\tstate9\tstate10\tstate11\tstate12\tstate13\tstate14\tstate15\n";
print writeFactorStateTablePercentFile "factor\t1_Active_Promoter\t2_Weak_Promoter\t3_Poised_Promoter\t4_Strong_Enhancer\t5_Strong_Enhancer\t6_Weak_Enhancer\t7_Weak_Enhancer\t8_Insulator\t9_Txn_Transition\t10_Txn_Elongation\t11_Weak_Txn\t12_Repressed\t13_Heterochrom/lo\t14_Repetitive/CNV\t15_Repetitive/CNV\n";
my @factorTotals = ();
while (<runfile>) {
chomp;
my $factor = $_;
print "$factor\n";
my $factorSum = 0;
print writeFactorStateTableFile "$factor\t";
open tallyfile, "broadhmm/$factor/factor-tally.txt";
while (<tallyfile>) {
chomp;
my $stateTally = $_;
print writeFactorStateTableFile "$stateTally\t";
# push(@factorValues, $stateTally);
$factorSum += $stateTally;
}
close tallyfile;
print writeFactorStateTableFile "\n";
# $factorSum = sum(@factorValues);
print writeFactorStateTablePercentFile "$factor\t";
open tallyfile, "broadhmm/$factor/factor-tally.txt";
while (<tallyfile>) {
chomp;
my $stateTally = $_;
my $statePercent = $stateTally / $factorSum;
print ref $stateTally;
print "factorsum: $factorSum\n";
print "$stateTally\n";
print "$statePercent\n";
print writeFactorStateTablePercentFile "$statePercent\t";
}
close tallyfile;
print writeFactorStateTablePercentFile "\n";
# push(@factorTotals, sum(@factorValues));
}
# foreach (@factorTotals)
# {
# print "$_\n";
# }
# print $factorTotals[1];
# for ($state = 1; $state < 16; $state++) {
# print "$state\n";
# open broadhmmFile, $broadhmmPath;
# while (<broadhmmFile>) {
# chomp;
# my @line = split(/\t/,"$_");
# # print index($line[3], $state);
# if (index($line[3],"$state"."_") == 0) {
# # print "$line[3]\n";
# print writeSplitState "$_\n";
# }
# }
# }