}
public void validateSamRecords(final Iterable<SAMRecord> samRecords,
final SAMFileHeader header) {
SAMRecordIterator iter = (SAMRecordIterator) samRecords.iterator();
final ProgressLogger progress = new ProgressLogger(log, 10000000,
"Validated Read");
try {
while (iter.hasNext()) {
SAMRecord record = iter.next();
final long recordNumber = progress.getCount() + 1;
final Collection<SAMValidationError> errors = record.isValid();
if (errors != null) {
for (final SAMValidationError error : errors) {
error.setRecordNumber(recordNumber);
addError(error);
}
}
validateMateFields(record, recordNumber);
validateSortOrder(record, recordNumber);
validateReadGroup(record, header);
final boolean cigarIsValid = validateCigar(record, recordNumber);
if (cigarIsValid) {
validateNmTag(record, recordNumber);
}
validateSecondaryBaseCalls(record, recordNumber);
validateTags(record, recordNumber);
if (sequenceDictionaryEmptyAndNoWarningEmitted
&& !record.getReadUnmappedFlag()) {
addError(new SAMValidationError(
Type.MISSING_SEQUENCE_DICTIONARY,
"Sequence dictionary is empty", null));
sequenceDictionaryEmptyAndNoWarningEmitted = false;
}
progress.record(record);
}
} catch (SAMFormatException e) {
// increment record number because the iterator behind the
// SAMFileReader
// reads one record ahead so we will get this failure one record
// ahead
final String msg = "SAMFormatException on record "
+ progress.getCount() + 1;
out.println(msg);
throw new PicardException(msg, e);
} catch (FileTruncatedException e) {
addError(new SAMValidationError(Type.TRUNCATED_FILE,
"File is truncated", null));