-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmax_bins_with_population_restriction_theoretical.py
64 lines (56 loc) · 1.9 KB
/
max_bins_with_population_restriction_theoretical.py
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
#!usr/bin/python
import sys, os
import math
directory_theo="/Users/Matthew/Documents/GitHub/RSA-normalization-values/AnglesIteratedThroughAgain"
##directory_bin_theo="/Users/Matthew/Documents/GitHub/RSA-normalization-values/TheoreticalBins/no_pop_restriction"
##directory_bin_emp="/Users/Matthew/Documents/GitHub/RSA-normalization-values/EmpiricalBins/no_pop_restriction"
directory_bin_theo="/Users/Matthew/Documents/GitHub/RSA-normalization-values/TheoreticalBins/pop_restriction"
directory_bin_emp="/Users/Matthew/Documents/GitHub/RSA-normalization-values/EmpiricalBins/pop_restriction"
inp=sys.argv[1]
cap= inp.upper()
fname= os.path.join(directory_bin_emp , inp + "_max_emperical_bins_pop_restriction")
##fname= os.path.join(directory_bin_emp , inp + "_max_emperical_bins")
filein= open(fname)
filein.readline()
key=[]
bins={}
for line in filein:
data=line.split()
phi=int(data[0])
psi=int(data[1])
sa= int(float(data[2]))
pop= int(data[3])
bins[(phi,psi)]=[sa, pop, 0]
key.append((phi,psi))
filein.close()
fname=os.path.join(directory_theo ,"AnglesIteratedThroughAgain" + cap)
filein= open(fname)
filein.readline()
flag=0
temp=0
for line in filein:
info=line.split()
psi= float(info[2])
phi= float(info[1])
sa= float(info[0])
## if(flag==0):
## temp=phi
## flag=1
## if(phi==temp):
## phi=-phi
b=((int(phi)/5)*5, (int(psi)/5)*5)
if(sa > bins[b][2]):
bins[b][2]=sa
##print bins[b][2]
filein.close()
fout=os.path.join(directory_bin_theo , inp+"_max_theoretical_bins_Again_pop_restriction")
##fout=os.path.join(directory_bin_theo , inp+"_max_theoretical_bins_Again")
fileout=open(fout, 'w')
fileout.write("Phi\tPsi\tmaxSA\n")
for k in key:
if( bins[k][0]<5):
##if( bins[k][0]==0):
fileout.write(str(k[0])+"\t"+str(k[1])+"\t"+ str(0)+"\n")
else:
fileout.write(str(k[0])+"\t"+str(k[1])+"\t"+ str(bins[k][2])+"\n")
fileout.close()