From 3ac9f93122a1987da82b1d1a730715768eaf386e Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 6 Sep 2025 14:20:18 +0100 Subject: Roll cat_data_frames into cat_genotype. cat_data_frames is no longer a special function used by both cat_genotype and cat_phenotype. Specialize it and roll it into cat_genotype. --- pyhegp/pyhegp.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pyhegp/pyhegp.py b/pyhegp/pyhegp.py index e93c62f..3598931 100644 --- a/pyhegp/pyhegp.py +++ b/pyhegp/pyhegp.py @@ -124,12 +124,12 @@ def encrypt_phenotype(phenotype, key): columns=sample_names)), axis="columns") -def cat_data_frames(frames, metadata_columns): - def cat2(df1, df2): - return pd.merge(df1, df2, how="inner", on=metadata_columns) - return reduce(cat2, frames) - def cat_genotype(genotypes): + def cat2(df1, df2): + return pd.merge(df1, df2, + how="inner", + on=list(filter(is_genotype_metadata_column, + df1.columns))) match genotypes: # If there are no input data frames, return an empty data # frame with the chromosome and position columns. @@ -140,9 +140,7 @@ def cat_genotype(genotypes): genotype.position = genotype.position.astype("int") return genotype case _: - return cat_data_frames(genotypes, - list(filter(is_genotype_metadata_column, - genotypes[0].columns))) + return reduce(cat2, genotypes) def cat_phenotype(phenotypes): match phenotypes: -- cgit 1.4.1