int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 2 && !optionExists("settings")) usage(); struct trackHubCheckOptions *checkOptions = NULL; AllocVar(checkOptions); checkOptions->specHost = (optionExists("test") ? "genome-test.soe.ucsc.edu" : "genome.ucsc.edu"); checkOptions->specHost = optionVal("specHost", checkOptions->specHost); checkOptions->printMeta = optionExists("printMeta"); checkOptions->checkFiles = !optionExists("noTracks"); checkOptions->checkSettings = optionExists("checkSettings"); struct trackHubSettingSpec *setting = NULL; AllocVar(setting); setting->level = optionVal("level", "all"); if (trackHubSettingLevel(setting) < 0) { fprintf(stderr, "ERROR: Unrecognized support level %s\n\n", setting->level); usage(); } checkOptions->level = setting->level; char *version = NULL; if (optionExists("version")) version = optionVal("version", NULL); checkOptions->version = version; char *extraFile = optionVal("extra", NULL); if (extraFile != NULL) addExtras(extraFile, checkOptions); cacheTime = optionInt("cacheTime", cacheTime); udcSetCacheTimeout(cacheTime); // UDC cache dir: first check for hg.conf setting, then override with command line option if given. setUdcCacheDir(); udcSetDefaultDir(optionVal("udcDir", udcDefaultDir())); knetUdcInstall(); // make the htslib library use udc if (optionExists("settings")) { showSettings(checkOptions); return 0; } struct dyString *errors = newDyString(1024); if (trackHubCheck(argv[1], checkOptions, errors)) { // uniquify and count errors struct slName *errs = slNameListFromString(errors->string, '\n'); slUniqify(&errs, slNameCmp, slNameFree); int errCount = slCount(errs); printf("Found %d problem%s:\n", errCount, errCount == 1 ? "" : "s"); printf("%s\n", slNameListToString(errs, '\n')); return 1; } return 0; }
struct slPair *mdbSelectPairs(struct cart *cart, struct slPair *mdbVars) // Returns the current mdb vars and vals in the table of drop down selects { // figure out how many metadata selects are visible. int numMetadataSelects = 0; struct slPair *mdbSelectPairs = NULL; if (mdbVars == NULL) return 0; // Get the current number of rows in the table of mdb selects for (;;) { char buf[256]; safef(buf, sizeof(buf), "%s%d", METADATA_NAME_PREFIX, numMetadataSelects + 1); char *str = cartOptionalString(cart, buf); if (isEmpty(str)) break; else numMetadataSelects++; } // Requesting to add or delete any? int delSearchSelect = cartUsualInt(cart, TRACK_SEARCH_DEL_ROW, 0); // 1-based row to delete int addSearchSelect = cartUsualInt(cart, TRACK_SEARCH_ADD_ROW, 0); // 1-based row to insert after if (delSearchSelect) numMetadataSelects--; if (addSearchSelect) numMetadataSelects++; if (numMetadataSelects) { int ix; char buf[256]; for (ix = 0; ix < numMetadataSelects; ix++) { int offset; // used to handle additions/deletions if (addSearchSelect > 0 && ix >= addSearchSelect) offset = 0; // do nothing to offset (i.e. copy data from previous row) else if (delSearchSelect > 0 && ix + 1 >= delSearchSelect) offset = 2; else offset = 1; safef(buf, sizeof(buf), "%s%d", METADATA_NAME_PREFIX, ix + offset); char *var = cartOptionalString(cart, buf); char *val = NULL; // We need to make sure var is valid in this assembly; if it isn't, reset it to "cell". if (slPairFindVal(mdbVars,var) == NULL) var = "cell"; else { safef(buf, sizeof(buf), "%s%d", METADATA_VALUE_PREFIX, ix + offset); enum cvSearchable searchBy = cvSearchMethod(var); if (searchBy == cvSearchByMultiSelect) { // Multi-selects as comma delimited list of values struct slName *vals = cartOptionalSlNameList(cart,buf); if (vals) { val = slNameListToString(vals,','); // A comma delimited list of values slNameFreeList(&vals); } } else if (searchBy == cvSearchBySingleSelect || searchBy == cvSearchByFreeText || searchBy == cvSearchByWildList) val = cloneString(cartUsualString(cart, buf,ANYLABEL)); //else if (searchBy == cvSearchByDateRange || searchBy == cvSearchByIntegerRange) // { // // TO BE IMPLEMENTED // } if (val != NULL && sameString(val, ANYLABEL)) val = NULL; } slPairAdd(&mdbSelectPairs,var,val); // val already cloned } if (delSearchSelect > 0) { safef(buf, sizeof(buf), "%s%d", METADATA_NAME_PREFIX, numMetadataSelects + 1); cartRemove(cart, buf); safef(buf, sizeof(buf), "%s%d", METADATA_VALUE_PREFIX, numMetadataSelects + 1); cartRemove(cart, buf); } } else { // create defaults slPairAdd(&mdbSelectPairs,"cell", NULL); slPairAdd(&mdbSelectPairs,"antibody",NULL); } slReverse(&mdbSelectPairs); return mdbSelectPairs; }