variant analysis and filtering from annotation file
1
0
Entering edit mode
8.0 years ago
garimav89 • 0

I have a annotation.txt file like this : chr1 34567 A chr2 12345 C chr14 14567 T chr15 32456 A

I want to extract data of chr1 only. I'm using following command: awk '$1 ~/chr1/' annotation.txt > chr1.txt

But it is giving me results for chr11, chr12 , chr13, chr14, chr15, chr16, chr17, chr18, chr19 as well. please help me to extract data of just chr1.

R SNP • 1.5k views
ADD COMMENT
0
Entering edit mode
8.0 years ago
a1.gough • 0

Depends on the exact format of the file - if there are multiple lines where chr1 may occur:

awk 'match($0,/chr1 [0-9]+ [ACTG]/) {print substr($0,RSTART,RLENGTH)}' annotation.txt > chr1.txt

ADD COMMENT

Login before adding your answer.

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