def displayClustersBonds(self,clusters, factor=0.7,ev=1.0): colors = [ getattr(upy_colors, name) for name in upy_colors.cnames ] centers = [] radiiG = [] radiiM = [] radii = [] if clusters is None: return for i,cluster in enumerate(clusters): centers.append(cluster.centroid.coords) radg = cluster.radiusOfGyration() radm = cluster.encapsualtingRadius() self.radg = radg #added by Graham 4/4/11 self.radm = radm #added by Graham 4/4/11 #rad = radg/0.7 rad = radg + factor*(radm-radg) radiiG.append(radg) radiiM.append(radm) radii.append(rad) ptCoords = [x.coords for x in cluster.points] # Create a bhtree for the ptCoords using a granility of 10 bht = bhtreelib.BHtree( centers, radiiM, 10) # find all pairs of atoms for which the distance is less than 1.1 # times the sum of the radii print ("cutoff ",ev) pairs = bht.closePointsPairsInTree(ev) bhtreelib.freeBHtree(bht) # pairs is list of tuple of atom indices. nbc = len(clusters) bonds = {} for i,pair in enumerate(pairs): # 1- Get the atoms corresponding of the indices of the pair cl1 = clusters[int(pair[0])] cl2 = clusters[int(pair[1])] head = cl1.centroid.coords tail = cl2.centroid.coords rad = cl1.radiusOfGyration() + factor*(cl1.encapsualtingRadius()-cl1.radiusOfGyration())#or diameter ? pinstance = self.helper.getObject("BC") if pinstance is None : pinstance=self.helper.Cylinder("BC",radius=1.,length=1.,res=10, pos = [0.,0.,0.],parent=None)[0] cyl = self.helper.getObject("clbond"+str(i)) if cyl is None : cyl=self.helper.oneCylinder("clbond"+str(i),head,tail,radius=rad,instance=pinstance,material=None, parent = self.CenterSpheres,color=colors[nbc]) else : self.helper.updateOneCylinder("clbond"+str(i),head,tail,radius=rad,color=colors[nbc]) self.clusterCenterCyl["clbond"+str(i)] = [head,tail,rad] if len(self.clusterCenterCyl) > len(pairs): for j in range(len(pairs),len(self.clusterCenterCyl)): # for cy in self.clusterCenterCyl[len(pair):]: # o=self.clusterCenterCyl[] self.helper.deleteObject("clbond"+str(j))
def displayClustersBonds(self, clusters, factor=0.7, ev=1.0): colors = [getattr(upy_colors, name) for name in upy_colors.cnames] centers = [] radiiG = [] radiiM = [] radii = [] if clusters is None: return for i, cluster in enumerate(clusters): centers.append(cluster.centroid.coords) radg = cluster.radiusOfGyration() radm = cluster.encapsualtingRadius() self.radg = radg #added by Graham 4/4/11 self.radm = radm #added by Graham 4/4/11 #rad = radg/0.7 rad = radg + factor * (radm - radg) radiiG.append(radg) radiiM.append(radm) radii.append(rad) ptCoords = [x.coords for x in cluster.points] # Create a bhtree for the ptCoords using a granility of 10 bht = bhtreelib.BHtree(centers, radiiM, 10) # find all pairs of atoms for which the distance is less than 1.1 # times the sum of the radii print("cutoff ", ev) pairs = bht.closePointsPairsInTree(ev) bhtreelib.freeBHtree(bht) # pairs is list of tuple of atom indices. nbc = len(clusters) bonds = {} for i, pair in enumerate(pairs): # 1- Get the atoms corresponding of the indices of the pair cl1 = clusters[int(pair[0])] cl2 = clusters[int(pair[1])] head = cl1.centroid.coords tail = cl2.centroid.coords rad = cl1.radiusOfGyration() + factor * ( cl1.encapsualtingRadius() - cl1.radiusOfGyration() ) #or diameter ? pinstance = self.helper.getObject("BC") if pinstance is None: pinstance = self.helper.Cylinder("BC", radius=1., length=1., res=10, pos=[0., 0., 0.], parent=None)[0] cyl = self.helper.getObject("clbond" + str(i)) if cyl is None: cyl = self.helper.oneCylinder("clbond" + str(i), head, tail, radius=rad, instance=pinstance, material=None, parent=self.CenterSpheres, color=colors[nbc]) else: self.helper.updateOneCylinder("clbond" + str(i), head, tail, radius=rad, color=colors[nbc]) self.clusterCenterCyl["clbond" + str(i)] = [head, tail, rad] if len(self.clusterCenterCyl) > len(pairs): for j in range(len(pairs), len(self.clusterCenterCyl)): # for cy in self.clusterCenterCyl[len(pair):]: # o=self.clusterCenterCyl[] self.helper.deleteObject("clbond" + str(j))
def pack_multi(env, ncpus=1,seedNum=14, stepByStep=False, verbose=False, sphGeom=None, labDistGeom=None, debugFunc=None,name = None, vTestid = 3,vAnalysis = 0,**kw): ## Fill the grid by picking an ingredient first and then ## this filling should be able to continue from a previous one ## find a suitable point suing hte ingredient's placer object self=env import time import pp nparts = 2 job_server = pp.Server(ncpus=ncpus) t1=time.time() self.timeUpDistLoopTotal = 0 #Graham added to try to make universal "global variable Verbose" on Aug 28 self.static=[] if self.grid is None: print("no grid setup") return # create a list of active ingredients indices in all recipes to allow # removing inactive ingredients when molarity is reached allIngredients = self.callFunction(self.getActiveIng) nbIngredients = len(allIngredients) self.cFill = self.nFill if name == None : name = "F"+str(self.nFill) self.FillName.append(name) self.nFill+=1 # seed random number generator SEED=seedNum numpy.random.seed(SEED)#for gradient seed(seedNum) self.randomRot.setSeed(seed=seedNum) # create copies of the distance array as they change when molecules # are added, theses array can be restored/saved before feeling freePoints = self.grid.freePoints[:] nbFreePoints = len(freePoints)#-1 grab_callback = GrabResult(nbFreePoints,self) grab_callback.freePoints=freePoints # self.freePointMask = numpy.ones(nbFreePoints,dtype="int32") if "fbox" in kw : # Oct 20, 2012 This is part of the code that is breaking the grids for all meshless organelle fills self.fbox = kw["fbox"] if self.fbox is not None and not self.EnviroOnly : self.freePointMask = numpy.ones(nbFreePoints,dtype="int32") bb_insidepoint = self.grid.getPointsInCube(self.fbox, [0,0,0], 1.0)[:]#center and radius ?3,runTime=self.runTimeDisplay self.freePointMask[bb_insidepoint]=0 bb_outside = numpy.nonzero(self.freePointMask) self.grid.gridPtId[bb_outside] = 99999 compId = self.grid.gridPtId #why a copy? --> can we split ? distance = self.grid.distToClosestSurf[:] grab_callback.distance = distance spacing = self.smallestProteinSize # DEBUG stuff, should be removed later self.jitterVectors = [] self.jitterLength = 0.0 self.totnbJitter = 0 self.maxColl = 0.0 self.successfullJitter = [] self.failedJitter = [] #this function also depend on the ingr.completiion that can be restored ? self.activeIngr0, self.activeIngr12 = self.callFunction(self.getSortedActiveIngredients, (allIngredients,verbose)) print('len(allIngredients', len(allIngredients)) print('len(self.activeIngr0)', len(self.activeIngr0)) print('len(self.activeIngr12)', len(self.activeIngr12)) self.activeIngre_saved = self.activeIngr[:] self.totalPriorities = 0 # 0.00001 for priors in self.activeIngr12: pp = priors.packingPriority self.totalPriorities = self.totalPriorities + pp print('totalPriorities = ', self.totalPriorities) previousThresh = 0 self.normalizedPriorities = [] self.thresholdPriorities = [] # Graham- Once negatives are used, if picked random# # is below a number in this list, that item becomes # the active ingredient in the while loop below for priors in self.activeIngr0: self.normalizedPriorities.append(0) if self.pickWeightedIngr :#why ? self.thresholdPriorities.append(2) for priors in self.activeIngr12: #pp1 = 0 pp = priors.packingPriority if self.totalPriorities != 0: np = float(pp)/float(self.totalPriorities) else: np=0. self.normalizedPriorities.append(np) print('np is ', np, ' pp is ', pp, ' tp is ', np + previousThresh) self.thresholdPriorities.append(np + previousThresh) previousThresh = np + float(previousThresh) self.activeIngr = self.activeIngr0 + self.activeIngr12 nls=0 totalNumMols = 0 self.totalNbIngr = self.getTotalNbObject(allIngredients) if len(self.thresholdPriorities ) == 0: for ingr in allIngredients: totalNumMols += ingr.nbMol print('totalNumMols Fill5if = ', totalNumMols) else : for threshProb in self.thresholdPriorities: nameMe = self.activeIngr[nls] print('threshprop Fill5else is %f for ingredient: %s %s %d'%(threshProb, nameMe,nameMe.name,nameMe.nbMol)) totalNumMols += nameMe.nbMol print('totalNumMols Fill5else = ', totalNumMols) nls+=1 print ("tobj = ",self.totalNbIngr) a=numpy.ones((self.totalNbIngr,3))*999999999.9#*100.0#max ingredient excepted. vRangeStart = 0.0 tCancelPrev=time.time() test = True kk=0 ptInd = 0 PlacedMols = 0 vThreshStart = 0.0 # Added back by Graham on July 5, 2012 from Sept 25, 2011 thesis version #if bullet build the organel rbnode if self.placeMethod == "pandaBullet": self.setupPanda() for o in self.organelles: if o.rbnode is None : o.rbnode = self.addMeshRBOrganelle(o) #============================================================================== # #the big loop #============================================================================== #self.largestProteinSize = 0 #before starting reset largest size self.grabedvalue=[] while nbFreePoints: #breakin test print ("nbFreePoints",nbFreePoints,len(self.activeIngr),vRangeStart) if len(self.activeIngr)==0: print('broken by len****') break if vRangeStart>1: print('broken by vRange and hence Done!!!****') break #we do two pass by dividing the grid on Y by 2*ncpus for p in range(nparts): print ("pass n ",p) grab_callback.reset(grab_callback.nbFreePoints) picked_ingredients=[] for n in range(ncpus): print ("prepare job",n) ingr = self.callFunction(self.pickIngredient,(vThreshStart,)) picked_ingredients.append(ingr) compNum = ingr.compNum radius = ingr.minRadius jitter = self.callFunction(ingr.getMaxJitter,(spacing,)) # compute dpad which is the distance at which we need to update # distances after the drop is successfull mr = self.get_dpad(compNum) dpad = ingr.minRadius + mr + jitter ## find the points that can be used for this ingredients ## in the slice ? res=self.callFunction(self.getPointToDrop,(ingr,radius,jitter, freePoints,nbFreePoints, distance,compId,compNum,vRangeStart,vThreshStart)) # distance,compId,compNum,vRangeStart)) # Replaced this with Sept 25, 2011 thesis version on July 5, 2012 print ("pick",ingr,res) if res[0] : ptInd = res[1] if ptInd > len(distance): print ("problem ",ptInd) continue else : print ("vRangeStart coninue ",res) vRangeStart = res[1] continue # continue # print ("picked ",ptInd) #place the ingrediant if self.overwritePlaceMethod : ingr.placeType = self.placeMethod #check the largestProteinSize #worker ? if ingr.encapsulatingRadius > self.largestProteinSize : self.largestProteinSize = ingr.encapsulatingRadius print ("submit job",n) p=job_server.submit(ingr.place_mp,(self, ptInd, freePoints, nbFreePoints, distance, dpad,True, stepByStep, verbose), modules=("AutoFill",), callback=grab_callback.add) # success, nbFreePoints = self.callFunction(ingr.place,(self, ptInd, # freePoints, nbFreePoints, distance, dpad, # stepByStep, verbose), # {"debugFunc":debugFunc}) print ("after place nbFreePoints",nbFreePoints) job_server.wait() #grab result results=grab_callback.queue[:]#success, nbFreePoints # print ("results",results) nbFreePoints=grab_callback.nbFreePoints print ("cumul freePts",grab_callback.nbFreePoints) #need to cumul freepoints and distance distance = grab_callback.distance[:] freePoints = grab_callback.freePoints[:] # self.molecules = grab_callback.molecules[:] # self.grabedvalue.append(grab_callback.queue[:]) for n in range(ncpus): # print("nbFreePoints after PLACE ",nbFreePoints) ingr = picked_ingredients[n] success = results[n][0] # nbFreePoints = results[n][1] if success: if ingr.encapsulatingRadius > self.largestProteinSize : self.largestProteinSize = ingr.encapsulatingRadius PlacedMols+=1 print ("ingr",ingr.completion,ingr.name) if ingr.completion >= 1.0 : ind = self.activeIngr.index(ingr) if ind > 0: #j = 0 for j in range(ind): if j >= len(self.thresholdPriorities) or j >= len(self.normalizedPriorities): continue self.thresholdPriorities[j] = self.thresholdPriorities[j] + self.normalizedPriorities[ind] self.activeIngr.pop(ind) self.activeIngr0, self.activeIngr12 = self.callFunction(self.getSortedActiveIngredients, (self.activeIngr,verbose)) self.activeIngre_saved = self.activeIngr[:] self.totalPriorities = 0 # 0.00001 for priors in self.activeIngr12: pp = priors.packingPriority self.totalPriorities = self.totalPriorities + pp previousThresh = 0 self.normalizedPriorities = [] self.thresholdPriorities = [] # Graham- Once negatives are used, if picked random# # is below a number in this list, that item becomes #the active ingredient in the while loop below for priors in self.activeIngr0: self.normalizedPriorities.append(0) if self.pickWeightedIngr : self.thresholdPriorities.append(2) for priors in self.activeIngr12: #pp1 = 0 pp = priors.packingPriority if self.totalPriorities != 0: np = float(pp)/float(self.totalPriorities) else: np=0. self.normalizedPriorities.append(np) self.thresholdPriorities.append(np + previousThresh) previousThresh = np + float(previousThresh) self.activeIngr = self.activeIngr0 + self.activeIngr12 #end for part # break self.distancesAfterFill = distance self.freePointsAfterFill = freePoints self.nbFreePointsAfterFill = nbFreePoints self.distanceAfterFill = distance t2 = time.time() print('time to fill', t2-t1) if self.saveResult: self.grid.freePoints = freePoints[:] self.grid.distToClosestSurf = distance[:] #shoul check extension filename for type of saved file self.saveGridToFile(self.resultfile+"grid") self.grid.result_filename = self.resultfile+"grid" self.store() self.store_asTxt() self.store_asJson() print('time to save end', time.time()-t2) ingredients ={} for pos, rot, ingr, ptInd in self.molecules: if ingr.name not in ingredients : ingredients[ingr.name]=[ingr,[],[],[]] mat = rot.copy() mat[:3, 3] = pos ingredients[ingr.name][1].append(pos) ingredients[ingr.name][2].append(rot) ingredients[ingr.name][3].append(numpy.array(mat)) for o in self.organelles: for pos, rot, ingr, ptInd in o.molecules: if ingr.name not in ingredients : ingredients[ingr.name]=[ingr,[],[],[]] mat = rot.copy() mat[:3, 3] = pos ingredients[ingr.name][1].append(pos) ingredients[ingr.name][2].append(rot) ingredients[ingr.name][3].append(numpy.array(mat)) self.ingr_result = ingredients if self.treemode == "bhtree" : from bhtree import bhtreelib bhtreelib.freeBHtree(self.close_ingr_bhtree)
def pack_multi(env, ncpus=1, seedNum=14, stepByStep=False, verbose=False, sphGeom=None, labDistGeom=None, debugFunc=None, name=None, vTestid=3, vAnalysis=0, **kw): ## Fill the grid by picking an ingredient first and then ## this filling should be able to continue from a previous one ## find a suitable point suing hte ingredient's placer object self = env import time import pp nparts = 2 job_server = pp.Server(ncpus=ncpus) t1 = time.time() self.timeUpDistLoopTotal = 0 #Graham added to try to make universal "global variable Verbose" on Aug 28 self.static = [] if self.grid is None: print("no grid setup") return # create a list of active ingredients indices in all recipes to allow # removing inactive ingredients when molarity is reached allIngredients = self.callFunction(self.getActiveIng) nbIngredients = len(allIngredients) self.cFill = self.nFill if name == None: name = "F" + str(self.nFill) self.FillName.append(name) self.nFill += 1 # seed random number generator SEED = seedNum numpy.random.seed(SEED) #for gradient seed(seedNum) self.randomRot.setSeed(seed=seedNum) # create copies of the distance array as they change when molecules # are added, theses array can be restored/saved before feeling freePoints = self.grid.freePoints[:] nbFreePoints = len(freePoints) #-1 grab_callback = GrabResult(nbFreePoints, self) grab_callback.freePoints = freePoints # self.freePointMask = numpy.ones(nbFreePoints,dtype="int32") if "fbox" in kw: # Oct 20, 2012 This is part of the code that is breaking the grids for all meshless organelle fills self.fbox = kw["fbox"] if self.fbox is not None and not self.EnviroOnly: self.freePointMask = numpy.ones(nbFreePoints, dtype="int32") bb_insidepoint = self.grid.getPointsInCube( self.fbox, [0, 0, 0], 1.0)[:] #center and radius ?3,runTime=self.runTimeDisplay self.freePointMask[bb_insidepoint] = 0 bb_outside = numpy.nonzero(self.freePointMask) self.grid.gridPtId[bb_outside] = 99999 compId = self.grid.gridPtId #why a copy? --> can we split ? distance = self.grid.distToClosestSurf[:] grab_callback.distance = distance spacing = self.smallestProteinSize # DEBUG stuff, should be removed later self.jitterVectors = [] self.jitterLength = 0.0 self.totnbJitter = 0 self.maxColl = 0.0 self.successfullJitter = [] self.failedJitter = [] #this function also depend on the ingr.completiion that can be restored ? self.activeIngr0, self.activeIngr12 = self.callFunction( self.getSortedActiveIngredients, (allIngredients, verbose)) print('len(allIngredients', len(allIngredients)) print('len(self.activeIngr0)', len(self.activeIngr0)) print('len(self.activeIngr12)', len(self.activeIngr12)) self.activeIngre_saved = self.activeIngr[:] self.totalPriorities = 0 # 0.00001 for priors in self.activeIngr12: pp = priors.packingPriority self.totalPriorities = self.totalPriorities + pp print('totalPriorities = ', self.totalPriorities) previousThresh = 0 self.normalizedPriorities = [] self.thresholdPriorities = [] # Graham- Once negatives are used, if picked random# # is below a number in this list, that item becomes # the active ingredient in the while loop below for priors in self.activeIngr0: self.normalizedPriorities.append(0) if self.pickWeightedIngr: #why ? self.thresholdPriorities.append(2) for priors in self.activeIngr12: #pp1 = 0 pp = priors.packingPriority if self.totalPriorities != 0: np = float(pp) / float(self.totalPriorities) else: np = 0. self.normalizedPriorities.append(np) print('np is ', np, ' pp is ', pp, ' tp is ', np + previousThresh) self.thresholdPriorities.append(np + previousThresh) previousThresh = np + float(previousThresh) self.activeIngr = self.activeIngr0 + self.activeIngr12 nls = 0 totalNumMols = 0 self.totalNbIngr = self.getTotalNbObject(allIngredients) if len(self.thresholdPriorities) == 0: for ingr in allIngredients: totalNumMols += ingr.nbMol print('totalNumMols Fill5if = ', totalNumMols) else: for threshProb in self.thresholdPriorities: nameMe = self.activeIngr[nls] print('threshprop Fill5else is %f for ingredient: %s %s %d' % (threshProb, nameMe, nameMe.name, nameMe.nbMol)) totalNumMols += nameMe.nbMol print('totalNumMols Fill5else = ', totalNumMols) nls += 1 print("tobj = ", self.totalNbIngr) a = numpy.ones( (self.totalNbIngr, 3)) * 999999999.9 #*100.0#max ingredient excepted. vRangeStart = 0.0 tCancelPrev = time.time() test = True kk = 0 ptInd = 0 PlacedMols = 0 vThreshStart = 0.0 # Added back by Graham on July 5, 2012 from Sept 25, 2011 thesis version #if bullet build the organel rbnode if self.placeMethod == "pandaBullet": self.setupPanda() for o in self.organelles: if o.rbnode is None: o.rbnode = self.addMeshRBOrganelle(o) #============================================================================== # #the big loop #============================================================================== #self.largestProteinSize = 0 #before starting reset largest size self.grabedvalue = [] while nbFreePoints: #breakin test print("nbFreePoints", nbFreePoints, len(self.activeIngr), vRangeStart) if len(self.activeIngr) == 0: print('broken by len****') break if vRangeStart > 1: print('broken by vRange and hence Done!!!****') break #we do two pass by dividing the grid on Y by 2*ncpus for p in range(nparts): print("pass n ", p) grab_callback.reset(grab_callback.nbFreePoints) picked_ingredients = [] for n in range(ncpus): print("prepare job", n) ingr = self.callFunction(self.pickIngredient, (vThreshStart, )) picked_ingredients.append(ingr) compNum = ingr.compNum radius = ingr.minRadius jitter = self.callFunction(ingr.getMaxJitter, (spacing, )) # compute dpad which is the distance at which we need to update # distances after the drop is successfull mr = self.get_dpad(compNum) dpad = ingr.minRadius + mr + jitter ## find the points that can be used for this ingredients ## in the slice ? res = self.callFunction( self.getPointToDrop, (ingr, radius, jitter, freePoints, nbFreePoints, distance, compId, compNum, vRangeStart, vThreshStart)) # distance,compId,compNum,vRangeStart)) # Replaced this with Sept 25, 2011 thesis version on July 5, 2012 print("pick", ingr, res) if res[0]: ptInd = res[1] if ptInd > len(distance): print("problem ", ptInd) continue else: print("vRangeStart coninue ", res) vRangeStart = res[1] continue # continue # print ("picked ",ptInd) #place the ingrediant if self.overwritePlaceMethod: ingr.placeType = self.placeMethod #check the largestProteinSize #worker ? if ingr.encapsulatingRadius > self.largestProteinSize: self.largestProteinSize = ingr.encapsulatingRadius print("submit job", n) p = job_server.submit( ingr.place_mp, (self, ptInd, freePoints, nbFreePoints, distance, dpad, True, stepByStep, verbose), modules=("AutoFill", ), callback=grab_callback.add) # success, nbFreePoints = self.callFunction(ingr.place,(self, ptInd, # freePoints, nbFreePoints, distance, dpad, # stepByStep, verbose), # {"debugFunc":debugFunc}) print("after place nbFreePoints", nbFreePoints) job_server.wait() #grab result results = grab_callback.queue[:] #success, nbFreePoints # print ("results",results) nbFreePoints = grab_callback.nbFreePoints print("cumul freePts", grab_callback.nbFreePoints) #need to cumul freepoints and distance distance = grab_callback.distance[:] freePoints = grab_callback.freePoints[:] # self.molecules = grab_callback.molecules[:] # self.grabedvalue.append(grab_callback.queue[:]) for n in range(ncpus): # print("nbFreePoints after PLACE ",nbFreePoints) ingr = picked_ingredients[n] success = results[n][0] # nbFreePoints = results[n][1] if success: if ingr.encapsulatingRadius > self.largestProteinSize: self.largestProteinSize = ingr.encapsulatingRadius PlacedMols += 1 print("ingr", ingr.completion, ingr.name) if ingr.completion >= 1.0: ind = self.activeIngr.index(ingr) if ind > 0: #j = 0 for j in range(ind): if j >= len(self.thresholdPriorities) or j >= len( self.normalizedPriorities): continue self.thresholdPriorities[ j] = self.thresholdPriorities[ j] + self.normalizedPriorities[ind] self.activeIngr.pop(ind) self.activeIngr0, self.activeIngr12 = self.callFunction( self.getSortedActiveIngredients, (self.activeIngr, verbose)) self.activeIngre_saved = self.activeIngr[:] self.totalPriorities = 0 # 0.00001 for priors in self.activeIngr12: pp = priors.packingPriority self.totalPriorities = self.totalPriorities + pp previousThresh = 0 self.normalizedPriorities = [] self.thresholdPriorities = [] # Graham- Once negatives are used, if picked random# # is below a number in this list, that item becomes #the active ingredient in the while loop below for priors in self.activeIngr0: self.normalizedPriorities.append(0) if self.pickWeightedIngr: self.thresholdPriorities.append(2) for priors in self.activeIngr12: #pp1 = 0 pp = priors.packingPriority if self.totalPriorities != 0: np = float(pp) / float(self.totalPriorities) else: np = 0. self.normalizedPriorities.append(np) self.thresholdPriorities.append(np + previousThresh) previousThresh = np + float(previousThresh) self.activeIngr = self.activeIngr0 + self.activeIngr12 #end for part # break self.distancesAfterFill = distance self.freePointsAfterFill = freePoints self.nbFreePointsAfterFill = nbFreePoints self.distanceAfterFill = distance t2 = time.time() print('time to fill', t2 - t1) if self.saveResult: self.grid.freePoints = freePoints[:] self.grid.distToClosestSurf = distance[:] #shoul check extension filename for type of saved file self.saveGridToFile(self.resultfile + "grid") self.grid.result_filename = self.resultfile + "grid" self.store() self.store_asTxt() self.store_asJson() print('time to save end', time.time() - t2) ingredients = {} for pos, rot, ingr, ptInd in self.molecules: if ingr.name not in ingredients: ingredients[ingr.name] = [ingr, [], [], []] mat = rot.copy() mat[:3, 3] = pos ingredients[ingr.name][1].append(pos) ingredients[ingr.name][2].append(rot) ingredients[ingr.name][3].append(numpy.array(mat)) for o in self.organelles: for pos, rot, ingr, ptInd in o.molecules: if ingr.name not in ingredients: ingredients[ingr.name] = [ingr, [], [], []] mat = rot.copy() mat[:3, 3] = pos ingredients[ingr.name][1].append(pos) ingredients[ingr.name][2].append(rot) ingredients[ingr.name][3].append(numpy.array(mat)) self.ingr_result = ingredients if self.treemode == "bhtree": from bhtree import bhtreelib bhtreelib.freeBHtree(self.close_ingr_bhtree)