61 struct tm* ct = localtime(&t);
62 out <<
"##fileformat=VCFv4.0" << endl;
63 out <<
"##fileDate=" << (ct->tm_year + 1900) << (ct->tm_mon + 1) << ct->tm_mday << endl;
64 out <<
"##source=Bio++" << endl;
65 out <<
"##FILTER=<ID=PASS,Description=\"All filters passed\">" << endl;
66 out <<
"##FILTER=<ID=gap,Description=\"At least one sequence contains a gap\">" << endl;
67 out <<
"##FILTER=<ID=unk,Description=\"At least one sequence contains an unresolved character\">" << endl;
68 if (genotypes_.size() > 0)
69 out <<
"##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">" << endl;
70 out <<
"##INFO=<ID=AC,Number=A,Type=Integer,Description=\"Total number of alternate alleles in called genotypes\">" << endl;
74 out <<
"#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO";
75 if (genotypes_.size() > 0) {
77 for (
size_t i = 0; i < genotypes_.size(); ++i) {
78 out <<
"\t" << genotypes_[i][0];
79 if (genotypes_[i].size() > 1) {
81 for (
size_t j = 1; j < genotypes_[i].size(); ++j) {
82 out <<
"-" << genotypes_[i][j];
95 size_t offset = refSeq.
start();
97 map<int, string> chars;
102 vector<int> gt(genotypes_.size());
105 if (refSeq[i] == gap)
111 if (SymbolListTools::hasUnresolved(sites.
getSite(i))) {
119 map<int, size_t> counts;
127 for (
int x = 0; x < 4; ++x) {
129 size_t f = counts[x];
143 if (ac ==
"" && outputAll_) {
147 out << chr <<
"\t" << (offset + walker.
getSequencePosition(i) + 1) <<
"\t.\t" << chars[refSeq[i]] <<
"\t" << alt <<
"\t.\t" << filter <<
"\tAC=" << ac;
149 if (genotypes_.size() > 0) {
151 for (
size_t g = 0; g < genotypes_.size(); ++g) {
153 for (
auto x: genotypes_[g]) {
154 if (geno !=
"") geno +=
"|";
156 if (sequences.size() == 0)
157 geno += (generateDiploids_ ?
".|." :
".");
158 else if (sequences.size() > 1)
159 throw Exception(
"VcfOutputMafIterator::writeBlock(). Duplicated sequence for species '" + x +
"'.");
161 int state = (*sequences[0])[i];
163 geno += (generateDiploids_ ?
".|." :
".");
166 if (generateDiploids_)
virtual int getGapCharacterCode() const=0
virtual const Alphabet * getAlphabet() const=0
A synteny block data structure, the basic unit of a MAF alignement file.
std::vector< const MafSequence * > getSequencesForSpecies(const std::string &species) const
AlignedSequenceContainer & getAlignment()
const MafSequence & getSequenceForSpecies(const std::string &species) const
A sequence class which is used to store data from MAF files.
const std::string & getChromosome() const
bool isUnresolved(int state) const
size_t getSequencePosition(size_t alnPos)
void writeBlock_(std::ostream &out, const MafBlock &block) const
void writeHeader_(std::ostream &out) const
const Site & getSite(size_t siteIndex) const
size_t getNumberOfSites() const
std::string toString(T t)