Question: Problems awking columns from map file
0
gravatar for Nuthatch
3 months ago by
Nuthatch0
Nuthatch0 wrote:

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!

unix convertf map awk ped • 143 views
ADD COMMENTlink modified 3 months ago by Bastien Hervé4.9k • written 3 months ago by Nuthatch0
2
gravatar for Bastien Hervé
3 months ago by
Bastien Hervé4.9k
Karolinska Institutet, Sweden
Bastien Hervé4.9k wrote:

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
ADD COMMENTlink modified 3 months ago • written 3 months ago by Bastien Hervé4.9k

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?

ADD REPLYlink written 3 months ago by Nuthatch0

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

ADD REPLYlink written 3 months ago by Nuthatch0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2577 users visited in the last hour
_