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

# This file describes browser build for the staAur1

#########################################################################
# photo from WikiMedia Commons
#    (DONE - 2017-04-04 - Hiram)

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

wget --timestamping \
"https://upload.wikimedia.org/wikipedia/commons/d/d3/Staphylococcus_aureus_VISA_2.jpg"

convert -quality 80 -geometry 350x350 Staphylococcus_aureus_VISA_2.jpg \
	Staphylococcus_aureus.jpg

cd /hive/data/genomes/staAur1

printf 'photoCreditURL  https://phil.cdc.gov/phil/details.asp?pid=11157
photoCreditName Centers for Disease Control and Prevention's Public Health Image Library
' > photoReference.txt

cat photoReference.txt

photoCreditURL  https://phil.cdc.gov/phil/details.asp?pid=11157
photoCreditName Centers for Disease Control and Prevention's Public Health Image Library

# Checking in that photograph to the source tree

git commit -m 'Staphylococcus aureus from CDC public health image library refs #19937' Staphylococcus_aureus.jpg

#########################################################################
#  Initial steps (DONE - 2017-08-04 - Hiram)

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

sed -e 's/hbv1/staAur1/g; s/DONE/TBD/g; s/Hbv1/StaAur1/g;' \
	../hbv1/initialBuild.txt  > initialBuild.txt

mkdir /hive/data/genomes/staAur1/refseq
cd /hive/data/genomes/staAur1/refseq

GCF_000013425.1_ASM1342v1

# bacteria/Staphylococcus_aureus/all_assembly_versions/GCF_000013425.1_ASM1342v1

export accession="GCF_000013425.1"
export asmId="ASM1342v1"
export level0="GCF"
export level1="000"
export level2="013"
export level3="425"

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

# sent 298 bytes  received 5247197 bytes  1499284.29 bytes/sec
# total size is 5244835  speedup is 1.00

# real    0m2.911s

# check assembly size for later reference:

faSize GCF*v1_genomic.fna.gz

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

# this information is from the top of
#    staAur1/refseq/GCF_000013425.1_ASM1342v1_assembly_report.txt

# Assembly name:  ASM1342v1
# Organism name:  Staphylococcus aureus subsp. aureus NCTC 8325 (firmicutes)
# Infraspecific name:  strain=NCTC 8325
# Taxid:          93061
# BioSample:      SAMN02604235
# BioProject:     PRJNA237
# Submitter:      University of Oklahoma Health Sciences Center
# Date:           2006-2-13
# Assembly type:  n/a
# Release type:   major
# Assembly level: Complete Genome
# Genome representation: full
# RefSeq category: Reference Genome
# GenBank assembly accession: GCA_000013425.1
# RefSeq assembly accession: GCF_000013425.1
# RefSeq assembly and GenBank assemblies identical: yes
#
## Assembly-Units:
## GenBank Unit Accession       RefSeq Unit Accession   Assembly-Unit name
## GCA_000013435.1      GCF_000013435.1 Primary Assembly

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

    # this clade 'bacteria' does not yet exist in hgcentraltest.clade

    hgsql hgcentraltest -e 'INSERT INTO clade (name, label, priority)
        VALUES ("bacteria", "Bacteria", 1500)'

    # fixup the genomeCladePriority to 1500
    # fixup scientificName from:
    #   scientificName Staphylococcus aureus subsp. aureus NCTC 8325
    # to:
    #   scientificName Staphylococcus aureus
    # fixup commonName from commonName Firmicutes to: Staph
    # set mitoAcc none


    # to see order keys to verify this one is correct:
# hgsql -e 'select name,organism,orderKey from dbDb order by orderKey;' \
#	hgcentraltest | less
# saiBol1 Squirrel monkey 19725
# staAur1                 19765
# conCri1 Star-nosed mole 19805

    # verify it looks sane
    cat staAur1.config.ra
# config parameters for makeGenomeDb.pl:
db staAur1
clade bacteria
genomeCladePriority 1500
scientificName Staphylococcus aureus
commonName Staph
assemblyDate Feb. 2006
assemblyLabel University of Oklahoma Health Sciences Center
assemblyShortLabel ASM1342v1
orderKey 19765
mitoAcc none
fastaFiles /hive/data/genomes/staAur1/ucsc/*.fa.gz
agpFiles /hive/data/genomes/staAur1/ucsc/*.agp
# qualFiles none
dbDbSpeciesDir bacteria
photoCreditURL  https://phil.cdc.gov/phil/details.asp?pid=11157
photoCreditName Centers for Disease Control and Prevention's Public Health Image Library
ncbiGenomeId 154
ncbiAssemblyId 34528
ncbiAssemblyName ASM1342v1
ncbiBioProject 237
ncbiBioSample SAMN02604235
genBankAccessionID GCF_000013425.1
taxId 93061

#############################################################################
# setup UCSC named files (DONE - 2017-08-04 - Hiram)

    mkdir /hive/data/genomes/staAur1/ucsc
    cd /hive/data/genomes/staAur1/ucsc

    # one simple sequence:
    zcat ../refseq/GCF_000013425.1_ASM1342v1_genomic.fna.gz \
      | sed -e 's/^>NC_007795.1.*/>NC_007795v1/;' | gzip > chr.fa.gz

    printf "NC_007795v1\t1\t2821361\t1\tF\tNC_007795.1\t1\t2821361\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 (DONE - 2017-08-04 - Hiram)

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

    # then finish it off:
    time (makeGenomeDb.pl -workhorse=hgwdev -dbHost=hgwdev \
       -fileServer=hgwdev -continue=db staAur1.config.ra) > db.log 2>&1
    # real    0m19.868s

    # check in the trackDb files created in TemporaryTrackDbCheckout/
    #    and add staAur1 to trackDb/makefile

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

##############################################################################
# cpgIslands on UNMASKED sequence (DONE - 2017-08-04 - Hiram)
    mkdir /hive/data/genomes/staAur1/bed/cpgIslandsUnmasked
    cd /hive/data/genomes/staAur1/bed/cpgIslandsUnmasked

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

    cat fb.staAur1.cpgIslandExtUnmasked.txt
    # 17793 bases of 2821361 (0.631%) in intersection

#############################################################################
# cytoBandIdeo - (DONE - 2017-08-04 - Hiram)
    mkdir /hive/data/genomes/staAur1/bed/cytoBand
    cd /hive/data/genomes/staAur1/bed/cytoBand
    makeCytoBandIdeo.csh staAur1

#########################################################################
# ucscToINSDC and ucscToRefSeq table/track (DONE - 2017-08-05 - Hiram)

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

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

    # lookup the Genbank/INSDC name at:
    #	https://www.ncbi.nlm.nih.gov/assembly/GCA_000013425.1
    # In this case: NC_007795.1 == CP000253.1

    printf "NC_007795v1\t0\t2821361\tNC_007795.1\n" > ucscToRefSeq.bed
    printf "NC_007795v1\t0\t2821361\tCP000253.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 staAur1 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 staAur1 ucscToRefSeq ./ucscToRefSeq.sql ucscToRefSeq.bed

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

    featureBits -countGaps staAur1 ucscToRefSeq
    # 2821361 bases of 2821361 (100.000%) in intersection


#########################################################################
# add chromAlias table (DONE - 2017-08-05 - Hiram)

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

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

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

    cat  staAur1.chromAlias.tab | sed -e 's/^/# /;'
# CP000253.1    NC_007795v1     genbank
# NC_007795.1   NC_007795v1     refseq

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

#########################################################################
# fixup search rule for assembly track/gold table (DONE - 2017-08-05 - Hiram)
    cd ~/kent/src/hg/makeDb/trackDb/bacteria/staAur1

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

    # 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;" staAur1 | wc -l
    # 1

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

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

    # hence, add to trackDb/bacteria/staAur1/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-08-04 - Hiram)

    # RepeatMasker doesn't know about this virus sequence name as is,
    #   scientificName Staphylococcus aureus
    # found this in taxonomy.dat table in RM:
    #   'low g+c gram-positive bacteria' name, taxId 1239
    # from: /hive/data/staging/data/RepeatMasker140131/Libraries/taxonomy.dat

    mkdir /hive/data/genomes/staAur1/bed/repeatMasker
    cd /hive/data/genomes/staAur1/bed/repeatMasker
    time  (doRepeatMasker.pl -buildDir=`pwd` \
        -species "low g+c gram-positive bacteria" -bigClusterHub=ku \
	-dbHost=hgwdev -workhorse=hgwdev \
        -smallClusterHub=ku staAur1) > do.log 2>&1 &
    # real    1m49.755s

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

    # continue with cleanUp:
    time  (doRepeatMasker.pl -buildDir=`pwd` \
        -species "low g+c gram-positive bacteria" -bigClusterHub=ku \
        -dbHost=hgwdev -workhorse=hgwdev -continue=cleanup \
	-smallClusterHub=ku staAur1) > cleanup.log 2>&1 &
    # real    0m4.496s

    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;                                            *

    cat faSize.rmsk.txt
# 2821361 bases (1 N's 2821360 real 2807400 upper 13960 lower) in 1 sequences in 1 files
# %0.49 masked total, %0.49 masked real

    time featureBits -countGaps staAur1 rmsk
    # 13960 bases of 2821361 (0.495%) in intersection
    #	real    0m0.016s

##########################################################################
# running simple repeat (DONE - 2017-08-04 - Hiram)

    mkdir /hive/data/genomes/staAur1/bed/simpleRepeat
    cd /hive/data/genomes/staAur1/bed/simpleRepeat
    # using trf409 1 here (human == 6)
    time (doSimpleRepeat.pl -buildDir=`pwd` -bigClusterHub=ku \
        -dbHost=hgwdev -workhorse=hgwdev -smallClusterHub=ku \
        -trf409 1 staAur1) > do.log 2>&1 &
    # real    0m24.338s

    cat fb.simpleRepeat
    #	26152 bases of 2821361 (0.927%) in intersection

#########################################################################
# CREATE MICROSAT TRACK (DONE - 2017-08-04 - Hiram)
    # XXX - this makes an empty microsat.bed file, nothing to load
    ssh hgwdev
    mkdir /cluster/data/staAur1/bed/microsat
    cd /cluster/data/staAur1/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 staAur1 microsat microsat.bed

##########################################################################
## WINDOWMASKER (DONE - 2017-08-04 - Hiram)

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

    cat faSize.staAur1.cleanWMSdust.txt
# 2821361 bases (1 N's 2821360 real 2364826 upper 456534 lower) in 1 sequences in 1 files
# %16.18 masked total, %16.18 masked real

    cat fb.staAur1.rmsk.windowmaskerSdust.txt
# 8293 bases of 2821361 (0.294%) in intersection

##########################################################################
# masking 2bit file (DONE - 2017-08-04 - Hiram)
    cd /hive/data/genomes/staAur1

    twoBitMask staAur1.rmsk.2bit \
        -add bed/simpleRepeat/trfMask.bed staAur1.rmsk.trf.2bit

    twoBitMask staAur1.rmsk.trf.2bit -type=.bed \
        -add bed/windowMasker/cleanWMask.bed.gz staAur1.2bit

    twoBitToFa staAur1.2bit stdout | faSize stdin > faSize.staAur1.2bit.txt
    cat faSize.staAur1.2bit.txt
# 2821361 bases (1 N's 2821360 real 2359001 upper 462359 lower) in 1 sequences in 1 files
# %16.39 masked total, %16.39 masked real

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

##########################################################################
# run up idKeys files for ncbiRefSeq (DONE - 2017-08-04 - Hiram)
    mkdir /hive/data/genomes/staAur1/bed/idKeys
    cd /hive/data/genomes/staAur1/bed/idKeys

    time (doIdKeys.pl -buildDir=`pwd`  staAur1) > do.log 2>&1 &
    # real    0m17.167s

    cat staAur1.keySignature.txt
    #   3d70b1f5bdeec2114c63b7ce2017ea96

##########################################################################
# cpgIslands - (DONE - 2017-08-04 - Hiram)
    mkdir /hive/data/genomes/staAur1/bed/cpgIslands
    cd /hive/data/genomes/staAur1/bed/cpgIslands
    time (doCpgIslands.pl -dbHost=hgwdev -bigClusterHub=ku \
      -workhorse=hgwdev -smallClusterHub=ku staAur1) > do.log 2>&1 &
    # real    0m36.836s

    cat fb.staAur1.cpgIslandExt.txt
    # 16205 bases of 2821361 (0.574%) in intersection

##############################################################################
# genscan - (DONE - 2017-08-04 - Hiram)
    mkdir /hive/data/genomes/staAur1/bed/genscan
    cd /hive/data/genomes/staAur1/bed/genscan
    time (doGenscan.pl -buildDir=`pwd` -workhorse=hgwdev -dbHost=hgwdev \
      -bigClusterHub=ku staAur1) > do.log 2>&1 &
    # real    2m7.070s

    cat fb.staAur1.genscan.txt
    # 395771 bases of 2821361 (14.028%) in intersection

    cat fb.staAur1.genscanSubopt.txt
    # 104700 bases of 2821361 (3.711%) in intersection

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

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

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

##############################################################################
# Create kluster run files (DONE - 2017-08-04 - Hiram)

    # numerator is staAur1 gapless bases "real" as reported by:
    featureBits -noRandom -noHap staAur1 gap
    # 0 bases of 2821361 (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 \( 2821361 / 2861349177 \) \* 1024
    #  ( 2821361 / 2861349177 ) * 1024 = 1.009689

    # repMatch=1 produces 410921 overused 11-mers
    # repMatch=2 produces 73051 overused 11-mers
    # repMatch=3 produces 18919 overused 11-mers
    # repMatch=3 produces 6121 overused 11-mers
    # repMatch=5 produces 2319 overused 11-mers
    # repMatch=6 produces 923 overused 11-mers
    # repMatch=7 produces 379 overused 11-mers
    # repMatch=8 produces 168 overused 11-mers
    # repMatch=9 produces 80 overused 11-mers
    # repMatch=10 produces 43 overused 11-mers
    #    ...
    # repMatch=20 produces 0 overused 11-mers
    # ==> use -repMatch=20, do not need to mask anything
    cd /hive/data/genomes/staAur1
    blat staAur1.2bit \
         /dev/null /dev/null -tileSize=11 -makeOoc=jkStuff/staAur1.11.ooc \
        -repMatch=20
    #   Wrote 0 overused 11-mers to jkStuff/staAur1.11.ooc

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

#########################################################################
# GENBANK AUTO UPDATE (DONE - 2017-08-04 - Hiram)
    ssh hgwdev
    cd $HOME/kent/src/hg/makeDb/genbank
    git pull
    # /cluster/data/genbank/data/organism.lst shows:
    # organism             mrnaCnt   estCnt  refSeqCnt
    # Staphylococcus  2       0       0
    # Staphylococcus aureus   185     0       0
    # Staphylococcus aureus subsp. aureus NCTC 8325   32      0       0
    # Staphylococcus aureus subsp. aureus RN4220      1       0       0
    # Staphylococcus epidermidis      46      1255    0
    # Staphylococcus lentus   1       0       0
    # Staphylococcus lugdunensis      9       0       0
    # Staphylococcus phage phi-42     1       0       0
    # Staphylococcus pseudintermedius 9       0       0
    # Staphylococcus sp. B2_30        1       0       0
    # Staphylococcus sp. B2_43        1       0       0
    # Staphylococcus sp. SH24 1       0       0
    # Staphylococcus warneri  1       0       0

    # add these four to src/lib/gbGenome.c for staAurNames[]
    # Staphylococcus  2       0       0
    # Staphylococcus aureus   185     0       0
    # Staphylococcus aureus subsp. aureus NCTC 8325   32      0       0
    # Staphylococcus aureus subsp. aureus RN4220      1       0       0

    # edit etc/genbank.conf to add staAur1 just after aplCal1 and before hbv1

# staAur1 (Staphylococcus aureus -  Taxid: 93061)
staAur1.serverGenome = /hive/data/genomes/staAur1/staAur1.2bit
staAur1.clusterGenome = /hive/data/genomes/staAur1/staAur1.2bit
staAur1.ooc = /hive/data/genomes/staAur1/jkStuff/staAur1.11.ooc
staAur1.lift = no
staAur1.downloadDir = staAur1
staAur1.perChromTables = no
staAur1.refseq.mrna.native.pslCDnaFilter  = ${finished.refseq.mrna.native.pslCDnaFilter}
staAur1.refseq.mrna.xeno.pslCDnaFilter    = ${finished.refseq.mrna.xeno.pslCDnaFilter}
staAur1.genbank.mrna.native.pslCDnaFilter = ${finished.genbank.mrna.native.pslCDnaFilter}
staAur1.genbank.mrna.xeno.pslCDnaFilter   = ${finished.genbank.mrna.xeno.pslCDnaFilter}
staAur1.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
# staAur1.upstreamGeneTbl = ensGene
# staAur1.upstreamMaf = multiz9way /hive/data/genomes/staAur1/bed/multiz9way/species.list

    git commit -m 'adding staAur1 Staphylococcus aureus- refs #19937' etc/genbank.conf src/lib/gbGenome.c
    git push

    make install-server
    make etc-update

    cd /cluster/data/genbank

    time ./bin/gbAlignStep -initial staAur1
    # logFile: var/build/logs/2017.08.04-14:20:13.staAur1.initalign.log
    #  real    296m21.433s

    tail -2 var/build/logs/2017.08.04-14:20:13.staAur1.initalign.log
hgwdev 2017.08.04-19:16:28 staAur1.initalign: Succeeded: staAur1
hgwdev 2017.08.04-19:16:35 staAur1.initalign: finish

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

    # load database when finished
    ssh hgwdev
    cd /cluster/data/genbank
    time ./bin/gbDbLoadStep -drop -initialLoad staAur1
    # logFile: var/dbload/hgwdev/logs/2017.08.05-00:32:05.staAur1.dbload.log
    # real    19m45.284s

    # enable daily alignment and update of hgwdev
    cd ~/kent/src/hg/makeDb/genbank
    git pull
    # add staAur1 to:
    #   etc/align.dbs etc/hgwdev.dbs
    git commit -m 'adding staAur1 to the update alignments refs #19337' etc/align.dbs etc/hgwdev.dbs
    git push
    make etc-update

#############################################################################
# ncbiGene (DONE - 2017-08-05 - Hiram)

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

    # switching the names from column 1 to 12 and 12 to 1 with the awk:
    gff3ToGenePred -useName -attrsOut=staAur1.attrs.tab -geneNameAttr=gene \
       ../../refseq/GCF_000013425.1_ASM1342v1_genomic.gff.gz \
           stdout | sed -e 's/NC_007795.1/NC_007795v1/;' \
             | awk -F'\t' '{print $12,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$1,$13,$14,$15}' | tr '[ ]' '[\t]' > staAur1.ncbiGene.gp
# rpmH    NC_007795v1     -       2821009 2821147 2821009 2821147 1       2821009,
#         2821147,        0       YP_501500.1     cmpl    cmpl    0,
# rnpA    NC_007795v1     -       2820535 2820889 2820535 2820889 1       2820535,
#         2820889,        0       YP_501499.1     cmpl    cmpl    0,

    genePredCheck -db=staAur1 staAur1.ncbiGene.gp 2>&1 | sed -e 's/^/    # /;'
    # checked: 2844 failed: 0

    hgLoadGenePred -genePredExt staAur1 ncbiGene staAur1.ncbiGene.gp
    genePredCheck -db=staAur1 ncbiGene 2>&1 | sed -e 's/^/    # /;'
    # checked: 2844 failed: 0
XXX - need to get gene descriptions out of the genbank record

#########################################################################
#  BLATSERVERS ENTRY (DONE - 2017-08-07 - 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 ("staAur1", "blat1a", "17876", "1", "0"); \
	INSERT INTO blatServers (db, host, port, isTrans, canPcr) \
	VALUES ("staAur1", "blat1a", "17877", "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="staAur1";' 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=staAur1 -tableCoverage all.joiner
    joinerCheck -database=staAur1 -times all.joiner
    joinerCheck -database=staAur1 -keys all.joiner

    cd /hive/data/genomes/staAur1
    # needed a symlink for RM output:
    cd NC_007795v1
    ln -s ../bed/repeatMasker/staAur1.sorted.fa.out NC_007795v1.fa.out
    cd ..
    time (makeDownloads.pl -workhorse=hgwdev staAur1) > downloads.log 2>&1
    #  real    0m12.888s

    #   now ready for pushQ entry
    mkdir /hive/data/genomes/staAur1/pushQ
    cd /hive/data/genomes/staAur1/pushQ
    time (makePushQSql.pl -redmineList staAur1) \
	> staAur1.pushQ.sql 2> stderr.out
    #  real    3m37.776s


    #   check for errors in stderr.out, some are OK, e.g.:
# writing redmine listings to
# redmine.staAur1.file.list
# redmine.staAur1.table.list
# redmine.staAur1.releaseLog.txt
# WARNING: staAur1 does not have augustusGene
# WARNING: staAur1 does not have microsat
# WARNING: staAur1 does not have nestedRepeats
# WARNING: staAur1 does not have seq
# WARNING: staAur1 does not have extFile
# WARNING: staAur1 does not have estOrientInfo

# WARNING: Could not tell (from trackDb, all.joiner and hardcoded lists of
# supporting and genbank tables) which tracks to assign these tables to:
#   ncbiGene

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

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