From 2ff5a7536cb8dd89ac094d7dc18eece927242797 Mon Sep 17 00:00:00 2001 From: Aaron <aaronquinlan@gmail.com> Date: Mon, 16 Aug 2010 13:33:45 -0400 Subject: [PATCH] Improved the error checking for unionBedGraphs. --- src/unionBedGraphs/unionBedGraphsMain.cpp | 27 ++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/unionBedGraphs/unionBedGraphsMain.cpp b/src/unionBedGraphs/unionBedGraphsMain.cpp index 15f80709..916220b9 100644 --- a/src/unionBedGraphs/unionBedGraphsMain.cpp +++ b/src/unionBedGraphs/unionBedGraphsMain.cpp @@ -124,17 +124,38 @@ int main(int argc, char* argv[]) else if(PARAMETER_CHECK("-header", 7, parameterLength)) { printHeader = true; } + else if(PARAMETER_CHECK("-empty", 6, parameterLength)) { + printEmptyRegions = true; + } else if(PARAMETER_CHECK("-examples", 9, parameterLength)) { ShowHelp(); ShowExamples(); exit(1); } } + + //Sanity checks + if (inputFiles.empty() == true) { + cerr << "Error: missing BedGraph file names (-i) to combine." << endl; + exit(1); + } + if (inputFiles.size() == 1) { + cerr << "Error: Only a single BedGraph file was specified. Nothing to combine, exiting." << endl; + exit(1); + } + if (printEmptyRegions && (genomeFile.empty() == true)) { + cerr << "Error: when using -empty, the genome sizes file (-g) must be specified using '-g FILE'." << endl; + exit(1); + } + if ((haveTitles == true) && (inputFiles.size() != inputTitles.size())) { + cerr << "Error: The number of file titles (-names) does not match the number of files (-i)." << endl; + exit(1); + } - UnionBedGraphs mbg(cout, inputFiles, inputTitles, printEmptyRegions, genomeFile, noCoverageValue); + UnionBedGraphs ubg(cout, inputFiles, inputTitles, printEmptyRegions, genomeFile, noCoverageValue); if (printHeader) - mbg.PrintHeader(); - mbg.Union(); + ubg.PrintHeader(); + ubg.Union(); } void ShowHelp(void) { -- GitLab