bb12e20332ff8cdf45003f41268011e95ca64221
angie
  Mon Nov 5 15:30:59 2018 -0800
In pslFromGff3Cigar, we should not reverse the order of CIGAR operations when strand is +- or -+.  I'm not sure if the spec covers the -- case for Gap, so making that an errAbort until we get input with that combo.  Tested with BLAT.  Discovered the problem when our altSeqLiftOverPsl alignments on the - strand were a sea of mismatches in hgTracks.  refs #18854 note-27.

diff --git src/lib/psl.c src/lib/psl.c
index 5dc19a6..0aca0d1 100644
--- src/lib/psl.c
+++ src/lib/psl.c
@@ -1939,37 +1939,36 @@
 
 if (cigar == NULL)
     {
     // no cigar means one block
     size = qEnd - qStart;
     totalSize += size;
     psl->blockSizes[psl->blockCount] = size;
     psl->qStarts[psl->blockCount] = qNext;
     psl->tStarts[psl->blockCount] = tNext;
     psl->blockCount++;
     tNext += size;
     qNext += size;
     }
 else
     {
+    if (strand[0] == '-' && strand[1] == '-')
+        errAbort("GFF3 spec is vague about Gap when both strands are '-'; not implemented yet.");
     char cigarSpec[strlen(cigar)+1];  // copy since parsing is destructive
-    strcpy(cigarSpec, cigar);
+    safecpy(cigarSpec, sizeof cigarSpec, cigar);
     char *cigarNext = cigarSpec;
-    if (strand[1] == '-')
-	for(; *cigarNext; cigarNext++)
-	    ;
-    while(getNextCigarOp(cigarSpec, (strand[1] == '-'), &cigarNext, &op, &size))
+    while(getNextCigarOp(cigarSpec, FALSE, &cigarNext, &op, &size))
 	{
 	switch (op)
 	    {
 	    case 'M': // match or mismatch (gapless aligned block)
 		if (psl->blockCount == blocksAlloced)
 		    pslGrow(psl, &blocksAlloced);
 
 		totalSize += size;
 		psl->blockSizes[psl->blockCount] = size;
 		psl->qStarts[psl->blockCount] = qNext;
 		psl->tStarts[psl->blockCount] = tNext;
 		psl->blockCount++;
 		tNext += size;
 		qNext += size;
 		break;