#!/bin/sh

if [ $# -ne 1 ]; then
    echo "usage: ./commonNames.sh <Nway.nh>"
    echo "Renames the names from UCSC database names to common names."
    echo "This depends upon the exact UCSC database names present in the"
    echo ".nh file.  Last updated to work with the 96way.nh file."
    exit 255
fi

export F=$1

/cluster/bin/phast/tree_doctor \
-r \
"hg19 -> Human ;
hg38 -> Human ;
panTro3 -> Chimp ;
panTro4 -> Chimp ;
panPan1 -> Bonobo ;
gorGor3 -> Gorilla ;
ponAbe2 -> Orangutan ;
macFas5 -> Crab_eating_macaque ;
rheMac2 -> Rhesus ;
rheMac3 -> Rhesus ;
chlSab1 -> Green_monkey ;
chlSab2 -> Green_monkey ;
nomLeu1 -> Gibbon ;
nomLeu3 -> Gibbon ;
papHam1 -> Baboon ;
saiBol1 -> Squirrel_monkey ;
calJac3 -> Marmoset ;
tarSyr1 -> Tarsier ;
micMur1 -> Mouse_lemur ;
otoGar1 -> Bushbaby ;
otoGar3 -> Bushbaby ;
tupChi1 -> Chinese_tree_shrew ;
tupBel1 -> Tree_shrew ;
galVar1 -> Malayan_flying_lemur ;
criGri1 -> Chinese_hamster ;
mesAur1 -> Golden_hamster ;
perManBai1 -> Prairie_deer_mouse ;
mm9 -> Mouse ;
mm10 -> Mouse ;
rn4 -> Rat ;
rn5 -> Rat ;
octDeg1 -> Brush_tailed_rat ;
dipOrd1 -> Kangaroo_rat ;
micOch1 -> Prairie_vole ;
hetGla1 -> Naked_mole_rat ;
hetGla2 -> Naked_mole_rat ;
cavPor3 -> Guinea_pig ;
jacJac1 -> Lesser_Egyptian_jerboa ;
nanGal1 -> Upper_Galilee_mountains_blind_mole_rat ;
speTri1 -> Squirrel ;
speTri2 -> Squirrel ;
musFur1 -> Ferret ;
chiLan1 -> Chinchilla ;
oryCun2 -> Rabbit ;
ochPri2 -> Pika ;
ochPri3 -> Pika ;
susScr2 -> Pig ;
susScr3 -> Pig ;
vicPac1 -> Alpaca ;
vicPac2 -> Alpaca ;
turTru1 -> Dolphin ;
turTru2 -> Dolphin ;
panHod1 -> Tibetan_antelope ;
oviAri1 -> Sheep ;
oviAri3 -> Sheep ;
capHir1 -> Domestic_goat ;
camFer1 -> Bactrian_camel ;
bosTau6 -> Cow ;
bosTau7 -> Cow ;
bosMut1 -> Wild_yak ;
bubBub1 -> Water_buffalo ;
equCab2 -> Horse ;
equPrz1 -> Przewalski_horse ;
cerSim1 -> White_rhinoceros ;
felCat4 -> Cat ;
felCat5 -> Cat ;
panTig1 -> Amur_tiger ;
canFam2 -> Dog ;
canFam3 -> Dog ;
canLup1 -> Gray_wolf ;
ailMel1 -> Panda ;
ursMar1 -> Polar_bear ;
myoDav1 -> David_s_myotis ;
myoBra1 -> Brand_s_bat ;
myoLuc1 -> Microbat ;
myoLuc2 -> Microbat ;
eidHel1 -> Straw_colored_fruit_bat ;
pteAle1 -> Black_flying_fox ;
pteVam1 -> Megabat ;
rhiFer1 -> Greater_horseshoe_bat ;
ptePar1 -> Parnell_s_mustached_bat ;
megLyr1 -> Indian_false_vampire ;
eptFus1 -> Big_brown_bat ;
odoRosDiv1 -> Pacific_walrus ;
lepWed1 -> Weddell_seal ;
eriEur1 -> Hedgehog ;
eriEur2 -> Hedgehog ;
conCri1 -> Star_nosed_mole ;
sorAra1 -> Shrew ;
sorAra2 -> Shrew ;
loxAfr3 -> Elephant ;
eleEdw1 -> Cape_elephant_shrew ;
oryAfe1 -> Aardvark ;
chrAsi1 -> Cape_golden_mole ;
orcOrc1 -> Killer_whale ;
phyCat1 -> Sperm_whale ;
balAcu1 -> Minke_whale ;
proCap1 -> Rock_hyrax ;
echTel1 -> Tenrec ;
echTel2 -> Tenrec ;
dasNov2 -> Armadillo ;
dasNov3 -> Armadillo ;
triMan1 -> Manatee ;
choHof1 -> Sloth ;
macEug2 -> Wallaby ;
sarHar1 -> Tasmanian_devil ;
monDom5 -> Opossum ;
ornAna1 -> Platypus ;
lepDis1 -> Cuckoo_roller ;
merNub1 -> Northern_carmine_bee_eater ;
pelCri1 -> Dalmatian_pelican ;
phaCar1 -> Bar_tailed_trogon ;
phaLep1 -> White_tailed_tropicbird ;
nipNip1 -> Crested_ibis;
pteGut1 -> Yellow_throated_sandgrouse ;
egrGar1 -> Little_egret ;
pygAde1 -> Adelie_penguin ;
aptFor1 -> Emperor_penguin ;
carCri1 -> Red_legged_seriema ;
mesUni1 -> Brown_roatelo ;
eurHel1 -> Sunbittern ;
balPav1 -> Crowned_crain ;
chlUnd1 -> Houbara_bustard ;
colLiv1 -> Rock_pigeon ;
apaVit1 -> Rock_pigeon ;
phoRub1 -> American_flamingo ;
opiHoa1 -> Hoatzin ;
tauEry1 -> Red_crested_turaco ;
fulGla1 -> Northern_fulmar ;
chaVoc1 -> Killdeer ;
calAnn1 -> Anna_s_hummingbird ;
cucCan1 -> Common_cuckoo ;
pseHum1 -> Tibetan_ground_jay ;
gavSte1 -> Red_throated_loon ;
capCar1 -> Chuck_will_s_widow ;
zonAlb1 -> White_throated_sparrow ;
geoFor1 -> Medium_ground_finch ;
ficAlb1 -> Collared_flycatcher ;
ficAlb2 -> Collared_flycatcher ;
amaVit1 -> Puerto_Rican_parrot ;
araMac1 -> Scarlet_macaw ;
falChe1 -> Saker_falcon ;
aquChr1 -> Golden_eagle ;
halAlb1 -> White_tailed_eagle ;
manVit1 -> Golden_collared_manakin ;
corBra1 -> American_crow ;
acaChl1 -> Rifleman ;
falPer1 -> Peregrine_falcon ;
melUnd1 -> Budgerigar ;
anaPla1 -> Mallard_duck ;
tytAlb1 -> Barn_owl ;
picPub1 -> Downy_woodpecker ;
strCam1 -> Ostrich ;
tinGut1 -> White_throated_tinamou ;
melGal1 -> Turkey ;
colStr1 -> Speckled_mousebird ;
galGal3 -> Chicken ;
galGal4 -> Chicken ;
cotJap1 -> Japanese_quail ;
serCan1 -> Canary ;
taeGut1 -> Zebra_finch ;
taeGut2 -> Zebra_finch ;
allMis1 -> American_alligator ;
allSin1 -> Chinese_alligator ;
croPor1 -> Crocodile ;
gavGan1 -> Gharial ;
latCha1 -> Coelacanth ;
stePar1 -> Bicolor_damselfish ;
dicLab1 -> European_sea_bass ;
pytBiv1 -> Burmese_python ;
anoCar2 -> Lizard ;
cheMyd1 -> Green_seaturtle ;
apaSpi1 -> Spiny_softshell_turtle ;
pelSin1 -> Chinese_softshell_turtle ;
chrPic1 -> Painted_turtle ;
chrPic2 -> Painted_turtle ;
xenTro3 -> Frog_X_tropicalis ;
xenTro4 -> Frog_X_tropicalis ;
xenTro7 -> Frog_X_tropicalis ;
lepOcu1 -> Spotted_gar ;
tetNig1 -> Tetraodon ;
tetNig2 -> Tetraodon ;
fr2 -> Fugu ;
fr3 -> Fugu ;
takFla1 -> Yellowbelly_pufferfish ;
oreNil1 -> Nile_tilapia ;
oreNil2 -> Nile_tilapia ;
hapBur1 -> Burton_s_mouthbreeder ;
cynSem1 -> Tongue sole ;
neoBri1 -> Princess_of_Burundi ;
mayZeb1 -> Zebra_mbuna ;
punNye1 -> Pundamilia_nyererei ;
sebNig1 -> Tiger_fockfish ;
sebRub1 -> Flag_fockfish ;
gasAcu1 -> Stickleback ;
oryLat2 -> Medaka ;
xipMac1 -> Southern_platyfish ;
angJap1 -> Japanese_eel ;
danRer7 -> Zebrafish ;
astMex1 -> Mexican_tetra ;
poeFor1 -> Amazon_molly ;
poeRet1 -> Guppy ;
gadMor1 -> Atlantic_cod ;
lipVex1 -> Yangtze_river_dolphin ;
calMil1 -> Elephant_shark ;
letCam1 -> Arctic_lamprey ;
petMar1 -> Lamprey ;
petMar2 -> Lamprey ;" \
	${F} | sed -e "s/X_trop/X._trop/; s/Burton_s/Burton's/; s/Brand_s/Brand's/; s/David_s/David's/; s/Parnell_s/Parnell's/; s/will_s/will's/; s/Anna_s/Anna's/; s/Star_nosed/Star-nosed/; s/00*)/)/g; s/00*,/,/g"
