Skip to content

Commit

Permalink
[chore/minorfix] Update argval checks for INT+ args
Browse files Browse the repository at this point in the history
Update argument value min max checking for INT+ arguments and change
their helppage descriptions to fetch the values from the program

Fix elapsed real time printing to stdout, change to stderr instead
  • Loading branch information
isinaltinkaya committed Mar 7, 2024
1 parent 1b08819 commit b2e027b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
25 changes: 13 additions & 12 deletions io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,21 @@ void help_page() {
fprintf(stderr, " --gvcf-dps INT(,INT..) _____ Minimum per-sample read depth range(s) for constructing gVCF blocks (requires: -doGVCF 1)\n");
fprintf(stderr, " Example: `--gvcf-dps 5,10,20` will group invariable sites into three types of gVCF blocks: [5,10), [10,20) and [20,inf)\n");
fprintf(stderr, " Sites with minimum depth < 5 will be printed as regular VCF records.\n");
fprintf(stderr, " --adjust-qs INT+ [3] _______ 0: Do not adjust quality scores\n");
fprintf(stderr, " 1: Use adjusted quality scores in genotype likelihoods (requires: --precise-gl 0)\n");
fprintf(stderr, " 2: Use adjusted quality scores in calculating the quality score sum (QS) tag (requires: -addQS 1)\n");
fprintf(stderr, " 4: Use adjusted quality scores in pileup output (requires: --printPileup 1)\n");
fprintf(stderr, " 8: Use adjusted quality scores in --printQScores output (requires: --printQScores 1)\n");
fprintf(stderr, " 16: Use adjusted quality scores in --printGlError output (requires: --printGlError 1)\n");
// fprintf(stderr, " --adjust-qs INT+ [3] _______ 0: Do not adjust quality scores\n");
fprintf(stderr, " --adjust-qs INT+ [%d] _______ %d: Do not adjust quality scores\n", args->adjustQs, ARG_QS_ADJUST_DISABLED);
fprintf(stderr, " %d: Use adjusted quality scores in genotype likelihoods (requires: --precise-gl 0)\n", ARG_QS_ADJUST_FOR_GL);
fprintf(stderr, " %d: Use adjusted quality scores in calculating the quality score sum (QS) tag (requires: -addQS 1)\n", ARG_QS_ADJUST_FOR_QSUM);
fprintf(stderr, " %d: Use adjusted quality scores in pileup output (requires: --printPileup 1)\n", ARG_QS_ADJUST_FOR_PILEUP);
fprintf(stderr, " %d: Use adjusted quality scores in --printQScores output (requires: --printQScores 1)\n", ARG_QS_ADJUST_FOR_PRINTQSCORES);
fprintf(stderr, " %d: Use adjusted quality scores in --printGlError output (requires: --printGlError 1)\n", ARG_QS_ADJUST_FOR_PRINTGLERROR);
fprintf(stderr, " --adjust-by FLOAT [0.499] __ Adjustment value for quality scores (requires: --adjust-qs > 0)\n");
fprintf(stderr, " -explode [0]|1 _____________ 1: Explode to sites that are not in input file.\n");
fprintf(stderr, " Useful for simulating invariable sites when the input file only contains variable sites.\n");
fprintf(stderr, " Sets all genotypes in exploded sites to homozygous reference.\n");
fprintf(stderr, " --rm-invar-sites INT+ [0]___ 0: Do not remove invariable sites\n");
fprintf(stderr, " 1: Remove sites where all individuals' true genotypes in the input file are homozygous reference\n");
fprintf(stderr, " 2: Remove sites where all individuals' true genotypes in the input file are homozygous alternative\n");
fprintf(stderr, " 4: Remove sites where the all simulated reads among all individuals are the same base\n");
fprintf(stderr, " --rm-invar-sites INT+ [%s]___ %d: Do not remove invariable sites\n", ARG_RM_INVAR_DISABLED, ARG_RM_INVAR_DISABLED);
fprintf(stderr, " %d: Remove sites where all individuals' true genotypes in the input file are homozygous reference\n", ARG_RM_INVAR_INPUT_HOMOREFGT);
fprintf(stderr, " %d: Remove sites where all individuals' true genotypes in the input file are homozygous alternative\n", ARG_RM_INVAR_INPUT_HOMOALTGT);
fprintf(stderr, " %d: Remove sites where the all simulated reads among all individuals are the same base\n", ARG_RM_INVAR_INPUT_SIM_INVAR);
fprintf(stderr, " Example: '--rm-invar-sites 3' (1+2) will do both 1 and 2 (i.e. remove all homozygous sites)\n");
fprintf(stderr, " --rm-empty-sites [0]|1 _____ 0: Do not remove empty sites\n");
fprintf(stderr, " 1: Remove empty sites (i.e. sites where no reads were simulated)\n");
Expand Down Expand Up @@ -641,7 +642,7 @@ argStruct* args_get(int argc, char** argv) {
CHECK_ARG_VALUES_LIST(args->platform, "--platform", ARG_PLATFORM_NONE, ARG_PLATFORM_RTA3);
CHECK_ARG_INTERVAL_01(args->usePreciseGlError, "--precise-gl");
CHECK_ARG_INTERVAL_INT(args->i16_mapq, 0, 60, "--i16-mapq");
CHECK_ARG_INTERVAL_INT(args->adjustQs, 0, 15, "--adjust-qs");
CHECK_ARG_INTERVAL_INT(args->adjustQs, 0, ARGMAX_QS_ADJUST, "--adjust-qs");
if (PROGRAM_WILL_ADJUST_QS && args->adjustBy == 0.0) {
ERROR("--adjust-qs %d requires a non-zero value for --adjust-by. Please set --adjust-by and rerun.", args->adjustQs);
}
Expand All @@ -663,7 +664,7 @@ argStruct* args_get(int argc, char** argv) {
}

CHECK_ARG_INTERVAL_01(args->explode, "-explode");
CHECK_ARG_INTERVAL_INT(args->rmInvarSites, 0, 7, "--rm-invar-sites");
CHECK_ARG_INTERVAL_INT(args->rmInvarSites, 0, ARGMAX_RM_INVAR, "--rm-invar-sites");
CHECK_ARG_INTERVAL_01(args->rmEmptySites, "--rm-empty-sites");
CHECK_ARG_INTERVAL_INT(args->doUnobserved, 0, 5, "-doUnobserved");
CHECK_ARG_INTERVAL_01(args->doGVCF, "-doGVCF");
Expand Down
22 changes: 17 additions & 5 deletions shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const double NEG_INF = -std::numeric_limits<double>::infinity();

// args->adjustQs
// NONE: do not perform any adjustment
#define ARG_QS_ADJUST_NONE (0)
#define ARG_QS_ADJUST_DISABLED (0)
// [+1] use adjusted quality scores for genotype likelihoods
#define ARG_QS_ADJUST_FOR_GL (1<<0)
// [+2] use adjusted quality scores for qsum (QS tag)
Expand All @@ -112,6 +112,18 @@ const double NEG_INF = -std::numeric_limits<double>::infinity();
// [+16] use adjusted quality scores for --printGlError
#define ARG_QS_ADJUST_FOR_PRINTGLERROR (1<<4)

#define ARGMAX_QS_ADJUST (ARG_QS_ADJUST_FOR_GL | ARG_QS_ADJUST_FOR_QSUM | ARG_QS_ADJUST_FOR_PILEUP | ARG_QS_ADJUST_FOR_PRINTQSCORES | ARG_QS_ADJUST_FOR_PRINTGLERROR)

#define ARG_RM_INVAR_DISABLED (0<<0)
#define ARG_RM_INVAR_INPUT_HOMOREFGT (1<<0)
#define ARG_RM_INVAR_INPUT_HOMOALTGT (1<<1)
#define ARG_RM_INVAR_INPUT_HOMOGT (ARG_RM_INVAR_INPUT_HOMOREFGT | ARG_RM_INVAR_INPUT_HOMOALTGT)
#define ARG_RM_INVAR_INPUT_SIM_INVAR (1<<2)

#define ARGMAX_RM_INVAR (ARG_RM_INVAR_INPUT_HOMOREFGT | ARG_RM_INVAR_INPUT_HOMOALTGT | ARG_RM_INVAR_INPUT_SIM_INVAR)



#define ARG_PLATFORM_NONE (0)
#define ARG_PLATFORM_RTA3 (1)

Expand Down Expand Up @@ -152,16 +164,16 @@ const double NEG_INF = -std::numeric_limits<double>::infinity();
( (args->addI16 || args->addFormatADF || args->addFormatADR || args->addInfoADF || args->addInfoADR))

#define PROGRAM_WILL_SKIP_INPUT_HOMOREFGT_SITES \
( ((args->rmInvarSites) & 1) )
( ((args->rmInvarSites) & ARG_RM_INVAR_INPUT_HOMOREFGT) )

#define PROGRAM_WILL_SKIP_INPUT_HOMOALTGT_SITES \
( ((args->rmInvarSites) & 2) )
( ((args->rmInvarSites) & ARG_RM_INVAR_INPUT_HOMOALTGT) )

#define PROGRAM_WILL_SKIP_INPUT_HOMOGT_SITES \
( ((args->rmInvarSites) & 3) )
( ((args->rmInvarSites) & ARG_RM_INVAR_INPUT_HOMOGT) )

#define PROGRAM_WILL_SKIP_SIM_INVAR_SITES \
( ((args->rmInvarSites) & 4) )
( ((args->rmInvarSites) & ARG_RM_INVAR_INPUT_SIM_INVAR) )

#define PROGRAM_WILL_USE_BINARY_GTSOURCE \
( ((args->gtSource)==ARG_GTSOURCE_BINARY) )
Expand Down
6 changes: 1 addition & 5 deletions vcfgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,13 @@ inline int check_rec_alleles(simRecord* sim) {

const int nSamples = sim->nSamples;



// -> clear
// rec_alleles[0] = -1;
// rec_alleles[1] = -1;
// rec_alleles[2] = -1;
// rec_alleles[3] = -1;
// rec_alleles[4] = -1;


char* allele = NULL;
int x;
for (int i = 0;i < n_alleles;++i) {
Expand Down Expand Up @@ -1713,11 +1710,10 @@ int main(int argc, char** argv) {
fprintf(args->arg_fp, "\n\tElapsed time (CPU): %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC);

time_t end_time = time(NULL);
fprintf(stdout, "\tElapsed time (Real): %f seconds\n", difftime(end_time, start_time));
fprintf(stderr, "\tElapsed time (Real): %f seconds\n", difftime(end_time, start_time));
fprintf(args->arg_fp, "\tElapsed time (Real): %f seconds\n", difftime(end_time, start_time));



args_destroy(args);

return(0);
Expand Down

0 comments on commit b2e027b

Please sign in to comment.