nodes: 0, module; 1, function_definition; 2, function_name:numDomtblout; 3, parameters; 4, block; 5, identifier:domtblout; 6, identifier:numHits; 7, identifier:evalueT; 8, identifier:bitT; 9, identifier:sort; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, for_statement; 16, for_statement; 17, comment:"""
      parse hmm domain table output
      this version is faster but does not work unless the table is sorted
      """; 18, comparison_operator:sort is True; 19, block; 20, assignment; 21, yield; 22, assignment; 23, identifier:line; 24, identifier:domtblout; 25, block; 26, identifier:hit; 27, call; 28, block; 29, identifier:sort; 30, True; 31, for_statement; 32, return_statement; 33, identifier:header; 34, list; 35, identifier:header; 36, pattern_list; 37, expression_list; 38, if_statement; 39, comment:# parse line and get description; 40, expression_statement; 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, comment:# create ID based on query name and domain number; 45, expression_statement; 46, comment:# domain c-Evalue and domain score thresholds; 47, expression_statement; 48, expression_statement; 49, expression_statement; 50, if_statement; 51, if_statement; 52, expression_statement; 53, identifier:top_hits; 54, argument_list; 55, expression_statement; 56, identifier:hit; 57, call; 58, block; 59, string; 60, string; 61, string; 62, string; 63, string; 64, string; 65, string; 66, string; 67, string; 68, string; 69, string; 70, string; 71, string; 72, string; 73, string; 74, string; 75, string; 76, string; 77, string; 78, string; 79, string; 80, string; 81, string; 82, identifier:prev; 83, identifier:hits; 84, None; 85, list; 86, call; 87, block; 88, assignment; 89, assignment; 90, assignment; 91, call; 92, assignment; 93, assignment; 94, assignment; 95, assignment; 96, comparison_operator:ID != prev; 97, block; 98, boolean_operator; 99, block; 100, elif_clause; 101, elif_clause; 102, elif_clause; 103, assignment; 104, identifier:hits; 105, identifier:numHits; 106, integer:13; 107, True; 108, yield; 109, identifier:numDomtblout_sort; 110, argument_list; 111, expression_statement; 112, string_content:#target name; 113, string_content:target accession; 114, string_content:tlen; 115, string_content:query name; 116, string_content:query accession; 117, string_content:qlen; 118, string_content:full E-value; 119, string_content:full score; 120, string_content:full bias; 121, string_content:domain #; 122, string_content:# domains; 123, string_content:domain c-Evalue; 124, string_content:domain i-Evalue; 125, string_content:domain score; 126, string_content:domain bias; 127, string_content:hmm from; 128, string_content:hmm to; 129, string_content:seq from; 130, string_content:seq to; 131, string_content:env from; 132, string_content:env to; 133, string_content:acc; 134, string_content:target description; 135, attribute; 136, argument_list; 137, continue_statement; 138, identifier:line; 139, call; 140, identifier:desc; 141, call; 142, identifier:line; 143, subscript; 144, attribute; 145, argument_list; 146, identifier:ID; 147, binary_operator:line[0] + line[9]; 148, pattern_list; 149, expression_list; 150, pattern_list; 151, expression_list; 152, pattern_list; 153, expression_list; 154, identifier:ID; 155, identifier:prev; 156, if_statement; 157, expression_statement; 158, comparison_operator:evalueT == False; 159, comparison_operator:bitT == False; 160, expression_statement; 161, boolean_operator; 162, block; 163, boolean_operator; 164, block; 165, boolean_operator; 166, block; 167, identifier:prev; 168, identifier:ID; 169, identifier:hit; 170, identifier:domtblout; 171, identifier:numHits; 172, identifier:evalueT; 173, identifier:bitT; 174, yield; 175, identifier:line; 176, identifier:startswith; 177, string; 178, attribute; 179, argument_list; 180, attribute; 181, argument_list; 182, identifier:line; 183, slice; 184, identifier:line; 185, identifier:append; 186, identifier:desc; 187, subscript; 188, subscript; 189, subscript; 190, subscript; 191, call; 192, call; 193, identifier:evalue; 194, identifier:bitscore; 195, subscript; 196, subscript; 197, subscript; 198, subscript; 199, identifier:evalue; 200, identifier:bitscore; 201, comparison_operator:len(hits) > 0; 202, block; 203, assignment; 204, identifier:evalueT; 205, False; 206, identifier:bitT; 207, False; 208, call; 209, comparison_operator:evalue <= evalueT; 210, comparison_operator:bitT == False; 211, expression_statement; 212, comparison_operator:evalue <= evalueT; 213, comparison_operator:bit >= bitT; 214, expression_statement; 215, comparison_operator:evalueT == False; 216, comparison_operator:bit >= bitT; 217, expression_statement; 218, identifier:hit; 219, string_content:#; 220, call; 221, identifier:split; 222, string; 223, identifier:join; 224, subscript; 225, integer:0; 226, integer:18; 227, identifier:line; 228, integer:0; 229, identifier:line; 230, integer:9; 231, identifier:line; 232, integer:11; 233, identifier:line; 234, integer:13; 235, identifier:float; 236, argument_list; 237, identifier:float; 238, argument_list; 239, identifier:line; 240, integer:11; 241, identifier:line; 242, integer:13; 243, identifier:line; 244, integer:11; 245, identifier:line; 246, integer:13; 247, call; 248, integer:0; 249, for_statement; 250, identifier:hits; 251, list; 252, attribute; 253, argument_list; 254, identifier:evalue; 255, identifier:evalueT; 256, identifier:bitT; 257, False; 258, call; 259, identifier:evalue; 260, identifier:evalueT; 261, identifier:bit; 262, identifier:bitT; 263, call; 264, identifier:evalueT; 265, False; 266, identifier:bit; 267, identifier:bitT; 268, call; 269, attribute; 270, argument_list; 271, string_content:; 272, identifier:line; 273, slice; 274, subscript; 275, subscript; 276, identifier:len; 277, argument_list; 278, identifier:hit; 279, call; 280, block; 281, identifier:hits; 282, identifier:append; 283, identifier:line; 284, attribute; 285, argument_list; 286, attribute; 287, argument_list; 288, attribute; 289, argument_list; 290, identifier:line; 291, identifier:strip; 292, integer:18; 293, identifier:line; 294, integer:11; 295, identifier:line; 296, integer:13; 297, identifier:hits; 298, identifier:top_hits; 299, argument_list; 300, expression_statement; 301, identifier:hits; 302, identifier:append; 303, identifier:line; 304, identifier:hits; 305, identifier:append; 306, identifier:line; 307, identifier:hits; 308, identifier:append; 309, identifier:line; 310, identifier:hits; 311, identifier:numHits; 312, integer:13; 313, True; 314, yield; 315, identifier:hit
code: def numDomtblout(domtblout, numHits, evalueT, bitT, sort):
      """
      parse hmm domain table output
      this version is faster but does not work unless the table is sorted
      """
      if sort is True:
          for hit in numDomtblout_sort(domtblout, numHits, evalueT, bitT):
              yield hit
          return
      header = ['#target name', 'target accession', 'tlen',
                'query name', 'query accession', 'qlen',
                'full E-value', 'full score', 'full bias',
                'domain #', '# domains',
                'domain c-Evalue', 'domain i-Evalue', 'domain score', 'domain bias',
                'hmm from', 'hmm to', 'seq from', 'seq to', 'env from', 'env to',
                'acc', 'target description']
      yield header
      prev, hits = None, []
      for line in domtblout:
          if line.startswith('#'):
              continue
          # parse line and get description
          line = line.strip().split()
          desc = ' '.join(line[18:])
          line = line[0:18]
          line.append(desc)
          # create ID based on query name and domain number
          ID = line[0] + line[9]
          # domain c-Evalue and domain score thresholds
          line[11], line[13] = float(line[11]), float(line[13])
          evalue, bitscore = line[11], line[13]
          line[11], line[13] = evalue, bitscore
          if ID != prev:
              if len(hits) > 0:
                  for hit in top_hits(hits, numHits, 13, True):
                      yield hit
              hits = []
          if evalueT == False and bitT == False:
              hits.append(line)
          elif evalue <= evalueT and bitT == False:
              hits.append(line)
          elif evalue <= evalueT and bit >= bitT:
              hits.append(line)
          elif evalueT == False and bit >= bitT:
              hits.append(line)
          prev = ID
      for hit in top_hits(hits, numHits, 13, True):
          yield hit