0dd85c97e0eef63c3e7f4145fe8ad7dbfacfdffb
kuhn
  Tue Feb 15 12:26:44 2011 -0800
added comments.  added extra debug around rm files.  changed a hard number to a variable.  thanks, brooke
diff --git src/utils/qa/countPerChrom.csh src/utils/qa/countPerChrom.csh
index 6d30de6..a881f2b 100755
--- src/utils/qa/countPerChrom.csh
+++ src/utils/qa/countPerChrom.csh
@@ -159,68 +159,73 @@
   endif 
   # output
   echo "$c\t$new\t$old" >> Xout$$
   set table=$argv[2]
 end
 
 if ( $histo == "true" ) then
   cat Xout$$ | grep chr | egrep -v "random|hap|Un|$db" | sed "s/chr//" \
     | sort -n -k1,1  > XgraphFile0$$
   set max1=`cat XgraphFile0$$ | awk '{print $2}' | sort -n | tail -1`
   set max=$max1
   if ( $machineOut != "" ) then
     # get max values for 2nd dataset for scaling purposes
     set max2=`cat XgraphFile0$$ | awk '{print $3}' | sort -n | tail -1`
     if ( $max1 > $max2 ) then
+      # shrink second histogram proportionately
       set histosize2=`echo $max1 $max2 $histosize | awk '{printf("%2d", $2/$1*$3)}'`
       set max=$max1
     else
+      # shrink first histogram proportionately
       set histosize1=`echo $max1 $max2 $histosize | awk '{printf("%2d", $1/$2*$3)}'`
       set max=$max2
     endif
 
     if ( $debug == true) then
       echo max1 max2 eachX $max1 $max2 $eachX
       echo histosize.histosize1.histosize2 $histosize.$histosize1.$histosize2
     endif
 
+    # make two-col files for graph.csh
     cat XgraphFile0$$ | awk '{print $1, $2}' > XgraphFile1$$ 
     cat XgraphFile0$$ | awk '{print $1, $3}' > XgraphFile2$$ 
     graph.csh XgraphFile1$$ $histosize1 > Xgraph1$$
     graph.csh XgraphFile2$$ $histosize2 > Xgraph2$$
     # put a . into files where the value is blank, to keep join from collapsing
     cat Xgraph1$$ | egrep "." | awk '{ if ($2 == "") { $2 = "."; } print $1, $2; }' > Xgraph1b$$
     cat Xgraph2$$ | egrep "." | awk '{ if ($2 == "") { $2 = "."; } print $1, $2; }' > Xgraph2b$$
     # output header
     echo
     echo "chr \t$db \t$oldDb$machineOut" | awk '{printf("%3s %'$histosize1's %-'$histosize2's\n", $1, $2, $3)}'
     echo
-    # join on first col, retaining everything from first col
+    # join on first col, retaining everything from first col.  print both graphs side by side.
     join -a1 -j1 Xgraph1b$$ Xgraph2b$$ | awk '{printf("%3s %'$histosize1's %-'$histosize2's\n", $1, $2, $3)}'
   else
-    graph.csh XgraphFile0$$ | awk '{printf("%3s %-36s\n", $1, $2)}'
+    # only one data set. graph it.
+    graph.csh XgraphFile0$$ | awk '{printf("%3s %-'$histosize's\n", $1, $2)}'
   endif
 
   # print some stats
   if ($max > $histosize) then
-    set eachX=`echo $max1 $histosize | awk '{printf("%2d", $1/$2)}'`
+    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
 
+if ( $debug == true) 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