This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Problems awking columns from map file

Hi everyone, I've converted three PACKEDANCESTRYMAP format files (myfile.geno, myfile.snp, myfile.ind) into PED files (myfile.ped, myfile.map, myfile.pedind), using convertf.

myfile.map obtained from the conversion has six columns, and looks like this:

1     rs3094315     0.020130       752566 G A
1    rs12124819     0.020242       776546 A G
1    rs28765502     0.022137       832918 T C
1     rs7419119     0.022518       842013 T G
1      rs950122     0.022720       846864 G C

I want to remove the last two columns of this file. So I've tried with this command:

awk '{print $1" "$2" "$3" "$4"}' myfile.map > myfile_fourcol.map

It worked for other map files in the past, but now I get this message:

awk: cmd. line:1: {print $1" "$2" "$3" "$4"}
awk: cmd. line:1:                         ^ unterminated string
awk: cmd. line:1: {print $1" "$2" "$3" "$4"}
awk: cmd. line:1:                         ^ syntax error

Can anyone help me to fix this? Thank you!

awk unix map ped convertf

1 answer

The error is clear :

awk: cmd. line:1: {print $1" "$2" "$3" "$4"}
awk: cmd. line:1:                         ^ unterminated string

The " after $4 should be remove

Tabulation is a better delimiter than white spaces

awk -F '\t' '{print $1"\t"$2"\t"$3"\t"$4}' myfile.map > myfile_fourcol.map

I tried with your command, but I got tha same error message. Apparently tabulation is not the delimiter. How to know which is the actual delimiter?

Sorry. I forgot to remove the " after $4! Now it's ok! Problem solved.

Log in to answer this question.