nodes: 0, module; 1, function_definition; 2, function_name:get_sort_cmd; 3, parameters; 4, block; 5, default_parameter; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, if_statement; 10, return_statement; 11, identifier:tmp_dir; 12, None; 13, comment:"""Retrieve GNU coreutils sort command, using version-sort if available.
  
      Recent versions of sort have alpha-numeric sorting, which provides
      more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
      This also fixes versions of sort, like 8.22 in CentOS 7.1, that have broken
      sorting without version sorting specified.
  
      https://github.com/bcbio/bcbio-nextgen/issues/624
      https://github.com/bcbio/bcbio-nextgen/issues/1017
      """; 14, assignment; 15, identifier:has_versionsort; 16, block; 17, else_clause; 18, boolean_operator; 19, block; 20, identifier:cmd; 21, identifier:has_versionsort; 22, call; 23, expression_statement; 24, block; 25, boolean_operator; 26, call; 27, expression_statement; 28, attribute; 29, argument_list; 30, assignment; 31, expression_statement; 32, identifier:tmp_dir; 33, call; 34, attribute; 35, argument_list; 36, augmented_assignment; 37, call; 38, identifier:strip; 39, identifier:cmd; 40, string:"sort -V"; 41, assignment; 42, attribute; 43, argument_list; 44, attribute; 45, identifier:isdir; 46, identifier:tmp_dir; 47, identifier:cmd; 48, binary_operator:" -T %s" % tmp_dir; 49, attribute; 50, argument_list; 51, identifier:cmd; 52, string:"sort"; 53, attribute; 54, identifier:exists; 55, identifier:tmp_dir; 56, identifier:os; 57, identifier:path; 58, string:" -T %s"; 59, identifier:tmp_dir; 60, identifier:subprocess; 61, identifier:check_output; 62, string:"sort --help | grep version-sort; exit 0"; 63, keyword_argument; 64, identifier:os; 65, identifier:path; 66, identifier:shell; 67, True
code: def get_sort_cmd(tmp_dir=None):
      """Retrieve GNU coreutils sort command, using version-sort if available.
  
      Recent versions of sort have alpha-numeric sorting, which provides
      more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
      This also fixes versions of sort, like 8.22 in CentOS 7.1, that have broken
      sorting without version sorting specified.
  
      https://github.com/bcbio/bcbio-nextgen/issues/624
      https://github.com/bcbio/bcbio-nextgen/issues/1017
      """
      has_versionsort = subprocess.check_output("sort --help | grep version-sort; exit 0", shell=True).strip()
      if has_versionsort:
          cmd = "sort -V"
      else:
          cmd = "sort"
      if tmp_dir and os.path.exists(tmp_dir) and os.path.isdir(tmp_dir):
          cmd += " -T %s" % tmp_dir
      return cmd