1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*
* Copyright (C) 2010-2011 Regents of the University of Michigan,
* Hyun Min Kang, Matthew Flickenger, Matthew Snyder,
* and Goncalo Abecasis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VCF_FILE_H__
#define __VCF_FILE_H__
#include "InputFile.h"
#include "VcfHeader.h"
/// This header file provides interface to read/write VCF files.
class VcfFile {
public:
/// Default Constructor, initializes the variables, but does not open
/// any files.
VcfFile();
/// Destructor
virtual ~VcfFile();
/// Open the vcf file with the specified filename,
/// overwritten by child classes for read/write.
/// \param filename the vcf file to open.
/// \param header to be read/written from/to the file
/// \return true = success; false = failure.
virtual bool open(const char* filename, VcfHeader& header) = 0;
/// Close the file if it is open.
void close();
/// When set to true, read only the first 8 columns, skipping the format
/// and genotype fields, so when reading do not store them, and when
/// writing do not write them. Defaults to read/write all columns.
/// This setting is maintained even when the file is reset/closed.
/// \param siteOnly process only the first 8 columns
void setSiteOnly(bool siteOnly) {mySiteOnly = siteOnly;}
/// Get the number of VCF records that have been processed (read/written)
/// so far including any filtered records.
int getNumRecords() {return(myNumRecords);}
// Get the Status of the last call that sets status.
// inline StatGenStatus::Status getStatus()
// {
// return(myStatus.getStatus());
// }
/// Get the filename that is currently opened.
/// \return filename associated with this class
const char* getFileName() const
{
return(myFilePtr->getFileName());
}
protected:
// Open the vcf file with the specified filename
// with the specified mode.
// \param filename the vcf file to open.
// \param mode how to open (r/w).
// \return true = success; false = failure.
bool open(const char* filename, const char* mode,
InputFile::ifileCompression compressionMode = InputFile::DEFAULT);
void reset();
virtual void resetFile() = 0;
IFILE myFilePtr;
StatGenStatus myStatus;
bool mySiteOnly;
// Number of records read/written so far. Child classes need to set this.
int myNumRecords;
private:
VcfFile(const VcfFile& vcfFile);
VcfFile& operator=(const VcfFile& vcfFile);
};
#endif
|