1 /*  $Id: bed_line_reader.hpp 629256 2021-04-13 13:28:19Z ivanov $
2 * ===========================================================================
3 *
4 *                            PUBLIC DOMAIN NOTICE
5 *               National Center for Biotechnology Information
6 *
7 *  This software/database is a "United States Government Work" under the
8 *  terms of the United States Copyright Act.  It was written as part of
9 *  the author's official duties as a United States Government employee and
10 *  thus cannot be copyrighted.  This software/database is freely available
11 *  to the public for use. The National Library of Medicine and the U.S.
12 *  Government have not placed any restriction on its use or reproduction.
13 *
14 *  Although all reasonable efforts have been taken to ensure the accuracy
15 *  and reliability of the software and data, the NLM and the U.S.
16 *  Government do not and cannot warrant the performance or results that
17 *  may be obtained by using this software or data. The NLM and the U.S.
18 *  Government disclaim all warranties, express or implied, including
19 *  warranties of performance, merchantability or fitness for any particular
20 *  purpose.
21 *
22 *  Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author:  Frank Ludwig, NCBI
27 *
28 * File Description:
29 *   Scanner for BED input data.
30 *
31 * ===========================================================================
32 */
33 
34 #ifndef BED_LINE_READER__HPP
35 #define BED_LINE_READER__HPP
36 
37 #include <corelib/ncbifile.hpp>
38 #include <util/line_reader.hpp>
39 
40 #include "feat_line_reader.hpp"
41 #include "bed_import_data.hpp"
42 
43 BEGIN_NCBI_SCOPE
44 BEGIN_objects_SCOPE
45 
46 //  ============================================================================
47 class CBedLineReader:
48     public CFeatLineReader
49 //  ============================================================================
50 {
51 public:
52     CBedLineReader(
53         CImportMessageHandler&);
54 
~CBedLineReader()55     virtual ~CBedLineReader() {};
56 
57     bool
58     GetNextRecord(
59         CStreamLineReader&,
60         CFeatImportData&) override;
61 
62     void
63     SetInputStream(
64         CNcbiIstream&,
65         bool = false) override;
66 
67 private:
68     bool
69     xIgnoreLine(
70         const string&) const override;
71 
72     bool
73     xProcessTrackLine(
74         const string&);
75 
76     void
77     xSplitLine(
78         const std::string&,
79         std::vector<std::string>&);
80 
81     void
82     xInitializeRecord(
83         const std::vector<std::string>&,
84         CFeatImportData&) override;
85 
86     void
87     xInitializeChromInterval(
88         const std::vector<std::string>&,
89         std::string&,
90         TSeqPos&,
91         TSeqPos&,
92         ENa_strand&);
93 
94     void
95     xInitializeChromName(
96         const std::vector<std::string>&,
97         std::string&);
98 
99     void
100     xInitializeScore(
101         const std::vector<string>&,
102         double&);
103 
104     void
105     xInitializeThickInterval(
106         const std::vector<std::string>&,
107         TSeqPos&,
108         TSeqPos&);
109 
110     void
111     xInitializeRgb(
112         const std::vector<string>&,
113         CBedImportData::RgbValue&);
114     void
115     xInitializeRgbFromScoreColumn(
116         const std::vector<string>&,
117         CBedImportData::RgbValue&);
118     void
119     xInitializeRgbFromRgbColumn(
120         const std::vector<string>&,
121         CBedImportData::RgbValue&);
122     void
123     xInitializeRgbFromStrandColumn(
124         const std::vector<string>&,
125         CBedImportData::RgbValue&);
126 
127     void
128     xInitializeBlocks(
129         const std::vector<string>&,
130         unsigned int& blockCount,
131         std::vector<int>& blockStarts,
132         std::vector<int>& blockSizes);
133 
134 	size_t mColumnCount;
135     std::string mColumnDelimiter;
136     int mSplitFlags;
137     bool mUseScore;
138     bool mItemRgb;
139     bool mColorByStrand;
140     CBedImportData::RgbValue mRgbStrandPlus;
141     CBedImportData::RgbValue mRgbStrandMinus;
142 };
143 
144 END_objects_SCOPE
145 END_NCBI_SCOPE
146 
147 #endif
148