因为DNA转录中的字母AUG,需要开始阅读信使RNA

时间:2016-03-21 22:13:56

标签: python python-2.7

我有这个RNA信使:

'UAUGCUAAUUCGAUAACCGA'

我想创建一个从'AUG'密码子开始存储的函数,但我不知道如何制作它。 结果应如下所示:

'AUGCUAAUUCGAUAACCGA'

我已经尝试过这个:

 cadenaseparada = []
 for i in range(0,fin,3):
     codon = v[i] +v[i+1] + v[i+2]
     cadenaseparada.append(codon)

3 个答案:

答案 0 :(得分:1)

rna = 'UAUGCUAAUUCGAUAACCGA'
index = rna.find('AUG')
out = rna[index:] if index >= 0 else ''

print out

答案 1 :(得分:0)

有些事情是错误的:

  • 您不能遍历整个字符串,因为您还包含索引之后的两个元素。
  • 如果n * 3没有以n索引(其中[start:stop]是任何整数)开始,你不应该使用3的步长你会错过它
  • 您无需追加即可使用rna = 'U A U G C U A A U U C G A U A A C C G A' rna = ''.join(rna.split()) # This just converts it to a string with no whitspaces. # Don't iterate over the whole string, stop when reaching len(rna)-2 for i in range(0,len(rna)-2): # Break and only keep everything from here on # Compare the current 3 letters if rna[i:i+3] == 'AUG': out = rna[i:] break # End the loop here print out # 'AUGCUAAUUCGAUAACCGA' 语法排除字符串范围。

一个工作示例可能是:

var item = gridDataSource.get(id);
item.dirty = true;
item.SomeOtherlId = 5;
kendoGrid.refresh();

答案 2 :(得分:0)

也许使用index

dna = 'UAUGCUAAUUCGAUAACCGA'

try:
    mrna_index = dna.index('AUG')
except ValueError:
    mrna_index = None
    cadena_separada = None
else:
    cadena_separada = dna[mrna_index:]