bpp-seq-omics  2.2.0
OutputAlignmentMafIterator.h
Go to the documentation of this file.
1 //
2 // File: OutputAlignmentMafIterator.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 _OUTPUTALIGNMENTMAFITERATOR_H_
41 #define _OUTPUTALIGNMENTMAFITERATOR_H_
42 
43 #include "MafIterator.h"
44 
45 //From bpp-seq:
46 #include <Bpp/Seq/Io/OSequence.h>
47 
48 //From the STL:
49 #include <iostream>
50 #include <string>
51 #include <deque>
52 
53 namespace bpp {
54 
61 {
62  private:
63  std::ostream* output_;
64  std::string file_;
65  bool mask_;
66  std::auto_ptr<OAlignment> writer_;
67  unsigned int currentBlockIndex_;
68 
69  public:
81  OutputAlignmentMafIterator(MafIterator* iterator, std::ostream* out, OAlignment* writer, bool mask = true) :
82  AbstractFilterMafIterator(iterator), output_(out), file_(), mask_(mask), writer_(writer), currentBlockIndex_(0)
83  {
84  if (!writer)
85  throw Exception("OutputAlignmentMafIterator (constructor 1): sequence writer should not be a NULL pointer!");
86  }
87 
100  OutputAlignmentMafIterator(MafIterator* iterator, const std::string& file, OAlignment* writer, bool mask = true) :
101  AbstractFilterMafIterator(iterator), output_(0), file_(file), mask_(mask), writer_(writer), currentBlockIndex_(0)
102  {
103  if (!writer)
104  throw Exception("OutputAlignmentMafIterator (constructor 2): sequence writer should not be a NULL pointer!");
105  }
106 
108 
109  private:
112  output_(iterator.output_),
113  file_(iterator.file_),
114  mask_(iterator.mask_),
115  writer_(),
117  {}
118 
120  {
121  output_ = iterator.output_;
122  file_ = iterator.file_;
123  mask_ = iterator.mask_;
124  writer_.release();
126  return *this;
127  }
128 
129 
130  private:
131  MafBlock* analyseCurrentBlock_() throw (Exception);
132 
133  void writeBlock(std::ostream& out, const MafBlock& block) const;
134 };
135 
136 } // end of namespace bpp.
137 
138 #endif //_OUTPUTALIGNMENTMAFITERATOR_H_
OutputAlignmentMafIterator(MafIterator *iterator, std::ostream *out, OAlignment *writer, bool mask=true)
Creates a new OutputAlignmentMafIterator object.
STL namespace.
A synteny block data structure, the basic unit of a MAF alignement file.
Definition: MafBlock.h:55
OutputAlignmentMafIterator(const OutputAlignmentMafIterator &iterator)
Interface to loop over maf alignment blocks.
Definition: MafIterator.h:58
OutputAlignmentMafIterator & operator=(const OutputAlignmentMafIterator &iterator)
OutputAlignmentMafIterator(MafIterator *iterator, const std::string &file, OAlignment *writer, bool mask=true)
Creates a new OutputAlignmentMafIterator object.
void writeBlock(std::ostream &out, const MafBlock &block) const
Helper class for developping filter for maf blocks.
Definition: MafIterator.h:149
This iterator forward the iterator given as input after having printed its content to an alignment fi...