import re


def bases_mask_is_valid(bases_mask):
    """
    Check if a bases mask is valid

    Arguments:
      bases_mask: bases mask string to check

    Returns:
      Boolean: True if the supplied bases mask is valid,
        False if not.
    """
    try:
        for read in bases_mask.upper().split(','):
            if not re.match(r'^([IY][0-9]+|[IY]*)(N[0-9]+|N*)$',read):
                return False
        return True
    except AttributeError:
        return False