Skip to content

Dynamic errors#15

Merged
siberianisaev merged 32 commits into
mainfrom
dynamic_errors
Feb 18, 2026
Merged

Dynamic errors#15
siberianisaev merged 32 commits into
mainfrom
dynamic_errors

Conversation

@siberianisaev

@siberianisaev siberianisaev commented Feb 3, 2026

Copy link
Copy Markdown
Contributor
import cap_upload_validator.errors as err


def main():
    e = err.CapMultiException()

    # File errors
    e.append(err.BadAnnDataFile())

    # X
    e.append(err.AnnDataMissingCountMatrix())
    e.append(err.AnnDataInvalidCountMatrix())
    e.append(err.CSCMatrixInX(locations=["adata.X", "adata.raw.X"]))

    # Embeddings
    e.append(err.AnnDataMissingEmbeddings())

    # Obs
    e.append(err.AnnDataMissingObs())

    e.append(
        err.AnnDataMissingObsColumns(
            missing_columns=["organism", "assay", "tissue"]
        )
    )

    e.append(
        err.AnnDataEmptyOrNoneInGeneralMetadata(
            none_columns=["organism", "assay"],
            empty_columns=["tissue"],
        )
    )

    # Var
    e.append(err.AnnDataMissingVarIndex())
    e.append(err.AnnDataNumericVarIndex())
    e.append(err.AnnDataVarNotSubsetOfRawVar())
    e.append(err.AnnDataGeneIndexIsNotUnique())

    e.append(err.AnnDataNonStandardVarError())
    e.append(err.AnnDataUnsupportedGenes(missing_genes_count=42))

    if e.have_errors():
        raise e


if __name__ == "__main__":
    try:
        main()
    except err.CapMultiException as ex:
        print("\n=================================\n")
        print(str(ex))
        print("\n=================================\n")
CapMultiException:

BadAnnDataFile: The file format is not supported!

AnnDataMissingCountMatrix: Matrix is missing in both `.X` and `.raw.X`.

AnnDataInvalidCountMatrix: Raw counts matrix values must be non-negative integers.

CSCMatrixInX: A CSC matrix is found in adata.X and adata.raw.X. The gene expression matrix must be stored in CSR or dense format!

AnnDataMissingEmbeddings: Embeddings are missing or incorrectly formatted. They must be stored in `.obsm` as [n_cells × 2] datasets with names starting with 'X_' (e.g., X_umap, X_tsne).

AnnDataMissingObs: The `.obs` is missing.

AnnDataMissingObsColumns: Required `.obs` metadata is missing. The file must contain 'assay', 'disease', 'organism', 'tissue' or corresponding '<x>_ontology_term_id' fields.
Missing columns: organism, assay, tissue

AnnDataEmptyOrNoneInGeneralMetadata: Required `.obs` metadata contains missing or invalid values.
All required fields must be filled with valid values.
Columns with None / NaN values: assay, organism
Columns with empty values: tissue

AnnDataMissingVarIndex: The `.var.index` is missing or empty.

AnnDataNumericVarIndex: The `.var.index` contains numeric values instead of gene identifiers.

AnnDataVarNotSubsetOfRawVar: `var.index` must be a subset of `raw.var.index`.

AnnDataGeneIndexIsNotUnique: `var.index` must not contain duplicates.

AnnDataNonStandardVarError: Generic CAP exception

AnnDataUnsupportedGenes: File does not contain valid ENSEMBL terms in var.
We currently support only Homo sapiens and Mus musculus.
In the case of multiple species in the dataset, orthologous Homo sapiens genes are required.
If there are other species you wish to upload to CAP, please contact support@celltype.info and we will work to accommodate your request.
Number of unsupported genes found: 42

For details visit:
	https://github.com/cellannotation/cap-validator/wiki/Validation-Errors

@siberianisaev siberianisaev marked this pull request as ready for review February 10, 2026 13:00
@siberianisaev siberianisaev requested a review from rm1113 February 11, 2026 08:38
Comment thread src/cap_upload_validator/errors.py Outdated
Comment thread src/cap_upload_validator/errors.py Outdated
Comment thread src/cap_upload_validator/errors.py Outdated
Comment thread src/cap_upload_validator/errors.py Outdated
Comment thread src/cap_upload_validator/errors.py Outdated
Comment thread src/cap_upload_validator/errors.py Outdated
Comment thread src/cap_upload_validator/upload_validator.py Outdated
Comment thread src/cap_upload_validator/upload_validator.py Outdated
Comment thread src/cap_upload_validator/upload_validator.py Outdated
Comment thread src/cap_upload_validator/upload_validator.py
@siberianisaev siberianisaev requested a review from rm1113 February 11, 2026 12:50
@siberianisaev siberianisaev merged commit 1a40d9c into main Feb 18, 2026
5 checks passed
@siberianisaev siberianisaev deleted the dynamic_errors branch February 18, 2026 09:22
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