def numDomtblout_sort(domtblout, numHits, evalueT, bitT):
header = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>']<EOL>yield header<EOL>hmm = {h:[] for h in header}<EOL>for line in domtblout:<EOL><INDENT>if line.startswith('<STR_LIT:#>'):<EOL><INDENT>continue<EOL><DEDENT>line = line.strip().split()<EOL>line[<NUM_LIT:11>], line[<NUM_LIT>] = float(line[<NUM_LIT:11>]), float(line[<NUM_LIT>])<EOL>evalue, bit = line[<NUM_LIT:11>], line[<NUM_LIT>]<EOL>if evalueT is not False and evalue > evalueT:<EOL><INDENT>continue<EOL><DEDENT>if bitT is not False and bit < bitT:<EOL><INDENT>continue<EOL><DEDENT>line, desc = line[<NUM_LIT:0>:<NUM_LIT>], '<STR_LIT:U+0020>'.join(line[<NUM_LIT>:])<EOL>line.append(desc)<EOL>for i, h in zip(line, header):<EOL><INDENT>hmm[h].append(i)<EOL><DEDENT><DEDENT>hmm = pd.DataFrame(hmm)<EOL>for query, df in hmm.groupby(by = ['<STR_LIT>', '<STR_LIT>']):<EOL><INDENT>df = df.sort_values(by = ['<STR_LIT>'], ascending = False)<EOL>for hit in df[header].values[<NUM_LIT:0>:numHits]:<EOL><INDENT>yield hit<EOL><DEDENT><DEDENT>
parse hmm domain table output with sorting