@Override public String toString() { final StringBuilder b = new StringBuilder("EventMap{"); for ( final VariantContext vc : getVariantContexts() ) b.append(String.format("%s:%d-%d %s,", vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles())); b.append("}"); return b.toString(); }
@Override public boolean apply(final VariantContext vc) { final boolean include = !intervalsOfInterestDetector.getOverlaps(new Interval(vc.getContig(), vc.getStart(), vc.getEnd())).isEmpty(); if (!include) LOG.debug("Filtering variant at ", vc.getContig(), ":", vc.getStart(), "-", vc.getEnd()); return include; } }
/** * create a genome location, given a variant context * @param genomeLocParser parser * @param vc the variant context * @return the genomeLoc */ public static final GenomeLoc getLocation(GenomeLocParser genomeLocParser,VariantContext vc) { return genomeLocParser.createGenomeLoc(vc.getChr(), vc.getStart(), vc.getEnd(), true); }
@Override public boolean apply(final VariantContext vc) { final boolean include = !intervalsOfInterestDetector.getOverlaps(new Interval(vc.getContig(), vc.getStart(), vc.getEnd())).isEmpty(); if (!include) LOG.debug("Filtering variant at ", vc.getContig(), ":", vc.getStart(), "-", vc.getEnd()); return include; } }
private boolean overlaps(VariantContext v) { if (intervals == null) { return true; } final Interval interval = new Interval(v.getContig(), v.getStart(), v.getEnd()); Collection<Interval> overlaps = overlapDetector.getOverlaps(interval); return !overlaps.isEmpty(); } }
public VariantContext createEmptyContext(VariantContext other, List<String> samples) { VariantContextBuilder builder = new VariantContextBuilder(); // set the alleles to be the same builder.alleles(other.getAlleles()); builder.loc(other.getChr(),other.getStart(),other.getEnd()); // set all genotypes to empty List<Genotype> genotypes = new ArrayList<Genotype>(samples.size()); for ( String sample : samples ) genotypes.add(GenotypeBuilder.create(sample, new ArrayList<Allele>(0))); builder.genotypes(genotypes); return builder.make(); }
private boolean overlaps(VariantContext v) { if (intervals == null) { return true; } final Interval interval = new Interval(v.getContig(), v.getStart(), v.getEnd()); return overlapDetector.overlapsAny(interval); } }
private boolean overlaps(VariantContext v) { if (intervals == null) { return true; } final Interval interval = new Interval(v.getContig(), v.getStart(), v.getEnd()); return overlapDetector.overlapsAny(interval); } }
/** Returns true if the variant and interval overlap. */ private boolean overlapsInterval(final VariantContext ctx, final Interval interval) { if (!ctx.getContig().equals(interval.getContig())) return false; else if (CoordMath.overlaps(ctx.getStart(), ctx.getEnd(), interval.getStart(), interval.getEnd())) return true; else return false; }
/** Returns true if the variant and interval overlap. */ private boolean overlapsInterval(final VariantContext ctx, final Interval interval) { if (!ctx.getContig().equals(interval.getContig())) return false; else if (CoordMath.overlaps(ctx.getStart(), ctx.getEnd(), interval.getStart(), interval.getEnd())) return true; else return false; }
@Test public void testCreationFromVariantContext() { final VariantContext feature = new VariantContextBuilder("x", "chr1", 1, 5, Arrays.asList(Allele.create("AAAAA", true))).make(); final GenomeLoc loc = genomeLocParser.createGenomeLoc(feature); Assert.assertEquals(loc.getContig(), feature.getChr()); Assert.assertEquals(loc.getStart(), feature.getStart()); Assert.assertEquals(loc.getStop(), feature.getEnd()); }
/** * Copy constructor * * @param other the VariantContext to copy */ protected VariantContext(VariantContext other) { this(other.getSource(), other.getID(), other.getContig(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.getFiltersMaybeNull(), other.getAttributes(), other.fullyDecoded, NO_VALIDATION); }
/** * Copy constructor * * @param other the VariantContext to copy */ protected VariantContext(VariantContext other) { this(other.getSource(), other.getID(), other.getContig(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.getFiltersMaybeNull(), other.getAttributes(), other.fullyDecoded, NO_VALIDATION); }
/** * Copy constructor * * @param other the VariantContext to copy */ protected VariantContext(VariantContext other) { this(other.getSource(), other.getID(), other.getChr(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.getFiltersMaybeNull(), other.getAttributes(), other.fullyDecoded, NO_VALIDATION); }
@Test(dataProvider = "indelFlipData") public void testFlipIndel(final VariantContext source, final ReferenceSequence reference, final VariantContext result) { final LiftOver liftOver = new LiftOver(CHAIN_FILE); final Interval originalLocus = new Interval(source.getContig(), source.getStart(), source.getEnd()); final Interval target = liftOver.liftOver(originalLocus); if (target != null && !target.isNegativeStrand()) { throw new RuntimeException("not reversed"); } final VariantContext flipped = LiftoverUtils.liftVariant(source, target, reference, false, false); VcfTestUtils.assertEquals(flipped, result); }
@Test(dataProvider = "indelFlipDataWithOriginalAllele") public void testFlipIndelWithOriginalAlleles(final VariantContext source, final ReferenceSequence reference, final VariantContext result) { final LiftOver liftOver = new LiftOver(CHAIN_FILE); final Interval originalLocus = new Interval(source.getContig(), source.getStart(), source.getEnd()); final Interval target = liftOver.liftOver(originalLocus); if (target != null && !target.isNegativeStrand()) { throw new RuntimeException("not reversed"); } final VariantContext flipped = LiftoverUtils.liftVariant(source, target, reference, false, true); VcfTestUtils.assertEquals(flipped, result); }
@Test(dataProvider = "snpWithChangedRef") public void snpWithChangedRef(final VariantContext source, final ReferenceSequence reference, final VariantContext result) { final LiftOver liftOver = new LiftOver(POSITIVE_CHAIN_FILE); final Interval originalLocus = new Interval(source.getContig(), source.getStart(), source.getEnd()); final Interval target = liftOver.liftOver(originalLocus); final VariantContext flipped = LiftoverUtils.swapRefAlt(source, LiftoverUtils.DEFAULT_TAGS_TO_REVERSE, LiftoverUtils.DEFAULT_TAGS_TO_DROP); VcfTestUtils.assertEquals(flipped, result); }
@Test(dataProvider = "indelNoFlipData") public void testLiftOverSimpleIndels(final LiftOver liftOver, final ReferenceSequence reference, final VariantContext source, final VariantContext result) { final Interval target = liftOver.liftOver(new Interval(source.getContig(), source.getStart(), source.getEnd()), .95); VariantContextBuilder vcb = LiftoverUtils.liftSimpleVariantContext(source, target); VcfTestUtils.assertEquals(vcb == null ? null : vcb.make(), result); }
@Test(dataProvider = "leftAlignAllelesData") public void testLeftAlignVariants(final VariantContext source, final ReferenceSequence reference, final VariantContext result) { VariantContextBuilder vcb = new VariantContextBuilder(source); LiftoverUtils.leftAlignVariant(vcb, source.getStart(), source.getEnd(), source.getAlleles(), reference); vcb.genotypes(LiftoverUtils.fixGenotypes(source.getGenotypes(), source.getAlleles(), vcb.getAlleles())); VcfTestUtils.assertEquals(vcb.make(), result); }