e70152e44cc66cc599ff6b699eb8adc07f3e656a kent Sat May 24 21:09:34 2014 -0700 Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment. diff --git src/hg/qa/seqCheck.c src/hg/qa/seqCheck.c index 0c78818..4cff0a1 100644 --- src/hg/qa/seqCheck.c +++ src/hg/qa/seqCheck.c @@ -1,105 +1,108 @@ /* seqCheck - check that extFile references in seq table are valid. */ + +/* Copyright (C) 2013 The Regents of the University of California + * See README in this or parent directory for licensing information. */ #include "common.h" #include "hdb.h" char *database = NULL; struct extFileId { struct extFileId *next; int id; }; void usage() /* Explain usage and exit. */ { errAbort( "seqCheck - check that extFile references in seq table are valid\n" "usage:\n" " seqCheck database \n"); } struct extFileId *readSeq() /* Slurp in the rows */ { struct extFileId *list=NULL, *el; char query[512]; struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr; char **row; int count = 0; verbose(2, "reading in from seq...\n"); sqlSafef(query, sizeof(query), "select distinct(extFile) from seq"); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { count++; AllocVar(el); el->id = atoi(row[0]); el->next = list; list = el; } sqlFreeResult(&sr); hFreeConn(&conn); slReverse(&list); /* could possibly skip if it made much difference in speed. */ verbose(2, "%d rows found\n", count); return list; } void seqCheck() /* seqCheck - read in all seq, compare to extFile. */ { struct extFileId *idList = NULL; struct extFileId *id1 = NULL; char query[512]; struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr; char **row; idList = readSeq(); verbose(2, "checking....\n"); for (id1 = idList; id1 != NULL; id1 = id1->next) { sqlSafef(query, sizeof(query), "select path from extFile where id = %d", id1->id); sr = sqlGetResult(conn, query); row = sqlNextRow(sr); if (row == NULL) { verbose(1, "no matches for %d\n", id1->id); continue; } /* check here for multiple matches */ while ((row = sqlNextRow(sr)) != NULL) { } sqlFreeResult(&sr); } // seqFreeList(&seqList); } int main(int argc, char *argv[]) /* Check args and call seqCheck. */ { if (argc != 2) usage(); database = argv[1]; // check for table existence if (!hTableExists(database, "seq")) errAbort("no seq table"); if (!hTableExists(database, "extFile")) errAbort("no extFile table"); seqCheck(); return 0; }