diff --git a/src/cljam/io/util/bin.clj b/src/cljam/io/util/bin.clj index 6afc5b0f..a63bc87c 100644 --- a/src/cljam/io/util/bin.clj +++ b/src/cljam/io/util/bin.clj @@ -35,7 +35,7 @@ (bit-shift-right (if (<= pos 0) 0 (dec pos)) linear-index-shift)) (defn get-spans - "Calculate span information for random access from ndex data such as tabix." + "Calculate span information for random access from index data such as tabix." [index-data ^long ref-idx ^long beg ^long end] (let [bins (reg->bins beg end) chunks (get-chunks index-data ref-idx bins) diff --git a/src/cljam/io/vcf/reader.clj b/src/cljam/io/vcf/reader.clj index cd614bf9..c8d32a7e 100644 --- a/src/cljam/io/vcf/reader.clj +++ b/src/cljam/io/vcf/reader.clj @@ -181,14 +181,8 @@ :vcf identity)] (map parse-fn (read-data-lines (.reader rdr) (.header rdr) kws))))) -(defn- make-lazy-variants [f s] - (when-first [fs s] - (lazy-cat - (f fs) - (make-lazy-variants f (rest s))))) - (defn read-variants-randomly - "Read variants of the bgzip compressed VCF file randomly using tabix file. + "Reads variants of the bgzip compressed VCF file randomly using tabix file. Returning them as a lazy sequence." [^VCFReader rdr {:keys [chr start end] :or {start 1 end 4294967296}} @@ -202,7 +196,7 @@ parse-fn (case depth :deep (vcf-util/variant-parser (.meta-info rdr) (.header rdr)) :vcf identity)] - (make-lazy-variants + (mapcat (fn [[chunk-beg ^long chunk-end]] (.seek input-stream chunk-beg) (->> #(when (< (.getFilePointer input-stream) chunk-end) diff --git a/test/cljam/io/tabix_test.clj b/test/cljam/io/tabix_test.clj index 6805d81a..aecb6301 100644 --- a/test/cljam/io/tabix_test.clj +++ b/test/cljam/io/tabix_test.clj @@ -23,8 +23,8 @@ (is (number? (.meta tabix-data))) (is (number? (.skip tabix-data))) (is (vector? (.seq tabix-data))) - (is (instance? Chunk (get (get (get (.bidx tabix-data) 0) 4687) 0))) - (is (vector? (get (.lidx tabix-data) 0))))) + (is (instance? Chunk (get (get (get (.bidx tabix-data) 0) 4687) 0))) + (is (vector? (get (.lidx tabix-data) 0))))) (deftest-remote large-file (with-before-after {:before (prepare-cavia!)}