/** * @return true if both are on same reference, and the overlap. */ public boolean overlaps(final QueryInterval other) { if (this.referenceIndex != other.referenceIndex) { return false; } final int thisEnd = (this.end == 0 ? Integer.MAX_VALUE : this.end); final int otherEnd = (other.end == 0 ? Integer.MAX_VALUE : other.end); return CoordMath.overlaps(this.start, thisEnd, other.start, otherEnd); }
/** * @return true if both are on same reference, and the overlap. */ public boolean overlaps(final QueryInterval other) { if (this.referenceIndex != other.referenceIndex) { return false; } final int thisEnd = (this.end == 0 ? Integer.MAX_VALUE : this.end); final int otherEnd = (other.end == 0 ? Integer.MAX_VALUE : other.end); return CoordMath.overlaps(this.start, thisEnd, other.start, otherEnd); }
/** * @return true if both are on same reference, and the overlap. */ public boolean overlaps(final QueryInterval other) { if (this.referenceIndex != other.referenceIndex) { return false; } final int thisEnd = (this.end == 0 ? Integer.MAX_VALUE : this.end); final int otherEnd = (other.end == 0 ? Integer.MAX_VALUE : other.end); return CoordMath.overlaps(this.start, thisEnd, other.start, otherEnd); }
/** Returns true if this interval overlaps the other interval, otherwise false. */ public boolean intersects(final Interval other) { return (this.getSequence().equals(other.getSequence()) && CoordMath.overlaps(this.start, this.end, other.start, other.end)); }
/** 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 this interval overlaps the other interval, otherwise false. */ public boolean intersects(final Interval other) { return (this.getContig().equals(other.getContig()) && CoordMath.overlaps(this.getStart(), this.getEnd(), other.getStart(), other.getEnd())); }
/** * Returns true if this interval overlaps the other interval, otherwise false. */ public boolean intersects(final Interval other) { return (this.getContig().equals(other.getContig()) && CoordMath.overlaps(this.getStart(), this.getEnd(), other.getStart(), other.getEnd())); }
/** 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; }
/** * Determines whether this interval comes within {@code distance} of overlapping the provided locatable. * When distance = 0 this is equal to {@link #overlaps(Locatable)} * * @param other interval to check * @param distance how many bases may be between the two intervals for us to still consider them overlapping. * @return true if this interval overlaps other, otherwise false */ default boolean withinDistanceOf(Locatable other, int distance) { return contigsMatch(other) && CoordMath.overlaps(getStart(), getEnd(), other.getStart()-distance, other.getEnd()+distance); }
/** * Determines whether this interval comes within {@code distance} of overlapping the provided locatable. * When distance = 0 this is equal to {@link #overlaps(Locatable)} * * @param other interval to check * @param distance how many bases may be between the two intervals for us to still consider them overlapping. * @return true if this interval overlaps other, otherwise false */ default boolean withinDistanceOf(Locatable other, int distance) { return contigsMatch(other) && CoordMath.overlaps(getStart(), getEnd(), other.getStart()-distance, other.getEnd()+distance); }
final int intervalStart = interval.getStart(); if (!CoordMath.overlaps(refPos, refPos + alignmentBlock.getLength(), intervalStart, intervalEnd)) { continue;
final int intervalStart = interval.getStart(); if (!CoordMath.overlaps(refPos, refPos + alignmentBlock.getLength(), intervalStart, intervalEnd)) { continue;
final SAMRecord record = iterator.next(); if (record.getReferenceIndex().intValue() == refId) { boolean overlaps = CoordMath.overlaps(record.getAlignmentStart(), record.getAlignmentEnd(), alignmentSpan.getStart(), alignmentSpan.getStart()+ alignmentSpan.getSpan()); if (overlaps) matchFound = true;
final SAMRecord record = iterator.next(); if (record.getReferenceIndex().intValue() == refId) { boolean overlaps = CoordMath.overlaps(record.getAlignmentStart(), record.getAlignmentEnd(), alignmentSpan.getStart(), alignmentSpan.getStart()+ alignmentSpan.getSpan()); if (overlaps) matchFound = true;
@Test public void scanMappedReads() throws IOException { SamReader samReader = SamReaderFactory.makeDefault().open(BAM_FILE); SAMRecordIterator samRecordIterator = samReader.iterator(); CRAMFileReader reader = new CRAMFileReader(new ByteArraySeekableStream(cramBytes), new ByteArraySeekableStream(baiBytes), source, ValidationStringency.SILENT); reader.setValidationStringency(ValidationStringency.SILENT); int counter = 0; while (samRecordIterator.hasNext()) { SAMRecord samRecord = samRecordIterator.next(); if (samRecord.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX) break; // test only 1st and 2nd in every 100 to speed the test up: if (counter++ %100 > 1) continue; String s1 = samRecord.getSAMString(); CloseableIterator<SAMRecord> iterator = reader.queryAlignmentStart(samRecord.getReferenceName(), samRecord.getAlignmentStart()); Assert.assertTrue(iterator.hasNext(), counter + ": " + s1); SAMRecord cramRecord = iterator.next(); String s2 = cramRecord.getSAMString(); Assert.assertEquals(samRecord.getReferenceName(), cramRecord.getReferenceName(), s1 + s2); // default 'overlap' is true, so test records intersect the query: Assert.assertTrue(CoordMath.overlaps(cramRecord.getAlignmentStart(), cramRecord.getAlignmentEnd(), samRecord.getAlignmentStart(), samRecord.getAlignmentEnd()), s1 + s2); } samRecordIterator.close(); reader.close(); Assert.assertEquals(counter, nofMappedReads); }
Assert.assertTrue(CoordMath.overlaps( cramRecord.getAlignmentStart(), cramRecord.getAlignmentEnd(),