Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use XZ for LZMA compression in CRAM #321

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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