diff --git a/spaceprime/cli.py b/spaceprime/cli.py index a5dcdbe..bc139b3 100644 --- a/spaceprime/cli.py +++ b/spaceprime/cli.py @@ -81,7 +81,7 @@ def read_individuals(args, coords): def read_anc_pop_id(anc_pop_id): - if anc_pop_id[0] is not None and not len(anc_pop_id) > 1: + if anc_pop_id is not None and not len(anc_pop_id) > 1: if not os.path.exists(anc_pop_id[0]): raise FileNotFoundError(f"anc_pop_id file {anc_pop_id[0]} not found") else: diff --git a/spaceprime/demography.py b/spaceprime/demography.py index e79d24b..815a9b4 100644 --- a/spaceprime/demography.py +++ b/spaceprime/demography.py @@ -6,6 +6,7 @@ from typing import Union, List, Optional import msprime from .utilities import calc_migration_matrix +import warnings ## not sure if I should add a subclass or not. There are only two new functions, so might not be worth it. @@ -270,6 +271,13 @@ def add_ancestral_populations( if not isinstance(anc_sizes, list): anc_sizes = [anc_sizes] + # set anc_id to None and throw a warning if anc_sizes is less than 2 + if len(anc_sizes) < 2 and anc_id is not None: + warnings.warn( + "anc_sizes is less than two, but you provided a list of anc_id's. If you meant to setup more than one anc_size, provide a list of sizes to anc_size. Otherwise, you're fine." + ) + anc_id = None + # check merge time if isinstance(merge_time, list): raise ValueError("merge_time should be a single float or int, not a list.")