mutcleaner.cleaners.ctxm_cleaner#
Functions
|
Clean CTXM dataset using configurable pipeline |
|
Create CTXM dataset cleaning pipeline |
Classes
|
Configuration class for CTXM dataset cleaner. |
- class mutcleaner.cleaners.ctxm_cleaner.CTXMCleanerConfig(pipeline_name='CTXM Cleaning Pipeline', num_workers=16, validate_config=True, column_mapping=<factory>, filters=<factory>, type_conversions=<factory>, process_workers=16, validate_mut_workers=16, label_columns=<factory>, ambler_to_seq_mapping=<factory>, wt_name='CTXM_ampicillin', primary_label_column='fitness')[source]#
Bases:
BaseCleanerConfigConfiguration class for CTXM dataset cleaner. Inherits from BaseCleanerConfig and adds CTXM-specific configuration options.
Simply run mutcleaner.download_ctxm_source_file() to download the dataset.
Alternatively, the raw CTXM file can be obtained from:
- Attributes:
- column_mappingDict[str, str]
Mapping from source to target column names
- filtersDict[str, Callable]
Filter conditions for data cleaning
- type_conversionsDict[str, str]
Data type conversion specifications
- validate_mut_workersint
Number of workers for mutation validation, set to -1 to use all available CPUs
- validate_wt_workersint
Number of workers for wildtype sequence validation, set to -1 to use all available CPUs
- label_columnsList[str]
List of score columns to process
- primary_label_columnstr
Primary score column for the dataset
Methods
from_dict(config_dict)Create configuration object from dictionary
from_json(json_path)Load configuration from JSON file
get_summary()Get a human-readable summary of the configuration
merge(partial_config)Merge partial configuration with current configuration
to_dict([exclude_callables])Convert configuration to dictionary
to_json(json_path, **json_kwargs)Save configuration to JSON file
validate()Validate CTXM-specific configuration parameters
- ambler_to_seq_mapping: Dict[str, str]#
- column_mapping: Dict[str, str]#
- filters: Dict[str, Callable]#
- label_columns: List[str]#
- pipeline_name: str = 'CTXM Cleaning Pipeline'#
- primary_label_column: str = 'fitness'#
- process_workers: int = 16#
- type_conversions: Dict[str, str]#
- validate()[source]#
Validate CTXM-specific configuration parameters
- Raises:
ValueError – If configuration is invalid
- Return type:
None
- validate_mut_workers: int = 16#
- wt_name: str = 'CTXM_ampicillin'#
- wt_sequence = 'RMMFAAAACIPLLLGSAPLYAQTSAVQQKLAALEKSSGGRLGVALIDTADNTQVLYRGDERFPMCSTSKVMAAAAVLKQSETQKQLLNQPVEIKPADLVNYNPIAEKHVNGTMTLAELSAAALQYSDNTAMNKLIAQLGGPGGVTAFARAIGDETFRLDRTEPTLNTAIPGDPRDTTTPRAMAQTLRQLTLGHALGETQRAQLVTWLKGNTTGAASIRAGLPTSWTVGDKTGSGDYGTTNDIAVIWPQGRAPLVLVTYFTQPQQNAESRRDVLASAARIIAEGL'#
- mutcleaner.cleaners.ctxm_cleaner.clean_ctxm_dataset(pipeline)[source]#
Clean CTXM dataset using configurable pipeline
- Parameters:
pipeline (
Pipeline) – CTXM dataset cleaning pipeline- Return type:
Tuple[Pipeline,MutationDataset]- Returns:
Pipeline: The cleaned pipeline - MutationDataset: The cleaned CTXM dataset
Examples
>>> pipeline = create_CTXM_cleaner(df) # df is raw CTXM dataset file Use default configuration:
>>> pipeline, dataset = clean_CTXM_dataset(pipeline)
Use partial configuration:
>>> pipeline, dataset = clean_CTXM_dataset(df, config={ ... "process_workers": 8, ... })
Load configuration from file:
>>> pipeline, dataset = clean_CTXM_dataset(df, config="config.json")
- mutcleaner.cleaners.ctxm_cleaner.create_ctxm_cleaner(dataset_or_path=None, config=None)[source]#
Create CTXM dataset cleaning pipeline
- Parameters:
dataset_or_path (
Union[DataFrame,str,Path,None]) – Raw dataset DataFrame or file path to CTXM dataset.config (
Union[CTXMCleanerConfig,Dict[str,Any],str,Path,None]) – Configuration for the cleaning pipeline. Can be: - CTXMCleanerConfig object - Dictionary with configuration parameters (merged with defaults) - Path to JSON configuration file (str or Path) - None (uses default configuration)
- Return type:
- Returns:
Pipeline: The cleaning pipeline used
- Raises:
TypeError – If config has invalid type
ValueError – If configuration validation fails