Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrm committed Sep 21, 2023
1 parent b665e77 commit 7836419
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 230 deletions.
52 changes: 46 additions & 6 deletions cellpack/autopack/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,42 @@ def get_ingredient_by_name(self, name, compartment_id=None):
else:
return None

def get_ingredients_in_tree(self, closest_ingredients):
ingredients = []
packed_objects = self.packed_objects.get()
if len(packed_objects):
nearby_packed_objects = [
packed_objects[i] for i in closest_ingredients["indices"]
]
for obj in nearby_packed_objects:
ingredients.append([obj, closest_ingredients["distances"]])
return ingredients

def get_closest_ingredients(self, point, cutoff=10.0):
to_return = {"indices": [], "distances": []}
numpy.zeros(self.totalNbIngr).astype("i")
nb = 0
number_packed = len(self.packed_objects.get())
if not number_packed:
return to_return
if self.close_ingr_bhtree is not None:
# request kdtree
nb = []
self.log.info("finding partners")

if number_packed >= 1:
distance, nb = self.close_ingr_bhtree.query(
point, number_packed, distance_upper_bound=cutoff
) # len of ingr posed so far
if number_packed == 1:
distance = [distance]
nb = [nb]
to_return["indices"] = nb
to_return["distances"] = distance # sorted by distance short -> long
return to_return
else:
return to_return

def setExteriorRecipe(self, recipe):
"""
Set the exterior recipe with the given one. Create the weakref.
Expand Down Expand Up @@ -1264,14 +1300,13 @@ def onePrevIngredient(self, i, mingrs, distance, nbFreePoints, marray):
spacing = self.smallestProteinSize
jitter = ingr.getMaxJitter(spacing)
dpad = ingr.min_radius + mr + jitter
insidePoints, newDistPoints = ingr.getInsidePoints(
self.grid,
self.grid.masterGridPositions,
dpad,
distance,
centT=centT,
insidePoints, newDistPoints = ingr.get_new_distance_values(
jtrans=jtrans,
rotMatj=rotMatj,
gridPointsCoords=self.grid.masterGridPositions,
distance=distance,
dpad=dpad,
centT=centT,
)
# update free points
if len(insidePoints) and self.place_method.find("panda") != -1:
Expand Down Expand Up @@ -1816,6 +1851,11 @@ def set_result_file_name(self, seed_basename):
"""
self.result_file = str(self.out_folder / f"results_{seed_basename}")

def update_after_place(self, grid_point_index):
self.order[grid_point_index] = self.lastrank
self.lastrank += 1
self.nb_ingredient += 1

def pack_grid(
self,
seedNum=0,
Expand Down
Loading

0 comments on commit 7836419

Please sign in to comment.