def motifPosCmp(motifOcc1, motifOcc2):
    """Compares two motif occurences according to their position on a given
    sequence. The occurences must be on the same sequence."""
    assert(motifOcc1.getSeqName() == motifOcc2.getSeqName())

    motifOcc1Centre = motifOcc1.getCentre()
    motifOcc2Centre = motifOcc2.getCentre()

    if (motifOcc1Centre < motifOcc2Centre):
        return -1
    elif (motifOcc1Centre == motifOcc2Centre):
        return 0
    else:
        assert (motifOcc1Centre > motifOcc2Centre)
        return 1