00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CGA_TOOLS_COMMAND_VAR2VCF_HPP_
00016 #define CGA_TOOLS_COMMAND_VAR2VCF_HPP_ 1
00017
00019
00020 #include "cgatools/core.hpp"
00021 #include "cgatools/command/Command.hpp"
00022 #include "cgatools/reference/CrrFile.hpp"
00023 #include "cgatools/variants/VariantFileIterator.hpp"
00024 #include "cgatools/variants/SuperlocusIterator.hpp"
00025
00026 namespace cgatools { namespace command {
00027
00028 class LocusVcfConverter;
00029
00030 class Var2Vcf : public Command
00031 {
00032 public:
00033 Var2Vcf(const std::string& name);
00034
00035 protected:
00036 int run(po::variables_map& vm);
00037
00038 private:
00039 void writeHeader(
00040 std::ostream& out,
00041 LocusVcfConverter& conv) const;
00042 void writeRecord(
00043 std::ostream& out,
00044 LocusVcfConverter& conv) const;
00045 void writeNoCallRecord(
00046 std::ostream& out,
00047 LocusVcfConverter& conv) const;
00048 void splitForVcf(
00049 const cgatools::variants::Superlocus& sl,
00050 std::vector<cgatools::reference::Range>& ranges) const;
00051 void addVariantRanges(
00052 std::vector<cgatools::reference::Range>& ranges,
00053 const std::pair<std::deque<cgatools::variants::Locus>::const_iterator,
00054 std::deque<cgatools::variants::Locus>::const_iterator>& loci) const;
00055 void addNoCallSplits(
00056 std::vector<uint32_t>& ncSplits,
00057 const std::pair<std::deque<cgatools::variants::Locus>::const_iterator,
00058 std::deque<cgatools::variants::Locus>::const_iterator>& loci) const;
00059 void splitAndAddRange(
00060 std::vector<cgatools::reference::Range>& ranges,
00061 const cgatools::reference::Range& range,
00062 const std::vector<uint32_t>& ncSplits) const;
00063 void phaseHaplotypes(
00064 const cgatools::variants::Superlocus& sl,
00065 std::vector<cgatools::variants::PhasedHypothesis>& hyp) const;
00066 int scoreHypothesis(
00067 const cgatools::variants::PhasedHypothesis& hyp,
00068 const std::set<std::string>& popAlleles) const;
00069 void addPopAlleles(
00070 const cgatools::variants::PhasedHypothesis& hyp,
00071 std::set<std::string>& popAlleles) const;
00072 std::string getVcfChromosomeName(
00073 size_t chromosomeId) const;
00074 std::string getReferenceBuild() const;
00075 void transferSource(
00076 std::ostream& out) const;
00077 void transferMetadataHeader(
00078 std::ostream& out,
00079 const std::string& key,
00080 bool mustExist,
00081 bool mustBeUnique) const;
00082
00083 std::string referenceFileName_;
00084 std::string outputFileName_;
00085 std::vector<std::string> variantFileNames_;
00086 bool includeNoCalls_;
00087
00088 cgatools::reference::CrrFile crr_;
00089 std::vector< boost::shared_ptr<cgatools::variants::VariantFileIterator> > var_;
00090 };
00091
00092 } }
00093
00094 #endif // CGA_TOOLS_COMMAND_VAR2VCF_HPP_