This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Replace sequence id from one fasta file to another fasta file.

I have two fasta files. Both files have equal number of sequences but with different sequences and also different sequence id. (First file have CDS sequences and second file have Promoter sequences for CDS sequences of first file in same order.) I want to replace sequence id of second file from sequence id of first file in same order (Replace first sequence id of second file with first sequence id of first file, second sequence id with second sequence id, third sequence id with third sequence id and so on...).enter image description here

fasta sequence id

Hi Victorsaroha.vs,

You may not be aware of this, but questions like these have been asked tens of times. If you google for biostars replace fasta header you'll find plenty of hits giving you inspiration on how to solve your question.

Feel free to ask again if you get stuck - but please try first to find a solution yourself - and show the effort you put in solving the question.

Cheers,
Wouter

1 answer

This might work:

paste -d'\n' cds.fa pro.fa | awk '{if (NR % 4 == 1 || NR % 4 == 0) print $0}'

Sorry... this just merged both files pasting sequences from Promoter file in the last of CDS file.

see if this works: $ paste -d'\n' cds.fa promoter.fa | awk '{if (NR % 4 == 2 || NR % 4 == 3) print $0}' . If it works, up vote PP (kloetzl's post).

Log in to answer this question.