コード例 #1
0
void jsValidateKeysOnDb(struct joiner *joiner, struct joinerSet *js,
                        char *db, struct hash *keyHash, struct keyHitInfo *khiList)
/* Validate keys pertaining to this database. */
{
    struct joinerField *jf;
    struct hash *localKeyHash = NULL;
    struct keyHitInfo *localKhiList = NULL;
    struct joinerField *keyField;

    if ((keyField = js->fieldList) == NULL)
        return;
    if (keyHash == NULL)
    {
        char *keyDb;
        if (slNameInList(keyField->dbList, db))
        {
            keyDb = db;
        }
        else if (!dbInAnyField(js->fieldList->next, db))
        {
            return;
        }
        else
        {
            if (slCount(keyField->dbList) == 1)
                keyDb = keyField->dbList->name;
            else
            {
                struct slName *lastDb = slLastEl(keyField->dbList);
                keyDb = lastDb->name;
                verbose(1, " note - using %s database as reference for identifier %s\n",
                        keyDb, js->name);
            }
        }
        keyHash = localKeyHash = readKeyHash(keyDb, joiner, keyField,
                                             &localKhiList);
        khiList = localKhiList;
    }
    if (keyHash != NULL)
    {
        for (jf = js->fieldList; jf != NULL; jf = jf->next)
        {
            if (jf != keyField && slNameInList(jf->dbList, db))
            {
                doKeyChecks(db, joiner, js, keyHash, khiList, keyField, jf);
            }
        }
    }
    hashFree(&localKeyHash);
    slFreeList(&localKhiList);
}
コード例 #2
0
static struct joinerField *findJoinerField(struct joinerSet *js,
        struct joinerDtf *dtf)
/* Find field in set if any that matches dtf */
{
    struct slRef *chain = joinerSetInheritanceChain(js), *link;
    struct joinerField *jf, *ret = NULL;
    for (link = chain; link != NULL; link = link->next)
    {
        js = link->val;
        for (jf = js->fieldList; jf != NULL; jf = jf->next)
        {
            if (sameString(dtf->table, jf->table) && sameString(dtf->field, jf->field))
            {
                if (slNameInList(jf->dbList, dtf->database))
                {
                    ret = jf;
                    break;
                }
            }
        }
        if (ret != NULL)
            break;
    }
    slFreeList(&chain);
    return ret;
}
コード例 #3
0
void checkTableForFields(struct sqlConnection *conn, char *tableName)
/* Do basic checks on the table to make sure it's kosher. i.e. */
/* chrom, chromStart, name all exist along with the table itself. */
{
    struct slName *fieldList;
    if (!sqlTableExists(conn, tableName))
        errAbort("table %s not found.", tableName);
    fieldList = sqlListFields(conn, tableName);
    if (!slNameInList(fieldList, "chrom"))
        errAbort("table %s doesn't have a chrom field. It must have chrom, chromStart, and name at the minimum.", tableName);
    if (!slNameInList(fieldList, "chromStart"))
        errAbort("table %s doesn't have a chrom field. It must have chrom, chromStart, and name at the minimum.", tableName);
    if (!slNameInList(fieldList, "name"))
        errAbort("table %s doesn't have a chrom field. It must have chrom, chromStart, and name at the minimum.", tableName);
    slNameFreeList(&fieldList);
}
コード例 #4
0
ファイル: rtdbWebUpdate.c プロジェクト: davidhoover/kent
void doMiddle(struct cart *theCart)
/* Set up globals and make web page */
{
char *database = cgiOptionalString("db");
char *rtdbServer = cfgOption("rtdb.server");
char *rtdbPort = cfgOption("rtdb.port");
char *rtdbChoices = cfgOption("rtdb.databases");
struct slName *dbs = slNameListFromComma(rtdbChoices);
cart = theCart;
cartWebStart(cart, database, "MGC RTDB Update");
if (!rtdbServer)
    errAbort("rtdb.update not defined in the hg.conf file. "
	     "Chances are this CGI isn't meant for this machine.");
if (!rtdbPort)
    errAbort("rtdb.update not defined in the hg.conf file. "
	     "Chances are this CGI isn't meant for this machine.");
/* create HMTL form if button wasn't pressed.  Otherwise, run the update */
if (!cgiVarExists("RTDBSubmit"))
    makeForm(dbs);
else if ((database == NULL) || (!slNameInList(dbs, database)))
    {
    makeForm(dbs);
    printf("<br>Error: Select one of databases listed.");
    }
else
    updateServer(rtdbServer, rtdbPort, database);
cartWebEnd();
slNameFreeList(&dbs);
}
コード例 #5
0
void checkOneDependency(struct joiner *joiner,
                        struct joinerDependency *dep, struct sqlConnection *conn, char *dbName)
/* Check out one dependency in one database. */
{
    char *tableToCheck = dep->table->table;
    if (sqlWildcardIn(tableToCheck))
    {
        errAbort("Can't handle wildCards in dependency tables line %d of %s",
                 dep->lineIx, joiner->fileName);
    }
    if (slNameInList(dep->table->dbList, dbName)
            && sqlTableExists(conn, tableToCheck))
    {
        time_t tableTime = sqlTableUpdateTime(conn, tableToCheck);
        struct joinerTable *dependsOn;
        for (dependsOn = dep->dependsOnList; dependsOn != NULL;
                dependsOn = dependsOn->next)
        {
            if (slNameInList(dependsOn->dbList, dbName))
            {
                if (!sqlTableExists(conn, dependsOn->table))
                {
                    warn("Error: %s.%s doesn't exist line %d of %s",
                         dbName, dependsOn->table,
                         dep->lineIx, joiner->fileName);
                }
                else
                {
                    time_t depTime = sqlTableUpdateTime(conn, dependsOn->table);
                    if (depTime > tableTime)
                    {
                        char *depStr = sqlUnixTimeToDate(&depTime, FALSE);
                        char *tableStr = sqlUnixTimeToDate(&tableTime, FALSE);

                        warn("Error: %s.%s updated after %s.%s line %d of %s",
                             dbName, dependsOn->table, dbName, tableToCheck,
                             dep->lineIx, joiner->fileName);
                        warn("\t%s vs. %s", depStr, tableStr);
                        freeMem(depStr);
                        freeMem(tableStr);
                    }
                }
            }
        }
    }
}
コード例 #6
0
ファイル: hgTablesTest.c プロジェクト: elmargb/kentUtils
boolean varIncludesType(struct htmlForm *form, char *var, char *value)
/* Return TRUE if value is one of the options for var. */
{
struct htmlFormVar *formVar = htmlFormVarGet(form, var);
if (formVar == NULL)
    errAbort("Couldn't find %s variable in form", var);
return slNameInList(formVar->values, value);
}
コード例 #7
0
ファイル: vcfTrack.c プロジェクト: maximilianh/kent
static boolean filterColumnFail(struct vcfRecord *record, struct slName *filterValues)
/* Return TRUE if record's FILTER column value(s) matches one of filterValues (from cart). */
{
int i;
for (i = 0;  i < record->filterCount;  i++)
    if (slNameInList(filterValues, record->filters[i]))
	return TRUE;
return FALSE;
}
コード例 #8
0
ファイル: mainPage.c プロジェクト: davidhoover/kent
char *findSelDb()
/* Find user selected database (as opposed to genome database). */
{
struct slName *dbList = getDbListForGenome();
char *selDb = cartUsualString(cart, hgtaTrack, NULL);
if (!slNameInList(dbList, selDb))
    selDb = cloneString(dbList->name);
slFreeList(&dbList);
return selDb;
}
コード例 #9
0
boolean dbInAnyField(struct joinerField *fieldList, char *db)
/* Return TRUE if database is used in any field. */
{
    struct joinerField *field;
    for (field = fieldList; field != NULL; field = field->next)
    {
        if (slNameInList(field->dbList, db))
            return TRUE;
    }
    return FALSE;
}
コード例 #10
0
ファイル: timePosTable.c プロジェクト: davidhoover/kent
static struct chromSize *getChroms(char *db)
/* get list of chroms to use in tests */
{
struct slName *specs = optionMultiVal("chrom", NULL);
if (specs == NULL)
    return getLongestChrom(db);
else if (slNameInList(specs, "all"))
    return getAllChroms(db);
else
    return getChromsFromSpecs(db, specs);
}
コード例 #11
0
static struct hash *getCoveredTables(struct joiner *joiner, char *db,
                                     struct sqlConnection *conn)
/* Get list of tables covered in database. */
{
    struct hash *hash = hashNew(0);
    struct joinerIgnore *ig;
    struct slName *spec;
    struct joinerSet *js;
    struct joinerField *jf;

    /* First put in all the ignored tables. */
    for (ig = joiner->tablesIgnored; ig != NULL; ig = ig->next)
    {
        if (slNameInList(ig->dbList, db))
        {
            for (spec = ig->tableList; spec != NULL; spec = spec->next)
            {
                verbose(3,"ignoreTable: '%s'\n", spec->name);
                addTablesLike(hash, conn, spec->name);
            }
        }
    }

    /* Now put in tables that are in one of the identifiers. */
    for (js = joiner->jsList; js != NULL; js = js->next)
    {
        for (jf = js->fieldList; jf != NULL; jf = jf->next)
        {
            if (slNameInList(jf->dbList, db))
            {
                char spec[512];
                safef(spec, sizeof(spec), "%s%s%s",
                      emptyForNull(jf->splitPrefix), jf->table,
                      emptyForNull(jf->splitSuffix));
                addTablesLike(hash, conn, spec);
                verbose(4,"ident: '%s', table: '%s'\n", js->name, spec);
            }
        }
    }
    return hash;
}
コード例 #12
0
ファイル: joiner.c プロジェクト: bowhan/kent
static struct joinerField *joinerSetIncludesTable(struct joinerSet *js, 
	char *database, char *table)
/* If joiner set includes database and table, return the associated field. */
{
struct joinerField *jf;
for (jf = js->fieldList; jf != NULL; jf = jf->next)
    {
    if (sameString(table, jf->table) && slNameInList(jf->dbList, database))
        return jf;
    }
return NULL;
}
コード例 #13
0
ファイル: hgTablesTest.c プロジェクト: elmargb/kentUtils
void testOutCustomTrack(struct htmlPage *tablePage, struct htmlForm *mainForm,
     char *org, char *db, char *group, char *track, char *table)
/* Get as customTrack and make sure nothing explodes. */
/* mainForm not used */
{
struct htmlPage *outPage;
int attempts = 0;
struct htmlFormVar *groupVar;

if (tablePage->forms == NULL) 
    errAbort("testOutCustomTrack: Missing form (tablePage)");

htmlPageSetVar(tablePage, NULL, hgtaOutputType, "customTrack");
outPage = quickSubmit(tablePage, org, db, group, track, table,
    "customTrackUi", hgtaDoTopSubmit, "submit");
while (outPage == NULL && attempts < MAX_ATTEMPTS)
    {
    printf("testOutCustomTrack: trying again to get customTrackUi\n");
    outPage = quickSubmit(tablePage, org, db, group, track, table,
        "customTrackUi", hgtaDoTopSubmit, "submit");
    attempts++;
    }
if (outPage == NULL)
    {
    qaStatusSoftError(tablesTestList->status,
           "Error in testOutCustomTrack - couldn't get outPage.");
    return;
    }

serialSubmit(&outPage, org, db, group, track, table, "outCustom", hgtaDoGetCustomTrackTb, "submit");
if (outPage == NULL)
    {
    qaStatusSoftError(tablesTestList->status,
           "Error in testOutCustomTrack - serialSubmit returned null page.");
    return;
    }
if (outPage->forms == NULL)
    {
    qaStatusSoftError(tablesTestList->status,
           "Error in custom track - no form produced.");
    htmlPageFree(&outPage);
    return;
    }
groupVar = htmlFormVarGet(outPage->forms, hgtaGroup);
if (!slNameInList(groupVar->values, "user"))
    {
    qaStatusSoftError(tablesTestList->status, 
	"No custom track group after custom track submission");
    }
htmlPageFree(&outPage);
}
コード例 #14
0
void cullCutters(struct cutter **enzList, boolean semicolon, struct slName *justThese, int matchSize)
/* Reduce the list of enzymes based on different options. */
{
struct cutter *enz = *enzList, *next;
while (enz != NULL)
    {
    next = enz->next;
    if ((justThese && !slNameInList(justThese, enz->name)) ||  
	(enz->matchSize < matchSize) || (!semicolon && enz->semicolon))
	{	
	slRemoveEl(enzList, enz);
	cutterFree(&enz);
	}
    enz = next;
    }
}
コード例 #15
0
ファイル: keys.c プロジェクト: JinfengChen/pblat
void kvtWriteAll(struct kvt *kvt, FILE *f, struct slName *hideList)
/* Write all keys to file except the ones in hideList */
{
    int i;
    static char lf = '\n';
    struct keyVal *kv = kvt->table;
    int keyCount = kvt->used;

    for (i=0; i<keyCount; ++i)
    {
        char *key = kv->key;
        if (kv->val != NULL && !slNameInList(hideList, key))
            fprintf(f, "%s %s\n", key, kv->val);
        ++kv;
    }
    mustWrite(f, &lf, 1);   /* Instead of fputc for error checking. */
}
コード例 #16
0
ファイル: hgFileSearch.c プロジェクト: maximilianh/kent
struct grp *groupsFilterForTdbList(struct grp **grps,struct trackDb *tdbList)
{
struct grp *grpList = *grps;
*grps = NULL;
struct slName *tdbGroups = tdbListGetGroups(tdbList);
if (tdbList == NULL)
    return *grps;

while (grpList != NULL)
    {
    struct grp *grp = slPopHead(&grpList);
    if (slNameInList(tdbGroups,grp->name))
        slAddHead(grps,grp);
    }
slNameFreeList(&tdbGroups);
slReverse(grps);
return *grps;
}
コード例 #17
0
static void addHitMiss(struct hash *keyHash, char *id, struct joinerField *jf,
                       int *pHits, char **pMiss, int *pTotal)
/* Record info about one hit or miss to keyHash */
{
    id = doChopsAndUpper(jf, id);
    if (jf->exclude == NULL || !slNameInList(jf->exclude, id))
    {
        struct keyHitInfo *khi;
        if ((khi = hashFindVal(keyHash, id)) != NULL)
        {
            *pHits += 1;
            khi->count += 1;
        }
        else
        {
            if (*pMiss == NULL)
                *pMiss = cloneString(id);
        }
        *pTotal += 1;
    }
}
コード例 #18
0
void cleanup(struct mahoney *mahoneyList, char *mouseDb, char *pcrBed)
/* Look up gene names in refLink table where possible and use these instead
 * of embedded names. */
{
struct mahoney *m;
struct hash *refHash = refGeneToNameHash(mouseDb);
struct hash *llHash = locusLinkToRefSeq(mouseDb);
struct hash *pcrHash = mtfToRnaHash(pcrBed);
int refWinsByPcr = 0, llWinsByPcr = 0, noWin = 0, bothWin = 0, noWinNoPcr = 0;
int refWinsByName = 0, llWinsByName = 0;
int refWinsByDefault = 0, llWinsByDefault = 0, noWinByDefault = 0;
int locusLinkFromPcr = 0, genbankFromPcr = 0;

for (m = mahoneyList; m != NULL; m = m->next)
    {
    char mtf[8];
    char buf[9];
    safef(mtf, sizeof(mtf), "%d", m->mtf);
    struct rnaList *rl;
    boolean gotConflict = FALSE;
    rl = hashFindVal(pcrHash, mtf);

    /* Look for conflicts between refSeq and locusLink representations. 
     * Use PCR and names to try to resolve them.  (Ultimately this proves to
     * be futile though).  On unresolved ones axe the locusLink and refSeq
     * id's */
    if (startsWith("NM_", m->genbank) && m->locusId[0] != 0)
        {
	struct refSeqInfo *rsRsi = hashFindVal(refHash, m->genbank);
	struct refSeqInfo *llRsi = hashFindVal(llHash, m->locusId);
	boolean resolved = FALSE;
	if (rsRsi != NULL && llRsi != NULL)
	    {
	    if (rsRsi->locusLink == llRsi->locusLink)
		{
	        ++bothWin;
		resolved = TRUE;
		}
	    else
	        {
		if (conflictLog != NULL)
		    fprintf(conflictLog, 
		    	"MTF #%d locusLink %d (from %s)  doesn't match %s\n",
		    	m->mtf, rsRsi->locusLink, m->genbank, m->locusId);
		}
	    if (!resolved)
		{
		if (rl != NULL)
		    {
		    if (slNameInList(rl->accList, rsRsi->refSeq))
			{
			safef(buf, sizeof(buf), "%d", rsRsi->locusLink);
			m->locusId = cloneString(buf);
			++refWinsByPcr;
			if (conflictLog != NULL)
			    fprintf(conflictLog, "    picking %d by PCR\n",
				rsRsi->locusLink);	
			resolved = TRUE;
			}
		    else if (slNameInList(rl->accList, llRsi->refSeq))
			{
			m->genbank = cloneString(llRsi->refSeq);
			++llWinsByPcr;
			if (conflictLog != NULL)
			    fprintf(conflictLog, "    picking %d by PCR\n",
				llRsi->locusLink);	
			resolved = TRUE;
			}
		    else
			{
			++noWin;
			}
		    }
		}
	    else
	        {
		++noWinNoPcr;
		}
	    if (!resolved)
	        {
		if (mahoneyNameAgrees(m->geneName, rsRsi->geneName))
		    {
		    safef(buf, sizeof(buf), "%d", rsRsi->locusLink);
		    m->locusId = cloneString(buf);
		    ++refWinsByName;
		    if (conflictLog != NULL)
		        fprintf(conflictLog, "    picking %d by name\n",
			    rsRsi->locusLink);	
		    resolved = TRUE;
		    }
		else if (mahoneyNameAgrees(m->geneName, llRsi->geneName))
		    {
		    m->genbank = cloneString(llRsi->refSeq);
		    ++llWinsByName;
		    if (conflictLog != NULL)
		        fprintf(conflictLog, "    picking %d by name\n",
			    llRsi->locusLink);	
		    resolved = TRUE;
		    }
		else
		    {
		    verbose(3, "No resolution MTF%d by name or PCR\n", m->mtf);
		    }
		}
	    }
	else if (rsRsi == NULL && llRsi == NULL)
	    {
	    verbose(3, "refSeq %s, locusLink %s not found in refLink\n", m->genbank, m->locusId);
	    if (conflictLog != NULL)
		fprintf(conflictLog, 
		    "MTF #%d neither locusLink %s nor refSeq %s exist for mouse\n",
		    m->mtf, m->locusId, m->genbank);
	    ++noWinByDefault;
	    }
	else if (llRsi == NULL)
	    {
	    if (conflictLog != NULL)
		{
		fprintf(conflictLog, 
		    "MTF #%d locusLink %d (from %s)  doesn't match %s\n",
		    m->mtf, rsRsi->locusLink, m->genbank, m->locusId);
		fprintf(conflictLog, "    picking %d since %s not in mouse\n",
		    rsRsi->locusLink, m->locusId);	
		}
	    verbose(3, "locusId %s not found in refLink (refSeq %s)\n", m->locusId, m->genbank);
	    safef(buf, sizeof(buf), "%d", rsRsi->locusLink);
	    m->locusId = cloneString(buf);
	    ++refWinsByDefault;
	    resolved = TRUE;
	    }
	else if (rsRsi == NULL)
	    {
	    if (conflictLog != NULL)
		{
		fprintf(conflictLog, 
		    "MTF #%d refSeq %s doesn't exist in mouse\n",
		    m->mtf, m->genbank);
		fprintf(conflictLog, "    replacing with %s from locusLink %s\n",
		    llRsi->refSeq, m->locusId);	
		}
	    verbose(3, "refSeq %s not found in refLink (locusLink %s)\n", m->genbank, m->locusId);
	    m->genbank = cloneString(llRsi->refSeq);
	    ++llWinsByDefault;
	    resolved = TRUE;
	    }
	else
	    {
	    internalErr();
	    }
	}

    /* If no locusLink, try to get it from PCR */
    if (m->locusId == NULL || m->locusId[0] == 0)
        {
	struct rnaList *rl = hashFindVal(pcrHash, mtf);
	if (rl != NULL)
	    {
	    char *refSeq = findRefSeqInList(rl, NULL);
	    if (refSeq != NULL)
		{
		struct refSeqInfo *rsi = hashFindVal(refHash, refSeq);
		if (rsi != NULL)
		    {
		    char buf[8];
		    ++locusLinkFromPcr;
		    safef(buf, sizeof(buf), "%d", rsi->locusLink);
		    verbose(3, "MTF%d from PCR refSeq %s\n", m->mtf, refSeq);
		    if (conflictLog != NULL)
			{
			fprintf(conflictLog, 
			    "MTF #%d  setting locusLink/refseq to %d/%s from PCR\n",
			    m->mtf, rsi->locusLink, refSeq);
			fprintf(conflictLog, "    replacing with %s from locusLink %s\n",
			    rsi->refSeq, m->locusId);	
			}
		    m->locusId = cloneString(buf);
		    m->genbank = refSeq;
		    }
		}
	    }
	}

    /* If have locusLink, use it to update name. */
	{
	struct refSeqInfo *llRsi = hashFindVal(llHash, m->locusId);
	if (llRsi != NULL && llRsi->geneName != NULL && llRsi->geneName[0] != 0)
	    m->geneName = llRsi->geneName;
	}

    /* If no genbank, use PCR to fill in genbank. */
    if (   (m->genbank == NULL || m->genbank[0] == 0) 
    	&& (m->locusId == NULL || m->locusId[0] == 0)
	&& (m->geneName == NULL || m->geneName[0] == 0))
	{
	struct rnaList *rl = hashFindVal(pcrHash, mtf);
	if (rl != NULL)
	    {
	    m->genbank = rl->accList->name;
	    verbose(2, "MTF%d - filling in genbank %s from PCR\n", m->mtf, m->genbank);
	    ++genbankFromPcr;
	    }
	}
    }
verbose(2, "RefSeq conflicts: refWinsByPcr %d, llWinsByPcr %d, noWin %d, noWinNoPcr %d, bothWin %d\n", refWinsByPcr, llWinsByPcr, noWin, noWinNoPcr, bothWin);
verbose(2, "              refWinsByName %d, llWinsByName %d\n", refWinsByName, llWinsByName);
verbose(2, "              refWinsByDefault %d, llWinsByDefault %d, noWinByDefault %d\n", refWinsByDefault, llWinsByDefault, noWinByDefault);
verbose(2, "Filled by PCR: locusLink %d, genbank %d\n", locusLinkFromPcr, genbankFromPcr);
}
コード例 #19
0
ファイル: cdwCheckDataset.c プロジェクト: davidhoover/kent
void cdwCheckDataset(char *outputFile)
/* cdwCheckDataset - Look at all the submissions for a given dataset and print helpful stats.. */
{

FILE *f = mustOpen(outputFile,"w"); 
struct sqlConnection *conn = sqlConnect("cdw"); 

char query[1024]; 
struct cdwSubmitDir *submitDir; 
// Get the id associated with the submission directory. 
if (gWorkingDir == NULL)
    {
    char cwd[1024]; 
    getcwd(cwd, sizeof(cwd)); 
    sqlSafef(query, sizeof(query), "select * from cdwSubmitDir where url = '%s';", cwd);
    submitDir = cdwSubmitDirLoadByQuery(conn, query); 
    }
else
    {
    sqlSafef(query, sizeof(query), "select * from cdwSubmitDir where url = '%s';", gWorkingDir);
    submitDir = cdwSubmitDirLoadByQuery(conn, query); 
    }

if (!submitDir)
    uglyAbort("There are no submissions associated with the submission directory provided.");

// Get all cdwSubmit entries associated with the submission directory. 
sqlSafef(query, sizeof(query), "select * from cdwSubmit where submitDirId = '%i';", submitDir->id); 
struct cdwSubmit *submitList = cdwSubmitLoadByQuery(conn, query);

struct cdwSubmit *submission;
// Keep track of the # of submissions, meta files and mani files. 
int count = 0; 
long long int totalFiles = 0, totalBytes = 0;	// Count the total files and bytes. 
struct slName *submitters = NULL, *user;    // Keep track of the submitters.   
// Loop over all cdwSubmit entries and gather/print out stats.  

for (submission = submitList; ; submission = submission->next)
    {
    ++count;
    sqlSafef(query,sizeof(query), "select * from cdwUser where id = '%i';", (int)submission->userId); 
    struct cdwUser *user = cdwUserLoadByQuery(conn,query); 
    if(!slNameInList(submitters, user->email)) // If a submitter has not been seen add it. 
	slNameAddHead(&submitters, user->email);
    // Print out submission stats. 
    fprintf(f, "Sub #: %i | Sub id: %i | New files: %i | New bytes: %lld | Mani id: %i |",  
	    count, submission->id, submission->newFiles, submission->newBytes, submission->manifestFileId);  
    fprintf(f, " Meta id: %i | Files with new meta data values: %i | User email: %s | Wrangler: %s\n",
	    submission->metaFileId, submission->metaChangeCount, user->email, submission->wrangler); 
    totalFiles += submission->newFiles; 
    totalBytes += submission->newBytes; 
    if (submission->next == NULL)
	break; 
    }
sqlSafef(query, sizeof(query), "select distinct metaFileId from cdwSubmit where submitDirId=%i", submitDir->id); 
fprintf(f,"Total submissions:\t%i\n", count); 
fprintf(f,"Total files:\t%lld\n",totalFiles);
// Math magic for pretty printing the file size. 
long long int tBytes, gBytes, mBytes, kBytes, bytes; 
tBytes = totalBytes/1000000000000;
gBytes = (totalBytes - tBytes * 1000000000000)/1000000000;
mBytes = (totalBytes - tBytes * 1000000000000 - gBytes * 1000000000)/1000000;
kBytes = (totalBytes - tBytes * 1000000000000 - gBytes * 1000000000 - mBytes * 1000000)/1000;
bytes = totalBytes - tBytes * 1000000000000 - gBytes * 1000000000 - mBytes * 1000000 - kBytes * 1000;

fprintf(f,"Total bytes:\t%lld T %lld G %lld M %lld K %lld B\n",  tBytes, gBytes, mBytes, kBytes, bytes); 

fprintf(f,"Submitters: "); 
// Print out the submitters, ideally it will only be one person but in practice... Not so much. 
for (user = submitters; ; user = user->next)
    {
    fprintf(f,"%s", user->name); 
    if (user->next == NULL)
	break;
    fprintf(f,", ");
    }
fprintf(f,"\n"); 
sqlDisconnect(&conn); 

}
コード例 #20
0
ファイル: hgTablesTest.c プロジェクト: elmargb/kentUtils
void testOutSequence(struct htmlPage *tablePage, struct htmlForm *mainForm,
     char *org, char *db, char *group, char *track, char *table, 
     int expectedRows)
/* Get as sequence and make sure count agrees with expected. */
/* mainForm not used */
{
struct htmlPage *outPage;
int attempts = 0;
struct htmlFormVar *typeVar;

if (tablePage->forms == NULL) 
    errAbort("testOutSequence: Missing form (tablePage)");

htmlPageSetVar(tablePage, NULL, hgtaOutputType, "sequence");
outPage = quickSubmit(tablePage, org, db, group, track, table,
    "seqUi1", hgtaDoTopSubmit, "submit");
while (outPage == NULL && attempts < MAX_ATTEMPTS) 
    {
    printf("testOutSequence: trying again to get seqUi1\n");
    outPage = quickSubmit(tablePage, org, db, group, track, table,
        "seqUi1", hgtaDoTopSubmit, "submit");
    attempts++;
    }
if (outPage == NULL) 
    {
    qaStatusSoftError(tablesTestList->status,
        "Error in testOutSequence - couldn't get outPage");
    return;
    }
if (outPage->forms == NULL)
    {
    qaStatusSoftError(tablesTestList->status,
        "Error in testOutSequence - missing form");
    htmlPageFree(&outPage);
    return;
    }

/* Since some genomic sequence things are huge, this will
 * only test in case where it's a gene prediction. */
typeVar = htmlFormVarGet(outPage->forms, hgtaGeneSeqType);
if (typeVar != NULL)
    {
    struct htmlPage *seqPage;
    static char *types[] = {"protein", "mRNA"};
    int i;
    for (i=0; i<ArraySize(types); ++i)
        {
        char *type = types[i];
        if (slNameInList(typeVar->values, type))
             {
	     struct htmlPage *page;
	     char testName[128];
	     htmlPageSetVar(outPage, NULL, hgtaGeneSeqType, type);
	     safef(testName, sizeof(testName), "%sSeq", type);
	     page = quickSubmit(outPage, org, db, group, track, table,
	        testName, hgtaDoGenePredSequence, "submit");
	     checkFaOutput(page, expectedRows, TRUE);
	     htmlPageFree(&page);
	     }
         }
    htmlPageSetVar(outPage, NULL, hgtaGeneSeqType, "genomic");
    serialSubmit(&outPage, org, db, group, track, table, "seqUi2", hgtaDoGenePredSequence, "submit");
    // check that outPage != NULL

    /* On genomic page uncheck intron if it's there, then get results * and count them. */
    if (htmlFormVarGet(outPage->forms, "hgSeq.intron") != NULL)
         htmlPageSetVar(outPage, NULL, "hgSeq.intron", NULL);
    seqPage = quickSubmit(outPage, org, db, group, track, table, "genomicSeq", hgtaDoGenomicDna, "submit");
    // check that seqPage != NULL
    checkFaOutput(seqPage, expectedRows, FALSE);
    htmlPageFree(&seqPage);
    }

htmlPageFree(&outPage);
}
コード例 #21
0
struct hash *readKeyHash(char *db, struct joiner *joiner,
                         struct joinerField *keyField, struct keyHitInfo **retList)
/* Read key-field into hash.  Check for dupes if need be. */
{
    struct sqlConnection *conn = sqlWarnConnect(db);
    struct hash *keyHash = NULL;
    struct keyHitInfo *khiList = NULL, *khi;
    if (conn == NULL)
    {
        return NULL;
    }
    else
    {
        struct slName *table;
        struct slName *tableList = getTablesForField(conn,keyField->splitPrefix,
                                   keyField->table,
                                   keyField->splitSuffix);
        int rowCount = totalTableRows(conn, tableList);
        int hashSize = digitsBaseTwo(rowCount)+1;
        char query[256], **row;
        struct sqlResult *sr;
        int itemCount = 0;
        int dupeCount = 0;
        char *dupe = NULL;

        if (rowCount > 0)
        {
            if (hashSize > hashMaxSize)
                hashSize = hashMaxSize;
            keyHash = hashNew(hashSize);
            for (table = tableList; table != NULL; table = table->next)
            {
                safef(query, sizeof(query), "select %s from %s",
                      keyField->field, table->name);
                sr = sqlGetResult(conn, query);
                while ((row = sqlNextRow(sr)) != NULL)
                {
                    char *id = doChopsAndUpper(keyField, row[0]);
                    if (hashLookup(keyHash, id))
                    {
                        if (keyField->unique)
                        {
                            if (keyField->exclude == NULL ||
                                    !slNameInList(keyField->exclude, id))
                            {
                                if (dupeCount == 0)
                                    dupe = cloneString(id);
                                ++dupeCount;
                            }
                        }
                    }
                    else
                    {
                        AllocVar(khi);
                        hashAddSaveName(keyHash, id, khi, &khi->name);
                        slAddHead(&khiList, khi);
                        ++itemCount;
                    }
                }
                sqlFreeResult(&sr);
            }
            if (dupe != NULL)
            {
                warn("Error: %d duplicates in %s.%s.%s including '%s'",
                     dupeCount, db, keyField->table, keyField->field, dupe);
                freez(&dupe);
            }
            verbose(2, " %s.%s.%s - %d unique identifiers\n",
                    db, keyField->table, keyField->field, itemCount);
        }
        slFreeList(&tableList);
    }
    sqlDisconnect(&conn);
    *retList = khiList;
    return keyHash;
}