diff --git a/example/example_data.map b/example/example_data.map index 2fcdd32..2cd5253 100644 --- a/example/example_data.map +++ b/example/example_data.map @@ -1,4 +1,3 @@ -1 1 0 0 - -1 2 19.5 15000000 - +pos chr cM +0 1 0 +15000000 1 19.5 \ No newline at end of file diff --git a/src/threads_arg/utils.py b/src/threads_arg/utils.py index d360c86..595ac65 100644 --- a/src/threads_arg/utils.py +++ b/src/threads_arg/utils.py @@ -54,8 +54,10 @@ def read_map_file(map_file, expected_chromosome=None) -> Tuple[np.ndarray, np.nd def _read_pgen_physical_positions(pgen_file): - pvar = pgen_file.replace("pgen", "pvar") - bim = pgen_file.replace("pgen", "bim") + if not pgen_file.endswith("pgen"): + raise ValueError(f"Cannot find .pvar or .bim files, {pgen_file} does not end with 'pgen'.") + pvar = pgen_file.rstrip("pgen") + "pvar" + bim = pgen_file.rstrip("pgen") + "bim" physical_positions = None if os.path.isfile(bim): physical_positions = np.array(pd.read_table(bim, sep="\\s+", header=None, comment='#')[3]).astype(np.float64)