我在试着编一个代码来找到siRNA。现在,我已经编写了一个代码,它只是寻找所有可能的siRNA组合。我还需要找到最好的,必须包含30%到50%的GC或CG核苷酸
该程序正在搜索CG或GC含量在30%到50%之间的21个核苷酸长度序列。目前,我的程序只在一个字符串中生成所有长度为21的可能siRNA,但我需要分离那些具有所需GC或CG量的siRNA
我的程序如何处理K=2的示例,这意味着来自mRNA的iRNA序列的长度:
最后,我想从中选择C+G核苷酸含量在30-50%之间的那些
好的,这里我们只有100的CG,但是让我们把K改为4,让我们使用ATGCCGTA作为输入
ATCGTA 所有iRNA组合['UAGC'、'AGCG'、'GCGC'、'CGCA'、'GCAU']
所以,这里,正确的是-UAGC和GCAU
import re
def converttostr(input_seq, seperator):
# Join all the strings in list
final_str = seperator.join(input_seq)
return final_str
DNA_seq = input("")
RNA_seq = DNA_seq.replace("T", "U")
N = RNA_seq
iRNA = (N.translate(str.maketrans({"A": "U", "G": "C", "U": "A", "C": "G"})))
iRNA_str = iRNA
K = 21
iRNA_comb = [iRNA[i: j] for i in range(len(iRNA_str)) for j in range(i + 1, len(iRNA_str) + 1) if len(iRNA_str[i:j]) == K]
print("All iRNA combinations", iRNA_comb)
seperator = ', '
LtS = converttostr(iRNA_comb, seperator)
print("List converted to string: ", LtS)
CG = re.split(" CG |[^a-zA-Z ]+",LtS)
print("siRNA with CG founded",CG)
此代码查找字符串中有多少个
GC
或CG
组合,并将值在30-50%之间的组合过滤到输出数组我还打印了为不同测试用例计算的百分比,供您参考
代码:
输入:
输出:
我试图弄明白这段代码的作用,但我不能确定你以前用过其他语言吗?只需指定要接收的输入数据和输出
如果符合条件(30%-50%),则返回true。然后你可以把它添加到列表或其他任何地方
相关问题 更多 >
编程相关推荐