about summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2025-09-02 15:59:40 +0100
committerArun Isaac2025-09-02 22:32:03 +0100
commit0e1c22e1873a6cdd5a8632e524adc09cc71ed3f2 (patch)
treeb2f46ab52b83608266fce1b5c8f4300c9078f88e
parent0a7d4eb372239a0714e17dfa32947f244503c7c0 (diff)
downloadpyhegp-0e1c22e1873a6cdd5a8632e524adc09cc71ed3f2.tar.gz
pyhegp-0e1c22e1873a6cdd5a8632e524adc09cc71ed3f2.tar.lz
pyhegp-0e1c22e1873a6cdd5a8632e524adc09cc71ed3f2.zip
Catenate an empty list of genotypes.
We handle this as a special case.
-rw-r--r--pyhegp/pyhegp.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/pyhegp/pyhegp.py b/pyhegp/pyhegp.py
index 3ffa314..f204a36 100644
--- a/pyhegp/pyhegp.py
+++ b/pyhegp/pyhegp.py
@@ -111,7 +111,17 @@ def encrypt_genotype(genotype, key, summary):
                      axis="columns")
 
 def cat_genotype(genotypes):
-    return pd.concat(genotypes)
+    match genotypes:
+        # If there are no input data frames, return an empty data
+        # frame with the chromosome and position columns.
+        case []:
+            genotype = pd.DataFrame(data={"chromosome": [],
+                                          "position": []})
+            genotype.chromosome = genotype.chromosome.astype("str")
+            genotype.position = genotype.position.astype("int")
+            return genotype
+        case _:
+            return pd.concat(genotypes)
 
 @click.group()
 def main():