Skip to content

Commit

Permalink
silences warning in plan_radial_network when int passed
Browse files Browse the repository at this point in the history
previously would warn about duplicates when not necessary
  • Loading branch information
richardjgowers committed Mar 8, 2024
1 parent ea4f593 commit 9e4ae4d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion openfe/setup/ligand_network_planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ def generate_radial_network(
# handle central_ligand arg possibilities
# after this, central_ligand is resolved to a SmallMoleculeComponent
if isinstance(central_ligand, int):
central_ligand_index = central_ligand
ligands = list(ligands)
try:
central_ligand = ligands[central_ligand]
central_ligand = ligands[central_ligand_index]
except IndexError:
raise ValueError(f"index '{central_ligand}' out of bounds, there are "
f"{len(ligands)} ligands")
# you could do a list comprehension like:
# ligands = [l for l in ligands if l != central]
# but this wouldn't properly catch when multiple identical central ligands have been passed
# so instead slice out the central ligand
ligands = ligands[:central_ligand_index] + ligands[central_ligand_index + 1:]
elif isinstance(central_ligand, str):
ligands = list(ligands)
possibles = [l for l in ligands if l.name == central_ligand]
Expand Down

0 comments on commit 9e4ae4d

Please sign in to comment.