/*
    vcflib C++ library for parsing and manipulating VCF files

    Copyright © 2010-2020 Erik Garrison
    Copyright © 2020      Pjotr Prins

    This software is published under the MIT License. See the LICENSE file.
*/

#include "Variant.h"

using namespace std;
using namespace vcflib;

int main(int argc, char** argv) {
if (argc == 2) {
  string h_flag = argv[1];
  if (h_flag == "-h" || h_flag == "--help") {
      cerr << R"(
Count alleles

Usage: vcfcountalleles <vcf file>

Example:

vcfcountalleles samples/scaffold612.vcf
42603

Type: statistics

      )";
      exit(1);
    }
  }


    VariantCallFile variantFile;

    if (argc > 1) {
        string filename = argv[1];
        variantFile.open(filename);
    } else {
        variantFile.open(std::cin);
    }

    if (!variantFile.is_open()) {
        return 1;
    }

    int uniqueAlleles = 0;

    Variant var(variantFile);
    while (variantFile.getNextVariant(var)) {
        uniqueAlleles += var.alleles.size();
    }

    cout << uniqueAlleles << endl;

    return 0;

}
