Skip to content

Commit

Permalink
refactor: add .bz2 support for fasta&fastq file format
Browse files Browse the repository at this point in the history
  • Loading branch information
chaunceyyu committed Jul 12, 2020
1 parent 05b79c3 commit 6fbad8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define ASQG_EXT ".asqg"
#define HITS_EXT ".hits"
#define GZIP_EXT ".gz"
#define BZIP_EXT ".bz2"
#define RMDUP_EXT ".rmdup"
#define EC_EXT ".ec"
#define FA_EXT ".fa"
Expand Down
6 changes: 5 additions & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include <boost/algorithm/string.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/gzip.hpp>

#include <log4cxx/logger.h>
Expand All @@ -17,6 +17,8 @@ namespace Utils {
try {
if (boost::algorithm::ends_with(filename, GZIP_EXT)) {
stream->push(boost::iostreams::gzip_decompressor());
} else if (boost::algorithm::ends_with(filename, BZIP_EXT)) {
stream->push(boost::iostreams::bzip2_decompressor());
}
stream->push(boost::iostreams::file_descriptor_source(filename));
} catch (...) {
Expand All @@ -29,6 +31,8 @@ namespace Utils {
try {
if (boost::algorithm::ends_with(filename, GZIP_EXT)) {
stream->push(boost::iostreams::gzip_compressor());
} else if (boost::algorithm::ends_with(filename, BZIP_EXT)) {
stream->push(boost::iostreams::bzip2_compressor());
}
stream->push(boost::iostreams::file_descriptor_sink(filename));
} catch (...) {
Expand Down

0 comments on commit 6fbad8c

Please sign in to comment.