- Timestamp:
- Mar 14, 2017, 8:05:31 AM (6 years ago)
- Location:
- trunk/yat/omic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/omic/BamFile.cc
r3579 r3630 274 274 if (!h.header_) 275 275 throw utility::runtime_error("OutBamFile::open with null header"); 276 #if YAT_HAVE_HTSLIB 277 open_base(fn, "wb", NULL); 278 sam_hdr_write(sf_, h.header_); 279 #else 280 open_base(fn, "wb", h.header_); 281 #endif 276 open(fn, std::string("wb"), h); 282 277 } 283 278 … … 298 293 else 299 294 mode = "wu"; 295 #else 296 mode.push_back('0'+compression); 297 #endif 298 open(fn, mode, h); 299 } 300 301 302 void OutBamFile::open(const std::string& fn, const std::string& mode, 303 const BamHeader& h) 304 { 305 #if YAT_HAVE_HTSLIB 300 306 open_base(fn, mode, NULL); 301 sam_hdr_write(sf_, h.header_); 302 #else 303 mode.push_back('0'+compression); 307 if (sam_hdr_write(sf_, h.header_)) { 308 std::ostringstream ss; 309 ss << "failed open '" << fn << "'"; 310 throw utility::runtime_error(ss.str()); 311 } 312 #else 304 313 open_base(fn, mode, h.header_); 305 314 #endif -
trunk/yat/omic/BamFile.h
r3550 r3630 318 318 319 319 private: 320 void open(const std::string& fn, const std::string& mode, 321 const BamHeader& h); 322 320 323 }; 321 324 -
trunk/yat/omic/BamRead.cc
r3584 r3630 262 262 data_size() += offset; 263 263 core().n_cigar = c.size(); 264 assert( data_size() <= bam_->m_data);264 assert(static_cast<uint32_t>(data_size()) <= data_capacity()); 265 265 } 266 266 … … 272 272 bam1_core_t& BamRead::core(void) 273 273 { return bam_->core; } 274 275 276 uint32_t BamRead::data_capacity(void) const 277 { 278 return bam_->m_data; 279 } 274 280 275 281 … … 329 335 memcpy(bam1_qname(bam_), n.c_str(), n.size()+1); 330 336 data_size() += offset; 331 assert( data_size() <= bam_->m_data);337 assert(static_cast<uint32_t>(data_size()) <= data_capacity()); 332 338 } 333 339 … … 341 347 342 348 343 void BamRead::reserve( int n)344 { 345 assert(bam_); 346 if ( bam_->m_data >= n)349 void BamRead::reserve(uint32_t n) 350 { 351 assert(bam_); 352 if (data_capacity() >= static_cast<uint32_t>(n)) 347 353 return; 348 354 // at least double capacity 349 bam_->m_data = std::max( bam_->m_data<<1, n);355 bam_->m_data = std::max(data_capacity()<<1, n); 350 356 bam_->data = (uint8_t*)realloc(bam_->data, bam_->m_data); 351 357 if (!bam_->data) { -
trunk/yat/omic/BamRead.h
r3596 r3630 329 329 private: 330 330 // ensure capacity of data pointer is (at least) n 331 void reserve( int n);331 void reserve(uint32_t n); 332 332 333 333 bam1_t* bam_; … … 342 342 int& data_size(void); 343 343 const int& data_size(void) const; 344 uint32_t data_capacity(void) const; 344 345 }; 345 346
Note: See TracChangeset
for help on using the changeset viewer.