                        (mapcat #((get-exp-info eid :replicate-names) %)
                                (get-exp-info eid :sample-names))
                        sample-names)]
-    (doseq [tuple (partition-all 2 sample-names)]
-      (let [futs-vecs
-            (mapv
-             (fn[snm]
-               (let [job (assoc-in phase1-job-template [:nodes :ph1 :args]
-                                   (get-phase-1-args
-                                    exp eid snm :repk repk
-                                    :bowtie bt :star star))
-                     cfg (-> job
-                             (pg/config-pgm-graph-nodes get-toolinfo nil nil)
-                             pg/config-pgm-graph)]
-                 #_(clojure.pprint/pprint cfg)
-                 (->> cfg pg/make-flow-graph pg/run-flow-program)))
-             tuple)]
-        (mapv (fn[futs] (mapv (fn[fut] (deref fut)) futs))
-              futs-vecs)))
+    (swap! status-atom assoc :DONE [])
+    (loop [tuples (partition-all 2 sample-names)
+           abort? false]
+      (if (or (empty? tuples) abort?)
+        abort?
+        (let [tuple (first tuples)
+              futs-vecs
+              (mapv
+               (fn[snm]
+                 (let [job (assoc-in phase1-job-template [:nodes :ph1 :args]
+                                     (get-phase-1-args
+                                      exp eid snm :repk repk
+                                      :bowtie bt :star star))
+                       cfg (-> job
+                               (pg/config-pgm-graph-nodes get-toolinfo nil nil)
+                               pg/config-pgm-graph)]
+                   #_(clojure.pprint/pprint cfg)
+                   (->> cfg pg/make-flow-graph pg/run-flow-program)))
+               tuple)]
+          (recur (rest tuples)
+                 (coll/reducem
+                  (fn[replicate futs]
+                    (let [abort? (job-flow-node-results futs status-atom)
+                          flow-results (@status-atom :done)]
+                      (swap! status-atom
+                             #(assoc % :DONE
+                                     (conj (% :DONE) [replicate flow-results])))
+                      abort?))
+                  (fn ([] false) ([x y] #_(println x y) (or x y)))
+                  :|| tuple futs-vecs)))))
     (pg/send-msg
      [recipient]
      (str "Aerobio job status: " exp " phase-1  " eid)
      (str "Finished " (if repk "replicates" "merged") " for " eid ))))
 
+#_(let [a (atom [])]
+  [(coll/reducem
+    (fn [x y]
+      (swap! a conj [x y])
+      (if (= 0 x) true false))
+    (fn ([] false) ([x y] (println x y) (or x y)))
+    :|| (range 5) [:one :two :three :four :five])
+   @a])
 
 ;;;(ns-unmap 'aerobio.htseq.common 'get-comparison-files)
 (defmulti

      prn (->> cfg clojure.pprint/pprint)
      :else cfg)))


(defn run-phase-0
  [eid recipient get-toolinfo template]
  (let [ph0 template
        cfg (-> (assoc-in ph0 [:nodes :ph0 :args] [eid recipient])
                (pg/config-pgm-graph-nodes get-toolinfo nil nil)
                pg/config-pgm-graph)
        ;;_ (clojure.pprint/pprint cfg)
        futs-vec (->> cfg pg/make-flow-graph pg/run-flow-program)]
    (mapv (fn[fut] (deref fut)) futs-vec)))


;;;(ns-unmap 'aerobio.htseq.common 'get-phase-1-args)

  (let [fqzmap (get-all-replicate-fqzs eid)
        rnm-bits (str/split #"-" repname)
        fqzs (fqzmap (cljstr/join "-" (coll/takev 2 rnm-bits)))]
    (assert (seq fqzs)
            (format "%s : There are no fastq files for %s" eid repname))
    (if (< (count rnm-bits) 3)
      fqzs
      (->> fqzs
