This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding explicit support for SV/CNV calling tools (#68)
- Loading branch information
Showing
5 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
.../main/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportDragenCnv.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import htsjdk.variant.vcf.VCFFilterHeaderLine; | ||
import htsjdk.variant.vcf.VCFHeader; | ||
import htsjdk.variant.vcf.VCFHeaderLine; | ||
|
||
/** Import SV caller support for Dragen CNV. */ | ||
public class CallerSupportDragenCnv extends CallerSupportBase { | ||
|
||
public SvCaller getSvCaller() { | ||
return SvCaller.DRAGEN_CNV; | ||
} | ||
|
||
public boolean isCompatible(VCFHeader vcfHeader) { | ||
boolean seenDragenVersionHeaderLine = false; | ||
boolean seenDragenCommandLineHeaderLine = false; | ||
for (VCFHeaderLine headerLine : vcfHeader.getOtherHeaderLines()) { | ||
if (headerLine.getKey().equals("DRAGENVersion")) { | ||
seenDragenVersionHeaderLine = true; | ||
} else if (headerLine.getKey().equals("DRAGENCommandLine")) { | ||
seenDragenCommandLineHeaderLine = true; | ||
} | ||
} | ||
|
||
final VCFFilterHeaderLine cnvBinSupportRatio = | ||
vcfHeader.getFilterHeaderLine("cnvBinSupportRatio"); | ||
boolean seenCnvBinSupportRatioFilter = (cnvBinSupportRatio != null); | ||
|
||
return seenDragenVersionHeaderLine | ||
&& seenDragenCommandLineHeaderLine | ||
&& seenCnvBinSupportRatioFilter; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...c/main/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportDragenSv.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import com.github.bihealth.varfish_annotator.utils.HtsjdkUtils; | ||
import htsjdk.variant.vcf.VCFFilterHeaderLine; | ||
import htsjdk.variant.vcf.VCFHeader; | ||
import htsjdk.variant.vcf.VCFHeaderLine; | ||
import htsjdk.variant.vcf.VCFInfoHeaderLine; | ||
|
||
/** Import SV caller support for Dragen SV. */ | ||
public class CallerSupportDragenSv extends CallerSupportBase { | ||
|
||
public SvCaller getSvCaller() { | ||
return SvCaller.DRAGEN_SV; | ||
} | ||
|
||
public boolean isCompatible(VCFHeader vcfHeader) { | ||
boolean seenSourceDragen = false; | ||
for (VCFHeaderLine headerLine : HtsjdkUtils.getSourceHeaderLines(vcfHeader)) { | ||
final String value = headerLine.getValue(); | ||
if (value.startsWith("DRAGEN")) { | ||
seenSourceDragen = true; | ||
} | ||
} | ||
|
||
final VCFFilterHeaderLine minQualFilter = vcfHeader.getFilterHeaderLine("MinQUAL"); | ||
boolean seenMinQualFilter = (minQualFilter != null); | ||
final VCFInfoHeaderLine mateIdInfo = vcfHeader.getInfoHeaderLine("MATEID"); | ||
boolean seenMateIdInfo = (mateIdInfo != null); | ||
|
||
return seenSourceDragen && seenMinQualFilter && seenMateIdInfo; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...annotator-core/src/main/java/com/github/bihealth/varfish_annotator/utils/HtsjdkUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.github.bihealth.varfish_annotator.utils; | ||
|
||
import htsjdk.variant.vcf.VCFHeader; | ||
import htsjdk.variant.vcf.VCFHeaderLine; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class HtsjdkUtils { | ||
public static List<VCFHeaderLine> getSourceHeaderLines(VCFHeader vcfHeader) { | ||
final ArrayList<VCFHeaderLine> result = new ArrayList<>(); | ||
for (VCFHeaderLine headerLine : vcfHeader.getOtherHeaderLines()) { | ||
if (headerLine.getKey().equals("source")) { | ||
result.add(headerLine); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...t/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportDragenCnvTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import com.github.bihealth.varfish_annotator.ResourceUtils; | ||
import htsjdk.variant.vcf.VCFFileReader; | ||
import htsjdk.variant.vcf.VCFHeader; | ||
import java.io.File; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
public class CallerSupportDragenCnvTest { | ||
|
||
@TempDir public File tmpFolder; | ||
File vcfFile; | ||
File otherVcfFile; | ||
CallerSupportDragenCnv callerSupport; | ||
|
||
@BeforeEach | ||
void initEach() { | ||
vcfFile = new File(tmpFolder + "/vcf-header.vcf"); | ||
ResourceUtils.copyResourceToFile("/callers-sv/dragen-cnv-head.vcf", vcfFile); | ||
otherVcfFile = new File(tmpFolder + "/incompatible.vcf"); | ||
ResourceUtils.copyResourceToFile("/callers-sv/delly2-head.vcf", otherVcfFile); | ||
callerSupport = new CallerSupportDragenCnv(); | ||
} | ||
|
||
@Test | ||
void testGetSvCaller() { | ||
Assertions.assertEquals(SvCaller.DRAGEN_CNV, callerSupport.getSvCaller()); | ||
} | ||
|
||
@Test | ||
void testIsCompatiblePositive() { | ||
final VCFFileReader vcfReader = new VCFFileReader(vcfFile, false); | ||
final VCFHeader vcfHeader = vcfReader.getHeader(); | ||
|
||
Assertions.assertTrue(callerSupport.isCompatible(vcfHeader)); | ||
} | ||
|
||
@Test | ||
void testIsCompatibleNegative() { | ||
final VCFFileReader vcfReader = new VCFFileReader(vcfFile, false); | ||
final VCFHeader vcfHeader = vcfReader.getHeader(); | ||
|
||
Assertions.assertTrue(callerSupport.isCompatible(vcfHeader)); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...st/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportDragenSvTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import com.github.bihealth.varfish_annotator.ResourceUtils; | ||
import htsjdk.variant.vcf.VCFFileReader; | ||
import htsjdk.variant.vcf.VCFHeader; | ||
import java.io.File; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
public class CallerSupportDragenSvTest { | ||
|
||
@TempDir public File tmpFolder; | ||
File vcfFile; | ||
File otherVcfFile; | ||
CallerSupportDragenSv callerSupport; | ||
|
||
@BeforeEach | ||
void initEach() { | ||
vcfFile = new File(tmpFolder + "/vcf-header.vcf"); | ||
ResourceUtils.copyResourceToFile("/callers-sv/dragen-sv-head.vcf", vcfFile); | ||
otherVcfFile = new File(tmpFolder + "/incompatible.vcf"); | ||
ResourceUtils.copyResourceToFile("/callers-sv/delly2-head.vcf", otherVcfFile); | ||
callerSupport = new CallerSupportDragenSv(); | ||
} | ||
|
||
@Test | ||
void testGetSvCaller() { | ||
Assertions.assertEquals(SvCaller.DRAGEN_SV, callerSupport.getSvCaller()); | ||
} | ||
|
||
@Test | ||
void testIsCompatiblePositive() { | ||
final VCFFileReader vcfReader = new VCFFileReader(vcfFile, false); | ||
final VCFHeader vcfHeader = vcfReader.getHeader(); | ||
|
||
Assertions.assertTrue(callerSupport.isCompatible(vcfHeader)); | ||
} | ||
|
||
@Test | ||
void testIsCompatibleNegative() { | ||
final VCFFileReader vcfReader = new VCFFileReader(vcfFile, false); | ||
final VCFHeader vcfHeader = vcfReader.getHeader(); | ||
|
||
Assertions.assertTrue(callerSupport.isCompatible(vcfHeader)); | ||
} | ||
} |