replace values using a reference file
0
0
Entering edit mode
5.0 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?

sequencing fasta orthogroups • 809 views
ADD COMMENT

Login before adding your answer.

Traffic: 2339 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