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

NEW: adds validator for Dist1D[Nested] #22

Merged
merged 2 commits into from
May 29, 2024
Merged
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
12 changes: 11 additions & 1 deletion q2_stats/_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from qiime2.plugin import ValidationError
from q2_stats.plugin_setup import plugin
from q2_stats import Dist1D, Ordered, Unordered, Matched, Independent
from q2_stats import (Dist1D, Ordered, Unordered, NestedOrdered,
NestedUnordered, Matched, Independent)


@plugin.register_validator(Dist1D[Ordered | Unordered,
Expand All @@ -34,3 +35,12 @@ def validate_unique_subjects_within_group(data: pd.DataFrame, level):
'Unique subject found more than once within an individual'
' group. Group(s) where duplicated subject was found:'
f' [{group_id}] Duplicated subjects: {dupes}')


@plugin.register_validator(Dist1D[NestedOrdered | NestedUnordered,
Matched | Independent])
def validate_all_nesteddist_columns_present(data: pd.DataFrame, level):
req_cols = ['id', 'measure', 'group', 'class', "level"]
for col in req_cols:
if col not in data.columns:
raise ValidationError(f'"{col}" not found in distribution.')
Loading