/**
* Creates a new SAM record from the basecall data
*/
private SAMRecord createSamRecord(final ReadData readData, final String readName, final boolean isPf, final boolean firstOfPair, final String unmatchedBarcode) {
final SAMRecord sam = new SAMRecord(null);
sam.setReadName(readName);
sam.setReadBases(readData.getBases());
sam.setBaseQualities(readData.getQualities());
// Flag values
sam.setReadPairedFlag(isPairedEnd);
sam.setReadUnmappedFlag(true);
sam.setReadFailsVendorQualityCheckFlag(!isPf);
if (isPairedEnd) {
sam.setMateUnmappedFlag(true);
sam.setFirstOfPairFlag(firstOfPair);
sam.setSecondOfPairFlag(!firstOfPair);
}
if (filters.filterOut(sam)) {
sam.setAttribute(ReservedTagConstants.XN, 1);
}
if (this.readGroupId != null) {
sam.setAttribute(SAMTag.RG.name(), readGroupId);
}
// If it's a barcoded run and the read isn't assigned to a barcode, then add the barcode
// that was read as an optional tag
if (unmatchedBarcode != null) {
sam.setAttribute(SAMTag.BC.name(), unmatchedBarcode);
}
return sam;
}