def chans_to_casa(chans, sep=';'):
    """Create a string with in CASA format with the channel ranges.
    """
    chanstr = ''
    for ch in chans:
        if len(ch)==1:
            chanstr += '%i%s' % (ch, sep) 
        else:
            chanstr += '%i~%i%s' % (ch[0], ch[-1], sep)
    return chanstr.strip(sep)