fa85991b426e3a45db1cbfc03d832db1f4aead3c
angie
  Tue Jun 18 13:27:25 2024 -0700
Bugfix: when END is not defined as integer in the VCF header, it is assumed to be a string, so make sure to convert to int if needed before using as chromEnd.

diff --git src/lib/vcf.c src/lib/vcf.c
index e34a580..f23e9c5 100644
--- src/lib/vcf.c
+++ src/lib/vcf.c
@@ -624,31 +624,37 @@
 	    data[j].datString = vcfFilePooledStr(vcff, valWords[j]);
 	    break;
 	case vcfInfoCharacter:
 	    data[j].datChar = valWords[j][0];
 	    break;
 	case vcfInfoString:
 	    data[j].datString = vcfFilePooledStr(vcff, valWords[j]);
 	    break;
 	default:
 	    errAbort("invalid vcfInfoType (uninitialized?) %d", type);
 	    break;
 	}
     }
 // If END is given, use it as chromEnd:
 if (sameString(infoKey, vcfInfoEnd))
+    {
+    // But check first whether the header defined it as an int because if not, it was stored as str
+    if (type == vcfInfoInteger)
         record->chromEnd = data[0].datInt;
+    else if (type == vcfInfoString)
+        record->chromEnd = atoi(data[0].datString);
+    }
 *pData = data;
 *pMissingData = missingData;
 return count;
 }
 
 static void parseInfoColumn(struct vcfFile *vcff, struct vcfRecord *record, char *string)
 /* Translate string into array of vcfInfoElement. */
 {
 if (sameString(string, "."))
     {
     record->infoCount = 0;
     return;
     }
 char *elWords[VCF_MAX_INFO];
 record->infoCount = chopByChar(string, ';', elWords, ArraySize(elWords));