Changeset 3358
- Timestamp:
- Nov 23, 2014, 8:02:26 AM (8 years ago)
- Location:
- trunk/yat/omic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/omic/BamFile.cc
r3357 r3358 125 125 bool InBamFile::read(BamRead& read, hts_itr_t* iter) 126 126 { 127 assert(0 && "FIXME"); 128 int result_ = -1; 127 int result = sam_itr_next(sf_, iter, read.bam_); 129 128 #else 130 129 bool InBamFile::read(BamRead& read, bam_iter_t iter) 131 130 { 132 131 assert(sf_->type & 1); // no random access from sam files 133 int result _= bam_iter_read(sf_->x.bam, iter, read.bam_);134 #endif 135 if (result _<-1) {132 int result = bam_iter_read(sf_->x.bam, iter, read.bam_); 133 #endif 134 if (result<-1) { 136 135 std::ostringstream ss; 137 136 ss << "read(2): invalid bam file '" << filename() << "'"; 138 if (result _== -2)137 if (result == -2) 139 138 ss << " truncated file"; 140 139 else 141 ss << " error: " << result _;140 ss << " error: " << result; 142 141 throw utility::runtime_error(ss.str()); 143 142 } 144 return result _>=0;143 return result>=0; 145 144 } 146 145 -
trunk/yat/omic/BamHeader.cc
r3352 r3358 40 40 41 41 42 void BamHeader::parse_region(const std::string& reg, int& tid, int& begin,42 void BamHeader::parse_region(const std::string& reg, int& id, int& begin, 43 43 int& end) const 44 44 { 45 45 assert(header_); 46 46 #if YAT_HAVE_HTSLIB 47 assert(0 && "FIXME: parse_region not implement against htslib"); 47 const char* b = reg.c_str(); 48 const char* e = hts_parse_reg(b, &begin, &end); 49 // If begin > end suggests something is wrong and that is also how 50 // bam_parse_region (below in samtools impl) used to detect error 51 // and return non-zero. 52 if (begin<=end) { 53 std::string chr = reg.substr(0, e-b); 54 try { 55 id = tid(chr); 56 return; 57 } 58 catch (utility::runtime_error& e) { 59 ; // throw below instead 60 } 61 } 48 62 #else 49 if (!bam_parse_region(header_, reg.c_str(), & tid, &begin, &end))63 if (!bam_parse_region(header_, reg.c_str(), &id, &begin, &end)) 50 64 return; 51 65 #endif … … 73 87 { 74 88 #if YAT_HAVE_HTSLIB 75 return bam_name2id(header_, name.c_str()); 89 int res = bam_name2id(header_, name.c_str()); 90 if (res==-1) { 91 std::string msg("invalid segment name:"); 92 msg += name; 93 throw utility::runtime_error(msg); 94 } 95 return res; 76 96 #else 77 97 if (!header_->hash) { -
trunk/yat/omic/BamReadIterator.cc
r3353 r3358 113 113 { 114 114 #if YAT_HAVE_HTSLIB 115 hts_itr_t* it = hts_itr_query(bf.index(), tid, begin, end, NULL);115 hts_itr_t* it = sam_itr_queryi(bf.index(), tid, begin, end); 116 116 #else 117 117 bam_iter_t it = bam_iter_query(bf.index(), tid, begin, end);
Note: See TracChangeset
for help on using the changeset viewer.