Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle CTX_INV subtype in SVAnnotate #8693

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public enum ComplexVariantSubtype {
dDUP_iDEL,
INS_iDEL,
CTX_PP_QQ,
CTX_PQ_QP
CTX_PQ_QP,
CTX_INV
}

// not defined in output vcf header but used in internal id that is currently output in the ID column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ protected static List<SVSegment> parseComplexIntervals(final List<String> cpxInt
* protein-coding consequences
*/
@VisibleForTesting
protected static List<SVSegment> getComplexAnnotationIntervals(final List<SVSegment> cpxIntervals,
protected static ArrayList<SVSegment> getComplexAnnotationIntervals(final List<SVSegment> cpxIntervals,
final GATKSVVCFConstants.ComplexVariantSubtype complexType) {
final List<SVSegment> segments = new ArrayList<>(cpxIntervals.size());
final ArrayList<SVSegment> segments = new ArrayList<>(cpxIntervals.size());
final List<SimpleInterval> dupIntervals = new ArrayList<>(cpxIntervals.size());
SimpleInterval inversionIntervalToAdjust = null;
boolean keepSegment;
Expand Down Expand Up @@ -679,8 +679,8 @@ protected static List<SVSegment> getSVSegments(final VariantContext variant,
final int pos = variant.getStart();
final String chr2 = variant.getAttributeAsString(GATKSVVCFConstants.CONTIG2_ATTRIBUTE, null);
final int end2 = variant.getAttributeAsInt(GATKSVVCFConstants.END2_ATTRIBUTE, pos);
final List<String> cpxIntervals = variant.getAttributeAsStringList(GATKSVVCFConstants.CPX_INTERVALS, null);
if (overallSVType.equals(GATKSVVCFConstants.StructuralVariantAnnotationType.CPX)) {
final List<String> cpxIntervals = variant.getAttributeAsStringList(GATKSVVCFConstants.CPX_INTERVALS, null);
if (cpxIntervals.isEmpty()) {
throw new UserException("Complex (CPX) variant must contain CPX_INTERVALS INFO field");
}
Expand All @@ -695,14 +695,22 @@ protected static List<SVSegment> getSVSegments(final VariantContext variant,
new SimpleInterval(chrom, pos, pos + 1)));
}
} else if (overallSVType.equals(GATKSVVCFConstants.StructuralVariantAnnotationType.CTX)) {
intervals = new ArrayList<>(2);
intervals.add(new SVSegment(overallSVType, new SimpleInterval(variant))); // CHROM:POS-POS+1
// annotate both breakpoints of translocation - CHR2:END2-END2+1
// if SVTYPE is CTX and CPX_TYPE is CTX_INV, add INV from CTX_INTERVALS
if (complexType == GATKSVVCFConstants.ComplexVariantSubtype.CTX_INV && !cpxIntervals.isEmpty()) {
intervals = getComplexAnnotationIntervals(parseComplexIntervals(cpxIntervals), complexType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to either have getComplexAnnotationIntervals() return an ArrayList or wrap this call in new ArrayList(). The reason being that the returned List could be immutable (it's not right now, but possible it could change in the future), in which case the calls to .add() below would throw an error.

} else {
intervals = new ArrayList<>(2);
}
// annotate POS and END separately in case END != POS+1, such as in the case of CTX_INV
intervals.add(new SVSegment(overallSVType, new SimpleInterval(chrom, pos, pos)));
intervals.add(new SVSegment(overallSVType, new SimpleInterval(chrom, variant.getEnd(), variant.getEnd())));
// annotate breakpoints of translocation on CHR2 - END2 and END2+1
// TODO: update if POS2 is added to accommodate complex translocations
if (chr2 == null) {
throw new UserException("Translocation (CTX) variant represented as a single record must contain CHR2 INFO field");
}
intervals.add(new SVSegment(overallSVType,
new SimpleInterval(chr2, end2, end2 + 1)));
intervals.add(new SVSegment(overallSVType, new SimpleInterval(chr2, end2, end2)));
intervals.add(new SVSegment(overallSVType, new SimpleInterval(chr2, end2 + 1, end2 + 1)));
} else if (overallSVType.equals(GATKSVVCFConstants.StructuralVariantAnnotationType.BND)){
intervals = new ArrayList<>(2);
final int svLen = variant.getAttributeAsInt(GATKSVVCFConstants.SVLEN, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,8 @@ public Object[][] getComplexSubtypes() {
{ GATKSVVCFConstants.ComplexVariantSubtype.dDUP_iDEL, true },
{ GATKSVVCFConstants.ComplexVariantSubtype.INS_iDEL, false },
{ GATKSVVCFConstants.ComplexVariantSubtype.CTX_PP_QQ, false },
{ GATKSVVCFConstants.ComplexVariantSubtype.CTX_PQ_QP, false }
{ GATKSVVCFConstants.ComplexVariantSubtype.CTX_PQ_QP, false },
{ GATKSVVCFConstants.ComplexVariantSubtype.CTX_INV, false }
};
}

Expand Down Expand Up @@ -564,8 +565,10 @@ public Object[][] getSVTypesAndSegmentsTestData() {
GATKSVVCFConstants.ComplexVariantSubtype.CTX_PP_QQ,
GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
createListOfSVSegments(GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
new SimpleInterval[]{ new SimpleInterval("chr2", 86263976, 86263977),
new SimpleInterval("chr19", 424309, 424310) }),
new SimpleInterval[]{ new SimpleInterval("chr2", 86263976, 86263976),
new SimpleInterval("chr2", 86263977, 86263977),
new SimpleInterval("chr19", 424309, 424309),
new SimpleInterval("chr19", 424310, 424310) }),
null },
{ createVariantContext("chr2", 86263976, 86263976, null, 424309, "G",
"G]chr19:424309]", null, null,"CTX_PP/QQ", null),
Expand All @@ -575,12 +578,28 @@ public Object[][] getSVTypesAndSegmentsTestData() {
new SimpleInterval("chr2", 86263976, 86263976))),
null},
{ createVariantContext("chr2", 86263977, 86263977, null, 424309, "A",
"[chr19:424310[A", null, null, "CTX_PP/QQ", null),
"[chr19:424310[A", -1, null, "CTX_PP/QQ", null),
GATKSVVCFConstants.ComplexVariantSubtype.CTX_PP_QQ,
GATKSVVCFConstants.StructuralVariantAnnotationType.BND,
Arrays.asList(new SVAnnotateEngine.SVSegment(GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
new SimpleInterval("chr2", 86263977, 86263977))),
null },
{ createVariantContext("chr4", 21923233, 22506191, "chr8", 107912008, "N",
"<CTX>", null, null, "CTX_INV",
Collections.singletonList("INV_chr4:21923233-22506191")),
GATKSVVCFConstants.ComplexVariantSubtype.CTX_INV,
GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
Arrays.asList(new SVAnnotateEngine.SVSegment(GATKSVVCFConstants.StructuralVariantAnnotationType.INV,
new SimpleInterval("chr4", 21923233, 22506191)),
new SVAnnotateEngine.SVSegment(GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
new SimpleInterval("chr4", 21923233, 21923233)),
new SVAnnotateEngine.SVSegment(GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
new SimpleInterval("chr4", 22506191, 22506191)),
new SVAnnotateEngine.SVSegment(GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
new SimpleInterval("chr8", 107912008, 107912008)),
new SVAnnotateEngine.SVSegment(GATKSVVCFConstants.StructuralVariantAnnotationType.CTX,
new SimpleInterval("chr8", 107912009, 107912009)) ),
null },
{ createVariantContext("chr2", 205522308, 205522384, "chr2", null, "N",
"<INV>", 76, null, null, null),
null,
Expand Down Expand Up @@ -862,6 +881,13 @@ public Object[][] getAnnotateStructuralVariantTestData() {
createAttributesMap(
Arrays.asList(GATKSVVCFConstants.PROMOTER,GATKSVVCFConstants.INTERGENIC),
Arrays.asList("EMMA2", true)) },
// CTX_INV - this test case is not interchromosomal because the test GTF only has chr1
{ createVariantContext("chr1", 10, 1010, "chr1", 2300, null,
"<CTX>", -1, null, "CTX_INV", Arrays.asList("INV_chr1:10-1010")),
createAttributesMap(
Arrays.asList(GATKSVVCFConstants.INV_SPAN, GATKSVVCFConstants.NONCODING_SPAN,
GATKSVVCFConstants.LOF, GATKSVVCFConstants.INTERGENIC),
Arrays.asList("EMMA1", "DNase", "EMMA2", false))},
// check annotate promoter for all segments in multi-segment SV
{ createVariantContext("chr1", 30, 30, "chr1", 3030, null,
"<BND>", null, "-+", null, null),
Expand Down
Loading