Skip to content

Commit

Permalink
Merge pull request #69 from ayamada/feature/tune-cloverage-worktime
Browse files Browse the repository at this point in the history
For reduce worktime of `lein cloverage`
  • Loading branch information
alumi committed Apr 28, 2017
2 parents 11a0fef + 878f0fd commit f6ec43b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion test/cljam/t_bam.clj
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
(is (thrown? IOException (bam/reader invalid-file-2 :ignore-index true)))
(is (thrown? IOException (bam/reader not-found-file :ignore-index true)))))

(deftest bamreader-medium-file
(deftest-slow bamreader-medium-file
(with-before-after {:before (prepare-cache!)
:after (clean-cache!)}
(with-open [rdr (bam/reader medium-bam-file :ignore-index true)]
Expand Down
33 changes: 20 additions & 13 deletions test/cljam/t_bam_indexer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[cljam.bam-indexer :as bai]))

(def temp-file-sorted (str temp-dir "/test.sorted.bam"))
(def temp-file-sorted-2 (str temp-dir "/test.sorted2.bam"))

(deftest about-bam-indexer
(with-before-after {:before (do (prepare-cache!)
Expand Down Expand Up @@ -52,23 +53,29 @@
)))

(deftest about-bam-indexer-small-file
(doseq [n-threads [1 4]]
(with-before-after {:before (do (prepare-cache!)
(fs/copy small-bam-file temp-file-sorted))
:after (clean-cache!)}
(with-before-after {:before (do (prepare-cache!)
(fs/copy small-bam-file temp-file-sorted)
(fs/copy small-bam-file temp-file-sorted-2))
:after (clean-cache!)}
(let [temp-file-sorted-bai (str temp-file-sorted ".bai")
temp-file-sorted-bai-2 (str temp-file-sorted-2 ".bai")]
(is (not-throw? (bai/create-index temp-file-sorted
(str temp-file-sorted ".bai")
:n-threads n-threads)))
(is (fs/exists? (str temp-file-sorted ".bai")))
temp-file-sorted-bai
:n-threads 1)))
(is (fs/exists? temp-file-sorted-bai))
(is (not-throw? (bai/create-index temp-file-sorted-2
temp-file-sorted-bai-2
:n-threads 4)))
(is (fs/exists? temp-file-sorted-bai-2))
(is (same-file? temp-file-sorted-bai temp-file-sorted-bai-2))
(with-open [r (bam/reader temp-file-sorted)]
;; Random read with different number of spans.
(are [?param ?counts] (= (count (io/read-alignments r ?param)) ?counts)
{:chr "chr1" :start 23000000 :end 25000000 :depth :shallow} 14858
{:chr "chr1" :start 23000000 :end 25000000 :depth :pointer} 14858
{:chr "chr1" :start 23000000 :end 25000000 :depth :deep} 14858
{:chr "chr1" :start 23000000 :end 24500000 :depth :deep} 11424
{:chr "chr1" :start 23000000 :end 24000000 :depth :deep} 10010
{:chr "chr1" :start 23000000 :end 23500000 :depth :deep} 3806
{:chr "chr1" :start 23000000 :end 23001000 :depth :deep} 46 ;; 1 span
{:chr "chr1" :start 24900000 :end 24902000 :depth :deep} 3 ;; 2 spans
{:chr "chr1" :start 24000000 :end 24001000 :depth :deep} 6 ;; 3 spans
{:chr "chr1" :start 23260000 :end 23268650 :depth :deep} 58 ;; 4 spans
{:chr "chr1" :start 23430000 :end 23470000 :depth :deep} 55 ;; 5 spans
{:chr "*"} 0)))))

(deftest-slow about-bam-indexer-medium-file
Expand Down
4 changes: 2 additions & 2 deletions test/cljam/t_pileup.clj
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
(mplp/pileup-seq 101 120 (map #(hash-map :pos (inc %) :cigar "10M") (range))))
[10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10]))
(is (= (map :pos
(last (mplp/pileup-seq 1 1000000 (map #(hash-map :pos (inc %) :cigar "10M") (range)))))
[999991 999992 999993 999994 999995 999996 999997 999998 999999 1000000]))
(last (mplp/pileup-seq 1 100000 (map #(hash-map :pos (inc %) :cigar "10M") (range)))))
[99991 99992 99993 99994 99995 99996 99997 99998 99999 100000]))

;; -----
;; ----
Expand Down

0 comments on commit f6ec43b

Please sign in to comment.