nodes: 0, module; 1, function_definition; 2, function_name:samblaster_dedup_sort; 3, parameters; 4, block; 5, identifier:data; 6, identifier:tx_out_file; 7, identifier:tx_sr_file; 8, identifier:tx_disc_file; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, comment:# full BAM -- associate more memory and cores; 15, expression_statement; 16, comment:# Potentially downsample to maximum coverage here if not splitting and whole genome sample; 17, expression_statement; 18, expression_statement; 19, if_statement; 20, comment:# split and discordant BAMs -- give less memory/cores since smaller files; 21, expression_statement; 22, expression_statement; 23, expression_statement; 24, expression_statement; 25, comment:# samblaster 0.1.22 and better require the -M flag for compatibility with bwa-mem; 26, expression_statement; 27, return_statement; 28, comment:"""Deduplicate and sort with samblaster, produces split read and discordant pair files.
      """; 29, assignment; 30, assignment; 31, assignment; 32, assignment; 33, assignment; 34, assignment; 35, assignment; 36, identifier:ds_cmd; 37, block; 38, else_clause; 39, assignment; 40, assignment; 41, assignment; 42, assignment; 43, assignment; 44, call; 45, identifier:samblaster; 46, call; 47, identifier:samtools; 48, call; 49, identifier:tmp_prefix; 50, binary_operator:"%s-sorttmp" % utils.splitext_plus(tx_out_file)[0]; 51, identifier:tobam_cmd; 52, parenthesized_expression; 53, pattern_list; 54, call; 55, identifier:ds_cmd; 56, conditional_expression:None if data.get("align_split") else bam.get_maxcov_downsample_cl(data, "samtools"); 57, identifier:sort_opt; 58, conditional_expression:"-n" if data.get("align_split") and dd.get_mark_duplicates(data) else ""; 59, expression_statement; 60, block; 61, identifier:sort_opt; 62, string:""; 63, pattern_list; 64, call; 65, identifier:splitter_cmd; 66, call; 67, identifier:discordant_cmd; 68, call; 69, identifier:cmd; 70, parenthesized_expression; 71, attribute; 72, argument_list; 73, attribute; 74, argument_list; 75, attribute; 76, argument_list; 77, string:"%s-sorttmp"; 78, subscript; 79, string:"{samtools} sort {sort_opt} -@ {cores} -m {mem} -T {tmp_prefix}-{dext} {out_file} -"; 80, identifier:cores; 81, identifier:mem; 82, identifier:_get_cores_memory; 83, argument_list; 84, None; 85, call; 86, call; 87, string:"-n"; 88, boolean_operator; 89, string:""; 90, assignment; 91, expression_statement; 92, identifier:cores; 93, identifier:mem; 94, identifier:_get_cores_memory; 95, argument_list; 96, attribute; 97, argument_list; 98, attribute; 99, argument_list; 100, concatenated_string; 101, identifier:cmd; 102, identifier:format; 103, dictionary_splat; 104, identifier:config_utils; 105, identifier:get_program; 106, string:"samblaster"; 107, subscript; 108, identifier:config_utils; 109, identifier:get_program; 110, string:"samtools"; 111, subscript; 112, call; 113, integer:0; 114, identifier:data; 115, keyword_argument; 116, attribute; 117, argument_list; 118, attribute; 119, argument_list; 120, call; 121, call; 122, identifier:dedup_cmd; 123, binary_operator:"%s %s > %s" % (tobam_cmd.format(out_file="", dext="full", **locals()), ds_cmd, tx_out_file); 124, assignment; 125, identifier:data; 126, keyword_argument; 127, identifier:tobam_cmd; 128, identifier:format; 129, keyword_argument; 130, keyword_argument; 131, dictionary_splat; 132, identifier:tobam_cmd; 133, identifier:format; 134, keyword_argument; 135, keyword_argument; 136, dictionary_splat; 137, string:"{samblaster} --addMateTags -M --splitterFile >({splitter_cmd}) --discordantFile >({discordant_cmd}) "; 138, string:"| {dedup_cmd}"; 139, call; 140, identifier:data; 141, string:"config"; 142, identifier:data; 143, string:"config"; 144, attribute; 145, argument_list; 146, identifier:downscale; 147, integer:2; 148, identifier:data; 149, identifier:get; 150, string:"align_split"; 151, identifier:bam; 152, identifier:get_maxcov_downsample_cl; 153, identifier:data; 154, string:"samtools"; 155, attribute; 156, argument_list; 157, attribute; 158, argument_list; 159, string:"%s %s > %s"; 160, tuple; 161, identifier:dedup_cmd; 162, call; 163, identifier:downscale; 164, integer:4; 165, identifier:out_file; 166, binary_operator:"-o %s" % tx_sr_file; 167, identifier:dext; 168, string:"spl"; 169, call; 170, identifier:out_file; 171, binary_operator:"-o %s" % tx_disc_file; 172, identifier:dext; 173, string:"disc"; 174, call; 175, identifier:locals; 176, argument_list; 177, identifier:utils; 178, identifier:splitext_plus; 179, identifier:tx_out_file; 180, identifier:data; 181, identifier:get; 182, string:"align_split"; 183, identifier:dd; 184, identifier:get_mark_duplicates; 185, identifier:data; 186, call; 187, identifier:ds_cmd; 188, identifier:tx_out_file; 189, attribute; 190, argument_list; 191, string:"-o %s"; 192, identifier:tx_sr_file; 193, identifier:locals; 194, argument_list; 195, string:"-o %s"; 196, identifier:tx_disc_file; 197, identifier:locals; 198, argument_list; 199, attribute; 200, argument_list; 201, identifier:tobam_cmd; 202, identifier:format; 203, keyword_argument; 204, keyword_argument; 205, dictionary_splat; 206, identifier:tobam_cmd; 207, identifier:format; 208, keyword_argument; 209, keyword_argument; 210, dictionary_splat; 211, identifier:out_file; 212, binary_operator:"-o %s" % tx_out_file; 213, identifier:dext; 214, string:"full"; 215, call; 216, identifier:out_file; 217, string:""; 218, identifier:dext; 219, string:"full"; 220, call; 221, string:"-o %s"; 222, identifier:tx_out_file; 223, identifier:locals; 224, argument_list; 225, identifier:locals; 226, argument_list
code: def samblaster_dedup_sort(data, tx_out_file, tx_sr_file, tx_disc_file):
      """Deduplicate and sort with samblaster, produces split read and discordant pair files.
      """
      samblaster = config_utils.get_program("samblaster", data["config"])
      samtools = config_utils.get_program("samtools", data["config"])
      tmp_prefix = "%s-sorttmp" % utils.splitext_plus(tx_out_file)[0]
      tobam_cmd = ("{samtools} sort {sort_opt} -@ {cores} -m {mem} -T {tmp_prefix}-{dext} {out_file} -")
      # full BAM -- associate more memory and cores
      cores, mem = _get_cores_memory(data, downscale=2)
      # Potentially downsample to maximum coverage here if not splitting and whole genome sample
      ds_cmd = None if data.get("align_split") else bam.get_maxcov_downsample_cl(data, "samtools")
      sort_opt = "-n" if data.get("align_split") and dd.get_mark_duplicates(data) else ""
      if ds_cmd:
          dedup_cmd = "%s %s > %s" % (tobam_cmd.format(out_file="", dext="full", **locals()), ds_cmd, tx_out_file)
      else:
          dedup_cmd = tobam_cmd.format(out_file="-o %s" % tx_out_file, dext="full", **locals())
      # split and discordant BAMs -- give less memory/cores since smaller files
      sort_opt = ""
      cores, mem = _get_cores_memory(data, downscale=4)
      splitter_cmd = tobam_cmd.format(out_file="-o %s" % tx_sr_file, dext="spl", **locals())
      discordant_cmd = tobam_cmd.format(out_file="-o %s" % tx_disc_file, dext="disc", **locals())
      # samblaster 0.1.22 and better require the -M flag for compatibility with bwa-mem
      cmd = ("{samblaster} --addMateTags -M --splitterFile >({splitter_cmd}) --discordantFile >({discordant_cmd}) "
             "| {dedup_cmd}")
      return cmd.format(**locals())