nodes: 0, module; 1, function_definition; 2, function_name:_align_from_fastq; 3, parameters; 4, block; 5, identifier:fastq1; 6, identifier:fastq2; 7, identifier:aligner; 8, identifier:align_ref; 9, identifier:sam_ref; 10, identifier:names; 11, identifier:align_dir; 12, identifier:data; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, comment:# handle align functions that update the main data dictionary in place; 18, if_statement; 19, comment:"""Align from fastq inputs, producing sorted BAM output.
      """; 20, assignment; 21, assignment; 22, assignment; 23, call; 24, block; 25, comment:# handle output of raw SAM files that need to be converted to BAM; 26, else_clause; 27, identifier:config; 28, subscript; 29, identifier:align_fn; 30, attribute; 31, identifier:out; 32, call; 33, identifier:isinstance; 34, argument_list; 35, assert_statement; 36, return_statement; 37, block; 38, identifier:data; 39, string:"config"; 40, subscript; 41, identifier:align_fn; 42, identifier:align_fn; 43, argument_list; 44, identifier:out; 45, identifier:dict; 46, call; 47, tuple; 48, identifier:out; 49, expression_statement; 50, expression_statement; 51, return_statement; 52, identifier:TOOLS; 53, identifier:aligner; 54, identifier:fastq1; 55, identifier:fastq2; 56, identifier:align_ref; 57, identifier:names; 58, identifier:align_dir; 59, identifier:data; 60, attribute; 61, argument_list; 62, call; 63, call; 64, assignment; 65, assignment; 66, identifier:data; 67, identifier:out; 68, identifier:get; 69, string:"work_bam"; 70, attribute; 71, argument_list; 72, attribute; 73, argument_list; 74, identifier:work_bam; 75, call; 76, subscript; 77, call; 78, identifier:dd; 79, identifier:get_sample_name; 80, identifier:data; 81, identifier:out; 82, identifier:get; 83, string:"work_bam"; 84, attribute; 85, argument_list; 86, identifier:data; 87, string:"work_bam"; 88, attribute; 89, argument_list; 90, identifier:bam; 91, identifier:sam_to_bam; 92, identifier:out; 93, identifier:config; 94, identifier:bam; 95, identifier:sort; 96, identifier:work_bam; 97, identifier:config
code: def _align_from_fastq(fastq1, fastq2, aligner, align_ref, sam_ref, names,
                        align_dir, data):
      """Align from fastq inputs, producing sorted BAM output.
      """
      config = data["config"]
      align_fn = TOOLS[aligner].align_fn
      out = align_fn(fastq1, fastq2, align_ref, names, align_dir, data)
      # handle align functions that update the main data dictionary in place
      if isinstance(out, dict):
          assert out.get("work_bam"), (dd.get_sample_name(data), out.get("work_bam"))
          return out
      # handle output of raw SAM files that need to be converted to BAM
      else:
          work_bam = bam.sam_to_bam(out, config)
          data["work_bam"] = bam.sort(work_bam, config)
          return data