Skip to content

Commit

Permalink
Merge pull request #102 from chrovis/fix/lazy-depth-pmap
Browse files Browse the repository at this point in the history
Use lazy pmap for lazy-depth
  • Loading branch information
alumi committed Aug 31, 2017
2 parents 7df1f95 + 37d93af commit 579df0d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cljam/algo/depth.clj
@@ -1,6 +1,7 @@
(ns cljam.algo.depth
"Provides algorithms for calculating simple depth of coverage."
(:require [com.climate.claypoole :as cp]
[com.climate.claypoole.lazy :as lazy]
[cljam.common :as common]
[cljam.util :as util]
[cljam.io.sam :as sam]
Expand Down Expand Up @@ -34,10 +35,10 @@
(if (= n-threads 1)
(map (fn [[start end]]
(count-for-positions (read-fn rdr start end) start end)) xs)
(cp/pmap (dec n-threads)
(fn [[start end]]
(with-open [r (sam/clone-bam-reader rdr)]
(count-for-positions (read-fn r start end) start end))) xs)))]
(lazy/pmap (dec n-threads)
(fn [[start end]]
(with-open [r (sam/clone-bam-reader rdr)]
(count-for-positions (read-fn r start end) start end))) xs)))]
(->> (util/divide-region start end step)
count-fn
(apply concat))))
Expand Down

0 comments on commit 579df0d

Please sign in to comment.