This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Rename FASTA Headers

Hello, i want to change the fasta header of this input file :

>M04631:312:000000000-C6V6K:1:2107:11495:1734 1:N:0:ACTGAGCG+TTATGCGA

>M04631:312:000000000-C6V6K:1:2107:13059:1785 1:N:0:ACTGAGCG+TTATGCGA

In this fasta header:

>adjH001

>adjH002

>adjH....

>adjH099

>adjH100

what script do I have to use??

next-gen

Hello kari_vo3!

Questions similar to yours can already be found at:

We have closed your question to allow us to keep similar content in the same thread.

If you disagree with this please tell us why in a reply below. We'll be happy to talk about it.

Cheers!

Looks like you have MiSeq data, please provide the actual context about what you're doing. It should include the words "MiSeq" and "fastq". It's highly unlikely that your actual question will end up actually renaming fasta entries.

You need to explain your naming convention further. There’s no information in those headers to generate what you’re asking for.

If you just want all the sequences named adjH followed by some number, how high should these numbers go? How many sequences do you have? Since you want them 0-padded this matters.

Are the names arbitrary in order?

i have 300000 reads and then i'll renamed them to a metagenomic analysis :

renamed them to a metagenomic analysis

That's not clear. We still don't know where the adjH001 identifiers are based on.

You need to tell us how:

>adjH001 pairs with >M04631:312:000000000-C6V6K:1:2107:11495:1734 1:N:0:ACTGAGCG+TTATGCGA

or any other sequence. Is it purely based on the order in which they occur?

1 answer

awk 'BEGIN{N=1;S=">adjH"}{if(/^>/){printf("%s%03d\n",S,N);N++}else{print $0}}' in.fa > out.fa

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.
Upvote|Bookmark|Accept

Log in to answer this question.