Skip to content

Commit

Permalink
Use XZ for LZMA compression in CRAM
Browse files Browse the repository at this point in the history
  • Loading branch information
athos committed Aug 27, 2024
1 parent b0b8cb4 commit 421df41
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cljam/io/cram/decode/structure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
compressor (case method
1 CompressorStreamFactory/GZIP
2 CompressorStreamFactory/BZIP2
3 CompressorStreamFactory/LZMA
3 CompressorStreamFactory/XZ
(throw
(ex-info (str "compression method " method
" not supported")
Expand Down
8 changes: 4 additions & 4 deletions src/cljam/io/cram/encode/compressor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(:import [java.io ByteArrayOutputStream OutputStream]
[org.apache.commons.compress.compressors.bzip2 BZip2CompressorOutputStream]
[org.apache.commons.compress.compressors.gzip GzipCompressorOutputStream]
[org.apache.commons.compress.compressors.lzma LZMACompressorOutputStream]
[org.apache.commons.compress.compressors.xz XZCompressorOutputStream]
[org.apache.commons.io.output CountingOutputStream]))

(defprotocol ICompressor
Expand Down Expand Up @@ -32,7 +32,7 @@
{:compressor :bzip, :data (.toByteArray baos)}))

(deftype LZMACompressor
[^LZMACompressorOutputStream out ^ByteArrayOutputStream baos]
[^XZCompressorOutputStream out ^ByteArrayOutputStream baos]
ICompressor
(compressor-output-stream [_] out)
(->compressed-result [_]
Expand Down Expand Up @@ -60,7 +60,7 @@
uncompressed)
:bzip (compress-with #(BZip2CompressorOutputStream. %)
uncompressed)
:lzma (compress-with #(LZMACompressorOutputStream. %)
:lzma (compress-with #(XZCompressorOutputStream. %)
uncompressed)
(throw
(ex-info (str "compression method " method
Expand All @@ -78,7 +78,7 @@
:raw (->RawCompressor baos)
:gzip (->GzipCompressor (GzipCompressorOutputStream. baos) baos)
:bzip (->BZip2Compressor (BZip2CompressorOutputStream. baos) baos)
:lzma (->LZMACompressor (LZMACompressorOutputStream. baos) baos)
:lzma (->LZMACompressor (XZCompressorOutputStream. baos) baos)
:best (->SelectiveCompressor baos #{:raw :gzip :bzip :lzma})
(if (set? method-or-methods)
(->SelectiveCompressor baos method-or-methods)
Expand Down
4 changes: 2 additions & 2 deletions test/cljam/io/cram/data_series_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(:import [java.io ByteArrayInputStream ByteArrayOutputStream]
[org.apache.commons.compress.compressors.bzip2 BZip2CompressorInputStream]
[org.apache.commons.compress.compressors.gzip GzipCompressorInputStream]
[org.apache.commons.compress.compressors.lzma LZMACompressorInputStream]))
[org.apache.commons.compress.compressors.xz XZCompressorInputStream]))

(deftest build-data-series-decoders-test
(let [encodings {:BA {:codec :external, :content-id 1}
Expand Down Expand Up @@ -454,7 +454,7 @@
:raw bais
:gzip (GzipCompressorInputStream. bais)
:bzip (BZip2CompressorInputStream. bais)
:lzma (LZMACompressorInputStream. bais))]
:lzma (XZCompressorInputStream. bais))]
(lsb/read-bytes in raw-size))))

(deftest build-data-series-encoders-test
Expand Down

0 comments on commit 421df41

Please sign in to comment.