Changeset 3300


Ignore:
Timestamp:
Aug 20, 2014, 7:43:27 AM (9 years ago)
Author:
Peter
Message:

BAM_CBACK is not #defined in older versions of bam.h. refs #810

Location:
branches/0.12-stable/yat
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/0.12-stable/yat/omic/BamRead.cc

    r3222 r3300  
    107107    assert(bam_);
    108108    return bam_->l_aux;
     109  }
     110
     111
     112  uint32_t BamRead::calend(const bam1_core_t *c, const uint32_t *cigar) const
     113  {
     114    int k, end = c->pos;
     115    for (k = 0; k < c->n_cigar; ++k) {
     116      int op  = bam_cigar_op(cigar[k]);
     117      int len = bam_cigar_oplen(cigar[k]);
     118      if (op == BAM_CBACK) { // move backward
     119        int l, u, v;
     120        if (k == c->n_cigar - 1) break; // skip trailing 'B'
     121        for (l = k - 1, u = v = 0; l >= 0; --l) {
     122          int op1  = bam_cigar_op(cigar[l]);
     123          int len1 = bam_cigar_oplen(cigar[l]);
     124          if (bam_cigar_type(op1)&1) { // consume query
     125            if (u + len1 >= len) { // stop
     126              if (bam_cigar_type(op1)&2) v += len - u;
     127              break;
     128            } else u += len1;
     129          }
     130          if (bam_cigar_type(op1)&2) v += len1;
     131        }
     132        end = l < 0? c->pos : end - v;
     133      } else if (bam_cigar_type(op)&2) end += bam_cigar_oplen(cigar[k]);
     134    }
     135    return end;
    109136  }
    110137
     
    186213  bam1_core_t& BamRead::core(void)
    187214  { return bam_->core; }
     215
     216
     217  int32_t BamRead::end(void) const
     218  {
     219    assert(bam_);
     220    return this->calend(&core(), bam1_cigar(bam_));
     221  }
    188222
    189223
     
    328362
    329363
    330   int32_t BamRead::end(void) const
    331   {
    332     assert(bam_);
    333     return bam_calend(&core(), bam1_cigar(bam_));
    334   }
    335 
    336 
    337364  void BamRead::swap(BamRead& other)
    338365  {
  • branches/0.12-stable/yat/omic/BamRead.h

    r3222 r3300  
    309309    friend class OutBamFile;
    310310    friend class BamReadIterator;
     311    // FIXME guard out this
     312    uint32_t calend(const bam1_core_t *c, const uint32_t *cigar) const;
    311313  };
    312314
  • branches/0.12-stable/yat/utility/Cigar.h

    r3213 r3300  
    5959#endif // end of YAT_HAVE_LIBBAM
    6060
     61// CBACK is not defined in old versions of bam.h
     62#ifndef BAM_CBACK
     63#define BAM_CBACK 9
     64#endif
     65
    6166// backport #defines from samtools 0.1.19
    6267#ifndef BAM_CIGAR_STR
Note: See TracChangeset for help on using the changeset viewer.