This describes the scripts and so forth Jim uses to analyse
the blastz alignments.  
	Let $B represent the blastz directory
	Let $D represent the database (hg12)
	Let $O represent the assembly directory (....build30)

o  Make chrom.sizes and chrom.list files 
     ssh hgwdev
     cd $O
     mysql -u hguser -phguserstuff -A -N $D > chrom.sizes <<end
     select chrom,size from chromInfo;
     end
     awk '{print $1;}' chrom.sizes > chrom.list
    
o  Generate the chromosome level axtFiles in $B/axtChrom and
   axtBest files in $B/axtBest following the procedure in 
   src/hg/makeDb/*.doc.

o  Generate bed files for alignments
   cd $B 
   mkdir bedAll
   cd axtChrom
   gunzip -c chr*.axt.gz | axtToBed stdin ../bedAll/all.bed
   cd ..
   mkdir bedBest
   cd axtBest
   cat *.axt | axtToBed stdin ../bedBest/best.bed

o  Generate bed files for various gene related features
   ssh hgwdev
   cd $B
   mkdir refParts
   cd refParts
   featureBits $D refGene:cds -bed=cds.bed
   featureBits $D refGene:utr3 -bed=utr3.bed
   featureBits $D refGene:utr5 -bed=utr5.bed
   featureBits $D refGene:intron -bed=intron.bed
   featureBits $D refGene:upstream:200 -bed=up200.bed
   featureBits $D refGene:end:200 -bed=down200.bed

o  Get the latest knownReg.bed from Laura Elnitski at Penn State
   and put it in $B/refParts

o  Generate bed files for ancient repeats.
    ssh hgwdev
    cd $B/refParts
    foreach i (`cat $O/chrom.list`)
       set t = ${i}_arTmp
       mysql -u hguser -phguserstuff -A -N $D -e "select genoName,genoStart,genoEnd,repName from $t" >> ancientRepeats.bed
       echo $t
    end

o  Generate bed files for genome (excluding gaps)
    ssh hgwdev
    cd $B/refParts
    foreach i (`cat $O/chrom.list`)
       set t = ${i}_gold
       mysql -u hguser -phguserstuff -A -N $D -e "select chrom,chromStart,chromEnd from $t" >> genome.bed
       echo $t
    end

o  Generate axt files for various features
   ssh kkstore
   cd $B/refParts
   foreach i (*.bed)
       cat ../axtBest/*.axt | axtAndBed stdin $i $i:r.axt
   end

o  Generate substitution matrices and indel size distributions
   foreach i (*.axt)
       axtCalcMatrix $i > $i:r.mat
   end
   axtCalcMatrix ../axtBest/*.axt > genome.mat

o  Generate coverage files.
   ssh hgwdev
   cd $B/refParts
   foreach i (*.bed)
       bedCoverage $D ../bedAll/all.bed -restrict=$i > $i:r.depth
       echo done $i:r.depth
   end
   bedCoverage $D ../bedAll/all.bed > genome.depth

o  Generate GC composition files
   ssh kkstore
   cd $B/refParts
   foreach i (*.bed)
       gcForBed $i $O/nib > $i:r.gc
       echo done $i:r.gc
   end

o  Figure out how much of human 20 is syntenic to mouse 2.
   cd $B/refParts
     axtQueryCount ../axtBest/chr20.axt > chr20.qc
     grep -v chr2 chr20.qc | addCols stdin
     addCols chr20.qc
   take the ratio of the bases covered in by the grep
   line (the second column) with bases covered by the
   next line (also second column).

o  Make data to use for 'generic gene' graph:
     ssh kkstore
     cd $B/refParts
     ggcPic ../axtBest $O/chrom.sizes $O/bed/refSeq/refGene.tab ggc -geneParts=ggc.parts -generic
