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

 
# This file describes building the browser database for the archaeal
# species Methanosarcina acetivorans.

# DOWNLOAD SEQUENCE FROM GENBANK (DONE 01/07/04)

    ssh eieio
    mkdir /cluster/store5/archae/archFulg1
    ln -s /cluster/store5/archae/archFulg1 /cluster/data/archFulg1
    cd /cluster/data/archFulg1
    cp /projects/lowelab/db/Bacteria/Archaeoglobus_fulgidus/Arch_fulg.fa chr.fa
    # Edit header of chr.fa to '> archFulg1'

# CREATE DATABASES AND A BUNCH OF INITIAL STUFF (DONE 9/29/05)

    ssh hgwdev
    echo 'create database archFulg1' | hgsql ''
    cd /cluster/data/archFulg1
    mkdir nib
    faToNib chr.fa nib/chr.nib
    hgNibSeq archFulg1 /cluster/data/archFulg1/nib chr.fa
    faSize -detailed chr.fa > chrom.sizes
    mkdir -p /gbdb/archFulg1/nib
    echo "create table grp (PRIMARY KEY(NAME)) select * from hg16.grp" \
	    | hgsql archFulg1
    echo 'INSERT INTO dbDb \
        (name, description, nibPath, organism, \
                defaultPos, active, orderKey, genome, scientificName, \
                htmlPath, hgNearOk) values \
        ("archFulg1", "December 1997", "/gbdb/archFulg1/nib", "Archaeoglobus fulgidus", \
               "chr:500000-550000", 1, 230, "Archaeoglobus fulgidus", \
                "Archaeoglobus fulgidus DSM4304", "/gbdb/archFulg1/html/description.html", \
                0);' \
      | hgsql hgcentraltest
    echo 'INSERT INTO defaultDb (genome, name) values ("Archaeoglobus fulgidus", "archFulg1");' \
      | hgsql hgcentraltest
    echo 'INSERT INTO genomeClade (genome, clade, priority) values ("Archaeoglobus fulgidus", "archaea",230);'  \
      | hgsql hgcentraltest

    cd ~/kent/src/hg/makeDb/trackDb
    # add the trackDb directories
    mkdir -p archae/archFulg1
    cvs add archae/archFulg1
    cvs commit archae/archFulg1

# GC20BASE (DONE 9/29/05)
    ssh kkstore02
    mkdir -p /cluster/data/archFulg1/bed/gc20Base
    cd /cluster/data/archFulg1/bed/gc20Base
    hgGcPercent -wigOut -doGaps -file=stdout -win=20 archFulg1 \
        /cluster/data/archFulg1/nib | wigEncode stdin gc20Base.wig gc20Base.wib
    ssh hgwdev
    cd /cluster/data/archFulg1/bed/gc20Base
    mkdir /gbdb/archFulg1/wib
    ln -s `pwd`/gc20Base.wib /gbdb/archFulg1/wib
    hgLoadWiggle -pathPrefix=/gbdb/archFulg1/wib archFulg1 gc20Base gc20Base.wig
    #	verify index is correct:
    hgsql archFulg1 -e "show index from gc20Base;"
    #	should see good numbers in Cardinality column

# TANDEM REPEAT MASKER (DONE 9/29/05)

    ssh hgwdev
    mkdir -p /cluster/data/archFulg1/bed/simpleRepeat
    cd /cluster/data/archFulg1
    trfBig chr.fa /dev/null -bedAt=/cluster/data/archFulg1/bed/simpleRepeat/chr.bed
    cd /cluster/data/archFulg1/bed/simpleRepeat
    cat chr.bed | sed -e 's/archFulg1/chr/' > temp
    mv temp chr.bed
    hgLoadBed archFulg1 simpleRepeat *.bed -sqlTable=/cluster/home/kpollard/kent/src/hg/lib/simpleRepeat.sql


# TIGR GENES (DONE 9/29/05)
    # First go to http://www.tigr.org/tigr-scripts/CMR2/gene_attribute_form.dbi
    # and fill out the web form as follows:
    #   - Pick "Retrieve attributes for the specified DNA feature within a specific 
    #     organism and/or a specific role category".
    #       * Pick genome, and "Primary and TIGR annotation ORFs" 
    #         from the 1st and 3rd box.
    #       * Select everything from "Choose TIGR Annotation Gene Attributes"
    #       * Select "Primary Locus Name" from "Choose Primary Annotation Gene Attributes"
    #       * Select everything from "Choose Other Gene Attributes"
    #   - Click submit, and click save as tab-delimited file.
    ssh hgwdev
    mkdir /cluster/data/archFulg1/bed/tigrCmrORFs
    cp archFulg1-tigr.tab /cluster/data/archFulg1/bed/tigrCmrORFs
    cd /cluster/data/archFulg1/bed/tigrCmrORFs
    /projects/lowelab/users/aamp/bin/i386/tigrCmrToBed archFulg1-tigr.tab archFulg1-tigr.bed
    cat archFulg1-tigr.bed | sed -e 's/chr1/chr/' > temp
    mv temp archFulg1-tigr.bed
    hgLoadBed -tab archFulg1 tigrCmrGene archFulg1-tigr.bed -sqlTable=/cluster/home/kpollard/kent/src/hg/lib/tigrCmrGene.sql
    echo "rename table tigrCmrGene to tigrCmrORFs;" | hgsql archFulg1

# DESCRIPTION PAGE (DONE 9/30/05)

    ssh hgwdev
    # Write ~/kent/src/hg/makeDb/trackDb/archae/archFulg1/description.html
    chmod a+r ~/kent/src/hg/makeDb/trackDb/archae/archFulg1/description.html
    # Check it in.
    mkdir -p /cluster/data/archFulg1/html/
    cp ~/kent/src/hg/makeDb/trackDb/archae/archFulg1/description.html /cluster/data/archFulg1/html/description.html
    mkdir /gbdb/archFulg1/html
    ln -s /cluster/data/archFulg1/html/description.html /gbdb/archFulg1/html/
