Commit 6500dd70 authored by Kai's avatar Kai

first meeting status

parent 8643b254
......@@ -6,6 +6,10 @@ from Bio.Alphabet import generic_dna
import sys
from collections import Counter
#questions:
#start/stop codons
#register
def ind(hyb,s):
try:
i = hyb.index(s)
......@@ -21,26 +25,25 @@ def cond(hyb,start,stop):
j = ind(sub_s,start)
if j<0:
return False
elif 180-j<30:
elif j<30:
return False
elif 180-j>=30:
elif j>=30:
return True
return False
def cond_reg(hyb,start,stop):
s = hyb[:180]
i = ind(s,stop)
if i>=0 & i%3 == 0:
sub_s = s[i:]
j = ind(sub_s,start)
if j<0:
return False
elif 180-j <30 & j%3 == 0:
return False
elif 180-j>=30 & j%3 == 0:
return True
return False
s = hyb[:180]
i = ind(s,stop)
if i>=0 & i%3 == 0:
sub_s = s[i:]
j = ind(sub_s,start)
if j<0:
return False
if j<30 and j%3 == 0:
return False
elif j>=30 and j%3 == 0:
return True
return False
def tests():
test_start_codon = 'ATG'
......@@ -55,6 +58,29 @@ def tests():
print("Length: %i of cond2 test seq, non-reg cond: %s reg cond: %s "%(len(cond2_test_seq),cond(cond2_test_seq,test_start_codon,test_stop_codon),cond_reg(cond2_test_seq,test_start_codon,test_stop_codon)))
print("Length: %i of cond3 test seq, non-reg cond: %s reg cond: %s "%(len(cond3_test_seq),cond(cond3_test_seq,test_start_codon,test_stop_codon),cond_reg(cond3_test_seq,test_start_codon,test_stop_codon)))
def list_n_best(start_codons,stop_codons,n):
total_start = sum([start_codons[e] for e in set(start_codons.elements())])
total_stop = sum([stop_codons[e] for e in set(stop_codons.elements())])
print("Start codons:")
for i,(seq,count) in enumerate(start_codons.most_common(n)):
print("Nr.%i, %s, %f"%(i,str(seq),100*count/total_start))
print("")
print("Stop codons:")
for i,(seq,count) in enumerate(stop_codons.most_common(n)):
print("Nr.%i, %s, %f"%(i,str(seq),100*count/total_stop))
def assess_conditions(hybrids,start,stop):
conds = [cond(hybrid,str(start),str(stop)) for hybrid in hybrids]
cond_regs = [cond_reg(hybrid,str(start),str(stop)) for hybrid in hybrids]
cond_counter = Counter(conds)
cond_regs_counter = Counter(cond_regs)
print("No register:")
for i,(seq,count) in enumerate(cond_counter.most_common(2)):
print("Condition %s, %f"%(str(seq),100*count/len(hybrids)))
print("")
print("With register:")
for i,(seq,count) in enumerate(cond_regs_counter.most_common(2)):
print("Condition %s, %f"%(str(seq),100*count/len(hybrids)))
if __name__ == "__main__":
reader = csv.reader(open("./Pseudomonas_aeruginosa_UCBPP-PA14_109.csv","r"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment