Skip to content
Open
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
10 changes: 7 additions & 3 deletions .github/workflows/test-spras.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ jobs:
# Install spras in the environment using pip
shell: bash --login {0}
run: pip install .
- name: Log conda environment
# Log conda environment contents
- name: Get pipx
shell: bash --login {0}
run: pip install pipx
- shell: bash --login {0}
run: pipx install .
- name: Log conda environment contents
shell: bash --login {0}
run: conda list
- name: Install Apptainer
Expand Down Expand Up @@ -91,7 +95,7 @@ jobs:
# We enable high parallelization (cores 4) to test our way out of the experienced
# race conditions from #268 and #279
# We also enforce strict DAG evaluation to catch DAG problems before they appear as user errors. (#359)
run: snakemake --cores 4 --configfile config/config.yaml --show-failed-logs --strict-dag-evaluation cyclic-graph --strict-dag-evaluation functions --strict-dag-evaluation periodic-wildcards
run: spras run --cores 4 --configfile config/config.yaml --show-failed-logs --strict-dag-evaluation cyclic-graph --strict-dag-evaluation functions --strict-dag-evaluation periodic-wildcards

# Run pre-commit checks on source files
pre-commit:
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include README.md
include LICENSE
include Snakefile
include spras/cgroup_wrapper.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ After installing Docker, start Docker before running SPRAS.
Once you have activated the conda environment and started Docker, you can run SPRAS with the example Snakemake workflow.
From the root directory of the `spras` repository, run the command
```
snakemake --cores 1 --configfile config/config.yaml
spras run --cores 1 --configfile config/config.yaml
```
This will run the SPRAS workflow with the example config file (`config/config.yaml`) and input files.
Output files will be written to the `output` directory.
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ through SPRAS with

.. code:: bash

snakemake --cores 1 --configfile config/config.yaml
spras run --cores 1 --configfile config/config.yaml

Make sure to run the command inside the ``spras`` conda environment.

Expand Down
6 changes: 3 additions & 3 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Using SPRAS
===========

SPRAS is run through `Snakemake <https://snakemake.readthedocs.io/>`_, which comes
with the SPRAS conda environment.
with both the SPRAS conda environment and as a dependency of SPRAS.

To run SPRAS, run the following command inside the ``spras`` directory,
specifying a ``config.yaml`` and the number of cores to run SPRAS with:

.. code-block:: bash

snakemake --cores 1 --configfile config.yaml
spras run --cores 1 --configfile config.yaml

Parallelizing SPRAS
-------------------
Expand All @@ -23,7 +23,7 @@ To parallelize SPRAS, specify ``--cores`` to be a value higher than ``1``:

.. code-block:: bash

snakemake --cores 4 --configfile config.yaml
spras run --cores 4 --configfile config.yaml

SPRAS also supports high-performance computing with it's integration with
`HTCondor <https://htcondor.org/>`_. See :doc:`Running with HTCondor <../htcondor>`
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ dev = [
"Homepage" = "https://github.com/Reed-CompBio/spras"
"Issues" = "https://github.com/Reed-CompBio/spras/issues"

[project.entry-points."pipx.run"]
spras = "spras.cli:run"

[project.scripts]
spras = "spras.cli:run"

[build-system]
requires = ["setuptools>=64.0"]
build-backend = "setuptools.build_meta"
Expand Down
3 changes: 3 additions & 0 deletions spras/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if __name__ == "__main__":
from spras.cli import run
run()
53 changes: 53 additions & 0 deletions spras/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import argparse
import itertools
import os
import subprocess
from pathlib import Path

# https://stackoverflow.com/a/5137509/7589775
# The file we want, Snakefile, is also included in MANIFEST.in
dir_path = os.path.dirname(os.path.realpath(__file__))
# we resolve to simplify the path name in errors
snakefile_path = Path(dir_path, "..", "Snakefile").resolve()

# Removes the very awkwardly phrased "{subcommand1, subcommand2}" from the subcommand help
# from https://stackoverflow.com/a/13429281/7589775
class SubcommandHelpFormatter(argparse.RawDescriptionHelpFormatter):
def _format_action(self, action):
parts = super(argparse.RawDescriptionHelpFormatter, self)._format_action(action)
if action.nargs == argparse.PARSER:
parts = "\n".join(parts.split("\n")[1:])
return parts

def get_parser():
parser = argparse.ArgumentParser(
prog='SPRAS',
description='The wrapping tool for SPRAS (signaling pathway reconstruction analysis streamliner)',
epilog='SPRAS is in alpha. Report issues or suggest features on GitHub: https://github.com/Reed-CompBio/spras',
formatter_class=SubcommandHelpFormatter)

subparsers = parser.add_subparsers(title='subcommands',
help='subcommand help',
dest='subcommand')
subparsers = subparsers.add_parser('run',
help='Run the SPRAS Snakemake workflow',
# We let snakemake handle help
add_help=False)

return parser

def run():
parser = get_parser()
(args, unknown_args) = parser.parse_known_args()

if args.subcommand == "run":
subprocess.run(list(itertools.chain(
["snakemake", "-s", snakefile_path],
unknown_args
)))
return

parser.print_help()

if __name__ == '__main__':
run()
Loading