   (:require [clojure.data.json :as json])
   (:use [cavm.binner :only (calc-bin)])
   (:use [clj-time.format :only (formatter unparse)])
-  (:use [cavm.hashable :only (ahashable get-array)])
+  (:use [cavm.hashable :only (ahashable)])
   (:use [korma.core :rename {insert kcinsert}])
   (:require [cavm.query.sources :as sources])
+  (:require [me.raynes.fs :as fs])
   (:gen-class))
 
-;(def db {:classname "org.h2.Driver"
-;         :subprotocol "h2"
-;         :subname "file:///data/TCGA/craft/h2/cavm.h2"})
 
 ; Coerce this sql fn name to a keyword so we can reference it.
 (def KEY-ID (keyword "SCOPE_IDENTITY()"))


  ([files metadata matrix-fn features force]
   (kdb/transaction
     (let [matrix (matrix-fn)
           exp (merge-m-ent experiments-meta metadata)
           files (map fmt-time files)]
       (when (or force
                 (not (= (set files) (set (related-sources experiments exp)))))
         (clear-by-exp exp)
         (load-related-sources
           experiment_sources :experiments_id exp files)
         (load-exp-samples exp (:samples (meta matrix)))
         (load-exp-matrix exp matrix))))))

; XXX factor out common parts with merge, above?
(defn del-exp [file]

(defn create-db [file]
  (kdb/create-db  {:classname "org.h2.Driver"
                   :subprotocol "h2"
                   :subname file
                   :make-pool true}))

(defmacro with-db [db & body]
  `(kdb/with-db ~db ~@body))
