src/utils/qa/makeFilledBlockBed.csh 1.5
1.5 2009/05/21 01:28:08 rhead
Changed getChromlist.csh so that it does not create a file, just prints results. Changed all of the scripts that call it to redirect output to a unique file name, and then remove only that file at the end. Added onintr command that allow for cleanup of files created if scripts are ended prematurely.
Index: src/utils/qa/makeFilledBlockBed.csh
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/utils/qa/makeFilledBlockBed.csh,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -B -U 1000000 -r1.4 -r1.5
--- src/utils/qa/makeFilledBlockBed.csh 17 Apr 2009 16:31:59 -0000 1.4
+++ src/utils/qa/makeFilledBlockBed.csh 21 May 2009 01:28:08 -0000 1.5
@@ -1,84 +1,85 @@
#!/bin/tcsh
source `which qaConfig.csh`
####################
# 10-03-07 Bob Kuhn and Brooke Rhead
#
# make bed file of large blocks, ignoring intron/exons
#
####################
+onintr cleanup
+
set split=""
set db=""
set table=""
set chr=""
set start=""
set send=""
if ($#argv != 3 ) then
echo
echo " make bed file of large blocks, fusing introns/exons"
echo " will take split tables without the chrN_ prefix."
echo
echo " usage: database table outfile.bed"
echo
echo
exit
else
set db=$argv[1]
set table=$argv[2]
set outfile=$argv[3]
endif
# get the chrom name for this table
set split=`getSplit.csh $db $table hgwdev`
if ( $split == "unsplit" ) then
set split=""
else
set split=${split}_
endif
set chr=`getChromFieldName.csh $db ${split}$table`
# echo "chr = $chr"
# echo "split = $split"
# find the correct names for starts and ends
if ( $chr == "chrom" ) then
set start=`hgsql -Ne "DESC $split$table" $db | awk '{print $1}' \
| egrep "txStart|chromStart" | head -1 | awk '{print $1}'`
set end=`hgsql -Ne "DESC $split$table" $db | awk '{print $1}' \
| egrep "txEnd|chromEnd" | head -1 | awk '{print $1}'`
else
if ( $chr == "tName" ) then
set start="tStart"
set end="tEnd"
else
if ( $chr == "genoName" ) then
set start="genoStart"
set end="genoEnd"
endif
else
echo "\nThere is no chrom field called chrom , tName or genoName.\n"
exit 1
endif
endif
# echo $db
# echo $table
# echo $chr $start $end
# make bed file of large blocks, ignoring intron/exons
rm -f $outfile
if ( $split == "" ) then
hgsql -Ne "SELECT $chr, $start, $end FROM $table" $db > $outfile
else
- if (! -e $db.chromlist ) then
- getChromlist.csh $db > /dev/null
- endif
- foreach chrom (`cat $db.chromlist`)
+ getChromlist.csh $db > $db.chromlist$$
+ foreach chrom (`cat $db.chromlist$$`)
hgsql -Ne "SELECT $chr, $start, $end FROM ${chrom}_$table" $db >> $outfile
end
endif
-rm -f $db.chromlist
+cleanup:
+rm -f $db.chromlist$$
exit