aboutsummaryrefslogtreecommitdiff
path: root/quality_control/headers.py
diff options
context:
space:
mode:
Diffstat (limited to 'quality_control/headers.py')
-rw-r--r--quality_control/headers.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/quality_control/headers.py b/quality_control/headers.py
index 59d3d77..b7bc01e 100644
--- a/quality_control/headers.py
+++ b/quality_control/headers.py
@@ -1,6 +1,6 @@
"""Validate the headers"""
-from quality_control.errors import InvalidHeaderValue
+from quality_control.errors import DuplicateHeader, InvalidHeaderValue
def valid_header(strains, headers):
"Return the valid headers with reference to strains or throw an error"
@@ -13,4 +13,13 @@ def valid_header(strains, headers):
raise InvalidHeaderValue(
*(f"'{header}' not a valid strain." for header in invalid_headers))
+ unique_headers = set(headers)
+ if len(unique_headers) != len(headers):
+ repeated = (
+ (header, headers.count(header))
+ for header in unique_headers if headers.count(header) > 1)
+ raise DuplicateHeader(*(
+ f"'{header}' is present in the header row {times} times."
+ for header, times in repeated))
+
return headers