diff options
| author | Frederick Muriuki Muriithi | 2026-03-11 14:38:28 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-03-11 14:38:28 -0500 |
| commit | 90809ed28ac6d07f20f533f8a0108d3557cc1bc4 (patch) | |
| tree | 2a3e9d545f46c79652ba887c7be62d3e6090b480 /scripts | |
| parent | 4dcf6eef6e0bc97ec1aac6aad2a1548e5f79c651 (diff) | |
| download | gn-uploader-90809ed28ac6d07f20f533f8a0108d3557cc1bc4.tar.gz | |
Check whether files exist before attempting to operate on them.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/run_qtlreaper.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/scripts/run_qtlreaper.py b/scripts/run_qtlreaper.py index a0c3b22..d9cadea 100644 --- a/scripts/run_qtlreaper.py +++ b/scripts/run_qtlreaper.py @@ -160,16 +160,20 @@ def dispatch(args: Namespace) -> int: while _qtlreaper.poll() is None: logger.debug("QTLReaper process running…") time.sleep(1) - results = tuple(#type: ignore[var-annotated] - max(qtls, key=lambda qtl: qtl["LRS"]) - for qtls in - reduce(__qtls_by_trait__, - parse_tsv_file(_qtlreaper_main_output), - {}).values()) - save_qtl_values_to_db(conn, results) + results = ( + tuple(#type: ignore[var-annotated] + max(qtls, key=lambda qtl: qtl["LRS"]) + for qtls in + reduce(__qtls_by_trait__, + parse_tsv_file(_qtlreaper_main_output), + {}).values()) + if _qtlreaper_main_output.exists() + else tuple()) logger.debug("Cleaning up temporary files.") - _traitsfile.unlink() - _qtlreaper_main_output.unlink() + + # short-circuits to delete file if exists + _traitsfile.exists() and _traitsfile.unlink() + _qtlreaper_main_output.exists() and _qtlreaper_main_output.unlink() logger.info("Successfully computed p values for %s traits.", len(_traitsdata)) return 0 except FileNotFoundError as fnf: |
