code: def _keep_assembled_chrom(bam_file, genome, config):
      
      fai = "%s.fai" % genome
      chrom = []
      with open(fai) as inh:
          for line in inh:
              c = line.split("\t")[0]
              if c.find("_") < 0:
                  chrom.append(c)
      chroms = " ".join(chrom)
      out_file = utils.append_stem(bam_file, '_chrom')
      samtools = config_utils.get_program("samtools", config)
      if not utils.file_exists(out_file):
          with file_transaction(out_file) as tx_out:
              cmd = "{samtools} view -b {bam_file} {chroms} > {tx_out}"
              do.run(cmd.format(**locals()), "Remove contigs from %s" % bam_file)
          bam.index(out_file, config)
      return out_file
docs: Remove contigs from the BAM file