Changeset 3306
- Timestamp:
- Aug 21, 2014, 6:37:21 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/0.12-stable merged: 3296,3300-3304
- Property svn:mergeinfo changed
-
trunk/NEWS
r3295 r3306 12 12 13 13 yat 0.12.x series from http://dev.thep.lu.se/yat/svn/branches/0.12-stable 14 15 version 0.12.1 (released 21 August 2014) 16 - bam_calend is buggy in older versions of samtools; configure 17 script checks that bam_calend works as expected; if not use its 18 own implementation (see bug #810) 19 20 A complete list of closed tickets can be found here [[br]] 21 http://dev.thep.lu.se/yat/query?status=closed&milestone=yat+0.12.1 14 22 15 23 version 0.12 (released 25 July 2014) -
trunk/configure.ac
r3295 r3306 383 383 # check if global variable bam_nt16_rev_table is available 384 384 YAT_BAM_NT16_REV_TABLE 385 # check if function bam_calend works. Result of this test can be 386 # overridden by setting variable 'yat_cv_func_bam_calend' 387 YAT_FUNC_BAM_CALEND([$srcdir/test/data/foo.sam]) 385 388 AC_PATH_PROG([SAMTOOLS], [samtools], [false]) 386 389 AC_ARG_VAR([SAMTOOLS], [Tools for alignment in the SAM format]) -
trunk/m4/version.m4
r3220 r3306 77 77 # yat-0.11.2 8:2:0 78 78 # yat-0.12 9:0:0 79 # yat-0.12.1 9:1:0 79 80 # 80 81 # *Accidently, the libtool number was not updated for yat 0.5 -
trunk/m4/yat_check_libbam.m4
r3130 r3306 1 1 ## $Id$ 2 2 # 3 # serial 4 (yat 0.11)3 # serial 5 (yat 0.12.1) 4 4 # 5 5 # 6 # Copyright (C) 2012, 2013 Peter Johansson6 # Copyright (C) 2012, 2013, 2014 Peter Johansson 7 7 # 8 8 # This file is part of the yat library, http://dev.thep.lu.se/yat … … 107 107 108 108 109 # YAT_FUNC_BAM_CALEND(SAM_FILE) 110 # =================== 111 # Check if there is a bam_calend that works 112 AC_DEFUN([YAT_FUNC_BAM_CALEND], 113 [ 114 AC_CACHE_CHECK([for working bam_calend], 115 [yat_cv_func_bam_calend], 116 [AC_RUN_IFELSE( 117 [AC_LANG_PROGRAM( 118 [_YAT_BAM_INCLUDES], 119 [ 120 samfile_t* samfile = samopen("$1", "r", NULL); 121 if (!samfile) 122 return 1; 123 bam1_t* read = bam_init1(); 124 while (samread(samfile, read) >= -1) { 125 bool have_match = false; 126 if (read->core.n_cigar < 1) 127 continue; 128 uint32_t end = bam_calend(&read->core, bam1_cigar(read)); 129 // replace BAM_CMATCH with BAM_CEQUAL in cigar 130 for (size_t k=0; k<read->core.n_cigar; ++k) { 131 uint32_t& element = bam1_cigar(read)@<:@k@:>@; 132 uint32_t op = element & BAM_CIGAR_MASK; 133 if (op == BAM_CMATCH) { 134 have_match = true; 135 uint32_t oplen = element >> BAM_CIGAR_SHIFT; 136 element = oplen<<BAM_CIGAR_SHIFT|BAM_CEQUAL; 137 } 138 } 139 // if no match element found, next read please 140 if (!have_match) 141 continue; 142 // bam_calend works on BAM_CEQUAL 143 if (bam_calend(&read->core, bam1_cigar(read)) == end) 144 return 0; 145 // bam_calend is not working as expected 146 return 2; 147 } 148 // end of data, fail 149 return 3; 150 ]) 151 ], 152 [yat_cv_func_bam_calend=yes], 153 [yat_cv_func_bam_calend=no], 154 [yat_cv_func_bam_calend="guessing no"]) 155 ]) 156 AS_IF([test x"$yat_cv_func_bam_calend" = x"yes"],[ 157 AC_DEFINE([HAVE_BAM_CALEND], [1], [Define to 1 if bam_calend is working]) 158 ]) 159 ]) 160 161 109 162 # _YAT_BAM_INCLUDES 110 163 # ================= … … 114 167 @%:@if YAT_HAVE_BAM_H 115 168 @%:@ include <bam.h> 169 @%:@ include <sam.h> 116 170 @%:@elif YAT_HAVE_BAM_BAM_H 117 171 @%:@ include <bam/bam.h> 172 @%:@ include <bam/sam.h> 118 173 @%:@elif YAT_HAVE_SAMTOOLS_BAM_H 119 174 @%:@ include <samtools/bam.h> 175 @%:@ include <samtools/sam.h> 120 176 @%:@endif 121 177 ]) # _YAT_BAM_HEADER -
trunk/test/bam.cc
r3295 r3306 120 120 121 121 122 void test_end(test::Suite& suite, BamRead bam) 123 { 124 suite.out() << "test end:\n"; 125 suite.out() << bam.pos() << "-" << bam.end() << " " << bam.cigar_str() 126 << "\n"; 127 uint32_t end = bam.end(); 128 if (!suite.add(end==24093)) { 129 suite.err() << "error: incorrect end: " << end << "\n"; 130 } 131 132 // change the cigar to include a DIFF and EQUAL 133 utility::Aligner::Cigar cig; 134 cig.push_back(BAM_CEQUAL, 55); 135 cig.push_back(BAM_CDIFF, 1); 136 cig.push_back(BAM_CEQUAL, 44); 137 bam.cigar(cig); 138 suite.out() << bam.pos() << "-" << bam.end() << " " << bam.cigar_str() 139 << "\n"; 140 end = bam.end(); 141 if (!suite.add(end==24093)) { 142 suite.err() << "error: incorrect end: " << end << "\n"; 143 } 144 } 145 146 122 147 void test_sequence(test::Suite& suite, const BamRead& b) 123 148 { … … 234 259 in.read(bam); 235 260 // test that functions are implemented 236 bam.end();261 test_end(suite, bam); 237 262 bam.flag(); 238 263 bam.mpos(); -
trunk/yat/omic/BamRead.cc
r3295 r3306 107 107 assert(bam_); 108 108 return bam_->l_aux; 109 } 110 111 112 uint32_t BamRead::calend(const bam1_core_t *c, const uint32_t *cigar) const 113 { 114 #ifdef HAVE_BAM_CALEND 115 return bam_calend(&core(), bam1_cigar(bam_)); 116 #endif 117 int k, end = c->pos; 118 for (k = 0; k < c->n_cigar; ++k) { 119 int op = bam_cigar_op(cigar[k]); 120 int len = bam_cigar_oplen(cigar[k]); 121 if (op == BAM_CBACK) { // move backward 122 int l, u, v; 123 if (k == c->n_cigar - 1) break; // skip trailing 'B' 124 for (l = k - 1, u = v = 0; l >= 0; --l) { 125 int op1 = bam_cigar_op(cigar[l]); 126 int len1 = bam_cigar_oplen(cigar[l]); 127 if (bam_cigar_type(op1)&1) { // consume query 128 if (u + len1 >= len) { // stop 129 if (bam_cigar_type(op1)&2) v += len - u; 130 break; 131 } else u += len1; 132 } 133 if (bam_cigar_type(op1)&2) v += len1; 134 } 135 end = l < 0? c->pos : end - v; 136 } else if (bam_cigar_type(op)&2) end += bam_cigar_oplen(cigar[k]); 137 } 138 return end; 109 139 } 110 140 … … 186 216 bam1_core_t& BamRead::core(void) 187 217 { return bam_->core; } 218 219 220 int32_t BamRead::end(void) const 221 { 222 assert(bam_); 223 return this->calend(&core(), bam1_cigar(bam_)); 224 } 188 225 189 226 … … 328 365 329 366 330 int32_t BamRead::end(void) const331 {332 assert(bam_);333 return bam_calend(&core(), bam1_cigar(bam_));334 }335 336 337 367 void BamRead::swap(BamRead& other) 338 368 { -
trunk/yat/omic/BamRead.h
r3295 r3306 309 309 friend class OutBamFile; 310 310 friend class BamReadIterator; 311 uint32_t calend(const bam1_core_t *c, const uint32_t *cigar) const; 311 312 }; 312 313 -
trunk/yat/utility/Cigar.h
r3213 r3306 56 56 /// \abstract CIGAR: X = mismatch 57 57 #define BAM_CDIFF 8 58 #define BAM_CBACK 959 58 #endif // end of YAT_HAVE_LIBBAM 59 60 // BAM_CBACK is not defined in old versions of bam.h 61 #ifndef BAM_CBACK 62 #define BAM_CBACK 9 63 #endif 60 64 61 65 // backport #defines from samtools 0.1.19
Note: See TracChangeset
for help on using the changeset viewer.