This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Add A Unique Identifier For Fasta File To A Long List Of Sequences

I have a long list of sequences and I want to convert this list to a fasta file. How do I add > and a unique identifier to each line?

thanks!

sequence fasta

2 answers

Awk is a possibility. Assuming one sequence per line in a file called sequencefile.txt:

awk '{print ">" NR; print $0}' sequencefile.txt

NR is the line number, so it will be unique relative to the sequences in sequencefile.txt.

You can accept this as the answer by clicking on the checkmark just under the votes.

"assuming" is the grandma' of Satan :o)

With Biopieces www.biopieces.org) you do:

read_tab -i in.tab -k SEQ | add_ident -k SEQ_NAME | write_fasta -o out.fasta -x

More info here: add_ident

That is nice, but a little overkilling.

If you are using biopieces for further steps downstream then what you call slight overkill does make sense. Granted it doesn't look like stevebob was already using biopieces but maybe this gave him a push towards discovering it..

biopieces is a very convenient toolbox. It works very well, thanks Maasha!

Log in to answer this question.