nodes: 0, module; 1, function_definition; 2, function_name:_biobambam_dedup_sort; 3, parameters; 4, block; 5, identifier:data; 6, identifier:tx_out_file; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, comment:"""Perform streaming deduplication and sorting with biobambam's bamsormadup
      """; 14, assignment; 15, assignment; 16, assignment; 17, call; 18, block; 19, else_clause; 20, call; 21, identifier:samtools; 22, call; 23, pattern_list; 24, call; 25, identifier:tmp_file; 26, binary_operator:"%s-sorttmp" % utils.splitext_plus(tx_out_file)[0]; 27, attribute; 28, argument_list; 29, expression_statement; 30, expression_statement; 31, comment:# scale core usage to avoid memory issues with larger WGS samples; 32, block; 33, attribute; 34, argument_list; 35, attribute; 36, argument_list; 37, identifier:cores; 38, identifier:mem; 39, identifier:_get_cores_memory; 40, argument_list; 41, string:"%s-sorttmp"; 42, subscript; 43, identifier:data; 44, identifier:get; 45, string:"align_split"; 46, assignment; 47, assignment; 48, expression_statement; 49, expression_statement; 50, expression_statement; 51, expression_statement; 52, identifier:cmd; 53, identifier:format; 54, dictionary_splat; 55, identifier:config_utils; 56, identifier:get_program; 57, string:"samtools"; 58, subscript; 59, identifier:data; 60, keyword_argument; 61, call; 62, integer:0; 63, identifier:sort_opt; 64, conditional_expression:"-n" if data.get("align_split") and _check_dedup(data) else ""; 65, identifier:cmd; 66, binary_operator:"{samtools} sort %s -@ {cores} -m {mem} -O bam -T {tmp_file}-namesort -o {tx_out_file} -" % sort_opt; 67, assignment; 68, assignment; 69, assignment; 70, assignment; 71, call; 72, identifier:data; 73, string:"config"; 74, identifier:downscale; 75, integer:2; 76, attribute; 77, argument_list; 78, string:"-n"; 79, boolean_operator; 80, string:""; 81, string:"{samtools} sort %s -@ {cores} -m {mem} -O bam -T {tmp_file}-namesort -o {tx_out_file} -"; 82, identifier:sort_opt; 83, identifier:cores; 84, call; 85, identifier:ds_cmd; 86, call; 87, identifier:bamsormadup; 88, call; 89, identifier:cmd; 90, parenthesized_expression; 91, identifier:locals; 92, argument_list; 93, identifier:utils; 94, identifier:splitext_plus; 95, identifier:tx_out_file; 96, call; 97, call; 98, identifier:max; 99, argument_list; 100, attribute; 101, argument_list; 102, attribute; 103, argument_list; 104, binary_operator:"{bamsormadup} inputformat=sam threads={cores} tmpfile={tmp_file}-markdup "
                 "SO=coordinate %s > {tx_out_file}" % ds_cmd; 105, attribute; 106, argument_list; 107, identifier:_check_dedup; 108, argument_list; 109, integer:1; 110, call; 111, identifier:bam; 112, identifier:get_maxcov_downsample_cl; 113, identifier:data; 114, string:"bamsormadup"; 115, identifier:config_utils; 116, identifier:get_program; 117, string:"bamsormadup"; 118, identifier:data; 119, concatenated_string; 120, identifier:ds_cmd; 121, identifier:data; 122, identifier:get; 123, string:"align_split"; 124, identifier:data; 125, identifier:int; 126, argument_list; 127, string:"{bamsormadup} inputformat=sam threads={cores} tmpfile={tmp_file}-markdup "; 128, string:"SO=coordinate %s > {tx_out_file}"; 129, call; 130, attribute; 131, argument_list; 132, identifier:math; 133, identifier:ceil; 134, binary_operator:cores * 0.75; 135, identifier:cores; 136, float:0.75
code: def _biobambam_dedup_sort(data, tx_out_file):
      """Perform streaming deduplication and sorting with biobambam's bamsormadup
      """
      samtools = config_utils.get_program("samtools", data["config"])
      cores, mem = _get_cores_memory(data, downscale=2)
      tmp_file = "%s-sorttmp" % utils.splitext_plus(tx_out_file)[0]
      if data.get("align_split"):
          sort_opt = "-n" if data.get("align_split") and _check_dedup(data) else ""
          cmd = "{samtools} sort %s -@ {cores} -m {mem} -O bam -T {tmp_file}-namesort -o {tx_out_file} -" % sort_opt
      else:
          # scale core usage to avoid memory issues with larger WGS samples
          cores = max(1, int(math.ceil(cores * 0.75)))
          ds_cmd = bam.get_maxcov_downsample_cl(data, "bamsormadup")
          bamsormadup = config_utils.get_program("bamsormadup", data)
          cmd = ("{bamsormadup} inputformat=sam threads={cores} tmpfile={tmp_file}-markdup "
                 "SO=coordinate %s > {tx_out_file}" % ds_cmd)
      return cmd.format(**locals())