一、上一个版本
- 抱歉各位兄弟我感觉这道题我现在的能力有限,不纠结了跳过去.等第3刷的时候解决吧.
- 可能彼岸就在眼前,但是我累了.等下次吧
这个版本中div_text函数已经可以很好的划分字符串了
但是我发现了一个问题.它间隔字符效果如下
genome_text = 'TTATGTTTTAAGGATGGGGCGTTAGTT'
len_num_out = len(genome_text)
def div_text(start_num, end_num, text_word):
text_i_save = ""
for i_t in range(start_num, end_num):
text_i_save += text_word[i_t]
return text_i_save
之前的间隔的取数.在这里得到了修正.其实就是将for循环的步幅改回到1
len_num = len(genome_text)
for i in range(0, len_num):
if i + 2 < len_num:
print(div_text(i, i + 3, genome_text))
print('i is', i, 'i+3 is', i + 3)
genome_text = 'TTATGTTTTAAGGATGGGGCGTTAGTT'
len_num_out = len(genome_text)
def div_text(start_num, end_num, text_word):
text_i_save = ""
for i_t in range(start_num, end_num):
text_i_save += text_word[i_t]
return text_i_save
def cut_word_start(judge_word, text_word):
len_num = len(text_word)
for i in range(0, len_num):
if i + 2 < len_num:
if div_text(i, i + 3, text_word) == judge_word:
return text_word[i + 3:]
def cut_word_end(judge_word, text_word):
len_num = len(text_word)
for i in range(0, len_num):
if i + 2 < len_num:
if div_text(i, i + 3, text_word) == judge_word:
print(text_word[:i])
# print(i)
def main():
a = cut_word_start("ATG", genome_text)
cut_word_end("TAA",a)
main()
二、如何将TAG、TAA、TGA都做成条件
- 抱歉各位兄弟我感觉这道题我现在的能力有限,不纠结了跳过去.等第3刷的时候解决吧.
- 可能彼岸就在眼前,但是我累了.等下次吧
第一条里我已经成功提取了TTT这个序列但是
在
‘TTATGTTTTAAGGATGGGGCGTTAGTT’
还存在GGGCGT
另外 当我取的了TTT后,如何让计算机继续往后去寻找
规则也写的很明白
ATG之后TAG或TAA或TGA之前,这样一个区间
抱歉各位兄弟我感觉这道题我现在的能力有限,不纠结了跳过去.等第3刷的时候解决吧.
genome_text = 'TTATGTTTTAAGGATGGGGCGTTAGTT'
len_num_out = len(genome_text)
def div_text(start_num, end_num, text_word):
text_i_save = ""
for i_t in range(start_num, end_num):
text_i_save += text_word[i_t]
return text_i_save
def cut_word_start(judge_word, text_word):
len_num = len(text_word)
for i in range(0, len_num):
if i + 2 < len_num:
if div_text(i, i + 3, text_word) == judge_word:
return text_word[i + 3:]
def cut_word_end(judge_word1, judge_word2, judge_word3, text_word):
len_num = len(text_word)
for i in range(0, len_num):
if i + 2 < len_num:
run_code = div_text(i, i + 3, text_word)
if run_code == judge_word1 or run_code == judge_word2 or run_code == judge_word3:
print(text_word[:i])
# 这个从他们之前取值的想法有点烧脑了.先放弃了
def between_code(judge_start, judge_end1, judge_end2, judge_end3, text_int):
a = cut_word_start(judge_start, text_int)
cut_word_end(judge_end1, judge_end2, judge_end3, a)
def main():
a = cut_word_start("ATG", genome_text)
cut_word_end("TAG", "TAA", "TGA", a)
main()