【发布时间】:2020-04-15 15:31:44
【问题描述】:
我看到了一些关于这个领域问题的问题,但我无法用它来解决我的问题,尽管我花了好几个小时试图理解 Biopython 方法。
我可以用逻辑做到这一点,但我认为最好使用 Biopython。
我尝试使用我找到的代码:
f = open(r"C:\Users\97254\Downloads\dna2.fasta")
sequences = {}
count = 0
for line in f:
line = line.rstrip()
if line[0] == '>':
count += 1
first_row = line.split()
name = first_row[0][1:]
sequences[name] = ''
else:
sequences[name] = sequences[name] + line
startP = re.compile('ATG')
for sequence in sequences.values():
sequence = squence[1:]
longest = (0,)
for m in startP.finditer(sequence):
if len(Seq.Seq(sequence)[m.start():].translate(to_stop=True)) > longest[0]:
pro = Seq.Seq(sequence)[m.start():].translate(to_stop=True)
longest = (len(sequence[m.start():m.start()+len(pro)*3+3]),
m.start(),
sequence[m.start():m.start()+len(pro)*3+3])
我应该使用诸如 for 循环之类的逻辑,它以 3 的跳跃迭代序列,还是有 Biopythonic 的方法来做到这一点?
谢谢!
【问题讨论】:
-
如果您也想查找起始/终止密码子,请查看github.com/chris-rands/CrUtils/blob/master/scripts/…
标签: bioinformatics biopython fasta