williamslab / ped-sim

Pedigree simulator
GNU General Public License v3.0
25 stars 11 forks source link

Invalid sex file presence handling #16

Closed y-popov closed 3 years ago

y-popov commented 3 years ago

When I try to run ped-sim on VCF without chrX data and map-file without chrX and don't specify --sexes, I get the following error:

ERROR: could not open sexes file (null)!
open: Bad address

It seems like there is inconsistency in input arguments handling

if (CmdLineOpts::inVCFfile) {
    if (!CmdLineOpts::vcfSexesFile && haveXmap) {
      for(int o = 0; o < 2; o++) {
    fprintf(outs[o], "WARNING: input VCF supplied and an X chromosome genetic map, but no --sexes file\n");
    fprintf(outs[o], "         output VCF will *not* include X chromosome data\n\n");
      }
    }
    else
      readSexes(sexes, sexesCountData, CmdLineOpts::vcfSexesFile);
  }

In my case: haveXmap is False CmdLineOpts::vcfSexesFile is False So (!CmdLineOpts::vcfSexesFile && haveXmap) is False and else case is executing what is wrong, because i don't specify sexes-file.

williamslab commented 3 years ago

Ah, good catch. Thanks for digging into the code. Just pushed a fix that makes the else statement read else if (CmdLineOpts::vcfSexesFile). Feel free to follow up if the change doesn't solve this.

y-popov commented 3 years ago

@williamslab, many thanks for so quick fix! It seems to work now.