Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Enable the use of SyncedVariantReader with no intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthibault79 committed Sep 2, 2014
1 parent 816fee7 commit 9d1eee0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gamgee/indexed_variant_reader.h
Expand Up @@ -34,7 +34,7 @@ class IndexedVariantReader {
* parsing them into Variant objects
*
* @param filename the name of the variant file
* @param interval_list a vector of intervals represented by strings
* @param interval_list a vector of intervals represented by strings. Empty vector for all intervals.
*
*/
IndexedVariantReader(const std::string& filename, const std::vector<std::string> interval_list) :
Expand Down
14 changes: 10 additions & 4 deletions gamgee/synced_variant_reader.h
Expand Up @@ -40,15 +40,21 @@ class SyncedVariantReader {
* @brief opens multiple files (vcf or bcf) and allows an iterator to parse them
*
* @param filenames the names of the variant files
* @param interval_list a comma-separated list of the intervals to traverse
* @param interval_list a comma-separated string of the intervals to traverse. Empty string for all intervals.
* @exception will throw std::runtime_error if the htslib structure cannot be initialized
*/
SyncedVariantReader(const std::vector<std::string>& filenames, const std::string& interval_list) :
m_synced_readers {utils::make_shared_synced_variant_reader(bcf_sr_init())}
{
auto success = bcf_sr_set_regions(m_synced_readers.get(), interval_list.c_str(), 0);
if (success != 0)
throw HtslibException(success);
auto success = 0;
if (interval_list.empty()) {
m_synced_readers->require_index = 1;
}
else {
success = bcf_sr_set_regions(m_synced_readers.get(), interval_list.c_str(), 0);
if (success != 0)
throw HtslibException(success);
}

for (const auto& filename : filenames) {
success = bcf_sr_add_reader(m_synced_readers.get(), filename.c_str());
Expand Down
2 changes: 1 addition & 1 deletion test/variant_reader_test.cpp
Expand Up @@ -792,7 +792,7 @@ const auto indexed_variant_bp_partial_joined = boost::algorithm::join(indexed_va

// full interval lists
BOOST_AUTO_TEST_CASE( synced_variant_reader_full_test ) {
for (const auto intervals : {indexed_variant_chrom_full_joined, indexed_variant_bp_full_joined}) {
for (const auto intervals : {string{""}, indexed_variant_chrom_full_joined, indexed_variant_bp_full_joined}) {
for (const auto input_files : {indexed_variant_vcf_inputs, indexed_variant_bcf_inputs}) {
auto truth_index = 0u;
const auto reader = SyncedVariantReader<SyncedVariantIterator>{input_files, intervals};
Expand Down

0 comments on commit 9d1eee0

Please sign in to comment.