def iupac_to_regex(iupac):
    """
	Converts a IUPAC string with wildcards to a regular expression.
	"""
    wildcards = {'R': 'AG', 'Y': 'CT', 'S': 'CG', 'W': 'AT', 'K': 'GT', 'M':
        'AC', 'B': 'CGT', 'D': 'AGT', 'H': 'ACT', 'V': 'ACG', 'N': 'ACGT',
        'X': 'ACGT'}
    regex = ''
    for c in iupac.upper():
        if c in 'ACGT':
            regex += c
        elif c in wildcards:
            regex += '[' + wildcards[c] + ']'
        else:
            raise ValueError("don't know how to handle character %s" % c)
    return regex
