def fragment_sequences(sequence, qualities, splitchar):
    """Works like split() on strings, except it does this on a sequence
    and the corresponding list with quality values.
    Returns a tuple for each fragment, each sublist has the fragment
    sequence as first and the fragment qualities as second elemnt"""
    # this is slow (due to zip and list appends... use an iterator over
    #  the sequence find find variations and splices on seq and qual

    if len(sequence) != len(qualities):
        print(sequence, qualities)
        raise RuntimeError("Internal error: length of sequence and qualities don't match???")

    retlist = []
    if len(sequence) == 0:
        return retlist

    actseq = []
    actqual = []
    if sequence[0] != splitchar:
        inseq = True
    else:
        inseq = False
    for char, qual in zip(sequence, qualities):
        if inseq:
            if char != splitchar:
                actseq.append(char)
                actqual.append(qual)
            else:
                retlist.append(("".join(actseq), actqual))
                actseq = []
                actqual = []
                inseq = False
        else:
            if char != splitchar:
                inseq = True
                actseq.append(char)
                actqual.append(qual)

    if inseq and len(actseq):
        retlist.append(("".join(actseq), actqual))

    return retlist