Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to new augur curate commands; update ingest/vendored subrepo [#26] #31

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ingest/defaults/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ curate:
- "%Y-%m-%d"
- "%Y-%m-%dT%H:%M:%SZ"

# Field containing location information
genbank_location_field: "location"

titlecase:
# Abbreviations not cast to titlecase, keeps uppercase
abbreviations: ["USA"]
Expand Down
15 changes: 8 additions & 7 deletions ingest/rules/curate.smk
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ rule curate:
field_map=format_field_map(config["curate"]["field_map"]),
date_fields=config["curate"]["date_fields"],
expected_date_formats=config["curate"]["expected_date_formats"],
genbank_location_field=config["curate"]["genbank_location_field"],
articles=config["curate"]["titlecase"]["articles"],
abbreviations=config["curate"]["titlecase"]["abbreviations"],
titlecase_fields=config["curate"]["titlecase"]["fields"],
Expand All @@ -91,32 +92,32 @@ rule curate:
"""
(
cat {input.sequences_ndjson:q} \
| ./vendored/transform-field-names \
| augur curate rename \
--field-map {params.field_map} \
| augur curate normalize-strings \
| augur curate format-dates \
--date-fields {params.date_fields:q} \
--expected-date-formats {params.expected_date_formats:q} \
| ./vendored/transform-genbank-location \
| augur curate parse-genbank-location \
--location-field {params.genbank_location_field:q} \
| augur curate titlecase \
--titlecase-fields {params.titlecase_fields:q} \
--articles {params.articles:q} \
--abbreviations {params.abbreviations:q} \
| ./vendored/transform-authors \
| augur curate abbreviate-authors \
--authors-field {params.authors_field:q} \
--default-value {params.authors_default_value:q} \
--abbr-authors-field {params.abbr_authors_field:q} \
| ./vendored/apply-geolocation-rules \
| augur curate apply-geolocation-rules \
--geolocation-rules {input.all_geolocation_rules:q} \
| ./vendored/merge-user-metadata \
| augur curate apply-record-annotations \
--annotations {input.annotations:q} \
--id-field {params.annotations_id:q} \
| augur curate passthru \
--output-metadata {output.metadata:q} \
--output-fasta {output.sequences:q} \
--output-id-field {params.id_field:q} \
--output-seq-field {params.sequence_field}
) 2>> {log:q}
) 2> {log:q}
"""


Expand Down
3 changes: 0 additions & 3 deletions ingest/vendored/.cramrc

This file was deleted.

14 changes: 14 additions & 0 deletions ingest/vendored/.github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
- push

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pre-commit/[email protected]
4 changes: 2 additions & 2 deletions ingest/vendored/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/nextstrain/ingest
branch = main
commit = c0b4c6bb5e6ccbba86374d2c09b42077768aac23
commit = 258ab8ce898a88089bc88caee336f8d683a0e79a
parent = d2728676b6fe0d74abf87e0cebf7ac9ec9a2917b
method = merge
cmdver = 0.4.6
cmdver = 0.4.7
40 changes: 40 additions & 0 deletions ingest/vendored/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/sync-pre-commit-deps
rev: v0.0.1
hooks:
- id: sync-pre-commit-deps
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://github.com/rhysd/actionlint
rev: v1.6.27
hooks:
- id: actionlint
entry: env SHELLCHECK_OPTS='--exclude=SC2027' actionlint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.6
hooks:
# Run the linter.
- id: ruff
32 changes: 20 additions & 12 deletions ingest/vendored/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ Potential Nextstrain CLI scripts
- [download-from-s3](download-from-s3) - Download file from AWS S3 bucket with decompression based on file extension in S3 URL.
Skips download if the local file already exists and has a hash identical to the S3 object's metadata `sha256sum`.

Potential augur curate scripts

- [apply-geolocation-rules](apply-geolocation-rules) - Applies user curated geolocation rules to NDJSON records
- [merge-user-metadata](merge-user-metadata) - Merges user annotations with NDJSON records
- [transform-authors](transform-authors) - Abbreviates full author lists to '<first author> et al.'
- [transform-field-names](transform-field-names) - Rename fields of NDJSON records
- [transform-genbank-location](transform-genbank-location) - Parses `location` field with the expected pattern `"<country_value>[:<region>][, <locality>]"` based on [GenBank's country field](https://www.ncbi.nlm.nih.gov/genbank/collab/country/)
- [transform-strain-names](transform-strain-names) - Ordered search for strain names across several fields.

## Software requirements

Some scripts may require Bash ≥4. If you are running these scripts on macOS, the builtin Bash (`/bin/bash`) does not meet this requirement. You can install [Homebrew's Bash](https://formulae.brew.sh/formula/bash) which is more up to date.
Expand All @@ -134,7 +125,24 @@ Some scripts may require Bash ≥4. If you are running these scripts on macOS, t

Most scripts are untested within this repo, relying on "testing in production". That is the only practical testing option for some scripts such as the ones interacting with S3 and Slack.

For more locally testable scripts, Cram-style functional tests live in `tests` and are run as part of CI. To run these locally,
## Working on this repo

This repo is configured to use [pre-commit](https://pre-commit.com),
to help automatically catch common coding errors and syntax issues
with changes before they are committed to the repo.

If you will be writing new code or otherwise working within this repo,
please do the following to get started:

1. [install `pre-commit`](https://pre-commit.com/#install) by running
either `python -m pip install pre-commit` or `brew install
pre-commit`, depending on your preferred package management
solution
2. install the local git hooks by running `pre-commit install` from
the root of the repo
3. when problems are detected, correct them in your local working tree
before committing them.

1. Download Cram: `pip install cram`
2. Run the tests: `cram tests/`
Note that these pre-commit checks are also run in a GitHub Action when
changes are pushed to GitHub, so correcting issues locally will
prevent extra cycles of correction.
Loading