我有一个包含以下数据的txt文件:
克瑞
ATGCCTTGGGCAACGGT…(多行)
克瑞
aggtggccaaggtt…(多行)
我想首先找到'chrI',然后遍历ATGC的多行代码,直到找到xth char。然后我想打印第xth个字符直到yth字符。我一直在使用regex,但是一旦找到包含chrI的行,我就不知道如何继续迭代以找到xth字符。在
这是我的代码:
for i, line in enumerate(sacc_gff):
for match in re.finditer(chromo_val, line):
print(line)
for match in re.finditer(r"[ATGC]{%d},{%d}\Z" % (int(amino_start), int(amino_end)), line):
print(match.group())
变量的含义:
chromo_val
=chrI
amino_start
=(我的程序找到了一些起点)
amino_end
=(我的程序找到了某个端点)
注意:amino_start
和{
请让我知道,如果我能为你澄清什么,谢谢。在
看起来你在处理fasta的数据,所以我会给出一个答案,但如果不是这样,你仍然可以使用sub_序列选择部分。在
fasta格式:
^{pr2}$由于您使用的是以下格式的fasta文件:
而且是生物信息学专业的,我猜你会经常操作序列,我建议安装名为FAST的perl包。一旦安装了该程序以获取每个序列的2-14个字符,您将执行以下操作:
^{pr2}$这是最近的publication for FAST和{a2},其中包含一个用于在命令行上操纵分子序列数据的工具箱。在
相关问题 更多 >
编程相关推荐