批量合并fasta格式文件
#==========================================
# This code was written by Sihua Peng, PhD.
#==========================================
from Bio import SeqIO
import csv
# 从Input_files.csv读取待合并的文件名
input_files = []
with open('sample-52-plus-20new-found.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
input_files.extend(row)
# 输出文件
output_file = 'sample-52-plus-20new-found-2.fasta'
# 合并序列并保存为FASTA格式文件
with open(output_file, 'w') as output_handle:
for input_file in input_files:
with open(input_file, 'r') as input_handle:
records = SeqIO.parse(input_handle, 'fasta')
SeqIO.write(records, output_handle, 'fasta')