Index: src/utils/qa/showTracks
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/utils/qa/showTracks,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -B -U 1000000 -r1.5 -r1.6
--- src/utils/qa/showTracks	3 Jun 2008 22:32:01 -0000	1.5
+++ src/utils/qa/showTracks	11 Apr 2009 00:37:05 -0000	1.6
@@ -1,301 +1,302 @@
 #! /bin/tcsh
+source `which qaConfig.csh`
 echo "Content-Type:text/html"
 echo
 echo "<HTML>"
 echo "<HEAD>"
 
 set srvr = "genome.ucsc.edu"
 if ( $?QUERY_STRING == 0 ) then
     set QUERY_STRING = "srvr=genome.ucsc.edu"
 endif
 if ( "$QUERY_STRING" == "" ) then
     set QUERY_STRING = "srvr=genome.ucsc.edu"
 endif
 # Split the field=value pair on the '='.
 set pair=`echo $QUERY_STRING | sed 's/=/\t/'`
 # The first part of the pair is the name.
 set varname=`echo ${pair} | awk '{print $1}'`
 # The second part of the pair is the srvr name.
 set varval=`echo ${pair} | awk '{print $2}'`
 if ("$varname" == "srvr") then
     set srvr = "$varval"
 endif
 #echo "dbg: pair = $pair <br>"
 
 echo '<TITLE>Track UI on '`echo $srvr | sed "s/.ucsc.edu//" \
   | sed "s/.cse//"`' </TITLE>'
 echo "</HEAD>"
 echo 
 echo "<BODY>"
 echo
 echo '<H2>Track UI on '`echo $srvr | sed "s/.ucsc.edu//" \
   | sed "s/.cse//"`'</H2>'
 
 # echo "Hello.<br><br>"
 
 echo "<BLOCKQUOTE><B> hgw: &nbsp;"
 
 # display without a link if that's the page you are on.
 foreach machine ( dev beta genome 1 2 3 4 5 6 7 8 )
   echo $srvr | grep $machine > /dev/null
   if ( $status ) then
     if ( $machine == RR || $machine == genome) then
       set node=genome
       set machine=RR
     else 
       set node=hgw${machine}.cse 
     endif
     echo '<A HREF="showTracks?srvr='$node'.ucsc.edu">'
   endif
   echo $machine | sed "s/genome/RR/"
   echo "</A>&nbsp;"
 end
 echo "  </B>"
 echo "</BLOCKQUOTE>"
 
 set line=`grep "pq.user" hg.conf`
 set pair=`echo $line| sed 's/=/\t/'`
 set user=`echo ${pair} | awk '{print $2}'`
 
 set line=`grep "pq.password" hg.conf`
 set pair=`echo $line| sed 's/=/\t/'`
 set pwd=`echo ${pair} | awk '{print $2}'`
 
 set junkPath = "../trash/gbjunk"  # normal cgi use
 #set junkPath = "./gbjunk"       # use when running from commandline
 
 set recentDb = "hg17"
 
 set sql = 'select name, label, "." from grp '
 set sql = "$sql"'where name not like "user" and name not like "encode" and name not like "x" '
 set sql = "$sql"'order by priority;'
 
 #echo "$sql<br>"
 
 set grpraw = `/cluster/bin/i386/hgsql $recentDb -B --skip-column-names -e "$sql"`
 set err = $status
 if ($err) then
     echo "error $err processing: $sql <br>"
     exit 0
 endif
 
 #echo "$grpraw <br>"
 
 set grpname = ()
 set grplabel = ()
 
 while ( "$grpraw" != "" )
     #echo "$grpraw[1] = "
     set grpname = ($grpname $grpraw[1])
     shift grpraw
     set txt = ""
     set sep = ""
     while ( "$grpraw[1]" != "." )
     	set txt = "$txt$sep$grpraw[1]"
 	shift grpraw
 	set sep = "_"
     end
     shift grpraw
     set grplabel = ($grplabel "$txt")
     #echo "$txt <br>"
 end
 #echo "<br>"
 #echo "grpname: size $#grpname = $grpname <br>"
 #echo "grplabel: size $#grplabel= $grplabel <br>"
 #echo "<br>"
 #echo "<br>"
 
 set sql = 'select name from dbDb where active = "1" and name not like "zoo%" order by orderKey;'
 set dblist = `/cluster/bin/i386/hgsql hgcentralbeta -B --skip-column-names -e "$sql"`
 set err = $status
 if ($err) then
     echo "error $err processing: $sql <br>"
     exit 0
 endif
 
 #echo $dblist
 #foreach db ( $dblist )
 #    echo "$db <br>"
 #end
 #echo "<br>"
 #echo "<br>"
 
 
 set sql = 'drop table gbjunk;'
 #echo "$sql<br>"
 /cluster/bin/i386/hgsql -u$user -p$pwd qapushq -B --skip-column-names -e "$sql"
 set err = $status
 if ($err) then
     # ignore this error, probably the table doesn't exist because it got cleaned up
     #echo "error $err processing: $sql <br>"
 endif
 #echo "got past table cleanup.<br>"
 
 set sql = ''
 set sql = "$sql"'create table gbjunk('
 set sql = "$sql"'db varchar(255), '
 set sql = "$sql"'grp varchar(255), '
 set sql = "$sql"'tableName varchar(255), '
 set sql = "$sql"'shortLabel varchar(255));'
 #echo "$sql<br>"
 /cluster/bin/i386/hgsql -u$user -p$pwd qapushq -B --skip-column-names -e "$sql"
 set err = $status
 if ($err) then
     echo "error $err processing: $sql <br>"
     exit 0
 endif
 #echo "got past table create.<br>"
 
 rm -f $junkPath
 foreach db ( $dblist )
     set sql = 'select "'"$db"'", grp, tableName, shortLabel from trackDb '
     set sql = "$sql"'where grp not like "user" and grp not like "encode" and grp not like "x" '
     set sql = "$sql"'order by grp;'
     /cluster/bin/i386/hgsql $db -B --skip-column-names -e "$sql" >> $junkPath
     set err = $status
     if ($err) then
 	echo "error $err processing: $sql <br>"
     	exit 0
     endif
 end
 #echo "<br>"
 #echo "<br>"
 
 set sql = 'load data local infile "'"$junkPath"'" into table gbjunk;'
 /cluster/bin/i386/hgsql -u$user -p$pwd qapushq -e "$sql" 
 set err = $status
 if ($err) then
     echo "error $err processing: $sql <br>"
     exit 0
 endif
 #echo "got past table load.<br>"
 
 
 rm -f $junkPath
 
 # ==== MAIN LOOP ===========
 
 @ g = 1
 while ( $g <= $#grplabel  )
     set lbl = `echo $grplabel[$g] | sed -e "s/_/ /g"`
     echo "<H3>$lbl</H3>"
 
 # ---- FIND ALL TRACKS IN GRP g ----
     set sql = 'select distinct shortLabel, ".", tableName from gbjunk '
     set sql = "$sql"'where grp="'"$grpname[$g]"'" '
     set sql = "$sql"'order by shortLabel;'
     #echo "$sql<br>"
     set trklist = `/cluster/bin/i386/hgsql -u$user -p$pwd qapushq -B --skip-column-names -e "$sql"`
     set err = $status
     if ($err) then
 	echo "error $err processing: $sql <br>"
     	exit 0
     endif
     #echo "$trklist<br>"
     echo "<br>"
     
     echo "<table BORDER CELLSPACING=0 CELLPADDING=5>"
 
     #-- column headings --
     echo "<th>"
     echo "Track"
     echo "</th>"
     foreach db ( $dblist )
 	echo "<th>"
 	echo "$db"
     	echo "</th>"
     end
   
     #-- do rows --
     while ("$trklist" != "")
     	
 	echo "<tr>"
     
     	echo "<td>"
      	set shortLabel = ""
     	set sep = ""
 	while ("$trklist[1]" != ".")
 	    #echo "$trklist[1] "
 	    set shortLabel = "$shortLabel$sep$trklist[1]"
     	    shift trklist
     	    set sep = " "
 	end
     	shift trklist
 	echo "$shortLabel"
     	echo "</td>"
 
 	#get table too for yes links 
 	set table = "$trklist[1]"
     	shift trklist
 
 	#-------DB COLUMNS LOOP-----------
 
 	set sql = 'select db from gbjunk '
     	set sql = "$sql"'where grp="'"$grpname[$g]"'" '
     	set sql = "$sql"'and shortLabel="'"$shortLabel"'" '
 	set sql = "$sql"'order by db;'
     	#echo "$sql<br>"
 	set datalist = `/cluster/bin/i386/hgsql -u$user -p$pwd qapushq -B --skip-column-names -e "$sql"`
     	set err = $status
 	if ($err) then
 	    echo "error $err processing: $sql <br>"
     	    exit 0
 	endif
     	#echo "$datalist<br>"
 
 	foreach db ( $dblist )
 	    echo "<td>"
 	    #echo "$db"
 	    set found = "0"
 	    foreach dl ( $datalist )
 		if ("$dl" == "$db") then
 		    set found = "1"
 		endif
 	    end
 	    if ( "$found" == "1" ) then
 	        set link = '<a href="http://'"$srvr"'/cgi-bin/hgTrackUi'
 		set link = "$link"'?db='"$db"'&g='"$table"'&c=chr1&position=chr1:1-10000'
 		set link = "$link"'" target=_blank>yes</a>'
 		echo "$link"
 	    else
 		echo "no"
 	    endif
     	    echo "</td>"
 	end
 
 	#---------------------------------
     
 	echo "</tr>"
 	
     end
     
     echo "</table>"
     
 # ----------------------------------
 
     
     @ g = $g + 1
 end
 echo "<br>"
 echo "<br>"
 
 
 set sql = 'drop table gbjunk;'
 #echo "$sql<br>"
 /cluster/bin/i386/hgsql -u$user -p$pwd qapushq -B --skip-column-names -e "$sql"
 set err = $status
 if ($err) then
     echo "error $err processing: $sql <br>"
     exit 0
 endif
 #echo "got past table cleanup.<br>"
 
 #echo "The End.<br>"
 #echo "<br>"
 
 
 # ==== END MAIN LOOP ===========
 
 echo
 echo "</BODY>"
 echo "</HTML>"

