diff --git a/src/cljam/algo/convert.clj b/src/cljam/algo/convert.clj index 2be67ed1..989fcfa9 100644 --- a/src/cljam/algo/convert.clj +++ b/src/cljam/algo/convert.clj @@ -1,19 +1,19 @@ (ns cljam.algo.convert "Converters between equivalent formats: SAM/BAM and FASTA/TwoBit." - (:require [clojure.tools.logging :as logging] - [clojure.string :as cstr] - [cljam.common :refer [*n-threads* get-exec-n-threads]] - [cljam.io.sam :as sam] + (:require [cljam.common :refer [*n-threads* get-exec-n-threads]] [cljam.io.bam.encoder :as encoder] + [cljam.io.fastq :as fq] + [cljam.io.sam :as sam] [cljam.io.sam.util.flag :as flag] [cljam.io.sam.util.refs :as refs] - [cljam.util.sequence :as util-seq] [cljam.io.sequence :as cseq] - [cljam.io.fastq :as fq] [cljam.io.util :as io-util] + [cljam.util.sequence :as util-seq] + [clojure.string :as cstr] + [clojure.tools.logging :as logging] [com.climate.claypoole :as cp]) - (:import [java.nio ByteBuffer] - [cljam.io.fastq FASTQRead])) + (:import [cljam.io.fastq FASTQRead] + [java.io ByteArrayOutputStream])) ;;; SAM <-> BAM @@ -30,9 +30,9 @@ n-threads (get-exec-n-threads)] (doseq [blocks (cp/pmap (if (= n-threads 1) :serial (dec n-threads)) (fn [chunk'] - (mapv #(let [bb (ByteBuffer/allocate (encoder/get-block-size %))] - (encoder/encode-alignment bb % refs) - {:data (.array bb)}) + (mapv #(let [baos (ByteArrayOutputStream. (encoder/get-block-size %))] + (encoder/encode-alignment baos % refs) + {:data (.toByteArray baos)}) chunk')) (partition-all num-block (sam/read-alignments rdr {})))] (sam/write-blocks wtr blocks)))) diff --git a/src/cljam/io/bam/core.clj b/src/cljam/io/bam/core.clj index c3bf7505..bae24bf5 100644 --- a/src/cljam/io/bam/core.clj +++ b/src/cljam/io/bam/core.clj @@ -6,7 +6,7 @@ [writer :as writer]] [cljam.io.bam-index :as bai] [cljam.io.util.bgzf :as bgzf] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.data-io :as lsb] [cljam.util :as util]) (:import java.util.Arrays [java.io DataInputStream DataOutputStream IOException FileNotFoundException] diff --git a/src/cljam/io/bam/encoder.clj b/src/cljam/io/bam/encoder.clj index aa25e47b..a5a9d339 100644 --- a/src/cljam/io/bam/encoder.clj +++ b/src/cljam/io/bam/encoder.clj @@ -7,7 +7,7 @@ [cljam.io.sam.util.quality :as qual] [cljam.io.sam.util.cigar :as cigar] [cljam.io.sam.util.sequence :as seq] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.io-stream :as lsb] [cljam.io.bam.common :as common])) (def ^:private ^:const fixed-tag-size 3) diff --git a/src/cljam/io/bam/reader.clj b/src/cljam/io/bam/reader.clj index 7ad3b3b6..be337582 100644 --- a/src/cljam/io/bam/reader.clj +++ b/src/cljam/io/bam/reader.clj @@ -5,7 +5,7 @@ [cljam.io.sam.util.header :as header] [cljam.io.bam-index.core :as bai] [cljam.io.bam.decoder :as decoder] - [cljam.io.util.lsb :as lsb]) + [cljam.io.util.lsb.data-io :as lsb]) (:import [java.io Closeable FileNotFoundException] [cljam.io.bam.decoder BAMRawBlock] [bgzf4j BGZFInputStream])) diff --git a/src/cljam/io/bam/writer.clj b/src/cljam/io/bam/writer.clj index e99cbe0a..6acdfc87 100644 --- a/src/cljam/io/bam/writer.clj +++ b/src/cljam/io/bam/writer.clj @@ -4,7 +4,7 @@ [cljam.io.protocols :as protocols] [cljam.io.sam.util.refs :as refs] [cljam.io.sam.util.header :as header] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.io-stream :as lsb] [cljam.io.bam.common :as common] [cljam.io.bam.encoder :as encoder] [cljam.io.bam.decoder :as bam-decoder] diff --git a/src/cljam/io/bam_index/reader.clj b/src/cljam/io/bam_index/reader.clj index 556fa17d..998b6c69 100644 --- a/src/cljam/io/bam_index/reader.clj +++ b/src/cljam/io/bam_index/reader.clj @@ -1,6 +1,6 @@ (ns cljam.io.bam-index.reader (:require [clojure.java.io :as cio] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.io-stream :as lsb] [cljam.io.bam-index.common :refer [bai-magic]] [cljam.io.util.chunk :as chunk] [cljam.util :as util]) diff --git a/src/cljam/io/bam_index/writer.clj b/src/cljam/io/bam_index/writer.clj index 8b1d00ef..071edf36 100644 --- a/src/cljam/io/bam_index/writer.clj +++ b/src/cljam/io/bam_index/writer.clj @@ -2,7 +2,7 @@ (:require [com.climate.claypoole :as cp] [cljam.common :refer [get-exec-n-threads]] [cljam.io.util.bgzf :as bgzf] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.io-stream :as lsb] [cljam.io.util.bin :as util-bin] [cljam.io.bam-index.common :refer [linear-index-shift linear-index-depth diff --git a/src/cljam/io/bcf/reader.clj b/src/cljam/io/bcf/reader.clj index 9449543b..3a24549c 100644 --- a/src/cljam/io/bcf/reader.clj +++ b/src/cljam/io/bcf/reader.clj @@ -4,7 +4,7 @@ [cljam.io.protocols :as protocols] [cljam.io.util.bgzf :as bgzf] [cljam.io.util.byte-buffer :as bb] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.io-stream :as lsb] [cljam.io.vcf.reader :as vcf-reader] [cljam.io.vcf.util :as vcf-util] [cljam.util :as util] diff --git a/src/cljam/io/bcf/writer.clj b/src/cljam/io/bcf/writer.clj index 372a9131..2a3f4a1a 100644 --- a/src/cljam/io/bcf/writer.clj +++ b/src/cljam/io/bcf/writer.clj @@ -2,7 +2,7 @@ (:require [clojure.string :as cstr] [cljam.io.protocols :as protocols] [cljam.io.util.bgzf :as bgzf] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.io-stream :as lsb] [cljam.io.vcf.writer :as vw] [cljam.io.vcf.util :as vcf-util] [cljam.util :as util]) diff --git a/src/cljam/io/bigwig.clj b/src/cljam/io/bigwig.clj index ab416d69..007a9cc5 100644 --- a/src/cljam/io/bigwig.clj +++ b/src/cljam/io/bigwig.clj @@ -4,7 +4,7 @@ specifications." (:require [clojure.java.io :as cio] [cljam.io.protocols :as protocols] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.data-io :as lsb] [cljam.util :as util]) (:import [java.net URL] [java.io Closeable IOException RandomAccessFile] diff --git a/src/cljam/io/csi.clj b/src/cljam/io/csi.clj index 752c4ece..3aafbd5e 100644 --- a/src/cljam/io/csi.clj +++ b/src/cljam/io/csi.clj @@ -1,13 +1,13 @@ (ns cljam.io.csi "Basic I/O of CSI:Coordinate Sorted Index files." - (:require [clojure.string :as cstr] - [cljam.io.util.bgzf :as bgzf] - [cljam.io.util.lsb :as lsb] + (:require [cljam.io.util.bgzf :as bgzf] + [cljam.io.util.bin :as util-bin] [cljam.io.util.chunk :as chunk] - [cljam.io.util.bin :as util-bin]) - (:import java.util.Arrays - [java.io DataInputStream DataOutputStream IOException] - [java.nio ByteBuffer ByteOrder])) + [cljam.io.util.lsb.io-stream :as lsb] + [clojure.string :as cstr]) + (:import [java.io DataInputStream DataOutputStream IOException] + [java.nio ByteBuffer ByteOrder] + java.util.Arrays)) (def ^:const ^:private csi-magic "CSI\1") diff --git a/src/cljam/io/tabix.clj b/src/cljam/io/tabix.clj index 4e7dfc07..ed32bffd 100644 --- a/src/cljam/io/tabix.clj +++ b/src/cljam/io/tabix.clj @@ -2,7 +2,7 @@ "Alpha - subject to change. Reader of a TABIX format file." (:require [cljam.io.util.bgzf :as bgzf] - [cljam.io.util.lsb :as lsb] + [cljam.io.util.lsb.io-stream :as lsb] [cljam.io.util.bin :as util-bin] [clojure.string :as cstr]) (:import java.util.Arrays