[docs]@classmethoddefbuild_object(cls,path:Path=None,metadata_file:Path=None,result_path:Path=None,region_type:str=None,receptor_chains:str=None,**kwargs):params={"path":Path(path)ifpathisnotNoneelseNone,"metadata_file":Path(metadata_file)ifmetadata_fileisnotNoneelseNone,"result_path":Path(result_path)ifresult_pathisnotNoneelseNone,"region_type":RegionType[region_type.upper()]ifregion_typeelseNone,"receptor_chains":ChainPair[receptor_chains.upper()]ifreceptor_chainselseNone,}if"column_mapping"inkwargsandkwargs['column_mapping']:ParameterValidator.assert_type_and_value(kwargs['column_mapping'],dict,cls.__name__,'column_mapping')ifnotall(isinstance(el,int)forelinkwargs['column_mapping'].keys()):assertlen(set(kwargs['column_mapping'].values()))==len(list(kwargs['column_mapping'].values())), \
(f"{cls.__name__}: Columns must be mapped to unique names, got: "f"{list(kwargs['column_mapping'].values())}.")ifkwargs.get('columns_to_load',None):ParameterValidator.assert_type_and_value(kwargs['columns_to_load'],list,cls.__name__,"columns_to_load")ifkwargs.get('label_columns',None):ParameterValidator.assert_type_and_value(kwargs['label_columns'],list,cls.__name__,"label_columns")ifkwargs.get('columns_to_load',None)andkwargs.get('label_columns',None):assertall(col_nameinkwargs['columns_to_load']forcol_nameinkwargs['label_columns']), \
(f"{cls.__name__}: Some column names defined under 'label_columns' were not listed in 'columns_to_load'.\n"f"label_columns: {kwargs['label_columns']}\n"f"columns_to_load: {kwargs['columns_to_load']}\n"f"To prevent this error, please add all label columns to columns_to_load.")ifkwargs.get('columns_to_load',None)andkwargs.get('column_mapping',None):assertall(keyinkwargs['columns_to_load']forkeyinkwargs['column_mapping']), \
f"{cls.__name__}: Some keys defined under 'column_mapping' were not listed in 'columns_to_load'."total_specified_fields=list(kwargs['column_mapping'].keys())+kwargs['columns_to_load']ifkwargs.get('label_columns',None):total_specified_fields+=kwargs['label_columns']total_specified_fields=set(total_specified_fields)number_specified_fields=len(total_specified_fields)number_imported_fields=len(kwargs['columns_to_load'])assertnumber_specified_fields==number_imported_fields, \
(f"{cls.__name__}: 'column_mapping', 'columns_to_load' and 'label_columns' fields were not correctly specified: "f"{total_specified_fields} fields specified, and {number_imported_fields} fields are imported.\n"f"All specified fields are: {sorted(total_specified_fields)}\n"f"This does not match columns_to_load: {sorted(kwargs['columns_to_load'])}")params={**kwargs,**params}returnDatasetImportParams(**params)