Skip to content

Commit ede50c6

Browse files
committed
more validation for data sets
1 parent 385ffea commit ede50c6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

smcpp/analysis.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ def _validate_data(self):
7575
raise RuntimeError("Error: data set contains sites where every "
7676
"individual is homozygous recessive. Please encode / "
7777
"fold these as non-segregating (homozygous dominant).")
78+
bad = (np.any(c.data[:, 1::3] > c.a[None, :], axis=1) |
79+
np.any(c.data[:, 2::3] > c.data[:, 3::3], axis=1) |
80+
np.any(c.data[:, 3::3] > c.n[None, :], axis=1))
81+
if np.any(bad):
82+
logger.error("File %s has invalid observations "
83+
"(a > 2 or b > n or n > sample size): %s",
84+
c.fn, np.where(bad)[0])
85+
sys.exit(1)
7886

7987
def _recode_nonseg(self, cutoff):
8088
self._contigs = estimation_tools.recode_nonseg(self._contigs, cutoff)

0 commit comments

Comments
 (0)