Skip to content

Commit 8e4e375

Browse files
committed
[vcf2smc] add a more descriptive error message when genotypes are missing. fixes #20
1 parent 8d615be commit 8e4e375

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

smcpp/commands/vcf2smc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,14 @@ def print_pop(i):
156156
# <span, dist gt, # undist gt, # undist, [...]>
157157
def rec2gt(rec):
158158
ref = rec.alleles[0]
159+
for di in dist:
160+
for d, i in di:
161+
if len(rec.samples[d]) != 2:
162+
raise RuntimeError(
163+
"Expected a diploid genotype at position {} "
164+
"for individual {} but found:\n{}".format(rec.pos, d, rec))
159165
da = [[rec.samples[d].alleles[i]
160-
for d, i in di] for di in dist]
166+
for d, i in di] for di in dist]
161167
a = [sum([x != ref for x in d])
162168
if None not in d else -1 for d in da]
163169
bs = [[rec.samples[d].alleles[i] != ref

0 commit comments

Comments
 (0)