在FASTA文件中的多个序列中在读取帧2中找到最长的ORF(开放读取帧)

问题描述 投票:0回答:1

我已经看到了有关该领域问题的一些问题,但是尽管试图理解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的方法来做到这一点?

谢谢!

bioinformatics biopython fasta
1个回答
1
投票

BioPython Tutorial and Cookbook contains the following code for finding open reading frames

from Bio import SeqIO
record = SeqIO.read("NC_005816.fna", "fasta")
table = 11
min_pro_len = 100

for strand, nuc in [(+1, record.seq), (-1, record.seq.reverse_complement())]:
    for frame in range(3):
        length = 3 * ((len(record)-frame) // 3) #Multiple of three
        for pro in nuc[frame:frame+length].translate(table).split("*"):
            if len(pro) >= min_pro_len:
                print("%s...%s - length %i, strand %i, frame %i" \
                      % (pro[:30], pro[-3:], len(pro), strand, frame))

输出:

GCLMKKSSIVATIITILSGSANAASSQLIP...YRF - length 315, strand 1, frame 0
KSGELRQTPPASSTLHLRLILQRSGVMMEL...NPE - length 285, strand 1, frame 1
GLNCSFFSICNWKFIDYINRLFQIIYLCKN...YYH - length 176, strand 1, frame 1
VKKILYIKALFLCTVIKLRRFIFSVNNMKF...DLP - length 165, strand 1, frame 1
NQIQGVICSPDSGEFMVTFETVMEIKILHK...GVA - length 355, strand 1, frame 2
RRKEHVSKKRRPQKRPRRRRFFHRLRPPDE...PTR - length 128, strand 1, frame 2
TGKQNSCQMSAIWQLRQNTATKTRQNRARI...AIK - length 100, strand 1, frame 2
QGSGYAFPHASILSGIAMSHFYFLVLHAVK...CSD - length 114, strand -1, frame 0
IYSTSEHTGEQVMRTLDEVIASRSPESQTR...FHV - length 111, strand -1, frame 0
WGKLQVIGLSMWMVLFSQRFDDWLNEQEDA...ESK - length 125, strand -1, frame 1
RGIFMSDTMVVNGSGGVPAFLFSGSTLSSY...LLK - length 361, strand -1, frame 1
WDVKTVTGVLHHPFHLTFSLCPEGATQSGR...VKR - length 111, strand -1, frame 1
LSHTVTDFTDQMAQVGLCQCVNVFLDEVTG...KAA - length 107, strand -1, frame 2
RALTGLSAPGIRSQTSCDRLRELRYVPVSL...PLQ - length 119, strand -1, frame 2

由于它直接来自本教程,所以我认为这是找到ORF的最Biopythonic方法。它还迭代“ 3跳”中的序列,但是它使用BioPython函数SeqIO.read()来解析fasta文件。

© www.soinside.com 2019 - 2024. All rights reserved.