84f9843f1c767648dde8a3afafa8762c21b6a0cc
angie
  Tue Mar 22 10:57:28 2011 -0700
Code review feedback from Mark: use MayOpen naming convention, solineFileOnTabix -> lineFileTabixMayOpen.  I still can't bring myself
to remove the calls to warn, because I want the CGIs to get those
using the webAbort error handlers in conjunction w/errCatch etc.
There are tons of calls to warn() in our lib code, which can be
redirected using the errAbort handler stack if desired.

diff --git src/lib/linefile.c src/lib/linefile.c
index d1b888c..e9cff00 100644
--- src/lib/linefile.c
+++ src/lib/linefile.c
@@ -184,31 +184,31 @@
 struct lineFile *lineFileOnString(char *name, bool zTerm, char *s)
 /* Wrap a line file object around string in memory. This buffer
  * have zeroes written into it and be freed when the line file
  * is closed. */
 {
 struct lineFile *lf;
 AllocVar(lf);
 lf->fileName = cloneString(name);
 lf->fd = -1;
 lf->bufSize = lf->bytesInBuf = strlen(s);
 lf->zTerm = zTerm;
 lf->buf = s;
 return lf;
 }
 
-struct lineFile *lineFileOnTabix(char *fileOrUrl, bool zTerm)
+struct lineFile *lineFileTabixMayOpen(char *fileOrUrl, bool zTerm)
 /* Wrap a line file around a data file that has been compressed and indexed
  * by the tabix command line program.  The index file <fileOrUrl>.tbi must be
  * readable in addition to fileOrUrl. If there's a problem, warn & return NULL.
  * This works only if kent/src has been compiled with USE_TABIX=1 and linked
  * with the tabix C library. */
 {
 #ifdef USE_TABIX
 int tbiNameSize = strlen(fileOrUrl) + strlen(".tbi") + 1;
 char *tbiName = needMem(tbiNameSize);
 safef(tbiName, tbiNameSize, "%s.tbi", fileOrUrl);
 tabix_t *tabix = ti_open(fileOrUrl, tbiName);
 if (tabix == NULL)
     {
     warn("Unable to open \"%s\"", fileOrUrl);
     freez(&tbiName);
@@ -218,42 +218,42 @@
     {
     warn("Unable to load tabix index from \"%s\"", tbiName);
     freez(&tbiName);
     return NULL;
     }
 struct lineFile *lf = needMem(sizeof(struct lineFile));
 lf->fileName = cloneString(fileOrUrl);
 lf->fd = -1;
 lf->bufSize = 64 * 1024;
 lf->buf = needMem(lf->bufSize);
 lf->zTerm = zTerm;
 lf->tabix = tabix;
 freez(&tbiName);
 return lf;
 #else // no USE_TABIX
-warn(COMPILE_WITH_TABIX, "lineFileOnTabix");
+warn(COMPILE_WITH_TABIX, "lineFileTabixMayOpen");
 return NULL;
 #endif // no USE_TABIX
 }
 
 boolean lineFileSetTabixRegion(struct lineFile *lf, char *seqName, int start, int end)
-/* Assuming lf was created by lineFileOnTabix, tell tabix to seek to the specified region
+/* Assuming lf was created by lineFileTabixMayOpen, tell tabix to seek to the specified region
  * and return TRUE (or if there are no items in region, return FALSE). */
 {
 #ifdef USE_TABIX
 if (lf->tabix == NULL)
-    errAbort("lineFileSetTabixRegion: lf->tabix is NULL.  Did you open lf with lineFileOnTabix?");
+    errAbort("lineFileSetTabixRegion: lf->tabix is NULL.  Did you open lf with lineFileTabixMayOpen?");
 int tabixSeqId = ti_get_tid(lf->tabix->idx, seqName);
 if (tabixSeqId < 0 && startsWith("chr", seqName))
     // We will get some files that have chr-less Ensembl chromosome names:
     tabixSeqId = ti_get_tid(lf->tabix->idx, seqName+strlen("chr"));
 if (tabixSeqId < 0)
     return FALSE;
 ti_iter_t iter = ti_queryi(lf->tabix, tabixSeqId, start, end);
 if (iter == NULL)
     return FALSE;
 if (lf->tabixIter != NULL)
     ti_iter_destroy(lf->tabixIter);
 lf->tabixIter = iter;
 lf->bufOffsetInFile = ti_bgzf_tell(lf->tabix->fp);
 lf->bytesInBuf = 0;
 lf->lineIx = -1;
@@ -306,31 +306,31 @@
     errAbort("Couldn't open %s , %s", fileName, strerror(errno));
 return lf;
 }
 
 void lineFileReuse(struct lineFile *lf)
 /* Reuse current line. */
 {
 lf->reuse = TRUE;
 }
 
 
 INLINE void noTabixSupport(struct lineFile *lf, char *where)
 {
 #ifdef USE_TABIX
 if (lf->tabix != NULL)
-    lineFileAbort(lf, "%s: not implemented for lineFile opened with lineFileOnTabix.", where);
+    lineFileAbort(lf, "%s: not implemented for lineFile opened with lineFileTabixMayOpen.", where);
 #endif // USE_TABIX
 }
 
 void lineFileSeek(struct lineFile *lf, off_t offset, int whence)
 /* Seek to read next line from given position. */
 {
 noTabixSupport(lf, "lineFileSeek");
 if (lf->pl != NULL)
     errnoAbort("Can't lineFileSeek on a compressed file: %s", lf->fileName);
 lf->reuse = FALSE;
 if (whence == SEEK_SET && offset >= lf->bufOffsetInFile 
 	&& offset < lf->bufOffsetInFile + lf->bytesInBuf)
     {
     lf->lineStart = lf->lineEnd = offset - lf->bufOffsetInFile;
     }