Skip to content

Commit

Permalink
patch for n_t masking when all_sites option is used
Browse files Browse the repository at this point in the history
  • Loading branch information
silastittes committed May 16, 2024
1 parent f26ae43 commit 9151c04
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions workflows/masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ def get_mask_from_chrom_annotation(speciesID, chrom_annotation, chromID):
:chromID: chromosome ID (e.g., "chr1")
"""
species = stdpopsim.get_species(speciesID)
a = species.get_annotations(chrom_annotation)
mask = [a.get_chromosome_annotations(chrom) for chrom in chromID]
if chrom_annotation in [s.id for s in species.annotations]:
a = species.get_annotations(chrom_annotation)
mask = [a.get_chromosome_annotations(chrom) for chrom in chromID]
else:
#if annotation is anything but a stdpopsim annotation, don't mask anything
mask = np.array([], dtype=int).reshape(0, 2)
return mask


Expand Down Expand Up @@ -107,7 +111,7 @@ def get_combined_masks(species, mask_file, chromID, chrom_annotation=None):
else:
mask = np.array([], dtype=int).reshape(0, 2)
# get annotations for chrom
if chrom_annotation is not None:
if chrom_annotation in [s.id for s in stdpopsim.get_species(species).annotations]:
an_mask = get_mask_from_chrom_annotation(species, chrom_annotation, chromID)
mask = [np.concatenate((m, am)) for m, am in zip(mask, an_mask)]
# merge overlapping and adjacent intervals
Expand Down

0 comments on commit 9151c04

Please sign in to comment.