8768b54aa72f850c5ed4362608007cb3cfb7901e
braney
  Mon Feb 1 14:25:20 2016 -0800
oops... VCF files were being closed twice sometimes

diff --git src/lib/vcf.c src/lib/vcf.c
index 6f4ad60..3f48d2d 100644
--- src/lib/vcf.c
+++ src/lib/vcf.c
@@ -968,41 +968,42 @@
     lineFileClose(&(vcff->lf)); // Not sure why it is closed.  Angie?
     }
 return vcff;
 }
 
 struct vcfFile *vcfTabixFileMayOpen(char *fileOrUrl, char *chrom, int start, int end,
 				    int maxErr, int maxRecords)
 /* Open a VCF file that has been compressed and indexed by tabix and
  * parse VCF header, or return NULL if unable.  If chrom is non-NULL,
  * seek to the position range and parse all lines in range into
  * vcff->records.  If maxErr >= zero, then continue to parse until
  * there are maxErr+1 errors.  A maxErr less than zero does not stop
  * and reports all errors. Set maxErr to VCF_IGNORE_ERRS for silence */
 {
 struct lineFile *lf = lineFileTabixMayOpen(fileOrUrl, TRUE);
+if (lf == NULL)
+    return NULL;
 struct vcfFile *vcff = vcfFileHeaderFromLineFile(lf, maxErr);
 if (vcff == NULL)
     return NULL;
 if (isNotEmpty(chrom) && start != end)
     {
     if (lineFileSetTabixRegion(lf, chrom, start, end))
-        {
         vcff->records = vcfParseData(vcff, NULL, 0, 0, maxRecords);
-        lineFileClose(&(vcff->lf)); // Not sure why it is closed.  Angie?
-        }
     }
+
+lineFileClose(&(vcff->lf)); // file is all read in so we close it
 return vcff;
 }
 
 int vcfRecordCmp(const void *va, const void *vb)
 /* Compare to sort based on position. */
 {
 const struct vcfRecord *a = *((struct vcfRecord **)va);
 const struct vcfRecord *b = *((struct vcfRecord **)vb);
 int dif;
 dif = strcmp(a->chrom, b->chrom);
 if (dif == 0)
     dif = a->chromStart - b->chromStart;
 if (dif == 0)
     dif = a->chromEnd - b->chromEnd; // shortest first
 if (dif == 0)