# for emacs: -*- mode: sh; -*-
#########################################################################
# hivgne8v2 DATABASE BUILD (STARTED 04/24/08, DONE 4/28/08, Fan)

    ssh hiv1
    mkdir -p /cluster/store12/medical/hiv/hivgne8v2
    cd /cluster/store12/medical/hiv/hivgne8v2

    cd /gbdb
    mkdir hivgne8v2
    cd hivgne8v2
    cp -Rp ../hivgne8/* .

#########################################################################
# CREATING DATABASE 

# Create the hivgne8v2 database.
    
    echo 'create database hivgne8v2' | hgsql hiv1

# CREATING GRP TABLE FOR TRACK GROUPING 
    
    echo "create table grp (PRIMARY KEY(NAME)) select * from hiv1.grp" \
      | hgsql hivgne8v2

#########################################################################
# MAKE HGCENTRALHIV1 ENTRY AND TRACKDB TABLE FOR HIVGNE8V2 

    echo 'insert into defaultDb values("HIV GNE8 (GP120) V2.0", "hivgne8v2");' \
      | hgsql -h localhost hgcentralhiv1

    echo 'insert into dbDb values("hivgne8v2", " Sep. 1998", \
          "/gbdb/hivgne8v2/nib", "HIV GNE8 (GP120) V2.0", "chr1", 1, 2030, \
    "HIV GNE8 (GP120) V2.0","Human immunodeficiency     virus 1", \
    "/gbdb/hivgne8v2/html/description.html", 0, 0, " sequence as of Sep., 1998");' \
      | hgsql hgcentralhiv1 -h localhost

    echo 'insert into genomeClade values("HIV GNE8 (GP120) V2.0", "other", 110);'\
      | hgsql hgcentralhiv1 -h localhost

#########################################################################
# COPY OVER MYSQL TABLES FROM hivgne8

    cd /cluster/store12/medical/hiv/hivgne8v2

# create do1 with the following lines:

echo processing table $1 ...

#hgsql hivgne8v2 -e "drop table ${1}"

getDbTableDef hivgne8 $1 >$1.sql
hgsql hivgne8 -N -e "select * from ${1}" >$1.tab
hgsql hivgne8v2 <$1.sql

hgsql hivgne8v2 -e "load data local infile '${1}.tab' into table ${1}"

# create doall with the following lines:

do1 aaSeq 
do1 chromInfo 
do1 dnaSeq 
do1 extFile 
do1 grp 
do1 gsIdXref 
do1 gsidClinicRec 
do1 gsidClinicRecWithSeq 
do1 gsidSubjInfo 
do1 hSeq 
do1 hgFindSpec 
do1 hgFindSpec_fanhsu 
do1 history 
do1 hivGene 
do1 interPro 
do1 seq 
do1 tableDescriptions 
do1 trackDb 
do1 trackDb_fanhsu 
do1 vax004 
do1 vax004AaCons 
do1 vax004Cons 
do1 vax004Msa

    chmod +x do*
    doall

# create trackDb

    cd kent/src/hg/makeDb/trackDb

# edit makefile to add hivgne8v2
    vi makefile

    cd hiv
    mkdir hivgne8v2
    cd hivgne8v2
    cp -p ../hivgne8/* .

    cd ../..
    make alpha DBS=hivgne8v2

# Ask admin to start BLAT server process for hivgne8v2 and then
# MAKE HGCENTRALHIV1 BLATSERVERS ENTRY FOR HIVGNE8V2
    
    echo 'insert into blatServers values("hivgne8v2", "hiv1", "17794", "1", "0"); \
          insert into blatServers values("hivgne8v2", "hiv1", "17795", "0", "0");' \
      | hgsql hgcentralhiv1 -h localhost

#########################################################################
# CREATE VAX003 TRACK

    cd /cluster/store12/medical/hiv/hivgne8v2
# get vax003 sequences
    hgsql hivgne8v2 -N -e 'select * from dnaSeq where id like "%T%"' >vax003.tab

# create .fa file
    tabToFa vax003

    mkdir -p /gbdb/hivgne8v2/vax003
    cp -p vax003.fa /gbdb/hivgne8v2/vax003/vax003.fa

    hgLoadSeq -replace hivgne8v2 /gbdb/hivgne8v2/vax003/vax003.fa

# BLAT
    gfClient -minScore=200 -minIdentity=80 -nohead hiv1.cse.ucsc.edu 17795  /gbdb/hivgne8v2/nib \
    -out=psl -t=dna -q=dna vax003.fa vax003.psl

# count the result
    wc *.psl
    cut -f 10 vax003.psl |wc
    cut -f 10 vax003.psl |sort -u |wc

# load the psl result into vax003 table
    hgLoadPsl hivgne8v2 vax003.psl

# hgLoadPsl has some file permission problem.  Finish this by manually load the psl.tab file.
    hgsql hivgne8v2 -e 'load data local infile "psl.tab" into table vax003'

#########################################################################
# COPY OVER MSA TABLES

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msa/AE
    cd /cluster/store12/medical/hiv/hivgne8v2/msa/AE

# get table definition
    mysqldump -d hivVax003Vax004 vax003AEMsa -u medcat -p$HGPSWD|hgsql hivgne8v2
    
# load the table   
    hgsql hivgne8v2 -e "insert into vax003AEMsa select * from hivVax003Vax004.vax003AEMsa"

#########################################################################
# CREATE MAF TRACKS FOR VAX004

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msa
    cd /cluster/store12/medical/hiv/hivgne8v2/msa

# create a script file, doall

    hgsql hivgne8v2 -N -e \
    'select id from dnaSeq where id like "%U%"'\
    |sed -e 's/ss/do1 ss/g' >doall

# create one line script file, do1, with the following line in it:

    hgsql hivgne8v2 -N -e  "select id, seq from vax004Msa where id='${1}'"
    chmod +x do*

# run the script to get the .tab file with all MSA sequences of VAX004
    doall >gne8.tab
# convert .tab into .fa file
    tabToFa gne8

# grab the base alignment sequence
    echo ">hivgne8v2" >gne8.aln
    hgsql hivgne8v2 -N -e 'select seq from vax004Msa where id="GNE8"'  >> gne8.aln

# prepare an interium file, jjAll.mfa
    cat gne8.aln gne8.fa >jjAll.mfa
    echo = >>jjAll.mfa

# Run xmfaToMafGne8 to create a precursor file for the final .maf

    xmfaToMafGne8 jjAll.mfa j.out  org1=hivgne8v2
    cat j.out|sed -e 's/\./_/g'|sed -e 's/_chr/\.chr/g' >chr1.tmp

    rm jjAll.mfa j.out

    cat chr1.tmp |sed -e 's/ss_U/U/g' >chr1.maf

# copy .maf to /gbdb.

    mkdir -p  /gbdb/hivgne8v2/vax004Maf 
    cp chr1.maf /gbdb/hivgne8v2/vax004Maf -p

    hgLoadMaf hivgne8v2 vax004Maf

# create another copy for protein MAF.

    mkdir -p  /gbdb/hivgne8v2/vax004AaMaf 
    cp -p chr1.maf /gbdb/hivgne8v2/vax004AaMaf
    hgLoadMaf hivgne8v2 vax004AaMaf

#########################################################################
# CREATE CONSERVATION TRACKS FOR VAX003 AE STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/conservation/AE
    cd /cluster/store12/medical/hiv/hivgne8v2/conservation/AE

# create the .wig file and .fa file of the consensus sequence.
    gsidMsa hivgne8v2 vax003AEMsa GNE8-gp120-AY771703 231 vax003AECons.wig vax003AEConsensus.fa

# encode and load the wig file
    wigEncode vax003AECons.wig stdout vax003AECons.wib \
    | hgLoadWiggle hivgne8v2 vax003AECons stdin

# copy .wib file to /gbdb
    mkdir -p /gbdb/hivgne8v2/wib
    cp vax003AECons.wib /gbdb/hivgne8v2/wib

# do the same for protein conservation track

    mkdir aa
    cd aa

# create .wig file
    gsidAaMsa2 hivgne8v2 vax003AEMsa GNE8-gp120-AY771703 231 vax003AEAaCons.wig vax003AEAaConsensus.fa

# encode and load the .wib file   
    wigEncode vax003AEAaCons.wig stdout vax003AEAaCons.wib \
    | hgLoadWiggle hivgne8v2 vax003AEAaCons stdin

    cp vax003AEAaCons.wib /gbdb/hivgne8v2/wib

#########################################################################
# CREATE MAF TRACKS FOR VAX003 AE STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msa/AE
    cd /cluster/store12/medical/hiv/hivgne8v2/msa/AE

# create a script file, doall

    hgsql hivgne8v2 -N -e \
    'select id from dnaSeq where id like "%T%"'\
    |sed -e 's/ss/do1 ss/g' >doall

# create one line script file, do1, with the following line in it:

    hgsql hivgne8v2 -N -e  "select id, seq from vax003AEMsa where id='${1}'"

    chmod +x do*

# run the script to get the .tab file with all MSA sequences of VAX003 AE
    doall >gne8.tab
# convert .tab into .fa file
    tabToFa gne8

# grab the base alignment sequence
    echo ">hivgne8v2" >gne8.aln
    hgsql hivgne8v2 -N -e 'select seq from vax003AEMsa where id="GNE8-gp120-AY771703"'  >> gne8.aln

# prepare an interium file, jjAll.mfa
    cat gne8.aln gne8.fa >jjAll.mfa
    echo = >>jjAll.mfa

# Run xmfaToMafGne8 to create a precursor file for the final .maf

    xmfaToMafGne8 jjAll.mfa j.out  org1=hivgne8v2
    cat j.out|sed -e 's/\./_/g'|sed -e 's/_chr/\.chr/g' >chr1.tmp

#    rm jjAll.mfa j.out

    cat chr1.tmp |sed -e 's/ss_T/T/g' >chr1.maf

# copy .maf to /gbdb.

    mkdir -p  /gbdb/hivgne8v2/vax003AEMaf
    cp chr1.maf /gbdb/hivgne8v2/vax003AEMaf -p

    hgLoadMaf hivgne8v2 vax003AEMaf

# create another copy for protein MAF.

    mkdir -p  /gbdb/hivgne8v2/vax003AEAaMaf 
    cp -p chr1.maf /gbdb/hivgne8v2/vax003AEAaMaf
    hgLoadMaf hivgne8v2 vax003AEAaMaf

#########################################################################
# COPY OVER MSA TABLES FOR VAX003 B STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msa/B
    cd /cluster/store12/medical/hiv/hivgne8v2/msa/B

# get table definition
    mysqldump -d hivVax003Vax004 vax003BMsa -u medcat -p$HGPSWD|hgsql hivgne8v2

# load the table   
    hgsql hivgne8v2 -e "insert into vax003BMsa select * from hivVax003Vax004.vax003BMsa"

#########################################################################
# CREATE CONSERVATION TRACKS FOR VAX003 B STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/conservation/B
    cd /cluster/store12/medical/hiv/hivgne8v2/conservation/B

# create the .wig file and .fa file of the consensus sequence.
    gsidMsa hivgne8v2 vax003BMsa GNE8-gp120-AY771703 231 vax003BCons.wig vax003BConsensus.fa

# encode and load the wig file
    wigEncode vax003BCons.wig stdout vax003BCons.wib \
    | hgLoadWiggle hivgne8v2 vax003BCons stdin

# copy .wib file to /gbdb
    mkdir -p /gbdb/hivgne8v2/wib
    cp vax003BCons.wib /gbdb/hivgne8v2/wib

# do the same for protein conservation track

    mkdir aa
    cd aa

# create .wig file
    gsidAaMsa2 hivgne8v2 vax003BMsa GNE8-gp120-AY771703 231 vax003BAaCons.wig vax003BAaConsensus.fa

# encode and load the .wib file   
    wigEncode vax003BAaCons.wig stdout vax003BAaCons.wib \
    | hgLoadWiggle hivgne8v2 vax003BAaCons stdin

    cp vax003BAaCons.wib /gbdb/hivgne8v2/wib

#########################################################################
# CREATE MAF TRACKS FOR VAX003 B STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msa/B
    cd /cluster/store12/medical/hiv/hivgne8v2/msa/B

# create a script file, doall

    hgsql hivgne8v2 -N -e \
    'select id from dnaSeq where id like "%T%"'\
    |sed -e 's/ss/do1 ss/g' >doall

# create one line script file, do1, with the following line in it:

    hgsql hivgne8v2 -N -e  "select id, seq from vax003BMsa where id='${1}'"

    chmod +x do*

# run the script to get the .tab file with all MSA sequences of VAX004
    doall >gne8.tab
# convert .tab into .fa file
    tabToFa gne8

# grab the base alignment sequence
    echo ">hivgne8v2" >gne8.aln
    hgsql hivgne8v2 -N -e 'select seq from vax003BMsa where id="GNE8-gp120-AY771703"'  >> gne8.aln

# prepare an interium file, jjAll.mfa
    cat gne8.aln gne8.fa >jjAll.mfa
    echo = >>jjAll.mfa

# Run xmfaToMafGne8B to create a precursor file for the final .maf

    xmfaToMafGne8 jjAll.mfa j.out  org1=hivgne8v2
    cat j.out|sed -e 's/\./_/g'|sed -e 's/_chr/\.chr/g' >chr1.tmp

    rm jjAll.mfa j.out

    cat chr1.tmp |sed -e 's/ss_T/T/g' >chr1.maf

# copy .maf to /gbdb.

    mkdir -p  /gbdb/hivgne8v2/vax003BMaf
    cp chr1.maf /gbdb/hivgne8v2/vax003BMaf -p
    
    hgLoadMaf hivgne8v2 vax003BMaf

# create another copy for protein MAF.

    mkdir -p  /gbdb/hivgne8v2/vax003BAaMaf 
    cp -p chr1.maf /gbdb/hivgne8v2/vax003BAaMaf
    hgLoadMaf hivgne8v2 vax003BAaMaf

#########################################################################
# CREATE VAX003 TRACK 

    cd ~/medical/hiv/hivgne8v2

# get vax003 sequences
    hgsql hivgne8v2 -N -e 'select * from dnaSeq where id like "%T%"' >vax003.tab

# create .fa file
    tabToFa vax003

    mkdir -p /gbdb/hivgne8v2/vax003
    cp -p vax003.fa /gbdb/hivgne8v2/vax003/vax003.fa

    hgLoadSeq -replace hivgne8v2 /gbdb/hivgne8v2/vax003/vax003.fa

# BLAT
    gfClient -minScore=200 -minIdentity=70 -nohead hiv1.cse.ucsc.edu 17795 \
    /gbdb/hivgne8v2/nib -out=psl -t=dna -q=dna vax003.fa vax003.psl

# count the result
    wc *.psl
    cut -f 10 vax003.psl |wc
    cut -f 10 vax003.psl |sort -u |wc

# load the psl result into vax003 table
    hgLoadPsl hivgne8v2 vax003.psl

# hgLoadPsl has some file permission problem.  Finish this by manually load the psl.tab file.
    hgsql hivgne8v2 -e 'load data local infile "psl.tab" into table vax003'

#########################################################################
# Build the gsidSubjSeq table (used by Table View).

   gsidSubjSeq hivgne8v2 dnaSeqId > j.dna
   gsidSubjSeq hivgne8v2 aaSeqId > j.aa

   cut -f 1 j.dna >j.1
   cut -f 1 j.aa  >j.2

   cut -f 2 j.dna  >j.3
   cut -f 2 j.aa   >j.4

   paste j.1 j.3 j.4> gsidSubjSeq.tab

   hgsql hivgne8v2 -e 'delete from gsidSubjSeq'
   hgsql hivgne8v2 -e \
   'load data local infile "gsidSubjSeq.tab" into table gsidSubjSeq'

   rm j.1 j.2 j.3 j.4 j.dna j.aa
#########################################################################
# RE-BUILD CONSERVATION AND MSA TRACKS FOR vax003AE (Done 7/14/08, Fan)

# COPY OVER shortened MSA sequences from hivVax003Vax004

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msaNew/AE
    cd /cluster/store12/medical/hiv/hivgne8v2/msaNew/AE

    hgsql hivgne8v2 -e "delete from vax003AEMsa"
    hgsql hivgne8v2 -e "insert into vax003AEMsa select * from hivVax003Vax004.vax003AEMsa"

# CREATE CONSERVATION TRACKS FOR AE STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/conservationNew/AE
    cd /cluster/store12/medical/hiv/hivgne8v2/conservationNew/AE

# create the .wig file and .fa file of the consensus sequence.
    gsidMsa hivgne8v2 vax003AEMsa GNE8-gp120-AY771703 231 vax003AECons.wig vax003AEConsensus.fa

# encode and load the wig file
    wigEncode vax003AECons.wig stdout vax003AECons.wib \
    | hgLoadWiggle hivgne8v2 vax003AECons stdin

# copy .wib file to /gbdb
    mkdir -p /gbdb/hivgne8v2/wib
    cp vax003AECons.wib /gbdb/hivgne8v2/wib

# do the same for protein conservationNew track

    mkdir aa
    cd aa

# create .wig file
    gsidAaMsa2 hivgne8v2 vax003AEMsa GNE8-gp120-AY771703 231 vax003AEAaCons.wig vax003AEAaConsensus.fa

# encode and load the .wib file   
    wigEncode vax003AEAaCons.wig stdout vax003AEAaCons.wib \
    | hgLoadWiggle hivgne8v2 vax003AEAaCons stdin

    cp vax003AEAaCons.wib /gbdb/hivgne8v2/wib

# CREATE MAF TRACKS FOR vax003AE STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msaNew/AE
    cd /cluster/store12/medical/hiv/hivgne8v2/msaNew/AE

# create a script file, doall

    hgsql hivgne8v2 -N -e \
    'select id from vax003AEMsa where id like "%T%"'\
    |sed -e 's/ss/do1 ss/g' >doall

# create one line script file, do1, with the following line in it:

    hgsql hivgne8v2 -N -e  "select id, seq from vax003AEMsa where id='${1}'"

    chmod +x do*

# run the script to get the .tab file with all MSA sequences of VAX004
    doall >gne8v2.tab
# convert .tab into .fa file
    tabToFa gne8v2

# grab the base alignment sequence
    echo ">hivgne8v2" >gne8v2.aln
    hgsql hivgne8v2 -N -e 'select seq from vax003AEMsa where id="GNE8-gp120-AY771703"'  >> gne8v2.aln

# prepare an interium file, jjAll.mfa
    cat gne8v2.aln gne8v2.fa >jjAll.mfa
    echo = >>jjAll.mfa

# Run xmfaToMafGne8 to create a precursor file for the final .maf

    xmfaToMafGne8 jjAll.mfa j.out  org1=hivgne8v2
    cat j.out|sed -e 's/\./_/g'|sed -e 's/_chr/\.chr/g' >chr1.tmp

    rm jjAll.mfa j.out

    cat chr1.tmp |sed -e 's/ss_T/T/g' >chr1.maf

# copy .maf to /gbdb.

    mkdir -p  /gbdb/hivgne8v2/vax003AEMaf
    cp chr1.maf /gbdb/hivgne8v2/vax003AEMaf -p
    echo before load
    hgLoadMaf hivgne8v2 vax003AEMaf

# create another copy for protein MAF.

    mkdir -p  /gbdb/hivgne8v2/vax003AEAaMaf 
    cp -p chr1.maf /gbdb/hivgne8v2/vax003AEAaMaf
    hgLoadMaf hivgne8v2 vax003AEAaMaf

#########################################################################
# RE-BUILD CONSERVATION AND MSA TRACKS FOR vax003B

# COPY OVER shortened MSA sequences from hivVax003Vax004

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msaNew/B
    cd /cluster/store12/medical/hiv/hivgne8v2/msaNew/B

    hgsql hivgne8v2 -e "delete from vax003BMsa"
    hgsql hivgne8v2 -e "insert into vax003BMsa select * from hivVax003Vax004.vax003BMsa"

# CREATE CONSERVATION TRACKS FOR B STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/conservationNew/B
    cd /cluster/store12/medical/hiv/hivgne8v2/conservationNew/B

# create the .wig file and .fa file of the consensus sequence.
    gsidMsa hivgne8v2 vax003BMsa GNE8-gp120-AY771703 231 vax003BCons.wig vax003BConsensus.fa

# encode and load the wig file
    wigEncode vax003BCons.wig stdout vax003BCons.wib \
    | hgLoadWiggle hivgne8v2 vax003BCons stdin

# copy .wib file to /gbdb
    mkdir -p /gbdb/hivgne8v2/wib
    cp vax003BCons.wib /gbdb/hivgne8v2/wib

# do the same for protein conservationNew track

    mkdir aa
    cd aa

# create .wig file
    gsidAaMsa2 hivgne8v2 vax003BMsa GNE8-gp120-AY771703 231 vax003BAaCons.wig vax003BAaConsensus.fa

# encode and load the .wib file   
    wigEncode vax003BAaCons.wig stdout vax003BAaCons.wib \
    | hgLoadWiggle hivgne8v2 vax003BAaCons stdin

    cp vax003BAaCons.wib /gbdb/hivgne8v2/wib

# CREATE MAF TRACKS FOR vax003B STRAIN

    mkdir -p /cluster/store12/medical/hiv/hivgne8v2/msaNew/B
    cd /cluster/store12/medical/hiv/hivgne8v2/msaNew/B

# create a script file, doall

    hgsql hivgne8v2 -N -e \
    'select id from vax003BMsa where id like "%T%"'\
    |sed -e 's/ss/do1 ss/g' >doall

# create one line script file, do1, with the following line in it:

    hgsql hivgne8v2 -N -e  "select id, seq from vax003BMsa where id='${1}'"

    chmod +x do*

# run the script to get the .tab file with all MSA sequences of VAX004
    doall >gne8v2.tab
# convert .tab into .fa file
    tabToFa gne8v2

# grab the base alignment sequence
    echo ">hivgne8v2" >gne8v2.aln
    hgsql hivgne8v2 -N -e 'select seq from vax003BMsa where id="GNE8-gp120-AY771703"'  >> gne8v2.aln

# prepare an interium file, jjAll.mfa
    cat gne8v2.aln gne8v2.fa >jjAll.mfa
    echo = >>jjAll.mfa

# Run xmfaToMafGne8v2B to create a precursor file for the final .maf

    xmfaToMafGne8 jjAll.mfa j.out  org1=hivgne8v2
    cat j.out|sed -e 's/\./_/g'|sed -e 's/_chr/\.chr/g' >chr1.tmp

    rm jjAll.mfa j.out

    cat chr1.tmp |sed -e 's/ss_T/T/g' >chr1.maf

# copy .maf to /gbdb.

    mkdir -p  /gbdb/hivgne8v2/vax003BMaf
    cp chr1.maf /gbdb/hivgne8v2/vax003BMaf -p
    echo before load
    hgLoadMaf hivgne8v2 vax003BMaf

# create another copy for protein MAF.

    mkdir -p  /gbdb/hivgne8v2/vax003BAaMaf 
    cp -p chr1.maf /gbdb/hivgne8v2/vax003BAaMaf
    hgLoadMaf hivgne8v2 vax003BAaMaf

#########################################################################
# REBUILD THE gsidClinicRecWithSeq TABLE (DONE 11/03/08, Fan)

# See details in hivVax003Vax004.txt.
#########################################################################
# BUILD THE POSITIVE SELECTION TRACKS FOR VAX003 SUBTYPE B

    ssh hiv1
    mkdir -p /hive/groups/gsid/medical/hiv/posSelection/B/hivgne8v2
    cd /hive/groups/gsid/medical/hiv/posSelection/B/hivgne8v2

# BLAT /cluster/hive/groups/gsid/medical/hiv/posSelection/B/BMsaAaConsensus.fa
# against hivgne8v2 base genome, select psl without header option
# cut and paste the result into the file BMsa.psl

hgLoadPsl -keep -table=BMsaPsl -nobin hivgne8v2 BMsa.psl 

# will get the following error:

#Processing BMsa.psl
#Can't start query:
#LOAD DATA CONCURRENT  INFILE
'/cluster/hive/groups/gsid/medical/hiv/hivgne8v2/posSelection/BMsa.psl'  INTO
TABLE BMsaPsl

#mySQL error 13: Can't get stat of
'/cluster/hive/groups/gsid/medical/hiv/hivgne8v2/posSelection/BMsa.psl'
(Errcode: 13)

# load manually then

hgsql hivgne8v2
load data local infile "BMsa.psl" into table BMsaPsl;
quit

# build positive selection tracks for model 2 and model 8.

gsidPosSelect hivgne8v2  BMsaPsl posSelBuild pSelectBModel2  posSelBModel2.bed
hgLoadBed hivgne8v2 posSelBModel2 posSelBModel2.bed

gsidPosSelect hivgne8v2 BMsaPsl posSelBuild pSelectBModel8  posSelBModel8.bed
hgLoadBed hivgne8v2 posSelBModel8 posSelBModel8.bed

##########################################################################
# BUILD THE POSITIVE SELECTION TRACKS FOR VAX003 SUBTYPE AE

    ssh hiv1
    mkdir -p /hive/groups/gsid/medical/hiv/posSelection/AE/hivgne8v2
    cd /hive/groups/gsid/medical/hiv/posSelection/AE/hivgne8v2

# BLAT
# /cluster/hive/groups/gsid/medical/hiv/posSelection/AE/AEMsaAaConsensus.fa
# against hivgne8v2 base genome, select psl without header option
# cut and paste the result into the file AEMsa.psl

hgLoadPsl -keep -table=AEMsaPsl -nobin hivgne8v2 AEMsa.psl 

# will get the following error:

#Processing AEMsa.psl
#Can't start query:
#LOAD DATA CONCURRENT  INFILE
'/cluster/hive/groups/gsid/medical/hiv/hivgne8v2/posSelection/AEMsa.psl'  INTO
TABLE AEMsaPsl

#mySQL error 13: Can't get stat of
'/cluster/hive/groups/gsid/medical/hiv/hivgne8v2/posSelection/AEMsa.psl'
(Errcode: 13)

# load manually then

hgsql hivgne8v2
load data local infile "AEMsa.psl" into table AEMsaPsl;
quit

# build positive selection tracks for model 2 and model 8.

gsidPosSelect hivgne8v2  AEMsaPsl posSelBuild pSelectAEModel2
posSelAEModel2.bed
hgLoadBed hivgne8v2 posSelAEModel2 posSelAEModel2.bed

gsidPosSelect hivgne8v2 AEMsaPsl posSelBuild pSelectAEModel8
posSelAEModel8.bed
hgLoadBed hivgne8v2 posSelAEModel8 posSelAEModel8.bed

##########################################################################
# BUILD THE POSITIVE SELECTION TRACKS FOR VAX004 (Done Fan, 3/2/09)

# Please see the corresponding section in hivVax003Vax004.txt for details.
##########################################################################

