src/hg/hgGenome/import.c 1.17

1.17 2010/03/25 17:20:40 angie
Use hAllocConnTrack instead of sqlConnect or hAllocConn to support profiles in hg.conf.
Index: src/hg/hgGenome/import.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgGenome/import.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -b -B -U 4 -r1.16 -r1.17
--- src/hg/hgGenome/import.c	12 Oct 2009 22:43:34 -0000	1.16
+++ src/hg/hgGenome/import.c	25 Mar 2010 17:20:40 -0000	1.17
@@ -135,10 +135,9 @@
 }
 
 
 
-struct grp *makeGroupList(struct sqlConnection *conn, 
-	struct trackDb *trackList, boolean allTablesOk)
+struct grp *makeGroupList(struct trackDb *trackList, boolean allTablesOk)
 /* Get list of groups that actually have something in them. */
 {
 struct grp *groupsAll, *groupList = NULL, *group;
 struct hash *groupsInTrackList = newHash(0);
@@ -152,9 +151,9 @@
         hashAdd(groupsInTrackList, track->grp, NULL);
     }
 
 /* Scan through group table, putting in ones where we have data. */
-groupsAll = hLoadGrps(sqlGetDatabase(conn));
+groupsAll = hLoadGrps(database);
 for (group = slPopHead(&groupsAll); group != NULL; group = slPopHead(&groupsAll))
     {
     if (hashLookup(groupsInTrackList, group->name))
 	{
@@ -408,9 +407,9 @@
 hashFree(&uniqHash);
 return nameList;
 }
 
-static char *findSelectedTable(struct sqlConnection *conn, struct trackDb *track, char *var)
+static char *findSelectedTable(struct trackDb *track, char *var)
 /* Find selected table.  Default to main track table if none
  * found. */
 {
 
@@ -433,24 +432,24 @@
 
 
 
 
-void initGroupsTracksTables(struct sqlConnection *conn)
+void initGroupsTracksTables()
 /* Get list of groups that actually have something in them. */
 {
 
 fullTrackList = getFullTrackList();
 
 curTrack = findSelectedTrack(fullTrackList, NULL, hggTrack);
 
-fullGroupList = makeGroupList(conn, fullTrackList, TRUE);
+fullGroupList = makeGroupList(fullTrackList, TRUE);
 
 curGroup = findSelectedGroup(fullGroupList, hggGroup);
 
 if (sameString(curGroup->name, "allTables"))
     curTrack = NULL;
 
-curTable = findSelectedTable(conn, curTrack, hggTable);
+curTable = findSelectedTable(curTrack, hggTable);
 
 if (curTrack == NULL)
     {
     struct trackDb *tdb = hTrackDbForTrack(database, curTable);
@@ -519,9 +518,9 @@
 struct grp *showGroupField(char *groupVar, char *groupScript,
     struct sqlConnection *conn, boolean allTablesOk)
 /* Show group control. Returns selected group. */
 {
-struct grp *group, *groupList = makeGroupList(conn, fullTrackList, allTablesOk);
+struct grp *group, *groupList = makeGroupList(fullTrackList, allTablesOk);
 struct grp *selGroup = findSelectedGroup(groupList, groupVar);
 hPrintf("<B>group:</B>\n");
 hPrintf("<SELECT NAME=%s %s>\n", groupVar, groupScript);
 for (group = groupList; group != NULL; group = group->next)
@@ -844,9 +843,10 @@
 	{
     	struct hTableInfo *hti = hFindTableInfo(database, NULL, name->name);
 	if (!hti)
 	    continue;  /* filter out tables that don't exist anymore */
-	if (!htiIsPositional(hti))
+	if (!htiIsPositional(hti) &&
+	    !startsWith("bam", track->type) && !startsWith("big", track->type))
 	    continue;  /* filter out non-positional, do not add it to new list */
 	}
     slAddHead(&newList,name);
     }
@@ -893,16 +893,17 @@
 struct hTableInfo *hti = NULL;
 
 
 cartWebStart(cart, database, "Import Table to Genome Graphs");
-hPrintf("<FORM ACTION=\"../cgi-bin/hgGenome\" NAME=\"mainForm\" METHOD=\"POST\">");
+hPrintf("<FORM ACTION=\"../cgi-bin/hgGenome\" NAME=\"mainForm\" METHOD=\"%s\">",
+	cartUsualString(cart, "formMethod", "POST"));
 cartSaveSession(cart);
 
 jsWriteFunctions();
 
 
 allJoiner = joinerRead("all.joiner");
-initGroupsTracksTables(conn);
+initGroupsTracksTables();
 
 hPrintf("<TABLE BORDER=0>\n");
 
 
@@ -1415,9 +1416,9 @@
 return dyStringCannibalize(&dy);
 }
 
 
-void submitImport(struct sqlConnection *conn)
+void submitImport()
 /* Called when they've submitted from import page */
 {
 boolean isWig = FALSE, isPositional = FALSE, isMaf = FALSE, isBedGr = FALSE,
         isChromGraphCt = FALSE, isCt = FALSE;
@@ -1428,9 +1429,9 @@
 cartSaveSession(cart);
 
 
 allJoiner = joinerRead("all.joiner");
-initGroupsTracksTables(conn);
+initGroupsTracksTables();
 
 if (strchr(curTable, '.') == NULL)  /* In same database */
     {
     hti = getHti(database, curTable);
@@ -1450,30 +1451,9 @@
     {
     isChromGraphCt = isChromGraph(curTrack);
     }
 
-
-/* debug info
-char *selGroup = cartString(cart, hggGroup);
-char *selTrack = cartString(cart, hggTrack);
-//char *selTable = cartString(cart, hggTable);
-
-hPrintf("Debug Info:<br>\n");
-hPrintf("----------------------------<br>\n");
-hPrintf("selected group: %s<br>\n",selGroup);
-hPrintf("selected track: %s<br>\n",selTrack);
-hPrintf("curTable: %s<br>\n",curTable);
-hPrintf("curTrack->type: %s<br>\n", curTrack->type);
-hPrintf("curTrack->tableName: %s<br>\n", curTrack->tableName);
-hPrintf("isWig: %d<br>\n", isWig);
-hPrintf("isPositional: %d<br>\n", isPositional);
-hPrintf("isMaf: %d<br>\n", isMaf);
-hPrintf("isBedGr: %d<br>\n", isBedGr);
-hPrintf("isChromGraphCt: %d<br>\n", isChromGraphCt);
-hPrintf("isCustomTrack: %d<br>\n", isCt);
-*/
-
-
+struct sqlConnection *conn = curTrack ? hAllocConnTrack(database, curTrack) : hAllocConn(database);
 if (isPositional && !isWig && !isMaf && !isBedGr && !isChromGraphCt)
     {  /* simple positional */
     char *convertType = 
     cartUsualString(cart, hggBedConvertType, hggBedDepth);
@@ -1493,12 +1473,8 @@
 else if (isPositional && !isWig && !isMaf && isBedGr && !isChromGraphCt)
     {  /* bedGraph */
     char *rawText = NULL;
 
-    //debug: 
-    char *bedGraphField = getBedGraphField(curTable);
-    hPrintf("bedGraphField = %s<br>\n",bedGraphField); fflush(stdout);
-
     rawText = makeDepthCgFromBed(isBedGr);
 
     struct errCatch *errCatch = errCatchNew();
     if (errCatchStart(errCatch))
@@ -1530,9 +1506,9 @@
     errCatchFinish(&errCatch);
 
     }
 
-
+hFreeConn(&conn);
 hPrintf("\n");
 hPrintf("<CENTER>");
 cgiMakeButton("submit", "OK");
 hPrintf("</CENTER>");