Question: replace headers in a fasta file
0
gravatar for nicolas.dussex
3.5 years ago by
New Zealand
nicolas.dussex30 wrote:

Hi,

I would like to replace the first filed my headers in my fasta file and concatenate it to the 2nd field (my gene ID), such a, I start with this:

> maker-scaffold_0-snap-gene-0.23-mRNA-1 gene=maker-scaffold_0-snap-gene-0.23

ATGGTGAAGCTCGTGGCGTTCTCGCCGTTCCGCTCGGCGCAGAGCGCGCTGGAGAACATGAACGCCGTGT
CCGAGGGGGTCCTGCACGAGGACCTGCGGCTGCTGCTGGACACGGCGCTGCCCCCCAAGAGGAA....

and get this:

>Species1_gene=maker-scaffold_0-snap-gene-0.23

ATGGTGAAGCTCGTGGCGTTCTCGCCGTTCCGCTCGGCGCAGAGCGCGCTGGAGAACATGAACGCCGTGT
CCGAGGGGGTCCTGCACGAGGACCTGCGGCTGCTGCTGGACACGGCGCTGCCCCCCAAGAGGAA....

I tried this:  awk ' { $2="Species1_" $2; print }, but it adds Species 1 at the end of each line including the sequence. I assume i shouldn't be too complicated but don't seem to find the solution.

Thanks a lot!

replace header fasta • 1.3k views
ADD COMMENTlink modified 3.5 years ago by venu6.1k • written 3.5 years ago by nicolas.dussex30
0
gravatar for venu
3.5 years ago by
venu6.1k
Germany
venu6.1k wrote:

If you have maker-scaffold_0-snap-gene-0.23-mRNA-1 -> this part same in all the headers, you can do the following or else you can modify the part after first slash according to your requirements.

perl -pe 's/maker-scaffold_0-snap-gene-0.23-mRNA-1 /Species_1/g' file.fa > modified_file.fa
ADD COMMENTlink modified 3.5 years ago • written 3.5 years ago by venu6.1k
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: 813 users visited in the last hour