bpp-seq-omics  2.2.0
AlignmentFilterMafIterator.h
Go to the documentation of this file.
1 //
2 // File: AlignmentFilterMafIterator.h
3 // Authors: Julien Dutheil
4 // Created: Tue Sep 07 2010
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (2010)
9 
10 This software is a computer program whose purpose is to provide classes
11 for sequences analysis.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _ALIGNMENTFILTERMAFITERATOR_H_
41 #define _ALIGNMENTFILTERMAFITERATOR_H_
42 
43 #include "MafIterator.h"
44 
45 //From the STL:
46 #include <iostream>
47 #include <string>
48 #include <deque>
49 
50 namespace bpp {
51 
65  public virtual MafTrashIterator
66 {
67  private:
68  std::vector<std::string> species_;
69  unsigned int windowSize_;
70  unsigned int step_;
71  unsigned int maxGap_;
72  double maxEnt_;
73  std::deque<MafBlock*> blockBuffer_;
74  std::deque<MafBlock*> trashBuffer_;
75  std::deque< std::vector<int> > window_;
78 
79  public:
81  const std::vector<std::string>& species,
82  unsigned int windowSize,
83  unsigned int step,
84  unsigned int maxGap,
85  double maxEnt,
86  bool keepTrashedBlocks,
87  bool missingAsGap) :
88  AbstractFilterMafIterator(iterator),
89  species_(species),
90  windowSize_(windowSize),
91  step_(step),
92  maxGap_(maxGap),
93  maxEnt_(maxEnt),
94  blockBuffer_(),
95  trashBuffer_(),
96  window_(species.size()),
97  keepTrashedBlocks_(keepTrashedBlocks),
98  missingAsGap_(missingAsGap)
99  {}
100 
101  public:
102  MafBlock* nextRemovedBlock() throw (Exception) {
103  if (trashBuffer_.size() == 0) return 0;
104  MafBlock* block = trashBuffer_.front();
105  trashBuffer_.pop_front();
106  return block;
107  }
108 
109  private:
110  MafBlock* analyseCurrentBlock_() throw (Exception);
111 };
112 
123  public virtual MafTrashIterator
124 {
125  private:
126  std::vector<std::string> species_;
127  unsigned int windowSize_;
128  unsigned int step_;
129  unsigned int maxGap_;
130  unsigned int maxPos_;
131  std::deque<MafBlock*> blockBuffer_;
132  std::deque<MafBlock*> trashBuffer_;
133  std::deque< std::vector<bool> > window_;
136 
137  public:
138  AlignmentFilter2MafIterator(MafIterator* iterator, const std::vector<std::string>& species, unsigned int windowSize, unsigned int step, unsigned int maxGap, unsigned int maxPos, bool keepTrashedBlocks, bool missingAsGap) :
139  AbstractFilterMafIterator(iterator),
140  species_(species),
141  windowSize_(windowSize),
142  step_(step),
143  maxGap_(maxGap),
144  maxPos_(maxPos),
145  blockBuffer_(),
146  trashBuffer_(),
147  window_(species.size()),
148  keepTrashedBlocks_(keepTrashedBlocks),
149  missingAsGap_(missingAsGap)
150  {}
151 
152  public:
153  MafBlock* nextRemovedBlock() throw (Exception) {
154  if (trashBuffer_.size() == 0) return 0;
155  MafBlock* block = trashBuffer_.front();
156  trashBuffer_.pop_front();
157  return block;
158  }
159 
160  private:
161  MafBlock* analyseCurrentBlock_() throw (Exception);
162 
163 };
164 
165 } // end of namespace bpp.
166 
167 #endif //_ALIGNMENTFILTERMAFITERATOR_H_
AlignmentFilterMafIterator(MafIterator *iterator, const std::vector< std::string > &species, unsigned int windowSize, unsigned int step, unsigned int maxGap, double maxEnt, bool keepTrashedBlocks, bool missingAsGap)
Filter maf blocks to remove ambiguously aligned or non-informative regions.
MafBlock * nextRemovedBlock()
Get the next available removed alignment block.
AlignmentFilter2MafIterator(MafIterator *iterator, const std::vector< std::string > &species, unsigned int windowSize, unsigned int step, unsigned int maxGap, unsigned int maxPos, bool keepTrashedBlocks, bool missingAsGap)
Filter maf blocks to remove ambiguously aligned or non-informative regions.
MafBlock * nextRemovedBlock()
Get the next available removed alignment block.
A synteny block data structure, the basic unit of a MAF alignement file.
Definition: MafBlock.h:55
Interface to loop over removed blocks of a maf alignment.
Definition: MafIterator.h:130
Interface to loop over maf alignment blocks.
Definition: MafIterator.h:58
std::deque< std::vector< bool > > window_
std::deque< std::vector< int > > window_
Helper class for developping filter for maf blocks.
Definition: MafIterator.h:149