Skip to content

Commit

Permalink
Make -k and -K take ranges (x-y) and lists (a,b,c).
Browse files Browse the repository at this point in the history
Examples include:
    -k 10
    -k 10,11,12
    -k 10-12
    -k 0,50-99
  • Loading branch information
jkbonfield committed Sep 8, 2022
1 parent 1732da9 commit 021a207
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 5 additions & 2 deletions crumble.1
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ applies to all data, even those that are otherwise kept intact.

.PP
.TP
\fB-k\fR \fIqual\fR
\fB-k\fR \fIqual_range\fR
.TQ
\fB-K\fR \fIqual\fR
\fB-K\fR \fIqual_range\fR
.TQ
\fB-N\fR
These options mark specific quality values as ones we wish to keep.
Expand All @@ -303,6 +303,9 @@ the same column. The intention of this is to not over-emphasise high
quality discrepant bases relative to the agreeing bases, which may
have been quantised or capped using other options.

The \fIqual_range\fR argument can be a single quality ("93"), a start
and end range ("90-99"), and also a comma separated list ("0,90-99").

.PP
.TP
\fB-d\fR \fIqual\fR
Expand Down
16 changes: 12 additions & 4 deletions snp_score.c
Original file line number Diff line number Diff line change
Expand Up @@ -2360,11 +2360,19 @@ int main(int argc, char **argv) {
break;

case 'k':
preserve_qual[MAX(0,MIN(255,atoi(optarg)))] = 1;
break;
case 'K':
preserve_qual[MAX(0,MIN(255,atoi(optarg)))] = 2;
case 'K': {
char *endp = optarg;
do {
long q1 = strtol(endp, &endp, 10), q2 = q1;
if (*endp == '-')
q2 = strtol(endp+1, &endp, 10);
do {
preserve_qual[MAX(0,MIN(255,q1))] = 1 + (opt == 'K');
} while (++q1 <= q2);
} while (*endp++ == ',');

break;
}
case 'N':
params.perfect_col = 1;
break;
Expand Down

0 comments on commit 021a207

Please sign in to comment.