def create_sequence_regex(peptide_sequence):
    """
    creates a regular expression from a possibly ambiguous AA sequence
    :param peptide_sequence: peptide sequence of any length (string)
    :return: peptide sequence in re form (string)
    """
    # ensure that sequence is a string
    peptide_sequence = str(peptide_sequence)
    # if no ambiguous characters are present, return the original seq.
    if ("B" not in peptide_sequence and "J" not in peptide_sequence and "Z"
            not in peptide_sequence and "X" not in peptide_sequence):
        return peptide_sequence
    # if any ambiguous characters are present, replace them with OR statements
    else:
        peptide_sequence = peptide_sequence.replace("B", "[B|D|N]")
        peptide_sequence = peptide_sequence.replace("J", "[J|I|L]")
        peptide_sequence = peptide_sequence.replace("Z", "[Z|E|Q]")
        peptide_sequence = peptide_sequence.replace("X", "[A-Z]")
        return peptide_sequence