###########################################################
#  Common subroutines to find the species from the        #
#    string (filename) and the gene from the gene header  #
#                                                         #
#   Written by Justin Elser                               #
#     Updated 9/2/10 for new species                      #
#                                                         #
#     Updated 6/16/11 for new species and added sub       #
#        to return retrieval info                         #
###########################################################

sub find_species {
	my $temp = $_[0];
	my $species;
	if ($temp =~ /Aegilops\_tauschii/) {
		$species = "Aegilops_tauschii";
	}elsif ($temp =~ /Amborella\_trichopoda/) {
		$species = "Amborella_trichopoda";
	}elsif ($temp =~ /Arabidopsis\_halleri/) {
		$species = "Arabidopsis_halleri";
	}elsif ($temp =~ /Arabidopsis\_lyrata/) {
		$species = "Arabidopsis_lyrata";
	}elsif ($temp =~ /Arabidopsis\_thaliana/) {
		$species = "Arabidopsis_thaliana";
	}elsif ($temp =~ /Arachis\_duranensis/) {
		$species = "Arachis_duranensis";
	}elsif ($temp =~ /Arachis\_ipaensis/) {
		$species = "Arachis_ipaensis";
	}elsif ($temp =~ /Asparagus\_officinalis/) {
		$species = "Asparagus_officinalis";
	}elsif ($temp =~ /Azolla/) {
		$species = "Azolla_filiculoides";
	}elsif ($temp =~ /Batrachochytrium/) {
		$species = "Batrachochytrium_dendrobatidis";
	}elsif ($temp =~ /Brachypodium\_distachyon/) {
		$species = "Brachypodium_distachyon";
	}elsif ($temp =~ /Brachypodium\_sylvaticum\.Corvallis/) {
		$species = "Brachypodium_sylvaticum.Corv";
	}elsif ($temp =~ /Brachypodium\_sylvaticum\.Greece/) {
		$species = "Brachypodium_sylvaticum.Greece";
	}elsif ($temp =~ /Brachypodium\_sylvaticum\.Spain/) {
		$species = "Brachypodium_sylvaticum.Spain";
	}elsif ($temp =~ /Brassica\_oleracea/) {
		$species = "Brassica_oleracea";
	}elsif ($temp =~ /Brassica\_rapa/) {
		$species = "Brassica_rapa";
	}elsif ($temp =~ /elegans/) {
		$species = "Caenorhabditis_elegans";
	}elsif ($temp =~ /Cajanus\_cajan/) {
		$species = "Cajanus_cajan";
	}elsif ($temp =~ /Cannabis\_sativa\.CRBRx/) {
		$species = "Cannabis_sativa.CRBRx";
	}elsif ($temp =~ /Cannabis\_sativa\.Purple/) {
		$species = "Cannabis_sativa.Purple.Kush";
	}elsif ($temp =~ /Capsella/) {
		$species = "Capsella_rubella";
	}elsif ($temp =~ /Capsicum\_annuum/) {
		$species = "Capsicum_annuum";
	}elsif ($temp =~ /Carica\_papaya/) {
		$species = "Carica_papaya";
	}elsif ($temp =~ /Castor_canadensis_/) {
		$species = "Castor_canadensis";
	}elsif ($temp =~ /Castor_canadensis.no.isoforms/) {
		$species = "Castor_canadensis.no.isoforms";
	}elsif ($temp =~ /Castor_canadensis.binpacker/) {
		$species = "Castor_canadensis.binpacker";
	}elsif ($temp =~ /Castor_canadensis.velvet/) {
		$species = "Castor_canadensis.velvet";
	}elsif ($temp =~ /Castor_canadensis.brent.proteins/) {
		$species = "Castor_canadensis.brent.proteins";
	}elsif ($temp =~ /Castor_canadensis.brent.transcripts/) {
		$species = "Castor_canadensis.brent.transcripts";
	}elsif ($temp =~ /Cavia_porcellus/) {
		$species = "Cavia_porcellus";
	}elsif ($temp =~ /Chlamy/) {
		$species = "Chlamydomonas_reinhardtii";
	}elsif ($temp =~ /Chondrus/) {
		$species = "Chondrus_crispus";
	}elsif ($temp =~ /Cicer\_arietinum/) {
		$species = "Cicer_arietinum";
	}elsif ($temp =~ /Citrullus\_lanatus/) {
		$species = "Citrullus_lanatus";
	}elsif ($temp =~ /Citrus\_clementina/) {
		$species = "Citrus_clementina";
	}elsif ($temp =~ /Citrus\_sinensis/) {
		$species = "Citrus_sinensis";
	}elsif ($temp =~ /Coffea\_canephora/) {;
		$species = "Coffea_canephora";
	}elsif ($temp =~ /Corchorus\_capsularis/) {
		$species = "Corchorus_capsularis";
	}elsif ($temp =~ /Corchorus\_olitorius/) {
		$species = "Corchorus_olitorius";
	}elsif ($temp =~ /Cornus_florida/) {
		$species = "Cornus_florida";
	}elsif ($temp =~ /Cucumis\_sativus/) {
		$species = "Cucumis_sativus";
	}elsif ($temp =~ /Danio/) {
		$species = "Danio_rerio";
	}elsif ($temp =~ /Dasypus_novemcinctus/) {
		$species = "Dasypus_novemcinctus";
	}elsif ($temp =~ /Dipodomys_ordii/) {
		$species = "Dipodomys_ordii";
	}elsif ($temp =~ /Drosophila/) {
		$species = "Drosophila_melanogaster";
	}elsif ($temp =~ /Durio/) {
		$species = "Durio_zibethinus";
	}elsif ($temp =~ /Echinops_telfairi/) {
		$species = "Echinops_telfairi";
	}elsif ($temp =~ /Ectocarpus/) {
		$species = "Ectocarpus_siliculosus";
	}elsif ($temp =~ /Elaphocordyceps\_capitata/) {
		$species = "Elaphocordyceps_capitata";
	}elsif ($temp =~ /Elaphocordyceps\_ophioglossoides/) {
		$species = "Elaphocordyceps_ophioglossoides";
	}elsif ($temp =~ /Elaphocordyceps\_paradoxa/) {
		$species = "Elaphocordyceps_paradoxa";
	}elsif ($temp =~ /Epichloe_festucae/) {
		$species = "Epichloe\_festucae";
	}elsif ($temp =~ /Erinaceus_europaeus/) {
		$species = "Erinaceus_europaeus";
	}elsif ($temp =~ /Erythranthe/) {
		$species = "Erythranthe_guttata";
	}elsif ($temp =~ /Escherichia\_coli/) {
		$species = "Escherichia_coli";
	}elsif ($temp =~ /Eucalyptus\_grandis/) {
		$species = "Eucalyptus_grandis";
	}elsif ($temp =~ /Fragaria/) {
		$species = "Fragaria_vesca";
	}elsif ($temp =~ /Fusarium_graminearum/) {
		$species = "Fusarium\_graminearum";
	}elsif ($temp =~ /Fusarium_oxysporum/) {
		$species = "Fusarium\_oxysporum.4287";
	}elsif ($temp =~ /Fusarium_verticillioides/) {
		$species = "Fusarium\_verticillioides";
	}elsif ($temp =~ /Gadus_morhua/) {
		$species = "Gadus\_morhua";
	}elsif ($temp =~ /Gasterosteus/) {
		$species = "Gasterosteus\_aculeatus";
	}elsif ($temp =~ /Glycine/) {
		$species = "Glycine_max";
	}elsif ($temp =~ /Gossypium\_raimondii/) {
		$species = "Gossypium_raimondii";
	}elsif ($temp =~ /Gossypium\_hirsutum/) {
		$species = "Gossypium_hirsutum";
	}elsif ($temp =~ /Homo\_sapiens/) {
		$species = "Homo_sapiens";
	}elsif ($temp =~ /Hordeum\_vulgare/) {
		$species = "Hordeum_vulgare";
	}elsif ($temp =~ /Humulus\_lupulus\.haplotig/) {
		$species = "Humulus_lupulus.haplotig";
	}elsif ($temp =~ /Humulus\_lupulus\.primary/) {
		$species = "Humulus_lupulus.primary";
	}elsif ($temp =~ /Ictidomys_tridecemlineatus/) {
		$species = "Ictidomys_tridecemlineatus";
	}elsif ($temp =~ /Jatropha/) {
		$species = "Jatropha_curcas";
	}elsif ($temp =~ /Kalanchoe\_laxiflora/) {
		$species = "Kalanchoe_laxiflora";
	}elsif ($temp =~ /Laccaria/) {
		$species = "Laccaria_bicolor";
	}elsif ($temp =~ /Leersia\_perrieri/) {
		$species = "Leersia_perrieri";
	}elsif ($temp =~ /Linum\_usitatissimum/) {
		$species = "Linum_usitatissimum";
	}elsif ($temp =~ /Macropus_eugenii/) {
		$species = "Macropus_eugenii";
	}elsif ($temp =~ /Magnaporthe/) {
		$species = "Magnaporthe_grisea";
	}elsif ($temp =~ /Malus/) {
		$species = "Malus_domestica";
	}elsif ($temp =~ /Manihot/) {
		$species = "Manihot_esculenta";
	}elsif ($temp =~ /Medicago/) {
		$species = "Medicago_truncatula";
	}elsif ($temp =~ /Mentha\_longifolia/) {
		$species = "Mentha_longifolia";
	}elsif ($temp =~ /Mimulus/) {
		$species = "Mimulus_guttatus";
	}elsif ($temp =~ /Mus\_musculus/) {
		$species = "Mus_musculus";
	}elsif ($temp =~ /Musa/) {
		$species = "Musa_acuminata";
	}elsif ($temp =~ /Mustela_putorius\.furo/) {
		$species = "Mustela_putorius.furo";
	}elsif ($temp =~ /Nectria\_haematococca/) {
		$species = "Nectria_haematococca";
	}elsif ($temp =~ /Nelumbo/) {
		$species = "Nelumbo_nucifera";
	}elsif ($temp =~ /Neurospora/) {
		$species = "Neurospora_crassa";
	}elsif ($temp =~ /Nicotiana/) {
		$species = "Nicotiana_attenuata";
	}elsif ($temp =~ /Nostoc/) {
		$species = "Nostoc_punctiforme.pcc.73102";
	}elsif ($temp =~ /Ocimum/) {
		$species = "Ocimum_tenuiflorum";
	}elsif ($temp =~ /Oncorhynchus\_mykiss/) {
		$species = "Oncorhynchus\_mykiss";
	}elsif ($temp =~ /Ornithorhynchus_anatinus/) {
		$species = "Ornithorhynchus_anatinus";
	}elsif ($temp =~ /Oryctolagus_cuniculus/) {
		$species = "Oryctolagus_cuniculus";
	}elsif ($temp =~ /Oryza\_australiensis/) {
		$species = "Oryza_australiensis";
	}elsif ($temp =~ /Oryza\_barthii/) {
		$species = "Oryza_barthii";
	}elsif ($temp =~ /Oryza\_brachyantha/) {
		$species = "Oryza_brachyantha";
	}elsif ($temp =~ /Oryza\_glaberrima/) {
		$species = "Oryza_glaberrima";
	}elsif ($temp =~ /Oryza\_glumipatula/) {
		$species = "Oryza_glumipatula";
	}elsif ($temp =~ /Oryza\_granulata/) {
		$species = "Oryza_granulata";
	}elsif ($temp =~ /Oryza\_kasalath/) {
		$species = "Oryza_kasalath";
	}elsif ($temp =~ /Oryza\_longistaminata/) {
		$species = "Oryza_longistaminata";
	}elsif ($temp =~ /Oryza\_meridionalis/) {
		$species = "Oryza_meridionalis";
	}elsif ($temp =~ /Oryza\_minuta/) {
		$species = "Oryza_minuta";
	}elsif ($temp =~ /Oryza\_nivara/) {
		$species = "Oryza_nivara";
	}elsif ($temp =~ /Oryza\_officinalis/) {
		$species = "Oryza_officinalis";
	}elsif ($temp =~ /Oryza\_punctata/) {
		$species = "Oryza_punctata";
	}elsif ($temp =~ /Oryza\_rufipogon/) {
		$species = "Oryza_rufipogon";
	}elsif ($temp =~ /Oryza\_sativa\.AUS\.kasalath/) {
		$species = "Oryza_sativa.AUS.kasalath";
	}elsif ($temp =~ /Oryza\_sativa\.AUS\.N22/) {
		$species = "Oryza_sativa.AUS.N22";
	}elsif ($temp =~ /Oryza\_sativa.indica\_/) {
		$species = "Oryza_sativa.indica";
	}elsif ($temp =~ /Oryza\_sativa.indica\.9311/) {
		$species = "Oryza_sativa.indica.9311.OGE";
	}elsif ($temp =~ /Oryza\_sativa.indica.IR29/) {
		$species = "Oryza_sativa.indica.IR29";
	}elsif ($temp =~ /Oryza\_sativa.indica.pokkali/) {
		$species = "Oryza_sativa.indica.pokkali";
	}elsif ($temp =~ /Oryza\_sativa.japonica.IRGSP/) {
		$species = "Oryza_sativa.japonica.IRGSP";
	}elsif ($temp =~ /Oryza\_sativa.japonica.MSU/) {
		$species = "Oryza_sativa.japonica.MSU";
	}elsif ($temp =~ /Oryza\_sativa.japonica.OGE/) {
		$species = "Oryza_sativa.japonica.OGE";
	}elsif ($temp =~ /Oryza\_sativa.japonica\_iplant/) {
		$species = "Oryza_sativa.japonica.iplant";
	}elsif ($temp =~ /Oryzias\_latipes/) {
		$species = "Oryzias\_latipes";
	}elsif ($temp =~ /Otolemur_garnettii/) {
		$species = "Otolemur_garnettii";
	}elsif ($temp =~ /Pan_troglodytes/) {
		$species = "Pan_troglodytes";
	}elsif ($temp =~ /Pediculus/) {
		$species = "Pediculus_humanus";
	}elsif ($temp =~ /Phaseolus\_vulgaris/) {
		$species = "Phaseolus_vulgaris";
	}elsif ($temp =~ /Phoenix/) {
		$species = "Phoenix_dactylifera";
	}elsif ($temp =~ /Phyllostachys/) {
		$species = "Phyllostachys_heterocycla";
	}elsif ($temp =~ /Physcomit/) {
		$species = "Physcomitrella_patens";
	}elsif ($temp =~ /Phytophthora/) {
		$species = "Phytophthora_infestans";
	}elsif ($temp =~ /Picea/) {
		$species = "Picea_abies";
	}elsif ($temp =~ /Pinus/) {
		$species = "Pinus_taeda";
	}elsif ($temp =~ /Populus\_trichocarpa\.ver2/) {
		$species = "Populus_trichocarpa.ver2";
	}elsif ($temp =~ /Populus\_trichocarpa/) {
		$species = "Populus_trichocarpa";
	}elsif ($temp =~ /Procavia_capensis/) {
		$species = "Procavia_capensis";
	}elsif ($temp =~ /Prunus/) {
		$species = "Prunus_persica";
	}elsif ($temp =~ /Pteropus_vampyrus/) {
		$species = "Pteropus_vampyrus";
	}elsif ($temp =~ /Rattus/) {
		$species = "Rattus_norvegicus";
	}elsif ($temp =~ /Rhizopus/) {
		$species = "Rhizopus_oryzae";
	}elsif ($temp =~ /Ricinus/) {
		$species = "Ricinus_communis";
	}elsif ($temp =~ /cerevisiae/) {
		$species = "Saccharomyces_cerevisiae";
	}elsif ($temp =~ /Salvia_hispanica/) {
		$species = "Salvia_hispanica";
	}elsif ($temp =~ /Salvia_splendens/) {
		$species = "Salvia_splendens";
	}elsif ($temp =~ /Salvinia\_cucullata/) {
		$species = "Salvinia_cucullata";
	}elsif ($temp =~ /pombe/) {
		$species = "Schizosaccharomyces_pombe";
	}elsif ($temp =~ /Selaginella/) {
		$species = "Selaginella_moellendorffii";
	}elsif ($temp =~ /Sesamum/) {
		$species = "Sesamum_indicum";
	}elsif ($temp =~ /Setaria/) {
		$species = "Setaria_italica";
	}elsif ($temp =~ /Solanum_tuberosum/) {
		$species = "Solanum_tuberosum";
	}elsif ($temp =~ /Solanum_lycopersicum/) {
		$species = "Solanum_lycopersicum";
	}elsif ($temp =~ /Sorex_araneus/) {
		$species = "Sorex_araneus";
	}elsif ($temp =~ /Sorghum/) {
		$species = "Sorghum_bicolor";
	}elsif ($temp =~ /Synechocystis/) {
		$species = "Synechocystis_sp.pcc.6803";
	}elsif ($temp =~ /Takifugu/) {
		$species = "Takifugu\_rubripes";
	}elsif ($temp =~ /Tarsius_syrichta/) {
		$species = "Tarsius_syrichta";
	}elsif ($temp =~ /Tetraodon/) {
		$species = "Tetraodon\_nigroviridis";
	}elsif ($temp =~ /Theobroma\_cacao/) {
		$species = "Theobroma_cacao";
	}elsif ($temp =~ /Tolypocladium\_inflatum/) {
		$species = "Tolypocladium_inflatum";
	}elsif ($temp =~ /Trichodesmium/) {
		$species = "Trichodesmium_erythraeum";
	}elsif ($temp =~ /Triticum\_aestivum/) {
		$species = "Triticum_aestivum";
	}elsif ($temp =~ /Triticum\_dicoccoides/) {
		$species = "Triticum_dicoccoides";
	}elsif ($temp =~ /Triticum\_monococcum\.DV92/) {
		$species = "Triticum_monococcum.DV92";
	}elsif ($temp =~ /Triticum\_monococcum\.G3116/) {
		$species = "Triticum_monococcum.G3116";
	}elsif ($temp =~/Triticum\_turgidum/) {
		$species = "Triticum_turgidum";
	}elsif ($temp =~ /Triticum\_urartu/) {
		$species = "Triticum_urartu";
	}elsif ($temp =~ /Utricularia/) {
		$species = "Utricularia_gibba";
	}elsif ($temp =~ /Vigna/) {
		$species = "Vigna_radiata";
	}elsif ($temp =~ /Vitis\_vinifera/) {
		$species = "Vitis_vinifera";
	}elsif ($temp =~ /Zea\_mays/) {
		$species = "Zea_mays";
	}elsif ($temp =~/Zoysia_japonica/) {
		$species = "Zoysia_japonica.Nagirizaki";
	}elsif ($temp =~/Zoysia_matrella/) {
		$species = "Zoysia_matrella.Wakaba";
	}elsif ($temp =~/Zoysia_pacifica/) {
		$species = "Zoysia_pacifica.Zanpa";
	}else {
		die "Error: Species can not be found from file name $temp!";
	}
	return $species;
}

sub find_gene {
	my $gene_header = $_[0];
	$gene_header =~ s/^>//; # strip off the header line identifier, if it isn't already
	my $species = $_[1];
	my $gene;
	if ($species eq "Aegilops_tauschii") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Amborella_trichopoda") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Arabidopsis_halleri") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Arabidopsis_lyrata") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Arabidopsis_thaliana") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Arachis_duranensis") {
		my ($gene_info, $desc) = split(/\s/, $gene_header);
		my ($spec, $random, $meth, $type, $spec2, $id, $transcript_no) = split(/\./, $gene_info);
		$gene = "$spec2" . "." . "$id" . "." . "$transcipt_no";
	}elsif ($species eq "Arachis_ipaensis") {
		my ($gene_info, $desc) = split(/\s/, $gene_header);
		my ($spec, $random, $meth, $type, $spec2, $id, $transcript_no) = split(/\./, $gene_info);
		$gene = "$spec2" . "." . "$id" . "." . "$transcipt_no";
	}elsif ($species eq "Arachis_ipaensis") {
		my ($gene_id, $desc) = split(/\s/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Asparagus_officinalis") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Azolla_filiculoides") {
		$gene = $gene_header;
	}elsif ($species eq "Batrachochytrium_dendrobatidis") {
		my ($transcript,$gene_id,$info) = split(/\s\|\s/, $gene_header);
		$gene = $transcript;
	}elsif ($species eq "Brachypodium_distachyon") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Brachypodium_sylvaticum.Corv") {
		my ($gene_id,$temp,$start,$end) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Brachypodium_sylvaticum.Greece") {
		$gene = $gene_header;
	}elsif ($species eq "Brachypodium_sylvaticum.Spain") {
		my ($gene_id,$temp,$start,$end) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Brassica_oleracea") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Brassica_rapa") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Caenorhabditis_elegans") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Cajanus_cajan") {
		my ($gene_info, $desc) = split(/\s/, $gene_header);
		my ($spec, $random, $meth, $type, $spec2, $spec_gene, $transcript_no) = split(/\./, $gene_info);
		$gene = "$spec2" . "." . "$spec_gene" . "." . "$transcript_no";
	}elsif ($species eq "Cannabis_sativa.Purple.Kush") {
		my ($gene_id, $strand, $start, $stop) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Cannabis_sativa.CRBRx") {
		my ($isoform, $gene_id, $tempj) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Capsella_rubella") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Capsicum_annuum") {
		my ($gene_id, $temp) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Carica_papaya") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Castor_canadensis") {
		my ($gene_info,$type,$gc,$gene_length) = split(/\s/, $gene_header);
		my ($gene_number,$gene_id) = split(/::/, $gene_info);
		my ($trinity_id, $m_number) = split(/\|/, $gene_id);
		$gene = $gene_number; #???
	}elsif ($species eq "Castor_canadensis.no.isoforms") {
		my ($gene_id,$m_number, $g_number) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Castor_canadensis.binpacker") {
		my ($m_id, $g_id, $temp) = split(/\s/, $gene_header);
		my ($root_id, $m_number) = split(/\|/, $m_id);
		$gene = "$root_id" . "_" . "$m_number";
	}elsif ($species eq "Castor_canadensis.velvet") {
		my ($m_id, $g_id, $temp) = split(/\s/, $gene_header);
		my ($root_id, $m_number) = split(/\|/, $m_id);
		$gene = "$root_id" . "_" . "$m_number";
	}elsif ($species eq "Castor_canadensis.brent.proteins") {
		my ($scaffold, $type, $coords) = split(/\s/, $gene_header);
		$gene = $scaffold;
	}elsif ($species eq "Castor_canadensis.brent.transcripts") {
		my ($scaffold, $type, $coords) = split(/\s/, $gene_header);
		$gene = $scaffold;
	}elsif ($species eq "Cavia_porcellus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Chlamydomonas_reinhardtii") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Chondrus_crispus") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Cicer_arietinum") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Citrullus_lanatus") {
		my ($gene_id, $type, $locus, $method) = split(/\s/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Citrus_clementina") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Citrus_sinensis") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Coffea_canephora") {
		my ($gene_id, $function) = split(/\s/,$gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Corchorus_capsularis") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Corchorus_olitorius") {
		my ($type, $gene_id, $gene_id_suffix, $function) = split(/[\|\s]+/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Cornus_florida") {
		#my ($spec, $contig, $start, $stop, $gene_id, $unknown, $type, $junk) = split(/\|\|/, $gene_header);
		$gene = $gene_header;
	}elsif ($species eq "Cucumis_sativus") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Danio_rerio") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Dasypus_novemcinctus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Dipodomys_ordii") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Drosophila_melanogaster") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Durio_zibethinus") {
		my ($gene_id, $type, $idk, $idk2, $quality) = split(/\s/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Echinops_telfairi") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Ectocarpus_siliculosus") {
		my ($gene_id,$temp) = split(/\s+/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Elaphocordyceps_capitata") {
		$gene = $gene_header;
	}elsif ($species eq "Elaphocordyceps_ophioglossoides") {
		$gene = $gene_header;
	}elsif ($species eq "Elaphocordyceps_paradoxa") {
		$gene = $gene_header;
	}elsif ($species eq "Epichloe_festucae") {
		my ($gene_id, $temp) = split(/\s/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Erinaceus_europaeus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Erythranthe_guttata") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Escherichia_coli") {
		$gene = $gene_header; #???
	}elsif ($species eq "Eucalyptus_grandis") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Fragaria_vesca") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Fusarium_graminearum") {
		my ($transcript, $gene_id, $info) = split(/\s\|\s/, $gene_header);
		$gene = $transcript;
	}elsif ($species eq "Fusarium_oxysporum.4287") {
		my ($transcript, $gene_id, $info) = split(/\s\|\s/, $gene_header);
		$gene = $transcript;
	}elsif ($species eq "Fusarium_verticillioides") {
		my ($transcript, $gene_id, $info) = split(/\s\|\s/, $gene_header);
		$gene = $transcript;
	}elsif ($species eq "Gadus_morhua") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
		$transcript =~ s/transcript\://;
		$gene = $transcript;
	}elsif ($species eq "Gasterosteus_aculeatus") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
		$transcript =~ s/transcript\://;
		$gene = $transcript;
	}elsif ($species eq "Glycine_max") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Gossypium_raimondii") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Gossypium_hirsutum") {
		$gene = $gene_header;
	}elsif ($species eq "Homo_sapiens") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Hordeum_vulgare") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Humulus_lupulus.haplotig") {
		$gene = $gene_header;
	}elsif ($species eq "Humulus_lupulus.primary") {
		$gene = $gene_header;
	}elsif ($species eq "Ictidomys_tridecemlineatus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform
	}elsif ($species eq "Jatropha_curcas") {
		my ($gene_id, $temp) = split(/\s/,$gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Kalanchoe_laxiflora") {
		my ($gene_id, $peptide, $locus, $ID, $annot) = split(/\s/,$gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Laccaria_bicolor") {
		my ($source,$spec,$gene_id,$scaffold) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Leersia_perrieri") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Linum_usitatissimum") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Macropus_eugenii") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform
	}elsif ($species eq "Magnaporthe_grisea") {
		my ($transcript,$gene_id,$temp) = split(/\s\|\s/, $gene_header);
		$gene = $transcript;
	}elsif ($species eq "Malus_domestica" ) {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Manihot_esculenta") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Medicago_truncatula") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Mentha_longifolia") {
		$gene = $gene_header;
	}elsif ($species eq "Mimulus_guttatus") {
		my ($gene_id,$transcript) = split(/\|/, $gene_header);
		$gene = $transcript;
	}elsif ($species eq "Mus_musculus") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Musa_acuminata") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Mustela_putorius.furo") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Nectria_haematococca") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
		$transcript =~ s/transcript\://;
		$gene = $transcript;
	}elsif ($species eq "Nelumbo_nucifera") {
		my ($gene_id, $temp) = split(/\s/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Neurospora_crassa") {
		my ($transcript,$gene_id,$temp) = split(/\s\|\s/,$gene_header);
		$gene = $transcript;
	}elsif ($species eq "Nicotiana_attenuata") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Nostoc_punctiforme.pcc.73102") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Ocimum_tenuiflorum") {
		my ($gene_id, $number) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Oncorhynchus_mykiss") {
		my ($gi, $number, $type, $gene_id, $function) = split(/\|/,$gene_header);
		$gene = $number;
	}elsif ($species eq "Ornithorhynchus_anatinus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Oryctolagus_cuniculus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Oryza_australiensis") {
		my ($gene_id, $strand, $start, $stop) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Oryza_barthii") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_brachyantha") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_glaberrima") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_glumipatula") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_granulata") {
		my ($gene_id, $strand, $start, $stop) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Oryza_kasalath") {
		$gene = $gene_header;
	}elsif ($species eq "Oryza_longistaminata") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_meridionalis") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_minuta") {
		my ($gene_id, $strand, $start, $stop) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Oryza_nivara") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_officinalis") {
		my ($gene_id, $strand, $start, $stop) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Oryza_punctata") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_rufipogon") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_sativa.indica") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_sativa.AUS.kasalath") {
		my ($gene_id, $strand, $start, $stop) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Oryza_sativa.AUS.N22") {
		$gene = $gene_header;
	}elsif ($species eq "Oryza_sativa.indica.9311.OGE") {
		$gene = $gene_header;
    }elsif ($species eq "Oryza_sativa.indica.IR29") {
    	my ($gene_id,$position, $start, $length) = split(/\|/, $gene_header);
    	$gene = $gene_id;
    }elsif ($species eq "Oryza_sativa.indica.pokkali") {
    	my ($gene_id,$position, $start, $length) = split(/\|/, $gene_header);
    	$gene = $gene_id;
	}elsif ($species eq "Oryza_sativa.japonica.iplant") {
		my ($gene_id,$chrom,$program,$function,$type) = split(/[\|\s]+/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Oryza_sativa.japonica.IRGSP") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Oryza_sativa.japonica.MSU") {
		my ($gene_id,$function) = split(/\s/,$gene_header);
        $gene = $gene_id;
    }elsif ($species eq "Oryza_sativa.japonica.OGE") {
		$gene = $gene_header;
	}elsif ($species eq "Oryzias_latipes") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
            $transcript =~ s/transcript\://;
            $gene = $transcript;
    }elsif ($species eq "Otolemur_garnettii") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Pan_troglodytes") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
    }elsif ($species eq "Phaseolus_vulgaris") {
    	$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Pediculus_humanus") {
		my ($gene_pa,$func,$func2,$unknown,$gene_id) = split(/[\|\s+]/, $gene_header);
		$gene = $gene_pa;
	}elsif ($species eq "Phoenix_dactylifera") {
		my ($gene_id, $locus_tag, $product, $strand) = split(/\s\[/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Phyllostachys_heterocycla") {
		my ($gene_id, $gene_model, $location, $dot, $strand, $dot2, $info) = split (/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Physcomitrella_patens") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Phytophthora_infestans") {
		my ($transcript, $gene_id, $function) = split(/\s\|\s/,$gene_header);
		$gene = $transcript;
	}elsif ($species eq "Picea_abies") {
		my ($gene_id, $confidence) = split(/\s/,$gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Pinus_taeda") {
		my ($gene_id,$type, $AED, $eAED, $qi) = split(/\s/,$gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Populus_trichocarpa.ver2") {
		my ($gene_id,$transcript_id) = split(/\|/,$gene_header);
		$gene = $transcript_id;
	}elsif ($species eq "Populus_trichocarpa") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Procavia_capensis") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Prunus_persica") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Pteropus_vampyrus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Rattus_norvegicus") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Rhizopus_oryzae") {
		my ($jgi,$temp,$num,$gene_id) = split(/\|/, $gene_header);
		$gene = $num;
	}elsif ($species eq "Ricinus_communis") {
		$gene = mart_gene($gene_header);
	}elsif ($species eq "Saccharomyces_cerevisiae") {
		$gene = ensembl_gene($gene_header);
    }elsif ($species eq "Salvia_hispanica") {
    	$gene = $gene_header;
    }elsif ($species eq "Salvia_splendens") {
    	$gene = $gene_header;
    }elsif ($species eq "Salvinia_cucullata") {
    	$gene = $gene_header;
	}elsif ($species eq "Schizosaccharomyces_pombe") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Selaginella_moellendorffii") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Sesamum_indicum") {
		$gene = $gene_header;
	}elsif ($species eq "Setaria_italica") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Solanum_lycopersicum") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Solanum_tuberosum") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Sorex_araneus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Sorghum_bicolor") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Synechocystis_sp.pcc.6803") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Takifugu_rubripes") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
        $transcript =~ s/transcript\://;
        $gene = $transcript;
    }elsif ($species eq "Tarsius_syrichta") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Tetraodon_nigroviridis") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Theobroma_cacao") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Tolypocladium_inflatum") {
		$gene = $gene_header;
	}elsif ($species eq "Trichodesmium_erythraeum") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Triticum_aestivum") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Triticum_dicoccoides") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Triticum_monococcum.DV92") {
		my ($gene_id,$temp) = split(/\|/,$gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Triticum_monococcum.G3116") {
		my ($gene_id,$temp) = split(/\|/,$gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Triticum_turgidum") {
		my ($gi,$temp,$gb,$gene_id,$strand,$start,$stop) = split(/[\|\s]+/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Triticum_urartu") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Utricularia_gibba") {
		my ($isoform, $gene_id) = split(/\|/, $gene_header);
		$gene = $isoform;
	}elsif ($species eq "Vigna_radiata") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Vitis_vinifera") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Zea_mays") {
		$gene = ensembl_gene($gene_header);
	}elsif ($species eq "Zoysia_japonica.Nagirizaki") {
		my ($gene_id, $location, $strand) = split(/\s/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Zoysia_matrella.Wakaba") {
		my ($gene_id, $location, $strand) = split(/\s/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Zoysia_pacifica.Zanpa") {
		my ($gene_id, $location, $strand) = split(/\s/, $gene_header);
		$gene = $gene_id;
		
	}else {
		die "Error: Gene id can not be found for species $species!";
	}
	return $gene;
}


sub find_gene_synonym {
	my $gene_header = $_[0];
	$gene_header =~ s/^>//; # strip off the header line identifier, if it isn't already
	my $species = $_[1];
	my $synonym;
	if ($species eq "Aegilops_tauschii") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Amborella_trichopoda") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Arabidopsis_halleri") {
		$gene = ensembl_synonym($gene_header);
	}elsif ($species eq "Arabidopsis_lyrata") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Arabidopsis_thaliana") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Asparagus_officinalis") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Batrachochytrium_dendrobatidis") {
		my ($transcript,$gene_id,$info) = split(/\s\|\s/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Brachypodium_distachyon") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Brassica_oleracea") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Brassica_rapa") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Caenorhabditis_elegans") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Cajanus_cajan") {
		my ($gene_id,$type,$locus,$temp) = split(/\s/, $gene_header);
		$synonym = $locus;
	}elsif ($species eq "Cannabis_sativa") {
		my ($isoform, $gene_id, $tempj) = split(/\s/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Capsella_rubella") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Carica_papaya") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Castor_canadensis") {
		my ($gene_info,$type,$gc,$gene_length) = split(/\s/, $gene_header);
		my ($gene_number,$gene_id) = split(/::/, $gene_info);
		my ($trinity_id, $m_number) = split(/\|/, $gene_id);
		$synonym = "$gene_number,$m_number";
	}elsif ($species eq "Castor_canadensis.no.isoforms") {
		my ($gene_id,$m_number, $g_number) = split(/\|/, $gene_header);
		$gene = $gene_id;
	}elsif ($species eq "Castor_canadensis.binpacker") {
		my ($m_id, $g_id, $temp) = split(/\s/, $gene_header);
		my ($root_id, $g_number) = split(/\|/, $m_id);
		$synonym = "$root_id" . "_" . "$g_number";
	}elsif ($species eq "Castor_canadensis.velvet") {
		my ($m_id, $g_id, $temp) = split(/\s/, $gene_header);
		my ($root_id, $g_number) = split(/\|/, $m_id);
		$synonym = "$root_id" . "_" . "$g_number";
	}elsif ($species eq "Cavia_porcellus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Chlamydomonas_reinhardtii") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Chondrus_crispus") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Cicer_arietinum") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Citrus_clementina") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Citrus_sinensis") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Corchorus_capsularis") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Corchorus_olitorius") {
		my ($type, $gene_id, $gene_id_suffix, $function) = split(/[\|\s]+/, $gene_header);
		$synonym = $gene_id_suffix;
	}elsif ($species eq "Cucumis_sativus") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Danio_rerio") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Dasypus_novemcinctus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Dipodomys_ordii") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Drosophila_melanogaster") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Echinops_telfairi") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Erinaceus_europaeus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Erythranthe_guttata") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Eucalyptus_grandis") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Fragaria_vesca") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Fusarium_graminearum") {
		my ($transcript, $gene_id, $info) = split(/\s\|\s/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Fusarium_oxysporum.4287") {
		my ($transcript, $gene_id, $info) = split(/\s\|\s/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Fusarium_verticillioides") {
		my ($transcript, $gene_id, $info) = split(/\s\|\s/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Gadus_morhua") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
		$transcript =~ s/transcript\://;
		$gene_id =~ s/gene\://;
		$peptide =~ s/\:pep//;
		$synonym = "$peptide,$gene_id";
	}elsif ($species eq "Gasterosteus_aculeatus") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
		$transcript =~ s/transcript\://;
		$gene_id =~ s/gene\://;
		$peptide =~ s/\:pep//;
		$synonym = "$peptide,$gene_id";
	}elsif ($species eq "Glycine_max") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Gossypium_raimondii") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Homo_sapiens") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Hordeum_vulgare") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Ictidomys_tridecemlineatus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Kalanchoe_laxiflora") {
		my ($gene_id, $peptide, $locus, $ID, $annot) = split(/\s/,$gene_header);
		$peptide =~ s/polypeptide\=//;
		$locus =~ s/locus\=//;
		$ID =~ s/ID\=//;
		$synonym = "$peptide,$locus,$ID";
	}elsif ($species eq "Leersia_perrieri") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Linum_usitatissimum") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Macropus_eugenii") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Magnaporthe_grissa") {
		my ($transcript,$gene_id,$temp) = split(/\s\|\s/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Malus_domestica" ) {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Manihot_esculenta") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Medicago_truncatula") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Mimulus_guttatus") {
		my ($gene_id,$transcript) = split(/\|/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Mus_musculus") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Musa_acuminata") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Mustela_putorius.furo") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Nectria_haematococca") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
		$transcript =~ s/transcript\://;
		$gene_id =~ s/gene\://;
		$peptide =~ s/\:pep//;
		$synonym = "$peptide,$gene_id";
	}elsif ($species eq "Neurospora_crassa") {
		my ($transcript,$gene_id,$temp) = split(/\s\|\s/,$gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Nicotiana_attenuata") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Nostoc_punctiforme.pcc.73102") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oncorhynchus_mykiss") {
		my ($gi, $number, $type, $gene_id, $function) = split(/\|/,$gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Ornithorhynchus_anatinus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Oryctolagus_cuniculus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Oryza_barthii") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_brachyantha") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_glaberrima") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_glumipatula") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_longistaminata") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_meridionalis") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_nivara") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_punctata") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryza_rufipogon") {
		$synonym = ensembl_synonym($gene_header);
    }elsif ($species eq "Oryza_sativa.indica") {
       $synonym = ensembl_synonym($gene_header);
    }elsif ($species eq "Oryza_sativa.japonica.IRGSP") {
        $synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Oryzias_latipes") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
        $transcript =~ s/transcript\://;
        $gene_id =~ s/gene\://;
        $peptide =~ s/\:pep//;
        $synonym = "$peptide,$gene_id";
    }elsif ($species eq "Otolemur_garnettii") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Pan_troglodytes") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Pediculus_humanus") {
		my ($gene_pa,$func,$func2,$unknown,$gene_id) = split(/[\|\s+]/, $gene_header);
		$gene_id =~ s/gene\://;
		$synonym = $gene_id;
	}elsif ($species eq "Phaseolus_vulgaris") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Phoenix_dactylifera") {
		my ($gene_id, $locus_tag, $product, $strand) = split(/\s\[/, $gene_header);
		$locus_tag =~ s/locus_tag=//;
		$locus_tag =~ s/"//g;
		$synonym = $locus_tag;
	}elsif ($species eq "Physcomitrella_patens") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Phytophthora_infestans") {
		my ($transcript, $gene_id, $function) = split(/\s\|\s/,$gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Populus_trichocarpa") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Procavia_capensis") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Prunus_persica") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Pteropus_vampyrus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Rattus_norvegicus") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Ricinus_communis") {
		$synonym = mart_synonym($gene_header);
	}elsif ($species eq "Saccharomyces_cerevisiae") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Schizosaccharomyces_pombe") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Selaginella_moellendorffii") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Setaria_italica") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Solanum_lycopersicum") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Solanum_tuberosum") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Sorex_araneus") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Sorghum_bicolor") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Synechocystis_sp.pcc.6803") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Takifugu_rubripes") {
		my ($peptide,$temp,$chrom,$gene_id,$transcript,$gene_type,$transcript_type) = split(/\s/,$gene_header);
        $transcript =~ s/transcript\://;
        $gene_id =~ s/gene\://;
        $peptide =~ s/\:pep//;
        $synonym = "$peptide,$gene_id";
    }elsif ($species eq "Tarsius_syrichta") {
		my ($isoform, $type, $scaffold, $temp_gene, $transcript, $gene_biotype, $transcript_biotype, $gene_symbol, $description) = split(/\s/, $gene_header);
		$temp_gene =~ s/gene\://;
		$transcript =~ s/transcript\://;
		$gene_symbol =~ s/gene_symbol\://;
		$synonym = "$temp_gene,$transcript,$gene_symbol";
	}elsif ($species eq "Tetraodon_nigroviridis") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Theobroma_cacao") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Trichodesmium_erythraeum") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Triticum_aestivum") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Triticum_dicoccoides") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Triticum_urartu") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Utricularia_gibba") {
		my ($isoform, $gene_id) = split(/\|/, $gene_header);
		$synonym = $gene_id;
	}elsif ($species eq "Vigna_radiata") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Vitis_vinifera") {
		$synonym = ensembl_synonym($gene_header);
	}elsif ($species eq "Zea_mays") {
		$synonym = ensembl_synonym($gene_header);
		
	}else {
		$synonym = "null";
	}
	return $synonym;
	
}

sub all_species_array {
	# return all species in an array
	my @spec_array;
	push (@spec_array, "Aegilops_tauschii");
	push (@spec_array, "Amborella_trichopoda");
	push (@spec_array, "Arabidopsis_lyrata");
	push (@spec_array, "Arabidopsis_thaliana");
	push (@spec_array, "Arachis_duranensis");
	push (@spec_array, "Arachis_ipaensis");
	push (@spec_array, "Batrachochytrium_dendrobatidis");
	push (@spec_array, "Brachypodium_distachyon");
	push (@spec_array, "Brachypodium_sylvaticum_Corvallis");
	push (@spec_array, "Brachypodium_sylvaticum_Greece");
	push (@spec_array, "Brachypodium_sylvaticum_Spain");
	push (@spec_array, "Brassica_oleracea");
	push (@spec_array, "Brassica_rapa");
	push (@spec_array, "Caenorhabditis_elegans");
	push (@spec_array, "Cajanus_cajan");
	push (@spec_array, "Cannabis_sativa.Purple.Kush");
	push (@spec_array, "Capsella_rubella");
	push (@spec_array, "Capsicum_annuum");
	push (@spec_array, "Carica_papaya");
	push (@spec_array, "Castor_canadensis");
	push (@spec_array, "Cavia_porcellus");
	push (@spec_array, "Chlamydomonas_reinhardtii");
	push (@spec_array, "Chondrus_crispus");
	push (@spec_array, "Cicer_arietinum");
	push (@spec_array, "Citrullus_lanatus");
	push (@spec_array, "Citrus_clementina");
	push (@spec_array, "Citrus_sinensis");
	push (@spec_array, "Coffea_canephora");
	push (@spec_array, "Cornus_florida");
	push (@spec_array, "Cucumis_sativus");
	push (@spec_array, "Danio_rerio");
	push (@spec_array, "Dasypus_novemcinctus");
	push (@spec_array, "Dipodomys_ordii");
	push (@spec_array, "Drosophila_melanogaster");
	push (@spec_array, "Echinops_telfairi");
	push (@spec_array, "Ectocarpus_siliculosus");
	push (@spec_array, "Elaphocordyceps_capitata");
	push (@spec_array, "Elaphocordyceps_ophioglossoides");
	push (@spec_array, "Elaphocordyceps_paradoxa");
	push (@spec_array, "Epichloe_festucae");
	push (@spec_array, "Erinaceus_europaeus");
	push (@spec_array, "Escherichia_coli");
	push (@spec_array, "Eucalyptus_grandis");
	push (@spec_array, "Fragaria_vesca");
	push (@spec_array, "Fusarium_graminearum");
	push (@spec_array, "Fusarium_oxysporum.4287");
	push (@spec_array, "Fusarium_verticillioides");
	push (@spec_array, "Gadus_morhua");
	push (@spec_array, "Gasterosteus_aculeatus");
	push (@spec_array, "Glycine_max");
	push (@spec_array, "Gossypium_raimondii");
	push (@spec_array, "Gossypium_hirsutum");
	push (@spec_array, "Homo_sapiens");
	push (@spec_array, "Hordeum_vulgare");
	push (@spec_array, "Ictidomys_tridecemlineatus");
	push (@spec_array, "Jatropha_curcas");
	push (@spec_array, "Kalanchoe_laxiflora");
	push (@spec_array, "Laccaria_bicolor");
	push (@spec_array, "Linum_usitatissimum");
	push (@spec_array, "Macropus_eugenii");
	push (@spec_array, "Magnaporthe_grissa");
	push (@spec_array, "Malus_domestica");
	push (@spec_array, "Manihot_esculenta");
	push (@spec_array, "Medicago_truncatula");
	push (@spec_array, "Mimulus_guttatus");
	push (@spec_array, "Mus_musculus");
	push (@spec_array, "Musa_acuminata");
	push (@spec_array, "Mustela_putorius.furo");
	push (@spec_array, "Nectria_haematococca");
	push (@spec_array, "Nelumbo_nucifera");
	push (@spec_array, "Neurospora_crassa");
	push (@spec_array, "Nostoc_punctiforme");
	push (@spec_array, "Oncorhynchus_mykiss");
	push (@spec_array, "Ornithorhynchus_anatinus");
	push (@spec_array, "Oryctolagus_cuniculus");
	push (@spec_array, "Oryza_australiensis");
	push (@spec_array, "Oryza_barthii");
	push (@spec_array, "Oryza_brachyantha");
	push (@spec_array, "Oryza_glaberrima");
	push (@spec_array, "Oryza_glumaepatula");
	push (@spec_array, "Oryza_granulata");
	push (@spec_array, "Oryza_kasalath");
	push (@spec_array, "Oryza_longistaminata");
	push (@spec_array, "Oryza_meridionalis");
	push (@spec_array, "Oryza_minuta");
	push (@spec_array, "Oryza_nivara");
	push (@spec_array, "Oryza_officinalis");
	push (@spec_array, "Oryza_punctata");
	push (@spec_array, "Oryza_rufipogon");
	push (@spec_array, "Oryza_sativa.indica.gramene");
	push (@spec_array, "Oryza_sativa.indica.iplant");
	push (@spec_array, "Oryza_sativa.indica.IR29");
	push (@spec_array, "Oryza_sativa.indica.pokkali");
	push (@spec_array, "Oryza_sativa.japonica.iplant");
	push (@spec_array, "Oryza_sativa.japonica.IRGSP");
	push (@spec_array, "Oryza_sativa.japonica.MSU");
	push (@spec_array, "Oryzias_latipes");
	push (@spec_array, "Otolemur_garnettii");
	push (@spec_array, "Pan_troglodytes");
	push (@spec_array, "Pediculus_humanus");
	push (@spec_array, "Phaseolus_vulgaris");
	push (@spec_array, "Phyllostachys_heterocycla");
	push (@spec_array, "Physcomitrella_patens");
	push (@spec_array, "Phytophthora_infestans");
	push (@spec_array, "Picea_abies");
	push (@spec_array, "Populus_trichocarpa");
	push (@spec_array, "Procavia_capensis");
	push (@spec_array, "Prunus_persica");
	push (@spec_array, "Pteropus_vampyrus");
	push (@spec_array, "Rattus_norvegicus");
	push (@spec_array, "Rhizopus_oryzae");
	push (@spec_array, "Ricinus_communis");
	push (@spec_array, "Saccharomyces_cerevisiae");
	push (@spec_array, "Salvia_hispancia.salba");
	push (@spec_array, "Salvia_splendens");
	push (@spec_array, "Schizosaccharomyces_pombe");
	push (@spec_array, "Selaginella_moellendorffii");
	push (@spec_array, "Setaria_italica");
	push (@spec_array, "Solanum_tuberosum");
	push (@spec_array, "Solanum_lycopersicum");
	push (@spec_array, "Sorex_araneus");
	push (@spec_array, "Sorghum_bicolor");
	push (@spec_array, "Synechocystis_pcc6803");
	push (@spec_array, "Takifugu_rubripes");
	push (@spec_array, "Tarsius_syrichta");
	push (@spec_array, "Tetraodon_nigroviridis");
	push (@spec_array, "Theobroma_cacao");
	push (@spec_array, "Tolypocladium_inflatum");
	push (@spec_array, "Trichodesmium_erythraeum");
	push (@spec_array, "Triticum_aestivum");
	push (@spec_array, "Triticum_monococcum.DV92");
	push (@spec_array, "Triticum_monococcum.G3116");
	push (@spec_array, "Triticum_turgidum");
	push (@spec_array, "Triticum_urartu");
	push (@spec_array, "Vitis_vinifera");
	push (@spec_array, "Zea_mays");
	
	return @spec_array;
}

sub retrieval_info {
	my $file = $_[0];
	$file =~ /([a-zA-Z]*\_+[a-zA-Z0-9.]+)\_((?:[a-zA-Z0-9+-.]+\_?)+)\_(\d+\_\d+\_\d+).fa/;
	my $species = $1;
	my $method = $2;
	my $date = $3;
	return ($method, $date);
}

sub find_taxon {
	my $species = $_[0];
	my %taxon_hash = (
		'Aegilops_tauschii', '37682',
		'Amborella_trichopoda', '13333',
		'Arabidopsis_halleri', '81970',
		'Arabidopsis_lyrata' , '59689',
		'Arabidopsis_thaliana', '3702',
		'Arachis_duranensis', '130453',
		'Arachis_ipaensis', '130454',
		'Asparagus_officinalis', '4686',
		'Azolla_filiculoides', '84609',
		'Batrachochytrium_dendrobatidis', '109871',
		'Brachypodium_distachyon', '15368',
		'Brachypodium_sylvaticum.Corv', '29664',
		'Brachypodium_sylvaticum.Greece', '29664',
		'Brachypodium_sylvaticum.Spain', '29664',
		'Brassica_oleracea', '3712',
		'Brassica_rapa' ,'3711',
		'Caenorhabditis_elegans', '6239',
		'Cajanus_cajan', '3821',
		'Cannabis_sativa.CRBRx', '3483',
		'Cannabis_sativa.Purple.Kush', '3483',
		'Capsella_rubella', '81985',
		'Capsicum_annuum', '4072',
		'Carica_papaya', '3649',
		'Chlamydomonas_reinhardtii', '3055',
		'Chondrus_crispus', '2769',
		'Cicer_arietinum', '3827',
		'Citrullus_lanatus', '3654',
		'Citrus_clementina', '85681',
		'Citrus_sinensis', '2711',
		'Coffea_canephora', '49390',
		'Corchorus_capsularis', '210143',
		'Corchorus_olitorius', '93759',
		'Cornus_florida', '4283',
		'Cucumis_sativus', '3659',
		'Danio_rerio', '7955',
		'Drosophila_melanogaster', '7227',
		'Durio_zibethinus', '66656',
		'Ectocarpus_siliculosus', '2880',
		'Elaphocordyceps_capitata', '45325',
		'Elaphocordyceps_ophioglossoides', '71617',
		'Elaphocordyceps_paradoxa', '94208',
		'Epichloe_festucae', '35717',
		'Erythranthe_guttata', '4155',
		'Escherichia_coli', '562',
		'Eucalyptus_grandis', '71139',
		'Fragaria_vesca', '57918',
		'Fusarium_graminearum', '5518',
		'Fusarium_oxysporum.4287', '660037',
		'Fusarium_verticillioides', '117187',
		'Gadus_morhua', '8049',
		'Gasterosteus_aculeatus', '69293',
		'Glycine_max', '3847',
		'Gossypium_raimondii', '29730',
		'Gossypium_hirsutum', '3635',
		'Homo_sapiens', '9606',
		'Hordeum_vulgare', '4513',
		'Humulus_lupulus.haplotig', '3486',
		'Humulus_lupulus.primary', '3486',
		'Jatropha_curcas', '180498',
		'Kalanchoe_laxiflora', '1670617',
		'Laccaria_bicolor', '29883',
		'Leersia_perrieri', '77586',
		'Linum_usitatissimum', '4006',
		'Magnaporthe_grissa', '148305',
		'Malus_domestica', '3750',
		'Manihot_esculenta', '3983',
		'Medicago_truncatula', '3880',
		'Mentha_longifolia', '38859',
		'Mimulus_guttatus', '4155',
		'Mus_musculus', '10090',
		'Musa_acuminata', '4641',
		'Nectria_haematococca', '140110',
		'Nelumbo_nucifera', '4432',
		'Neurospora_crassa', '5141',
		'Nicotiana_attenuata', '49451',
		'Nostoc_punctiforme.pcc.73102', '272131',
		'Nostoc_punctiforme', '272131',
		'Ocimum_tenuiflorum', '204149',
		'Oncorhynchus_mykiss', '8022',
		'Oryza_australiensis', '4532',
		'Oryza_barthii', '65489',
		'Oryza_brachyantha', '4533',
		'Oryza_glaberrima', '4538',
		'Oryza_glumipatula', '40148',
		'Oryza_granulata', '110450',
		'Oryza_kasalath', '4527',
		'Oryza_longistaminata', '4528',
		'Oryza_meridionalis', '40149',
		'Oryza_minuta', '63629',
		'Oryza_nivara', '4536',
		'Oryza_officinalis', '4535',
		'Oryza_punctata', '4537',
		'Oryza_rufipogon', '4529',
		'Oryza_sativa.AUS.kasalath', '1736659',
		'Oryza_sativa.AUS.N22', '1736659',
		'Oryza_sativa.indica', '39946',
		'Oryza_sativa.indica.9311.OGE', '39946',
		'Oryza_sativa.indica.gramene', '39946',
		'Oryza_sativa.indica.iplant', '39946',
		'Oryza_sativa.indica.IR29', '39946',
		'Oryza_sativa.indica.pokkali', '39946',
		'Oryza_sativa.japonica.iplant', '39947',
		'Oryza_sativa.japonica.IRGSP', '39947',
		'Oryza_sativa.japonica.MSU', '39947',
		'Oryza_sativa.japonica.OGE', '39947',
		'Oryzias_latipes', '8090',
		'Pediculus_humanus', '121225',
		'Phaseolus_vulgaris', '3885',
		'Phoenix_dactylifera', '42345',
		'Phyllostachys_heterocycla', '38705',
		'Physcomitrella_patens', '3218',
		'Phytophthora_infestans', '4787',
		'Picea_abies', '3329',
		'Pinus_taeda', '3352',
		'Populus_trichocarpa', '3694',
		'Populus_trichocarpa.ver3', '3694',
		'Prunus_persica', '3760',
		'Rattus_norvegicus', '10116',
		'Rhizopus_oryzae', '64495',
		'Ricinus_communis', '3988',
		'Saccharomyces_cerevisiae', '4932',
		'Salvia_hispanica', '49212',
		'Salvia_hispancia.salba', '49212',
		'Salvia_splendens', '180675',
		'Salvinia_cucullata', '32188',
		'Schizosaccharomyces_pombe', '4896',
		'Selaginella_moellendorffii', '88036',
		'Setaria_italica', '4555',
		'Solanum_lycopersicum', '4081',
		'Solanum_tuberosum', '4113',
		'Sorghum_bicolor', '4558',
		'Synechocystis_sp.pcc.6803', '1148',
		'Takifugu_rubripes', '31033',
		'Tetraodon_nigroviridis', '99883',
		'Theobroma_cacao', '3641',
		'Tolypocladium_inflatum', '29910',
		'Trichodesmium_erythraeum', '1206',
		'Triticum_aestivum', '4565',
		'Triticum_dicoccoides', '85692',
		'Triticum_monococcum.DV92', '4568',
		'Triticum_monococcum.G3116', '4568',
		'Triticum_turgidum', '4571',
		'Triticum_urartu', '4572',
		'Utricularia_gibba', '13748',
		'Vigna_radiata', '157791',
		'Vitis_vinifera', '29760',
		'Zea_mays', '4577',
		'Zoysia_japonica.Nagirizaki', '309978',
		'Zoysia_matrella.Wakaba', '38722',
		'Zoysia_pacifica.Zanpa', '1070856',
		);
	my $taxon = $taxon_hash{$species};
	return $taxon;
}	

sub ensembl_gene {
		my $gene_header = $_[0];
		my ($gene, $type, $contig, $gene_alias, $transcript, $biotype, $description) = split(/\s/, $gene_header);
		$transcript =~ s/transcript\://;
		return $transcript;
}

sub ensembl_synonym {
		my $gene_header = $_[0];
		my ($gene, $type, $contig, $gene_alias, $transcript, $biotype, $description) = split(/\s/, $gene_header);
        $gene_alias =~ s/gene\://;
        my $synonym = "$gene,$gene_alias";
		return $synonym;
}

sub mart_gene {
		my $gene_header = $_[0];
		my ($gene, $transcript, $synonyms) = split(/\|/, $gene_header);
		return $transcript;
}

sub mart_synonym {
		my $gene_header = $_[0];
		my ($gene, $transcript, $synonyms) = split(/\|/, $gene_header);
		if ($synonyms eq "") {
				my $synonym = "$gene";
				return $synonym;
		}else{
				my $synonym = "$gene,$synonyms";
				return $synonym;
		}
}


# subroutine to filter out non-canonical transcripts
sub trans_filter {
		my $species = $_[0];
		my $gene = $_[1];
		my $is_transcript = 1;
		if($species ne "Jatropha_curcas") { #Jatropha gene ids are .10, .20, .30, etc...
			if ($gene =~ /\.[2-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.1[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.2[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.3[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.4[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.5[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.6[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.7[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.8[0-9]$/) {$is_transcript = 0;}
			elsif ($gene =~ /\.9[0-9]$/) {$is_transcript = 0;}
		}
				
		# Maize genes that are not the first transcript
		if($species eq "Zea_mays") {
				if ($gene !~ /\_T001$/) {$is_transcript = 0;}
		}
				
		# Theobroma genes that are not the first transcript
		if($species eq "Theobroma_cacao") {
				if ($gene =~ /t[2-9]$/) {$is_transcript = 0;}
				elsif ($gene =~ /t1[0-9]$/) {$is_transcript = 0;}
		}
		

		# Salvia hispanica genes should all be counted
		if($species eq "Salvia_hispanica") {
			$is_transcript = 1;
		}

return $is_transcript;
}

1;
