Skip to content

Commit

Permalink
Merge pull request #17 from CardiacModelling/make-scripts-modules
Browse files Browse the repository at this point in the history
Make scripts modules
  • Loading branch information
joeyshuttleworth authored Jul 1, 2024
2 parents 2af94b8 + be2ece0 commit 2fc8f5f
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,75 @@ Then you can run the tests.
python3 -m unittest
```


<!-- USAGE -->
## 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 -->
## Contributing

Expand Down
Empty file.
28 changes: 28 additions & 0 deletions pcpostprocess/scripts/__main__.py
Original file line number Diff line number Diff line change
@@ -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) [<args>]",
)
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()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -46,6 +46,7 @@
'regex>=2023.12.25',
'openpyxl>=3.1.2',
'jinja2>=3.1.0',
'seaborn>=0.12.2'
],
extras_require={
'test': [
Expand All @@ -58,4 +59,10 @@
'syncropatch_export @ git+ssh://[email protected]/CardiacModelling/syncropatch_export@main'
],
},
entry_points={
'console_scripts': [
'pcpostprocess='
'pcpostprocess.scripts.__main__:main',
],
},
)

0 comments on commit 2fc8f5f

Please sign in to comment.