Fasta file name change: Change contig to annotated name
1
0
Entering edit mode
8.5 years ago
taekim009 • 0

Hello All,

I have two files a fasta file with:

>Contig1
atgcatgcatgcaatgcagcga
>Contig2
atagtagtattagcatcgatcgt
>Contig3
atgcagcagcgacg

AND

a text or .csv file with:

Contig1-metalloprotease
Contig2-serpin
Contig3-cystatin

Does anyone know how to match and replace:

>Contig1 with >Contig1-metalloprotease?

Any help would be much appreciated. Thanks in advance!

Assembly Fasta • 3.0k views
ADD COMMENT
0
Entering edit mode
8.5 years ago
apelin20 ▴ 480

I would just have a table:

Contig1 <tab> Contig1-metallo...

same for all contigs, tab delimited.

Then:

awk 'NR==FNR{array[">"$1]=(">" $1 "-" $2);next} {if($1 in array){$1=array[$1]}}1' Table.file original.fasta > annotated.fasta
ADD COMMENT

Login before adding your answer.

Traffic: 2567 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6