From bb3df6e2095ac2781f279a024ac5e13d24552bd9 Mon Sep 17 00:00:00 2001 From: Manuel Luypaert Date: Fri, 4 Sep 2020 15:39:28 +0100 Subject: [PATCH] Enabled defining other-names for products in batch API split operation #304 --- ids/src/wormbase/ids/core.clj | 17 ++++++++++------- src/wormbase/specs/gene.clj | 4 +++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ids/src/wormbase/ids/core.clj b/ids/src/wormbase/ids/core.clj index 3759c5c7..12af38be 100644 --- a/ids/src/wormbase/ids/core.clj +++ b/ids/src/wormbase/ids/core.clj @@ -171,14 +171,17 @@ :gene/species [:species/latin-name]} pull-from-gene (partial d/pull db (conj '[*] pull-attr-specs)) id-template (identifier-format db :gene/id) - new-data (map (fn [{:keys [from-id product-sequence-name product-biotype]}] + new-data (map (fn [{:keys [from-id product-sequence-name product-biotype product-other-names]}] (let [from-gene (pull-from-gene from-id) - from-species (:gene/species from-gene)] - {:db/id product-sequence-name - :gene/sequence-name product-sequence-name - :gene/biotype product-biotype - :gene/species (find from-species :species/latin-name) - :gene/status :gene.status/live})) + from-species (:gene/species from-gene) + product {:db/id product-sequence-name + :gene/sequence-name product-sequence-name + :gene/biotype product-biotype + :gene/species (find from-species :species/latin-name) + :gene/status :gene.status/live}] + (if (not (nil? product-other-names)) + (assoc product :gene/other-names product-other-names) + product))) xs)] (some->> xs (mapcat (fn [{:keys [from-id new-biotype product-sequence-name]}] diff --git a/src/wormbase/specs/gene.clj b/src/wormbase/specs/gene.clj index f75c38b5..3dd2992f 100644 --- a/src/wormbase/specs/gene.clj +++ b/src/wormbase/specs/gene.clj @@ -170,7 +170,9 @@ (s/def ::new-biotype (s/nilable :gene/biotype)) (s/def ::product-biotype :gene/biotype) (s/def ::product-sequence-name :gene/sequence-name) -(s/def ::batch-split-item (s/keys :req-un [::from-id ::new-biotype ::product-sequence-name ::product-biotype])) +(s/def ::product-other-names :gene/other-names) +(s/def ::batch-split-item (s/keys :req-un [::from-id ::new-biotype ::product-sequence-name ::product-biotype] + :opt-un [::product-other-names])) (s/def ::split-gene-batch (stc/spec {:spec (s/coll-of ::batch-split-item :min-count 1) :description "A collection of mappings describing the genes to be split."}))