        (make-index* refs)
        (finish-index refs)))
 
- ; TODO: Parallelize
 (defn make-index1
   [refs alns]
   (->> (partition-all 1000 alns)

  [bin-map1 bin-map2]
  (merge-with merge-chunks bin-map1 bin-map2))

;;; slow ...
(defn- merge-lidx
  [lidx1 lidx2]
  {:index (vec (map (fn [l1 l2]
                      (cond
                        (zero? l1) l2
                        (zero? l2) l1
                        :else (min l1 l2)))
                    (:index lidx1) (:index lidx2))) ; OPTIMIZE
   :largest-seen (max (:largest-seen lidx1) (:largest-seen lidx2))})


(defn merge-index
  [idx1 idx2]

       (map (partial zipmap [:bin :chunks]))))

(defn- init-linear-index []
  {})

(defn- update-linear-index
  [linear-index aln]
  (let [{:keys [beg]} (:chunk (:meta aln))
        aln-beg (:pos aln)
        aln-end (dec (+ aln-beg (cgr/count-ref (:cigar aln))))
        win-beg (if (zero? aln-end)
