diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index ac80e98..76f5fdd 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -37,15 +37,16 @@ jobs: python -m pip install -e . python -m pytest --cov --cov-config=.coveragerc - name: Run export with test data + timeout-minutes: 15 run: | sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super -y - python3 scripts/run_herg_qc.py tests/test_data/13112023_MW2_FF + pcpostprocess run_herg_qc tests/test_data/13112023_MW2_FF -w A01 A02 A03 - uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - name: Lint with flake8 run: | - python -m flake8 pcpostprocess/*.py tests/*.py scripts/*.py + python -m flake8 pcpostprocess/*.py tests/*.py pcpostprocess/scripts/*.py - name: Import sorting with isort run: | python -m isort --verbose --check-only --diff pcpostprocess tests setup.py diff --git a/README.md b/README.md index efd3439..536bc43 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,75 @@ Then you can run the tests. python3 -m unittest ``` + + +## Usage + +### Running QC and post-processing + +``` +$ pcpostprocess run_herg_qc --help + +usage: pcpostprocess run_herg_qc [-h] [-c NO_CPUS] + [--output_dir OUTPUT_DIR] [-w WELLS [WELLS ...]] + [--protocols PROTOCOLS [PROTOCOLS ...]] + [--reversal_spread_threshold REVERSAL_SPREAD_THRESHOLD] [--export_failed] + [--selection_file SELECTION_FILE] [--subtracted_only] + [--figsize FIGSIZE FIGSIZE] + [--debug] [--log_level LOG_LEVEL] [--Erev EREV] + data_directory + +positional arguments: + data_directory + +options: + -h, --help show this help message and exit + -c NO_CPUS, --no_cpus NO_CPUS + --output_dir OUTPUT_DIR + -w WELLS [WELLS ...], --wells WELLS [WELLS ...] + --protocols PROTOCOLS [PROTOCOLS ...] + --reversal_spread_threshold REVERSAL_SPREAD_THRESHOLD + --export_failed + --selection_file SELECTION_FILE + --subtracted_only + --figsize FIGSIZE FIGSIZE + --debug + --log_level LOG_LEVEL + --Erev EREV +``` + + +### Exporting Summary + +``` +$ pcpostprocess summarise_herg_export --help + +usage: pcpostprocess summarise_herg_export [-h] [--cpus CPUS] + [--wells WELLS [WELLS ...]] [--output OUTPUT] + [--protocols PROTOCOLS [PROTOCOLS ...]] [-r REVERSAL] + [--experiment_name EXPERIMENT_NAME] + [--figsize FIGSIZE FIGSIZE] [--output_all] + [--log_level LOG_LEVEL] + data_dir qc_estimates_file + +positional arguments: + data_dir path to the directory containing the subtract_leak results + qc_estimates_file + +options: + -h, --help show this help message and exit + --cpus CPUS, -c CPUS + --wells WELLS [WELLS ...], -w WELLS [WELLS ...] + --output OUTPUT, -o OUTPUT + --protocols PROTOCOLS [PROTOCOLS ...] + -r REVERSAL, --reversal REVERSAL + --experiment_name EXPERIMENT_NAME + --figsize FIGSIZE FIGSIZE + --output_all + --log_level LOG_LEVEL +``` + + ## Contributing diff --git a/pcpostprocess/scripts/__init__.py b/pcpostprocess/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pcpostprocess/scripts/__main__.py b/pcpostprocess/scripts/__main__.py new file mode 100644 index 0000000..40c7dcb --- /dev/null +++ b/pcpostprocess/scripts/__main__.py @@ -0,0 +1,28 @@ +import argparse +import sys + +from . import run_herg_qc, summarise_herg_export + + +def main(): + parser = argparse.ArgumentParser( + usage="pcpostprocess (run_herg_qc | summarise_herg_export) []", + ) + parser.add_argument( + "subcommand", + choices=["run_herg_qc", "summarise_herg_export"], + ) + args = parser.parse_args(sys.argv[1:2]) + + sys.argv[0] = f"pcpostprocess {args.subcommand}" + sys.argv.pop(1) # Subcommand's argparser shouldn't see this + + if args.subcommand == "run_herg_qc": + run_herg_qc.main() + + elif args.subcommand == "summarise_herg_export": + summarise_herg_export.main() + + +if __name__ == "__main__": + main() diff --git a/scripts/run_herg_qc.py b/pcpostprocess/scripts/run_herg_qc.py similarity index 100% rename from scripts/run_herg_qc.py rename to pcpostprocess/scripts/run_herg_qc.py diff --git a/scripts/summarise_herg_export.py b/pcpostprocess/scripts/summarise_herg_export.py similarity index 99% rename from scripts/summarise_herg_export.py rename to pcpostprocess/scripts/summarise_herg_export.py index 9f82427..6acbabf 100644 --- a/scripts/summarise_herg_export.py +++ b/pcpostprocess/scripts/summarise_herg_export.py @@ -12,10 +12,11 @@ import regex as re import scipy import seaborn as sns -from run_herg_qc import create_qc_table from syncropatch_export.voltage_protocols import VoltageProtocol -matplotlib.rcParams['figure.dpi'] = 300 +from pcpostprocess.scripts.run_herg_qc import create_qc_table + +matplotlib.use('Agg') pool_kws = {'maxtasksperchild': 1} diff --git a/setup.py b/setup.py index 53fc22d..540ca4e 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # Packages to include packages=find_packages( - include=('pcpostprocess', 'pcpostprocess.*')), + include=('pcpostprocess', 'pcpostprocess.scripts', 'pcpostprocess.*')), # Include non-python files (via MANIFEST.in) include_package_data=True, @@ -46,6 +46,7 @@ 'regex>=2023.12.25', 'openpyxl>=3.1.2', 'jinja2>=3.1.0', + 'seaborn>=0.12.2' ], extras_require={ 'test': [ @@ -58,4 +59,10 @@ 'syncropatch_export @ git+ssh://git@github.com/CardiacModelling/syncropatch_export@main' ], }, + entry_points={ + 'console_scripts': [ + 'pcpostprocess=' + 'pcpostprocess.scripts.__main__:main', + ], + }, )