libStatGen Software 1
GlfRefSection.h
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GLF_REFSECTION_H__
19#define __GLF_REFSECTION_H__
20
21#include <stdint.h>
22
23#include "InputFile.h"
24#include "CharBuffer.h"
25
26///This class allows a user to easily get/set the fields in a
27/// GLF section/chromosome header.
28/// The GlfRefSection contains:
29/// - Reference Sequence Name
30/// - Reference Sequence Length
32{
33public:
36
37 /// Copy Constructor
38 /// \param refSection reference section to copy into this one.
39 GlfRefSection(const GlfRefSection& refSection);
40
41 /// Overload operator= to copy the passed in refSection into this one.
42 /// \param refSection reference section to copy into this one.
43 GlfRefSection & operator = (const GlfRefSection& refSection);
44
45 /// Copy the passed in refSection into this refSection.
46 /// \param refSection reference section to copy into this one.
47 bool copy(const GlfRefSection& refSection);
48
49 /// Clear this reference section back to the default setting.
50 void resetRefSection();
51
52 /// Read the refSection from the specified file (file MUST be in
53 /// the correct position for reading a refSection).
54 /// \param filePtr file to read from that is in the correct position.
55 /// \return true if the reference section was successfully read from the
56 /// file, false if not.
57 bool read(IFILE filePtr);
58
59 /// Write the refSection to the specified file.
60 /// \param filePtr file to write to that is in the correct position.
61 /// \return true if the reference section was successfully written to the
62 /// file, false if not.
63 bool write(IFILE filePtr) const;
64
65 /////////////
66 // Accessors.
67
68 /// Get the reference name.
69 /// \param name string to populate with the reference name.
70 /// \return true if the name was successfully returned, false if not.
71 bool getName(std::string& name) const;
72
73 /// Get the length of the reference sequence.
74 /// \return reference sequence length for this reference section.
75 uint32_t getRefLen() const;
76
77 /// Set the reference name.
78 /// \param name reference name to set this section to.
79 /// \return true if the name was successfully set, false if not.
80 bool setName(const std::string& name);
81 /// Set the length of the reference sequence.
82 /// \param refLen reference sequence length to set this section to.
83 /// \return true if the length was successfully set, false if not.
84 bool setRefLen(uint32_t refLen);
85
86 /// Print the reference section in a readable format.
87 void print() const;
88
89private:
90 CharBuffer myRefName;
91 uint32_t myRefLen;
92};
93
94#endif
95
This class allows a user to easily get/set the fields in a GLF section/chromosome header.
Definition: GlfRefSection.h:32
void resetRefSection()
Clear this reference section back to the default setting.
bool setName(const std::string &name)
Set the reference name.
bool copy(const GlfRefSection &refSection)
Copy the passed in refSection into this refSection.
bool read(IFILE filePtr)
Read the refSection from the specified file (file MUST be in the correct position for reading a refSe...
GlfRefSection & operator=(const GlfRefSection &refSection)
Overload operator= to copy the passed in refSection into this one.
void print() const
Print the reference section in a readable format.
bool write(IFILE filePtr) const
Write the refSection to the specified file.
bool setRefLen(uint32_t refLen)
Set the length of the reference sequence.
uint32_t getRefLen() const
Get the length of the reference sequence.
bool getName(std::string &name) const
Get the reference name.
Class for easily reading/writing files without having to worry about file type (uncompressed,...
Definition: InputFile.h:37