<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Python script to calculate basic genome stats !]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/44566/python-script-to-calculate-basic-genome-stats?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/44566/python-script-to-calculate-basic-genome-stats?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44566/python-script-to-calculate-basic-genome-stats</guid>
	<pubDate>Mon, 10 Jun 2024 11:18:32 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44566/python-script-to-calculate-basic-genome-stats</link>
	<title><![CDATA[Python script to calculate basic genome stats !]]></title>
	<description><![CDATA[<code>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, &quot;fasta&quot;):
        sequence = record.seq
        genome_length += len(sequence)
        a_count += sequence.count(&#039;A&#039;)
        t_count += sequence.count(&#039;T&#039;)
        c_count += sequence.count(&#039;C&#039;)
        g_count += sequence.count(&#039;G&#039;)
        gc_count += sequence.count(&#039;G&#039;) + sequence.count(&#039;C&#039;)

    # Calculate GC content
    gc_content = (gc_count / genome_length) * 100 if genome_length &gt; 0 else 0

    # Print genome statistics
    print(f&quot;Genome Length: {genome_length} bp&quot;)
    print(f&quot;A Count: {a_count}&quot;)
    print(f&quot;T Count: {t_count}&quot;)
    print(f&quot;C Count: {c_count}&quot;)
    print(f&quot;G Count: {g_count}&quot;)
    print(f&quot;GC Content: {gc_content:.2f}%&quot;)

# Example usage
fasta_file = &quot;path/to/your/genome.fasta&quot;
calculate_genome_stats(fasta_file)</code>]]></description>
	<dc:creator>Abhi</dc:creator>
</item>

</channel>
</rss>