Skip to content

Commit

Permalink
Fix bug in simulation of relate datasets where some reads could have …
Browse files Browse the repository at this point in the history
…zero coverage; enable _check_no_coverage_reads to handle masked arrays where the mask is a boolean value
  • Loading branch information
matthewfallan committed Jun 10, 2024
1 parent e0eaa72 commit b15f63d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/seismicrna/core/batch/ends.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _check_no_coverage_reads(seg_ends: np.ndarray, what: str = "seg_ends"):
num_reads, num_segs = count_reads_segments(seg_ends, what)
if np.ma.isarray(seg_ends):
# Check if any reads have no coverage (are completely masked).
no_coverage = seg_ends.mask.all(axis=1)
no_coverage = np.ma.getmaskarray(seg_ends).all(axis=1)
if np.any(no_coverage):
raise ValueError(
f"Got {np.count_nonzero(no_coverage)} read(s) with no coverage "
Expand Down
2 changes: 1 addition & 1 deletion src/seismicrna/core/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

logger = getLogger(__name__)

__version__ = "0.17.3"
__version__ = "0.17.4"


def parse_version(version: str = __version__):
Expand Down
4 changes: 4 additions & 0 deletions src/seismicrna/relate/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ def simulate(cls,
(read_length if paired
else 0),
p_rev)
# Drop any reads with zero coverage.
has_coverage = np.less_equal(seg_end5s, seg_end3s).any(axis=1)
seg_end5s = seg_end5s[has_coverage]
seg_end3s = seg_end3s[has_coverage]
simulated_all = cls(batch=batch,
section=section,
seg_end5s=seg_end5s,
Expand Down
2 changes: 2 additions & 0 deletions src/seismicrna/relate/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def simulate_relate(out_dir: Path,
phred_enc=0,
min_phred=0,
ambindel=False,
clip_end5=0,
clip_end3=0,
min_reads=num_reads,
n_reads_xam=num_reads,
n_reads_rel=num_reads,
Expand Down

0 comments on commit b15f63d

Please sign in to comment.