/** Constructs a new coverage object for the provided mapping with the desired padding either side. */ public Coverage(final Interval i, final int padding) { this.interval = i; this.depths = new int[interval.length() + 2*padding]; }
/** * Counts the total number of bases a collection of intervals. */ public static long countBases(final Collection<Interval> intervals) { long total = 0; for (final Interval i : intervals) { total += i.length(); } return total; }
/** Constructs a new coverage object for the provided mapping with the desired padding either side. */ public Coverage(final Interval i, final int padding) { this.interval = i; this.depths = new int[interval.length() + 2*padding]; }
/** * Counts the total number of bases a collection of intervals. */ public static long countBases(final Collection<Interval> intervals) { long total = 0; for (final Interval i : intervals) { total += i.length(); } return total; }
/** Counts the total number of bases a collection of intervals. */ public static long countBases(final Collection<Interval> intervals) { long total = 0; for (final Interval i : intervals) { total += i.length(); } return total; }
@Override public long intervalWeight(final Interval interval) { return interval.length(); }
@Override public long intervalWeight(final Interval interval) { return interval.length(); }
public String toString() { if (toInterval == null) { // Matched a chain, but entirely within a gap. return fromInterval.toString() + " (len " + fromInterval.length() + ")=>null using chain " + chainId; } final String strand = toInterval.isNegativeStrand()? "-": "+"; return fromInterval.toString() + " (len " + fromInterval.length() + ")=>" + toInterval + "(" + strand + ") using chain " + chainId + " ; pct matched " + percentLiftedOver; } }
public String toString() { if (toInterval == null) { // Matched a chain, but entirely within a gap. return fromInterval.toString() + " (len " + fromInterval.length() + ")=>null using chain " + chainId; } final String strand = toInterval.isNegativeStrand()? "-": "+"; return fromInterval.toString() + " (len " + fromInterval.length() + ")=>" + toInterval + "(" + strand + ") using chain " + chainId + " ; pct matched " + percentLiftedOver; } }
public String toString() { if (toInterval == null) { // Matched a chain, but entirely within a gap. return fromInterval.toString() + " (len " + fromInterval.length() + ")=>null using chain " + chainId; } final String strand = toInterval.isNegativeStrand()? "-": "+"; return fromInterval.toString() + " (len " + fromInterval.length() + ")=>" + toInterval + "(" + strand + ") using chain " + chainId + " ; pct matched " + percentLiftedOver; } }
@Test(dataProvider = "failingIntervals") public void testDiagnosticLiftover(final Interval fromInterval) { final List<LiftOver.PartialLiftover> partials = liftOver.diagnosticLiftover(fromInterval); System.out.println("Diagnosing " + fromInterval + " (len " + fromInterval.length() + ")"); for (final LiftOver.PartialLiftover partial : partials) { System.out.println(partial); } }
public List<PartialLiftover> diagnosticLiftover(final Interval interval) { final List<PartialLiftover> ret = new ArrayList<PartialLiftover>(); if (interval.length() == 0) { throw new IllegalArgumentException("Zero-length interval cannot be lifted over. Interval: " + interval.getName()); } for (final Chain chain : chains.getOverlaps(interval)) { Interval intersectingChain = interval.intersect(chain.interval); final TargetIntersection targetIntersection = targetIntersection(chain, intersectingChain); if (targetIntersection == null) { ret.add(new PartialLiftover(intersectingChain, chain.id)); } else { Interval toInterval = createToInterval(interval.getName(), targetIntersection); float percentLiftedOver = targetIntersection.intersectionLength/(float)interval.length(); ret.add(new PartialLiftover(intersectingChain, toInterval, targetIntersection.chain.id, percentLiftedOver)); } } return ret; }
public List<PartialLiftover> diagnosticLiftover(final Interval interval) { final List<PartialLiftover> ret = new ArrayList<PartialLiftover>(); if (interval.length() == 0) { throw new IllegalArgumentException("Zero-length interval cannot be lifted over. Interval: " + interval.getName()); } for (final Chain chain : chains.getOverlaps(interval)) { Interval intersectingChain = interval.intersect(chain.interval); final TargetIntersection targetIntersection = targetIntersection(chain, intersectingChain); if (targetIntersection == null) { ret.add(new PartialLiftover(intersectingChain, chain.id)); } else { Interval toInterval = createToInterval(interval.getName(), interval.isNegativeStrand(), targetIntersection); float percentLiftedOver = targetIntersection.intersectionLength/(float)interval.length(); ret.add(new PartialLiftover(intersectingChain, toInterval, targetIntersection.chain.id, percentLiftedOver)); } } return ret; }
public List<PartialLiftover> diagnosticLiftover(final Interval interval) { final List<PartialLiftover> ret = new ArrayList<PartialLiftover>(); if (interval.length() == 0) { throw new IllegalArgumentException("Zero-length interval cannot be lifted over. Interval: " + interval.getName()); } for (final Chain chain : chains.getOverlaps(interval)) { Interval intersectingChain = interval.intersect(chain.interval); final TargetIntersection targetIntersection = targetIntersection(chain, intersectingChain); if (targetIntersection == null) { ret.add(new PartialLiftover(intersectingChain, chain.id)); } else { Interval toInterval = createToInterval(interval.getName(), interval.isNegativeStrand(), targetIntersection); float percentLiftedOver = targetIntersection.intersectionLength/(float)interval.length(); ret.add(new PartialLiftover(intersectingChain, toInterval, targetIntersection.chain.id, percentLiftedOver)); } } return ret; }
if (interval.length() == 0) { throw new IllegalArgumentException("Zero-length interval cannot be lifted over. Interval: " + interval.getName()); TargetIntersection targetIntersection = null; double minMatchSize = liftOverMinMatch * interval.length(); " because intersection length " + candidateIntersection.intersectionLength + " < minMatchSize " + minMatchSize + " (" + (candidateIntersection.intersectionLength/(float)interval.length()) + " < " + liftOverMinMatch + ")");
@Test public void testCoverageGetTotalOverflow() { final Interval interval = new Interval("chr1", 1, 2); final TargetMetricsCollector.Coverage coverage = new TargetMetricsCollector.Coverage(interval, 0); for (int offset = 0; offset <= interval.length(); offset++) { coverage.addBase(offset, Integer.MAX_VALUE - 1); } Assert.assertEquals((long)coverage.getTotal(), 2 * (long)(Integer.MAX_VALUE - 1)); } }
protected static VariantContextBuilder liftSimpleVariantContext(VariantContext source, Interval target) { if (target == null || source.getReference().length() != target.length()) { return null; } // Build the new variant context. Note: this will copy genotypes, annotations and filters final VariantContextBuilder builder = new VariantContextBuilder(source); builder.chr(target.getContig()); builder.start(target.getStart()); builder.stop(target.getEnd()); return builder; }
protected static VariantContextBuilder liftSimpleVariantContext(VariantContext source, Interval target) { if (target == null || source.getReference().length() != target.length()) { return null; } // Build the new variant context. Note: this will copy genotypes, annotations and filters final VariantContextBuilder builder = new VariantContextBuilder(source); builder.chr(target.getContig()); builder.start(target.getStart()); builder.stop(target.getEnd()); return builder; }
@Override public List<Interval> takeSome(final Interval interval, final long idealSplitWeight, final long currentSize, final double projectSizeOfRemaining) { final long amount = idealSplitWeight - currentSize; if (amount >= interval.length()) { return CollectionUtil.makeList(interval, null); } if (amount == 0) { return CollectionUtil.makeList(null, interval); } final Interval left = new Interval( interval.getContig(), interval.getStart(), interval.getStart() + (int) amount - 1, interval.isNegativeStrand(), interval.getName() ); final Interval right = new Interval( interval.getContig(), interval.getStart() + (int) amount, interval.getEnd(), interval.isNegativeStrand(), interval.getName() ); return CollectionUtil.makeList(left, right); } }
@Override public List<Interval> takeSome(final Interval interval, final long idealSplitWeight, final long currentSize, final double projectSizeOfRemaining) { final long amount = idealSplitWeight - currentSize; if (amount >= interval.length()) { return CollectionUtil.makeList(interval, null); } if (amount == 0) { return CollectionUtil.makeList(null, interval); } final Interval left = new Interval( interval.getContig(), interval.getStart(), interval.getStart() + (int) amount - 1, interval.isNegativeStrand(), interval.getName() ); final Interval right = new Interval( interval.getContig(), interval.getStart() + (int) amount, interval.getEnd(), interval.isNegativeStrand(), interval.getName() ); return CollectionUtil.makeList(left, right); } }