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

Commit

Permalink
Adding support to annotate CNVs with DoC (#73)
Browse files Browse the repository at this point in the history
Closes: #73
Related-Issue: #73
Projected-Results-Impact: none
  • Loading branch information
holtgrewe committed Sep 19, 2022
1 parent f0bed05 commit 6c3008b
Show file tree
Hide file tree
Showing 46 changed files with 20,620 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/tests/**/*.ser filter=lfs diff=lfs merge=lfs -text
/tests/**/*.vcf* filter=lfs diff=lfs merge=lfs -text
/varfish-annotator-cli/src/test/resources/input/real-world-37/* filter=lfs diff=lfs merge=lfs -text
/varfish-annotator-cli/src/test/resources/input/*/*.vcf* filter=lfs diff=lfs merge=lfs -text
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## v0.27 (work in progress)

- Writing out proper SV type for Dragen CNV (#76)
- Adding support for depth of coverage annotation (#73)

## v0.26

- Explicitely model support for SV callers (#68)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import java.util.ArrayList;
import java.util.List;

/**
* JCommander command for <tt>varfish_annotator annotate-sv</tt>.
Expand Down Expand Up @@ -110,6 +112,12 @@ public final class AnnotateSvsArgs {
"Skip records with this filter value (comma-separated list), default is 'LowQual'")
private String skipFilters = "LowQual";

@Parameter(
names = "--coverage-vcf",
description =
"Annotate CNV with coverage and mapping quality from maelstrom-core coverage VCF file")
private List<String> coverageVcfs = new ArrayList<>();

public String getRefseqSerPath() {
return refseqSerPath;
}
Expand Down Expand Up @@ -186,6 +194,10 @@ public String getSkipFilters() {
return skipFilters;
}

public List<String> getCoverageVcfs() {
return coverageVcfs;
}

@Override
public String toString() {
return "AnnotateSvsArgs{"
Expand Down Expand Up @@ -236,16 +248,17 @@ public String toString() {
+ '\''
+ ", sequentialUuids="
+ sequentialUuids
+ '\''
+ ", optOutFeatures=\'"
+ ", optOutFeatures='"
+ optOutFeatures
+ "\'"
+ ", writeBndMates=\'"
+ '\''
+ ", writeBndMates='"
+ writeBndMates
+ "\'"
+ ", skipFilters=\'"
+ '\''
+ ", skipFilters='"
+ skipFilters
+ "\'"
+ '\''
+ ", coverageVcfs="
+ coverageVcfs
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Closer;
import de.charite.compbio.jannovar.annotation.SVAnnotation;
import de.charite.compbio.jannovar.annotation.SVAnnotations;
import de.charite.compbio.jannovar.data.JannovarData;
Expand All @@ -36,10 +37,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -67,14 +65,10 @@ public final class AnnotateSvsVcf {
/** Pedigree to use for annotation. */
private Pedigree pedigree;

/** Helper to use for creating genotypes and feature effects files. */
private CallerSupport callerSupport;

/** Construct with the given configuration. */
public AnnotateSvsVcf(AnnotateSvsArgs args) {
this.args = args;
this.pedigree = null;
this.callerSupport = CallerSupportFactory.getFor(new File(args.getInputVcf()));
}

/** UUID counter for sequential UUID generation. */
Expand Down Expand Up @@ -139,19 +133,36 @@ public void run() {
featureEffectsStream, args.getOutputFeatureEffects());
Writer dbInfoWriter =
GzipUtil.maybeOpenGzipOutputStream(dbInfoStream, args.getOutputDbInfos());
BufferedWriter dbInfoBufWriter = new BufferedWriter(dbInfoWriter); ) {
BufferedWriter dbInfoBufWriter = new BufferedWriter(dbInfoWriter);
Closer covVcfCloser = Closer.create(); ) {
// Guess genome version.
GenomeVersion genomeVersion = new VcfCompatibilityChecker(reader).guessGenomeVersion();

new VcfCompatibilityChecker(reader).check(args.getRelease());
new DatabaseSelfTest(conn)
.selfTest(args.getRelease(), args.isSelfTestChr1Only(), args.isSelfTestChr22Only());

final Map<String, CoverageFromMaelstromReader> covReaders = new TreeMap<>();
for (String covVcf : args.getCoverageVcfs()) {
final CoverageFromMaelstromReader covReader =
new CoverageFromMaelstromReader(new File(covVcf));
covReaders.put(covReader.getSample(), covReader);
covVcfCloser.register(covReader);
}
final CallerSupport callerSupport =
new CallerSupportFactory(covReaders).getFor(new File(args.getInputVcf()));

System.err.println("Deserializing Jannovar file...");
JannovarData refseqJvData = new JannovarDataSerializer(args.getRefseqSerPath()).load();
JannovarData ensemblJvData = new JannovarDataSerializer(args.getEnsemblSerPath()).load();
annotateSvVcf(
genomeVersion, reader, refseqJvData, ensemblJvData, gtWriter, featureEffectsWriter);
genomeVersion,
reader,
refseqJvData,
ensemblJvData,
callerSupport,
gtWriter,
featureEffectsWriter);
new DbInfoWriterHelper()
.writeDbInfos(conn, dbInfoBufWriter, args.getRelease(), AnnotateVcf.class);
} catch (SQLException e) {
Expand Down Expand Up @@ -217,6 +228,7 @@ private void checkOptOutFeatures() {
* @param reader Reader for the input VCF file.
* @param refseqJv Deserialized RefSeq transcript database for Jannovar.
* @param ensemblJv Deserialized ENSEMBL transcript database for Jannovar.
* @param callerSupport Helper to use for adapting to SV caller.
* @param gtWriter Writer for variant call ("genotype") TSV file.
* @param featureEffectsWriter Writer for gene-wise feature effects.
* @throws VarfishAnnotatorException in case of problems
Expand All @@ -226,6 +238,7 @@ private void annotateSvVcf(
VCFFileReader reader,
JannovarData refseqJv,
JannovarData ensemblJv,
CallerSupport callerSupport,
Writer gtWriter,
Writer featureEffectsWriter)
throws VarfishAnnotatorException {
Expand Down
Loading

0 comments on commit 6c3008b

Please sign in to comment.