import re


def deannotate_sequence(annotated_seq, remove_whitespace=False):
    """Deletes the annotation of segments. Optionally removes whitespace.
    Either a tab or a | are sufficent, both are also acceptable"""
    #mathces from a tab or | or both to the end of line.    
    reg_exp = re.compile(r"\s*(\t|\||\t\s*\|).*\n", re.MULTILINE) 
    res = re.sub(reg_exp,"\n",annotated_seq)    
    
    if remove_whitespace:
        res=res.replace(" ","")
        res=res.replace("\n","")
        res=res.replace("\t","")
    return res