Last active
October 19, 2016 07:50
-
-
Save konrad/a06de1ba63356cb524e2 to your computer and use it in GitHub Desktop.
Split a multi entry fasta file into several files with on entry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from Bio import SeqIO | |
parser = argparse.ArgumentParser( | |
description="Split a multi entry fasta file into several files " | |
"with one entry") | |
parser.add_argument("input_file") | |
parser.add_argument("output_prefix") | |
args = parser.parse_args() | |
for seq_record in SeqIO.parse(args.input_file, "fasta"): | |
with open(args.output_prefix + seq_record.id + ".fa", "w") as output_fh: | |
output_fh.write(">{}\n{}\n".format( | |
seq_record.id, str(seq_record.seq))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment