Skip to content

Commit

Permalink
[uf-select] make --id select exact sequence id
Browse files Browse the repository at this point in the history
  • Loading branch information
zwets committed Jan 22, 2021
1 parent 1599953 commit 94235dd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions uf-select
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Usage: $(basename $0) [OPTIONS|NUMBERS|REGEX] [FILE ...]
OPTIONS
-n, --nth N[,..] Select the nth sequence(s) for each file.
-i, --id SEQID Select the sequence(s) whose ID contains SEQID
-i, --id SEQID Select the sequence(s) whose ID equals SEQID
-g, --grep REGEX Select the sequence(s) whose header matches REGEX.
As a convenience, when no option is specified then if the first argument
Expand Down Expand Up @@ -116,7 +116,7 @@ while [ -n "$FILE" ]; do
' "$FILE"
elif [ -n "$SEQID" ]; then
gawk -bO -v SEQID="$SEQID" '
NR % 2 == 1 && (P=index($1,SEQID)) != 0 { C=substr($1,P+length(SEQID),1); if (C=="" || C==" " || C=="|") { print; getline; print } }
NR % 2 == 1 && $1 == ">" SEQID { print; getline; print }
' "$FILE"
elif [ -n "$REGEX" ]; then
gawk -bO "$(printf 'NR %% 2 == 1 && /%s/ { print; getline; print }\n' "$REGEX")" "$FILE"
Expand Down

0 comments on commit 94235dd

Please sign in to comment.