tidymut.cleaners.human_domainome_cleaner module

class tidymut.cleaners.human_domainome_cleaner.HumanDomainomeCleanerConfig(num_workers: int = 16, validate_config: bool = True, *, pipeline_name: str = 'human_domainome_cleaner', sequence_dict_path: Union[str, Path], header_parser: Callable[[str], Tuple[str, Dict[str, str]]] = <function parse_uniprot_header>, column_mapping: Dict[str, str] = <factory>, type_conversions: Dict[str, str] = <factory>, drop_na_columns: List = <factory>, is_zero_based: bool = False, process_workers: int = 16, label_columns: List[str] = <factory>, primary_label_column: str = 'label_humanDomainome')[source]

Bases: BaseCleanerConfig

Configuration class for HumanDomainome dataset cleaner

Inherits from BaseCleanerConfig and adds HumanDomainome-specific configuration options.

sequence_dict_path

Path to the file containing UniProt ID to sequence mapping

Type:

Union[str, Path]

header_parser

Parse Header in fasta files and extract relevant information

Type:

Callable[[str], Tuple[str, Dict[str, str]]]

column_mapping

Mapping from source to target column names

Type:

Dict[str, str]

type_conversions

Data type conversion specifications

Type:

Dict[str, str]

drop_na_columns

List of column names where null values should be dropped

Type:

List[str]

is_zero_based

Whether mutation positions are zero-based

Type:

bool

process_workers

Number of workers for parallel processing

Type:

int

label_columns

List of score columns to process

Type:

List[str]

primary_label_column

Primary score column for the dataset

Type:

str

column_mapping: Dict[str, str]
drop_na_columns: List
header_parser() Tuple[str, Dict[str, str]]

Parse UniProt FASTA header to extract ID and metadata

Parameters:

header (str) – FASTA header line (without ‘>’)

Returns:

(sequence_id, metadata_dict)

Return type:

Tuple[str, Dict[str, str]]

Examples

>>> parse_uniprot_header("sp|P12345|PROT_HUMAN Protein description OS=Homo sapiens")
('P12345', {'db': 'sp', 'entry_name': 'PROT_HUMAN', 'description': 'Protein description OS=Homo sapiens'})
>>> parse_uniprot_header("P12345|PROT_HUMAN Description")
('P12345', {'entry_name': 'PROT_HUMAN', 'description': 'Description'})
>>> parse_uniprot_header("P12345")
('P12345', {})
is_zero_based: bool = False
label_columns: List[str]
pipeline_name: str = 'human_domainome_cleaner'
primary_label_column: str = 'label_humanDomainome'
process_workers: int = 16
sequence_dict_path: str | Path
type_conversions: Dict[str, str]
validate() None[source]

Validate HumanDomainome-specific configuration parameters

Raises:

ValueError – If configuration is invalid

tidymut.cleaners.human_domainome_cleaner.clean_human_domainome_dataset(pipeline: Pipeline) Tuple[Pipeline, MutationDataset][source]

Clean HumanDomainome dataset using configurable pipeline

Parameters:

pipeline (Pipeline) – HumanDomainome dataset cleaning pipeline

Returns:

  • Pipeline: The cleaned pipeline

  • MutationDataset: The cleaned HumanDomainome dataset

Return type:

Tuple[Pipeline, MutationDataset]

Raises:

RuntimeError – If pipeline execution fails

tidymut.cleaners.human_domainome_cleaner.create_human_domainome_cleaner(dataset_or_path: str | Path, sequence_dict_path: str | Path, config: HumanDomainomeCleanerConfig | Dict[str, Any] | str | Path | None = None) Pipeline[source]

Create HumanDomainome dataset cleaning pipeline

Parameters:
  • dataset_or_path (Union[pd.DataFrame, str, Path]) –

    Raw HumanDomainome dataset DataFrame or file path to K50 HumanDomainome - File: SupplementaryTable4.txt from the article

    ’Site-saturation mutagenesis of 500 human protein domains’

  • sequence_dict_path (Union[str, Path]) – Path to file containing UniProt ID to sequence mapping

  • config (Optional[Union[HumanDomainomeCleanerConfig, Dict[str, Any], str, Path]]) – Configuration for the cleaning pipeline. Can be: - HumanDomainomeCleanerConfig object - Dictionary with configuration parameters (merged with defaults) - Path to JSON configuration file (str or Path) - None (uses default configuration)

Returns:

The cleaning pipeline

Return type:

Pipeline

Raises:
  • FileNotFoundError – If data file or sequence dictionary file not found

  • TypeError – If config has invalid type

  • ValueError – If configuration validation fails

Examples

Basic usage: >>> pipeline = create_human_domainome_cleaner( … “human_domainome.csv”, … “uniprot_sequences.fasta” … ) >>> pipeline, dataset = clean_human_domainome_dataset(pipeline)

Custom configuration: >>> config = { … “process_workers”: 8, … “type_conversions”: {“label_humanDomainome”: “float32”} … } >>> pipeline = create_human_domainome_cleaner( … “human_domainome.csv”, … “sequences.csv”, … config=config … )

Load configuration from file: >>> pipeline = create_human_domainome_cleaner( … “data.csv”, … “sequences.fasta”, … config=”config.json” … )