1 #ifndef theplu_yat_omic_bam_file 2 #define theplu_yat_omic_bam_file 25 #include "BamHeader.h" 29 #include "yat/utility/Exception.h" 30 #include "yat/utility/FileUtil.h" 31 #include "yat/utility/yat_assert.h" 33 #include <htslib/sam.h> 35 #include <boost/utility.hpp> 51 template<
typename Derived>
54 typedef Derived derived_type;
100 void open_base(
const std::string& fn,
const std::string& mode,
101 const void* aux) YAT_DEPRECATE;
110 void open_base(
const std::string& fn,
const std::string& mode);
122 const std::string&
filename(
void)
const {
return filename_; }
125 std::string filename_;
161 explicit InBamFile(
const std::string& fn);
212 void open(
const std::string& fn);
232 uint64_t get_idx_stat(
int tid,
bool return_mapped)
const;
273 unsigned int compression);
308 unsigned int compression);
329 virtual ~error(
void)
throw();
339 void open(
const std::string& fn,
const std::string& mode,
346 template<
class Derived>
351 template<
class Derived>
358 template<
class Derived>
361 int res = bam_index_build(filename_.c_str(), 0);
363 std::ostringstream msg;
364 msg <<
"failed building index file '" << filename_ <<
".bai': ";
366 msg <<
"failed to build index";
368 msg <<
"failed to open file '" << filename_ <<
"'";
370 msg <<
"failed to save file";
376 template<
class Derived>
387 template<
class Derived>
394 template<
class Derived>
401 template<
class Derived>
403 const std::string& mode,
406 YAT_ASSERT(aux==NULL);
411 template<
class Derived>
413 const std::string& mode)
417 sf_ = sam_open(fn.c_str(), mode.c_str());
419 std::ostringstream ss;
420 ss <<
"failed open '" << fn <<
"'";
void write(const BamRead &read)
write a read to output file
virtual ~InBamFile(void)
destructor
void build_index(void) const
uint64_t n_no_coordinate(void) const
The Department of Theoretical Physics namespace as we define it.
void open_base(const std::string &fn, const std::string &mode, const void *aux)
Definition: BamFile.h:402
Error thrown from OutBamFile::write(const BamRead&) at failure.
Definition: BamFile.h:322
BamFile(void)
Definition: BamFile.h:347
Class holding a bam query.
Definition: BamRead.h:51
const index_type * index(void) const
const std::string & filename(void) const
filename of bam file
Definition: BamFile.h:122
bool is_open(void) const
Definition: BamFile.h:388
void open(const std::string &fn)
Open an input bam file.
bool have_index(void) const
Definition: BamFile.h:395
const BamRead & read(void) const
void build_index(void) const
Class used for all runtime error detected within yat library.
Definition: Exception.h:53
samFile * sf_
Definition: BamFile.h:115
uint64_t n_unmapped(int tid) const
void build_index_base(void) const
Definition: BamFile.h:359
virtual ~error(void)
Destructor.
InBamFile(void)
Default constructor.
Class to report errors associated with IO operations.
Definition: Exception.h:124
bool exists(void) const
Check whether file exists.
void close(void)
close file
Definition: BamFile.h:377
virtual ~BamFile(void)
Destructor.
Definition: BamFile.h:352
Definition: BamFile.h:245
void open(const std::string &fn, const BamHeader &hdr)
Open an output bam file.
Definition: BamFile.h:134
hts_idx_t index_type
Definition: BamFile.h:147
error(const BamRead &)
Constructor.
const BamHeader & header(void) const
uint64_t n_mapped(int tid) const
Checking file/directory existence and access permissions.
Definition: FileUtil.h:43
bool read(BamRead &read)
read the next BamRead