from abc import ABC
from pathlib import Path
import pandas as pd
from immuneML.data_model.dataset.Dataset import Dataset
from immuneML.data_model.dataset.RepertoireDataset import RepertoireDataset
from immuneML.preprocessing.Preprocessor import Preprocessor
from immuneML.util.PathBuilder import PathBuilder
[docs]class Filter(Preprocessor, ABC):
[docs] @staticmethod
def remove_empty_repertoires(repertoires: list):
filtered_repertoires = []
for repertoire in repertoires:
if len(repertoire.sequences) > 0:
filtered_repertoires.append(repertoire)
return filtered_repertoires
[docs] @staticmethod
def check_dataset_not_empty(processed_dataset: Dataset, location="Filter"):
assert processed_dataset.get_example_count() > 0, f"{location}: {type(processed_dataset).__name__} ended up empty after filtering. Please adjust filter settings."