Skip to main content

SciCommander

Run Python Tests

This is a small tool that executes single shell commands in a scientifically more reproducible and robust way, by doing the following things:

  • Auditing: Creating an audit log of most output files
  • Caching: Skipping executions where output files already exist
  • (Coming soon): Atomic writes - Writes files to a temporary location until command is finished

Requirements

  • A unix like operating system such as Linux or Mac OS (On Windows you can use WSL or MSYS2)
  • Python 3.6 or higher
  • A bash shell
  • For graph plotting for the HTML report, you need GraphViz and its dot command.

Installation

pip install scicommander

This will install the scicmd command into your PATH variable, so that it should be executable from your shell.

Usage

To view the options of the scicmd command, execute:

scicmd -h

To get the benefits from SciCommander, do the following:

  1. Prepend all your shell commands with the scicmd -c command.
  2. Wrap the command itself in quotes, either "" or ''. This is not strictly required always, but will be required for example if using redirection using > or piping with | (Alternatively one can just add quotes around those).
  3. Wrap definitions of input fields in {i:INPATH} and output files in {o:OUTPATH} for output paths.
  4. You can also just prepend input paths with i: and output paths with o:, but this is a slightly less robust method, that might fail to wrap the correct number of characters in some situations.
  5. Then run your script as usual.

Now you will notice that if you run your script again, it will skip all commands that have already finished and produced output files.

You will also have files with the extension .au.json for every output that you decorated with the syntax above.

To convert such an audit report into a nice HTML-report, run the following:

scicmd --to-html <audit-file>

Example

To demonstrate how you can use SciCommander, imagine that you want to write the following little bioinformatics pipeline, that writes some DNA and converts its reverse complement, as a shell script, my_pipeline.sh:

#!/bin/bash

# Create a fasta file with some DNA
echo AAAGCCCGTGGGGGACCTGTTC > o:dna.fa
# Compute the complement sequence
cat i:dna.fa | tr ACGT TGCA > o:dna.compl.fa
# Reverse the DNA string
cat i:dna.compl.fa | rev > o:dna.compl.rev.fa

Now, to make the commands run through SciCommander, change the syntax in the script like this:

#!/bin/bash

# Create a fasta file with some DNA
scicmd -c echo AAAGCCCGTGGGGGACCTGTTC '>' o:dna.fa
# Compute the complement sequence
scicmd -c cat i:dna.fa '|' tr ACGT TGCA '>' o:dna.compl.fa
# Reverse the DNA string
scicmd -c cat i:dna.compl.fa '|' rev '>' o:dna.compl.rev.fa

Notice how all input paths are prepended with i: and output paths with o:, and also that we had to wrap all pipe characters (|) and redirection characters (>) in quotes. This is so that they are not grabbed by bash immediately, but instead passed with the command to SciCommander, and executed as part of its execution.

Now you can run the script as usual, e.g. with:

bash my_pipeline.sh

Now, the files in your folder will look like this, if you list them with ls -tr:

my_pipeline.sh
dna.fa.au.json
dna.fa
dna.compl.fa.au.json
dna.compl.fa
dna.compl.rev.fa.au.json
dna.compl.rev.fa

Now, you see that the last .au.json file is dna.compl.rev.fa.au.json.

To convert this file to HTML and view it in a browser, you can do:

scicmd --to-html dna.compl.rev.fa.au.json

Then you will see an HTML page like this

Experimental: Bash integration

There is very early and experimental support for running SciCommander commands in bash, without needing to run them via the scicmd -c command.

To do this, start the SciCommander shell with the following command:

scishell

And then, you can run the example commands above as follows:

# Create a fasta file with some DNA
echo AAAGCCCGTGGGGGACCTGTTC > o:dna.fa
# Compute the complement sequence
cat i:dna.fa | tr ACGT TGCA > o:dna.compl.fa
# Reverse the DNA string
cat i:dna.compl.fa | rev > o:dna.compl.rev.fa

In other words, only the i: and o: markers are now needed, and no extra syntax.

Notes

[1] Although Nextflow and Snakemake already take care of some of the benefits, such as atomic writes, SciCommander adds additional features such as detailed per-output audit logs.

Release files for scicommander 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scicommander 0.3.3
File Size Uploaded
scicommander-0.3.3.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scicommander 0.3.3
File Interpreter ABI Platform
scicommander-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size:14.1 kB

Release files / scicommander-0.3.3.tar.gz

Download URL scicommander-0.3.3.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
903d401392ba5fd82270914c825bf2bb09b51559ed23ee915e2609f5b8c06528
BLAKE2b-256 checksum
How to use checksums
245cccb3652a7e9f6643e2564fe60becb3e3b2e396825ce46d521c99a29efdb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / scicommander-0.3.3-py3-none-any.whl

Download URL scicommander-0.3.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ecaa85a3dbc042b07dbba483f2041beaf3e9f804e59016a80e88cb5d15ed2fd7
BLAKE2b-256 checksum
How to use checksums
4ae1fc19c071f8a76f099169a582091a97eeb54a540e0e6c629289ca7d0d8ab7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page