#########################################################################
# SWAP LASTZ human/hg38 Tree chimp/rheMac8 - (DONE - 2016-02-05 - Hiram)
    # original alignment
    cd /hive/data/genomes/hg38/bed/lastzRheMac8.2016-02-05
    cat fb.hg38.chainRheMac8Link.txt
    # 2576861166 bases of 3049335806 (84.506%) in intersection

    # and for the swap:
    mkdir /hive/data/genomes/rheMac8/bed/blastz.hg38.swap
    cd /hive/data/genomes/rheMac8/bed/blastz.hg38.swap

    time (doBlastzChainNet.pl -verbose=2 \
      /hive/data/genomes/hg38/bed/lastzRheMac8.2016-02-05/DEF \
        -swap -chainMinScore=5000 -chainLinearGap=medium \
          -workhorse=hgwdev -smallClusterHub=ku -bigClusterHub=ku \
            -syntenicNet) > swap.log 2>&1
    #  real    234m24.287s

    cat fb.rheMac8.chainHg38Link.txt
    # 2499211352 bases of 3142093174 (79.540%) in intersection

    time (doRecipBest.pl -buildDir=`pwd` rheMac8 hg38) > rbest.log 2>&1
    # real    39m52.256s

##############################################################################
# SWAP LASTZ Rhesus rheMac8 (DONE - 2016-02-10 - Hiram)
    # original alignment
    mkdir /hive/data/genomes/mm10/bed/lastzRheMac8.2016-02-10
    cd /hive/data/genomes/mm10/bed/lastzRheMac8.2016-02-10

    cat fb.mm10.chainRheMac8Link.txt
    #	918841829 bases of 2652783500 (34.637%) in intersection

    # and for the swap:
    mkdir /hive/data/genomes/rheMac8/bed/blastz.mm10.swap
    cd /hive/data/genomes/rheMac8/bed/blastz.mm10.swap
    time (doBlastzChainNet.pl -verbose=2 \
	/hive/data/genomes/mm10/bed/lastzRheMac8.2016-02-10/DEF \
	-swap -syntenicNet \
	-workhorse=hgwdev -smallClusterHub=ku -bigClusterHub=ku \
	-chainMinScore=3000 -chainLinearGap=medium) > swap.log 2>&1
    #	real    110m33.219s

    cat fb.rheMac8.chainMm10Link.txt
    #	917131079 bases of 3142093174 (29.189%) in intersection

    time (doRecipBest.pl -buildDir=`pwd` rheMac8 mm10) > rbest.log 2>&1
    # real    409m8.252s

##############################################################################
# Chlorocebus sabaeus/Green monkey Lastz run (DONE - 2016-08-27 - Hiram)
    screen -S rheMac8ChlSab2      # use a screen to manage this longish running job
    mkdir /hive/data/genomes/rheMac8/bed/lastzChlSab2.2016-08-27
    cd /hive/data/genomes/rheMac8/bed/lastzChlSab2.2016-08-27

    # always set the BLASTZ program so we know what version was used
    printf "# chimp vs Chlorocebus sabaeus
BLASTZ=/cluster/bin/penn/lastz-distrib-1.03.66/bin/lastz
# maximum M allowed with lastz is only 254
BLASTZ_M=254
BLASTZ_Q=/scratch/data/blastz/human_chimp.v2.q
#    A    C    G    T
#   90 -330 -236 -356
# -330  100 -318 -236
# -236 -318  100 -330
# -356 -236 -330   90
BLASTZ_O=600
BLASTZ_E=150
# other parameters from panTro2 vs hg18 lastz on advice from Webb
BLASTZ_K=4500
BLASTZ_Y=15000
BLASTZ_T=2

# TARGET: Macaca Mulatta RheMac8
SEQ1_DIR=/hive/data/genomes/rheMac8/rheMac8.2bit
SEQ1_LEN=/hive/data/genomes/rheMac8/chrom.sizes
SEQ1_CHUNK=40000000
SEQ1_LIMIT=600
SEQ1_LAP=10000
SEQ1_IN_CONTIGS=0

# QUERY Chlorocebus sabaeus chlSab2
SEQ2_DIR=/hive/data/genomes/chlSab2/chlSab2.2bit
SEQ2_LEN=/hive/data/genomes/chlSab2/chrom.sizes
SEQ2_CHUNK=20000000
SEQ2_LAP=0
SEQ2_IN_CONTIGS=0

BASE=/hive/data/genomes/rheMac8/bed/lastzChlSab2.2016-08-27
TMPDIR=/dev/shm
" > DEF

    time (doBlastzChainNet.pl `pwd`/DEF -verbose=2 \
        -chainMinScore=5000 -chainLinearGap=medium \
        -workhorse=hgwdev -smallClusterHub=ku -bigClusterHub=ku \
        -syntenicNet) > do.log 2>&1
    # real    362m8.963s

    cat fb.rheMac8.chainChlSab2Link.txt
    # 2674926475 bases of 3142093174 (85.132%) in intersection

    # filter with doRecipBest.pl
    time (doRecipBest.pl -workhorse=hgwdev -buildDir=`pwd` \
        rheMac8 chlSab2) > rbest.log 2>&1 &
    # real    538m28.449s

    # running the swap
    mkdir /hive/data/genomes/chlSab2/bed/blastz.rheMac8.swap
    cd /hive/data/genomes/chlSab2/bed/blastz.rheMac8.swap
    time (doBlastzChainNet.pl -verbose=2 \
        -swap /hive/data/genomes/rheMac8/bed/lastzChlSab2.2016-08-27/DEF \
        -chainMinScore=5000 -chainLinearGap=medium \
        -workhorse=hgwdev -smallClusterHub=ku -bigClusterHub=ku \
        -syntenicNet) > swap.log 2>&1
    # real    89m19.998s

    cat fb.chlSab2.chainRheMac8Link.txt
    # 2596129666 bases of 2752019208 (94.335%) in intersection

    time (doRecipBest.pl -workhorse=hgwdev -buildDir=`pwd` \
        chlSab2 rheMac8) > rbest.log 2>&1
    # real    278m9.306s

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