Condense fasta header

'''
Biopython hack to condense fasta header. When there is a lengthy header in fasta file like the following:
>geneid1213 len = 234 covStat = val otherparam = sval,
Shorten it to make it
>geneid1213.
'''
from Bio import SeqIO
new_header = []
with open("test.fasta", "rU") as infile:
  for record in SeqIO.parse(infile, "fasta"):
    record.description = record.name
    record.id = record.name
    new_header.append(record)
SeqIO.write(new_header, "short_header.fasta", "fasta")
print("program complete")

Comments

Popular posts from this blog

Fasta_Dupicate_Header

Gene Copy Number Matrix

Fasta_Header_Rename