Skip to content

Commit

Permalink
add test with variants that fail harmonisation
Browse files Browse the repository at this point in the history
  • Loading branch information
nebfield committed Oct 18, 2024
1 parent 48a54f2 commit d30342f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pgscatalog.core/tests/data/bad_harmonised.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
###PGS CATALOG SCORING FILE - see https://www.pgscatalog.org/downloads/#dl_ftp_scoring for additional information
#format_version=2.0
##POLYGENIC SCORE (PGS) INFORMATION
#pgs_id=PGS003581
#pgs_name=MTAG.Envs.LifetimeMDD
#trait_reported=Major Depressive Disorder (Lifetime)
#trait_mapped=major depressive disorder
#trait_efo=MONDO_0002009
#genome_build=GRCh37
#variants_number=4861398
#weight_type=beta
##SOURCE INFORMATION
#pgp_id=PGP000461
#citation=Dahl A et al. bioRxiv (2022). doi:10.1101/2022.08.15.503980
##HARMONIZATION DETAILS
#HmPOS_build=GRCh38
#HmPOS_date=2023-04-12
#HmPOS_match_chr={""True"": null, ""False"": null}
#HmPOS_match_pos={""True"": null, ""False"": null}
rsID effect_allele other_allele effect_weight allelefrequency_effect variant_description hm_source hm_rsID hm_chr hm_pos hm_inferOtherAllele
. T C 0.004040743 0.329683 VARIANT_ID=1:2556125_C_T Unknown
. T C 0.004025092 0.329689 VARIANT_ID=1:2556548_C_T Unknown
. A G 0.004013246 0.329686 VARIANT_ID=1:2556709_G_A Unknown
24 changes: 24 additions & 0 deletions pgscatalog.core/tests/test_combine_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ def lift_scorefiles(request):
)


@pytest.fixture(scope="package")
def fail_harmonised(request):
"""This scoring file only contains variants that failed harmonisation."""
return request.path.parent / "data" / "bad_harmonised.txt"


def test_fail_harmonised(tmp_path, fail_harmonised):
"""Variants that have failed harmonisation will be missing mandatory fields, but we should accept them as a special case and write out like normal"""
out_path = tmp_path / "combined.txt"
path = [str(fail_harmonised)]

args = [("pgscatalog-combine", "-s"), path, ("-o", str(out_path), "-t", "GRCh38")]
flargs = list(itertools.chain(*args))

with patch("sys.argv", flargs):
run()

# https://github.com/PGScatalog/pygscatalog/issues/55
assert out_path.exists()
with open(out_path, mode="rt") as f:
x = list(csv.reader(f, delimiter="\t"))
assert len(x) == 4 # 3 variants + header


def test_combine_nonadditive(tmp_path, non_additive_scorefile_grch38):
"""Test normalising a single non-additive scoring file fails."""
out_path = tmp_path / "combined.txt.gz"
Expand Down

0 comments on commit d30342f

Please sign in to comment.