diff --git a/docs/using/Outside-Call-Format.md b/docs/using/Outside-Call-Format.md index ac1772007..60d51e8f2 100644 --- a/docs/using/Outside-Call-Format.md +++ b/docs/using/Outside-Call-Format.md @@ -73,6 +73,9 @@ We rely on string matching to match outside calls to recommendations. Consult the [Phenotypes List](/Phenotypes-List) for a complete list of named alleles, phenotypes and activity scores. +_Do not_ prefix allele names with the gene symbol in the second field (e.g. CYP2C9*1/CYP2C9*3). The gene is specified in +the first field so repeating it in second field is not necessary. + If there is an outside call for a gene that also has data from the VCF, the outside call will trump the VCF data. diff --git a/src/main/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCall.java b/src/main/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCall.java index e2c5c308e..539219d70 100644 --- a/src/main/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCall.java +++ b/src/main/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCall.java @@ -13,7 +13,7 @@ /** - * Calls from an outside data source. For example, Astrolabe (but could be others) + * Calls from an outside data source. * * @author Ryan Whaley */ @@ -51,7 +51,7 @@ public OutsideCall(String line, int lineNumber) throws RuntimeException { throw new BadOutsideCallException("Line " + lineNumber + ": No gene specified"); } - m_diplotype = StringUtils.stripToNull(fields.get(IDX_DIPS).replaceAll(m_gene, "")); + m_diplotype = StringUtils.stripToNull(fields.get(IDX_DIPS)); if (fields.size() == 2 && (m_diplotype == null || m_diplotype.equals(sf_diplotypeSeparator))) { if (StringUtils.isBlank(fields.get(IDX_DIPS))) { throw new BadOutsideCallException("Line " + lineNumber + ": No diplotype specified"); diff --git a/src/test/java/org/pharmgkb/pharmcat/PipelineTest.java b/src/test/java/org/pharmgkb/pharmcat/PipelineTest.java index 3b629bfd8..987bc7145 100644 --- a/src/test/java/org/pharmgkb/pharmcat/PipelineTest.java +++ b/src/test/java/org/pharmgkb/pharmcat/PipelineTest.java @@ -67,7 +67,7 @@ static void prepare() throws IOException { try (BufferedWriter writer = Files.newBufferedWriter(s_outsideCallFilePath)) { writer.write(""" ##Test Outside Call Data - CYP2D6\tCYP2D6*1/CYP2D6*4\t\t\t0.6\t0.75\tp: 0.0\t\t\tv1.9-2017_02_09 + CYP2D6\t*1/*4\t\t\t0.6\t0.75\tp: 0.0\t\t\tv1.9-2017_02_09 """); } @@ -797,6 +797,31 @@ void testCftrD1270NG551D(TestInfo testInfo) throws Exception { } + /** + * Check to see if the CPIC-specified allele name of "ivacaftor non-responsive CFTR sequence" gets translated to the + * more generic value of "Reference" for display in the report + */ + @Test + void testCftrOutsideReferenceCall(TestInfo testInfo) throws Exception { + Path outsideCallPath = TestUtils.createTestFile(testInfo, ".tsv"); + try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(outsideCallPath))) { + writer.println("CFTR\tivacaftor non-responsive CFTR sequence/ivacaftor non-responsive CFTR sequence"); + } + PipelineWrapper testWrapper = new PipelineWrapper(testInfo, false); + testWrapper.getVcfBuilder() + .reference("CYP2C19") + .reference("CYP2C9") + ; + testWrapper.execute(outsideCallPath); + + testWrapper.testCalledByMatcher("CYP2C19"); + testWrapper.testCalledByMatcher("CYP2C9"); + + testWrapper.testReportable("CFTR"); + testWrapper.testPrintCalls(DataSource.CPIC, "CFTR", "Reference/Reference"); + } + + @Test void testRosuvastatin(TestInfo testInfo) throws Exception { PipelineWrapper testWrapper = new PipelineWrapper(testInfo, false); diff --git a/src/test/java/org/pharmgkb/pharmcat/phenotype/OutsideCallParserTest.java b/src/test/java/org/pharmgkb/pharmcat/phenotype/OutsideCallParserTest.java index 356539ebe..0ca2cf3dc 100644 --- a/src/test/java/org/pharmgkb/pharmcat/phenotype/OutsideCallParserTest.java +++ b/src/test/java/org/pharmgkb/pharmcat/phenotype/OutsideCallParserTest.java @@ -15,35 +15,14 @@ class OutsideCallParserTest { - @Test - void testAstrolabeFormat(TestInfo testInfo) throws IOException { - String sf_astrolabeOutput = "##Test Astrolabe output\n" + - "#ROI_label\tdiplotype labels\tdiplotype activity\tdiplotype calling notes\tjaccard\tpart\tpValue\tROI notes\t" + - "special case\tnomenclature version\n" + - "CYP2D6\tCYP2D6*1/CYP2D6*4\t\t\t0.6\t0.75\tp: 0.0\t\t\tv1.9-2017_02_09\n"; - - Path tempAstroPath = TestUtils.createTestFile(testInfo, ".tsv"); - try (FileWriter fw = new FileWriter(tempAstroPath.toFile())) { - fw.write(sf_astrolabeOutput); - } - - List calls = OutsideCallParser.parse(tempAstroPath); - assertNotNull(calls); - assertEquals(1, calls.size()); - assertEquals("CYP2D6", calls.get(0).getGene()); - assertEquals("*1/*4", calls.get(0).getDiplotype()); - } - @Test void testMinimalInput(TestInfo testInfo) throws IOException { - String sf_astrolabeOutput = "CYP2C9\t*1/*2"; - - Path tempAstroPath = TestUtils.createTestFile(testInfo, ".tsv"); - try (FileWriter fw = new FileWriter(tempAstroPath.toFile())) { - fw.write(sf_astrolabeOutput); + Path outsideCallPath = TestUtils.createTestFile(testInfo, ".tsv"); + try (FileWriter fw = new FileWriter(outsideCallPath.toFile())) { + fw.write("CYP2C9\t*1/*2"); } - List calls = OutsideCallParser.parse(tempAstroPath); + List calls = OutsideCallParser.parse(outsideCallPath); assertNotNull(calls); assertEquals(1, calls.size()); assertEquals("CYP2C9", calls.get(0).getGene()); @@ -52,14 +31,15 @@ void testMinimalInput(TestInfo testInfo) throws IOException { @Test void testTwoGenes(TestInfo testInfo) throws IOException { - String sf_astrolabeOutput = "CYP2C9\t*1/*2\nCYP2C19\t*3/*4"; - - Path tempAstroPath = TestUtils.createTestFile(testInfo, ".tsv"); - try (FileWriter fw = new FileWriter(tempAstroPath.toFile())) { - fw.write(sf_astrolabeOutput); + Path tmpOutsideCallPath = TestUtils.createTestFile(testInfo, ".tsv"); + try (FileWriter fw = new FileWriter(tmpOutsideCallPath.toFile())) { + fw.write(""" + CYP2C9\t*1/*2 + CYP2C19\t*3/*4 + """); } - List calls = OutsideCallParser.parse(tempAstroPath); + List calls = OutsideCallParser.parse(tmpOutsideCallPath); assertNotNull(calls); assertEquals(2, calls.size()); assertEquals("CYP2C9", calls.get(0).getGene()); @@ -71,15 +51,38 @@ void testTwoGenes(TestInfo testInfo) throws IOException { @Test void testBadFormat(TestInfo testInfo) throws IOException { - String sf_astrolabeOutput = "CYP2C9\t*1/*2\nCYP2C19\t*3/*4/*2"; - - Path tempAstroPath = TestUtils.createTestFile(testInfo, ".tsv"); - try (FileWriter fw = new FileWriter(tempAstroPath.toFile())) { - fw.write(sf_astrolabeOutput); + Path outsideCallPath = TestUtils.createTestFile(testInfo, ".tsv"); + try (FileWriter fw = new FileWriter(outsideCallPath.toFile())) { + fw.write(""" + CYP2C9\t*1/*2 + CYP2C19\t*3/*4/*2 + """); } assertThrows(BadOutsideCallException.class, () -> { - OutsideCallParser.parse(tempAstroPath); + OutsideCallParser.parse(outsideCallPath); }); } + + + @Test + void testCommentsAndEmptyLines(TestInfo testInfo) throws IOException { + Path outsideCallPath = TestUtils.createTestFile(testInfo, ".tsv"); + try (FileWriter fw = new FileWriter(outsideCallPath.toFile())) { + fw.write(""" + # comment + CYP2C9\t*1/*2 + + ## another comment + + CYP2C9\t*3/*4 + + """); + } + + List calls = OutsideCallParser.parse(outsideCallPath); + assertEquals(2, calls.size()); + assertEquals("*1/*2", calls.get(0).getDiplotype()); + assertEquals("*3/*4", calls.get(1).getDiplotype()); + } } diff --git a/src/test/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCallTest.java b/src/test/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCallTest.java index b311af0a7..888572f87 100644 --- a/src/test/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCallTest.java +++ b/src/test/java/org/pharmgkb/pharmcat/phenotype/model/OutsideCallTest.java @@ -36,7 +36,7 @@ void testBad() { assertThrows(BadOutsideCallException.class, () -> { try { - new OutsideCall("CYP2D6\tCYP2D6", 3); + new OutsideCall("CYP2D6\t ", 3); } catch (BadOutsideCallException ex) { System.out.println(ex.getMessage()); throw ex; diff --git a/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6.tsv b/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6.tsv index 0053e44d1..05c523713 100644 --- a/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6.tsv +++ b/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6.tsv @@ -1,3 +1 @@ -##Test Astrolabe output -#ROI_label diplotype labels diplotype activity diplotype calling notes jaccard part pValue ROI notes special case nomenclature version CYP2D6 CYP2D6*3/CYP2D6*4 diff --git a/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6_G6PD.tsv b/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6_G6PD.tsv index cfebf993f..c5dfca467 100644 --- a/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6_G6PD.tsv +++ b/src/test/resources/org/pharmgkb/pharmcat/reporter/outside_CYP2D6_G6PD.tsv @@ -1,4 +1,2 @@ -##Test Astrolabe output -#ROI_label diplotype labels diplotype activity diplotype calling notes jaccard part pValue ROI notes special case nomenclature version CYP2D6 CYP2D6*3/CYP2D6*4 -G6PD B (wildtype)/B (wildtype) \ No newline at end of file +G6PD B (wildtype)/B (wildtype)