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
18 changed files
with
893 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...e/src/main/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportBase.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,9 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import htsjdk.variant.vcf.VCFHeader; | ||
|
||
public abstract class CallerSupportBase { | ||
public abstract SvCaller getSvCaller(); | ||
|
||
public abstract boolean isCompatible(VCFHeader vcfHeader); | ||
} |
24 changes: 24 additions & 0 deletions
24
...src/main/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportDelly2.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,24 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import htsjdk.variant.vcf.VCFFilterHeaderLine; | ||
import htsjdk.variant.vcf.VCFHeader; | ||
import htsjdk.variant.vcf.VCFInfoHeaderLine; | ||
|
||
/** Import SV caller support for Delly2. */ | ||
public class CallerSupportDelly2 extends CallerSupportBase { | ||
|
||
public SvCaller getSvCaller() { | ||
return SvCaller.DELLY2_SV; | ||
} | ||
|
||
public boolean isCompatible(VCFHeader vcfHeader) { | ||
final VCFFilterHeaderLine lowQualFilter = vcfHeader.getFilterHeaderLine("LowQual"); | ||
boolean seenLowQualFilter = (lowQualFilter != null); | ||
final VCFInfoHeaderLine ctInfo = vcfHeader.getInfoHeaderLine("CT"); | ||
boolean seenCtInfo = (ctInfo != null); | ||
final VCFInfoHeaderLine impreciseInfo = vcfHeader.getInfoHeaderLine("IMPRECISE"); | ||
boolean seenImpreciseInfo = (impreciseInfo != null); | ||
|
||
return seenLowQualFilter && seenCtInfo && seenImpreciseInfo; | ||
} | ||
} |
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; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...rc/main/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportGeneric.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,23 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import htsjdk.variant.vcf.VCFHeader; | ||
import htsjdk.variant.vcf.VCFInfoHeaderLine; | ||
|
||
/** Import SV caller support for generic SV callers. */ | ||
public class CallerSupportGeneric extends CallerSupportBase { | ||
|
||
public SvCaller getSvCaller() { | ||
return SvCaller.GENERIC; | ||
} | ||
|
||
public boolean isCompatible(VCFHeader vcfHeader) { | ||
final VCFInfoHeaderLine svTypeInfo = vcfHeader.getInfoHeaderLine("SVTYPE"); | ||
boolean seenSvTypeInfo = (svTypeInfo != null); | ||
final VCFInfoHeaderLine svEndInfo = vcfHeader.getInfoHeaderLine("END"); | ||
boolean seenSvTypeEnd = (svEndInfo != null); | ||
final VCFInfoHeaderLine svLenInfo = vcfHeader.getInfoHeaderLine("SVLEN"); | ||
boolean seenSvLenEnd = (svLenInfo != null); | ||
|
||
return seenSvTypeInfo && seenSvTypeEnd && seenSvLenEnd; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../src/main/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportManta.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,23 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
import com.github.bihealth.varfish_annotator.utils.HtsjdkUtils; | ||
import htsjdk.variant.vcf.VCFHeader; | ||
import htsjdk.variant.vcf.VCFHeaderLine; | ||
|
||
/** Import SV caller support for Manta. */ | ||
public class CallerSupportManta extends CallerSupportBase { | ||
|
||
public SvCaller getSvCaller() { | ||
return SvCaller.MANTA; | ||
} | ||
|
||
public boolean isCompatible(VCFHeader vcfHeader) { | ||
for (VCFHeaderLine headerLine : HtsjdkUtils.getSourceHeaderLines(vcfHeader)) { | ||
final String value = headerLine.getValue(); | ||
if (value.startsWith("GenerateSVCandidates")) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...tator-core/src/main/java/com/github/bihealth/varfish_annotator/annotate_svs/SvCaller.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,11 @@ | ||
package com.github.bihealth.varfish_annotator.annotate_svs; | ||
|
||
/** Enum with explicitely supported SV callers and generic support. */ | ||
public enum SvCaller { | ||
DELLY2_SV, | ||
DRAGEN_CNV, | ||
DRAGEN_SV, | ||
GATK_GCNV, | ||
GENERIC, | ||
MANTA, | ||
} |
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; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...ish-annotator-core/src/test/java/com/github/bihealth/varfish_annotator/ResourceUtils.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,53 @@ | ||
package com.github.bihealth.varfish_annotator; | ||
|
||
import java.io.*; | ||
import java.util.zip.GZIPInputStream; | ||
import org.apache.commons.io.IOUtils; | ||
|
||
/** | ||
* Helper class with static methods for handling resources in tests | ||
* | ||
* @author <a href="mailto:[email protected]">Manuel Holtgrewe</a> | ||
*/ | ||
public class ResourceUtils { | ||
|
||
/** Helper function for reading resources into memory */ | ||
public static String readResource(String path) { | ||
StringWriter writer = new StringWriter(); | ||
try { | ||
IOUtils.copy(ResourceUtils.class.getResourceAsStream(path), writer, "UTF-8"); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Problem reading resource " + path, e); | ||
} | ||
return writer.toString(); | ||
} | ||
|
||
/** Copy resource at the given path to the given output {@link File}. */ | ||
public static void copyResourceToFile(String path, File outFile) { | ||
try (InputStream input = ResourceUtils.class.getResourceAsStream(path); | ||
OutputStream os = new FileOutputStream(outFile)) { | ||
byte[] buffer = new byte[1024]; | ||
int length; | ||
while ((length = input.read(buffer)) > 0) { | ||
os.write(buffer, 0, length); | ||
} | ||
} catch (IOException e) { | ||
throw new RuntimeException("Problem with copying resource to file", e); | ||
} | ||
} | ||
|
||
/** gzunip resource at the given path to the given output {@link File}. */ | ||
public static void gunzipResourceToFile(String path, File outFile) { | ||
try (InputStream inputRaw = ResourceUtils.class.getResourceAsStream(path); | ||
GZIPInputStream input = new GZIPInputStream(inputRaw); | ||
OutputStream os = new FileOutputStream(outFile)) { | ||
byte[] buffer = new byte[1024]; | ||
int length; | ||
while ((length = input.read(buffer)) > 0) { | ||
os.write(buffer, 0, length); | ||
} | ||
} catch (IOException e) { | ||
throw new RuntimeException("Problem with copying resource to file", e); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...est/java/com/github/bihealth/varfish_annotator/annotate_svs/CallerSupportDellySvTest.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 CallerSupportDellySvTest { | ||
|
||
@TempDir public File tmpFolder; | ||
File vcfFile; | ||
File otherVcfFile; | ||
CallerSupportDelly2 callerSupport; | ||
|
||
@BeforeEach | ||
void initEach() { | ||
vcfFile = new File(tmpFolder + "/vcf-header.vcf"); | ||
ResourceUtils.copyResourceToFile("/callers-sv/delly2-head.vcf", vcfFile); | ||
otherVcfFile = new File(tmpFolder + "/incompatible.vcf"); | ||
ResourceUtils.copyResourceToFile("/callers-sv/manta-head.vcf", otherVcfFile); | ||
callerSupport = new CallerSupportDelly2(); | ||
} | ||
|
||
@Test | ||
void testGetSvCaller() { | ||
Assertions.assertEquals(SvCaller.DELLY2_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)); | ||
} | ||
} |
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)); | ||
} | ||
} |
Oops, something went wrong.