Posts

Showing posts from 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 = record.name record.id = record.name new_header.append(record) SeqIO.write(new_header, "short_header.fasta", "fasta") print("program complete")