/** * Lift over the given interval to the new genome build using the liftOverMinMatch set for this * LiftOver object. * @param interval Interval to be lifted over. * @return Interval in the output build coordinates, or null if it cannot be lifted over. */ public Interval liftOver(final Interval interval) { return liftOver(interval, liftOverMinMatch); }
Chain c1 = new Chain(); c1.addChain(new Chain()); Chain preNullChain = c1; Chain returnedChained = null; while ((returnedChained = preNullChain.returnChain()) != null) { preNullChain = returnedChained; } //here, preNullChain is the last Chain that is not null
@Test(dataProvider = "testIntervalsSubset") public void testLiftoverCounter(final Interval in, final Interval expected) { liftOver.resetFailedIntervalsBelowThresholdCounter(); final Interval out = liftOver.liftOver(in); Assert.assertEquals(out, expected); Assert.assertEquals(liftOver.getFailedIntervalsBelowThreshold(), expected == null ? 1 : 0); }
private static Interval createToInterval(final String intervalName, final boolean sourceNegativeStrand, final TargetIntersection targetIntersection) { // Compute the query interval given the offsets of the target interval start and end into the first and // last ContinuousBlocks. int toStart = targetIntersection.chain.getBlock(targetIntersection.firstBlockIndex).toStart + targetIntersection.startOffset; int toEnd = targetIntersection.chain.getBlock(targetIntersection.lastBlockIndex).getToEnd() - targetIntersection.offsetFromEnd; if (toEnd <= toStart || toStart < 0) { throw new SAMException("Something strange lifting over interval " + intervalName); } if (targetIntersection.chain.toOppositeStrand) { // Flip if query is negative. int negativeStart = targetIntersection.chain.toSequenceSize - toEnd; int negativeEnd = targetIntersection.chain.toSequenceSize - toStart; toStart = negativeStart; toEnd = negativeEnd; } // Convert to 1-based, inclusive. final boolean negativeStrand = targetIntersection.chain.toOppositeStrand ? !sourceNegativeStrand : sourceNegativeStrand; return new Interval(targetIntersection.chain.toSequenceName, toStart+1, toEnd, negativeStrand, intervalName); }
void write(final PrintWriter writer) { writer.printf("chain\t%f\t%s\t%d\t+\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%d\n", score, fromSequenceName, fromSequenceSize, fromChainStart, fromChainEnd, toSequenceName, toSequenceSize, (toNegativeStrand? "-": "+"), toChainStart, toChainEnd, id); for (int i = 0; i < blockList.size() - 1; ++i) { final ContinuousBlock thisBlock = blockList.get(i); final ContinuousBlock nextBlock = blockList.get(i+1); final int fromGap = nextBlock.fromStart - thisBlock.getFromEnd(); final int toGap = nextBlock.toStart - thisBlock.getToEnd(); writer.printf("%d\t%d\t%d\n", thisBlock.blockLength, fromGap, toGap); } writer.printf("%d\n", blockList.get(blockList.size() - 1).blockLength); writer.println(); }
@BeforeClass public void initLiftOver() { liftOver = new LiftOver(CHAIN_FILE); contigMap = liftOver.getContigMap(); }
private void addBlock(final int tStart, final int qStart, final int blockLength) { blockList.add(new ContinuousBlock(tStart, qStart, blockLength)); }
/** * Load UCSC chain file in order to lift over Intervals. */ public LiftOver(File chainFile) { IOUtil.assertFileIsReadable(chainFile); chains = Chain.loadChains(chainFile); }
@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); } }
/** * Lift over the given interval to the new genome build using the liftOverMinMatch set for this * LiftOver object. * @param interval Interval to be lifted over. * @return Interval in the output build coordinates, or null if it cannot be lifted over. */ public Interval liftOver(final Interval interval) { return liftOver(interval, liftOverMinMatch); }
private static Interval createToInterval(final String intervalName, final TargetIntersection targetIntersection) { // Compute the query interval given the offsets of the target interval start and end into the first and // last ContinuousBlocks. int toStart = targetIntersection.chain.getBlock(targetIntersection.firstBlockIndex).toStart + targetIntersection.startOffset; int toEnd = targetIntersection.chain.getBlock(targetIntersection.lastBlockIndex).getToEnd() - targetIntersection.offsetFromEnd; if (toEnd <= toStart || toStart < 0) { throw new SAMException("Something strange lifting over interval " + intervalName); } if (targetIntersection.chain.toNegativeStrand) { // Flip if query is negative. int negativeStart = targetIntersection.chain.toSequenceSize - toEnd; int negativeEnd = targetIntersection.chain.toSequenceSize - toStart; toStart = negativeStart; toEnd = negativeEnd; } // Convert to 1-based, inclusive. return new Interval(targetIntersection.chain.toSequenceName, toStart+1, toEnd, targetIntersection.chain.toNegativeStrand, intervalName); }
void write(final PrintWriter writer) { writer.printf("chain\t%f\t%s\t%d\t+\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%d\n", score, fromSequenceName, fromSequenceSize, fromChainStart, fromChainEnd, toSequenceName, toSequenceSize, (toOppositeStrand ? "-": "+"), toChainStart, toChainEnd, id); for (int i = 0; i < blockList.size() - 1; ++i) { final ContinuousBlock thisBlock = blockList.get(i); final ContinuousBlock nextBlock = blockList.get(i+1); final int fromGap = nextBlock.fromStart - thisBlock.getFromEnd(); final int toGap = nextBlock.toStart - thisBlock.getToEnd(); writer.printf("%d\t%d\t%d\n", thisBlock.blockLength, fromGap, toGap); } writer.printf("%d\n", blockList.get(blockList.size() - 1).blockLength); writer.println(); }
Chain returnedChain = null; Chain c1 = new Chain(); c1.addChain(new Chain()); try { returnedChain = c1.returnChain().returnChain().returnChain().returnChain(); } catch (NullPointerException e) { } System.out.println(returnedChain); //now here will print null as what you asked for
private void addBlock(final int tStart, final int qStart, final int blockLength) { blockList.add(new ContinuousBlock(tStart, qStart, blockLength)); }
/** * Lift over the given interval to the new genome build using the liftOverMinMatch set for this * LiftOver object. * @param interval Interval to be lifted over. * @return Interval in the output build coordinates, or null if it cannot be lifted over. */ public Interval liftOver(final Interval interval) { return liftOver(interval, liftOverMinMatch); }
private static Interval createToInterval(final String intervalName, final boolean sourceNegativeStrand, final TargetIntersection targetIntersection) { // Compute the query interval given the offsets of the target interval start and end into the first and // last ContinuousBlocks. int toStart = targetIntersection.chain.getBlock(targetIntersection.firstBlockIndex).toStart + targetIntersection.startOffset; int toEnd = targetIntersection.chain.getBlock(targetIntersection.lastBlockIndex).getToEnd() - targetIntersection.offsetFromEnd; if (toEnd <= toStart || toStart < 0) { throw new SAMException("Something strange lifting over interval " + intervalName); } if (targetIntersection.chain.toOppositeStrand) { // Flip if query is negative. int negativeStart = targetIntersection.chain.toSequenceSize - toEnd; int negativeEnd = targetIntersection.chain.toSequenceSize - toStart; toStart = negativeStart; toEnd = negativeEnd; } // Convert to 1-based, inclusive. final boolean negativeStrand = targetIntersection.chain.toOppositeStrand ? !sourceNegativeStrand : sourceNegativeStrand; return new Interval(targetIntersection.chain.toSequenceName, toStart+1, toEnd, negativeStrand, intervalName); }
void write(final PrintWriter writer) { writer.printf("chain\t%f\t%s\t%d\t+\t%d\t%d\t%s\t%d\t%s\t%d\t%d\t%d\n", score, fromSequenceName, fromSequenceSize, fromChainStart, fromChainEnd, toSequenceName, toSequenceSize, (toOppositeStrand ? "-": "+"), toChainStart, toChainEnd, id); for (int i = 0; i < blockList.size() - 1; ++i) { final ContinuousBlock thisBlock = blockList.get(i); final ContinuousBlock nextBlock = blockList.get(i+1); final int fromGap = nextBlock.fromStart - thisBlock.getFromEnd(); final int toGap = nextBlock.toStart - thisBlock.getToEnd(); writer.printf("%d\t%d\t%d\n", thisBlock.blockLength, fromGap, toGap); } writer.printf("%d\n", blockList.get(blockList.size() - 1).blockLength); writer.println(); }
private void addBlock(final int tStart, final int qStart, final int blockLength) { blockList.add(new ContinuousBlock(tStart, qStart, blockLength)); }
@Test(dataProvider = "testIntervals") public void testBasic(final Interval in, final Interval expected) { Assert.assertEquals(liftOver.liftOver(in), expected); }