multovl  1.3
Multiple overlaps of genomic regions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
linewriter.hh
Go to the documentation of this file.
1 /* <LICENSE>
2 License for the MULTOVL multiple genomic overlap tools
3 
4 Copyright (c) 2007-2012, Dr Andras Aszodi,
5 Campus Science Support Facilities GmbH (CSF),
6 Dr-Bohr-Gasse 3, A-1030 Vienna, Austria, Europe.
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are
11 met:
12 
13  * Redistributions of source code must retain the above copyright notice,
14  this list of conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice,
16  this list of conditions and the following disclaimer in the documentation
17  and/or other materials provided with the distribution.
18  * Neither the name of the Campus Science Support Facilities GmbH
19  nor the names of its contributors may be used to endorse
20  or promote products derived from this software without specific prior
21  written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
24 AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
27 THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 </LICENSE> */
35 #ifndef LINEWRITER_HEADER
36 #define LINEWRITER_HEADER
37 
38 // == HEADER linewriter.hh ==
39 
47 // -- Standard headers --
48 
49 #include <string>
50 #include <sstream>
51 
52 namespace multovl {
53 
54 class Region;
55 class MultiRegion;
56 
57 namespace io {
58 
63 {
64  public:
65 
69  explicit Linewriter(const std::string& chrom);
70 
71  virtual ~Linewriter() {}
72 
76  virtual std::string write(const Region& reg) = 0;
77 
81  virtual std::string write(const MultiRegion& reg) = 0;
82 
83  protected:
84 
85  void reset() { _ostr.clear(); _ostr.str(""); }
86 
87  std::string _chr;
88  std::ostringstream _ostr;
89 
90 };
91 
98 {
99  public:
100 
105  explicit BedLinewriter(const std::string& chrom):
106  Linewriter(chrom) {}
107 
113  virtual std::string write(const Region& reg);
114 
120  virtual std::string write(const MultiRegion& reg);
121 };
122 
129 {
130  public:
131 
138  GffLinewriter(const std::string& source, unsigned int version,
139  const std::string& chrom);
140 
146  virtual std::string write(const Region& region);
147 
153  virtual std::string write(const MultiRegion& region);
154 
155  // Accessors
156 
157  const std::string& source() const { return _source; }
158  unsigned int version() const { return _version; }
159 
160  private:
161 
162  std::string _source;
163  unsigned int _version; // 2 or 3
164  char _sep; // ' ' for version 2, '=' for version 3
165 };
166 
167 } // namespace io
168 } // namespace multovl
169 
170 #endif // MULTOVL_LINEWRITER_HEADER
virtual std::string write(const Region &region)
BedLinewriter(const std::string &chrom)
Definition: linewriter.hh:105
Linewriter for GFF-formatted lines. The GffLinewriter class understands Versions 2 and 3 of the GFF f...
Definition: linewriter.hh:128
virtual std::string write(const Region &reg)=0
Definition: multiregion.hh:62
Linewriter for BED-formatted lines. The BedLinewriter writes columns 1 to 6 of the BED format specifi...
Definition: linewriter.hh:97
Instances of the Region class represent regions on a sequence. They have first and last coordinates...
Definition: region.hh:65
Base class of stringifier objects.
Definition: linewriter.hh:62
virtual std::string write(const Region &reg)
Linewriter(const std::string &chrom)
GffLinewriter(const std::string &source, unsigned int version, const std::string &chrom)