70d4208efa11f262ba5591198214c9ccdc6b54ae angie Mon Aug 22 22:24:05 2011 -0700 Feature #3707 (VCF+tabix support in hgTables):Basic hgTables support for VCF, modeled after BAM code. Tested all fields, selected fields, bed output; filter, intersection, schema on 3 flavors of vcfTabix: ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20101123/interim_phase1_release/ALL.chr17.phase1.projectConsensus.genotypes.vcf.gz ftp://ftp-trace.ncbi.nlm.nih.gov/1000genomes/ftp/release/20100804/AFR.dindel.20100804.sites.vcf.gz ftp://ftp.ncbi.nih.gov/snp/organisms/human_9606/VCF/v4.0/ByChromosomeNoGeno/00-All.vcf.gz diff --git src/hg/hgTables/identifiers.c src/hg/hgTables/identifiers.c index 15d5149..b9b0e3a 100644 --- src/hg/hgTables/identifiers.c +++ src/hg/hgTables/identifiers.c @@ -58,30 +58,35 @@ if (retIdField != NULL) *retIdField = idField; if (retAliasField != NULL) *retAliasField = aliasField; } static struct slName *getExamples(struct sqlConnection *conn, char *table, char *field, int count) /* Return a list of several example values of table.field. */ { if (isBamTable(table)) { assert(sameString(field, "qName")); return randomBamIds(table, conn, count); } +if (isVcfTable(table)) + { + assert(sameString(field, "id")); + return randomVcfIds(table, conn, count); + } else { char fullTable[HDB_MAX_TABLE_STRING]; if (! hFindSplitTable(database, NULL, table, fullTable, NULL)) safecpy(fullTable, sizeof(fullTable), table); return sqlRandomSampleConn(conn, fullTable, field, count); } } static void explainIdentifiers(struct sqlConnection *conn, char *idField) /* Tell the user what field(s) they may paste/upload values for, and give * some examples. */ { char *xrefTable = NULL, *xrefIdField = NULL, *aliasField = NULL; getXrefInfo(conn, &xrefTable, &xrefIdField, &aliasField); @@ -276,31 +281,31 @@ } static struct hash *getAllPossibleIds(struct sqlConnection *conn, struct lm *lm, char *idField, char *extraWhere) /* Make a hash of all identifiers in curTable (and alias tables if specified) * so that we can check the validity of pasted/uploaded identifiers. */ { struct hash *matchHash = hashNew(20); struct slName *tableList; char *xrefTable = NULL, *xrefIdField = NULL, *aliasField = NULL; struct sqlConnection *alternateConn = conn; if (sameWord(curTable, WIKI_TRACK_TABLE)) alternateConn = wikiConnect(); -if (isCustomTrack(curTable) || isBamTable(curTable)) +if (isCustomTrack(curTable) || isBamTable(curTable) || isVcfTable(curTable)) /* Currently we don't check whether these are valid CT item * names or not. matchHash is empty for CTs. */ tableList = NULL; else if (sameWord(curTable, WIKI_TRACK_TABLE)) tableList = slNameNew(WIKI_TRACK_TABLE); else if (strchr(curTable, '.')) tableList = slNameNew(curTable); else tableList = hSplitTableNames(database, curTable); if (idField != NULL) addPrimaryIdsToHash(alternateConn, matchHash, idField, tableList, lm, extraWhere); getXrefInfo(alternateConn, &xrefTable, &xrefIdField, &aliasField); if (xrefTable != NULL) { addXrefIdsToHash(alternateConn, matchHash, idField, @@ -380,31 +385,31 @@ } } lineFileClose(&lf); char *extraWhere = NULL; int maxIdsInWhere = cartUsualInt(cart, "hgt_maxIdsInWhere", DEFAULT_MAX_IDS_IN_WHERE); if (totalTerms > 0 && totalTerms <= maxIdsInWhere) extraWhere = slNameToInExpression(idField, allTerms); struct lm *lm = lmInit(0); struct hash *matchHash = getAllPossibleIds(conn, lm, idField, extraWhere); trashDirFile(&tn, "hgtData", "identifiers", ".key"); f = mustOpen(tn.forCgi, "w"); for (term = allTerms; term != NULL; term = term->next) { struct slName *matchList = NULL, *match; - if (isCustomTrack(curTable) || isBamTable(curTable)) + if (isCustomTrack(curTable) || isBamTable(curTable) || isVcfTable(curTable)) { /* Currently we don't check whether these are valid CT item * names or not. matchHash is empty for CTs. */ matchList = slNameNew(term->name); } else { /* Support multiple alias->id mappings: */ char upcased[1024]; safecpy(upcased, sizeof(upcased), term->name); touppers(upcased); struct hashEl *hel = hashLookup(matchHash, upcased); if (hel != NULL) { matchList = slNameNew((char *)hel->val);