From 1971f4e591a0acd4f4be8b935b82002b146152e6 Mon Sep 17 00:00:00 2001 From: Steve Huang Date: Mon, 15 Oct 2018 13:50:09 -0400 Subject: [PATCH] Adding Allele constants for simple SV types(#1192) * adding constants for Simple structural variant types to Allele, ex SV_SIMPLE_DEL --- .../htsjdk/variant/variantcontext/Allele.java | 11 ++++++++++- .../variantcontext/StructuralVariantType.java | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/htsjdk/variant/variantcontext/Allele.java b/src/main/java/htsjdk/variant/variantcontext/Allele.java index abfda8b325..dfd11d892f 100644 --- a/src/main/java/htsjdk/variant/variantcontext/Allele.java +++ b/src/main/java/htsjdk/variant/variantcontext/Allele.java @@ -26,7 +26,6 @@ package htsjdk.variant.variantcontext; import htsjdk.samtools.util.StringUtil; -import htsjdk.variant.vcf.VCFConstants; import java.io.Serializable; import java.util.Arrays; @@ -200,6 +199,16 @@ protected Allele(final Allele allele, final boolean ignoreRefState) { public final static Allele NO_CALL = new Allele(NO_CALL_STRING, false); public final static Allele NON_REF_ALLELE = new Allele(NON_REF_STRING, false); + // for simple deletion, e.g. "ALT==" (note that the spec allows, for now at least, alt alleles like ) + public final static Allele SV_SIMPLE_DEL = StructuralVariantType.DEL.toSymbolicAltAllele(); + // for simple insertion, e.g. "ALT==" + public final static Allele SV_SIMPLE_INS = StructuralVariantType.INS.toSymbolicAltAllele(); + // for simple inversion, e.g. "ALT==" + public final static Allele SV_SIMPLE_INV = StructuralVariantType.INV.toSymbolicAltAllele(); + // for simple generic cnv, e.g. "ALT==" + public final static Allele SV_SIMPLE_CNV = StructuralVariantType.CNV.toSymbolicAltAllele(); + // for simple duplication, e.g. "ALT==" + public final static Allele SV_SIMPLE_DUP = StructuralVariantType.DUP.toSymbolicAltAllele(); // --------------------------------------------------------------------------------------------------------- // diff --git a/src/main/java/htsjdk/variant/variantcontext/StructuralVariantType.java b/src/main/java/htsjdk/variant/variantcontext/StructuralVariantType.java index 36b517a2a9..487f089e59 100644 --- a/src/main/java/htsjdk/variant/variantcontext/StructuralVariantType.java +++ b/src/main/java/htsjdk/variant/variantcontext/StructuralVariantType.java @@ -43,5 +43,18 @@ public enum StructuralVariantType { * event can be summarized as a set of novel adjacencies. * Each adjacency ties together two breakends. */ - BND + BND; + + // TODO: 10/10/18 one caveat: BND's have symbolic alt allele, but it takes more information (novel adjacency at the minimum) + /** + * Create angle-bracketed alt allele for simple SV types + * @return angle-bracketed alt allele for simple SV types + * @throws UnsupportedOperationException if this is invoked on a {@link #BND} object + */ + Allele toSymbolicAltAllele() { + if (this.equals(StructuralVariantType.BND)) { + throw new UnsupportedOperationException("BND type does not have angle bracketed alt allele"); + } + return Allele.create("<" + name() + ">", false); + } }