def calculate_average_ngram_presence(coordinates,genome,ngram): ngram_presence=np.zeros(len(coordinates)) ngram_reversed=Sequence.reverse_complement(ngram) for idx,c in enumerate(coordinates): seq=genome.extract_sequence(c) ngram_presence[idx]=(seq.count(ngram)+seq.count(ngram_reversed))/float(len(c)) return ngram_presence
def calculate_average_ngram_presence(coordinates, genome, ngram): ngram_presence = np.zeros(len(coordinates)) ngram_reversed = Sequence.reverse_complement(ngram) for idx, c in enumerate(coordinates): seq = genome.extract_sequence(c) ngram_presence[idx] = (seq.count(ngram) + seq.count(ngram_reversed)) / float(len(c)) return ngram_presence