<?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: Count the frequency of base G in a given DNA sequence]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/27266/count-the-frequency-of-base-g-in-a-given-dna-sequence?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/27266/count-the-frequency-of-base-g-in-a-given-dna-sequence?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/27266/count-the-frequency-of-base-g-in-a-given-dna-sequence</guid>
	<pubDate>Tue, 10 May 2016 11:38:32 -0500</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/27266/count-the-frequency-of-base-g-in-a-given-dna-sequence</link>
	<title><![CDATA[Count the frequency of base G in a given DNA sequence]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;
use warnings;

my $DNA = &quot;GATTACACAT&quot;;

#initialize $countG and $currentPos
my $countG = 0;
my $currentPos = 0;

#calculate the length of $DNA
my $DNAlength = length($DNA);

#for each letter in the sequence check if it is the base G
#if &#039;yes&#039; increment $countG
while($currentPos &lt; $DNAlength){
	my $base = substr($DNA,$currentPos,1);
	if($base eq &quot;G&quot;){
		$countG++;
	}
	$currentPos++;
} #end of while loop

#print out the number of Gs
print &quot;There are $countG G bases\n&quot;;</code>]]></description>
	<dc:creator>Nishi Singh</dc:creator>
</item>

</channel>
</rss>