From 8abb47765a0c809f64f802008834377bbab55308 Mon Sep 17 00:00:00 2001 From: Thierry Gosselin Date: Wed, 9 Sep 2026 13:26:12 +1000 Subject: [PATCH] Return failure status for GL validation errors --- abcCallGenotypes.cpp | 11 +++++------ abcGL.cpp | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/abcCallGenotypes.cpp b/abcCallGenotypes.cpp index 165a2b0..2e85f47 100644 --- a/abcCallGenotypes.cpp +++ b/abcCallGenotypes.cpp @@ -69,23 +69,23 @@ void abcCallGenotypes::getOptions(argStruct *arguments){ doCounts = angsd::getArg("-doCounts",doCounts,arguments); if((geno_minDepth!=-1 || geno_maxDepth!=-1 || geno_minMM!=-1 ) &&doCounts==0){ fprintf(stderr,"Must supply -doCounts to use a minimum depth for GC calling\n"); - exit(0); + exit(EXIT_FAILURE); } if(geno_maxDepth!=-1&&doCounts==0){ fprintf(stderr,"Must supply -doCounts to use a maximum depth for GC calling\n"); - exit(0); + exit(EXIT_FAILURE); } if(arguments->inputtype!=INPUT_BEAGLE&&doPost==0&&arguments->inputtype!=INPUT_VCF_GP){ fprintf(stderr,"\n\t-> You need -doPost to call genotypes \n"); - exit(0); + exit(EXIT_FAILURE); } if(doPost==1&&doMaf==0){ fprintf(stderr,"\n\t-> You need -doMaf inorder to get posterior probabilities when using freq as prior\n"); - exit(0); + exit(EXIT_FAILURE); } minInd=angsd::getArg("-minInd",minInd,arguments); @@ -103,7 +103,7 @@ abcCallGenotypes::abcCallGenotypes(const char *outfiles,argStruct *arguments,int if(arguments->argc==2){ if(!strcasecmp(arguments->argv[1],"-doGeno")){ printArg(stdout); - exit(0); + exit(EXIT_FAILURE); }else return; } @@ -280,4 +280,3 @@ void abcCallGenotypes::run(funkyPars *pars){ getGeno(pars); } - diff --git a/abcGL.cpp b/abcGL.cpp index 7ff20aa..288bf3e 100644 --- a/abcGL.cpp +++ b/abcGL.cpp @@ -38,7 +38,7 @@ void readError(double **errors,const char *fname){ FILE *fp=NULL; if(NULL==(fp=fopen(fname,"r"))){ fprintf(stderr,"Error opening file: %s\n",fname); - exit(0); + exit(EXIT_FAILURE); } char buf[LENS]; @@ -112,13 +112,13 @@ void abcGL::getOptions(argStruct *arguments){ doMajorMinor=angsd::getArg("-doMajorMinor",doMajorMinor,arguments); if(GL!=0 && (arguments->inputtype==INPUT_GLF || arguments->inputtype==INPUT_GLF3 || arguments->inputtype==INPUT_VCF_GL)){ fprintf(stderr,"Can't calculate genotype likelihoods from -glf/-glf3/VCF files\n"); - exit(0); + exit(EXIT_FAILURE); } if(arguments->inputtype==INPUT_GLF||arguments->inputtype==INPUT_GLF3||arguments->inputtype==INPUT_VCF_GL||arguments->inputtype==INPUT_GLF10_TEXT) return; if(doGlf&&GL==0){ fprintf(stderr,"\t-> You need to choose a genotype likelihood model -GL for dumping genotype likelihoods\n"); - exit(0); + exit(EXIT_FAILURE); } if(GL==0&&doGlf==0){ shouldRun[index] =0; @@ -133,15 +133,15 @@ void abcGL::getOptions(argStruct *arguments){ if(( GL<0||GL>7 )) { fprintf(stderr,"\t-> You've choosen a GL model=%d, only 1,2,3,4,5,6,7 are implemented\n",GL); - exit(0); + exit(EXIT_FAILURE); } if(GL==4&&(doCounts==0)){ fprintf(stderr,"\t-> Must supply -doCounts 1 for SYK model\n"); - exit(0); + exit(EXIT_FAILURE); } if(GL==6&&(doCounts==0)){ fprintf(stderr,"\t-> Must supply -doCounts 1 for -gl 6\n"); - exit(0); + exit(EXIT_FAILURE); } /* if(doGlf==2){ @@ -155,16 +155,16 @@ void abcGL::getOptions(argStruct *arguments){ */ if((doGlf==2||doGlf==3) && doMajorMinor==0){ fprintf(stderr,"\t-> For dumping beaglestyle output you need to estimate major/minor: -doMajorMinor\n"); - exit(0); + exit(EXIT_FAILURE); } if(arguments->inputtype==INPUT_BEAGLE&&doGlf){ fprintf(stderr,"\t-> cannot output likelihoods (doGlf) when input is beagle\n"); - exit(0); + exit(EXIT_FAILURE); } if(arguments->inputtype!=INPUT_BAM&&arguments->inputtype!=INPUT_PILEUP){ fprintf(stderr,"Error: Likelihoods can only be estimated based on BAM input and uppile input\n"); - exit(0); + exit(EXIT_FAILURE); } @@ -192,7 +192,7 @@ abcGL::abcGL(const char *outfiles,argStruct *arguments,int inputtype){ if(arguments->argc==2){ if(!strcasecmp(arguments->argv[1],"-GL")){ printArg(stdout); - exit(0); + exit(EXIT_FAILURE); }else return; }