Skip to content

Commit

Permalink
fix: Fixed faulty coord file parsing logic (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlamkin7 authored Mar 6, 2023
1 parent b57f91f commit f9819b1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions haptools/sim_genotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,12 @@ def numeric_alpha(x):
# sort coordinate files to ensure coords read are in sorted order
# remove all chr files not found in chroms list
all_coord_files = glob.glob(f'{coords_dir}/*.map')
if region:
try:
all_coord_files = [coord_file for coord_file in all_coord_files \
if f"chr{region['chr']}" in coord_file]
except:
raise Exception(f"Unable to find region chromosome {region['chr']} in map file directory.")
else:
all_coord_files = [coord_file for coord_file in all_coord_files \
if re.search(r'(?<=chr)(X|\d+)', coord_file).group() in chroms]
all_coord_files.sort(key=numeric_alpha)
all_coord_files = [coord_file for coord_file in all_coord_files \
if re.search(r'(?<=chr)(X|\d+)', coord_file).group() in chroms]
all_coord_files.sort(key=numeric_alpha)

if len(all_coord_files) != len(chroms):
raise Exception(f"Unable to find all chromosomes {chroms} in map file directory.")

# coords list has form chroms x coords
coords = []
Expand Down

0 comments on commit f9819b1

Please sign in to comment.