I have a fasta file which looks like this.
>header1
ATGC....
>header2
ATGC...
My list files looks like this
organism1
organism2
and contains a list of organism that I want to replace the header with.
I tried to use a for loop using sed command which is as follows:
for i in `cat list7b`; do sed "s/^>/$i/g" sequence.fa; done
but it didn't work please tell how I can achieve this task.
The result file should look like this
>organism1
ATGC...
>organism2
ATGC....
that is >header1 replaced with >organism_1 and so on
- The two headers are distinguished from ATGC as header always starts with
>greater than sign whereas ATGC would not. That's how they are distinguished. - The header lines should be replaced by the order of appearance, i.e. first
header*replaced with first-line from file, 2nd header from the second and so on.
I also request to explain the logic if possible. thanks in advance.
header1,header2etc lines from theATGC....lines. I assume the two linesorganism1andorganism2are your filelist7b. How do you define whichorganism*line shall replace whichheader*line? By a common trailing number, e.g.header1 ->organism1 etc? Or by the order of appearance, i.e. firstheader*replaced with first line from file, 2ndheader*with 2nd line etc?