private int compareCoordinates(final SAMRecord record1, final SAMRecord record2) { final int seqIndex1 = record1.getReferenceIndex(); final int seqIndex2 = record2.getReferenceIndex(); if (seqIndex1 == -1) { return ((seqIndex2 == -1) ? 0 : -1); } else if (seqIndex2 == -1) { return 1; } int result = seqIndex1 - seqIndex2; if (result != 0) { return result; } result = record1.getAlignmentStart() - record2.getAlignmentStart(); return result; }
private boolean passesFilter( final SAMRecord record, final String sequence, final int startPos, final int endPos, final boolean contained) { if (record == null) { return false; } if (!safeEquals(record.getReferenceName(), sequence)) { return false; } final int alignmentStart = record.getAlignmentStart(); int alignmentEnd = record.getAlignmentEnd(); if (alignmentStart <= 0) { assertTrue(record.getReadUnmappedFlag()); return false; } if (alignmentEnd <= 0) { // For indexing-only records, treat as single base alignment. assertTrue(record.getReadUnmappedFlag()); alignmentEnd = alignmentStart; } if (contained) { if (startPos != 0 && alignmentStart < startPos) { return false; } if (endPos != 0 && alignmentEnd > endPos) { return false; } } else { if (startPos != 0 && alignmentEnd < startPos) { return false; } if (endPos != 0 && alignmentStart > endPos) { return false; } } return true; }