src/hg/hgTables/seqOut.c 1.22

1.22 2009/04/16 18:20:40 angie
Print our usual 'No results' method instead of blank screen when no results (thx Katrina).
Index: src/hg/hgTables/seqOut.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/seqOut.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -b -B -U 4 -r1.21 -r1.22
--- src/hg/hgTables/seqOut.c	10 Apr 2009 20:04:29 -0000	1.21
+++ src/hg/hgTables/seqOut.c	16 Apr 2009 18:20:40 -0000	1.22
@@ -109,8 +109,9 @@
         hashAdd(protHash, row[0], lmCloneString(protHash->lm, protAcc));
     }
 sqlFreeResult(&sr);
 
+boolean gotResults = FALSE;
 for (bed = bedList; bed != NULL; bed = bed->next)
     {
     char *protAcc = hashFindVal(protHash, bed->name);
     if (protAcc != NULL && !hashLookup(uniqHash, protAcc))
@@ -119,10 +120,13 @@
 	hashAdd(uniqHash, protAcc, NULL);
 	if (fa != NULL)
 	    hPrintf("%s", fa);
 	freez(&fa);
+	gotResults = TRUE;
 	}
     }
+if (!gotResults)
+    hPrintf(NO_RESULTS);
 hashFree(&protHash);
 hashFree(&uniqHash);
 }
 
@@ -130,8 +134,9 @@
 /* Fetch refGene mRNA sequence. */
 {
 struct hash *uniqHash = newHash(18);
 struct bed *bed;
+boolean gotResults = FALSE;
 for (bed = bedList; bed != NULL; bed = bed->next)
     {
     if (!hashLookup(uniqHash, bed->name))
         {
@@ -139,10 +144,13 @@
 	hashAdd(uniqHash, bed->name, NULL);
 	if (fa != NULL)
 	    hPrintf("%s", fa);
 	freez(&fa);
+	gotResults = TRUE;
 	}
     }
+if (!gotResults)
+    hPrintf(NO_RESULTS);
 hashFree(&uniqHash);
 }
 
 void doGenePredNongenomic(struct sqlConnection *conn, int typeIx)
@@ -181,8 +189,9 @@
 	struct sqlResult *sr;
 	char **row;
 	char query[256];
 	struct hash *hash = newHash(18);
+	boolean gotResults = FALSE;
 
 	/* Make hash of all id's passing filters. */
 	for (bed = bedList; bed != NULL; bed = bed->next)
 	    hashAdd(hash, bed->name, NULL);
@@ -195,12 +204,15 @@
 	    if (hashLookup(hash, row[0]))
 		{
 		hPrintf(">%s\n", row[0]);
 		writeSeqWithBreaks(stdout, row[1], strlen(row[1]), 60);
+		gotResults = TRUE;
 		}
 	    }
 	sqlFreeResult(&sr);
 	hashFree(&hash);
+	if (!gotResults)
+	    hPrintf(NO_RESULTS);
 	}
     else
 	{
 	internalErr();
@@ -245,15 +257,22 @@
 struct region *region, *regionList = getRegions();
 struct hTableInfo *hti = getHti(database, curTable, conn);
 int fieldCount;
 textOpen();
+boolean gotResult = FALSE;
 for (region = regionList; region != NULL; region = region->next)
     {
     struct lm *lm = lmInit(64*1024);
     struct bed *bedList = cookedBedList(conn, curTable, region, lm, &fieldCount);
+    if (bedList != NULL)
+    	{
+    	gotResult = TRUE;
     hgSeqBed(database, hti, bedList);
+	}
     lmCleanup(&lm);
     }
+if (!gotResult)
+    hPrintf(NO_RESULTS);
 }
 
 void doGenePredSequence(struct sqlConnection *conn)
 /* Output genePred sequence. */