Ejemplo n.º 1
0
/*
    Dump the file upload details. Don't actually do anything with the uploaded file.
 */
static void uploadTest(Webs *wp, char *path, char *query)
{
    WebsKey         *s;
    WebsUpload  *up;
    char            *upfile;

    websSetStatus(wp, 200);
    websWriteHeaders(wp, -1, 0);
    websWriteHeader(wp, "Content-Type", "text/plain");
    websWriteEndHeaders(wp);
    if (scaselessmatch(wp->method, "POST")) {
        for (s = hashFirst(wp->files); s; s = hashNext(wp->files, s)) {
            up = s->content.value.symbol;
            websWrite(wp, "FILE: %s\r\n", s->name.value.string);
            websWrite(wp, "FILENAME=%s\r\n", up->filename);
            websWrite(wp, "CLIENT=%s\r\n", up->clientFilename);
            websWrite(wp, "TYPE=%s\r\n", up->contentType);
            websWrite(wp, "SIZE=%d\r\n", up->size);
            upfile = sfmt("%s/tmp/%s", websGetDocuments(), up->clientFilename);
            rename(up->filename, upfile);
            wfree(upfile);
        }
        websWrite(wp, "\r\nVARS:\r\n");
        for (s = hashFirst(wp->vars); s; s = hashNext(wp->vars, s)) {
            websWrite(wp, "%s=%s\r\n", s->name.value.string, s->content.value.string);
        }
    }
    websDone(wp);
}
Ejemplo n.º 2
0
static void fillInFastaOffsets(struct brokenRefPepTbl *brpTbl,
                               struct sqlConnection *conn,
                               struct extFileTbl* extFileTbl)
/* get offsets of proteins in fasta files */
{
struct hashCookie cookie = hashFirst(brpTbl->protFaHash);
struct hashEl *hel;

/* fill in */
while ((hel = hashNext(&cookie)) != NULL)
    getFastaOffsets(brpTbl, conn, extFileTbl, hel->name);

/* check if any missing */
cookie = hashFirst(brpTbl->protAccHash);
while ((hel = hashNext(&cookie)) != NULL)
    {
    struct brokenRefPep *brp = hel->val;
    if (strlen(brp->mrnaAcc) && (brp->newFaOff < 0))
        {
        /* in one case, this was a pseudoGene mistakenly left in as an
         * mRNA, so make it a warning */
        fprintf(stderr, "Warning: %s: refPep %s (for %s) not found in %s\n",
                sqlGetDatabase(conn), brp->protAcc, brp->mrnaAcc,
                brp->newFaPath);
        }
    }
}
Ejemplo n.º 3
0
static struct slName *getGenomeDbs(struct gbConf *conf)
/* get list of genome databases from variable names */
{
// build hash of dbs
struct hash *dbSet = hashNew(20);
struct hashCookie cookie = hashFirst(conf->hash);
struct hashEl *hel;
while ((hel = hashNext(&cookie)) != NULL)
    {
    char *prefix = parsePrefix(hel->name);
    if (isGenomeDb(prefix))
        hashStore(dbSet, prefix);
    }

// convert to a list of dbs
struct slName *dbs = NULL;
cookie = hashFirst(dbSet);
while ((hel = hashNext(&cookie)) != NULL)
    slSafeAddHead(&dbs, slNameNew(hel->name));
#ifdef DUMP_HASH_STATS
hashPrintStats(dbSet, "gbConfDbSet", stderr);
#endif
hashFree(&dbSet);
slSort(&dbs, slNameCmp);
return dbs;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
/* read ContigLocFilter, writing to individual chrom tables */
{
struct hashCookie cookie;
struct hashEl *hel;
char *chromName;

if (argc != 3)
    usage();

snpDb = argv[1];
contigGroup = argv[2];
hSetDb(snpDb);

/* check for needed tables */
if(!hTableExistsDb(snpDb, "ContigLocFilter"))
    errAbort("no ContigLocFilter table in %s\n", snpDb);
if(!hTableExistsDb(snpDb, "ContigInfo"))
    errAbort("no ContigInfo table in %s\n", snpDb);

chromHash = loadChroms(contigGroup);
if (chromHash == NULL) 
    {
    verbose(1, "couldn't get chrom info\n");
    return 1;
    }

writeSplitTables();

verbose(1, "closing files...\n");
cookie = hashFirst(chromHash);
while (hel = hashNext(&cookie))
    fclose(hel->val);

verbose(1, "creating tables...\n");
cookie = hashFirst(chromHash);
while ((chromName = hashNextName(&cookie)) != NULL)
    createTable(chromName);

verbose(1, "loading database...\n");
cookie = hashFirst(chromHash);
while ((chromName = hashNextName(&cookie)) != NULL)
    {
    verbose(1, "chrom = %s\n", chromName);
    loadDatabase(chromName);
    }

return 0;
}
Ejemplo n.º 5
0
char *identifierWhereClause(char *idField, struct hash *idHash)
/* If the number of pasted IDs is reasonably low, return a where-clause component for the IDs. */
{
if (idHash == NULL || idField == NULL)
    return NULL;
int numIds = hashNumEntries(idHash);
int maxIdsInWhere = cartUsualInt(cart, "hgt_maxIdsInWhere", DEFAULT_MAX_IDS_IN_WHERE);
if (numIds > 0 && numIds <= maxIdsInWhere)
    {
    struct dyString *dy = dyStringNew(16 * numIds);
    dyStringPrintf(dy, "%s in (", idField);
    struct hashCookie hc = hashFirst(idHash);
    boolean first = TRUE;
    char *id;
    while ((id = hashNextName(&hc)) != NULL)
	{
	if (first)
	    first = FALSE;
	else
	    dyStringAppend(dy, ", ");
	dyStringPrintf(dy, "'%s'", id);
	}
    dyStringAppend(dy, ")");
    return dyStringCannibalize(&dy);
    }
return NULL;
}
void doLog()
{
FILE *logFileHandle = mustOpen("snpGetSeqDup.log", "w");
struct hashCookie cookie = hashFirst(uniqHash);
char *rsId = NULL;
int count = 0;
struct hashEl *hel = NULL;
char *fileName = NULL;
struct dyString *dy = newDyString(1024);

while ((rsId = hashNextName(&cookie)) != NULL)
    {
    count = 0;
    for (hel = hashLookup(snpHash, rsId); hel != NULL; hel = hashLookupNext(hel))
	count++;
    if (count == 1) continue;
    for (hel = hashLookup(snpHash, rsId); hel != NULL; hel = hashLookupNext(hel))
        {
	fileName = (char *)hel->val;
	dyStringAppend(dy, fileName);
	dyStringAppend(dy, " ");
	}
    fprintf(logFileHandle, "%s\t%s\n", rsId, dy->string);
    dyStringClear(dy);
    }

carefulClose(&logFileHandle);
}
Ejemplo n.º 7
0
void writeResults()
/* loop through nameHash */
/* print all coords from coordHash to outputFileHandle */
/* also print count per SNP to logFileHandle */
{
struct hashCookie cookie;
struct hashEl *hel= NULL;
struct coords *cel = NULL;
int count = 0;
char *name;

verbose(1, "writing results...\n");
cookie = hashFirst(nameHash);
while ((name = hashNextName(&cookie)) != NULL)
    {
    count = 0;
    for (hel = hashLookup(coordHash, name); hel != NULL; hel= hashLookupNext(hel))
        {
	cel = (struct coords *)hel->val;
	fprintf(outputFileHandle, "%s\t%d\t%d\t%s\tMultipleAlignments\n", cel->chrom, cel->start, cel->end, name);
	count++;
	}
    fprintf(logFileHandle, "%s\t%d\n", name, count);
    }
}
void checkMrnaPartition(struct gbSelect* select)
/* Check an mRNA partition.  For genbank, check all ESTs against
 * this mRNA partation. */
{
struct hashCookie cookie;
struct hashEl* hel;

gbReleaseLoadProcessed(select);
struct gbSelect* prevSelect = gbProcessedGetPrevRel(select);
if (prevSelect != NULL)
    gbReleaseLoadProcessed(prevSelect);

gbVerbEnter(2, "checking %s", gbSelectDesc(select));
cookie = hashFirst(select->release->entryTbl);
while ((hel = hashNext(&cookie)) != NULL)
    checkOrgCat(hel->val, prevSelect);
gbVerbLeave(2, "checking %s", gbSelectDesc(select));
if (select->release->srcDb == GB_GENBANK)
    checkEstPartitions(select->release);

gbReleaseUnload(select->release);
if (prevSelect != NULL)
    {
    gbReleaseUnload(prevSelect->release);
    freeMem(prevSelect);
    }
}
Ejemplo n.º 9
0
static void writeTdbSimple(struct jsonWrite *jw, struct trackDb *tdb, struct hash *fieldHash)
/* Write JSON for the non-parent/child fields of tdb */
{
if (fieldOk("track", fieldHash))
    jsonWriteString(jw, "track", tdb->track);
if (fieldOk("table", fieldHash))
    jsonWriteString(jw, "table", tdb->table);
if (fieldOk("shortLabel", fieldHash))
    jsonWriteString(jw, "shortLabel", tdb->shortLabel);
if (fieldOk("longLabel", fieldHash))
    jsonWriteString(jw, "longLabel", tdb->longLabel);
if (fieldOk("type", fieldHash))
    jsonWriteString(jw, "type", tdb->type);
if (fieldOk("priority", fieldHash))
    jsonWriteDouble(jw, "priority", tdb->priority);
if (fieldOk("grp", fieldHash))
    jsonWriteString(jw, "grp", tdb->grp);
// NOTE: if you add a new field here, then also add it to nameIsTdbField above.
if (tdb->settingsHash)
    {
    struct hashEl *hel;
    struct hashCookie cookie = hashFirst(tdb->settingsHash);
    while ((hel = hashNext(&cookie)) != NULL)
        {
        if (! nameIsTdbField(hel->name) && fieldOk(hel->name, fieldHash))
            {
            //#*** TODO: move jsonStringEscape inside jsonWriteString
            char *encoded = jsonStringEscape((char *)hel->val);
            jsonWriteString(jw, hel->name, encoded);
            }
        }
    }
}
Ejemplo n.º 10
0
static void computeUserAbilities(WebsUser *user)
{
    char    *ability, *roles, *tok;

    assure(user);
    if ((user->abilities = hashCreate(-1)) == 0) {
        return;
    }
    roles = sclone(user->roles);
    for (ability = stok(roles, " \t,", &tok); ability; ability = stok(NULL, " \t,", &tok)) {
        computeAbilities(user->abilities, ability, 0);
    }
#if BIT_DEBUG
    {
        WebsKey *key;
        trace(5, "User \"%s\" has abilities: ", user->name);
        for (key = hashFirst(user->abilities); key; key = hashNext(user->abilities, key)) {
            trace(5, "%s ", key->name.value.string);
            ability = key->name.value.string;
        }
        trace(5, "\n");
    }
#endif
    wfree(roles);
}
Ejemplo n.º 11
0
void cartJsonExecute(struct cartJson *cj)
/* Get commands from cgi, print Content-type, execute commands, print results as JSON. */
{
cartJsonPushErrHandlers();
puts("Content-Type:text/javascript\n");

// Initialize response JSON object:
jsonWriteObjectStart(cj->jw, NULL);
// Always send back hgsid:
jsonWriteString(cj->jw, cartSessionVarName(), cartSessionId(cj->cart));

char *commandJson = cgiOptionalString(CARTJSON_COMMAND);
if (commandJson)
    {
    struct jsonElement *commandObj = jsonParse(commandJson);
    struct hash *commandHash = jsonObjectVal(commandObj, "commandObj");
    // change* commands need to go first!  Really we need an ordered map type here...
    // for now, just make a list and sort to put change commands at the front.
    struct slPair *commandList = NULL, *cmd;
    struct hashCookie cookie = hashFirst(commandHash);
    struct hashEl *hel;
    while ((hel = hashNext(&cookie)) != NULL)
        slAddHead(&commandList, slPairNew(hel->name, hel->val));
    slSort(&commandList, commandCmp);
    for (cmd = commandList;  cmd != NULL;  cmd = cmd->next)
	doOneCommand(cj, cmd->name, (struct jsonElement *)cmd->val);
    }

cartJsonPrintWarnings(cj->jw);
jsonWriteObjectEnd(cj->jw);
puts(cj->jw->dy->string);
cartJsonPopErrHandlers();
}
Ejemplo n.º 12
0
void refPepList(char *db,
                FILE* outFh)
/* list of sequences needing repair */
{
struct sqlConnection *conn = sqlConnect(db);
struct brokenRefPepTbl *brpTbl;
struct hashCookie cookie;
struct hashEl *hel;
struct extFileTbl* extFileTbl = NULL;

if (!checkForRefLink(conn))
    {
    sqlDisconnect(&conn);
    return;
    }

extFileTbl = extFileTblLoad(conn);
brpTbl = brokenRefPepTblNew(conn, NULL);
brokenRefPepGetSeqScan(conn, extFileTbl, brpTbl);
brokenRefPepGetMrnas(conn, brpTbl);
extFileTblFree(&extFileTbl);

cookie = hashFirst(brpTbl->protAccHash);
while ((hel = hashNext(&cookie)) != NULL)
    {
    struct brokenRefPep *brp = hel->val;
    fprintf(outFh, "%s\t%s\t%s\n", sqlGetDatabase(conn), brp->protAcc, (brp->mrnaAcc != NULL)? "repair" : "drop");
    }
gbVerbMsg(1, "%s: need to repair %d refseq protein gbExtFile entries",
          sqlGetDatabase(conn), brpTbl->numToRepair);
gbVerbMsg(1, "%s: need to drop %d refseq protein gbExtFile entries",
          sqlGetDatabase(conn), brpTbl->numToDrop);
}
Ejemplo n.º 13
0
void getSnps(char *tableName)
{
char query[512];
struct sqlConnection *conn = hAllocConn();
struct sqlResult *sr;
char **row;
struct hashCookie cookie;
struct hashEl *hel = NULL;

sqlSafef(query, sizeof(query), 
    "select chrom, chromStart, chromEnd, name, strand from %s", 
    tableName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
    {
    hel = hashLookup(chromHash, row[0]);
    if (hel == NULL)
        verbose(1, "%s not found\n", row[0]);
    else
        fprintf(hel->val, "%s\t%s\t%s\t%s\t0\t%s\t%s\t%s\n", row[0], row[1], row[2], row[3], row[4], row[5], row[6]);
    }
sqlFreeResult(&sr);
cookie = hashFirst(chromHash);
while ((hel = hashNext(&cookie)))
    fclose(hel->val);
}
Ejemplo n.º 14
0
void bitmapToMaskArray(struct hash *bitmapHash, struct hash *tbHash)
/* Translate each bitmap in bitmapHash into an array of mask coordinates
 * in the corresponding twoBit in tbHash.  Assume tbHash's mask array is
 * empty at the start -- we allocate it here.  Free bitmap when done. */
{
    struct hashCookie cookie = hashFirst(tbHash);
    struct hashEl *hel = NULL;

    while ((hel = hashNext(&cookie)) != NULL)
    {
        char *seqName = hel->name;
        struct twoBit *tb = (struct twoBit *)(hel->val);
        struct hashEl *bHel = hashLookup(bitmapHash, seqName);
        Bits *bits;
        unsigned start=0, end=0;

        assert(tb != NULL);
        assert(tb->maskBlockCount == 0);
        if (bHel == NULL)
            errAbort("Missing bitmap for seq \"%s\"", seqName);
        bits = (Bits *)bHel->val;
        if (bits != NULL)
        {
            struct lm *lm = lmInit(0);
            struct unsignedRange *rangeList = NULL, *range = NULL;
            int i;
            for (;;)
            {
                start = bitFindSet(bits, end, tb->size);
                if (start >= tb->size)
                    break;
                end = bitFindClear(bits, start, tb->size);
                if (end > start)
                {
                    lmAllocVar(lm, range);
                    range->start = start;
                    range->size = (end - start);
                    slAddHead(&rangeList, range);
                }
            }
            slReverse(&rangeList);
            tb->maskBlockCount = slCount(rangeList);
            if (tb->maskBlockCount > 0)
            {
                AllocArray(tb->maskStarts, tb->maskBlockCount);
                AllocArray(tb->maskSizes, tb->maskBlockCount);
                for (i = 0, range = rangeList;  range != NULL;
                        i++, range = range->next)
                {
                    tb->maskStarts[i] = range->start;
                    tb->maskSizes[i] = range->size;
                }
            }
            lmCleanup(&lm);
            bitFree(&bits);
            bHel->val = NULL;
        }
    }
}
Ejemplo n.º 15
0
static int writeAuthFile(char *path)
{
    FILE        *fp;
    WebsKey     *kp, *ap;
    WebsRole    *role;
    WebsUser    *user;
    WebsHash    roles, users;
    char        *tempFile;

    assert(path && *path);

    tempFile = websTempFile(NULL, "gp");
    if ((fp = fopen(tempFile, "w" FILE_TEXT)) == 0) {
        error("Can't open %s", tempFile);
        return -1;
    }
    fprintf(fp, "#\n#   %s - Authorization data\n#\n\n", basename(path));

    roles = websGetRoles();
    if (roles >= 0) {
        for (kp = hashFirst(roles); kp; kp = hashNext(roles, kp)) {
            role = kp->content.value.symbol;
            fprintf(fp, "role name=%s abilities=", kp->name.value.string);
            for (ap = hashFirst(role->abilities); ap; ap = hashNext(role->abilities, ap)) {
                fprintf(fp, "%s,", ap->name.value.string);
            }
            fputc('\n', fp);
        }
        fputc('\n', fp);
    }
    users = websGetUsers();
    if (users >= 0) {
        for (kp = hashFirst(users); kp; kp = hashNext(users, kp)) {
            user = kp->content.value.symbol;
            fprintf(fp, "user name=%s password=%s roles=%s", user->name, user->password, user->roles);
            fputc('\n', fp);
        }
    }
    fclose(fp);
    unlink(path);
    if (rename(tempFile, path) < 0) {
        error("Can't create new %s", path);
        return -1;
    }
    return 0;
}
Ejemplo n.º 16
0
static void dumpIgnoreTbl(struct hash* ignoreTbl)
/* print ignoreTbl for debugging purposes */
{
struct hashCookie cookie = hashFirst(ignoreTbl);
struct hashEl *hel;
while ((hel = hashNext(&cookie)) != NULL)
    verbose(3, "ignore: %s: %s\n", hel->name, (char*)hel->val);
}
Ejemplo n.º 17
0
static void addQueryNames(struct hash *qNameHash, struct pslTbl *pslTbl)
/* add query names to the hash table if they are not already there. */
{
struct hashCookie hc = hashFirst(pslTbl->queryHash);
struct pslQuery *q;
while ((q = hashNextVal(&hc)) != NULL)
    hashStore(qNameHash, q->qName);  /* add if not there */
}
Ejemplo n.º 18
0
static char *findType(struct hash *cvHash,char **requested,int requestCount,
                      char **queryBy, char **org,boolean silent)
/* returns the type that was requested or else the type associated with the term requested */
{
struct hashCookie hc = hashFirst(cvHash);
struct hashEl *hEl;
struct hash *ra;
char *type = typeOpt;

if (requested != NULL) // if no type, find it from requested terms.  Will validate terms match type
    {              // NOTE: Enter here even if there is a type, to confirm the type
    while ((hEl = hashNext(&hc)) != NULL)  // FIXME: This should be using mdbCv APIs to get hashes.
        {                                  // One per "request[]"
        ra = (struct hash *)hEl->val;
        if (sameWord(hashMustFindVal(ra, CV_TYPE),CV_TOT)) // TOT = typeOfTerm
            continue;
        char *val = hashFindVal(ra, *queryBy);
        if (val != NULL)
            {
            int ix = stringArrayIx(val,requested,requestCount);
            if (ix != -1) // found
                {
                char *thisType = hashMustFindVal(ra, CV_TYPE);
                char *thisOrg = hashFindVal(ra, ORGANISM);
                if (type == NULL)
                    {
                    if (thisOrg != NULL)
                        {
                        *org = strLower(cloneString(thisOrg));
                        }
                    type = thisType;
                    }
                else if (differentWord(type,thisType))
                    {
                    if (sameWord(CV_TERM_CONTROL,type))
                        type = thisType;
                    else if (differentWord(CV_TERM_CONTROL,thisType))
                        errAbort("Error: Requested %s of type '%s'.  But '%s' has type '%s'\n",
                                 *queryBy,type,requested[ix],thisType);
                    }
                }
            }
        }
    }
if (type == NULL && sameWord(*queryBy,CV_TERM))    // Special case of term becoming target
    {
    char *queryByTarget = CV_TARGET;
    type = findType(cvHash,requested,requestCount,&queryByTarget,org,TRUE); // silent here
    if (type != NULL)
        *queryBy = queryByTarget;
    }
if (type == NULL && !silent)    // Still not type? abort
    errAbort("Error: Required %s=%s ['%s', '%s', '%s', '%s' or '%s'] argument not found\n",
                    *queryBy,(requested != NULL) ? *requested : "?",
                    CV_TYPE, CV_TERM, CV_TAG, CV_TARGET, CV_LABEL);

return normalizeType(type);
}
Ejemplo n.º 19
0
static void brokenRefPepGetMrnas(struct sqlConnection *conn,
                                 struct brokenRefPepTbl *brpTbl)
/* load mrna information for broken refPeps */
{
struct hashCookie cookie = hashFirst(brpTbl->protAccHash);
struct hashEl *hel;
while ((hel = hashNext(&cookie)) != NULL)
    brokenRefPepGetPath(conn, brpTbl, (struct brokenRefPep*)hel->val);
}
Ejemplo n.º 20
0
struct chromAnnMapIter chromAnnMapFirst(struct chromAnnMap *cam)
/* get iterator over a chromAnnMap */
{
struct chromAnnMapIter iter;
ZeroVar(&iter);
iter.cam = cam;
iter.chromCookie = hashFirst(cam->ranges->hash);
return iter;
}
Ejemplo n.º 21
0
static void findNewEntries(struct gbSelect* select, struct gbStatusTbl* statusTbl)
/* Traverse the gbIndex file to find entries that were not in the gbStatus
 * table when loaded.  These are new entries. */
{
struct hashCookie cookie;
struct hashEl* hel;
cookie = hashFirst(select->release->entryTbl);
while ((hel = hashNext(&cookie)) != NULL)
    checkNewEntry(select, statusTbl, (struct gbEntry*)hel->val);
}
Ejemplo n.º 22
0
static void gotCcdsCheckInfo(struct hash *infoCcds)
/* check source databases added to ccdsInof table */
{
int errCnt = 0;
struct hashCookie cookie = hashFirst(infoCcds);
struct hashEl* hel;
while ((hel = hashNext(&cookie)) != NULL)
    errCnt += gotCcdsCheckSrcDb(hel);
if (errCnt > 0)
    errAbort("Error: not all CCDSs have both NCBI and Hinxton genes in ccdsInfo table");
}
Ejemplo n.º 23
0
struct hashCookie gbIgnoreFirst(struct gbIgnore *ignore)
/* get cookie to iterate over hash */
{
// a zero cookie will return NULL on hashNext() call 
struct hashCookie cookie;
if (ignore->accHash == NULL)
    ZeroVar(&cookie);
else
    cookie = hashFirst(ignore->accHash);
return cookie;
}
void flushSummaryBlocks(struct hash *componentHash, FILE *f)
/* flush any pending summary blocks */
{
struct mafSummary *ms;
struct hashCookie hc = hashFirst(componentHash);

while ((ms = (struct mafSummary *)hashNextVal(&hc)) != NULL)
    {
    outputSummary(f, ms);
    }
}
Ejemplo n.º 25
0
/* free slRef objects in the compRangeMap */
static void destructCompRangeMap(struct malnSet *malnSet) {
    struct hashCookie cookie = hashFirst(malnSet->compRangeMap->hash);
    struct hashEl *hel;
    while ((hel = hashNext(&cookie)) != NULL) {
        struct rbTree *rangeTree = hel->val;
        for (struct range *rng = rangeTreeList(rangeTree); rng != NULL; rng = rng->next) {
            slFreeList(&rng->val);
        }
    }
    genomeRangeTreeFree(&malnSet->compRangeMap);
}
Ejemplo n.º 26
0
int hubCheckTrack(struct trackHub *hub, struct trackHubGenome *genome, struct trackDb *tdb, 
                        struct trackHubCheckOptions *options, struct dyString *errors)
/* Check track settings and optionally, files */
{
int retVal = 0;

if (options->checkSettings && options->settings)
    {
    //verbose(3, "Found %d settings to check to spec\n", slCount(settings));
    verbose(3, "Checking track: %s\n", tdb->shortLabel);
    verbose(3, "Found %d settings to check to spec\n", hashNumEntries(tdb->settingsHash));
    struct hashEl *hel;
    struct hashCookie cookie = hashFirst(tdb->settingsHash);
    while ((hel = hashNext(&cookie)) != NULL)
        retVal |= hubCheckTrackSetting(hub, tdb, hel->name, options, errors);
    /* TODO: ? also need to check settings not in this list (other tdb fields) */
    }

if (options->printMeta)
    {
    struct slPair *metaPairs = trackDbMetaPairs(tdb);

    if (metaPairs != NULL)
        {
        printf("%s\n", trackHubSkipHubName(tdb->track));
        struct slPair *pair;
        for(pair = metaPairs; pair; pair = pair->next)
            {
            printf("\t%s : %s\n", pair->name, (char *)pair->val);
            }
        printf("\n");
        }
    slPairFreeValsAndList(&metaPairs);
    }

if (!options->checkFiles)
    return retVal;

struct errCatch *errCatch = errCatchNew();
if (errCatchStart(errCatch))
    {
    hubCheckBigDataUrl(hub, genome, tdb);
    }
errCatchEnd(errCatch);
if (errCatch->gotError)
    {
    retVal = 1;
    dyStringPrintf(errors, "%s", errCatch->message->string);
    }
errCatchFree(&errCatch);

return retVal;
}
Ejemplo n.º 27
0
void bestProbeOverlap(struct sqlConnection *conn, char *probeTable, 
	struct genePred *gpList, struct hash *gpToProbeHash)
/* Create hash of most overlapping probe if any for each gene. Require
 * at least 100 base overlap. */
{
/* Create a hash of binKeepers filled with probes. */
struct hash *keeperHash = keepersForChroms(conn);
struct hashCookie it = hashFirst(keeperHash);
struct hashEl *hel;
int pslCount = 0;
while ((hel = hashNext(&it)) != NULL)
    {
    char *chrom = hel->name;
    struct binKeeper *bk = hel->val;
    int rowOffset;
    struct sqlResult *sr = hChromQuery(conn, probeTable, chrom, NULL, &rowOffset);
    char **row;
    while ((row = sqlNextRow(sr)) != NULL)
        {
	struct psl *psl = pslLoad(row+rowOffset);
	binKeeperAdd(bk, psl->tStart, psl->tEnd, psl);
	++pslCount;
	}
    sqlFreeResult(&sr);
    }
verbose(2, "Loaded %d psls from %s\n", pslCount, probeTable);

/* Loop through gene list, finding best probe if any for each gene. */
struct genePred *gp;
for (gp = gpList; gp != NULL; gp = gp->next)
    {
    struct rbTree *rangeTree = genePredToRangeTree(gp, FALSE);
    struct psl *bestPsl = NULL;
    int bestOverlap = 99;	/* MinOverlap - 1 */
    struct binKeeper *bk = hashMustFindVal(keeperHash, gp->chrom);
    struct binElement *bin, *binList = binKeeperFind(bk, gp->txStart, gp->txEnd);
    for (bin = binList; bin != NULL; bin = bin->next)
        {
	struct psl *psl = bin->val;
	if (psl->strand[0] == gp->strand[0])
	    {
	    int overlap = pslRangeTreeOverlap(psl, rangeTree);
	    if (overlap > bestOverlap)
		{
		bestOverlap = overlap;
		bestPsl = psl;
		}
	    }
	}
    if (bestPsl != NULL)
        hashAdd(gpToProbeHash, gp->name, bestPsl->qName);
    }
}
Ejemplo n.º 28
0
static void alignStatsOutputUnaligned(FILE *fh, struct hash* querySizesTbl)
/* output stats on unaligned */
{
struct hashCookie cookie = hashFirst(querySizesTbl);
struct hashEl *hel;
while ((hel = hashNext(&cookie)) != NULL)
    {
    struct querySizeCnt *qs = hel->val;
    if (qs->alnCnt == 0)
        fprintf(fh, alnStatsFmt, hel->name, qs->qSize, "", 0, 0, 0.0, 0.0, 0.0, 0.0);
    }
}
static struct mgcStatus *sortTable(struct mgcStatusTbl *mst)
/* Get a list of the entries, sorted by imageId */
{
struct hashCookie cookie = hashFirst(mst->imageIdHash);
struct hashEl *hel;
struct mgcStatus *statusList = NULL;
while ((hel = hashNext(&cookie)) != NULL)
    slAddHead(&statusList, ((struct mgcStatus*)hel->val));

slSort(&statusList, imageIdCmp);
return statusList;
}
Ejemplo n.º 30
0
PUBLIC void websComputeAllUserAbilities()
{
    WebsUser    *user;
    WebsKey     *sym;

    if (users) {
        for (sym = hashFirst(users); sym; sym = hashNext(users, sym)) {
            user = (WebsUser*) sym->content.value.symbol;
            computeUserAbilities(user);
        }
    }
}