void bam_streamer:: set_new_region(const int ref, const int beg, const int end) { if (nullptr != _hitr) hts_itr_destroy(_hitr); _load_index(); if (ref < 0) { log_os << "ERROR: Invalid region specified for BAM/CRAM file: " << name() << "\n"; exit(EXIT_FAILURE); } _hitr = sam_itr_queryi(_hidx,ref,beg,end); _is_region = true; _region.clear(); _is_record_set = false; _record_no = 0; }
void bam_streamer:: set_new_region(const int ref, const int beg, const int end) { if (NULL != _biter) bam_iter_destroy(_biter); _load_index(); if (ref < 0) { log_os << "ERROR: Invalid region specified for BAM file: " << name() << "\n"; exit(EXIT_FAILURE); } _biter = bam_iter_query(_bidx,ref,beg,end); _is_region = true; _region.clear(); _is_record_set = false; _record_no = 0; }
hts_streamer:: hts_streamer( const char* filename, const char* region) : _is_record_set(false), _is_stream_end(false), _record_no(0), _stream_name(filename), _hfp(nullptr), _tidx(nullptr), _titr(nullptr), _kstr(kinit) { if (! filename) { BOOST_THROW_EXCEPTION(illumina::common::GeneralException("hts filename is null ptr")); } if ('\0' == *filename) { BOOST_THROW_EXCEPTION(illumina::common::GeneralException("hts filename is empty string")); } _hfp = hts_open(filename, "r"); if (! _hfp) { std::ostringstream oss; oss << "Failed to open hts file: '" << filename << "'"; BOOST_THROW_EXCEPTION(illumina::common::GeneralException(oss.str())); } _load_index(); // read only a region of HTS file: if (region) { resetRegion(region); } }