aboutsummaryrefslogtreecommitdiff
path: root/quality_control/headers.py
blob: 59d3d775243fe8e78a09c75cb12997bf09947c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Validate the headers"""

from quality_control.errors import InvalidHeaderValue

def valid_header(strains, headers):
    "Return the valid headers with reference to strains or throw an error"
    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