Skip to content

Commit

Permalink
replicate RuntimeError in test_outputvcf
Browse files Browse the repository at this point in the history
  • Loading branch information
aryarm authored Dec 30, 2024
1 parent 55a628c commit 8d1ae47
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
8 changes: 4 additions & 4 deletions tests/data/var_greater.bkp → tests/data/var_greater.bp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Sample_1_1
YRI 1 59423086 85.107755
CEU 1 2147483647 266.495714
CEU 1 248924793 286.279234
Sample_1_2
YRI 1 59423086 85.107755
YRI 1 2147483647 266.495714
YRI 1 248924793 286.279234
Sample_2_1
CEU 1 59423086 85.107755
YRI 1 2147483647 266.495714
YRI 1 248924793 286.279234
Sample_2_2
CEU 1 59423086 85.107755
CEU 1 2147483647 266.495714
CEU 1 248924793 286.279234
2 changes: 1 addition & 1 deletion tests/data/var_greater.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
##contig=<ID=chr1>
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT HG00096 HG00097 HG00099 HG00100 HG00101
chr1 10114 chr1:10114:T:C T C . . . GT 1|1 1|1 0|0 0|0 0|0
chr1 249403765 chr1:249403765:A:G A G . . . GT 0|0 0|0 1|1 1|1 1|1
chr1 248924809 chr1:248924809:A:G A G . . . GT 0|0 0|0 1|1 1|0 1|1
Binary file removed tests/data/var_greater.vcf.gz
Binary file not shown.
Binary file removed tests/data/var_greater.vcf.gz.tbi
Binary file not shown.
30 changes: 13 additions & 17 deletions tests/test_outputvcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ def test_end_bkp_coords():

def test_variants_greater_than_last_coord():
log = getLogger(name="test")
bkp_file = DATADIR / "var_greater.bkp"
vcf_file = DATADIR / "var_greater.vcf.gz"
bkp_file = DATADIR / "var_greater.bp"
vcf_file = DATADIR / "var_greater.vcf"
model_file = DATADIR / "outvcf_gen.dat"
sampleinfo_file = DATADIR / "outvcf_info.tab"
out_file = DATADIR / "outvcf_out.vcf.gz"
out_file = DATADIR / "outvcf_out.pgen"
chroms = ["1"]
bkps = _get_breakpoints(bkp_file, model_file)

Expand All @@ -135,26 +135,22 @@ def test_variants_greater_than_last_coord():
log,
)

# read in vcf file
vcf = VCF(str(out_file))
# read in pgen file
vcf = GenotypesPLINK(out_file, log=log)
for var in vcf:
if var.CHROM == "chr1" and var.POS == 10114:
assert var.genotypes[0] == [0, 0, True]
assert var.format("POP")[0] == "YRI,YRI"
assert var.genotypes[1] == [1, 1, True]
assert var.format("POP")[1] == "CEU,CEU"

elif var.CHROM == "chr1" and var.POS == 249403765:
assert var.genotypes[0] == [0, 1, True]
assert var.format("POP")[0] == "CEU,YRI"
assert var.genotypes[1] == [1, 0, True]
assert var.format("POP")[1] == "YRI,CEU"

if var.variants["chrom"] == "chr1" and var.variants["pos"] == 10114:
np.testing.assert_allclose(var.data[0], [0, 0, 1])
np.testing.assert_allclose(var.data[1], [1, 1, 1])
elif var.variants["chrom"] == "chr1" and var.variants["pos"] == 248924809:
np.testing.assert_allclose(var.data[0], [0, 1, 1])
np.testing.assert_allclose(var.data[1], [1, 0, 1])
else:
assert False

# Clean up by removing the output file from output_vcf
out_file.unlink()
out_file.with_suffix(".pvar").unlink()
out_file.with_suffix(".psam").unlink()


def test_alt_chrom_name():
Expand Down

0 comments on commit 8d1ae47

Please sign in to comment.