Skip to content

Commit

Permalink
Standardize regex syntax
Browse files Browse the repository at this point in the history
Use leading hyphen in regex character sets to follow the convention of
literal hyphens in either first or last position of a set and to support
easier appending of additional characters to the end of the set without
accidentally implementing a range with a trailing hyphen. Also, use a
compressed syntax for dates.
  • Loading branch information
huddlej committed Apr 12, 2022
1 parent 6721486 commit 1b4beda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ config["conda_environment"] = CONDA_ENV_PATH
wildcard_constraints:
# Allow build names to contain alphanumeric characters, underscores, and hyphens
# but not special strings used for Nextstrain builds.
build_name = r'(?:[a-zA-Z0-9_-](?!(tip-frequencies)))+',
date = r"[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]",
origin = r"[a-zA-Z0-9_-]+"
build_name = r'(?:[-a-zA-Z0-9_](?!(tip-frequencies)))+',
date = r"\d{4}-\d{2}-\d{2}",
origin = r"[-a-zA-Z0-9_]+"

localrules: clean

Expand Down
2 changes: 1 addition & 1 deletion workflow/schemas/config.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ properties:
# Allow build names to contain alphanumeric characters, underscores, and hyphens
# but not special strings used for Nextstrain builds. Also used in the
# workflow's wildcard_constraints.
pattern: "^(?:[a-zA-Z0-9_-](?!(tip-frequencies)))+$"
pattern: "^(?:[-a-zA-Z0-9_](?!(tip-frequencies)))+$"

S3_DST_COMPRESSION:
type: string
Expand Down
4 changes: 2 additions & 2 deletions workflow/snakemake_rules/export_for_nextstrain.smk
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ rule dated_json:
wildcard_constraints:
# Allow build names to contain alphanumeric characters, underscores, and hyphens
# but not special strings used for Nextstrain builds.
build_name = r'(?:[a-zA-Z0-9-_](?!(tip-frequencies|\d{4}-\d{2}-\d{2})))+',
date = r"[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]"
build_name = r'(?:[-a-zA-Z0-9_](?!(tip-frequencies|\d{4}-\d{2}-\d{2})))+',
date = r"\d{4}-\d{2}-\d{2}"
conda: config["conda_environment"]
shell:
"""
Expand Down

0 comments on commit 1b4beda

Please sign in to comment.