Input:
21 templeta parent 35718 36554 . - . ID=parent_cluster_50.21.11; Name=Partial%20parent%20for%20training%20set;
21 templeta kids 35718 36554 . - . ID=_52; Parent=parent_cluster_5085.21.11;
21 templeta location 35840 36073 . - . ID=_5285.location4; Parent=_5285
21 templeta pattern 35840 36073 . - 0 ID=_52.cds4; Parent=_5285
21 templeta location 35718 35778 . - . ID=_5285.location5; Parent=_5285
21 templeta pattern 35758 35778 . - 0 ID=_52.cds5; Parent=_5285
21 templeta length 35718 35757 . - . ID=_52.utr3p1; Parent=_5285
21 templeta parent 43191 43851 . + . ID=parent_cluster_5086.21.12; Name=Partial%20parent%20for%20training%20set;
21 templeta kids 43191 43851 . + . ID=_5286; Parent=parent_cluster_5086.21.12;
21 templeta length 43191 43192 . + . ID=_5286.utr5p1; Parent=_5286
21 templeta location 43191 43851 . + . ID=_5286.location1; Parent=_5286
21 templeta pattern 43193 43819 . + 0 ID=_5286.cds1; Parent=_5286; 5_prime_partial=true
21 templeta length 43820 43851 . + . ID=_5286.utr3p1; Parent=_5286
22 templeta parent 4204 4962 . - . ID=parent_cluster_5087.22.1; Name=Partial%20parent%20for%20training%20set;
22 templeta kids 4204 4962 . - . ID=_5287; Parent=parent_cluster_5087.22.1;
22 templeta length 4876 4962 . - . ID=_5287.utr5p1; Parent=_5287
22 templeta location 4204 4962 . - . ID=_5287.location1; Parent=_5287
22 templeta pattern 4204 4875 . - 0 ID=_5287.cds1; Parent=_5287; 3_prime_partial=true
Desired output:
21 templeta parent 35718 36554 . - . ID=parent_cluster_50.21.11; Name=Partial%20parent%20for%20training%20set;
21 templeta kids 35718 36554 . - . ID=_52; Parent=parent_cluster_5085.21.11;
21 templeta location 35840 36073 . - . ID=_5285.location4; Parent=_5285
21 templeta pattern 35840 36073 . - 0 ID=_52.cds4; Parent=_5285
21 templeta location 35718 35778 . - . ID=_5285.location5; Parent=_5285
21 templeta pattern 35758 35778 . - 0 ID=_52.cds5; Parent=_5285
21 templeta length 35718 35757 . - . ID=_52.utr3p1; Parent=_5285
Awk code that I have tried:
awk 'BEGIN {RS=""; FS="\n"} {for (i=1;i<=NF;i++) {if ($i~/ID=_52/) {print $_}}}' input_file
Output I get:
21 templeta parent 35718 36554 . - . ID=parent_cluster_50.21.11; Name=Partial%20parent%20for%20training%20set;
21 templeta kids 35718 36554 . - . ID=_52; Parent=parent_cluster_5085.21.11;
21 templeta location 35840 36073 . - . ID=_5285.location4; Parent=_5285
21 templeta pattern 35840 36073 . - 0 ID=_52.cds4; Parent=_5285
21 templeta location 35718 35778 . - . ID=_5285.location5; Parent=_5285
21 templeta pattern 35758 35778 . - 0 ID=_52.cds5; Parent=_5285
21 templeta length 35718 35757 . - . ID=_52.utr3p1; Parent=_5285
21 templeta parent 43191 43851 . + . ID=parent_cluster_5086.21.12; Name=Partial%20parent%20for%20training%20set;
21 templeta kids 43191 43851 . + . ID=_5286; Parent=parent_cluster_5086.21.12;
21 templeta length 43191 43192 . + . ID=_5286.utr5p1; Parent=_5286
21 templeta location 43191 43851 . + . ID=_5286.location1; Parent=_5286
21 templeta pattern 43193 43819 . + 0 ID=_5286.cds1; Parent=_5286; 5_prime_partial=true
21 templeta length 43820 43851 . + . ID=_5286.utr3p1; Parent=_5286
22 templeta parent 4204 4962 . - . ID=parent_cluster_5087.22.1; Name=Partial%20parent%20for%20training%20set;
22 templeta kids 4204 4962 . - . ID=_5287; Parent=parent_cluster_5087.22.1;
22 templeta length 4876 4962 . - . ID=_5287.utr5p1; Parent=_5287
22 templeta location 4204 4962 . - . ID=_5287.location1; Parent=_5287
22 templeta pattern 4204 4875 . - 0 ID=_5287.cds1; Parent=_5287; 3_prime_partial=true
My purpose is plan to use awk or any other programming language to extract those content that match exactly only "ID=_52" word instead of extract all the content that slightly match to "ID=_52" like "ID_05286", "ID_05287" .
Thanks for any advice.