Changeset 3213


Ignore:
Timestamp:
May 5, 2014, 9:51:59 AM (7 years ago)
Author:
Peter
Message:

three new cigar functions

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/cigar.cc

    r3201 r3213  
    7878  }
    7979
     80  if (!suite.add(cig.length()==17))
     81    suite.err() << "error: length: " << cig.length() << " expected 17\n";
     82  if (!suite.add(cig.query_length()==16))
     83    suite.err() << "error: query length: " << cig.query_length()
     84                << " expected 16\n";
     85  if (!suite.add(cig.reference_length()==17))
     86    suite.err() << "error: length: " << cig.reference_length()
     87                << " expected 17\n";
     88
    8089  if (!suite.add(cig.op(0)==0))
    8190    suite.err() << "error: cig.op(0): " << cig.op(0) << " expected 0\n";
  • trunk/yat/utility/Aligner.cc

    r3212 r3213  
    169169
    170170
     171  uint32_t Aligner::Cigar::length(uint8_t mask) const
     172  {
     173    uint32_t res = 0;
     174    for (size_t i=0; i<cigar_.size(); ++i)
     175      if (bam_cigar_type(op(i)) & mask)
     176        res += oplen(i);
     177    return res;
     178  }
     179
     180
     181  uint32_t Aligner::Cigar::length(void) const
     182  {
     183    return length(3);
     184  }
     185
     186
    171187  char Aligner::Cigar::opchr(size_t i) const
    172188  {
     
    238254
    239255
     256  uint32_t Aligner::Cigar::query_length(void) const
     257  {
     258    return length(1);
     259  }
     260
     261
     262  uint32_t Aligner::Cigar::reference_length(void) const
     263  {
     264    return length(2);
     265  }
     266
     267
    240268  size_t Aligner::Cigar::size(void) const
    241269  {
  • trunk/yat/utility/Aligner.h

    r3212 r3213  
    184184
    185185      /**
     186         Total length of operations counting operations that consume
     187         either (or both) query and reference e.g. match, insertion,
     188         or deletion. HardClip or Padding operations are ignored.
     189       */
     190      uint32_t length(void) const;
     191
     192      /**
    186193         See table in class documntation.
    187194
     
    226233
    227234      /**
     235         \brief Translate CIGAR to a query length.
     236
     237         Calculate total length of operations which consume a query
     238         e.g. match or insetion. See table in class documentation.
     239
     240         This is the same function as bam_cigar2qlen in samtools C
     241         API.
     242       */
     243      uint32_t query_length(void) const;
     244
     245      /**
     246         \brief Translate CIGAR to a reference length.
     247
     248         Calculate total length of operations which consume a reference
     249         e.g. match or deletion. See table in class documentation.
     250
     251         Similar to bam_calend but does not handle \c BAM_CBACK as it has
     252         not been included in SAM specification.
     253         http://sourceforge.net/p/samtools/mailman/message/29373646/
     254       */
     255      uint32_t reference_length(void) const;
     256
     257      /**
    228258         \return cigar element \a i
    229259       */
     
    237267      std::deque<uint32_t> cigar_;
    238268
     269      // calculate length only counting operations whose type is set
     270      // in mask, i.e., mask & type returns true
     271      uint32_t length(uint8_t mask) const;
    239272      // using compiler generated copy
    240273      // Cigar(const Cigar& other);
  • trunk/yat/utility/Cigar.h

    r3212 r3213  
    3030// allow inclusion of config_bam.h so this file is available also without bam.h
    3131#ifdef YAT_HAVE_LIBBAM
    32 #include "config_bam.h"
     32#include "yat/omic/config_bam.h"
    3333#include YAT_BAM_HEADER
    3434#else // if bam.h is not available #define CIGAR
Note: See TracChangeset for help on using the changeset viewer.