Skip to content

Commit

Permalink
fixing issue with latest 500 error resulting from no protein for gene
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjohnwright committed Jun 2, 2020
1 parent f14227f commit 4ff8db7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/rest_api/classes/gene/widgets/homology.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
[clojure.string :as str]
[datomic.api :as d]
[pseudoace.utils :as pace-utils]
[rest-api.classes.generic-fields :as generic]
[rest-api.db.main :refer [datomic-homology-conn]]
[rest-api.formatters.object :as obj :refer [pack-obj]]
Expand All @@ -10,26 +11,29 @@

(defn ** [x n] (reduce * (repeat n x)))


(defn best-blastp-matches [g]
(let [longest-protein (some->> (:gene/corresponding-cds g)
(let [proteins (some->> (:gene/corresponding-cds g)
(map :gene.corresponding-cds/cds)
(map :cds/corresponding-protein)
(map :cds.corresponding-protein/protein)
(remove nil?)
(map (fn [p]
{:length (->> p
:protein/peptide
:protein.peptide/length)
:obj p}))
(apply max-key :length))
hits (when (not (nil? longest-protein))
{:length (->> p
:protein/peptide
:protein.peptide/length)
:obj p})))
longest-protein (when (< 0 (count proteins))
(apply max-key :length proteins))
hits (when (not (nil? longest-protein))
(protein-core/get-best-blastp-matches (:obj longest-protein)))]
{:data {:biggest (->> longest-protein :obj :protein/id)
:hits hits}
{:data (pace-utils/vmap
:biggest (->> longest-protein :obj :protein/id)
:hits hits)
:description (if hits
"best BLASTP hits from selected species"
"no homologous proteins found, no best blastp hits to display")}))


(defn- get-orthologs [homolog-holders want-nematode]
(let [species-fn
(fn [oh]
Expand Down

0 comments on commit 4ff8db7

Please sign in to comment.