 
 (defn writer
   [f refs]
-  (->BAIWriter (DataOutputStream. (FileOutputStream. (file f)))
+  (->BAIWriter (DataOutputStream. (FileOutputStream. (io/file f)))
                refs
-               f))
+               (.getAbsolutePath (io/file f))))
 
 (defn write-index
   [^BAIWriter wtr alns]
   (try
     (write-index*! (.writer wtr) (.refs wtr) alns)
     (catch Exception e (do
-                         (let [f (file (.f wtr))]
+                         (let [f (io/file (.f wtr))]
                            (when (.exists f)
                              (.delete f)))
                          (logging/error "Failed to create BAM index")

        ;; bins
        (if (zero? (count (:bins index)))
          (lsb/write-int wtr 0)
          (let [bins (filter #(not (nil? %)) (:bins index))]
            ;; # of bins
            (lsb/write-int wtr (inc (count bins)))
            (doseq [bin bins]
              (write-bin wtr bin))
            ;; meta data
            (write-meta-data wtr (:meta index))))
        ;; linear index

(ns cljam.bam-index.writer
  (:require [clojure.java.io :as io]
            [clojure.tools.logging :as logging]
            [cljam.lsb :as lsb]
            [cljam.cigar :as cgr]
            [cljam.util :refer [gen-vec]]
