nodes: 0, module; 1, function_definition; 2, function_name:_transform_chrom; 3, parameters; 4, block; 5, identifier:chrom; 6, expression_statement; 7, try_statement; 8, comment:"""Helper function to obtain specific sort order."""; 9, block; 10, except_clause; 11, else_clause; 12, expression_statement; 13, block; 14, comment:# make sure numbered chromosomes are sorted numerically; 15, block; 16, assignment; 17, if_statement; 18, return_statement; 19, identifier:c; 20, call; 21, comparison_operator:chrom in ['X', 'Y']; 22, block; 23, elif_clause; 24, else_clause; 25, binary_operator:'%02d' % c; 26, identifier:int; 27, argument_list; 28, identifier:chrom; 29, list; 30, return_statement; 31, comparison_operator:chrom == 'MT'; 32, block; 33, block; 34, string; 35, identifier:c; 36, identifier:chrom; 37, string; 38, string; 39, identifier:chrom; 40, identifier:chrom; 41, string; 42, return_statement; 43, comment:# sort to the end; 44, return_statement; 45, comment:# sort to the very end; 46, string_content:%02d; 47, string_content:X; 48, string_content:Y; 49, string_content:MT; 50, string; 51, binary_operator:'__' + chrom; 52, string_content:_MT; 53, string; 54, identifier:chrom; 55, string_content:__
code: def _transform_chrom(chrom):
      """Helper function to obtain specific sort order."""
      try:
          c = int(chrom)
      except:
          if chrom in ['X', 'Y']:
              return chrom
          elif chrom == 'MT':
              return '_MT'  # sort to the end
          else:
              return '__' + chrom # sort to the very end
      else:
          # make sure numbered chromosomes are sorted numerically
          return '%02d' % c