f37a59b3cc853c1a69edac6d9069051c37eb6983
braney
  Mon Apr 15 11:11:53 2013 -0700
add udcDir option to the twoBit utilities so they can access remote twoBits with something other than the default udc cache dir
diff --git src/utils/twoBitToFa/twoBitToFa.c src/utils/twoBitToFa/twoBitToFa.c
index ec44811..717cb51 100644
--- src/utils/twoBitToFa/twoBitToFa.c
+++ src/utils/twoBitToFa/twoBitToFa.c
@@ -1,74 +1,77 @@
 /* twoBitToFa - Convert all or part of twoBit file to fasta. */
 #include "common.h"
 #include "linefile.h"
 #include "hash.h"
 #include "options.h"
 #include "dnaseq.h"
 #include "fa.h"
 #include "twoBit.h"
 #include "bPlusTree.h"
 #include "basicBed.h"
+#include "udc.h"
 
 
 void usage()
 /* Explain usage and exit. */
 {
 errAbort(
   "twoBitToFa - Convert all or part of .2bit file to fasta\n"
   "usage:\n"
   "   twoBitToFa input.2bit output.fa\n"
   "options:\n"
   "   -seq=name - restrict this to just one sequence\n"
   "   -start=X  - start at given position in sequence (zero-based)\n"
   "   -end=X - end at given position in sequence (non-inclusive)\n"
   "   -seqList=file - file containing list of the desired sequence names \n"
   "                    in the format seqSpec[:start-end], e.g. chr1 or chr1:0-189\n"
   "                    where coordinates are half-open zero-based, i.e. [start,end)\n"
   "   -noMask - convert sequence to all upper case\n"
   "   -bpt=index.bpt - use bpt index instead of built in one\n"
   "   -bed=input.bed - grab sequences specified by input.bed. Will exclude introns\n"
   "   -bedPos        - with -bed, to use chrom:start-end as the fasta ID in output.fa\n"
+  "   -udcDir=/dir/to/cache - place to put cache for remote bigBed/bigWigs\n"
   "\n"
   "Sequence and range may also be specified as part of the input\n"
   "file name using the syntax:\n"
   "      /path/input.2bit:name\n"
   "   or\n"
   "      /path/input.2bit:name\n"
   "   or\n"
   "      /path/input.2bit:name:start-end\n"
   );
 }
 
 char *clSeq = NULL;	/* Command line sequence. */
 int clStart = 0;	/* Start from command line. */
 int clEnd = 0;		/* End from command line. */
 char *clSeqList = NULL; /* file containing list of seq names */
 bool noMask = FALSE;  /* convert seq to upper case */
 char *clBpt = NULL;	/* External index file. */
 char *clBed = NULL;	/* Bed file that specifies bounds of sequences. */
 bool clBedPos = FALSE;
 
 static struct optionSpec options[] = {
    {"seq", OPTION_STRING},
    {"seqList", OPTION_STRING},
    {"start", OPTION_INT},
    {"end", OPTION_INT},
    {"noMask", OPTION_BOOLEAN},
    {"bpt", OPTION_STRING},
    {"bed", OPTION_STRING},
    {"bedPos", OPTION_BOOLEAN},
+   {"udcDir", OPTION_STRING},
    {NULL, 0},
 };
 
 void outputOne(struct twoBitFile *tbf, char *seqSpec, FILE *f, 
 	int start, int end)
 /* Output sequence. */
 {
 struct dnaSeq *seq = twoBitReadSeqFrag(tbf, seqSpec, start, end);
 if (noMask)
     toUpperN(seq->dna, seq->size);
 faWriteNext(f, seq->name, seq->dna, seq->size);
 dnaSeqFree(&seq);
 }
 
 static void processAllSeqs(struct twoBitFile *tbf, FILE *outFile)
@@ -191,30 +194,31 @@
 
 int main(int argc, char *argv[])
 /* Process command line. */
 {
 optionInit(&argc, argv, options);
 if (argc != 3)
     usage();
 clSeq = optionVal("seq", clSeq);
 clStart = optionInt("start", clStart);
 clEnd = optionInt("end", clEnd);
 clSeqList = optionVal("seqList", clSeqList);
 clBpt = optionVal("bpt", clBpt);
 clBed = optionVal("bed", clBed);
 clBedPos = optionExists("bedPos");
 noMask = optionExists("noMask");
+udcSetDefaultDir(optionVal("udcDir", udcDefaultDir()));
 
 if (clBedPos && !clBed) 
     errAbort("the -bedPos option requires the -bed option");
 if (clBed != NULL)
     {
     if (clSeqList != NULL)
 	errAbort("Can only have seqList or bed options, not both.");
     if (clSeq != NULL)
         errAbort("Can only have seq or bed options, not both.");
     }
 if ((clStart > clEnd) && (clSeq == NULL))
     errAbort("must specify -seq with -start and -end");
 if ((clSeq != NULL) && (clSeqList != NULL))
     errAbort("can't specify both -seq and -seqList");