diff options
-rw-r--r-- | scripts/rqtl2/phenotypes_qc.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/rqtl2/phenotypes_qc.py b/scripts/rqtl2/phenotypes_qc.py index 2c09835..7a52d09 100644 --- a/scripts/rqtl2/phenotypes_qc.py +++ b/scripts/rqtl2/phenotypes_qc.py @@ -159,6 +159,11 @@ def push_error(rconn: Redis, fqkey: str, error: InvalidValue) -> InvalidValue: return error +def file_fqkey(prefix: str, section: str, filepath: Path) -> str: + """Build a files fully-qualified key in a consistent manner""" + return f"{prefix}:{section}:{filepath.name}" + + def qc_phenocovar_file( filepath: Path, redisuri, @@ -176,7 +181,8 @@ def qc_phenocovar_file( _csvfile = rqtl2.read_csv_file(filepath, separator, comment_char) _headings = tuple(heading.lower() for heading in next(_csvfile)) _errors: tuple[InvalidValue, ...] = tuple() - save_error = partial(push_error, rconn, f"{fqkey}:errors:{filepath.name}") + save_error = partial( + push_error, rconn, file_fqkey(fqkey, "errors", filepath)) for heading in ("description", "units"): if heading not in _headings: _errors = (save_error(InvalidValue( @@ -271,7 +277,8 @@ def qc_pheno_file(# pylint: disable=[too-many-arguments] f"{fqkey}:logs") as logger, Redis.from_url(redisuri, decode_responses=True) as rconn): logger.info("Running QC on file: %s", filepath.name) - save_error = partial(push_error, rconn, f"{fqkey}:errors:{filepath.name}") + save_error = partial( + push_error, rconn, file_fqkey(fqkey, "errors", filepath)) _csvfile = rqtl2.read_csv_file(filepath, separator, comment_char) _headings: tuple[str, ...] = tuple( heading.lower() for heading in next(_csvfile)) |