diff options
author | Frederick Muriuki Muriithi | 2022-04-11 15:25:54 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-04-11 15:25:54 +0300 |
commit | 3fd3e1833e5fa32a2721d0b6a16b5fd4b43adf2a (patch) | |
tree | 7890be0288adf186da0bd115900c6e124e369b92 /quality_control/headers.py | |
parent | f15fac33627952ccf5d85a8c363b6d829c03b90d (diff) | |
download | gn-uploader-3fd3e1833e5fa32a2721d0b6a16b5fd4b43adf2a.tar.gz |
Implement MVI for headers validity checking function
Add a minimum viable implementation that passes the tests for the
function that checks for the validity of the headers
Diffstat (limited to 'quality_control/headers.py')
-rw-r--r-- | quality_control/headers.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/quality_control/headers.py b/quality_control/headers.py index b8ff160..59d3d77 100644 --- a/quality_control/headers.py +++ b/quality_control/headers.py @@ -4,4 +4,13 @@ from quality_control.errors import InvalidHeaderValue def valid_header(strains, headers): "Return the valid headers with reference to strains or throw an error" - return None + if not bool(headers[1:]): + raise InvalidHeaderValue( + "The header MUST contain at least 2 columns") + invalid_headers = tuple( + header for header in headers[1:] if header not in strains) + if invalid_headers: + raise InvalidHeaderValue( + *(f"'{header}' not a valid strain." for header in invalid_headers)) + + return headers |