-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunCalcAllOrgs.py
executable file
·216 lines (146 loc) · 4.25 KB
/
RunCalcAllOrgs.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import time
import os
print"starting"
directory="."
global DirectoryAC
global urllib
execfile("chemistry.py")
print"chemistry=",chemistry
execfile("%soptions.py"%chemistry)
print "AC %s loaded"%(urllib)
DirectoryAC="%s%s%s%s%s"%(directory,os.sep,os.pardir,os.sep,urllib)
if not os.path.isdir(DirectoryAC):
os.mkdir(DirectoryAC)
print "data stored in ", DirectoryAC
#execfile("AClib.py")
print"reading lib file: CalcAllOrganizations.py"
execfile("CalcAllOrganizations.py")
if len(sys.argv)>1:
pass
# =int(sys.argv[1])
# if len(sys.argv)>2:
# =int(sys.argv[2])
################################################################################
actual=set()
molecules={}
print"initialising the molecule variable"
initalisedatabases(DirectoryAC)
#initalisedatabases(directory)
print"initialising the database"
newallstates=shelve.open("%s%snewallstates.shelve"%(directory,os.sep),writeback=False)
print "opening the shelve newallstates"
setuparchives(directory)
print "setting up the archives"
molecules=ReturnAllMolecules()
print "those are the molecules"
print molecules
InitialiseReaFile(molecules)
print "REA file initialised"
TopSet=set(molecules)
TopOrganization=Organization(TopSet)
BottomSet=set([])
BottomOrganization=Organization(BottomSet)
NameTop=OrganizationName.check(TopOrganization)
NameBottom=OrganizationName.check(BottomOrganization)
print "NameTop=",NameTop
print "NameBottom=",NameBottom
print "going to study the Lattice"
sys.stdout.flush()
#brutforce:
#OrganizationsFoundStudyingAll=CheckAllSubsetsBySize(set(molecules))
MapLatticeFromBelow(NameTop, NameBottom)
#MapLattice(NameTop, NameBottom)
#MapLattice(NameTop, NameBottom,5000)
OrganizationsFoundStudyingAll=CheckAllSubsets(set(molecules))
closedatabases()
sys.exit(0)
#for s in AllStates.keys():
# newallstates[s]=AllStates[s]
for m in mol.keys():
temp=numpy.mat(mol[m])
molecules[m]=temp.T
states=getstates()
#print states
#newallstates={}
#newstepstext=newallstates.keys()
#print "newstepstext" ,newstepstext
#newstepstext.sort()
#newstepsint=[int(d) for d in newstepstext]
#print newstepsint
#for s in newallstates.keys():
# pass
#print newallstates[s]
print "number states recorded in new=",len(newallstates)
#for whichstep in newstepstext:
# print "whichstep",whichstep
# print newallstates[whichstep]
# newallstates.sync()
#print "number states recorded in new=",len(newallstates)
#for whichstep in newstepsint:
# print "whichstep",whichstep
# print newallstates["%10s"%whichstep]
#print newallstates
def readstate (whichstep):
moleculestemp=AllStates["%10s"%whichstep]
# b=Cell(AllStates["%10s"%whichstep])
print "moleculestemp=", moleculestemp
b=Cell(moleculestemp)
return b
print "number states recorded=",len(states)
#print "number states recorded in new=",len(newallstates)
#for s in states:
# b=readstate(s)
# print "molecules=",b.moleculesdict.keys()
# if(not IsOrganization(b.moleculesdict.keys())):
# print "is not an organization, the organization is:"
# orgpresent=OrgLibrary.check(b.moleculesdict.keys())
# print orgpresent
# print "organization known:", GetNKnownOrg()
#AllOrg=set(NameOrganization.DB.keys())
AllOrg=NameOrganization.DB.keys()
NOrg=len(AllOrg)
print NOrg
Buf=""
#for Pointer in range(NOrg):
for Pointer in range(600):
# print "hi"
print Pointer,
# print "hi2"
O1=AllOrg[Pointer]
# print "hi3"
# print AllOrg[Pointer]
# print "hi4"
print len(NameOrganization.DB.keys())
# print "hi5"
for SecondPointer in range(Pointer+1,NOrg):# RelOrg1Org2(A,B)
# Buf+="%s "%IsOrg1inOrg2(O1,AllOrg[SecondPointer])
# Buf+="%s "%RelOrg1Org2(O1,AllOrg[SecondPointer])
#Buf+="%s "%Org1intersectionOrg2(O1,AllOrg[SecondPointer])
Org1intersectionOrg2(O1,AllOrg[SecondPointer])
if Buf:
print Buf
Buf=""
print "hi6"
print "NOrg=",len(NameOrganization.DB.keys())
print "hi7"
#for O1O2 in findsubsets(AllOrg,2):
# print O1O2,
#for Organiz1 in AllOrg:
# for Organiz2 in AllOrg:
# print IsOrg1inOrg2(Organiz1,Organiz2),
#WriteLatticesKnownInGeneral()
#indexstep=0
#tinymove=0
#print "pippo"
#print "all states=",states
#fromtimestep=states[0]
#totimestep=states[-1]
#stepstudied=0
#diversity=[getdiversity(s) for s in states]
print "hi8"
diversity=getdiversitylist()
print "hi9"
#print AllStates
closedatabases()
#print len(AllStates)
print 'hi10 \a'