Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (21 sloc) 676 Bytes
from math import log
def logfact(n):
s=0.0
for x in range(1,n+1):
s+=log(x,10)
return(s)
with open("rosalind_prob.txt","rU") as f:
dna=f.readline()
dna=dna.strip()
prob_str=f.readline()
prob_array=(prob_str.strip()).split()
print prob_array
print logfact(5)
counts={'A':0,'T':0,'G':0,'C':0}
for x in dna:
counts[x]+=1
#bcoeff = logfact(counts['A']+counts['T']+counts['G']+counts['C'])-logfact(counts['A'])-logfact(counts['T'])-logfact(counts['G'])-logfact(counts['C'])
for x in prob_array:
p=float(x)
c= (counts['G']+counts['C'])*log(p/2,10)+(counts['A']+counts['T'])*log((1-p)/2,10)
print '{0:.3f}'.format(c),
You can’t perform that action at this time.