<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def countOccurrencesOfSeq(self, seq, givenRange=None):
        '''
        This function counts the number of occurrences of the given sequence
        @param seq - the sequence to search for
        @param givenRange - the range to start from (if a partial search has already been run), default=whole range
        @return - an integer count of the number of times seq occurred in this BWT
        '''
        #init the current range
        if givenRange == None:
            if not self.searchCache.has_key(seq[-self.cacheDepth:]):
                res = self.findIndicesOfStr(seq[-self.cacheDepth:])
                self.searchCache[seq[-self.cacheDepth:]] = (int(res[0]), int(res[1]))
            
            l, h = self.searchCache[seq[-self.cacheDepth:]]
            seq = seq[0:-self.cacheDepth]
            
        else:
            l = givenRange[0]
            h = givenRange[1]
            
        #reverse sequence and convert to ints so we can iterate through it
        revSeq = [self.charToNum[c] for c in reversed(seq)]
        
        for c in revSeq:
            #get the start and end offsets
            l = self.getOccurrenceOfCharAtIndex(c, l)
            h = self.getOccurrenceOfCharAtIndex(c, h)
            
            #early exit for counts
            if l == h:
                return 0
        
        #return the difference
        return h - l