DNA.
count
(subsequence, start=None, end=None)[source]¶Count occurrences of a subsequence in this sequence.
State: Stable as of 0.4.0.
subsequence (str, Sequence, or 1D np.ndarray (np.uint8 or '|S1')) – Subsequence to count occurrences of.
start (int, optional) – The position at which to start counting (inclusive).
end (int, optional) – The position at which to stop counting (exclusive).
Number of occurrences of subsequence in this sequence.
int
ValueError – If subsequence is of length 0.
TypeError – If subsequence is a Sequence
object with a different type
than this sequence.
Examples
>>> from skbio import Sequence
>>> s = Sequence('GGUCG')
>>> s.count('G')
3
>>> s.count('GG')
1
>>> s.count('T')
0
>>> s.count('G', 2, 5)
1