Skip to content

Commit 57680a1

Browse files
authored
Provide aliases for CLI scripts (#84)
* Alias CLI scripts as CLI commands * Define main function for scripts * Update CLI docs
1 parent 3d51f6d commit 57680a1

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

doc/source/usage/cli.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ Command Line Interface
22
======================
33

44
Command line interfaces (CLI) are provided for the two most common tasks:
5-
conformer generation and fingerprinting. At the moment, using the CLI requires
6-
:ref:`downloading the E3FP source <install:Option 3: Install from source>`.
7-
8-
In the below examples, we assume the E3FP repository is located at
9-
``$E3FP_REPO``.
5+
conformer generation and fingerprinting.
6+
When e3fp is installed, the CLI commands are available as ``e3fp-conformer`` and
7+
``e3fp-fingerprint``.
108

119
Conformer Generation CLI
1210
------------------------
1311

1412
To see all available options, run
1513

16-
.. command-output:: python $E3FP_REPO/src/e3fp/conformer/generate.py --help
14+
.. command-output:: e3fp-conformer --help
1715
:shell:
1816

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

2725
.. code-block:: shell-session
2826
29-
$ python $E3FP_REPO/src/e3fp/conformer/generate.py -s caffeine.smi --num_conf 3 -o ./
27+
$ e3fp-conformer -s caffeine.smi --num_conf 3 -o ./
3028
2017-07-17 00:11:05,743|WARNING|Only 1 processes available. 'mpi' mode not available.
3129
2017-07-17 00:11:05,748|INFO|num_proc is not specified. 'processes' mode will use all 8 processes
3230
2017-07-17 00:11:05,748|INFO|Parallelizer initialized with mode 'processes' and 8 processors.
@@ -54,14 +52,14 @@ Fingerprinting CLI
5452

5553
To see all available options, run
5654

57-
.. command-output:: python $E3FP_REPO/src/e3fp/fingerprint/generate.py --help
55+
.. command-output:: e3fp-fingerprint --help
5856
:shell:
5957

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

6260
.. code-block:: shell-session
6361
64-
$ python $E3FP_REPO/src/e3fp/fingerprint/generate.py caffeine.sdf.bz2 --bits 1024
62+
$ e3fp-fingerprint caffeine.sdf.bz2 --bits 1024
6563
2017-07-17 00:12:33,797|WARNING|Only 1 processes available. 'mpi' mode not available.
6664
2017-07-17 00:12:33,801|INFO|num_proc is not specified. 'processes' mode will use all 8 processes
6765
2017-07-17 00:12:33,801|INFO|Parallelizer initialized with mode 'processes' and 8 processors.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ dev = [
6464
Homepage = "https://github.com/keiserlab/e3fp"
6565
Download = "https://github.com/keiserlab/e3fp/tarball/{version}"
6666

67+
[project.scripts]
68+
e3fp-fingerprint = "e3fp.fingerprint.generate:main"
69+
e3fp-conformer = "e3fp.conformer.generate:main"
70+
6771
[tool.pytest.ini_options]
6872
addopts = "-ra -q"
6973
testpaths = ["e3fp/test"]

src/e3fp/conformer/generate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def run(
451451
hdf5_buffer.close()
452452

453453

454-
if __name__ == "__main__":
454+
def main():
455455
parser = argparse.ArgumentParser(
456456
"Generate conformers from mol2 or SMILES",
457457
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -604,3 +604,7 @@ def run(
604604

605605
kwargs = dict(params._get_kwargs())
606606
run(**kwargs)
607+
608+
609+
if __name__ == "__main__":
610+
main()

src/e3fp/fingerprint/generate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def run(
382382
list(results_iter)
383383

384384

385-
if __name__ == "__main__":
385+
def main():
386386
parser = argparse.ArgumentParser(
387387
"""Generate E3FP fingerprints from SDF files.""",
388388
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
@@ -520,3 +520,7 @@ def run(
520520
kwargs = dict(params._get_kwargs())
521521
sdf_files = kwargs.pop("sdf_files")
522522
run(sdf_files, **kwargs)
523+
524+
525+
if __name__ == "__main__":
526+
main()

0 commit comments

Comments
 (0)