Skip to content

Commit

Permalink
python plex_init in auto_run mode (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
acashmoney committed Aug 31, 2023
1 parent e3faea2 commit c7328d7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
4 changes: 3 additions & 1 deletion docs/docs/reference/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ The following functions are considered core when using the plex [pip package](ht
def plex_init(
tool_path: str,
scattering_method=ScatteringMethod.DOT_PRODUCT.value,
plex_path="plex",
plex_path="plex",
auto_run=False,
**kwargs
)
```
Expand All @@ -42,6 +43,7 @@ initial_io_cid = plex_init(
* **dotProduct:** Pairs corresponding elements from each input vector into subarrays. Requires all input vectors to have the same length.
* **crossProduct:** Generates all combinations of elements across input vectors, forming the Cartesian product. Input vector lengths can vary.
* `plex_path` *str*, *optional* - path pointing to plex binary
* `auto_run` *bool*, *optional* - automatically submits the job for computation based on the IO JSON
* `**kwargs` *keyword arguments*, *optional* - additional parameters in the form of a list, where keys are input names and values are input values; see each tool config for specific arguments accepted

---
Expand Down
22 changes: 18 additions & 4 deletions python/dev/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,29 @@
small_molecules = [f"{test_data_dir}/binding/abl/ZINC000003986735.sdf", f"{test_data_dir}/binding/abl/ZINC000019632618.sdf"]
proteins = [f"{test_data_dir}/binding/abl/7n9g.pdb"]

initial_io_cid = plex_init(
# Custom annotations for testing
custom_annotations = ["python_example", "test"]

print(f"Testing plex_init with auto_run flag set to True")

test_io_cid = plex_init(
CoreTools.EQUIBIND.value,
ScatteringMethod.CROSS_PRODUCT.value,
auto_run=True,
plex_path=plex_path,
small_molecule=small_molecules,
protein=proteins)
protein=proteins,
)

# Custom annotations for testing
custom_annotations = ["python_example", "test"]
print(f"Testing plex_init with auto_run flag set to False")

initial_io_cid = plex_init(
CoreTools.EQUIBIND.value,
ScatteringMethod.CROSS_PRODUCT.value,
plex_path=plex_path,
small_molecule=small_molecules,
protein=proteins
)

# check that environmental variable for recipient wallet is set
if not os.environ.get('RECIPIENT_WALLET'):
Expand Down
4 changes: 2 additions & 2 deletions python/src/plex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, message):
super().__init__(f"{self.message}\n{self.github_issue_message}")


def plex_init(tool_path: str, scattering_method=ScatteringMethod.DOT_PRODUCT.value, plex_path="plex", **kwargs):
def plex_init(tool_path: str, scattering_method=ScatteringMethod.DOT_PRODUCT.value, plex_path="plex", auto_run=False, **kwargs):
cwd = os.getcwd()
plex_work_dir = os.environ.get("PLEX_WORK_DIR", os.path.dirname(os.path.dirname(cwd)))

Expand All @@ -55,7 +55,7 @@ def plex_init(tool_path: str, scattering_method=ScatteringMethod.DOT_PRODUCT.val
# Convert kwargs dictionary to a JSON string
inputs = json.dumps(kwargs)

cmd = [plex_path, "init", "-t", tool_path, "-i", inputs, f"--scatteringMethod={scattering_method}"]
cmd = [plex_path, "init", "-t", tool_path, "-i", inputs, f"--scatteringMethod={scattering_method}", f"--autoRun={str(auto_run).lower()}"]

print(' '.join(cmd))

Expand Down

0 comments on commit c7328d7

Please sign in to comment.