0ada66384b92f544f169c92811c33e8fc57437f1
braney
  Tue Feb 23 14:21:33 2016 -0800
some more tweaks to CRAM support

diff --git src/lib/bamFile.c src/lib/bamFile.c
index ebd3408..9ce63ba 100644
--- src/lib/bamFile.c
+++ src/lib/bamFile.c
@@ -7,35 +7,37 @@
 #include "portable.h"
 #include "bamFile.h"
 #ifdef USE_BAM
 #include "htmshell.h"
 #include "udc.h"
 
 #ifdef KNETFILE_HOOKS
 // If KNETFILE_HOOKS is used (as recommended!), then we can simply call bam_index_load
 // without worrying about the samtools lib creating local cache files in cgi-bin:
 
 #ifdef USE_HTS
 static bam_index_t *bamOpenIdx(samfile_t *sam, char *fileOrUrl)
 /* If fileOrUrl has a valid accompanying .bai file, parse and return the index;
  * otherwise return NULL. */
 {
-char indexName[4096];
+if (sam->format.format == cram) 
+    return sam_index_load(sam, fileOrUrl);
+
 // assume that index is a .bai file 
+char indexName[4096];
 safef(indexName, sizeof indexName, "%s.bai", fileOrUrl);
-bam_index_t *idx = sam_index_load2(sam, fileOrUrl, indexName);
-return idx;
+return sam_index_load2(sam, fileOrUrl, indexName);
 }
 #else
 static bam_index_t *bamOpenIdx(char *fileOrUrl)
 /* If fileOrUrl has a valid accompanying .bai file, parse and return the index;
  * otherwise return NULL. */
 {
 bam_index_t *idx = bam_index_load(fileOrUrl);
 return idx;
 }
 #endif
 
 #else// no KNETFILE_HOOKS
 // Oh well.  The unmodified samtools lib downloads .bai files into the current
 // working directory, which is cgi-bin -- not good.  So we need to temporarily
 // change to a trash directory, let samtools download there, then pop back to