Entering edit mode
5.6 years ago
max_19
▴
170
Hi all,
I have a file of orthogroups and I need to convert the identifiers in it (using a conversion/reference file) so that blast will recognize them. I'm having an unexpected result using the code below.
orthogroup file looks like this (each line is an orthogroup, and members of that group are separated by space)
ortholog_group_1522: PAN|EQB60376.1 NAA|KCZ79755.1 PPS|OIR57675.1
ortholog_group_1330: EAE|EJW04139.1 IBE|XP_002650367.1
my reference/conversion file (2 column file):
PAN|EQB60376.1 gnl|BL_ORD_ID|0
NAA|KCZ79755.1 gnl|BL_ORD_ID|1
PPS|OIR57675.1 gnl|BL_ORD_ID|2
desired output is: ortholog_group_1522: gnl|BL_ORD_ID|0 gnl|BL_ORD_ID|1 gnl|BL_ORD_ID|2
I am working with the script below, but it is not producing the desired output:
replace.awk
NR==FNR { pattern[NR] = $1; replacement[NR] = $2; count++; next }
{
for (i = 1; i <= count; i++) {
sub(pattern[i], replacement[i])
}
print $0
}
awk -f replace.awk conversion_file.txt my_ortho_groups.txt
any ideas on what i'm missing here?
See if this helps: https://www.unix.com/unix-for-dummies-questions-and-answers/265523-awk-replace-values-one-file-using-second-reference-file.html