variant analysis and filtering from annotation file
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.
• 1,773 views
•
link
1 answer
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
• 0 views
•
link
Log in to answer this question.