6a34e093494113f5b0fcdb1392f327c8cd2a123b max Wed Feb 5 08:28:25 2014 -0800 making hgLiftOver work in the browserbox, refs #11957, note 56 diff --git src/hg/lib/liftOver.c src/hg/lib/liftOver.c index 57768b9..112dcb1 100644 --- src/hg/lib/liftOver.c +++ src/hg/lib/liftOver.c @@ -2,57 +2,65 @@ #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "binRange.h" #include "chain.h" #include "chainNetDbLoad.h" #include "bed.h" #include "genePred.h" #include "sample.h" #include "hdb.h" #include "liftOverChain.h" #include "liftOver.h" #include "portable.h" #include "obscure.h" +#include "net.h" struct chromMap /* Remapping information for one (old) chromosome */ { char *name; /* Chromosome name. */ struct binKeeper *bk; /* Keyed by old position, values are chains. */ }; static char otherStrand(char c) /* Swap +/- */ { if (c == '-') return '+'; else if (c == '+') return '-'; else return c; } // The maximum number of words per line that can be lifted: #define LIFTOVER_MAX_WORDS 64 void readLiftOverMap(char *fileName, struct hash *chainHash) /* Read map file into hashes. */ { -struct lineFile *lf = lineFileOpen(fileName, TRUE); + +struct lineFile *lf; +struct netParsedUrl *npu; +if (udcIsLocal(fileName)) + lf = lineFileOpen(fileName, TRUE); +else + lf = netHttpLineFileMayOpen(fileName, &npu); + struct chain *chain; struct chromMap *map; int chainCount = 0; while ((chain = chainRead(lf)) != NULL) { if ((map = hashFindVal(chainHash, chain->tName)) == NULL) { AllocVar(map); map->bk = binKeeperNew(0, chain->tSize); hashAddSaveName(chainHash, chain->tName, map, &map->name); } binKeeperAdd(map->bk, chain->tStart, chain->tEnd, chain); ++chainCount; } @@ -1759,31 +1767,32 @@ /* Get list of all liftOver chains in the central database */ { struct sqlConnection *conn = hConnectCentral(); struct liftOverChain *list = NULL; list = liftOverChainLoadByQuery(conn, "NOSQLINJ select * from liftOverChain"); hDisconnectCentral(&conn); return list; } void filterOutMissingChains(struct liftOverChain **pChainList) /* Filter out chains that don't exist. Helps partially mirrored sites. */ { while(*pChainList) { - if (fileSize((*pChainList)->path)==-1) + char *newPath = hReplaceGbdb((*pChainList)->path); + if (!udcExists(newPath)) { struct liftOverChain *temp = *pChainList; *pChainList = (*pChainList)->next; liftOverChainFree(&temp); } else { pChainList = &((*pChainList)->next); } } } struct liftOverChain *liftOverChainListFiltered() /* Get list of all liftOver chains in the central database * filtered to include only those chains whose liftover files exist. @@ -1823,31 +1832,31 @@ /* Get filename of liftOver chain */ { struct sqlConnection *conn = hConnectCentral(); struct liftOverChain *chain = NULL; char query[1024]; char *path = NULL; if (conn) { sqlSafef(query, sizeof(query), "select * from liftOverChain where fromDb='%s' and toDb='%s'", fromDb, toDb); chain = liftOverChainLoadByQuery(conn, query); if (chain != NULL) { - path = cloneString(chain->path); + path = hReplaceGbdb(chain->path); liftOverChainFree(&chain); } hDisconnectCentral(&conn); } return path; } char *liftOverErrHelp() /* Help message explaining liftOver failures */ { return "Deleted in new:\n" " Sequence intersects no chains\n" "Partially deleted in new:\n" " Sequence insufficiently intersects one chain\n"