Permalink
Browse files

add more extensive test

  • Loading branch information...
clayton committed Oct 7, 2017
1 parent ee652be commit e720d1f6f1d4289ecf3932339456a9f4021aa020
@@ -1,4 +1,4 @@
(defproject de.mpg.shh/util-datomic-peer "0.0.3"
(defproject de.mpg.shh/util-datomic-peer "0.0.4"
:description "Utilities for using datomic databases"
:url "http://www.shh.mpg.de/"
:license {:name "Eclipse Public License"
@@ -26,26 +26,16 @@
:domain.data.sequencing.illumina.run.read/cycles :db.type/long
:domain.data.sequencing.run.read/indexed? :db.type/boolean})

(def domain-data-datascript-schema {:domain.data.sequencing.illumina.run/read+ {:db/cardinality :db.cardinality/many
(def domain-data-datascript-schema {:domain.data.sequencing.illumina.run/run-id {:db/unique :db.unique/identity}
:domain.data.sequencing.illumina.run/read+ {:db/cardinality :db.cardinality/many
:db/isComponent true
:db/valueType :db.type/ref}
:domain.data.sequencing.illumina.run/lane+ {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}
:domain.data.sequencing.run/lane+ {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}
:domain.data.sequencing.run.lane/library+ {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
:domain.data/uuid {:db/unique :db.unique/identity}
:domain.data.sequencing.run/run-id {:db/unique :db.unique/identity}
:domain.data.sequencing.illumina.run.lane/library+ {:db/isComponent true
:db/cardinality :db.cardinality/many
:db/valueType :db.type/ref}
:domain.data.sequencing.illumina.run/run-id {:db/unique :db.unique/identity}
:domain.data.sequencing.run/read+ {:db/isComponent true
:db/cardinality :db.cardinality/many
:db/valueType :db.type/ref}})
:db/valueType :db.type/ref}})

(def tx-data [[:db/add (dt/tempid :db.part/data -1) :domain.data.sequencing.illumina.run/lane+ (dt/tempid :db.part/data -2)]
[:db/add (dt/tempid :db.part/data -1) :domain.data.sequencing.illumina.run/run-id "170911_NS500559_0049_AHKJ2TBGX3"]
@@ -0,0 +1,73 @@
(ns data.transaction-data-extended
(:require [datomic.api :as dt]))

(def run-lane-library-data [{:domain.data.sequencing.illumina.run/run-id "170911_NS500559_0049_AHKJ2TBGX3"
:domain.data.sequencing.illumina.run.lane/lane-id "L001"
:domain.data.sequencing.illumina.run.lane.library/library-id "JAE006.A0101"
:domain.data.sequencing.illumina.run.lane.library/read-count "250"
:file-name "JAE006.A0101_S0_L001_R1_001.fastq.gz"
:sha1sum "e92e815426b0bcb00ce3968512973e74b35c0650"
:path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L001_R1_001.fastq.gz"}
{:domain.data.sequencing.illumina.run/run-id "170911_NS500559_0049_AHKJ2TBGX3"
:domain.data.sequencing.illumina.run.lane/lane-id "L001"
:domain.data.sequencing.illumina.run.lane.library/library-id "JAE006.A0101"
:domain.data.sequencing.illumina.run.lane.library/read-count "250"
:file-name "JAE006.A0101_S0_L001_R2_001.fastq.gz"
:sha1sum "1fa8fb21a8162aa4731f3f300eb0de7a065962ac"
:path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L001_R2_001.fastq.gz"}
{:domain.data.sequencing.illumina.run/run-id "170911_NS500559_0049_AHKJ2TBGX3"
:domain.data.sequencing.illumina.run.lane/lane-id "L002"
:domain.data.sequencing.illumina.run.lane.library/library-id "JAE006.A0101"
:domain.data.sequencing.illumina.run.lane.library/read-count "250"
:file-name "JAE006.A0101_S0_L002_R1_001.fastq.gz"
:sha1sum "e92e815426b0bcb00ce3968512973e74b35c0650"
:path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L002_R1_001.fastq.gz"}
{:domain.data.sequencing.illumina.run/run-id "170911_NS500559_0049_AHKJ2TBGX3"
:domain.data.sequencing.illumina.run.lane/lane-id "L002"
:domain.data.sequencing.illumina.run.lane.library/library-id "JAE006.A0101"
:domain.data.sequencing.illumina.run.lane.library/read-count "250"
:file-name "JAE006.A0101_S0_L002_R2_001.fastq.gz"
:sha1sum "1fa8fb21a8162aa4731f3f300eb0de7a065962ac"
:path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L002_R2_001.fastq.gz"}])

(def domain-data-value-type {:domain.data.sequencing.illumina.run/uuid :db.type/uuid
:domain.data.sequencing.illumina.run/run-date :db.type/instant
:domain.data.sequencing.illumina.run.read/cycles :db.type/long
:domain.data.sequencing.illumina.run.read/indexed? :db.type/boolean
:domain.data.sequencing.illumina.run.lane/uuid :db.type/uuid
:domain.data.sequencing.illumina.run.lane.library/uuid :db.type/uuid
:domain.data.sequencing.illumina.run.lane.library/read-count :db.type/long})

(def domain-data-datascript-schema {:domain.data.sequencing.illumina.run/run-id {:db/unique :db.unique/identity}
:domain.data.sequencing.illumina.run/uuid {:db/unique :db.unique/identity}
:domain.data.sequencing.illumina.run.lane/uuid {:db/unique :db.unique/identity}
:domain.data.sequencing.illumina.run/lane+ {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}
:domain.data.sequencing.illumina.run.lane.library/uuid {:db/unique :db.unique/identity}
:domain.data.sequencing.illumina.run.lane/library+ {:db/isComponent true
:db/cardinality :db.cardinality/many
:db/valueType :db.type/ref}
:domain.data.sequencing.illumina.run/read+ {:db/isComponent true
:db/cardinality :db.cardinality/many
:db/valueType :db.type/ref}})

(def tx-data [[:db/add (dt/tempid :db.part/data -1) :domain.data.sequencing.illumina.run/lane+ (dt/tempid :db.part/data -2)]
[:db/add (dt/tempid :db.part/data -1) :domain.data.sequencing.illumina.run/lane+ (dt/tempid :db.part/data -4)]
[:db/add (dt/tempid :db.part/data -1) :domain.data.sequencing.illumina.run/run-id "170911_NS500559_0049_AHKJ2TBGX3"]
[:db/add (dt/tempid :db.part/data -2) :domain.data.sequencing.illumina.run.lane/lane-id "L001"]
[:db/add (dt/tempid :db.part/data -2) :domain.data.sequencing.illumina.run.lane/library+ (dt/tempid :db.part/data -3)]
[:db/add (dt/tempid :db.part/data -3) :domain.data.sequencing.illumina.run.lane.library/library-id "JAE006.A0101"]
[:db/add (dt/tempid :db.part/data -3) :domain.data.sequencing.illumina.run.lane.library/read-count 250]
[:db/add (dt/tempid :db.part/data -3) :domain.data.sequencing.illumina.run.lane.library/read-one-file-path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L001_R1_001.fastq.gz"]
[:db/add (dt/tempid :db.part/data -3) :domain.data.sequencing.illumina.run.lane.library/read-one-sha1sum "e92e815426b0bcb00ce3968512973e74b35c0650"]
[:db/add (dt/tempid :db.part/data -3) :domain.data.sequencing.illumina.run.lane.library/read-two-file-path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L001_R2_001.fastq.gz"]
[:db/add (dt/tempid :db.part/data -3) :domain.data.sequencing.illumina.run.lane.library/read-two-sha1sum "1fa8fb21a8162aa4731f3f300eb0de7a065962ac"]
[:db/add (dt/tempid :db.part/data -4) :domain.data.sequencing.illumina.run.lane/lane-id "L002"]
[:db/add (dt/tempid :db.part/data -4) :domain.data.sequencing.illumina.run.lane/library+ (dt/tempid :db.part/data -5)]
[:db/add (dt/tempid :db.part/data -5) :domain.data.sequencing.illumina.run.lane.library/library-id "JAE006.A0101"]
[:db/add (dt/tempid :db.part/data -5) :domain.data.sequencing.illumina.run.lane.library/read-count 250]
[:db/add (dt/tempid :db.part/data -5) :domain.data.sequencing.illumina.run.lane.library/read-one-file-path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L002_R1_001.fastq.gz"]
[:db/add (dt/tempid :db.part/data -5) :domain.data.sequencing.illumina.run.lane.library/read-one-sha1sum "e92e815426b0bcb00ce3968512973e74b35c0650"]
[:db/add (dt/tempid :db.part/data -5) :domain.data.sequencing.illumina.run.lane.library/read-two-file-path "/rawdata1/releases/2017/170911_NS500559_0049_AHKJ2TBGX3/JAE006.A0101/JAE006.A0101_S0_L002_R2_001.fastq.gz"]
[:db/add (dt/tempid :db.part/data -5) :domain.data.sequencing.illumina.run.lane.library/read-two-sha1sum "1fa8fb21a8162aa4731f3f300eb0de7a065962ac"]])
@@ -6,6 +6,7 @@
[datomic.api :as dt]
[datascript.core :as ds]
[data.transaction-data :as transaction-data]
[data.transaction-data-extended :as transaction-data-extended]
[de.mpg.shh.util-datomic-peer.transaction-data :as peer-transaction-data]))

(fact "Create tx-data for run-lane-library data"
@@ -31,4 +32,33 @@
:domain.data.sequencing.illumina.run.lane.library/read-count]}]}]]
(vec (peer-transaction-data/push->tx-data :db.part/data transaction-data/domain-data-value-type transaction-data/domain-data-datascript-schema push-pattern rows))) => transaction-data/tx-data)

(fact "Create tx-data for run-lane-library with generated uuid data"
(let [row->tx (fn [row]
(let [read-num (str/split (:file-name row) #"_")
read-num (-> row :file-name (str/split #"_") reverse second)
;;_ (info "read-num: " read-num)
path-kw (if (= read-num "R1")
:domain.data.sequencing.illumina.run.lane.library/read-one-file-path
:domain.data.sequencing.illumina.run.lane.library/read-two-file-path)
sum-kw (if (= read-num "R1")
:domain.data.sequencing.illumina.run.lane.library/read-one-sha1sum
:domain.data.sequencing.illumina.run.lane.library/read-two-sha1sum)]
(-> row
(clojure.set/rename-keys {:path path-kw :sha1sum sum-kw}))))
rows (vec (map row->tx transaction-data-extended/run-lane-library-data))
push-pattern [:domain.data.sequencing.illumina.run/run-id
:domain.data.sequencing.illumina.run/uuid
{:domain.data.sequencing.illumina.run/lane+ [:domain.data.sequencing.illumina.run.lane/lane-id
:domain.data.sequencing.illumina.run.lane/uuid
{:domain.data.sequencing.illumina.run.lane/library+ [:domain.data.sequencing.illumina.run.lane.library/library-id
:domain.data.sequencing.illumina.run.lane.library/uuid
:domain.data.sequencing.illumina.run.lane.library/read-one-file-path
:domain.data.sequencing.illumina.run.lane.library/read-one-sha1sum
:domain.data.sequencing.illumina.run.lane.library/read-two-file-path
:domain.data.sequencing.illumina.run.lane.library/read-two-sha1sum
:domain.data.sequencing.illumina.run.lane.library/read-count]}]}]]
(vec (remove (comp #(= % "uuid")
name
#(nth % 2)) (peer-transaction-data/push->tx-data :db.part/data transaction-data-extended/domain-data-value-type transaction-data-extended/domain-data-datascript-schema push-pattern rows)))) => transaction-data-extended/tx-data)


0 comments on commit e720d1f

Please sign in to comment.