I'm working on a simple nucleotide counter in python 2.7 and at one of the methods I wrote I'd like to print the g,c,a,t values sorted by the number of times they show up in the gene sheet. what could be the better way to do that? Thanks in advance!
def counting(self):
gene = open("BRCA1.txt", "r")
g = 0
a = 0
c = 0
t = 0
gene.readline()
for line in gene:
line = line.lower()
for char in line:
if char == "g":
g += 1
if char == "a":
a += 1
if char == "t":
t += 1
if char == "c":
c += 1
print "number of g\'s: %r" % str(g)
print "number of c\'s: %r" % str(c)
print "number of d\'s: %r" % str(a)
print "number of t\'s: %r" % str(t)