private void verifyRecord(final SAMRecord last, final SAMRecord cur) { if (checkOrderP && isOutOfOrder(last, cur)) { this.last = null; throw new UserException.MissortedBAM( String.format( "reads are out of order:%nlast:%n%s%ncurrent:%n%s%n", last.format(), cur.format())); } }
private boolean isOutOfOrder(final SAMRecord last, final SAMRecord cur) { if (last == null || cur.getReadUnmappedFlag()) return false; else { if (last.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX || last.getAlignmentStart() == SAMRecord.NO_ALIGNMENT_START) throw new UserException.MalformedBAM( last, String.format("read %s has inconsistent mapping information.", last.format())); if (cur.getReferenceIndex() == SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX || cur.getAlignmentStart() == SAMRecord.NO_ALIGNMENT_START) throw new UserException.MalformedBAM( last, String.format("read %s has inconsistent mapping information.", cur.format())); return (last.getReferenceIndex() > cur.getReferenceIndex()) || (last.getReferenceIndex().equals(cur.getReferenceIndex()) && last.getAlignmentStart() > cur.getAlignmentStart()); } }