2
2
* @file https://github.com/Zilong-Li/vcfpp/vcfpp.h
3
3
* @author Zilong Li
4
4
5
- * @version v0.6.1
5
+ * @version v0.6.2
6
6
* @breif a single C++ file for manipulating VCF
7
7
* Copyright (C) 2022-2023.The use of this code is governed by the LICENSE file.
8
8
******************************************************************************/
@@ -1633,6 +1633,14 @@ class BcfReader
1633
1633
header.hdr = bcf_hdr_read (fp.get ());
1634
1634
nsamples = bcf_hdr_nsamples (header.hdr );
1635
1635
SamplesName = header.getSamples ();
1636
+ if (isBcf)
1637
+ {
1638
+ hidx = std::shared_ptr<hts_idx_t >(bcf_index_load (fname.c_str ()), details::hts_idx_close ());
1639
+ }
1640
+ else
1641
+ {
1642
+ tidx = std::shared_ptr<tbx_t >(tbx_index_load (fname.c_str ()), details::tabix_idx_close ());
1643
+ }
1636
1644
}
1637
1645
1638
1646
/* * @brief set the number of threads to use */
@@ -1714,7 +1722,6 @@ class BcfReader
1714
1722
// 3. if region is empty, use "."
1715
1723
if (isBcf)
1716
1724
{
1717
- hidx = std::shared_ptr<hts_idx_t >(bcf_index_load (fname.c_str ()), details::hts_idx_close ());
1718
1725
if (itr) itr.reset (); // reset current region.
1719
1726
if (region.empty ())
1720
1727
itr = std::shared_ptr<hts_itr_t >(bcf_itr_querys (hidx.get (), header.hdr , " ." ),
@@ -1725,7 +1732,6 @@ class BcfReader
1725
1732
}
1726
1733
else
1727
1734
{
1728
- tidx = std::shared_ptr<tbx_t >(tbx_index_load (fname.c_str ()), details::tabix_idx_close ());
1729
1735
if (tidx.get () == NULL ) throw std::invalid_argument (" no tabix index found!" );
1730
1736
if (itr) itr.reset (); // reset
1731
1737
if (region.empty ())
0 commit comments