Indexer of BAM.

(ns cljam.algo.bam-indexer
  (:require [cljam.common :refer [*n-threads*]]
            [cljam.io.sam :as sam]
            [cljam.io.bam-index.core :as bai-core]))

Creates a BAM index file from the BAM file.

(defn create-index
  [in-bam out-bai & {:keys [n-threads] :or {n-threads 0}}]
  (with-open [r (sam/bam-reader in-bam)]
    (binding [*n-threads* n-threads]
      (bai-core/create-index out-bai (sam/read-blocks r) (sam/read-refs r)))))