About Lesson
Calculating Basic Sequence Statistics:
- Biopython provides methods to calculate basic statistics of a sequence, such as length and GC content.
from Bio.Seq import Seq sequence = Seq("ATCGATCGATCG") length = len(sequence) gc_content = sequence.count("G") + sequence.count("C") print("Sequence Length:", length) print("GC Content:", gc_content)
- Create a
Seq
object from a DNA sequence. - Use the
len()
function to calculate the sequence length. - Count the occurrences of “G” and “C” to calculate the GC content.
- Print the sequence length and GC content.