Created
September 9, 2014 21:02
-
-
Save walterst/f5c619799e6dc1f575a0 to your computer and use it in GitHub Desktop.
Usage python fix_fasta_labels.py X Y where X is the input fasta file, Y is the output fasta file The second string following a split on white space will be written as the label in the output fasta, this is intended to make a label in a fasta file generated from QIIME's pick_rep_set.py match the original sequence ID rather than the OTU ID.
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
#!/usr/bin/env python | |
"""Usage | |
python fix_fasta_labels.py X Y | |
where X is the input fasta file, Y is the output fasta file | |
The second string following a split on white space will be written | |
as the label in the output fasta, this is intended to make a label in a | |
fasta file generated from QIIME's pick_rep_set.py match the original | |
sequence ID rather than the OTU ID.""" | |
from sys import argv | |
from cogent.parse.fasta import MinimalFastaParser | |
input_fasta = open(argv[1], "U") | |
output_fasta = open(argv[2], "w") | |
for label,seq in MinimalFastaParser(input_fasta): | |
curr_label = " ".join(label.split(" ")[1:]) | |
output_fasta.write(">%s\n%s\n" % (curr_label, seq)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment