# skbio.sequence.DNASequence.__getitem__¶

DNASequence.__getitem__(i)[source]

The indexing operator.

Parameters: i : int, slice, or sequence of ints The position(s) to return from the BiologicalSequence. If i is a sequence of ints, these are assumed to be indices in the sequence to keep. BiologicalSequence New biological sequence containing the character(s) at position(s) i in the current BiologicalSequence. If quality scores are present, the quality score at position(s) i will be included in the returned sequence. ID and description are also included.

Examples

>>> from skbio.sequence import BiologicalSequence
>>> s = BiologicalSequence('GGUCGUGAAGGA')


Obtain a single character from the biological sequence:

>>> s[1]
<BiologicalSequence: G (length: 1)>


Obtain a slice:

>>> s[7:]
<BiologicalSequence: AAGGA (length: 5)>


Obtain characters at the following indices:

>>> s[[3, 4, 7, 0, 3]]
<BiologicalSequence: CGAGC (length: 5)>