import os
file_path=r'C:\Users\aklasim\Desktop\LAB\序列分割程序+结果\姬蠊py\part'
pathDir = os.listdir(file_path)
#folder=r'C:\Users\aklasim\Desktop\LAB\序列分割程序+结果\姬蠊py\apart\Anaplecta corneola'
#filename = r'C:\Users\aklasim\Desktop\LAB\序列分割程序+结果\姬蠊py\apart\Anaplecta corneola\JFL1.seq'
all=r'C:\Users\aklasim\Desktop\LAB\序列分割程序+结果\姬蠊py\part.fas'
a=open(all,'w')
a.close()
for filename in pathDir: # 遍历pathDir下的所有文件filename
t2=filename
for file in os.listdir(file_path+'\\'+filename):
title = file.strip('.seq')
seqpath=file_path+'\\'+filename+'\\'+file
以下为seq转fas并依次写入
with open(seqpath, 'r') as f:
counts = 1
line = f.readline()
while line:
if counts >= 3:
break
line = f.readline()
counts += 1
coi=line
with open(all,'a') as fas:
fas.write('>'+title+'_'+t2+'\n')
fas.write(coi+'\n')