Skip to content

failure to parse mulitple regions passed with -r  #309

Closed

Description

@dkj

Regression post 1.2?

$ alias bcftools=/software/hgi/pkglocal/bcftools-1.2/bin/bcftools
$ bcftools merge --force-samples -r 1:74941293,1:169676486 tmp/{{16814..16819},16826}.bcf > /dev/null
$ alias bcftools=/software/svi/bin/bcftools-dev 
$ bcftools merge --force-samples -r 1:74941293,1:169676486 tmp/{{16814..16819},16826}.bcf > /dev/null
[synced_bcf_reader.c:904 _regions_init_string] Could not parse the region(s): 1:74941293,1:169676486
Failed to read the regions: 1:74941293,1:169676486

Activity

  1. jmarshall commented on Aug 25, 2015

    @jmarshall
    Member

    This is fallout from samtools/htslib#171, in particular that it makes hts_parse_decimal() match hts_parse_reg() in allowing commas as thousands-separators. This of course conflicts with _regions_init_string()'s use of commas for a list. Alas…

    You can work around it with -r 1:74941293.,1:169676486 as the comma is only used as a thousands-separator before a decimal point. But it would be good to come up with a better solution to this conflict.

  2. jmarshall commented on Aug 26, 2015

    @jmarshall
    Member

    This is unfortunate. Having syntax (like , lists) inside option arguments is not very Unixy, and the problems like this that it leads to is why. More Unixy would be to have -r able to be given multiple times, so you could write this as

    bcftools merge -r 1:74941293 -r 1:169,676,486 foo.bcf bar.bcf
    

    but that would require changes to the argument parsing of every bcftools command that has this -r option.

    To fix the regression and make the existing -r 1:74941293,1:169676486 usage work the same way as previously, probably the answer is to give functions like _regions_init_string() that have their own designs on commas a way to tell hts_parse_decimal() not to parse them itself. See the proposed HTS_PARSE_* htslib change to do this.

  3. pd3 commented on Aug 26, 2015

    @pd3
    Member

    The thousands separating commas are unfortunately ambiguous: -r 1:1,123 can be interpreted as -r 1:1123 but also as -r 1:1 -r 123.

    Putting aside the question of what is UNIXy (see for example cut) and ignoring for a moment backward compatibility, it would be quite inconvenient to write -r 1 -r 2 -r 3 -r 4 instead of the current -r 1,2,3,4. Note also that comma is used as a list separator also in other contexts, for example when giving lists of samples.

    The user convenience of allowing commas as thousands separators is in practice less useful than passing multiple regions at once.

  4. jkbonfield commented on Aug 26, 2015

    @jkbonfield
    Contributor

    Doesn't this mean that bcftools doesn't adhere to the SAM specification though, as comma is a legal character in sample names? I think this boat has perhaps already sailed :(

  5. pd3 commented on Aug 26, 2015

    @pd3
    Member

    Yes, bcftools does not support commas in sequence names.

  6. added 2 commits that reference this issue on Sep 3, 2015
    9f46954
    3d3d778
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions