multovl  1.3
Multiple overlaps of genomic regions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
textio.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 MULTOVL_TEXTIO_HEADER
36 #define MULTOVL_TEXTIO_HEADER
37 
38 // == HEADER textio.hh ==
39 
46 // -- Standard headers --
47 
48 #include <string>
49 #include <vector>
50 
51 // -- Library headers --
52 
53 #include "trackio.hh"
54 #include "fileformat.hh"
55 
56 namespace multovl {
57 namespace io {
58 
59 class Linereader;
60 
66 class TextReader: public TrackReader
67 {
68 public:
69 
73  TextReader(
74  const std::string& infname,
75  Fileformat::Kind format);
76 
86  virtual
87  std::string read_into(std::string& chrom, Region& reg);
88 
89  ~TextReader();
90 
92  virtual
93  void add_error(const std::string& msg);
94 
95 private:
96 
97  bool is_valid() const { return _valid; }
98 
99  Linereader* _lrp; // can be BedLinereader or GffLinereader
100  std::ifstream _inf; // input file stream
101  std::string _line; // input buffer
102  unsigned int _linecount;
103  bool _valid;
104 
105 }; // END OF CLASS TextReader
106 
107 // -- Output --
108 
109 // Add code here if you want to do more complex output than the classic
110 // "write-GFF2-to-stdout" approach.
111 
112 } // namespace io
113 } // namespace multovl
114 
115 #endif // MULTOVL_TEXTIO_HEADER
virtual std::string read_into(std::string &chrom, Region &reg)
Definition: trackio.hh:69
virtual void add_error(const std::string &msg)
Adds an error message to _errors, nicely decorated with linecount.
Module to handle file format recognition.
Instances of the Region class represent regions on a sequence. They have first and last coordinates...
Definition: region.hh:65
Base class of parser objects. Linereader objects process one line at a time, and change their interna...
Definition: linereader.hh:75
TextReader(const std::string &infname, Fileformat::Kind format)
Definition: textio.hh:66
Base classes to read/write input/output tracks (collections of regions).