Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance tests #89

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions performance/compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This script requires pv.

# https://www.ivarch.com/programs/pv.shtml

# There is a Homebrew formula to install pv on macOS.

# This script also depends on the simulation data:
# make -C data

import subprocess
import sys


def run_time_pv(command: str):
print(command)
subprocess.run(f"time {command} | pv > /dev/null", shell=True)
print()


def run_bcftools(command: str, dataset_name: str):
run_time_pv(f"bcftools {command} data/{dataset_name}.vcf.gz")


def run_vcztools(command: str, dataset_name: str):
run_time_pv(f"vcztools {command} data/{dataset_name}.vcz")


if __name__ == "__main__":
commands = [
"view",
"view -s tsk_7068,tsk_8769,tsk_8820",
r"query -f '%CHROM %POS %REF %ALT{0}\n'",
r"query -f '%CHROM:%POS\n' -i 'POS=49887394 | POS=50816415'",
"view -s '' --force-samples",
]
dataset = "sim_10k"

if len(sys.argv) == 2 and sys.argv[1].isnumeric():
index = int(sys.argv[1])
command = commands[index]
run_bcftools(command, dataset)
run_vcztools(command, dataset)
elif len(sys.argv) >= 2:
command = " ".join(sys.argv[1:])
run_bcftools(command, dataset)
run_vcztools(command, dataset)
else:
for command in commands:
run_bcftools(command, dataset)
run_vcztools(command, dataset)
3 changes: 3 additions & 0 deletions performance/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!Makefile
!requirements.txt
29 changes: 29 additions & 0 deletions performance/data/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# The make recipes require bcftools and bgzip.

# https://samtools.github.io/bcftools/howtos/install.html
# https://www.htslib.org/doc/bgzip.html

# On macOS, there are Homebrew formulas for bcftools and htslib,
# which contains bgzip.

# The Python requirements are listed in requirements.txt:
# pip install -r requirements.txt

.PHONY: all clean

all: sim_10k.vcz

sim_10k.ts:
stdpopsim HomSap -c chr22 -o sim_10k.ts pop_0:10000

sim_10k.vcf.gz: sim_10k.ts
tskit vcf sim_10k.ts | bgzip > sim_10k.vcf.gz

sim_10k.vcf.gz.csi: sim_10k.vcf.gz
bcftools index sim_10k.vcf.gz

sim_10k.vcz: sim_10k.vcf.gz sim_10k.vcf.gz.csi
vcf2zarr convert sim_10k.vcf.gz sim_10k.vcz

clean:
rm -rf sim_10k.*
3 changes: 3 additions & 0 deletions performance/data/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stdpopsim
tskit
bio2zarr