Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Python script to calculate basic genome stats !

  • Public
By Abhi 195 days ago
from Bio import SeqIO def calculate_genome_stats(fasta_file): # Initialize variables to store genome statistics genome_length = 0 gc_count = 0 a_count = 0 t_count = 0 c_count = 0 g_count = 0 # Read the genome sequence from the FASTA file for record in SeqIO.parse(fasta_file, "fasta"): sequence = record.seq genome_length += len(sequence) a_count += sequence.count('A') t_count += sequence.count('T') c_count += sequence.count('C') g_count += sequence.count('G') gc_count += sequence.count('G') + sequence.count('C') # Calculate GC content gc_content = (gc_count / genome_length) * 100 if genome_length > 0 else 0 # Print genome statistics print(f"Genome Length: {genome_length} bp") print(f"A Count: {a_count}") print(f"T Count: {t_count}") print(f"C Count: {c_count}") print(f"G Count: {g_count}") print(f"GC Content: {gc_content:.2f}%") # Example usage fasta_file = "path/to/your/genome.fasta" calculate_genome_stats(fasta_file)