code: def select_unaligned_read_pairs(in_bam, extra, out_dir, config):
      
      runner = broad.runner_from_config(config)
      base, ext = os.path.splitext(os.path.basename(in_bam))
      nomap_bam = os.path.join(out_dir, "{}-{}{}".format(base, extra, ext))
      if not utils.file_exists(nomap_bam):
          with file_transaction(nomap_bam) as tx_out:
              runner.run("FilterSamReads", [("INPUT", in_bam),
                                            ("OUTPUT", tx_out),
                                            ("EXCLUDE_ALIGNED", "true"),
                                            ("WRITE_READS_FILES", "false"),
                                            ("SORT_ORDER", "queryname")])
      has_reads = False
      with pysam.Samfile(nomap_bam, "rb") as in_pysam:
          for read in in_pysam:
              if read.is_paired:
                  has_reads = True
                  break
      if has_reads:
          out_fq1, out_fq2 = ["{}-{}.fq".format(os.path.splitext(nomap_bam)[0], i) for i in [1, 2]]
          runner.run_fn("picard_bam_to_fastq", nomap_bam, out_fq1, out_fq2)
          return out_fq1, out_fq2
      else:
          return None, None
docs: Retrieve unaligned read pairs from input alignment BAM, as two fastq files.