From a13466408078067b7882fab119d22bb531d45698 Mon Sep 17 00:00:00 2001 From: atsuo yamada Date: Fri, 28 Apr 2017 01:28:55 +0900 Subject: [PATCH] Add test for `cljam level` --- test/cljam/t_cli.clj | 10 +++++++--- test/cljam/t_common.clj | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/cljam/t_cli.clj b/test/cljam/t_cli.clj index 40ef3fe7..22e3a78b 100644 --- a/test/cljam/t_cli.clj +++ b/test/cljam/t_cli.clj @@ -2,7 +2,9 @@ (:require [clojure.test :refer :all] [cljam.t-common :refer :all] [clojure.java.io :as io] - [cljam.cli :as cli]) + [cljam.cli :as cli] + [cljam.io :as cio] + [cljam.bam :as bam]) (:import [java.io PrintStream])) (defmacro with-out-file @@ -132,8 +134,10 @@ (with-out-file temp-out (cli/level [test-bam-file temp-bam])))) (is (not-throw? (with-out-file temp-out (cli/level [test-sorted-bam-file temp-bam])))) - ;; TODO: examine contents of temp-bam - )) + (with-open [rdr (bam/reader temp-bam :ignore-index true)] + (is (= (map #(first (keep :LV (:options %))) + (cio/read-alignments rdr)) + test-sorted-bam-levels))))) (deftest about-run (with-before-after {:before (prepare-cache!) diff --git a/test/cljam/t_common.clj b/test/cljam/t_common.clj index b794dce5..3e5368a5 100644 --- a/test/cljam/t_common.clj +++ b/test/cljam/t_common.clj @@ -307,6 +307,20 @@ {:data [1 0 0 0 11 0 0 0 3 30 73 18 1 0 0 0 24 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 120 53 0 -128 1 0 0 17 -127 24 -127 20 -126 -127 33 65 66 17 40 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30], :size 75} {:data [1 0 0 0 13 0 0 0 3 30 73 18 1 0 0 0 23 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 0 0 0 0 120 54 0 112 1 0 0 -127 24 -127 20 -126 -127 33 65 66 17 40 16 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30], :size 74}]) +(def test-sorted-bam-levels + [{:type "i", :value 0} + {:type "i", :value 1} + {:type "i", :value 2} + {:type "i", :value 2} + {:type "i", :value 0} + {:type "i", :value 0} + {:type "i", :value 0} + {:type "i", :value 1} + {:type "i", :value 2} + {:type "i", :value 3} + {:type "i", :value 4} + {:type "i", :value 5}]) + (def test-fa [{:rname "ref", :offset 5, :seq "AGCATGTTAGATAAGATAGCTGTGCTAGTAGGCAGTCAGCGCCAT", :blen 45} {:rname "ref2", :offset 57, :seq "aggttttataaaacaattaagtctacagagcaactacgcg", :blen 40}])