nodes: 0, module; 1, function_definition; 2, function_name:tobam_cl; 3, parameters; 4, block; 5, identifier:data; 6, identifier:out_file; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, with_statement; 12, identifier:is_paired; 13, False; 14, comment:"""Prepare command line for producing de-duplicated sorted output.
  
      - If no deduplication, sort and prepare a BAM file.
      - If paired, then use samblaster and prepare discordant outputs.
      - If unpaired, use biobambam's bammarkduplicates
      """; 15, assignment; 16, assignment; 17, with_clause; 18, block; 19, identifier:do_dedup; 20, call; 21, identifier:umi_consensus; 22, call; 23, with_item; 24, if_statement; 25, identifier:_check_dedup; 26, argument_list; 27, attribute; 28, argument_list; 29, as_pattern; 30, not_operator; 31, block; 32, elif_clause; 33, elif_clause; 34, else_clause; 35, identifier:data; 36, identifier:dd; 37, identifier:get_umi_consensus; 38, identifier:data; 39, call; 40, as_pattern_target; 41, identifier:do_dedup; 42, expression_statement; 43, identifier:umi_consensus; 44, block; 45, boolean_operator; 46, block; 47, block; 48, identifier:file_transaction; 49, argument_list; 50, identifier:tx_out_file; 51, yield; 52, expression_statement; 53, boolean_operator; 54, not_operator; 55, expression_statement; 56, expression_statement; 57, with_statement; 58, expression_statement; 59, identifier:data; 60, identifier:out_file; 61, tuple; 62, yield; 63, identifier:is_paired; 64, call; 65, call; 66, assignment; 67, assignment; 68, with_clause; 69, block; 70, yield; 71, call; 72, identifier:tx_out_file; 73, tuple; 74, identifier:_need_sr_disc_reads; 75, argument_list; 76, identifier:_too_many_contigs; 77, argument_list; 78, identifier:sr_file; 79, binary_operator:"%s-sr.bam" % os.path.splitext(out_file)[0]; 80, identifier:disc_file; 81, binary_operator:"%s-disc.bam" % os.path.splitext(out_file)[0]; 82, with_item; 83, with_statement; 84, tuple; 85, identifier:sam_to_sortbam_cl; 86, argument_list; 87, call; 88, identifier:tx_out_file; 89, identifier:data; 90, call; 91, string:"%s-sr.bam"; 92, subscript; 93, string:"%s-disc.bam"; 94, subscript; 95, as_pattern; 96, with_clause; 97, block; 98, call; 99, identifier:tx_out_file; 100, identifier:data; 101, identifier:tx_out_file; 102, identifier:_sam_to_grouped_umi_cl; 103, argument_list; 104, attribute; 105, argument_list; 106, call; 107, integer:0; 108, call; 109, integer:0; 110, call; 111, as_pattern_target; 112, with_item; 113, expression_statement; 114, identifier:_biobambam_dedup_sort; 115, argument_list; 116, identifier:data; 117, identifier:umi_consensus; 118, identifier:tx_out_file; 119, identifier:dd; 120, identifier:get_ref_file; 121, identifier:data; 122, attribute; 123, argument_list; 124, attribute; 125, argument_list; 126, identifier:file_transaction; 127, argument_list; 128, identifier:tx_sr_file; 129, as_pattern; 130, yield; 131, identifier:data; 132, identifier:tx_out_file; 133, attribute; 134, identifier:splitext; 135, identifier:out_file; 136, attribute; 137, identifier:splitext; 138, identifier:out_file; 139, identifier:data; 140, identifier:sr_file; 141, call; 142, as_pattern_target; 143, tuple; 144, identifier:os; 145, identifier:path; 146, identifier:os; 147, identifier:path; 148, identifier:file_transaction; 149, argument_list; 150, identifier:tx_disc_file; 151, call; 152, identifier:tx_out_file; 153, identifier:data; 154, identifier:disc_file; 155, identifier:samblaster_dedup_sort; 156, argument_list; 157, identifier:data; 158, identifier:tx_out_file; 159, identifier:tx_sr_file; 160, identifier:tx_disc_file
code: def tobam_cl(data, out_file, is_paired=False):
      """Prepare command line for producing de-duplicated sorted output.
  
      - If no deduplication, sort and prepare a BAM file.
      - If paired, then use samblaster and prepare discordant outputs.
      - If unpaired, use biobambam's bammarkduplicates
      """
      do_dedup = _check_dedup(data)
      umi_consensus = dd.get_umi_consensus(data)
      with file_transaction(data, out_file) as tx_out_file:
          if not do_dedup:
              yield (sam_to_sortbam_cl(data, tx_out_file), tx_out_file)
          elif umi_consensus:
              yield (_sam_to_grouped_umi_cl(data, umi_consensus, tx_out_file), tx_out_file)
          elif is_paired and _need_sr_disc_reads(data) and not _too_many_contigs(dd.get_ref_file(data)):
              sr_file = "%s-sr.bam" % os.path.splitext(out_file)[0]
              disc_file = "%s-disc.bam" % os.path.splitext(out_file)[0]
              with file_transaction(data, sr_file) as tx_sr_file:
                  with file_transaction(data, disc_file) as tx_disc_file:
                      yield (samblaster_dedup_sort(data, tx_out_file, tx_sr_file, tx_disc_file),
                             tx_out_file)
          else:
              yield (_biobambam_dedup_sort(data, tx_out_file), tx_out_file)