def iter_fasta(path):
with open(path) as handle:
header = None
buf = []
for line in handle:
if line.isspace():
continue # Omit empty lines.
line = line.strip()
if line.startswith(">"):
if buf:
assert header is not None
yield header, "".join(buf)
del buf[:]
header = line[1:] # Drop the '>'.
else:
buf.append(line)
# Handle the last record.
if buf:
yield header, "".join(buf)
FASTA是一种非常简单的格式,因此您可以在几行代码中运行自己的解析器,例如
最长的序列是
^{pr2}$相关问题 更多 >
编程相关推荐