reader.setValidationStringency(ValidationStringency.SILENT);
SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(
reader.getFileHeader(), true, new File(output));
CompareToReference c2r = new CompareToReference();
c2r.init(reference);
int i=0;
for (SAMRecord read : reader) {
int numMismatches = c2r.numMismatches(read);
int numIndelBases = getNumIndelBases(read);
int editDistance = numMismatches + numIndelBases;
read.setAttribute("NM", editDistance);