Skip to content

Commit

Permalink
fix(phenotyper): fix bug with stripping gene symbol from outside call…
Browse files Browse the repository at this point in the history
… diplotypes

Remove astrolabe support.

Fix-for: #161
  • Loading branch information
whaleyr authored and markwoon committed Nov 15, 2023
1 parent bcc2c81 commit cb97898
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 46 deletions.
3 changes: 3 additions & 0 deletions docs/using/Outside-Call-Format.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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");
Expand Down
27 changes: 26 additions & 1 deletion src/test/java/org/pharmgkb/pharmcat/PipelineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
""");
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<OutsideCall> 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<OutsideCall> calls = OutsideCallParser.parse(tempAstroPath);
List<OutsideCall> calls = OutsideCallParser.parse(outsideCallPath);
assertNotNull(calls);
assertEquals(1, calls.size());
assertEquals("CYP2C9", calls.get(0).getGene());
Expand All @@ -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<OutsideCall> calls = OutsideCallParser.parse(tempAstroPath);
List<OutsideCall> calls = OutsideCallParser.parse(tmpOutsideCallPath);
assertNotNull(calls);
assertEquals(2, calls.size());
assertEquals("CYP2C9", calls.get(0).getGene());
Expand All @@ -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<OutsideCall> calls = OutsideCallParser.parse(outsideCallPath);
assertEquals(2, calls.size());
assertEquals("*1/*2", calls.get(0).getDiplotype());
assertEquals("*3/*4", calls.get(1).getDiplotype());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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)
G6PD B (wildtype)/B (wildtype)

0 comments on commit cb97898

Please sign in to comment.