Skip to content

Commit

Permalink
reescale function now receives an input complex as cpx, makes a copy …
Browse files Browse the repository at this point in the history
…from it, complex = cpx.copy() and works with the copied object from then onwards
  • Loading branch information
Pau Ferri-Vicedo committed Nov 18, 2024
1 parent e6083b6 commit 92b69a6
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions VOID/dockers/success.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def dock_at_point(self, point, attempts):
hcoords = self.translate_host(point)

for trial in range(attempts):
cpx = self.create_new_complex(
host_coords=hcoords, guest_coords=self.rotate_guest()
)
cpx = self.create_new_complex(host_coords=hcoords, guest_coords=self.rotate_guest())

if self.fitness(cpx) >= 0:
print(f"{trial + 1} attempts to success")
Expand All @@ -32,9 +30,7 @@ def dock_at_point(self, point, attempts):

class SuccessMonteCarloDocker(MonteCarloDocker):
PARSER_NAME = "mcsuccess"
HELP = (
"Docks guests to host until a successful docking is found (Monte Carlo version)"
)
HELP = "Docks guests to host until a successful docking is found (Monte Carlo version)"

def dock(self, attempts):
cpx = Complex(self.host.copy(), self.guest.copy())
Expand All @@ -49,7 +45,7 @@ def dock(self, attempts):

return []

def rescale(self, complex):
def rescale(self, cpx):
"""Rescale the complex to the 0-1 range so results can be visualized in direct and xyz format.
Args:
Expand All @@ -58,6 +54,7 @@ def rescale(self, complex):
Returns:
Complex: The rescaled host-guest complex object.
"""
complex = cpx.copy()
lattice = complex.pose.lattice
frac_coords = []
species_list = []
Expand All @@ -66,18 +63,12 @@ def rescale(self, complex):
for site in complex.pose:
site_labels.append(site.label)
species_list.append(site.species)
coords = (
site.frac_coords
if site.label == "host"
else np.mod(site.frac_coords, 1.0)
)
coords = site.frac_coords if site.label == "host" else np.mod(site.frac_coords, 1.0)
frac_coords.append(coords)

site_properties = {"label": site_labels}

updated_structure = Structure(
lattice, species_list, frac_coords, site_properties=site_properties
)
updated_structure = Structure(lattice, species_list, frac_coords, site_properties=site_properties)

num_host_atoms = len(complex.host)

Expand Down

0 comments on commit 92b69a6

Please sign in to comment.