Basic Sequence Analyses

  • The Seq object deals with sequences. There are different methods between Seq objects and standard Python strings.

In [1]: import Bio

In [2]: Bio.__version__
Out[2]: '1.84'

In [3]: from Bio.Seq import Seq

In [4]: my_seq=Seq("TCATGTGTCCATACTTGATCATAG")

In [5]: my_seq.reverse_complement()
Out[5]: Seq('CTATGATCAAGTATGGACACATGA')

In [6]: my_seq.transcribe()
Out[6]: Seq('UCAUGUGUCCAUACUUGAUCAUAG')

In [7]: my_seq.translate()
Out[7]: Seq('SCVHT*S*')

In [8]: my_seq.translate(to_stop=True)
Out[8]: Seq('SCVHT')
  • GC functions in Bio.SeqUtils module to calculate a GC%,

In [1]: import Bio

In [2]: from Bio.Seq import Seq

In [3]: from Bio.SeqUtils import gc_fraction

In [4]: my_seq=Seq("ACTG")

In [5]: gc_fraction(my_seq)
Out[5]: 50.0

Last updated

Massachusetts Institute of Technology