From f4fe35ae5647af6b52c87aa4028e1d3c42f40cd6 Mon Sep 17 00:00:00 2001 From: Mark Woon Date: Fri, 26 Jul 2024 14:42:45 -0700 Subject: [PATCH] fix(namedallelematcher): avoid exceptions --- .../pharmcat/haplotype/DpydHapB3Matcher.java | 4 +- .../pharmcat/haplotype/model/BaseMatch.java | 2 +- .../java/org/pharmgkb/pharmcat/DpydTest.java | 61 +++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/pharmgkb/pharmcat/haplotype/DpydHapB3Matcher.java b/src/main/java/org/pharmgkb/pharmcat/haplotype/DpydHapB3Matcher.java index da221e20..bd493b57 100644 --- a/src/main/java/org/pharmgkb/pharmcat/haplotype/DpydHapB3Matcher.java +++ b/src/main/java/org/pharmgkb/pharmcat/haplotype/DpydHapB3Matcher.java @@ -247,8 +247,8 @@ public SortedSet mergePhasedDiplotypeMatch(MatchData matchData, BaseMatch h2 = dm.getHaplotype2(); boolean isHapB3homozygous = m_numHapB3Called == 2 && ( - m_hapB3Call.stream().filter(c -> c.equals("1")).count() == 2 || - m_hapB3IntronCall.stream().filter(c -> c.equals("1")).count() == 2 + (m_hapB3Call == null || m_hapB3Call.stream().filter(c -> c.equals("1")).count() == 2) || + (m_hapB3IntronCall == null || m_hapB3IntronCall.stream().filter(c -> c.equals("1")).count() == 2) ); if (dm.getHaplotype1().getName().equals(dm.getHaplotype2().getName()) || isHapB3homozygous) { diff --git a/src/main/java/org/pharmgkb/pharmcat/haplotype/model/BaseMatch.java b/src/main/java/org/pharmgkb/pharmcat/haplotype/model/BaseMatch.java index 73ccdccb..2800390c 100644 --- a/src/main/java/org/pharmgkb/pharmcat/haplotype/model/BaseMatch.java +++ b/src/main/java/org/pharmgkb/pharmcat/haplotype/model/BaseMatch.java @@ -22,7 +22,7 @@ * * @author Mark Woon */ -public abstract class BaseMatch implements Comparable { +public class BaseMatch implements Comparable { @Expose @SerializedName("name") private String m_name; diff --git a/src/test/java/org/pharmgkb/pharmcat/DpydTest.java b/src/test/java/org/pharmgkb/pharmcat/DpydTest.java index 96aa45d5..7c8329a7 100644 --- a/src/test/java/org/pharmgkb/pharmcat/DpydTest.java +++ b/src/test/java/org/pharmgkb/pharmcat/DpydTest.java @@ -731,6 +731,67 @@ void testFindCombinations(TestInfo testInfo) throws Exception { } + @Test + void hapB3AndIntronicC(TestInfo testInfo) throws Exception { + + PipelineWrapper testWrapper = new PipelineWrapper(testInfo, true, false, false); + testWrapper.getVcfBuilder() + .phased() + // hapB3 exon C>T + .variation("DPYD", "rs56038477", "C", "T") + // hapB3 intron G>C + .variation("DPYD", "rs75017182", "C", "C") + ; + + Path vcfFile = testWrapper.execute(); + + List expectedCalls = List.of( + "c.1129-5923C>G/c.1129-5923C>G, c.1236G>A (HapB3)" + ); + RecPresence hasDpwgAnnotations = RecPresence.YES; + + testWrapper.testCalledByMatcher("DPYD"); + testWrapper.testSourceDiplotypes(DataSource.CPIC, "DPYD", expectedCalls); + testWrapper.testRecommendedDiplotypes(DataSource.CPIC, "DPYD", List.of("c.1129-5923C>G, c.1236G>A (HapB3)", "c.1129-5923C>G")); + testWrapper.testPrintCalls(DataSource.CPIC, "DPYD", expectedCalls); + + dpydHasReports(testWrapper, hasDpwgAnnotations); + + Document document = readHtmlReport(vcfFile); + dpydHtmlChecks(document, expectedCalls, false, hasDpwgAnnotations); + } + + @Test + void hapB3AndIntronicD(TestInfo testInfo) throws Exception { + + PipelineWrapper testWrapper = new PipelineWrapper(testInfo, true, false, false); + testWrapper.getVcfBuilder() + .phased() + // hapB3 exon C>T + .variation("DPYD", "rs56038477", "T", "C") + // hapB3 intron G>C + .variation("DPYD", "rs75017182", "C", "C") + ; + + Path vcfFile = testWrapper.execute(); + + List expectedCalls = List.of( + "c.1129-5923C>G/c.1129-5923C>G, c.1236G>A (HapB3)" + ); + RecPresence hasDpwgAnnotations = RecPresence.YES; + + testWrapper.testCalledByMatcher("DPYD"); + testWrapper.testSourceDiplotypes(DataSource.CPIC, "DPYD", expectedCalls); + testWrapper.testRecommendedDiplotypes(DataSource.CPIC, "DPYD", List.of("c.1129-5923C>G, c.1236G>A (HapB3)", "c.1129-5923C>G")); + testWrapper.testPrintCalls(DataSource.CPIC, "DPYD", expectedCalls); + + dpydHasReports(testWrapper, hasDpwgAnnotations); + + Document document = readHtmlReport(vcfFile); + dpydHtmlChecks(document, expectedCalls, false, hasDpwgAnnotations); + } + + @Test void hapB3(TestInfo testInfo) throws Exception {