cancerit / alleleCount

Support code for NGS copy number algorithms. Takes a file of locations and a [cr|b]am file and generates a count of coverage of each allele [ACGT] at that location (given any filter settings)
http://cancerit.github.io/alleleCount/
GNU Affero General Public License v3.0
43 stars 8 forks source link

C alleleCounter - filter by long form #37

Closed keiranmraine closed 6 years ago

keiranmraine commented 6 years ago

Using the long form of the -f and -F options results in a segfault.

I started to dig in to this and found that the options are not marked as taking values:

https://github.com/cancerit/alleleCount/blob/e16b76df5f159d53c74d720af6247067afa6270f/c/src/alleleCounter.c#L91-L92

Should this be optional_argument?

With or without that change valgrid gives:

==5663== Memcheck, a memory error detector
==5663== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==5663== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==5663== Command: /.../GitHub/alleleCount/perl/bin/../../c/bin/alleleCounter --loci-file testData/loci_22.txt --hts-file testData/test.bam --output-file test --min-base-qual 30 --min-map-qual 35 --required-flag 3
==5663== 
==5663== Invalid read of size 1
==5663==    at 0x54A66E4: ____strtol_l_internal (strtol_l.c:298)
==5663==    by 0x461A42: alleleCounter_setup_options (stdlib.h:286)
==5663==    by 0x408E00: main (alleleCounter.c:366)
==5663==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==5663== 
==5663== 
==5663== Process terminating with default action of signal 11 (SIGSEGV)
==5663==  Access not within mapped region at address 0x0
==5663==    at 0x54A66E4: ____strtol_l_internal (strtol_l.c:298)
==5663==    by 0x461A42: alleleCounter_setup_options (stdlib.h:286)
==5663==    by 0x408E00: main (alleleCounter.c:366)

This occurs on both --required-flag 3 and --filtered-flag 3852 but not on the short forms -f 3 and -F 3852 for some reason.

keiranmraine commented 6 years ago

Even more odd is that using the long form as '--required-flag=3does work.--min-map-qualworks with or without=`

keiranmraine commented 6 years ago

Optional arg bit breaks on clean rebuild of binary giving:

option '--required-flag' doesn't allow an argument

With optional_argument it works but requires =

keiranmraine commented 6 years ago

Turns out all optional_arguments require '=' so best to document all args as needing it:

https://stackoverflow.com/questions/1052746/getopt-does-not-parse-optional-arguments-to-parameters/1052750#1052750

Handled by PR #38, may need to add some doc about = being required on long form optional args.