00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGATOOLS_VARIANTS_VARIANTFILEITERATOR_HPP_
00016 #define CGATOOLS_VARIANTS_VARIANTFILEITERATOR_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/util/DelimitedFile.hpp"
00022 #include "cgatools/variants/Locus.hpp"
00023
00024 namespace cgatools { namespace variants {
00025
00026 class VariantFileIterator : boost::noncopyable
00027 {
00028 typedef reference::CrrFile CrrFile;
00029 public:
00030 VariantFileIterator(const CrrFile& crr);
00031 void open(const std::string& fn);
00032 void close();
00033
00034 bool eof() const
00035 {
00036 return eof_;
00037 }
00038
00039 const Locus& operator*() const
00040 {
00041 return locus_;
00042 }
00043
00044 const Locus* operator->() const
00045 {
00046 return &locus_;
00047 }
00048
00049 VariantFileIterator& operator++()
00050 {
00051 readLocus();
00052 return *this;
00053 }
00054
00055 const std::string& getFileName()
00056 {
00057 return name_;
00058 }
00059
00060 void error(const std::string& msg) const;
00061 void locusCallError(const std::string& msg, const Locus& locus, const Call& call) const;
00062 void locusError(const std::string& msg, const Locus& locus) const;
00063
00064 void setReferenceCoverValidation(bool validate)
00065 {
00066 referenceCoverValidation_ = validate;
00067 }
00068
00069 const util::DelimitedFile::Metadata& getMetadata() const
00070 {
00071 return df_->getMetadata();
00072 }
00073
00074 const std::vector<std::string>& getColumnHeaders() const
00075 {
00076 return df_->getColumnHeaders();
00077 }
00078
00079 private:
00080 void readPending();
00081 void readLocus();
00082
00083 const CrrFile* crr_;
00084 boost::shared_ptr<std::istream> istream_;
00085 boost::shared_ptr<util::DelimitedFile> df_;
00086 std::string name_;
00087 Locus locus_;
00088 Call pendingCall_;
00089 bool eof_;
00090 bool hasPending_;
00091 bool referenceCoverValidation_;
00092 boost::uint64_t headerEnd_;
00093 boost::uint64_t fileEnd_;
00094 };
00095
00096 } }
00097
00098 #endif // CGATOOLS_VARIANTS_VARIANTFILEITERATOR_HPP_