code: def aligner_from_header(in_bam):
      
      from bcbio.pipeline.alignment import TOOLS
      with pysam.Samfile(in_bam, "rb") as bamfile:
          for pg in bamfile.header.get("PG", []):
              for ka in TOOLS.keys():
                  if pg.get("PN", "").lower().find(ka) >= 0:
                      return ka
docs: Identify aligner from the BAM header; handling pre-aligned inputs.