Learn Before
Concept
How Sequences Act like Strings
A few examples.... You can iterate over the elements in the Seq object the same as a string object :
from Bio.Seq import Seq my_seq = Seq("ATGCA") for index, letter in enumerate(my_seq): print((index, letter))
You can find the length of the Seq object:
print(len(my_seq))
You can access elements of a Seq object:
print(my_seq[2]) print(my_seq[-1])
You can also slice a Seq object:
print(my_seq[4:0:-2])
You can add Seq objects together:
my_seq2 = Seq("GTCATC") print(my_seq + my_seq2)
You can change the case of Seq objects:
print(my_seq2.lower())
When run in Python, the output will be:
(0, 'A') (1, 'T') (2, 'G') (3, 'C') (4, 'A') 5 G A AG ATGCAGTCATC gtcatc
0
1
Updated 2021-07-20
Tags
Python Programming Language
Data Science