Showing posts from August, 2018

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.'''fromBioimport SeqIO new_header = [] withopen("test.fasta", "rU") as infile: for record in SeqIO.parse(infile, "fasta"): record.description = = new_header.append(record) SeqIO.write(new_header, "short_header.fasta", "fasta") print("program complete")