Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Adding explicit support for SV/CNV calling tools (#68)
Browse files Browse the repository at this point in the history
Closes: #68
Related-Issue: #68
Projected-Results-Impact: none
  • Loading branch information
holtgrewe committed Sep 13, 2022
1 parent 753aea5 commit fbbafef
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 0 deletions.
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;
}
}
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;
}
}
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;
}
}
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));
}
}
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));
}
}

0 comments on commit fbbafef

Please sign in to comment.