Skip to content

samtools 1.2.2 view accepts invalid reference range (off by 1) #353

Description

samtools --version
samtools 1.2-2-gf8a6274
Using htslib 1.2.1
Copyright (C) 2015 Genome Research Ltd.
$ samtools view foo.cram ref0:100-100
read.96 16      ref0    97      40      4M      *       0       0       GTAG    IIII    MD:Z:4  NM:i:0
read.97 16      ref0    98      40      4M      *       0       0       TAGG    IIII    MD:Z:4  NM:i:0
read.98 16      ref0    99      40      4M      *       0       0       AGGT    IIII    MD:Z:4  NM:i:0
read.99 16      ref0    100     40      4M      *       0       0       GGTG    IIII    MD:Z:4  NM:i:0

If the reference range is given such that end == (start -1) the range is accepted. This should fail:

$ samtools view foo.cram ref0:100-99
read.96 16      ref0    97      40      4M      *       0       0       GTAG    IIII    MD:Z:4  NM:i:0
read.97 16      ref0    98      40      4M      *       0       0       TAGG    IIII    MD:Z:4  NM:i:0
read.98 16      ref0    99      40      4M      *       0       0       AGGT    IIII    MD:Z:4  NM:i:0

The following fails (as do smaller values of end), but with a spurious error message:

$ samtools view foo.cram ref0:100-98
[main_samview] region "ref0:100-98" specifies an unknown reference name. Continue anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions