diff --git a/alphastats/DataSet.py b/alphastats/DataSet.py index 04d88e52..8f6a5432 100644 --- a/alphastats/DataSet.py +++ b/alphastats/DataSet.py @@ -84,7 +84,7 @@ def __init__( # self.evidence_df: pd.DataFrame = loader.evidence_df # TODO unused - self.dataset_factory = DataSetFactory( + self._dataset_factory = DataSetFactory( rawinput=self.rawinput, index_column=self.index_column, intensity_column=self._intensity_column, @@ -93,7 +93,7 @@ def __init__( ) rawmat, mat, metadata, sample, preprocessing_info, preprocessed = ( - self._init_dataset() + self._get_init_dataset() ) self.rawmat: pd.DataFrame = rawmat self.mat: pd.DataFrame = mat @@ -104,10 +104,13 @@ def __init__( print("DataSet has been created.") - def _init_dataset(self): - rawmat, mat = self.dataset_factory.create_matrix_from_rawinput() + def _get_init_dataset( + self, + ) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, str, Dict, bool]: + """Get the initial data structure for the DataSet.""" + rawmat, mat = self._dataset_factory.create_matrix_from_rawinput() - metadata, sample = self.dataset_factory.create_metadata(mat) + metadata, sample = self._dataset_factory.create_metadata(mat) preprocessing_info = Preprocess.init_preprocessing_info( num_samples=mat.shape[0], @@ -189,7 +192,7 @@ def reset_preprocessing(self): self.sample, self.preprocessing_info, self._preprocessed, - ) = self._init_dataset() + ) = self._get_init_dataset() def batch_correction(self, batch: str) -> None: """A wrapper for Preprocess.batch_correction(), see documentation there.""" diff --git a/tests/test_DataSet.py b/tests/test_DataSet.py index 551b20ae..12545b2d 100644 --- a/tests/test_DataSet.py +++ b/tests/test_DataSet.py @@ -78,15 +78,15 @@ def test_load_metadata(self): def test_load_metadata_missing_sample_column(self, mock): # is error raised when name of sample column is missing path = self.metadata_path - self.obj.dataset_factory.sample_column = "wrong_sample_column" - self.obj.dataset_factory._load_metadata(file_path=path) + self.obj._dataset_factory.sample_column = "wrong_sample_column" + self.obj._dataset_factory._load_metadata(file_path=path) mock.assert_called_once() @patch("logging.Logger.warning") def test_load_metadata_warning(self, mock): # is dataframe None and is warning produced file_path = "wrong/file.xxx" - self.obj.dataset_factory._load_metadata(file_path=file_path) + self.obj._dataset_factory._load_metadata(file_path=file_path) mock.assert_called_once() def test_create_matrix(self): @@ -220,15 +220,15 @@ def test_dataset_without_metadata(self): def test_load_metadata_fileformats(self): # test if different fileformats get loaded correctly metadata_path = "testfiles/alphapept/metadata.txt" - self.obj.dataset_factory._load_metadata(file_path=metadata_path) + self.obj._dataset_factory._load_metadata(file_path=metadata_path) self.assertEqual(self.obj.metadata.shape, (2, 2)) metadata_path = "testfiles/alphapept/metadata.tsv" - self.obj.dataset_factory._load_metadata(file_path=metadata_path) + self.obj._dataset_factory._load_metadata(file_path=metadata_path) self.assertEqual(self.obj.metadata.shape, (2, 2)) metadata_path = "testfiles/alphapept/metadata.csv" - self.obj.dataset_factory._load_metadata(file_path=metadata_path) + self.obj._dataset_factory._load_metadata(file_path=metadata_path) self.assertEqual(self.obj.metadata.shape, (2, 2)) @patch("logging.Logger.warning")