扫描阅读框[3] Python [英] Scan Reading frame [3] Python

查看:86
本文介绍了扫描阅读框[3] Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个脚本,该脚本可以使用3的阅读框来检测某种模式,然后从该序列中以3的倍数查找另一个模式

I'm trying to write a script that can use a reading frame of 3 to detect a certain pattern and then from that sequence, go in multiples of 3 to find another pattern

sequence = 'TCATGAGGCTTTGGTAAATAT'

我需要它来

...以3的阅读框进行扫描,直到找到所需的图案(即'ATG')

...scan with a reading frame of 3 until it finds a desired pattern (i.e. 'ATG')

...标记原始模式中第一个模式('ATG')起始的位置和第二个模式开始('TAA')的位置.在这种情况下,"ATG"的位置为3,"TAA"的位置为15.

...mark the location of where the first pattern ('ATG') started in the original sequence and the position of where the second pattern started ('TAA'). In this case, it would be position 3 for 'ATG' and 15 for 'TAA' .

...创建一个列表,其中每个三元组都遵循第一个模式,直到到达第二个模式"TAA"(即"ATG","AGG","CTT",TGG","TAA")

...create a list with each triplet that follows the first pattern until it reaches the second pattern 'TAA' (i.e. 'ATG','AGG','CTT',TGG','TAA')

我如何构造一个阅读框以3个为一组阅读?我知道,一旦我找到一种阅读方法,就可以创建一条if语句,

How do I construct a reading frame to read it in sets of 3 ? I know that once i find a way to get the reading i can create an if statement saying

reading_frame=[]

for frame in sequence:
    if k == 'ATG':
        reading_frame.append(k)

首先我需要阅读框

推荐答案

sequence = 'TCATGAGGCTTTGGTAAATAT'

frame1 = sequence.find('ATG')

my_list = []

for codon in range(len(sequence)):
    next_codon = sequence[frame1:frame1+3]
    my_list.append(next_codon)
    frame1 +=3
    if next_codon == 'TAA':
        break

print my_list

['ATG','AGG','CTT','TGG','TAA']

['ATG', 'AGG', 'CTT', 'TGG', 'TAA']

这篇关于扫描阅读框[3] Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆