commit 3fc64616a64adfcaf5271ae24f35e443ce822faf
Author: John Marshall <John.W.Marshall@glasgow.ac.uk>
Date:   Tue Dec 17 19:10:47 2019 +0000

    Avoid using non-public HTSlib headers and functions
    
    Only headers in htslib/*.h are part of HTSlib's public API; cram/*.h
    in particular are not. Fortunately SeqLib only uses one function from
    cram/cram_io.h, and that is easily replaced with a public equivalent.
    
    Instead use `hts_set_fai_filename()`, which strdups the string given to
    it itself; `cram_set_option(fp->fp.cram, CRAM_OPT_REFERENCE, ...)` would
    also be an option, but it's better to avoid `fp->fp.cram` as poking into
    an htsFile's insides is also not supported by HTSlib.

diff --git a/SeqLib/BamWalker.h b/SeqLib/BamWalker.h
index d8ae7ee..3b8ffa9 100644
--- a/SeqLib/BamWalker.h
+++ b/SeqLib/BamWalker.h
@@ -11,11 +11,6 @@
 #define INT32_MAX 0x7fffffffL
 #endif
 
-extern "C" {
-#include "htslib/cram/cram.h"
-#include "htslib/cram/cram_io.h"
-}
-
 struct idx_delete {
   void operator()(hts_idx_t* x) { if (x) hts_idx_destroy(x); }
 };
diff --git a/src/BamReader.cpp b/src/BamReader.cpp
index 91fcedf..b4aea44 100644
--- a/src/BamReader.cpp
+++ b/src/BamReader.cpp
@@ -198,9 +198,7 @@ BamReader::BamReader() {}
 
     // open cram reference
     if (!m_cram_reference.empty()) {
-      char * m_cram_reference_cstr = strdup(m_cram_reference.c_str());
-      int ret = cram_load_reference(fp->fp.cram, m_cram_reference_cstr);
-      free(m_cram_reference_cstr);
+      int ret = hts_set_fai_filename(fp.get(), m_cram_reference.c_str());
       if (ret < 0) 
 	throw std::invalid_argument("Could not read reference genome " + m_cram_reference + " for CRAM opt");
     }
