e6f95e0b21cd672cfc1d0d30979cb24c5b0220db rhead Mon Apr 9 19:23:34 2012 -0700 Changed some exits to exit with an error status and added an onintr to keep tables from being left behind when the command is interrupted. diff --git src/utils/qa/countPerChrom.csh src/utils/qa/countPerChrom.csh index f6f0cb8..2491d84 100755 --- src/utils/qa/countPerChrom.csh +++ src/utils/qa/countPerChrom.csh @@ -1,27 +1,28 @@ #!/bin/tcsh source `which qaConfig.csh` ############################################### # # 12-13-05 # Robert Kuhn # # check to see if there are genes on all chroms. # ############################################### +onintr cleanup if ( "$HOST" != "hgwdev" ) then echo "\n error: you must run this script on dev!\n" exit 1 endif set db="" set oldDb="" set table="" set host2="" set chrom="" set chroms="" set old="" set new="" set machineOut="" @@ -39,31 +40,31 @@ set debug=false if ( $#argv < 2 || $#argv > 5 ) then # no command line args echo echo " check to see if there are annotations on all chroms." echo " will check to see if chrom field is named tName or genoName." echo echo " usage: database1 table [database2] [RR] [histogram]" echo echo " checks database1 on dev" echo " database2 will be checked on beta by default" echo " if RR is specified, will use genome-mysql" echo " histogram option prints bar graph, not values" echo - exit + exit 1 else set db=$argv[1] set table=$argv[2] endif if ( $#argv == 3 || $#argv == 4 ) then if ( $argv[3] == "histogram" ) then set histo="true" else if ( $argv[3] == "RR" || $argv[3] == "rr" ) then set host2="mysql -h genome-mysql -u genome -A" set oldDb=$db set machineOut="(${argv[3]})" else set host2="hgsql -h $sqlbeta" @@ -107,31 +108,31 @@ endif endif if ( $debug == true) then echo "db = $db" echo "oldDb = $oldDb" echo "machineOut = $machineOut" echo "table = $table" echo "host2 = $host2" endif set chroms=`hgsql -N -e "SELECT chrom FROM chromInfo" $db` set split=`getSplit.csh $db $table` if ( $status ) then echo "\n the database or table may not exist\n" - exit + exit 1 endif if ( $split == "unsplit" ) then set split="" else set split=${split}_ echo "\n split tables. e.g., $split$table" endif set chrom=`getChromFieldName.csh $db $split$table` if ( $status ) then echo " error getting chromFieldName." echo " chrom, genoName or tName required." echo exit 1 @@ -207,25 +208,26 @@ # print some stats if ($max > $histosize) then set eachX=`echo $max1 $histosize | awk '{printf("%d", $1/$2)}'` else set eachX=1 endif echo "max = $max1 | each x = $eachX" echo else # print text, not histogram # output header echo "chrom \t$db \t$oldDb$machineOut" cat Xout$$ endif +cleanup: if ( $debug == false ) then rm -f Xgraph1$$ rm -f Xgraph2$$ rm -f Xgraph1b$$ rm -f Xgraph2b$$ rm -f XgraphFile0$$ rm -f XgraphFile1$$ rm -f XgraphFile2$$ rm -f Xout$$ endif