Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide aliases for CLI scripts #84

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions doc/source/usage/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ Command Line Interface
======================

Command line interfaces (CLI) are provided for the two most common tasks:
conformer generation and fingerprinting. At the moment, using the CLI requires
:ref:`downloading the E3FP source <install:Option 3: Install from source>`.

In the below examples, we assume the E3FP repository is located at
``$E3FP_REPO``.
conformer generation and fingerprinting.
When e3fp is installed, the CLI commands are available as ``e3fp-conformer`` and
``e3fp-fingerprint``.

Conformer Generation CLI
------------------------

To see all available options, run

.. command-output:: python $E3FP_REPO/src/e3fp/conformer/generate.py --help
.. command-output:: e3fp-conformer --help
:shell:

We will generate conformers for the molecule whose SMILES string is defined in
Expand All @@ -26,7 +24,7 @@ The below example generates at most 3 conformers for this molecule.

.. code-block:: shell-session

$ python $E3FP_REPO/src/e3fp/conformer/generate.py -s caffeine.smi --num_conf 3 -o ./
$ e3fp-conformer -s caffeine.smi --num_conf 3 -o ./
2017-07-17 00:11:05,743|WARNING|Only 1 processes available. 'mpi' mode not available.
2017-07-17 00:11:05,748|INFO|num_proc is not specified. 'processes' mode will use all 8 processes
2017-07-17 00:11:05,748|INFO|Parallelizer initialized with mode 'processes' and 8 processors.
Expand Down Expand Up @@ -54,14 +52,14 @@ Fingerprinting CLI

To see all available options, run

.. command-output:: python $E3FP_REPO/src/e3fp/fingerprint/generate.py --help
.. command-output:: e3fp-fingerprint --help
:shell:

To continue the above example, we will fingerprint our caffeine conformers.

.. code-block:: shell-session

$ python $E3FP_REPO/src/e3fp/fingerprint/generate.py caffeine.sdf.bz2 --bits 1024
$ e3fp-fingerprint caffeine.sdf.bz2 --bits 1024
2017-07-17 00:12:33,797|WARNING|Only 1 processes available. 'mpi' mode not available.
2017-07-17 00:12:33,801|INFO|num_proc is not specified. 'processes' mode will use all 8 processes
2017-07-17 00:12:33,801|INFO|Parallelizer initialized with mode 'processes' and 8 processors.
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ dev = [
Homepage = "https://github.com/keiserlab/e3fp"
Download = "https://github.com/keiserlab/e3fp/tarball/{version}"

[project.scripts]
e3fp-fingerprint = "e3fp.fingerprint.generate:main"
e3fp-conformer = "e3fp.conformer.generate:main"

[tool.pytest.ini_options]
addopts = "-ra -q"
testpaths = ["e3fp/test"]
Expand Down
6 changes: 5 additions & 1 deletion src/e3fp/conformer/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def run(
hdf5_buffer.close()


if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser(
"Generate conformers from mol2 or SMILES",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
Expand Down Expand Up @@ -599,3 +599,7 @@ def run(

kwargs = dict(params._get_kwargs())
run(**kwargs)


if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion src/e3fp/fingerprint/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def run(
list(results_iter)


if __name__ == "__main__":
def main():
parser = argparse.ArgumentParser(
"""Generate E3FP fingerprints from SDF files.""",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
Expand Down Expand Up @@ -512,3 +512,7 @@ def run(
kwargs = dict(params._get_kwargs())
sdf_files = kwargs.pop("sdf_files")
run(sdf_files, **kwargs)


if __name__ == "__main__":
main()
Loading