           size
           (+ s (* (- size s) slope)))))))
 
-(defn gen-distinct-names [n]
+(defn gen-distinct-names
+  "Generate a list of names which are non-empty after trimming, and
+  are distinct after trimming."
+  [n]
   (gen/such-that
-    #(= (count %) (count (set %)))
+    #(= (count %) (count (set (map s/trim %))))
     (gen-vector-of-size
-      (gen/such-that not-empty gen/string-ascii)
+      (gen/such-that #(not-empty (s/trim %)) gen/string-ascii)
       n)))
 
 (defn scale-gen


(def ^:dynamic *test-runs* 100)

(defspec genomic-matrix-memory
  *test-runs*
  (prop/for-all
    [tsv gen-tsv
     id (gen/such-that not-empty gen/string-ascii)]
    (db-disk-fixture
      db
      (let [fields (fields-from-tsv tsv)
            {:keys [probes samples matrix]} tsv]
        (cdb/write-matrix
          db
          id
          [{:name id
            :time (org.joda.time.DateTime. 2014 1 1 0 0 0 0)
            :hash "1234"}]
          {}
          (fn [] fields)
          nil
          false)

        (let [exp (cdb/run-query db {:select [:name :status :rows] :from [:dataset]})
              q-samples (cdb/run-query db
                                       {:select [[:value :name]]
                                        :from [:field]
                                        :where [:= :name "sampleID"]
                                        :left-join [:code [:= :field.id :field_id]]
                                        :order-by [:ordering]})
              q-probes (cdb/run-query db {:select [:*] :from [:field]})
              q-data (cdb/fetch db [{:table id
                                     :columns probes
                                     :samples samples}])]
          (and (= exp [{:name id :status "loaded" :rows (count samples)}])
               (= (map :name q-samples) samples)
               (= (map :name q-probes) (cons "sampleID" probes))
               (nearly-equal-matrix
                 0.0001
                 matrix
                 (vec (map #(into [] %) (map ((first q-data) :data) probes))))))))))

(defn matrix1 [db]
  (ct/testing "tsv matrix from memory"

                 {:name "probe5" :id 12 :dataset_id 1} ]))
      (let [[probe1 probe2]
            (vec (map #(into [] %) (map ((first data) :data) ["probe1" "probe2"])))]
        (ct/is (nearly-equal probe1 [2.1 1.1]))
        (ct/is (nearly-equal probe2 [2.2 1.2]))))))

(defn detect-cgdata-genomic [db]
  (ct/testing "detect cgdata genomic"
