nodes: 0, module; 1, function_definition; 2, function_name:_combine_files; 3, parameters; 4, block; 5, identifier:tsv_files; 6, identifier:work_dir; 7, identifier:data; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, comment:"""Combine multiple priority tsv files into a final sorted output.
      """; 15, assignment; 16, assignment; 17, assignment; 18, not_operator; 19, block; 20, identifier:out_file; 21, identifier:header; 22, call; 23, identifier:sample; 24, call; 25, identifier:out_file; 26, call; 27, call; 28, with_statement; 29, attribute; 30, argument_list; 31, attribute; 32, argument_list; 33, attribute; 34, argument_list; 35, attribute; 36, argument_list; 37, with_clause; 38, block; 39, string:"\t"; 40, identifier:join; 41, list; 42, identifier:dd; 43, identifier:get_sample_name; 44, identifier:data; 45, attribute; 46, identifier:join; 47, identifier:work_dir; 48, binary_operator:"%s-prioritize.tsv" % (sample); 49, identifier:utils; 50, identifier:file_exists; 51, identifier:out_file; 52, with_item; 53, expression_statement; 54, expression_statement; 55, expression_statement; 56, expression_statement; 57, expression_statement; 58, string:"caller"; 59, string:"sample"; 60, string:"chrom"; 61, string:"start"; 62, string:"end"; 63, string:"svtype"; 64, string:"lof"; 65, string:"annotation"; 66, string:"split_read_support"; 67, string:"paired_support_PE"; 68, string:"paired_support_PR"; 69, identifier:os; 70, identifier:path; 71, string:"%s-prioritize.tsv"; 72, parenthesized_expression; 73, as_pattern; 74, assignment; 75, assignment; 76, assignment; 77, assignment; 78, call; 79, identifier:sample; 80, call; 81, as_pattern_target; 82, identifier:tmpdir; 83, call; 84, identifier:input_files; 85, call; 86, identifier:sort_cmd; 87, call; 88, identifier:cmd; 89, string:"{{ echo '{header}'; cat {input_files} | {sort_cmd} -k3,3 -k4,4n; }} > {tx_out_file}"; 90, attribute; 91, argument_list; 92, identifier:file_transaction; 93, argument_list; 94, identifier:tx_out_file; 95, attribute; 96, argument_list; 97, attribute; 98, argument_list; 99, attribute; 100, argument_list; 101, identifier:do; 102, identifier:run; 103, call; 104, string:"Combine prioritized from multiple callers"; 105, identifier:data; 106, identifier:out_file; 107, attribute; 108, identifier:dirname; 109, identifier:tx_out_file; 110, string:" "; 111, identifier:join; 112, identifier:tsv_files; 113, identifier:bedutils; 114, identifier:get_sort_cmd; 115, identifier:tmpdir; 116, attribute; 117, argument_list; 118, identifier:os; 119, identifier:path; 120, identifier:cmd; 121, identifier:format; 122, dictionary_splat; 123, call; 124, identifier:locals; 125, argument_list
code: def _combine_files(tsv_files, work_dir, data):
      """Combine multiple priority tsv files into a final sorted output.
      """
      header = "\t".join(["caller", "sample", "chrom", "start", "end", "svtype",
                          "lof", "annotation", "split_read_support", "paired_support_PE", "paired_support_PR"])
      sample = dd.get_sample_name(data)
      out_file = os.path.join(work_dir, "%s-prioritize.tsv" % (sample))
      if not utils.file_exists(out_file):
          with file_transaction(data, out_file) as tx_out_file:
              tmpdir = os.path.dirname(tx_out_file)
              input_files = " ".join(tsv_files)
              sort_cmd = bedutils.get_sort_cmd(tmpdir)
              cmd = "{{ echo '{header}'; cat {input_files} | {sort_cmd} -k3,3 -k4,4n; }} > {tx_out_file}"
              do.run(cmd.format(**locals()), "Combine prioritized from multiple callers")
      return out_file