Skip to content

Testing

Ryan Whaley edited this page Mar 15, 2024 · 11 revisions

PharmCAT's requires make >= 3.82. If you have a Mac, you may have an older version. If you have Homebrew installed, you can update make with:

brew install make

If not, please Google for instructions on how to install it via Xcode.

Preprocessor Testing

To test the Preprocessor, make sure you've installed the required modules:

pip3 install -r preprocessor/requirements.txt
pip3 install -r preprocessor/tests/requirements.txt

Then run:

make test-preprocessor

Auto-Generated VCF Testing

TL;DR:

make exactVcfTests

Generating VCFs to Test

/src/scripts/vcf_generator/test_gen.py is responsible for generating VCF files used to test the Named Allele Matcher.

It relies on the allele definitions to generate all possible combinations of variations that will lead to specific diplotype calls for a single gene.

/src/scripts/vcf_generator/generate_vcf_test_data.sh iterates through all genes, calling either:

  • /src/scripts/vcf_generator/test_gen.py
  • or /src/scripts/vcf_generator/test_gen_missing.py (will also generate VCFs with missing positions) if the -m flag is provided

and storing the VCFs in /build/testVcf.

Testing Named Allele Matcher

These VCFs are then run through the Named Allele Matcher using org.pharmgkb.pharmcat.haplotype.AutogeneratedVcfTester:

  • By default, test will pass if the expected result is one of the top matching results from the Named Allele Matcher.
  • In fuzzy-match mode, test will pass if the expected result matches any result from the Named Allele Matcher.
  • In exact-match mode, test will only pass if the Named Allele Matcher produces a single result that matches the expected result.

The "expected result" is determined based on the filename of the input VCF.

Results are saved to /build/autogeneratedTestResults. A summary is saved to /build/autogeneratedTestResults/autogenerated_test_report.txt. The directory will also contain a copy of the VCF and Named Allele Matcher's results for each failing test.

Make Targets

To simplify testing, use one of these make targets:

  • vcfTests
  • vcfMissingTests
  • exactVcfTests
  • exactVcfMissingTests
  • fuzzyVcfTests
  • fuzzyVcfMissingTests

For example:

make exactVcfTests
make exactVcfMissingTests