source: trunk/yat/omic/CigarIterator.cc @ 3329

Last change on this file since 3329 was 3329, checked in by Peter, 7 years ago

new class CigarIterator? that can be used to (surprise) iterate over a CIGAR.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1// $Id: CigarIterator.cc 3329 2014-10-12 08:25:00Z peter $
2
3/*
4  Copyright (C) 2014 Peter Johansson
5
6  This file is part of the yat library, http://dev.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with yat. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include <config.h>
23
24#include "CigarIterator.h"
25
26#include "yat/utility/Cigar.h"
27
28#include <cassert>
29
30namespace theplu {
31namespace yat {
32namespace omic {
33
34  CigarIterator::CigarIterator(void)
35    : base_(NULL) {}
36
37
38  CigarIterator::CigarIterator(const uint32_t* p, size_t x)
39    : base_(p), index_(x) {}
40
41
42  void CigarIterator::decrement(void)
43  {
44    if (index_)
45      --index_;
46    else {
47      --base_;
48      index_ = bam_cigar_oplen(*base_)-1;
49    }
50  }
51
52
53  CigarIterator::reference CigarIterator::dereference(void) const
54  {
55    return bam_cigar_op(*base_);
56  }
57
58
59  bool CigarIterator::equal(const CigarIterator& other) const
60  {
61    return base_==other.base_ && index_==other.index_;
62  }
63
64
65  void CigarIterator::increment(void)
66  {
67    if (++index_ == bam_cigar_oplen(*base_)) {
68      index_=0;
69      ++base_;
70    }
71  }
72
73}}}
Note: See TracBrowser for help on using the repository browser.