I have two input file.:
File 1 is a large reference sequence (A large Fasta sequence);
File 1 (is a file which first line is the header description and line other ">" is its corresponding word and counting from 1 till end of file);
>Data_1
ASWDADAQTWQQGSAAAAASDAFAFA
.
.
File 2 is list of data that I interested to replace specific word at specific location in File 1;
File 2 (3 column in File 2 and is tab-delimited format);
Data_1 2 Z
Data_1 3 T
Data_1 10 A
Data_1 11 T
.
.
Desired Output File
>Data_1
AZTDADAQTATQGSAAAAASDAFAFA
.
.
File 1 is a long record Fasta file (Include a first line of header description and line after ">" is its corresponding word).
File 2 is a file got 3 column (Tab-delimited).
First column is the header description (without ">") of File 1;
Second column is the position of word that I wanna to replace in File 1 based on Third column data;
Third column is the word that I wanna to replace it which specific word/specific position of File 1;
Awk code try
awk -F "\t" '(FNR==1){x++} (x==1){a[$1][$2]=$3;next} (x==2){if($0~/>/){h=$0;sub(/^.*Data/,"",h);sub(/ .*/,"",h)} else{seq[h]=seq[h]$0}} END{for(i in a){s=0; for(j in a){m=m substr(seq,s,j-1) a[j];s=j+1} m=m substr(seq,s); print ">Data"i"\n"m}}' File 2 File 1
I would like to replace specific word (exclude header >Data_1) at specific location in File 1 if it is list on File 2 data.
My main objective is hope to replace specific word at specific location in File 1 based on the record provided in File 2 (specific position and replace with new word based on File 2).
Thanks for any advice.