我必须创建两个函数,使我能够打开.genbank文件并将其转换为.fasta文件,反之亦然。目前我所拥有的是:
def Convert(file, file1)
handle_input=open('file', 'rU')
handle_output=open('file1', 'w')
while True:
s=handle_input.readline()
t=handle_output.write(s, '.genbank')
print(t)
Convert('file.fas', 'file.genbank')这也可能是不正确的,但我不知道该怎么做。
发布于 2015-10-16 17:35:28
你可以在互联网上找到很多关于这方面的文档。看看这里:https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
但为了让你开始:我假设这两个文件在未来不会完全相同,因为否则你可以只复制文件。
我有几句话要说。
1)你的循环while true会一直运行到时间结束。将其更改为类似于
for line in handle_input:
2)完成后关闭文件:
handle_input.close() handle_output.close()
3)t=handle_output.write(s, '.genbank')删除'.genbank‘参数
4)不需要做print(t)
注意:我还没有测试过这段代码,所以我可能犯了一些小错误
https://stackoverflow.com/questions/33166609
复制相似问题