Skip to content

Add schema def for unaligned sequences - #2037

Open
victorlin wants to merge 1 commit into
masterfrom
victorlin/subsample-config-schema
Open

Add schema def for unaligned sequences#2037
victorlin wants to merge 1 commit into
masterfrom
victorlin/subsample-config-schema

Conversation

@victorlin

@victorlin victorlin commented Aug 11, 2026

Copy link
Copy Markdown
Member

Description of proposed changes

Some workflows use unaligned sequences as input to augur subsample. In this case, proximal samples will not work properly. This schema def makes it easier for workflows to guard against configs with proximal samples.

Related issue(s)

nextstrain/rsv#103 (comment)

Checklist

@victorlin victorlin self-assigned this Aug 11, 2026
Some workflows use unaligned sequences as input to augur subsample. In
this case, proximal samples will not work properly. This schema def
makes it easier for workflows to guard against configs with proximal
samples.
@victorlin
victorlin force-pushed the victorlin/subsample-config-schema branch from 9c16031 to fc86867 Compare August 11, 2026 19:07
Comment on lines +255 to +266
"allOf": [
{"$ref": "#"},
{
"properties": {
"samples": {
"patternProperties": {
"^.+$": {"$ref": "#/$defs/filterSampleProperties"}
}
}
}
}
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure how allOf works here, so I just tested a couple configs.
Looks like this works as expected if just trying to use a proximalSampleProperties

Validating schema of 'results/run_config.yaml'...
  .subsample.'a/genome/6y'.samples.background failed: Unexpected property 'focal_sample'
ERROR: Validation of 'results/run_config.yaml' failed.

There's an edge case where I mix filterSampleProperties and proximalSampleProperties, then I get an error message that suggests proximalSampleProperties are accepted

Validating schema of 'results/run_config.yaml'...
  .subsample.'a/genome/6y'.samples.background failed: {"group_by": ["year", "country"], "focal_sample"…} did not match one of the acceptable options below.
    Option 1: {"$ref": "#/$defs/filterSampleProperties"}
      .subsample.'a/genome/6y'.samples.background failed: Unexpected property 'focal_sample'
    Option 2: {"$ref": "#/$defs/proximalSampleProperties"}
      .subsample.'a/genome/6y'.samples.background failed: Unexpected property 'group_by'
  .subsample.'a/genome/6y'.samples.background failed: Unexpected property 'focal_sample'
ERROR: Validation of 'results/run_config.yaml' failed.

I'm not sure there's a way to work around this since JSON schema doesn't really support overriding subschemas.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the schema defaults to allowing proximal samples. We could flip it around and make it opt-in such that nextstrain/rsv#103 references https://nextstrain.org/schemas/augur/subsample-config/v1, while measles references https://nextstrain.org/schemas/augur/subsample-config/v1#/$defs/schemaForAlignedSequences. This would work better with allOf since it's additive.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, based on allOf docs, flipping it around won't work either

allOf can not be used to "extend" a schema to add more details to it in the sense of object-oriented inheritance. Instances must independently be valid against "all of" the schemas in the allOf. See the section on Extending Closed Schemas for more information.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e19abfa works:

Validating schema of 'results/run_config.yaml'...
  .subsample.'a/genome/all-time'.samples.sample failed: Unexpected property 'focal_sample'
ERROR: Validation of 'results/run_config.yaml' failed.

But validation is also done at augur subsample run time. If proximal samples are opt-in, we'd need to make it explicit using something like --aligned-sequences instead of --sequences...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants