Skip to content

Commit

Permalink
feat: updated .vcf.gz output in simgenotype (#150)
Browse files Browse the repository at this point in the history
Co-authored-by: Arya Massarat <[email protected]>
  • Loading branch information
mlamkin7 and aryarm authored Dec 22, 2022
1 parent 063b411 commit f61f613
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ jobs:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
pipx install --python python3.10 --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx install --python python3.10 --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Run Nox
Expand Down
2 changes: 1 addition & 1 deletion haptools/sim_genotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def output_vcf(breakpoints, chroms, model_file, vcf_file, sampleinfo_file, regio
# Note: comment out the code below to enable (very experimental!) PGEN support
# curr_bkps = current_bkps.copy()
# _write_pgen(breakpoints, chroms, region, hapblock_samples, curr_bkps, output_samples, vcf_file, out+".pgen")
_write_vcf(breakpoints, chroms, region, hapblock_samples, vcf.samples, current_bkps, output_samples, vcf, out+".vcf")
_write_vcf(breakpoints, chroms, region, hapblock_samples, vcf.samples, current_bkps, output_samples, vcf, out+".vcf.gz")
return

def _write_vcf(breakpoints, chroms, region, hapblock_samples, vcf_samples, current_bkps, out_samples, in_vcf, out_vcf):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_outputvcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_alt_chrom_name():
)

# read in vcf file
vcf = VCF(str(out_prefix) + ".vcf")
vcf = VCF(str(out_prefix) + ".vcf.gz")
for var in vcf:
if var.CHROM == "chr1" and var.POS == 10114:
assert var.genotypes[0] == [0, 0, True]
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_alt_chrom_name():
assert False

# Remove output file from output_vcf located at out_prefix + '.vcf'
os.remove(str(out_prefix) + ".vcf")
os.remove(str(out_prefix) + ".vcf.gz")
return


Expand All @@ -112,7 +112,7 @@ def test_vcf_output():
# 1 59423090 GT:POP 0|1:CEU,YRI 1|0:YRI,CEU
# 2 10122 GT:POP 1|0:YRI,CEU 0|1:CEU,YRI
# read in vcf file
vcf = VCF(str(out_prefix) + ".vcf")
vcf = VCF(str(out_prefix) + ".vcf.gz")
for var in vcf:
if var.CHROM == "1" and var.POS == 10114:
assert var.genotypes[0] == [0, 0, True]
Expand All @@ -136,7 +136,7 @@ def test_vcf_output():
assert False

# Remove output file from output_vcf located at out_prefix + '.vcf'
os.remove(str(out_prefix) + ".vcf")
os.remove(str(out_prefix) + ".vcf.gz")
return


Expand Down Expand Up @@ -167,15 +167,15 @@ def test_region_vcf():
bkps, chroms, model_file, vcf_file, sampleinfo_file, region, str(out_prefix)
)

vcf = VCF(str(out_prefix) + ".vcf")
vcf = VCF(str(out_prefix) + ".vcf.gz")
for var in vcf:
assert var.POS == 10122 and var.CHROM == "2"
assert var.genotypes[0] == [1, 0, True]
assert var.format("POP")[0] == "YRI,CEU"
assert var.genotypes[1] == [0, 1, True]
assert var.format("POP")[1] == "CEU,YRI"

os.remove(str(out_prefix) + ".vcf")
os.remove(str(out_prefix) + ".vcf.gz")
return


Expand Down

0 comments on commit f61f613

Please sign in to comment.