From 795d87cf058f41877bddeb9dac3bbf273a52bfcc Mon Sep 17 00:00:00 2001 From: alsmith Date: Tue, 16 Apr 2024 17:53:34 +0100 Subject: [PATCH] Refactor DesignIP class to handle different types of designs --- seqnado/design.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/seqnado/design.py b/seqnado/design.py index 7d92d53d..dc193e75 100644 --- a/seqnado/design.py +++ b/seqnado/design.py @@ -717,11 +717,19 @@ def from_design( subset_column: Optional[str] = "scale_group", subset_value: Optional[List[str]] = None, ): - df = ( - design.to_dataframe() - .assign(sample_fullname=lambda df: df.sample_name + "_" + df.ip) - .set_index("sample_fullname") - ) + + if isinstance(design, Design): + df = ( + design.to_dataframe() + .assign(sample_fullname=lambda df: df.sample_name) + .set_index("sample_fullname") + ) + else: + df = ( + design.to_dataframe() + .assign(sample_fullname=lambda df: df.sample_name + "_" + df.ip) + .set_index("sample_fullname") + ) if subset_value: df = df.query(f"{subset_column} in {subset_value}")