10. Spreadsheet validation

The core of the validator.

class ptmd.lib.validator.core.ExcelValidator(file_id: int | str)

Bases: object

The core of the validator.

Parameters

file_id – The file id to validate.

add_error(label: str, message: str, field: str) None

Adds an error to the report.

Parameters
  • label – The label of the record.

  • message – The error message.

  • field – The field concerned by the error.

Returns

None

download_file() str | None

Download the file from Google Drive.

Returns

the downloaded file path.

validate() None

Validates the file.

validate_file() None

Validates the file.

class ptmd.lib.validator.core.ExternalExcelValidator(file_id: str)

Bases: ExcelValidator

Variation of the ExcelValidator for external files that doesn’t use the database.

Parameters

file_id – The file id to validate.

add_error(label: str, message: str, field: str) None

Adds an error to the report.

Parameters
  • label – The label of the record.

  • message – The error message.

  • field – The field concerned by the error.

Returns

None

download_file() str | None

Download the file from Google Drive.

Returns

the downloaded file path.

validate() None

Validates the file.

validate_file() None

Validates the file.

class ptmd.lib.validator.core.VerticalValidator(definitions: dict, validator: ExcelValidator)

Bases: object

Validate the study design of the exposure information using the general information sheet.

Parameters
  • definitions – The general information sheet.

  • validator – The ExcelValidator instance.

add_node(node: dict) None

Add the node and validates it.

Parameters

node – The node to add.

Returns

None

validate() None

Validates the study design after all nodes have been added

Returns

None

validate_controls(compound_values: dict) None

Validates the controls points against the general information. Verify the number of replicates and timepoints.

Parameters

compound_values – The compound values to validate.

Validate the identifier of the current ExcelValidator

ptmd.lib.validator.validate_identifier.validate_batch(validator: Any) None

Validates the batch.

Parameters

validator – The ExcelValidator for which to run the identifier validation.

ptmd.lib.validator.validate_identifier.validate_compound(validator: Any) None

Validates the compound.

Parameters

validator – The ExcelValidator for which to run the identifier validation.

ptmd.lib.validator.validate_identifier.validate_controls_compound(validator: Any, compound_name: str, code: int) None

Validates the controls compound.

Parameters
  • validator – The ExcelValidator for which to run the identifier validation.

  • compound_name – The reference compound name to check

  • code – The compound code to check

ptmd.lib.validator.validate_identifier.validate_dose(validator: Any) None

Validates the dose.

Parameters

validator – The ExcelValidator for which to run the dose validation.

ptmd.lib.validator.validate_identifier.validate_identifier(excel_validator: Any, record_index: int) None

Validate the identifier of the current ExcelValidator.

Parameters
  • excel_validator – The ExcelValidator for which to run the identifier validation.

  • record_index – The index of the record to validate.

ptmd.lib.validator.validate_identifier.validate_replicate(validator: Any) None

Validates the replicates.

Parameters

validator – The ExcelValidator for which to run the validation of the identifier replicate.

ptmd.lib.validator.validate_identifier.validate_replicates_compound(validator: Any, compound_name: str, code: int) None

Validates the replicates compounds.

Parameters
  • validator – The ExcelValidator for which to run the identifier validation.

  • compound_name – The reference compound name to check

  • code – The compound code to check

ptmd.lib.validator.validate_identifier.validate_species(validator: Any) None

Validates the species.

Parameters

validator – The ExcelValidator for which to run the identifier validation.

ptmd.lib.validator.validate_identifier.validate_timepoints(validator: Any) None

Validates the timepoints.

Parameters

validator – The ExcelValidator for which to run the timepoints validation.

ptmd.lib.validator.validate_identifier.validate_unique_identifier(validator: Any, record_index: int) None

Validates the identifier.

Parameters
  • validator – The ExcelValidator for which to run the identifier validation.

  • record_index – The index of the record to validate.