#!/bin/csh -evf

wget -nc -P /work/cf189/runPairwiseAlignments https://hgdownload.soe.ucsc.edu/goldenPath/hg38/multiz100way/hg38.100way.nh

/hpc/group/vertgenlab/cl454/src/phast/phast/bin/tree_doctor -p jacJac1,micOch1,mesAur1,chiLan1,octDeg1,camFer1,orcOrc1,panHod1,capHir1,odoRosDiv1,lepWed1,oryAfe1,eleEdw1,chrAsi1,ficAlb2,anaPla1,amaVit1,falPer1,colLiv1,falChe1,araMac1,pseHum1,zonAlb1,pelSin1,cheMyd1,apaSpi1,hapBur1,astMex1,neoBri1,punNye1,xipMac1,lepOcu1,takFla1,mayZeb1,pteAle1,eptFus1,myoDav1,eriEur2,sorAra2,conCri1 hg38.100way.nh > hg38.60way.nh

sed -i -e 's/chrPic2/chrPic1/g' -e 's/tupChi1/tupBel1/g' -e 's/panTro4/panTro6/g' -e 's/susScr3/susScr11/g' -e 's/gorGor3/gorGor6/g' -e 's/rheMac3/rheMac10/g' -e 's/mm10/mm39/g' -e 's/xenTro7/xenTro10/g' -e 's/petMar2/petMar3/g' -e 's/canFam3/canFam4/g' -e 's/bosTau8/bosTau9/g' hg38.60way.nh

set allDists=/hpc/group/vertgenlab/cl454/src/phast/phast/bin/all_dists
set tree=/work/cf189/runPairwiseAlignments/hg38.60way.nh
set out=/work/cf189/runPairwiseAlignments/60wayTree.dists.txt
set species=/work/cf189/runPairwiseAlignments/species.list

$allDists $tree > $out
cat $out | cut -f1| grep -v "(total)" | uniq > $species
tail -2 $out | head -1 | cut -f2 >> $species

echo DONE 

