<p>The TSV output should be sorted by default in a way that for a given query the top hit comes first, followed by other hits. For a quick extraction of top hits you may use a rather simplistic script:</p>
<p><a href="https://github.com/Cancer-Genomics-TH/tRNA_methyl/blob/main/src/parse_top_hits_cmscan.py" rel="nofollow noreferrer">https://github.com/Cancer-Genomics-TH/tRNA_methyl/blob/main/src/parse_top_hits_cmscan.py</a></p>

CC BY-SA 4.0
2024-02-21T19:03:08.343Z
2024-02-21T19:13:44.973Z
2024-02-21T19:13:44.973Z
darked89
<p>Since we don't know what you are trying to maximize here, which of the various columns would define the &quot;best&quot; hit for what you are trying to do, here is a generic solution that will just find the highest score:</p>
<pre class="lang-none prettyprint-override"><code>$ awk '( ! best[$1] ||  $6 &gt; best[$1] ){ best[$1]=$6; line[$1]=$0 } END{ for(name in best){ print line[name] }}' file 
NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh_C         PF02826.23   178   6.6e-63  209.7   0.0   1   2   1.3e-65   1.9e-62  208.2   0.0     1   178   110   284   110   284 0.98 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_232 -            309 2-Hacid_dh_C         PF02826.23   178   2.2e-49  165.7   0.0   1   1   1.9e-52   2.9e-49  165.3   0.0     4   178    97   271    95   271 0.92 # 243113 # 244039 # -1 # ID=7_232;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.653
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh_C         PF02826.23   178   7.2e-51  170.5   0.0   1   1   6.8e-54     1e-50  170.0   0.0     7   178   118   287   112   287 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_9_length_318862_cov_66.931761_127 -            311 2-Hacid_dh_C         PF02826.23   178   3.8e-48  161.7   0.0   1   1   3.3e-51   4.9e-48  161.3   0.0     2   176   100   271    98   273 0.89 # 151217 # 152149 # -1 # ID=9_127;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.652
NODE_2_length_853960_cov_68.957247_395 -            506 2-oxoacid_dh         PF00198.27   232   1.7e-82  274.8   0.0   1   1   2.2e-85   2.3e-82  274.4   0.0     2   231   277   504   276   505 0.98 # 406642 # 408159 # 1 # ID=2_395;partial=00;start_type=ATG;rbs_motif=GGA/GAG/AGG;rbs_spacer=5-10bp;gc_cont=0.644
NODE_2_length_853960_cov_68.957247_550 -            554 PGI                  PF00342.23   486  8.5e-202  669.5   0.0   1   1  1.6e-205  9.7e-202  669.3   0.0     1   486    52   543    52   543 0.97 # 568442 # 570103 # -1 # ID=2_550;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.626
</code></pre>
<p>To get the maximum value of a different field, just change <code>$6</code> to the corresponding field number.</p>
<p>And here's a version that looks for the smallest value, in this case using the E-value (field 5):</p>
<pre class="lang-none prettyprint-override"><code>$ awk '( ! best[$1] ||  $6 &lt; best[$1] ){ best[$1]=$6; line[$1]=$0 } END{ for(name in best){ print line[name] }}' file 
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   1   3      0.76   4.6e+03   -3.8   0.0    68    81    87   100    86   123 0.54 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_232 -            309 2-Hacid_dh_C         PF02826.23   178   2.2e-49  165.7   0.0   1   1   1.9e-52   2.9e-49  165.3   0.0     4   178    97   271    95   271 0.92 # 243113 # 244039 # -1 # ID=7_232;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.653
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh           PF00389.34   134   1.3e-13   49.2   0.0   1   1   5.1e-17   1.5e-13   49.0   0.0    21   129    28   314     6   318 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_9_length_318862_cov_66.931761_127 -            311 2-Hacid_dh_C         PF02826.23   178   3.8e-48  161.7   0.0   1   1   3.3e-51   4.9e-48  161.3   0.0     2   176   100   271    98   273 0.89 # 151217 # 152149 # -1 # ID=9_127;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.652
NODE_2_length_853960_cov_68.957247_395 -            506 2-oxoacid_dh         PF00198.27   232   1.7e-82  274.8   0.0   1   1   2.2e-85   2.3e-82  274.4   0.0     2   231   277   504   276   505 0.98 # 406642 # 408159 # 1 # ID=2_395;partial=00;start_type=ATG;rbs_motif=GGA/GAG/AGG;rbs_spacer=5-10bp;gc_cont=0.644
NODE_2_length_853960_cov_68.957247_550 -            554 PGI                  PF00342.23   486  8.5e-202  669.5   0.0   1   1  1.6e-205  9.7e-202  669.3   0.0     1   486    52   543    52   543 0.97 # 568442 # 570103 # -1 # ID=2_550;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.626
</code></pre>
<p>And here is the same code, expanded, with an explanation (this will still execute correctly if you copy/paste it into a terminal):</p>
<pre class="lang-shellsession prettyprint-override"><code>awk '
  ## If there's no value for the first field in the 'best' array or, if the
  ## existing value is lower than the 6th field, then save the $6th  field 
  ## as the new value for this name in the 'best' array, and save the current 
  ## line as the value in the 'line' array.
  ( ! best[$1] ||  $6 &lt; best[$1] ){ 
     best[$1]=$6 
     line[$1]=$0
  } 
  ## When we reach the end of the file, iterate over the 'line'
  ## array, and print each element.
  END{ 
    for(name in best){ 
      print line[name]
    }
   }' file 
</code></pre>

CC BY-SA 4.0
2024-02-21T21:25:07.450Z
2024-02-21T21:25:07.450Z
terdon
<p>I did <code>hmmsearch</code> with <code>--notextw</code> and <code>--domtblout</code> and I see several results for ids, I want to get the best result for each id. How I can parse it?</p>
<p><a href="https://i.sstatic.net/MK8KU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MK8KU.png" alt="enter image description here" /></a></p>
<p>I saw the tools in Biopython SearchIO but I really can't understand how I can do it. Please, can you explain it in detail?</p>
<p><strong>This is part of my file:</strong></p>
<pre><code>NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh           PF00389.34   134   1.6e-35  120.1   0.4   1   1   1.1e-38   3.3e-35  119.2   0.4     1   134     9   316     9   316 0.99 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh           PF00389.34   134   1.3e-13   49.2   0.0   1   1   5.1e-17   1.5e-13   49.0   0.0    21   129    28   314     6   318 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh_C         PF02826.23   178   6.6e-63  209.7   0.0   1   2   1.3e-65   1.9e-62  208.2   0.0     1   178   110   284   110   284 0.98 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh_C         PF02826.23   178   6.6e-63  209.7   0.0   2   2       1.1   1.6e+03   -3.3   0.0     6    44   331   369   328   371 0.66 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh_C         PF02826.23   178   7.2e-51  170.5   0.0   1   1   6.8e-54     1e-50  170.0   0.0     7   178   118   287   112   287 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_7_length_349797_cov_70.130335_232 -            309 2-Hacid_dh_C         PF02826.23   178   2.2e-49  165.7   0.0   1   1   1.9e-52   2.9e-49  165.3   0.0     4   178    97   271    95   271 0.92 # 243113 # 244039 # -1 # ID=7_232;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.653
NODE_9_length_318862_cov_66.931761_127 -            311 2-Hacid_dh_C         PF02826.23   178   3.8e-48  161.7   0.0   1   1   3.3e-51   4.9e-48  161.3   0.0     2   176   100   271    98   273 0.89 # 151217 # 152149 # -1 # ID=9_127;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.652
NODE_2_length_853960_cov_68.957247_395 -            506 2-oxoacid_dh         PF00198.27   232   1.7e-82  274.8   0.0   1   1   2.2e-85   2.3e-82  274.4   0.0     2   231   277   504   276   505 0.98 # 406642 # 408159 # 1 # ID=2_395;partial=00;start_type=ATG;rbs_motif=GGA/GAG/AGG;rbs_spacer=5-10bp;gc_cont=0.644
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   1   3      0.76   4.6e+03   -3.8   0.0    68    81    87   100    86   123 0.54 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   2   3       0.4   2.4e+03   -2.9   0.0    54    72   208   226   199   249 0.73 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   3   3   2.6e-22   1.6e-18   65.4   0.4     2   119   326   446   325   446 0.91 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_2_length_853960_cov_68.957247_550 -            554 PGI                  PF00342.23   486  8.5e-202  669.5   0.0   1   1  1.6e-205  9.7e-202  669.3   0.0     1   486    52   543    52   543 0.97 # 568442 # 570103 # -1 # ID=2_550;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.626
</code></pre>
<p>You can see <code>NODE_1_length_959108_cov_67.987603_423</code> several times with different annotations (<code>2-Hacid_dh</code>, <code>PF00389.34</code> and <code>2-Hacid_dh_C</code>, <code>PF02826.23</code> and <code>PGDH_inter</code>, <code>PF19304.3</code>).</p>
<p>I need to get only best result, only ONE result. I need to see only one row with this id (<code>NODE_1_length_959108_cov_67.987603_423</code>) with  only one annotation.</p>
<p>I assumed that there were some programs with certain algorithms that could select one thing. For example, as in blastp there is --max_hsps 1. I need to make a pivot table for each ID. I did a search in the Swissprot database, in the Pataa database, and also in Pfam. But there are several search results in pfam and I don’t know how to put it in the pivot table</p>

CC BY-SA 4.0
2024-02-21T19:02:27.687Z
Can you please paste the content as text instead of using screenshots? Also, the user manual says something *really* weird: "The tblout format is deliberately space-delimited (rather than tab-delimited) and justified into aligned columns, so these files are suitable both for automated parsing and for human examination." I think the author is wrong but your output does not look justified either, so I don't know what's happening.
Ram RS
CC BY-SA 4.0
2024-02-21T19:27:14.443Z
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Community
CC BY-SA 4.0
2024-02-21T20:00:59.907Z
Please post the _real_ file. We need an example we can use. Your image shows headers, but they are not shown in the text example. Please make sure the example accurately reflects the real input, and then also add what output you expect. You say you want the "best" hit. OK, but "best" based on what? Lowest E-value? Highest score? Longest length? And why would you only want one row? What if many are equally good?
terdon
CC BY-SA 4.0
2024-02-21T21:03:49.923Z
blast's `--max_hsps 1` does not work the way you think it does, it does not return the best hit.
Ram RS
CC BY-SA 4.0
2024-02-21T21:05:47.367Z
Please [edit] and give us these details. If we understand the biological question you are trying to answer, we might be able to help more. We don't even know the species you are working with or what input you used. You mentioned Pfam, should we assume you are looking for protein domain matches? To find homologs in different species perhaps? If so, please tell us since that changes what "best" would mean. Do you want the best match to the search HMM? The longest match for each input? And please add a full example. We need to see the headers in order to parse and to know what the data are.
terdon
CC BY-SA 4.0
2024-02-26T16:58:27.397Z
Hi @bobr could kindly mark one of the answers as "accepted" please? The question has been well answered - so its only fair on those answering - in addition it helps site stats (the question can keep circulating within the site otherwise).
M__
<linux><biopython><functional-annotation><parsing><hmmer>
How to parse hmmsearch output?
# How to parse hmmsearch output?

(Asked by: username_0 on 2024-02-21)

I did hmmsearch with --notextw and --domtblout and I see several results for ids, I want to get the best result for each id. How I can parse it?

I saw the tools in Biopython SearchIO but I really can't understand how I can do it. Please, can you explain it in detail?
This is part of my file:
NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh           PF00389.34   134   1.6e-35  120.1   0.4   1   1   1.1e-38   3.3e-35  119.2   0.4     1   134     9   316     9   316 0.99 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh           PF00389.34   134   1.3e-13   49.2   0.0   1   1   5.1e-17   1.5e-13   49.0   0.0    21   129    28   314     6   318 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh_C         PF02826.23   178   6.6e-63  209.7   0.0   1   2   1.3e-65   1.9e-62  208.2   0.0     1   178   110   284   110   284 0.98 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh_C         PF02826.23   178   6.6e-63  209.7   0.0   2   2       1.1   1.6e+03   -3.3   0.0     6    44   331   369   328   371 0.66 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh_C         PF02826.23   178   7.2e-51  170.5   0.0   1   1   6.8e-54     1e-50  170.0   0.0     7   178   118   287   112   287 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_7_length_349797_cov_70.130335_232 -            309 2-Hacid_dh_C         PF02826.23   178   2.2e-49  165.7   0.0   1   1   1.9e-52   2.9e-49  165.3   0.0     4   178    97   271    95   271 0.92 # 243113 # 244039 # -1 # ID=7_232;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.653
NODE_9_length_318862_cov_66.931761_127 -            311 2-Hacid_dh_C         PF02826.23   178   3.8e-48  161.7   0.0   1   1   3.3e-51   4.9e-48  161.3   0.0     2   176   100   271    98   273 0.89 # 151217 # 152149 # -1 # ID=9_127;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.652
NODE_2_length_853960_cov_68.957247_395 -            506 2-oxoacid_dh         PF00198.27   232   1.7e-82  274.8   0.0   1   1   2.2e-85   2.3e-82  274.4   0.0     2   231   277   504   276   505 0.98 # 406642 # 408159 # 1 # ID=2_395;partial=00;start_type=ATG;rbs_motif=GGA/GAG/AGG;rbs_spacer=5-10bp;gc_cont=0.644
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   1   3      0.76   4.6e+03   -3.8   0.0    68    81    87   100    86   123 0.54 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   2   3       0.4   2.4e+03   -2.9   0.0    54    72   208   226   199   249 0.73 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   3   3   2.6e-22   1.6e-18   65.4   0.4     2   119   326   446   325   446 0.91 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_2_length_853960_cov_68.957247_550 -            554 PGI                  PF00342.23   486  8.5e-202  669.5   0.0   1   1  1.6e-205  9.7e-202  669.3   0.0     1   486    52   543    52   543 0.97 # 568442 # 570103 # -1 # ID=2_550;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.626

You can see NODE_1_length_959108_cov_67.987603_423 several times with different annotations (2-Hacid_dh, PF00389.34 and 2-Hacid_dh_C, PF02826.23 and PGDH_inter, PF19304.3).
I need to get only best result, only ONE result. I need to see only one row with this id (NODE_1_length_959108_cov_67.987603_423) with  only one annotation.
I assumed that there were some programs with certain algorithms that could select one thing. For example, as in blastp there is --max_hsps 1. I need to make a pivot table for each ID. I did a search in the Swissprot database, in the Pataa database, and also in Pfam. But there are several search results in pfam and I don’t know how to put it in the pivot table

**Tags:** linux, biopython, functional-annotation, parsing, hmmer
> **Comments:**
> **username_1**: Can you please paste the content as text instead of using screenshots? Also, the user manual says something *really* weird: "The tblout format is deliberately space-delimited (rather than tab-delimited) and justified into aligned columns, so these files are suitable both for automated parsing and for human examination." I think the author is wrong but your output does not look justified either, so I don't know what's happening.  
> **username_2**: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.  
> **username_3**: Please post the _real_ file. We need an example we can use. Your image shows headers, but they are not shown in the text example. Please make sure the example accurately reflects the real input, and then also add what output you expect. You say you want the "best" hit. OK, but "best" based on what? Lowest E-value? Highest score? Longest length? And why would you only want one row? What if many are equally good?  
> **username_1**: blast's `--max_hsps 1` does not work the way you think it does, it does not return the best hit.  
> **username_3**: Please [edit] and give us these details. If we understand the biological question you are trying to answer, we might be able to help more. We don't even know the species you are working with or what input you used. You mentioned Pfam, should we assume you are looking for protein domain matches? To find homologs in different species perhaps? If so, please tell us since that changes what "best" would mean. Do you want the best match to the search HMM? The longest match for each input? And please add a full example. We need to see the headers in order to parse and to know what the data are.  
> **username_4**: Hi @bobr could kindly mark one of the answers as "accepted" please? The question has been well answered - so its only fair on those answering - in addition it helps site stats (the question can keep circulating within the site otherwise).  

---

## 2 answers

### Answer by username_5 on 2024-02-21. Score: 2

The TSV output should be sorted by default in a way that for a given query the top hit comes first, followed by other hits. For a quick extraction of top hits you may use a rather simplistic script:

<https://github.com/Cancer-Genomics-TH/tRNA_methyl/blob/main/src/parse_top_hits_cmscan.py>


---

### Answer by username_3 on 2024-02-21. Score: 1

Since we don't know what you are trying to maximize here, which of the various columns would define the "best" hit for what you are trying to do, here is a generic solution that will just find the highest score:
$ awk '( ! best[$1] ||  $6 > best[$1] ){ best[$1]=$6; line[$1]=$0 } END{ for(name in best){ print line[name] }}' file 
NODE_1_length_959108_cov_67.987603_423 -            531 2-Hacid_dh_C         PF02826.23   178   6.6e-63  209.7   0.0   1   2   1.3e-65   1.9e-62  208.2   0.0     1   178   110   284   110   284 0.98 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_232 -            309 2-Hacid_dh_C         PF02826.23   178   2.2e-49  165.7   0.0   1   1   1.9e-52   2.9e-49  165.3   0.0     4   178    97   271    95   271 0.92 # 243113 # 244039 # -1 # ID=7_232;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.653
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh_C         PF02826.23   178   7.2e-51  170.5   0.0   1   1   6.8e-54     1e-50  170.0   0.0     7   178   118   287   112   287 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_9_length_318862_cov_66.931761_127 -            311 2-Hacid_dh_C         PF02826.23   178   3.8e-48  161.7   0.0   1   1   3.3e-51   4.9e-48  161.3   0.0     2   176   100   271    98   273 0.89 # 151217 # 152149 # -1 # ID=9_127;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.652
NODE_2_length_853960_cov_68.957247_395 -            506 2-oxoacid_dh         PF00198.27   232   1.7e-82  274.8   0.0   1   1   2.2e-85   2.3e-82  274.4   0.0     2   231   277   504   276   505 0.98 # 406642 # 408159 # 1 # ID=2_395;partial=00;start_type=ATG;rbs_motif=GGA/GAG/AGG;rbs_spacer=5-10bp;gc_cont=0.644
NODE_2_length_853960_cov_68.957247_550 -            554 PGI                  PF00342.23   486  8.5e-202  669.5   0.0   1   1  1.6e-205  9.7e-202  669.3   0.0     1   486    52   543    52   543 0.97 # 568442 # 570103 # -1 # ID=2_550;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.626

To get the maximum value of a different field, just change $6 to the corresponding field number.
And here's a version that looks for the smallest value, in this case using the E-value (field 5):
$ awk '( ! best[$1] ||  $6 < best[$1] ){ best[$1]=$6; line[$1]=$0 } END{ for(name in best){ print line[name] }}' file 
NODE_1_length_959108_cov_67.987603_423 -            531 PGDH_inter           PF19304.3    119   9.9e-19   66.1   1.5   1   3      0.76   4.6e+03   -3.8   0.0    68    81    87   100    86   123 0.54 # 448882 # 450474 # -1 # ID=1_423;partial=00;start_type=GTG;rbs_motif=GGAG/GAGG;rbs_spacer=5-10bp;gc_cont=0.664
NODE_7_length_349797_cov_70.130335_232 -            309 2-Hacid_dh_C         PF02826.23   178   2.2e-49  165.7   0.0   1   1   1.9e-52   2.9e-49  165.3   0.0     4   178    97   271    95   271 0.92 # 243113 # 244039 # -1 # ID=7_232;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.653
NODE_7_length_349797_cov_70.130335_175 -            319 2-Hacid_dh           PF00389.34   134   1.3e-13   49.2   0.0   1   1   5.1e-17   1.5e-13   49.0   0.0    21   129    28   314     6   318 0.94 # 187752 # 188708 # -1 # ID=7_175;partial=00;start_type=GTG;rbs_motif=AGGAG;rbs_spacer=5-10bp;gc_cont=0.637
NODE_9_length_318862_cov_66.931761_127 -            311 2-Hacid_dh_C         PF02826.23   178   3.8e-48  161.7   0.0   1   1   3.3e-51   4.9e-48  161.3   0.0     2   176   100   271    98   273 0.89 # 151217 # 152149 # -1 # ID=9_127;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.652
NODE_2_length_853960_cov_68.957247_395 -            506 2-oxoacid_dh         PF00198.27   232   1.7e-82  274.8   0.0   1   1   2.2e-85   2.3e-82  274.4   0.0     2   231   277   504   276   505 0.98 # 406642 # 408159 # 1 # ID=2_395;partial=00;start_type=ATG;rbs_motif=GGA/GAG/AGG;rbs_spacer=5-10bp;gc_cont=0.644
NODE_2_length_853960_cov_68.957247_550 -            554 PGI                  PF00342.23   486  8.5e-202  669.5   0.0   1   1  1.6e-205  9.7e-202  669.3   0.0     1   486    52   543    52   543 0.97 # 568442 # 570103 # -1 # ID=2_550;partial=00;start_type=ATG;rbs_motif=None;rbs_spacer=None;gc_cont=0.626

And here is the same code, expanded, with an explanation (this will still execute correctly if you copy/paste it into a terminal):
awk '
  ## If there's no value for the first field in the 'best' array or, if the
  ## existing value is lower than the 6th field, then save the $6th  field 
  ## as the new value for this name in the 'best' array, and save the current 
  ## line as the value in the 'line' array.
  ( ! best[$1] ||  $6 < best[$1] ){ 
     best[$1]=$6 
     line[$1]=$0
  } 
  ## When we reach the end of the file, iterate over the 'line'
  ## array, and print each element.
  END{ 
    for(name in best){ 
      print line[name]
    }
   }' file


---

