/* THIS HyPhy BATCH LANGUAGE FILE IS PROVIDED AS AN EXAMPLE/TOOL FOR THE 2nd EDITION OF 'The Phylogenetic Handbook' Written by Sergei L Kosakovsky Pond (spond@ucsd.edu) Art FY Poon (apoon@ucsd.edu) Simon DW Frost (sdfrost@ucsd.edu) */ RequireVersion ("0.9920060830"); VERBOSITY_LEVEL = -1; /*---------------------------------------------------------------------------------------------------------------------------------------------*/ fprintf (stdout, "\n\nThis example analysis fits the local MG94xREV model \n", "(separate alpha and beta on each branch) to a codon dataset,\n", "and computes several distance measures between sequences:\n", " - expected number of substitutions per codon\n", " - expected number of syn. substitutions per codon\n", " - expected number of nonsyn. substitutions per codon\n", " - dS\n", " - dN\n", "and provides the example contrasting the estimation of dN and dS\n", "between a pair of sequences based on the phylogenetic tree and\n", "direct pairwise estimation.\n"); ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+DIRECTORY_SEPARATOR+"Utility"+DIRECTORY_SEPARATOR+"DescriptiveStatistics.bf"); ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+DIRECTORY_SEPARATOR+"TemplateModels"+DIRECTORY_SEPARATOR+"chooseGeneticCode.def"); ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+DIRECTORY_SEPARATOR+"dSdNTreeTools.ibf"); ChoiceList (freqs, "Alignment", 1, SKIP_NONE, "Flu H5N1 HA", "Use the example Influenza H5N1 hemagglutinin alignment (5 sequences)", "Drospophila adh", "Use the example Drosophila ADH alignment (6 sequences).", "Custom", "Load your own alignment and tree."); if (freqs < 0) { return 0; } if (freqs == 2) { SetDialogPrompt ("Choose a nucleotide alignment"); DataSet ds = ReadDataFile (PROMPT_FOR_FILE); } else { if (freqs == 1) { DataSet ds = ReadDataFile (PATH_TO_CURRENT_BF + '/datasets/Drosophilia_adh.nex'); } else { DataSet ds = ReadDataFile (PATH_TO_CURRENT_BF + '/datasets/H5N1_HA_5.nex'); } } DataSetFilter filteredData = CreateFilter (ds,3,"","",GeneticCodeExclusions); SKIP_MODEL_PARAMETER_LIST = 1; modelDesc = "012345"; modelType = 0; ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+DIRECTORY_SEPARATOR+"TemplateModels"+DIRECTORY_SEPARATOR+"MG94custom.mdl"); SKIP_MODEL_PARAMETER_LIST = 0; ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+DIRECTORY_SEPARATOR+"queryTree.bf"); LikelihoodFunction theLnLik = (filteredData, givenTree); fprintf (stdout, "Fitting local MG94xREV to observed data... \n"); Optimize (res, theLnLik); nonStopCount = ModelMatrixDimension; ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+DIRECTORY_SEPARATOR+"Distances"+DIRECTORY_SEPARATOR+"CodonTools.def"); sSites = 0; nsSites = 0; synM = {nonStopCount,nonStopCount}; nonSynM = {nonStopCount,nonStopCount}; vertOnes = {nonStopCount,1}; horOnes = {1,nonStopCount}; for (h1 = 0; h1