/*
 * Copyright (C) 2012 by Glenn Hickey (hickey@soe.ucsc.edu)
 *
 * Released under the MIT license, see LICENSE.txt
 */

#include <cstdlib>
#include <iostream>
#include "halStats.h"

using namespace std;
using namespace hal;

int main(int argc, char** argv)
{
  CLParserPtr optionsParser = hdf5CLParserInstance();
  optionsParser->addArgument("halFile", "path to hal file to validate");
  optionsParser->addOption("genome", "specific genome to validate instead of entire file", "");
  optionsParser->setDescription("Check if hal database is valid");
  string path, genomeName;
  try
  {
    optionsParser->parseOptions(argc, argv);
    path = optionsParser->getArgument<string>("halFile");
    genomeName = optionsParser->getOption<string>("genome");
  }
  catch(exception& e)
  {
    cerr << e.what() << endl;
    optionsParser->printUsage(cerr);
    exit(1);
  }
  try
  {
    AlignmentConstPtr alignment = openHalAlignmentReadOnly(path, optionsParser);
    if (genomeName == "") {
        validateAlignment(alignment);
    } else {
        const Genome *genome = alignment->openGenome(genomeName);
        validateGenome(genome);
    }
  }
  catch(hal_exception& e)
  {
    cerr << "hal exception caught: " << e.what() << endl;
    return 1;
  }
  catch(exception& e)
  {
    cerr << "Exception caught: " << e.what() << endl;
    return 1;
  }
  cout << "\nFile valid" << endl;
  
  return 0;
}

/*
 * Copyright (C) 2012 by Glenn Hickey (hickey@soe.ucsc.edu)
 *
 * Released under the MIT license, see LICENSE.txt
 */

#include <cstdlib>
#include <iostream>
#include "halStats.h"

using namespace std;
using namespace hal;

int main(int argc, char** argv)
{
  CLParserPtr optionsParser = hdf5CLParserInstance();
  optionsParser->addArgument("halFile", "path to hal file to validate");
  optionsParser->setDescription("Check if hal database is valid");
  string path;
  try
  {
    optionsParser->parseOptions(argc, argv);
    path = optionsParser->getArgument<string>("halFile");
  }
  catch(exception& e)
  {
    cerr << e.what() << endl;
    optionsParser->printUsage(cerr);
    exit(1);
  }
  try
  {
    AlignmentConstPtr alignment = openHalAlignmentReadOnly(path, optionsParser);
    validateAlignment(alignment);
  }
  catch(hal_exception& e)
  {
    cerr << "hal exception caught: " << e.what() << endl;
    return 1;
  }
  catch(exception& e)
  {
    cerr << "Exception caught: " << e.what() << endl;
    return 1;
  }
  cout << "\nFile valid" << endl;
  
  return 0;
}

--- 
+++ 
@@ -15,12 +15,14 @@
 {
   CLParserPtr optionsParser = hdf5CLParserInstance();
   optionsParser->addArgument("halFile", "path to hal file to validate");
+  optionsParser->addOption("genome", "specific genome to validate instead of entire file", "");
   optionsParser->setDescription("Check if hal database is valid");
-  string path;
+  string path, genomeName;
   try
   {
     optionsParser->parseOptions(argc, argv);
     path = optionsParser->getArgument<string>("halFile");
+    genomeName = optionsParser->getOption<string>("genome");
   }
   catch(exception& e)
   {
@@ -31,7 +33,12 @@
   try
   {
     AlignmentConstPtr alignment = openHalAlignmentReadOnly(path, optionsParser);
-    validateAlignment(alignment);
+    if (genomeName == "") {
+        validateAlignment(alignment);
+    } else {
+        const Genome *genome = alignment->openGenome(genomeName);
+        validateGenome(genome);
+    }
   }
   catch(hal_exception& e)
   {
Validate one genome at a time
