Commit 8643b254 authored by Kai's avatar Kai

ha

parent cc705b35
......@@ -6,6 +6,13 @@ from Bio.Alphabet import generic_dna
import sys
from collections import Counter
def ind(hyb,s):
try:
i = hyb.index(s)
except:
i = -1
return i
def cond(hyb,start,stop):
s = hyb[:180]
i = ind(s,stop)
......@@ -20,8 +27,35 @@ def cond(hyb,start,stop):
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
def tests():
test_start_codon = 'ATG'
test_stop_codon = 'CAT'
a_string = "A"*180
cond1_test_seq = Seq(a_string[:150] + test_stop_codon + a_string[153:],generic_dna)
cond2_test_seq = Seq(a_string[:162] + test_stop_codon + a_string[165:168] + test_start_codon + a_string[171:],generic_dna)
cond3_test_seq = Seq(a_string[:120] + test_stop_codon + a_string[123:153] + test_start_codon + a_string[156:],generic_dna)
print("Length: %i of cond1 test seq, non-reg cond: %s reg cond: %s "%(len(cond1_test_seq),cond(cond1_test_seq,test_start_codon,test_stop_codon),cond_reg(cond1_test_seq,test_start_codon,test_stop_codon)))
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)))
if __name__ == "__main__":
reader = csv.reader(open("./Pseudomonas_aeruginosa_UCBPP-PA14_109.csv","r"))
web_gene = list(open("./Pseudomonas_aeruginosa_UCBPP-PA14_109.fna","r"))[1:]
......@@ -42,4 +76,4 @@ if __name__ == "__main__":
hybrids.append(hybrid)
start_codons = Counter([seq[:3] for seq in web_ba_seqs])
stop_codons = Counter([seq[-3:] for seq in web_ba_seqs])
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