# for emacs: -*- mode: sh; -*-

# This file describes browser build for the hbv1

#########################################################################
# viron diagram found on WikiMedia Commons
#    (DONE - 2017-06-02 - Hiram)

mkdir -p /hive/data/genomes/hbv1/photo
cd /hive/data/genomes/hbv1/photo

wget -O wikiMediaCommons.hbv.png \
  https://upload.wikimedia.org/wikipedia/commons/7/78/HBV.png

convert -quality 80 -geometry 350x350 wikiMediaCommons.hbv.png hbv1.jpg

cd /hive/data/genomes/hbv1
printf 'photoCreditURL\thttps://commons.wikimedia.org/wiki/File:HBV.png
photoCreditName\tWikiMedia Commons: Dr. Graham Beards
' > photoReference.txt

cat photoReference.txt

photoCreditURL  https://commons.wikimedia.org/wiki/File:HBV.png
photoCreditName WikiMedia Commons: Dr. Graham Beards

# Checking in that photograph to the source tree, will need to fixup the
#	description.html page to correctly reference this photo since
#       our scripts use the scientific name to find the photo

#########################################################################
#  Initial steps (DONE - 2017-06-02 - Hiram)

# This initialBuild.txt document was started from hpv1
#  version of initialBuild.txt

sed -e 's/pv1/bv1/g; s/DONE/TBD/g;' ../hpv1/initialBuild.txt  > initialBuild.txt

mkdir /hive/data/genomes/hbv1/refseq
cd /hive/data/genomes/hbv1/refseq

viral/Hepatitis_B_virus/all_assembly_versions/GCF_000861825.2_ViralProj15428
export accession="GCF_000861825.2"
export asmId="ViralProj15428"
export level0="GCF"
export level1="000"
export level2="861"
export level3="825"

time rsync -L -a -P rsync://ftp.ncbi.nlm.nih.gov/genomes/all/$level0/$level1/$level2/$level3/${accession}_${asmId}/ ./

# sent 298 bytes  received 48050 bytes  32232.00 bytes/sec
# total size is 46296  speedup is 0.96

# real    0m1.422s

# check assembly size for later reference:

faSize G*428_genomic.fna.gz

# 3182 bases (0 N's 3182 real 3182 upper 0 lower) in 1 sequences in 1 files

# this information is from the top of
#    hbv1/refseq/GCF_000861825.2_ViralProj15428_assembly_report.txt

# Assembly name:  ViralProj15428
# Organism name:  Hepatitis B virus (viruses)
# Taxid:          10407
# BioProject:     PRJNA15428
# Submitter:      NCBI Genome Project
# Date:           1993-4-21
# Assembly type:  n/a
# Release type:   major
# Assembly level: Complete Genome
# Genome representation: full
# RefSeq assembly accession: GCF_000861825.2
#
## Assembly-Units:
## GenBank Unit Accession       RefSeq Unit Accession   Assembly-Unit name
##      GCF_000861815.2 Primary assembly

#############################################################################
# establish config.ra file (DONE - Hiram - 2017-06-02)
    # arguments here are: <db> <clade> <trackDbDir> <assembly_report.txt>
    cd /hive/data/genomes/hbv1
    $HOME/kent/src/hg/utils/automation/prepConfig.pl hbv1 virus \
        HBV ./refseq/*_assembly_report.txt > hbv1.config.ra
# going to need a mitoAcc ?

    # unfortunately, there is no bioSample, set to n/a
    # will need to fixup resulting description.html
    # set: mitoAcc none
    # set: commonName HBV
    # set: orderKey 8100  (common name alphabetic)

    # to see order keys to verify this one is correct:
# hgsql -e 'select name,organism,orderKey from dbDb order by orderKey;' \
#	hgcentraltest | less

    # verify it looks sane
    cat hbv1.config.ra
# config parameters for makeGenomeDb.pl:
db hbv1
clade virus
genomeCladePriority 2000
scientificName Hepatitis B virus
commonName HBV
assemblyDate Apr. 1993
assemblyLabel NCBI Genome Project
assemblyShortLabel ViralProj15428
orderKey 8100
mitoAcc none
fastaFiles /hive/data/genomes/hbv1/ucsc/*.fa.gz
agpFiles /hive/data/genomes/hbv1/ucsc/*.agp
# qualFiles none
dbDbSpeciesDir HBV
photoCreditURL  https://commons.wikimedia.org/wiki/File:HBV.png
photoCreditName WikiMedia Commons: Dr. Graham Beards
ncbiGenomeId 5536
ncbiAssemblyId 559321
ncbiAssemblyName ViralProj15428
ncbiBioProject 15428
ncbiBioSample n/a
genBankAccessionID GCF_000861825.2
taxId 10407

#############################################################################
# setup UCSC named files (DONE - 2017-06-02 - Hiram)

    mkdir /hive/data/genomes/hbv1/ucsc
    cd /hive/data/genomes/hbv1/ucsc

    # one simple sequence:
    zcat ../refseq/GCF_000861825.2_ViralProj15428_genomic.fna.gz \
      | sed -e 's/^>NC_003977.2.*/>NC_003977v2/;' | gzip > chr.fa.gz

    printf "NC_003977v2\t1\t3182\t1\tF\tNC_003977.2\t1\t3182\t+\n" > chr.agp

    # verify OK:
    checkAgpAndFa chr.agp chr.fa.gz
# Valid Fasta file entry
# All AGP and FASTA entries agree - both files are valid

#############################################################################
#  Initial database build (TBD - 2017-05-10 - Hiram)

    cd /hive/data/genomes/hbv1
    # verify sequence and AGP are OK:
    time (makeGenomeDb.pl -workhorse=hgwdev -dbHost=hgwdev -fileServer=hgwdev \
         -stop=agp hbv1.config.ra) > agp.log 2>&1
    # real    0m8.535s

    # then finish it off: (will break down in trackDb step due to
    #   photograph name.  Attempt to avoid this
    #   in /usr/local/apache/htdocs/images
    #       ln -s hbv1.jpg Hepatitis_B_virus.jpg

    time (makeGenomeDb.pl -workhorse=hgwdev -dbHost=hgwdev \
       -fileServer=hgwdev -continue=db hbv1.config.ra) > db.log 2>&1
    # real    0m10.027s

    time (makeGenomeDb.pl -workhorse=hgwdev -dbHost=hgwdev \
       -continue=trackDb -fileServer=hgwdev hbv1.config.ra) > trackDb.log 2>&1
    # real    0m6.801s

    # remove the temporary symlink, edit the description.html page
    # fixup photo URL to hbv1.jpg and the BioSample n/a
    # check in the trackDb files created in TemporaryTrackDbCheckout/
    #    and add hbv1 to trackDb/makefile

    # temporary symlink until masked sequence is available
    cd /hive/data/genomes/hbv1
    ln -s `pwd`/hbv1.unmasked.2bit /gbdb/hbv1/hbv1.2bit

##############################################################################
# cpgIslands on UNMASKED sequence (DONE - 2017-06-02 - Hiram)
    mkdir /hive/data/genomes/hbv1/bed/cpgIslandsUnmasked
    cd /hive/data/genomes/hbv1/bed/cpgIslandsUnmasked

    time (doCpgIslands.pl -dbHost=hgwdev -bigClusterHub=ku -buildDir=`pwd` \
       -tableName=cpgIslandExtUnmasked \
          -maskedSeq=/hive/data/genomes/hbv1/hbv1.unmasked.2bit \
             -workhorse=hgwdev -smallClusterHub=ku hbv1) > do.log 2>&1
    # real    1m6.607s

    cat fb.hbv1.cpgIslandExtUnmasked.txt
    # 396 bases of 3182 (12.445%) in intersection

#############################################################################
# cytoBandIdeo - (TBD - 2017-05-10 - Hiram)
    mkdir /hive/data/genomes/hbv1/bed/cytoBand
    cd /hive/data/genomes/hbv1/bed/cytoBand
    makeCytoBandIdeo.csh hbv1

#########################################################################
# ucscToINSDC and ucscToRefSeq table/track (DONE - 2017-06-02 - Hiram)

    # really simple situation here, only one name to deal with

    mkdir /hive/data/genomes/hbv1/bed/ucscToINSDC
    cd /hive/data/genomes/hbv1/bed/ucscToINSDC

    # lookup the INSDC name at:
    #	https://www.ncbi.nlm.nih.gov/genome/5536

    printf "NC_003977v2\t0\t3182\tNC_003977.2\n" > ucscToRefSeq.bed
    printf "NC_003977v2\t0\t3182\tV01460.1\n" > ucscToINSDC.bed

    export chrSize=`cut -f1 ucscToINSDC.bed | awk '{print length($0)}' | sort -n | tail -1`
    echo $chrSize
    # 11
    # use the chrSize in this sed
    sed -e "s/21/$chrSize/" $HOME/kent/src/hg/lib/ucscToINSDC.sql \
         | hgLoadSqlTab hbv1 ucscToINSDC stdin ucscToINSDC.bed
    # should be the same for ucscToRefSeq:
    export chrSize=`cut -f1 ucscToRefSeq.bed | awk '{print length($0)}' | sort -n | tail -1`
    echo $chrSize
    #  11
    sed -e "s/21/$chrSize/" $HOME/kent/src/hg/lib/ucscToINSDC.sql \
       | sed -e 's/INSDC/RefSeq/g;' > ucscToRefSeq.sql
    hgLoadSqlTab hbv1 ucscToRefSeq ./ucscToRefSeq.sql ucscToRefSeq.bed

    # checkTableCoords should be silent
    checkTableCoords hbv1
    # each should cover %100 entirely:
    featureBits -countGaps hbv1 ucscToINSDC
    # 3182 bases of 3182 (100.000%) in intersection

    featureBits -countGaps hbv1 ucscToRefSeq
    # 3182 bases of 3182 (100.000%) in intersection


#########################################################################
# add chromAlias table (DONE - 2017-06-02 - Hiram)

    mkdir /hive/data/genomes/hbv1/bed/chromAlias
    cd /hive/data/genomes/hbv1/bed/chromAlias

    hgsql -N -e 'select chrom,name,"refseq" from ucscToRefSeq;' hbv1 \
        > ucsc.refseq.tab
    hgsql -N -e 'select chrom,name,"genbank" from ucscToINSDC;' hbv1 \
        > ucsc.genbank.tab

    awk '{printf "%s\t%s\t%s\n", $2,$1,$3}' ucsc.genbank.tab ucsc.refseq.tab \
        | sort > hbv1.chromAlias.tab

    cat  hbv1.chromAlias.tab
# NC_003977.2     NC_003977v2     refseq
# V01460.1        NC_003977v2     genbank

    hgLoadSqlTab hbv1 chromAlias ~/kent/src/hg/lib/chromAlias.sql \
        hbv1.chromAlias.tab

#########################################################################
# fixup search rule for assembly track/gold table (DONE - 2017-06-02 - Hiram)
    cd ~/kent/src/hg/makeDb/trackDb/HBV/hbv1

    # preview prefixes and suffixes:
    hgsql -N -e "select frag from gold;" hbv1 \
      | sed -e 's/[0-9][0-9]*//;' | sort | uniq -c
#       1 NC_.2

    # implies a rule: 'NC_[0-9]+(\.[0-9]+)?'

    # verify this rule will find them all and eliminate them all:
    hgsql -N -e "select frag from gold;" hbv1 | wc -l
    # 1

    hgsql -N -e "select frag from gold;" hbv1 \
       | egrep -e 'NC_[0-9]+(\.[0-9]+)?' | wc -l
    # 1

    hgsql -N -e "select frag from gold;" hbv1 \
       | egrep -v -e 'NC_[0-9]+(\.[0-9]+)?' | wc -l
    # 0

    # hence, add to trackDb/chicken/hbv1/trackDb.ra
searchTable gold
shortCircuit 1
termRegex NC_[0-9]+(\.[0-9]+)?
query select chrom,chromStart,chromEnd,frag from %s where frag like '%s%%'
searchPriority 8

    # verify searches work in the position box

##########################################################################
# running repeat masker (DONE - 2017-06-02 - Hiram)
    # RepeatMasker doesn't know about this virus sequence name as is,
    # scientificName 
    # and there is nothing related in the taxonomy.dat table in RM.
    # However, there is a generic 'viruses' name, taxId 10239

    mkdir /hive/data/genomes/hbv1/bed/repeatMasker
    cd /hive/data/genomes/hbv1/bed/repeatMasker
    time  (doRepeatMasker.pl -buildDir=`pwd` \
        -species "viruses" -bigClusterHub=ku -dbHost=hgwdev -workhorse=hgwdev \
        -smallClusterHub=ku hbv1) > do.log 2>&1 &
    # real    1m49.755s

    # there were no repeats identified

    # and it fails with an empty nestedRepeats file during load
    # help the doLoad step finish:
    ln -s `pwd`/hbv1.rmsk.2bit /hive/data/genomes/hbv1/hbv1.rmsk.2bit

    # continue with cleanUp:
    time  (doRepeatMasker.pl -buildDir=`pwd` \
        -species "viruses" -bigClusterHub=ku -dbHost=hgwdev -workhorse=hgwdev \
        -continue=cleanup -smallClusterHub=ku hbv1) > cleanup.log 2>&1 &
    # real    0m4.284s

    egrep -i "versi|relea" do.log
    # RepeatMasker version open-4.0.5
    #    January 31 2015 (open-4-0-5) version of RepeatMasker
    # CC   RELEASE 20140131;                                            *

##########################################################################
# running simple repeat (DONE - 2017-06-12 - Hiram)

    mkdir /hive/data/genomes/hbv1/bed/simpleRepeat
    cd /hive/data/genomes/hbv1/bed/simpleRepeat
    # using trf409 1 here (human == 6)
    time (doSimpleRepeat.pl -buildDir=`pwd` -bigClusterHub=ku \
        -dbHost=hgwdev -workhorse=hgwdev -smallClusterHub=ku \
        -trf409 1 hbv1) > do.log 2>&1 &
    # XXX - there are no simple repeats, empty result
    # real    0m12.596s

#########################################################################
# CREATE MICROSAT TRACK (TBD - 2017-04-11 - Hiram)
    # XXX - there are no simple repeats
    ssh hgwdev
    mkdir /cluster/data/hbv1/bed/microsat
    cd /cluster/data/hbv1/bed/microsat

    awk '($5==2 || $5==3) && $6 >= 15 && $8 == 100 && $9 == 0 {printf("%s\t%s\t%s\t%dx%s\n", $1, $2, $3, $6, $16);}' \
       ../simpleRepeat/simpleRepeat.bed > microsat.bed

    hgLoadBed hbv1 microsat microsat.bed
    # Read 213828 elements of size 4 from microsat.bed

##########################################################################
## WINDOWMASKER (DONE - 2017-06-02 - Hiram)

    mkdir /hive/data/genomes/hbv1/bed/windowMasker
    cd /hive/data/genomes/hbv1/bed/windowMasker
    time (doWindowMasker.pl -buildDir=`pwd` -workhorse=hgwdev \
        -dbHost=hgwdev hbv1) > do.log 2>&1
    # real    0m23.043s

    # there are no repeats identified, failed on the empty files

    # need to cleanup anyway:
    time (doWindowMasker.pl -buildDir=`pwd` -workhorse=hgwdev \
        -continue=cleanup -dbHost=hgwdev hbv1) > cleanup.log 2>&1

##########################################################################
# masking 2bit file (DONE - 2017-06-02 - Hiram)
    cd /hive/data/genomes/hbv1

    # there are no repeats to mask, simply use the unmasked sequence:
    cp -p hbv1.unmasked.2bit hbv1.2bit

    # reset the symlink
    rm /gbdb/hbv1/hbv1.2bit
    ln -s `pwd`/hbv1.2bit /gbdb/hbv1/hbv1.2bit

##########################################################################
# run up idKeys files for ncbiRefSeq (DONE - 2017-06-02 - Hiram)
    mkdir /hive/data/genomes/hbv1/bed/idKeys
    cd /hive/data/genomes/hbv1/bed/idKeys

    time (doIdKeys.pl -buildDir=`pwd`  hbv1) > do.log 2>&1 &
    # real    0m16.968s

    cat hbv1.keySignature.txt
    #   7106cf68a1a0bc7c463a30d0ef3b156d

##########################################################################
# cpgIslands - (DONE - 2017-06-02 - Hiram)
    mkdir /hive/data/genomes/hbv1/bed/cpgIslands
    cd /hive/data/genomes/hbv1/bed/cpgIslands
    time (doCpgIslands.pl -dbHost=hgwdev -bigClusterHub=ku \
      -workhorse=hgwdev -smallClusterHub=ku hbv1) > do.log 2>&1 &
    # real    1m6.348s

    cat fb.hbv1.cpgIslandExt.txt
    # 396 bases of 3182 (12.445%) in intersection

##############################################################################
# genscan - (DONE - 2017-06-02 - Hiram)
    mkdir /hive/data/genomes/hbv1/bed/genscan
    cd /hive/data/genomes/hbv1/bed/genscan
    time (doGenscan.pl -buildDir=`pwd` -workhorse=hgwdev -dbHost=hgwdev \
      -bigClusterHub=ku hbv1) > do.log 2>&1 &
    # real    1m52.046s

    cat fb.hbv1.genscan.txt
    # 1110 bases of 3182 (34.884%) in intersection

    cat fb.hbv1.genscanSubopt.txt
    # 1063 bases of 3182 (33.407%) in intersection

#############################################################################
# augustus gene track (TBD - 2017-04-13 - Hiram)
    # XXX augustus can not do virus sequence

    mkdir /hive/data/genomes/hbv1/bed/augustus
    cd /hive/data/genomes/hbv1/bed/augustus
    time (doAugustus.pl -buildDir=`pwd` -bigClusterHub=ku \
    -species=human -dbHost=hgwdev -workhorse=hgwdev hbv1) > do.log 2>&1 &
    # real    72m23.671s

    cat fb.hbv1.augustusGene.txt
    # 29811614 bases of 2318132242 (1.286%) in intersection

##############################################################################
# Create kluster run files (TBD - 2017-04-13 - Hiram)

    # numerator is hbv1 gapless bases "real" as reported by:
    featureBits -noRandom -noHap hbv1 gap
    # 0 bases of 3182 (0.000%) in intersection
    #            ^^^

    # denominator is hg19 gapless bases as reported by:
    #   featureBits -noRandom -noHap hg19 gap
    #     234344806 bases of 2861349177 (8.190%) in intersection
    # 1024 is threshold used for human -repMatch:
    calc \( 3182 / 2861349177 \) \* 1024
    #  ( 3182 / 2861349177 ) * 1024 = 0.001139

    # repMatch=1 produces 578 overused 11-mers
    $ repMatch=2 produces 0 overused 11-mers
    # ==> use -repMatch=2, do not need to mask anything
    cd /hive/data/genomes/hbv1
    blat hbv1.2bit \
         /dev/null /dev/null -tileSize=11 -makeOoc=jkStuff/hbv1.11.ooc \
        -repMatch=2
    #   Wrote 0 overused 11-mers to jkStuff/hbv1.11.ooc

    #   check non-bridged gaps to see what the typical size is:
    # there are no non-bridged gaps in this assembly:
    hgsql -N -e 'select bridge from gap;' hbv1 | sort | uniq -c
    #	no output, nothing to see here

#########################################################################
# GENBANK AUTO UPDATE (TBD - 2017-04-13 - Hiram)
    ssh hgwdev
    cd $HOME/kent/src/hg/makeDb/genbank
    git pull
    # /cluster/data/genbank/data/organism.lst shows:
    # organism             mrnaCnt   estCnt  refSeqCnt
    # Hepatitis B virus	     5671	1	0
    # Hepatitis B virus subtype adw	1	0	0

    # edit etc/genbank.conf to add hbv1 at the end

# hbv1 (Hepatitis B virus - Taxid: 10407)
hbv1.serverGenome = /hive/data/genomes/hbv1/hbv1.2bit
hbv1.clusterGenome = /hive/data/genomes/hbv1/hbv1.2bit
hbv1.ooc = /hive/data/genomes/hbv1/jkStuff/hbv1.11.ooc
hbv1.lift = no
hbv1.downloadDir = hbv1
hbv1.perChromTables = no
hbv1.refseq.mrna.native.pslCDnaFilter  = ${finished.refseq.mrna.native.pslCDnaFilter}
hbv1.refseq.mrna.xeno.pslCDnaFilter    = ${finished.refseq.mrna.xeno.pslCDnaFilter}
hbv1.genbank.mrna.native.pslCDnaFilter = ${finished.genbank.mrna.native.pslCDnaFilter}
hbv1.genbank.mrna.xeno.pslCDnaFilter   = ${finished.genbank.mrna.xeno.pslCDnaFilter}
hbv1.genbank.est.native.pslCDnaFilter  = ${finished.genbank.est.native.pslCDnaFilter}
# DO NOT NEED genbank.mrna.xeno except for human, mouse
# defaults yes: genbank.mrna.native.load, genbank.mrna.native.loadDesc,
# genbank.est.native.load, refseq.mrna.native.load, refseq.mrna.native.loadDesc,
# refseq.mrna.xeno.load , refseq.mrna.xeno.loadDesc
# hbv1.upstreamGeneTbl = ensGene
# hbv1.upstreamMaf = multiz9way /hive/data/genomes/hpv1/bed/multiz9way/species.list

    git commit -m 'adding hbv1 Hepatitis B virus - refs #19533' etc/genbank.conf src/lib/gbGenome.c
    git push

    make etc-update
    make install-server

    cd /cluster/data/genbank

    time ./bin/gbAlignStep -initial hbv1
    # logFile: var/build/logs/2017.06.03-09:54:08.hbv1.initalign.log
    #  real    406m38.235s

 tail -2 var/build/logs/2017.06.03-09:54:08.hbv1.initalign.log
hgwdev 2017.06.03-16:38:15 hbv1.initalign: Succeeded: hbv1
hgwdev 2017.06.03-16:40:47 hbv1.initalign: finish

    # logFile: var/build/logs/2017.06.02-11:29:04.hbv1.initalign.log
    #   real    248m27.891s

    tail -2 var/build/logs/2017.06.02-11:29:04.hbv1.initalign.log
# hgwdev 2017.06.02-15:37:28 hbv1.initalign: Succeeded: hbv1
# hgwdev 2017.06.02-15:37:32 hbv1.initalign: finish

    #   To re-do, rm the dir first:
    #     /cluster/data/genbank/work/initial.hbv1

    # load database when finished
    ssh hgwdev
    cd /cluster/data/genbank
    time ./bin/gbDbLoadStep -drop -initialLoad hbv1
    # logFile: var/dbload/hgwdev/logs/2017.06.06-08:35:26.hbv1.dbload.log
    # real    136m30.161s
XXX - ready to continue - Wed Jun  7 12:41:23 PDT 2017

    # logFile: logFile: var/dbload/hgwdev/logs/2017.06.02-16:56:52.hbv1.dbload.log
    # real    16m51.160s

    tail -1  var/dbload/hgwdev/logs/2017.06.02-16:56:52.hbv1.dbload.log
    # hgwdev 2017.06.02-17:13:43 hbv1.dbload: finish

    # to completely re-run with altered genbank.conf:
    cd /cluster/data/genbank/data/aligned
    og -d */hbv1
# drwxrwsr-x 49 4096 Jun  2 15:33 genbank.219.0/hbv1
# drwxrwsr-x 25 4096 Jun  2 15:37 refseq.82/hbv1
    cd /cluster/data/genbank/data/aligned
    rm -fr */hbv1

XXX -checking with genbank master on zero results - Fri May 12 08:19:39 PDT 2017
    # enable daily alignment and update of hgwdev
    cd ~/kent/src/hg/makeDb/genbank
    git pull
    # add hbv1 to:
    #   etc/align.dbs etc/hgwdev.dbs
    git add etc/align.dbs etc/hgwdev.dbs
    git commit -m 'adding hbv1 to the update alignments refs #19228' etc/align.dbs etc/hgwdev.dbs
    git push
    make etc-update

#############################################################################
# ncbiGene (TBD - 2017-05-10 - Hiram)

    mkdir /hive/data/genomes/hbv1/bed/ncbiGene
    cd /hive/data/genomes/hbv1/bed/ncbiGene

    # switching the names from column 1 to 12 and 12 to 1 with the awk:
    gff3ToGenePred -useName -attrsOut=hbv1.attrs.tab -geneNameAttr=gene \
       ../../refseq/GCF_000862685.1_ViralProj15424_genomic.gff.gz \
           stdout | sed -e 's/NC_004104.1/NC_004104v1/;' \
             | awk -F'\t' '{print $12,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$1,$13,$14,$15}' | tr '[ ]' '[\t]' > hbv1.ncbiGene.gp
# NP_671509.1     NC_004104v1     +       5791    7309    5791    7309    1      5791,    7309,   0       L1      cmpl    cmpl    0,
# becomes:
# L1      NC_004104v1     +       5791    7309    5791    7309    1       5791,  7309,    0       NP_671509.1     cmpl    cmpl    0,

    genePredCheck -db=hbv1 hbv1.ncbiGene.gp 
    # checked: 7 failed: 0

    hgLoadGenePred -genePredExt hbv1 ncbiGene hbv1.ncbiGene.gp
    genePredCheck -db=hbv1 ncbiGene
    # checked: 7 failed: 0
XXX - more name wrangling is in order
XXX - need to get gene descriptions out of the genbank record

#########################################################################
#  BLATSERVERS ENTRY (TBD - 2017-04-19 - Hiram)
#	After getting a blat server assigned by the Blat Server Gods,
    ssh hgwdev

    hgsql -e 'INSERT INTO blatServers (db, host, port, isTrans, canPcr) \
	VALUES ("hbv1", "blat1a", "17872", "1", "0"); \
	INSERT INTO blatServers (db, host, port, isTrans, canPcr) \
	VALUES ("hbv1", "blat1a", "17873", "0", "1");' \
	    hgcentraltest
    #	test it with some sequence

############################################################################
## set default position to SRC gene sequence from human protein blat
##  (TBD - 2017-04-19 - Hiram)

    ssh hgwdev
    hgsql -e 'update dbDb set defaultPos="NW_003613641v1:1277445-1295702"
	where name="hbv1";' hgcentraltest

#########################################################################
# all.joiner update, downloads and in pushQ - (TBD - 2017-04-25 - Hiram)
    cd $HOME/kent/src/hg/makeDb/schema
    # fixup all.joiner until this is a clean output
    joinerCheck -database=hbv1 -tableCoverage all.joiner
    joinerCheck -database=hbv1 -times all.joiner
    joinerCheck -database=hbv1 -keys all.joiner

    cd /hive/data/genomes/hbv1
    time (makeDownloads.pl -workhorse=hgwdev hbv1) > downloads.log 2>&1
    #  real    22m35.669s

    #   now ready for pushQ entry
    mkdir /hive/data/genomes/hbv1/pushQ
    cd /hive/data/genomes/hbv1/pushQ
    time (makePushQSql.pl -redmineList hbv1) \
          > hbv1.pushQ.sql 2> stderr.out
    #  real    7m21.629s

    #   check for errors in stderr.out, some are OK, e.g.:
    # WARNING: hgwdev does not have /gbdb/hbv1/wib/gc5Base.wib
    # WARNING: hgwdev does not have /gbdb/hbv1/wib/quality.wib
    # WARNING: hgwdev does not have /gbdb/hbv1/bbi/quality.bw
    # WARNING: hbv1 does not have seq
    # WARNING: hbv1 does not have extFile


    # enter the path names to the redmine listings in the redmine issue
    # refs 19228

#########################################################################
