/** * @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); }
/** * Checks to see if the two sets of coordinates have any overlap. */ public static boolean overlaps(final int start, final int end, final int start2, final int end2) { return (start2 >= start && start2 <= end) || (end2 >=start && end2 <= end) || encloses(start2, end2, start, end); }
/** Given a coordinate on the genome (same chromosome) give the corresponding coordinate in the transcript. */ public int getTranscriptCoordinate(final int genomeCoordinate) { int exonOffset = 0; for (final Exon e : exons) { if (genomeCoordinate >= e.start && genomeCoordinate <=e.end) { return (genomeCoordinate - e.start + 1) + exonOffset; } else { exonOffset += CoordMath.getLength(e.start, e.end); } } return -1; }
final int endIndexOfRange = CoordMath.getEnd(currentCycleIndex, desc.length); allRanges.add(new Range(currentCycleIndex, endIndexOfRange)); currentCycleIndex = endIndexOfRange + 1;
} else { final int fragmentStart = Math.min(rec.getAlignmentStart(), rec.getMateAlignmentStart()); final int fragmentEnd = CoordMath.getEnd(fragmentStart, Math.abs(rec.getInferredInsertSize())); fragmentInterval = new Interval(rec.getReferenceName(), fragmentStart, fragmentEnd); CoordMath.getEnd(alignmentBlock.getReferenceStart(), alignmentBlock.getLength()), coverage); final int mateAlignmentEnd = CoordMath.getEnd(rec.getMateAlignmentStart(), mateReferenceLength); properOrientation = SamPairUtil.getPairOrientation(rec) == SamPairUtil.PairOrientation.FR; leftMostAlignedBase = Math.min(rec.getAlignmentStart(), rec.getMateAlignmentStart()); if (properOrientation && CoordMath.encloses(gene.getStart(), gene.getEnd(), leftMostAlignedBase, rightMostAlignedBase)) { if (negativeReadStrand == negativeTranscriptionStrand) { ++metrics.NUM_R1_TRANSCRIPT_STRAND_READS;
final Bait bait = new Bait(target.getContig(), baitStart, CoordMath.getEnd(baitStart, baitSize), target.isNegativeStrand(), designer.makeBaitName(target.getName(), 1, 1)); final int lastBaitStart = CoordMath.getStart(target.getEnd(), baitSize); final double actualShift = (lastBaitStart - firstBaitStart) / (double) (baitCount - 1); int start = firstBaitStart; while (start <= lastBaitStart) { final int end = CoordMath.getEnd(start, baitSize); final Bait bait = new Bait(target.getContig(), start,
public int getIntersectionLength(final Interval other) { if (this.intersects(other)) { return (int) CoordMath.getOverlap(this.getStart(), this.getEnd(), other.getStart(), other.getEnd()); } return 0; }
final int endIndexOfRange = CoordMath.getEnd(currentCycleIndex, desc.length); allRanges.add(new Range(currentCycleIndex, endIndexOfRange)); currentCycleIndex = endIndexOfRange + 1;
} else { final int fragmentStart = Math.min(rec.getAlignmentStart(), rec.getMateAlignmentStart()); final int fragmentEnd = CoordMath.getEnd(fragmentStart, Math.abs(rec.getInferredInsertSize())); fragmentInterval = new Interval(rec.getReferenceName(), fragmentStart, fragmentEnd); CoordMath.getEnd(alignmentBlock.getReferenceStart(), alignmentBlock.getLength()), coverage); final int mateAlignmentEnd = CoordMath.getEnd(rec.getMateAlignmentStart(), mateReferenceLength); properOrientation = SamPairUtil.getPairOrientation(rec) == SamPairUtil.PairOrientation.FR; leftMostAlignedBase = Math.min(rec.getAlignmentStart(), rec.getMateAlignmentStart()); if (properOrientation && CoordMath.encloses(gene.getStart(), gene.getEnd(), leftMostAlignedBase, rightMostAlignedBase)) { if (negativeReadStrand == negativeTranscriptionStrand) { ++metrics.NUM_R1_TRANSCRIPT_STRAND_READS;
final Bait bait = new Bait(target.getContig(), baitStart, CoordMath.getEnd(baitStart, baitSize), target.isNegativeStrand(), designer.makeBaitName(target.getName(), 1, 1)); final int lastBaitStart = CoordMath.getStart(target.getEnd(), baitSize); final double actualShift = (lastBaitStart - firstBaitStart) / (double) (baitCount - 1); int start = firstBaitStart; while (start <= lastBaitStart) { final int end = CoordMath.getEnd(start, baitSize); final Bait bait = new Bait(target.getContig(), start,
public int getIntersectionLength(final Interval other) { if (this.intersects(other)) { return (int) CoordMath.getOverlap(this.getStart(), this.getEnd(), other.getStart(), other.getEnd()); } return 0; }
/** * Returns 1-based index of first base in read that corresponds to M in CIGAR string. * Note that first is relative to 5' end, so that for reverse-strand alignment, the index of * the last base aligned is computed relative to the end of the read. */ int getIndexOfFirstAlignedBase(final SAMRecord rec) { final List<AlignmentBlock> alignmentBlocks = rec.getAlignmentBlocks(); if (rec.getReadNegativeStrandFlag()) { final AlignmentBlock alignmentBlock = alignmentBlocks.get(alignmentBlocks.size() - 1); return rec.getReadLength() - CoordMath.getEnd(alignmentBlock.getReadStart(), alignmentBlock.getLength()) + 1; } else { return alignmentBlocks.get(0).getReadStart(); } } }
/** * @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); }
/** Given a coordinate on the genome (same chromosome) give the corresponding coordinate in the transcript. */ public int getTranscriptCoordinate(final int genomeCoordinate) { int exonOffset = 0; for (final Exon e : exons) { if (genomeCoordinate >= e.start && genomeCoordinate <=e.end) { return (genomeCoordinate - e.start + 1) + exonOffset; } else { exonOffset += CoordMath.getLength(e.start, e.end); } } return -1; }
/** * Checks to see if the two sets of coordinates have any overlap. */ public static boolean overlaps(final int start, final int end, final int start2, final int end2) { return (start2 >= start && start2 <= end) || (end2 >=start && end2 <= end) || encloses(start2, end2, start, end); }
public int getIntersectionLength(final Interval other) { if (this.intersects(other)) { return (int)CoordMath.getOverlap(this.getStart(), this.getEnd(), other.getStart(), other.getEnd()); } return 0; }
/** * Returns 1-based index of first base in read that corresponds to M in CIGAR string. * Note that first is relative to 5' end, so that for reverse-strand alignment, the index of * the last base aligned is computed relative to the end of the read. */ int getIndexOfFirstAlignedBase(final SAMRecord rec) { final List<AlignmentBlock> alignmentBlocks = rec.getAlignmentBlocks(); if (rec.getReadNegativeStrandFlag()) { final AlignmentBlock alignmentBlock = alignmentBlocks.get(alignmentBlocks.size() - 1); return rec.getReadLength() - CoordMath.getEnd(alignmentBlock.getReadStart(), alignmentBlock.getLength()) + 1; } else { return alignmentBlocks.get(0).getReadStart(); } } }