 +	const char* xsiString = "";
 +	if(features.secondBestScore != 0xffff) {
 +		snprintf(xsibuf, 100, "%d", features.secondBestScore);
-+		xsiSeparator = "\tXS:i";
++		xsiSeparator = "\tXS:i:-";
 +		xsiString = xsibuf;
 +	}
 +	
 +	// ZT:Z
 +	char ztzbuf[1024];
 +	const char* ztzSeparator = "\tZT:Z:";
-+	snprintf(ztzbuf, 1023, "%d,%d,%0.8f,%0.8f,%d", features.bestScore, features.bestScore-features.secondBestScore, features.probabilityOfAllCandidates, features.probabilityOfBestCandidate, features.popularSeedsSkipped);
++	snprintf(ztzbuf, 1023, "%0.8f,%0.8f,%d", features.probabilityOfAllCandidates, features.probabilityOfBestCandidate, features.popularSeedsSkipped);
 +	const char* ztzString = ztzbuf;
 +	
 +    int charsInString = snprintf(buffer, bufferSpace, "%.*s\t%d\t%s\t%u\t%d\t%s\t%s\t%u\t%lld\t%.*s\t%.*s%s%.*s%s%s%s%s%s%s\tPG:Z:SNAP%s%.*s%s%s\n",

-    int charsInString = snprintf(buffer, bufferSpace, "%.*s\t%d\t%s\t%u\t%d\t%s\t%s\t%u\t%lld\t%.*s\t%.*s%s%.*s%s%s\tPG:Z:SNAP%s%.*s\n",
+	// AS:i
+	char asibuf[100];
+	const char* asiSeparator = "\tAS:i:";
+	snprintf(asibuf, 100, "%d", features.bestScore);
+	const char* asiString = asibuf;
+	

                     if (0 == addFrontClipping) {
diff -rupN -x Xcode -x .git tmp/snap/SNAPLib/SAM.cpp snap/SNAPLib/SAM.cpp
--- tmp/snap/SNAPLib/SAM.cpp	2015-07-28 15:15:02.000000000 -0400
+++ snap/SNAPLib/SAM.cpp	2015-07-28 16:57:37.000000000 -0400
@@ -1123,6 +1123,7 @@ SAMFormat::writeRead(
     Read * read,
     AlignmentResult result, 
