Question: How To Add A Unique Identifier For Fasta File To A Long List Of Sequences
2
gravatar for Stevebob
8.4 years ago by
Stevebob20
Stevebob20 wrote:

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!

fasta sequence • 5.3k views
ADD COMMENTlink written 8.4 years ago by Stevebob20
6
gravatar for Sean Davis
8.4 years ago by
Sean Davis26k
National Institutes of Health, Bethesda, MD
Sean Davis26k wrote:

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.

ADD COMMENTlink written 8.4 years ago by Sean Davis26k
3

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

ADD REPLYlink written 8.4 years ago by Sean Davis26k
1

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

ADD REPLYlink written 8.4 years ago by Martin A Hansen3.0k

worked great, thanks!

ADD REPLYlink written 8.4 years ago by Stevebob20
1
gravatar for Martin A Hansen
8.4 years ago by
Martin A Hansen3.0k
Denmark
Martin A Hansen3.0k wrote:

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

ADD COMMENTlink written 8.4 years ago by Martin A Hansen3.0k
1

That is nice, but a little overkilling.

ADD REPLYlink written 8.4 years ago by lh332k
1

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..

ADD REPLYlink written 8.4 years ago by Daniel50
1

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

ADD REPLYlink written 8.1 years ago by Manu Prestat4.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1824 users visited in the last hour