##############################################################################
# LASTZ Rat rn6 (DONE - 2020-10-20 - Hiram)
    mkdir /hive/data/genomes/rheMac10/bed/lastzRn6.2020-10-20
    cd /hive/data/genomes/rheMac10/bed/lastzRn6.2020-10-20

    printf '# rat vs rhesus
BLASTZ=/cluster/bin/penn/lastz-distrib-1.04.03/bin/lastz
# TARGET: Rhesus RheMac10
SEQ1_DIR=/hive/data/genomes/rheMac10/rheMac10.2bit
SEQ1_LEN=/hive/data/genomes/rheMac10/chrom.sizes
SEQ1_CHUNK=20000000
SEQ1_LAP=10000

# QUERY: Rat Rn6
SEQ2_DIR=/hive/data/genomes/rn6/rn6.2bit
SEQ2_LEN=/hive/data/genomes/rn6/chrom.sizes
SEQ2_CHUNK=20000000
SEQ2_LAP=0
SEQ2_LIMIT=500

BASE=/hive/data/genomes/rheMac10/bed/lastzRn6.2020-10-20
TMPDIR=/dev/shm
' > DEF

    #	establish a screen to control this job
    screen -S rheMac10Rn6
    time (doBlastzChainNet.pl -verbose=2 `pwd`/DEF \
	-syntenicNet \
	-workhorse=hgwdev -smallClusterHub=hgwdev -bigClusterHub=ku \
	-chainMinScore=3000 -chainLinearGap=medium) > do.log 2>&1 &
    #   real    278m29.024s

    cat fb.rheMac10.chainRn6Link.txt
    #	901231172 bases of 2936892733 (30.687%) in intersection
    cat fb.rheMac10.chainSynRn6Link.txt
    #   854008376 bases of 2936892733 (29.079%) in intersection

    time (doRecipBest.pl -load -workhorse=hgwdev -buildDir=`pwd` \
	rheMac10 rn6) > rbest.log 2>&1 &
    # real    293m29.540s

    cat fb.rheMac10.chainRBest.Rn6.txt
    #	860406990 bases of 2936892733 (29.297%) in intersection

    mkdir /hive/data/genomes/rn6/bed/blastz.rheMac10.swap
    cd /hive/data/genomes/rn6/bed/blastz.rheMac10.swap
    time (doBlastzChainNet.pl -verbose=2 \
	/hive/data/genomes/rheMac10/bed/lastzRn6.2020-10-20/DEF \
	-swap -syntenicNet \
	-workhorse=hgwdev -smallClusterHub=hgwdev -bigClusterHub=ku \
	-chainMinScore=3000 -chainLinearGap=medium) > swap.log 2>&1
    #	real    61m59.379s

    cat fb.rn6.chainRheMac10Link.txt
    #   938991388 bases of 2729860805 (34.397%) in intersection
    cat fb.rn6.chainSynRheMac10Link.txt
    #	873546846 bases of 2729860805 (32.000%) in intersection

    time (doRecipBest.pl -load -workhorse=hgwdev -buildDir=`pwd` \
	rn6 rheMac10) > rbest.log 2>&1
    # real    358m51.937s

    cat fb.rn6.chainRBest.RheMac10.txt
    #	861947799 bases of 2729860805 (31.575%) in intersection

##############################################################################
# LASTZ Rhesus RheMac10 vs. Crab-eating macaque MacFas5
#	(DONE - 2021-10-12 - hiram)

    cd /cluster/home/hiram/kent/src/hg/makeDb/doc/rheMac10
    time (~/kent/src/hg/utils/automation/pairLastz.sh rheMac10 macFas5 \
      primate primate) > rheMac10.macFas5.log 2>&1 &
    #	real	422m56.515s
    #	user	0m1.550s
    #	sys	0m1.626s

    # the following make doc is in that log file, copied here:

    mkdir /hive/data/genomes/rheMac10/bed/lastzMacFas5.2021-10-12
    cd /hive/data/genomes/rheMac10/bed/lastzMacFas5.2021-10-12

    printf '# Crab-eating macaque MacFas5 vs. Rhesus RheMac10
BLASTZ=/cluster/bin/penn/lastz-distrib-1.04.03/bin/lastz
BLASTZ_T=2
BLASTZ_O=600
BLASTZ_E=150
BLASTZ_M=254
BLASTZ_K=4500
BLASTZ_Y=15000
BLASTZ_Q=/hive/data/staging/data/blastz/human_chimp.v2.q
#       A     C     G     T
# A    90  -330  -236  -356
# C  -330   100  -318  -236
# G  -236  -318   100  -330
# T  -356  -236  -330    90

# TARGET: Rhesus RheMac10
SEQ1_DIR=/hive/data/genomes/rheMac10/rheMac10.2bit
SEQ1_LEN=/hive/data/genomes/rheMac10/chrom.sizes
SEQ1_CHUNK=20000000
SEQ1_LAP=10000
SEQ1_LIMIT=40

# QUERY: Crab-eating macaque MacFas5
SEQ2_DIR=/hive/data/genomes/macFas5/macFas5.2bit
SEQ2_LEN=/hive/data/genomes/macFas5/chrom.sizes
SEQ2_CHUNK=20000000
SEQ2_LAP=0
SEQ2_LIMIT=100

BASE=/hive/data/genomes/rheMac10/bed/lastzMacFas5.2021-10-12
TMPDIR=/dev/shm

' > DEF

    time (~/kent/src/hg/utils/automation/doBlastzChainNet.pl  -verbose=2 `pwd`/DEF -syntenicNet \
        -workhorse=hgwdev -smallClusterHub=hgwdev -bigClusterHub=ku \
        -chainMinScore=5000 -chainLinearGap=medium) > do.log 2>&1
    grep -w real do.log | sed -e 's/^/    # /;'
    # real	188m26.969s

    sed -e 's/^/    # /;' fb.rheMac10.chainMacFas5Link.txt
    # 2784170031 bases of 2936892733 (94.800%) in intersection
    sed -e 's/^/    # /;' fb.rheMac10.chainSynMacFas5Link.txt
    # 2760382026 bases of 2936892733 (93.990%) in intersection

    time (~/kent/src/hg/utils/automation/doRecipBest.pl  -load -workhorse=hgwdev -buildDir=`pwd` \
       \
       \
        rheMac10 macFas5) > rbest.log 2>&1

    grep -w real rbest.log | sed -e 's/^/    # /;'
    # real	96m55.151s

    sed -e 's/^/    # /;' fb.rheMac10.chainRBest.MacFas5.txt
    # 2728786009 bases of 2936892733 (92.914%) in intersection

    ### and for the swap

    cd /hive/data/genomes/macFas5/bed/blastz.rheMac10.swap

   time (~/kent/src/hg/utils/automation/doBlastzChainNet.pl  -swap -verbose=2 \
    /hive/data/genomes/rheMac10/bed/lastzMacFas5.2021-10-12/DEF -swapDir=`pwd` \
  -syntenicNet -workhorse=hgwdev -smallClusterHub=hgwdev -bigClusterHub=ku \
    -chainMinScore=5000 -chainLinearGap=medium) > swap.log 2>&1

    grep -w real swap.log | sed -e 's/^/    # /;'
    # real	71m1.507s

    sed -e 's/^/    # /;' fb.macFas5.chainRheMac10Link.txt
    # 2739714634 bases of 2803866698 (97.712%) in intersection
    sed -e 's/^/    # /;' fb.macFas5.chainSynRheMac10Link.txt
    # 2729711862 bases of 2803866698 (97.355%) in intersection
\    time (~/kent/src/hg/utils/automation/doRecipBest.pl  -load -workhorse=hgwdev -buildDir=`pwd` \
    \
    \
   macFas5 rheMac10) > rbest.log 2>&1

    grep -w real rbest.log | sed -e 's/^/    # /;'
    # real	66m32.559s

    sed -e 's/^/    # /;' fb.macFas5.chainRBest.RheMac10.txt
    # 2730109619 bases of 2803866698 (97.369%) in intersection

##############################################################################
# LASTZ Rhesus RheMac10 vs. Baboon PapAnu2
#    (DONE - 2022-03-17 - Jairo Navarro)

    mkdir /hive/data/genomes/rheMac10/bed/lastzPapAnu2.2022-03-09
    cd /hive/data/genomes/rheMac10/bed/lastzPapAnu2.2022-03-09

    printf '# Baboon PapAnu2 vs. Rhesus RheMac10
BLASTZ=/cluster/bin/penn/lastz-distrib-1.04.03/bin/lastz
BLASTZ_T=2
BLASTZ_O=600
BLASTZ_E=150
BLASTZ_M=254
BLASTZ_K=4500
BLASTZ_Y=15000
BLASTZ_Q=/hive/data/staging/data/blastz/human_chimp.v2.q
#       A     C     G     T
# A    90  -330  -236  -356
# C  -330   100  -318  -236
# G  -236  -318   100  -330
# T  -356  -236  -330    90

# TARGET: Rhesus RheMac10
SEQ1_DIR=/hive/data/genomes/rheMac10/rheMac10.2bit
SEQ1_LEN=/hive/data/genomes/rheMac10/chrom.sizes
SEQ1_CHUNK=20000000
SEQ1_LAP=10000
SEQ1_LIMIT=40

# QUERY: Baboon PapAnu2
SEQ2_DIR=/hive/data/genomes/papAnu2/papAnu2.2bit
SEQ2_LEN=/hive/data/genomes/papAnu2/chrom.sizes
SEQ2_CHUNK=20000000
SEQ2_LAP=0
SEQ2_LIMIT=500

BASE=/hive/data/genomes/rheMac10/bed/lastzPapAnu2.2022-03-09
TMPDIR=/dev/shm

' > DEF

    time (~/kent/src/hg/utils/automation/doBlastzChainNet.pl  -verbose=2 `pwd`/DEF -syntenicNet \
        -workhorse=hgwdev -smallClusterHub=hgwdev -bigClusterHub=ku \
        -chainMinScore=5000 -chainLinearGap=medium) > do.log 2>&1
    grep -w real do.log | sed -e 's/^/    # /;'

    sed -e 's/^/    # /;' fb.rheMac10.chainPapAnu2Link.txt
    # 2661233289 bases of 2936892733 (90.614%) in intersection
    sed -e 's/^/    # /;' fb.rheMac10.chainSynPapAnu2Link.txt
    # 2637780437 bases of 2936892733 (89.815%) in intersection

    time (~/kent/src/hg/utils/automation/doRecipBest.pl  -load -workhorse=hgwdev -buildDir=`pwd` \
       \
       \
        rheMac10 papAnu2) > rbest.log 2>&1

    grep -w real rbest.log | sed -e 's/^/    # /;'
    # real	92m15.570s

    sed -e 's/^/    # /;' fb.rheMac10.chainRBest.PapAnu2.txt
    # 2603944831 bases of 2936892733 (88.663%) in intersection

    ### and for the swap

    cd /hive/data/genomes/papAnu2/bed/blastz.rheMac10.swap

   time (~/kent/src/hg/utils/automation/doBlastzChainNet.pl  -swap -verbose=2 \
    /hive/data/genomes/rheMac10/bed/lastzPapAnu2.2022-03-09/DEF -swapDir=`pwd` \
  -syntenicNet -workhorse=hgwdev -smallClusterHub=hgwdev -bigClusterHub=ku \
    -chainMinScore=5000 -chainLinearGap=medium) > swap.log 2>&1

    grep -w real swap.log | sed -e 's/^/    # /;'

    sed -e 's/^/    # /;' fb.papAnu2.chainRheMac10Link.txt
    # 2643316405 bases of 2893250291 (91.361%) in intersection
    sed -e 's/^/    # /;' fb.papAnu2.chainSynRheMac10Link.txt

    cd /hive/data/genomes/papAnu2/bed/blastz.rheMac10.swap

   time (~/kent/src/hg/utils/automation/doBlastzChainNet.pl  -swap -verbose=2 \
    /hive/data/genomes/rheMac10/bed/lastzPapAnu2.2022-03-09/DEF -swapDir=`pwd` \
  -syntenicNet -workhorse=hgwdev -smallClusterHub=hgwdev -bigClusterHub=ku \
    -chainMinScore=5000 -chainLinearGap=medium) > swap.log 2>&1

    grep -w real swap.log | sed -e 's/^/    # /;'
    # real	70m47.109s

    sed -e 's/^/    # /;' fb.papAnu2.chainRheMac10Link.txt
    # 2643316405 bases of 2893250291 (91.361%) in intersection
    sed -e 's/^/    # /;' fb.papAnu2.chainSynRheMac10Link.txt
    # 2615443297 bases of 2893250291 (90.398%) in intersection
\    time (~/kent/src/hg/utils/automation/doRecipBest.pl  -load -workhorse=hgwdev -buildDir=`pwd` \
    \
    \
   papAnu2 rheMac10) > rbest.log 2>&1

    grep -w real rbest.log | sed -e 's/^/    # /;'
    # real	109m15.780s

    sed -e 's/^/    # /;' fb.papAnu2.chainRBest.RheMac10.txt
    # 2607952215 bases of 2893250291 (90.139%) in intersection

##############################################################################
# LASTZ Rhesus RheMac10 vs. Cow BosTau9
#    (DONE - 2025-03-23 - mspeir)

    mkdir /hive/data/genomes/rheMac10/bed/lastzBosTau9.2025-03-23
    cd /hive/data/genomes/rheMac10/bed/lastzBosTau9.2025-03-23

    printf '# Cow BosTau9 vs. Rhesus RheMac10
BLASTZ=/cluster/bin/penn/lastz-distrib-1.04.03/bin/lastz

# TARGET: Rhesus  rheMac10
SEQ1_DIR=/hive/data/genomes/rheMac10/rheMac10.2bit
SEQ1_LEN=/hive/data/genomes/rheMac10/chrom.sizes
SEQ1_CHUNK=20000000
SEQ1_LAP=10000
SEQ1_LIMIT=40

# QUERY: Cow  bosTau9
SEQ2_DIR=/hive/data/genomes/bosTau9/bosTau9.2bit
SEQ2_LEN=/hive/data/genomes/bosTau9/chrom.sizes
SEQ2_CHUNK=20000000
SEQ2_LAP=0
SEQ2_LIMIT=100

BASE=/hive/data/genomes/rheMac10/bed/lastzBosTau9.2025-03-23
TMPDIR=/dev/shm

' > DEF

    time (~/kent/src/hg/utils/automation/doBlastzChainNet.pl  -verbose=2 `pwd`/DEF -syntenicNet \
        -workhorse=hgwdev -smallClusterHub=hgwdev -fileServer=hgwdev -bigClusterHub=hgwdev \
        -chainMinScore=3000 -chainLinearGap=medium) > do.log 2>&1
    grep -w real do.log | sed -e 's/^/    # /;'
    # real	796m10.530s

    sed -e 's/^/    # /;' fb.rheMac10.chainBosTau9Link.txt
    # 1345771048 bases of 2936892733 (45.823%) in intersection
    sed -e 's/^/    # /;' fb.rheMac10.chainSynBosTau9Link.txt
    # 1293982344 bases of 2936892733 (44.060%) in intersection

    time (~/kent/src/hg/utils/automation/doRecipBest.pl  -load -workhorse=hgwdev -buildDir=`pwd` \
       \
       \
        rheMac10 bosTau9) > rbest.log 2>&1

    grep -w real rbest.log | sed -e 's/^/    # /;'
    # real	229m21.039s

    sed -e 's/^/    # /;' fb.rheMac10.chainRBest.BosTau9.txt
    # 1282431413 bases of 2936892733 (43.666%) in intersection

##############################################################################
# LASTZ Rhesus RheMac10 vs. Horse EquCab3
#    (DONE - 2025-03-23 - mspeir)

    mkdir /hive/data/genomes/rheMac10/bed/lastzEquCab3.2025-03-23
    cd /hive/data/genomes/rheMac10/bed/lastzEquCab3.2025-03-23

    printf '# Horse EquCab3 vs. Rhesus RheMac10
BLASTZ=/cluster/bin/penn/lastz-distrib-1.04.03/bin/lastz

# TARGET: Rhesus  rheMac10
SEQ1_DIR=/hive/data/genomes/rheMac10/rheMac10.2bit
SEQ1_LEN=/hive/data/genomes/rheMac10/chrom.sizes
SEQ1_CHUNK=20000000
SEQ1_LAP=10000
SEQ1_LIMIT=40

# QUERY: Horse  equCab3
SEQ2_DIR=/hive/data/genomes/equCab3/equCab3.2bit
SEQ2_LEN=/hive/data/genomes/equCab3/chrom.sizes
SEQ2_CHUNK=20000000
SEQ2_LAP=0
SEQ2_LIMIT=100

BASE=/hive/data/genomes/rheMac10/bed/lastzEquCab3.2025-03-23
TMPDIR=/dev/shm

' > DEF

    time (~/kent/src/hg/utils/automation/doBlastzChainNet.pl  -verbose=2 `pwd`/DEF -syntenicNet \
        -workhorse=hgwdev -smallClusterHub=hgwdev -fileServer=hgwdev -bigClusterHub=hgwdev \
        -chainMinScore=3000 -chainLinearGap=medium) > do.log 2>&1
    grep -w real do.log | sed -e 's/^/    # /;'
    # real	757m43.917s

    sed -e 's/^/    # /;' fb.rheMac10.chainEquCab3Link.txt
    # 1631389178 bases of 2936892733 (55.548%) in intersection
    sed -e 's/^/    # /;' fb.rheMac10.chainSynEquCab3Link.txt
    # 1576810063 bases of 2936892733 (53.690%) in intersection

    time (~/kent/src/hg/utils/automation/doRecipBest.pl  -load -workhorse=hgwdev -buildDir=`pwd` \
       \
       \
        rheMac10 equCab3) > rbest.log 2>&1

    grep -w real rbest.log | sed -e 's/^/    # /;'
    # real	230m53.590s

    sed -e 's/^/    # /;' fb.rheMac10.chainRBest.EquCab3.txt
    # 1553000153 bases of 2936892733 (52.879%) in intersection

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