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/hgTables.c src/hg/hgTables/hgTables.c index 6bb5e14..168bc04 100644 --- src/hg/hgTables/hgTables.c +++ src/hg/hgTables/hgTables.c @@ -583,65 +583,61 @@ void checkTableExists(struct sqlConnection *conn, char *table) /* Check that table exists, or put up an error message. */ { char *splitTable = chromTable(conn, table); if (!sqlTableExists(conn, table)) errAbort("Table %s doesn't exist", table); freeMem(splitTable); } struct hTableInfo *hubTrackTableInfo(struct trackDb *tdb) /* Given trackDb entry for a hub track, wrap table info around it. */ { struct hTableInfo *hti; if (startsWithWord("bigBed", tdb->type)) - { hti = bigBedToHti(tdb->track, NULL); - } else if (startsWithWord("bam", tdb->type)) - { hti = bamToHti(tdb->table); - } +else if (startsWithWord("vcfTabix", tdb->type)) + hti = vcfToHti(tdb->table); else { AllocVar(hti); hti->rootName = cloneString(tdb->track); hti->isPos = TRUE; hti->type = cloneString(tdb->type); } return hti; } struct hTableInfo *maybeGetHti(char *db, char *table, struct sqlConnection *conn) /* Return primary table info, but don't abort if table not there. Conn should be open to db. */ { struct hTableInfo *hti = NULL; if (isHubTrack(table)) { struct trackDb *tdb = hashMustFindVal(fullTrackAndSubtrackHash, table); hti = hubTrackTableInfo(tdb); } else if (isBigBed(database, table, curTrack, ctLookupName)) - { hti = bigBedToHti(table, conn); - } else if (isBamTable(table)) - { hti = bamToHti(table); - } +else if (isVcfTable(table)) + hti = vcfToHti(table); else if (isCustomTrack(table)) { struct customTrack *ct = ctLookupName(table); hti = ctToHti(ct); } else if (sameWord(table, WIKI_TRACK_TABLE)) { hti = wikiHti(); } else { char *track; if (startsWith("chrN_", table)) track = table + strlen("chrN_"); else @@ -1363,54 +1359,56 @@ /* Do some error diagnostics for user. */ if (outCount == 0) explainWhyNoResults(f); hashFree(&idHash); } void doTabOutTable( char *db, char *table, FILE *f, struct sqlConnection *conn, char *fields) /* Do tab-separated output on fields of a single table. */ { if (isBigBed(database, table, curTrack, ctLookupName)) bigBedTabOut(db, table, conn, fields, f); else if (isBamTable(table)) bamTabOut(db, table, conn, fields, f); +else if (isVcfTable(table)) + vcfTabOut(db, table, conn, fields, f); else if (isCustomTrack(table)) { doTabOutCustomTracks(db, table, conn, fields, f); } else doTabOutDb(db, db, table, table, f, conn, fields); } struct slName *fullTableFields(char *db, char *table) /* Return list of fields in db.table.field format. */ { char dtBuf[256]; struct sqlConnection *conn; struct slName *fieldList = NULL, *dtfList = NULL, *field, *dtf; if (isBigBed(database, table, curTrack, ctLookupName)) { conn = hAllocConn(db); fieldList = bigBedGetFields(table, conn); hFreeConn(&conn); } else if (isBamTable(table)) - { fieldList = bamGetFields(table); - } +else if (isVcfTable(table)) + fieldList = vcfGetFields(table); else if (isCustomTrack(table)) { struct customTrack *ct = ctLookupName(table); char *type = ct->dbTrackType; if (type != NULL) { conn = hAllocConn(CUSTOM_TRASH); if (startsWithWord("maf", type) || startsWithWord("makeItems", type) || sameWord("bedDetail", type) || sameWord("pgSnp", type)) fieldList = sqlListFields(conn, ct->dbTableName); hFreeConn(&conn); } if (fieldList == NULL) fieldList = getBedFields(ct->fieldCount); } else