From cdf0690f9df6f7b0dbf32c9559578178b16f99b9 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Fri, 10 Nov 2017 09:32:39 -0500 Subject: [PATCH 01/24] Updated LEISR rate reporting in JSON to have identical format to other site-level methods, like FEL, MEME, etc. --- res/TemplateBatchFiles/LEISR.bf | 7 ++--- .../libv3/tasks/estimators.bf | 4 +-- tests/hbltests/libv3/data/dat.nuc | 30 +++++++++---------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/res/TemplateBatchFiles/LEISR.bf b/res/TemplateBatchFiles/LEISR.bf index 50bf79840..8ff5cb17c 100644 --- a/res/TemplateBatchFiles/LEISR.bf +++ b/res/TemplateBatchFiles/LEISR.bf @@ -155,7 +155,6 @@ leisr.table_output_options = {terms.table_options.header : TRUE, terms.table_opt leisr.table_headers = {{"MLE", "Relative rate estimate at a site"} {"Lower", "Lower bound of 95% profile likelihood CI"} {"Upper", "Upper bound of 95% profile likelihood CI"}}; -//console.log(leisr.alignment_info [terms.data.sites]); leisr.site_results = {leisr.alignment_info [terms.data.sites], Rows (leisr.table_headers)}; leisr.site_patterns = alignments.Extract_site_patterns (leisr.filter_names[0]); @@ -338,9 +337,9 @@ lfunction leisr.store_results (node, result, arguments) { // JSON-related //console.log(_site_index_); - //leisr.site_results[_site_index_][0] = (leisr.rate_estimates[_site_index_+1])[terms.fit.MLE]; - //leisr.site_results[_site_index_][1] = (leisr.rate_estimates[_site_index_+1])[terms.lower_bound]; - //leisr.site_results[_site_index_][2] = (leisr.rate_estimates[_site_index_+1])[terms.upper_bound]; + leisr.site_results[_site_index_][0] = (leisr.rate_estimates[_site_index_+1])[terms.fit.MLE]; + leisr.site_results[_site_index_][1] = (leisr.rate_estimates[_site_index_+1])[terms.lower_bound]; + leisr.site_results[_site_index_][2] = (leisr.rate_estimates[_site_index_+1])[terms.upper_bound]; " ); diff --git a/res/TemplateBatchFiles/libv3/tasks/estimators.bf b/res/TemplateBatchFiles/libv3/tasks/estimators.bf index 5611e5fe1..05842380b 100644 --- a/res/TemplateBatchFiles/libv3/tasks/estimators.bf +++ b/res/TemplateBatchFiles/libv3/tasks/estimators.bf @@ -371,7 +371,7 @@ lfunction estimators.TraverseLocalParameters (likelihood_function_id, model_desc /** - * @name estimators.ApplyExistingEstimates + * @name * @param {String} likelihood_function_id * @param {Dictionary} model_descriptions * @param {Matrix} initial_values @@ -614,7 +614,7 @@ lfunction estimators.CreateLFObject (context, data_filter, tree, model_template, for (i = 0; i < components; i += 1) { lf_components[2 * i] = filters[i]; DataSetFilter ^ (filters[i]) = CreateFilter( ^ (data_filter[i]), 1); - } + } user_model_id = context + ".user_model"; utility.ExecuteInGlobalNamespace ("`user_model_id` = 0"); diff --git a/tests/hbltests/libv3/data/dat.nuc b/tests/hbltests/libv3/data/dat.nuc index 516ec504c..8a70180f9 100644 --- a/tests/hbltests/libv3/data/dat.nuc +++ b/tests/hbltests/libv3/data/dat.nuc @@ -1,31 +1,31 @@ >t8 -GACAAGTACC +GACAAGTACCCCCC >t9 -AATAGGTTAA +AATAGGTTAATTTT >t6 -AAGCGTAGAC +AAGCGTAGACCCCC >t7 -GGCCATCACA +GGCCATCACATTTT >t4 -GGGCAGTAAT +GGGCAGTAATCCCC >t5 -ACCCTGGCGT +ACCCTGGCGTTTTT >t2 -GCTCCGTACA +GCTCCGTACAAAAA >t3 -AGCATTACGA +AGCATTACGATTTT >t1 -GGGCCGTGAT +GGGCCGTGATTTTT >t14 -GGCGGTGTTC +GGCGGTGTTCAAAA >t15 -TCGATTCCGT +TCGATTCCGTAAAA >t10 -GCTCCGCATA +GCTCCGCATAAAAA >t11 -GGCAATATTA +GGCAATATTACCCC >t12 -AGAGATCCTT +AGAGATCCTTCCCC >t13 -GGCCATCACA +GGCCATCACACCCC (((t12:0.6007418204,(((t13:0.02560783178,t7:0.06241315883):0.3850171629,((t1:0.3803801907,t4:0.2644045493):0.288204158,((t8:0.2050027882,(t10:0.2882345759,t2:0.2495629364):0.4606286683):0.5220576057,t5:0.8048256312):0.05435458641):0.2048651455):0.4364210158,(t6:0.5203341169,t9:0.4957795972):0.9166075331):0.5339687597):0.2889535469,(t15:0.8320546721,t14:0.7063525459):0.2664719955):0.3073638263,(t3:0.4359256458,t11:0.7989921882):0.04232083797); From bb9e4d48c29b49943fd5bbe6f8b0cca80980182d Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Fri, 10 Nov 2017 10:36:02 -0500 Subject: [PATCH 02/24] Branch attributes JSON section now identical; was improperly nested before --- res/TemplateBatchFiles/LEISR.bf | 45 +++++++++++++-------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/res/TemplateBatchFiles/LEISR.bf b/res/TemplateBatchFiles/LEISR.bf index 8ff5cb17c..e70a62054 100644 --- a/res/TemplateBatchFiles/LEISR.bf +++ b/res/TemplateBatchFiles/LEISR.bf @@ -20,6 +20,8 @@ LoadFunctionLibrary("libv3/models/DNA/JC69.bf"); LoadFunctionLibrary("libv3/models/protein.bf"); LoadFunctionLibrary("libv3/models/protein/empirical.bf"); +// for JSON storage compatibility +LoadFunctionLibrary("SelectionAnalyses/modules/io_functions.ibf"); /*------------------------------------------------------------------------------*/ @@ -40,14 +42,14 @@ io.DisplayAnalysisBanner(leisr.analysis_description); /***************************************** LOAD DATASET **********************************************************/ SetDialogPrompt ("Specify a multiple sequence alignment file"); -leisr.alignment_info = alignments.ReadNucleotideDataSet ("leisr.dataset", NOne); +leisr.alignment_info = alignments.ReadNucleotideDataSet ("leisr.dataset", None); -name_mapping = leisr.alignment_info[utility.getGlobalValue("terms.data.name_mapping")]; -if (None == name_mapping) { - name_mapping = {}; - utility.ForEach (alignments.GetSequenceNames ("leisr.dataset"), "_value_", "`&name_mapping`[_value_] = _value_"); +leisr.name_mapping = leisr.alignment_info[utility.getGlobalValue("terms.data.name_mapping")]; +if (None == leisr.name_mapping) { + leisr.name_mapping = {}; + utility.ForEach (alignments.GetSequenceNames ("leisr.dataset"), "_value_", "`&leisr.name_mapping`[_value_] = _value_"); } -leisr.partitions_and_trees = trees.LoadAnnotatedTreeTopology.match_partitions (leisr.alignment_info[utility.getGlobalValue("terms.data.partitions")], name_mapping); +leisr.partitions_and_trees = trees.LoadAnnotatedTreeTopology.match_partitions (leisr.alignment_info[utility.getGlobalValue("terms.data.partitions")], leisr.name_mapping); leisr.partition_count = Abs (leisr.partitions_and_trees); io.CheckAssertion ("leisr.partition_count==1", "This analysis can only handle a single partition"); @@ -268,10 +270,14 @@ leisr.json_content = { terms.json.input : } }, terms.json.MLE : {terms.json.headers : leisr.table_headers, - terms.json.content : {"0":leisr.site_results}}, - terms.json.branch_attributes: leisr.alignment_wide_MLES[terms.branch_length], - terms.json.attribute :{ leisr.baseline_model_name: {terms.json.attribute_type: terms.branch_length}} - }; + terms.json.content : {"0":leisr.site_results} + } + }; +selection.io.json_store_branch_attribute(leisr.json_content, utility.getGlobalValue ("terms.original_name"), utility.getGlobalValue ("terms.json.node_label"), -1, 0, utility.getGlobalValue ("leisr.name_mapping")); +selection.io.json_store_branch_attribute(leisr.json_content, utility.getGlobalValue ("leisr.baseline_model_name"), utility.getGlobalValue ("terms.branch_length"), 0, 0, + selection.io.extract_branch_info((leisr.alignment_wide_MLES[terms.branch_length])[0], "selection.io.branch.length") + ); + io.SpoolJSON (leisr.json_content, leisr.alignment_info[terms.data.file] + ".LEISR.json"); @@ -351,21 +357,4 @@ lfunction leisr.store_results (node, result, arguments) { lfunction leisr.getIC(logl, params, samples) { return -2 * logl + 2 * samples / (samples - params - 1) * params; -} - - - -lfunction leisr.json_store_branch_attribute(json, attribute_name, attribute_type, partition, values) { - utility.EnsureKey(json, terms.json.branch_attributes); - utility.EnsureKey(json[terms.json.branch_attributes], partition); - utility.EnsureKey(json[terms.json.branch_attributes], terms.json.attribute); - utility.EnsureKey((json[terms.json.branch_attributes])[terms.json.attribute], attribute_name); - ((json[terms.json.branch_attributes])[terms.json.attribute])[attribute_name] = {terms.json.attribute_type : attribute_type}; - - utility.ForEach (utility.Keys (values), "selection.io.json_store_branch_attribute.branch_name", - "utility.EnsureKey ((json[terms.json.branch_attributes])[partition], selection.io.json_store_branch_attribute.branch_name)"); - - utility.ForEach (utility.Keys (values), "selection.io.json_store_branch_attribute.branch_name", - "(((json[terms.json.branch_attributes])[partition])[selection.io.json_store_branch_attribute.branch_name])[attribute_name] = values[selection.io.json_store_branch_attribute.branch_name]"); - } - +} \ No newline at end of file From ea54298b223038a8bb89c02b606027636d5b20ac Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Wed, 15 Nov 2017 13:16:33 -0500 Subject: [PATCH 03/24] Added 3 new AA models: hiv-between, hiv-within (both from nickle 2007), and cpREV --- .../libv3/models/protein.bf | 6 +- .../libv3/models/protein/empirical.bf | 918 +++++++++++++++++- .../libv3/models/protein/matrix2dict_aux.bf | 160 ++- 3 files changed, 994 insertions(+), 90 deletions(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein.bf b/res/TemplateBatchFiles/libv3/models/protein.bf index dd00da4cd..cd6a0ec90 100644 --- a/res/TemplateBatchFiles/libv3/models/protein.bf +++ b/res/TemplateBatchFiles/libv3/models/protein.bf @@ -14,7 +14,11 @@ models.protein.empirical_models = {{"LG", "Empirical model of protein evolution {"WAG", "Empirical model of protein evolution from Whelan and Goldman (2001). Ref: https://doi.org/10.1093/oxfordjournals.molbev.a003851"}, {"JTT", "Empirical model of protein evolution from Jones, Taylor, and Thornton (1996). Ref: https://doi.org/10.1093/bioinformatics/8.3.275"}, {"JC69", "Empirical model of protein evolution with equal exchangeability rates among all amino acids, also known as JC69."}, - {"mtMAM", "Empirical model of protein evolution for mammalian mitochondrial genomes from Yang N, Nielsen R, and Hasegawa M. (1998). Ref: http://dx.doi.org/10.1093/oxfordjournals.molbev.a025888"}}; + {"mtMAM", "Empirical model of protein evolution for mammalian mitochondrial genomes from Yang N, Nielsen R, and Hasegawa M. (1998). Ref: http://dx.doi.org/10.1093/oxfordjournals.molbev.a025888"}, + {"cpREV", "Empirical model of protein evolution for chloroplast genomes from from Adachi et al. (2000). Ref: https://www.ncbi.nlm.nih.gov/pubmed/10795826"}, + {"HIVBm", "Empirical model of protein evolution for between-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, + {"HIVWm", "Empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"} + }; models.protein.dimensions = 20; diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index ac30de35d..0b3025521 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -10,20 +10,29 @@ models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDes "WAG": "models.protein.WAG.ModelDescription", "JTT": "models.protein.JTT.ModelDescription", "JC69": "models.protein.JC69.ModelDescription", - "mtMAM": "models.protein.mtMAM.ModelDescription"}; + "mtMAM": "models.protein.mtMAM.ModelDescription", + "cpREV": "models.protein.cpREV.ModelDescription", + "HIVBm": "models.protein.HIVBm.ModelDescription", + "HIVWm": "models.protein.HIVBm.ModelDescription" + }; models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDescription", "WAG": "models.protein.WAGF.ModelDescription", "JTT": "models.protein.JTTF.ModelDescription", "JC69": "models.protein.JC69F.ModelDescription", - "mtMAM": "models.protein.mtMAMF.ModelDescription"}; - + "mtMAM": "models.protein.mtMAMF.ModelDescription", + "cpREV": "models.protein.cpREVF.ModelDescription", + "HIVBm": "models.protein.HIVBmF.ModelDescription", + "HIVWm": "models.protein.HIVBmF.ModelDescription"}; models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDescription", "WAG": "models.protein.WAGML.ModelDescription", "JTT": "models.protein.JTTML.ModelDescription", "JC69": "models.protein.JC69ML.ModelDescription", - "mtMAM": "models.protein.mtMAMML.ModelDescription"}; + "mtMAM": "models.protein.mtMAMML.ModelDescription", + "cpREV": "models.protein.cpREVF.ModelDescription", + "HIVBm": "models.protein.HIVBmML.ModelDescription", + "HIVWm": "models.protein.HIVBmML.ModelDescription"}; /** @module models.protein.empirical */ @@ -496,6 +505,136 @@ function models.protein.mtMAMML.ModelDescription(type) { +/**************************************** cpREV functions *************************************/ + +/** + * @name models.protein.cpREV.ModelDescription + * @description Create the baseline schema (dictionary) for the cpREV model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.cpREV.ModelDescription(type) { + models.protein.cpREV.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.cpREV.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.cpREV.Rij; + models.protein.cpREV.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.cpREV.frequencies"; + return models.protein.cpREV.ModelDescription.model_definition; +} + +/** + * @name models.protein.cpREVF.ModelDescription + * @description Create the baseline schema (dictionary) for the cpREV+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.cpREVF.ModelDescription(type) { + models.protein.cpREVF.ModelDescription.model_definition = models.protein.cpREV.ModelDescription(type); + models.protein.cpREVF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.cpREVF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.cpREVF.ModelDescription.model_definition; +} + +/** + * @name models.protein.cpREVML.ModelDescription + * @description Create the baseline schema (dictionary) for the cpREV+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.cpREVML.ModelDescription(type) { + models.protein.cpREVML.ModelDescription.model_definition = models.protein.cpREV.ModelDescription(type); + models.protein.cpREVML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.cpREVML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.cpREVML.ModelDescription.model_definition; +} + + +/**************************************** HIVBm functions *************************************/ + + +/** + * @name models.protein.HIVBm.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVBm model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVBm.ModelDescription(type) { + models.protein.HIVBm.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.HIVBm.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.HIVBm.Rij; + models.protein.HIVBm.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.HIVBm.frequencies"; + return models.protein.HIVBm.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVBmF.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVBm+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVBmF.ModelDescription(type) { + models.protein.HIVBmF.ModelDescription.model_definition = models.protein.HIVBm.ModelDescription(type); + models.protein.HIVBmF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.HIVBmF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.HIVBmF.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVBmML.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVBm+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVBmML.ModelDescription(type) { + models.protein.HIVBmML.ModelDescription.model_definition = models.protein.HIVBm.ModelDescription(type); + models.protein.HIVBmML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.HIVBmML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.HIVBmML.ModelDescription.model_definition; +} + + + +/**************************************** HIVWm functions *************************************/ + + +/** + * @name models.protein.HIVWm.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVWm model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVWm.ModelDescription(type) { + models.protein.HIVWm.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.HIVWm.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.HIVWm.Rij; + models.protein.HIVWm.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.HIVWm.frequencies"; + return models.protein.HIVWm.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVWmF.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVWm+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVWmF.ModelDescription(type) { + models.protein.HIVWmF.ModelDescription.model_definition = models.protein.HIVWm.ModelDescription(type); + models.protein.HIVWmF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.HIVWmF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.HIVWmF.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVWmML.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVWm+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVWmML.ModelDescription(type) { + models.protein.HIVWmML.ModelDescription.model_definition = models.protein.HIVWm.ModelDescription(type); + models.protein.HIVWmML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.HIVWmML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.HIVWmML.ModelDescription.model_definition; +} + + + /*=============================================================================================*/ /** Below this section are all of the empirical matrices and frequency vectors, including Rij **/ @@ -1822,8 +1961,779 @@ models.protein.mtMAM.Rij = { }; +lfunction models.protein.HIVWm.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.0377494} + {0.0240105} + {0.0342034} + {0.0618606} + {0.0422741} + {0.0838496} + {0.0156076} + {0.0983641} + {0.0641682} + {0.0577867} + {0.0158419} + {0.0891129} + {0.0458601} + {0.0437824} + {0.057321} + {0.0550846} + {0.0813774} + {0.0515639} + {0.019597} + {0.0205847}}; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + +models.protein.HIVWm.Rij = { + "A":{ + "C":0.167653, + "D":4.43521, + "E":5.56325, + "F":0.597923, + "G":1.8685, + "H":0.005, + "I":0.005, + "K":0.592784, + "L":0.16024, + "M":0.005, + "N":0.617509, + "P":1.00981, + "Q":0.005, + "R":0.0744808, + "S":8.594200000000001, + "T":24.1422, + "V":24.8094, + "W":0.005, + "Y":0.005 + }, + "C":{ + "D":0.005, + "E":0.005, + "F":0.362959, + "G":0.0489798, + "H":0.005, + "I":0.005, + "K":0.005, + "L":0.005, + "M":0.005, + "N":0.0604932, + "P":0.005, + "Q":0.005, + "R":2.86364, + "S":1.12195, + "T":0.005, + "V":0.005, + "W":5.49894, + "Y":8.34835 + }, + "D":{ + "E":12.1233, + "F":0.005, + "G":10.3969, + "H":2.31779, + "I":0.145124, + "K":0.894313, + "L":0.005, + "M":0.005, + "N":29.4087, + "P":0.005, + "Q":0.005, + "R":0.0674539, + "S":0.427881, + "T":0.630395, + "V":2.91786, + "W":0.005, + "Y":2.28154 + }, + "E":{ + "F":0.005, + "G":14.7801, + "H":0.005, + "I":0.0390512, + "K":23.9626, + "L":0.129839, + "M":0.005, + "N":0.201526, + "P":0.005, + "Q":3.20656, + "R":0.0251632, + "S":0.005, + "T":0.458743, + "V":2.19952, + "W":0.005, + "Y":0.005 + }, + "F":{ + "G":0.005, + "H":0.005, + "I":1.48288, + "K":0.005, + "L":7.48781, + "M":0.005, + "N":0.005, + "P":0.0342252, + "Q":0.005, + "R":0.005, + "S":4.27939, + "T":0.114512, + "V":2.28, + "W":0.005, + "Y":4.12728 + }, + "G":{ + "H":0.005, + "I":0.005, + "K":0.279425, + "L":0.0489798, + "M":0.0489798, + "N":0.0604932, + "P":0.005, + "Q":0.0604932, + "R":13.4379, + "S":6.27966, + "T":0.0489798, + "V":2.79622, + "W":2.8258, + "Y":0.005 + }, + "H":{ + "I":0.005, + "K":0.22406, + "L":1.76382, + "M":0.005, + "N":8.59876, + "P":13.9444, + "Q":18.5465, + "R":6.84405, + "S":0.7251570000000001, + "T":0.95956, + "V":0.827479, + "W":0.005, + "Y":47.4889 + }, + "I":{ + "K":0.817481, + "L":9.102460000000001, + "M":17.3064, + "N":0.987028, + "P":0.005, + "Q":0.0342252, + "R":1.34069, + "S":0.7400910000000001, + "T":9.36345, + "V":24.8231, + "W":0.005, + "Y":0.114512 + }, + "K":{ + "L":0.005, + "M":4.09564, + "N":10.6655, + "P":0.111928, + "Q":13.0705, + "R":39.8897, + "S":0.005, + "T":4.04802, + "V":0.128065, + "W":0.005, + "Y":0.005 + }, + "L":{ + "M":11.3839, + "N":0.005, + "P":9.83095, + "Q":2.89048, + "R":0.586757, + "S":6.14396, + "T":0.005, + "V":2.95344, + "W":1.37031, + "Y":0.005 + }, + "M":{ + "N":0.201526, + "P":0.005, + "Q":0.005, + "R":3.28652, + "S":0.392575, + "T":7.41313, + "V":14.7683, + "W":0.005, + "Y":0.579198 + }, + "N":{ + "P":0.344848, + "Q":0.342068, + "R":0.16024, + "S":14.5699, + "T":4.54206, + "V":0.0744808, + "W":0.005, + "Y":5.06475 + }, + "P":{ + "Q":3.04502, + "R":0.404723, + "S":14.249, + "T":4.33701, + "V":0.005, + "W":0.005, + "Y":0.005 + }, + "Q":{ + "R":10.6746, + "S":0.16024, + "T":0.203091, + "V":0.005, + "W":0.0443298, + "Y":0.005 + }, + "R":{ + "S":8.350239999999999, + "T":0.928203, + "V":0.279425, + "W":5.96564, + "Y":0.005 + }, + "S":{ + "T":6.34079, + "V":0.862637, + "W":1.10156, + "Y":0.933142 + }, + "T":{ + "V":0.005, + "W":0.005, + "Y":0.490608 + }, + "V":{ + "W":0.005, + "Y":1.35482 + }, + "W":{ + "Y":0.005 + } +}; +lfunction models.protein.HIVBm.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{ 0.060490222} + { 0.020075899} + { 0.042109048} + { 0.071567447} + { 0.028809447} + { 0.072308239} + { 0.022293943} + { 0.069730629} + { 0.056968211} + { 0.098851122} + { 0.019768318} + { 0.044127815} + { 0.046025282} + { 0.053606488} + { 0.066039665} + { 0.05060433} + { 0.053636813} + { 0.061625237} + { 0.033011601} + { 0.028350243}}; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + +models.protein.HIVBm.Rij = { + "A":{ + "C":0.123758, + "D":1.45504, + "E":1.48135, + "F":0.0141269, + "G":2.13536, + "H":0.0847613, + "I":0.005, + "K":0.005, + "L":0.215256, + "M":0.0186643, + "N":0.005, + "P":2.12217, + "Q":0.0551128, + "R":0.307507, + "S":2.46633, + "T":15.9183, + "V":7.61428, + "W":0.005, + "Y":0.005 + }, + "C":{ + "D":0.005, + "E":0.005, + "F":9.29815, + "G":0.897871, + "H":0.240073, + "I":0.005, + "K":0.005, + "L":0.129777, + "M":0.005, + "N":0.08606419999999999, + "P":0.005, + "Q":0.005, + "R":0.351721, + "S":4.69314, + "T":0.739969, + "V":0.420027, + "W":2.63277, + "Y":7.57932 + }, + "D":{ + "E":10.5872, + "F":0.005, + "G":2.83806, + "H":1.9169, + "I":0.0176792, + "K":0.005, + "L":0.008760479999999999, + "M":0.005, + "N":17.6612, + "P":0.0342658, + "Q":0.005, + "R":0.005, + "S":0.52823, + "T":0.274724, + "V":1.04793, + "W":0.005, + "Y":0.6746529999999999 + }, + "E":{ + "F":0.005, + "G":3.92775, + "H":0.11974, + "I":0.00609079, + "K":4.61482, + "L":0.005, + "M":0.175789, + "N":0.07926329999999999, + "P":0.0120226, + "Q":2.5602, + "R":0.0749218, + "S":0.005, + "T":0.289774, + "V":1.02847, + "W":0.005, + "Y":0.07926329999999999 + }, + "F":{ + "G":0.291561, + "H":0.145558, + "I":3.39836, + "K":0.0342658, + "L":8.524839999999999, + "M":0.188025, + "N":0.005, + "P":0.005, + "Q":0.005, + "R":0.005, + "S":0.956472, + "T":0.0141269, + "V":0.723274, + "W":0.8293430000000001, + "Y":15.34 + }, + "G":{ + "H":0.005, + "I":0.005, + "K":0.521705, + "L":0.005, + "M":0.005, + "N":0.323401, + "P":0.005, + "Q":0.0619137, + "R":3.65345, + "S":4.38041, + "T":0.369615, + "V":0.953155, + "W":1.21674, + "Y":0.005 + }, + "H":{ + "I":0.103111, + "K":0.005, + "L":1.74171, + "M":0.005, + "N":7.64585, + "P":2.45318, + "Q":7.05545, + "R":9.04044, + "S":0.382747, + "T":0.7115939999999999, + "V":0.005, + "W":0.06951789999999999, + "Y":18.6943 + }, + "I":{ + "K":0.322319, + "L":5.95879, + "M":11.2065, + "N":0.680565, + "P":0.0410593, + "Q":0.005, + "R":0.677289, + "S":1.21803, + "T":8.612170000000001, + "V":17.7389, + "W":0.005, + "Y":0.148168 + }, + "K":{ + "L":0.0814995, + "M":1.28246, + "N":7.90443, + "P":0.0313862, + "Q":6.54737, + "R":20.45, + "S":0.504111, + "T":4.67142, + "V":0.265829, + "W":0.005, + "Y":0.005 + }, + "L":{ + "M":5.31961, + "N":0.005, + "P":2.07757, + "Q":1.49456, + "R":0.701427, + "S":0.927656, + "T":0.0437673, + "V":1.41036, + "W":0.748843, + "Y":0.111986 + }, + "M":{ + "N":0.005, + "P":0.005, + "Q":0.303676, + "R":2.51394, + "S":0.005, + "T":4.94026, + "V":6.8532, + "W":0.089078, + "Y":0.005 + }, + "N":{ + "P":0.00739578, + "Q":0.672052, + "R":0.295543, + "S":13.1447, + "T":6.88667, + "V":0.026656, + "W":0.005, + "Y":1.76417 + }, + "P":{ + "Q":4.47211, + "R":1.28355, + "S":5.37762, + "T":2.01417, + "V":0.005, + "W":0.0444506, + "Y":0.0304381 + }, + "Q":{ + "R":3.4215, + "S":0.116311, + "T":0.243589, + "V":0.0209153, + "W":0.026656, + "Y":0.113033 + }, + "R":{ + "S":3.4791, + "T":2.86868, + "V":0.0812454, + "W":0.9913380000000001, + "Y":0.00991826 + }, + "S":{ + "T":8.93107, + "V":0.0749218, + "W":0.0248728, + "Y":0.648024 + }, + "T":{ + "V":0.709226, + "W":0.005, + "Y":0.105652 + }, + "V":{ + "W":0.005, + "Y":0.0410593 + }, + "W":{ + "Y":1.28022 + } +}; +lfunction models.protein.cpREV.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{ 0.076} + { 0.009} + { 0.037} + { 0.049} + { 0.051} + { 0.084} + { 0.025} + { 0.081} + { 0.05} + { 0.101} + { 0.022} + { 0.041} + { 0.043} + { 0.038} + { 0.062} + { 0.062} + { 0.054} + { 0.066} + { 0.018} + { 0.031}}; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + +models.protein.cpREV.Rij = { + "A":{ + "C":1.2816975, + "D":0.33527215, + "E":0.95600458, + "F":0.13027718, + "G":1.2740342, + "H":0.1264455, + "I":0.27779692, + "K":0.45213844, + "L":0.37742065, + "M":0.35443056, + "N":0.43489587, + "P":0.93876201, + "Q":0.30078701, + "R":0.20116329, + "S":4.6746517, + "T":2.5672267, + "V":1.8545339, + "W":0.026821772, + "Y":0.10728709 + }, + "C":{ + "D":0.019158408, + "E":0.019158408, + "F":1.3909005, + "G":0.58049978, + "H":0.84488581, + "I":0.53643544, + "K":0.091960361, + "L":0.75867297, + "M":0.30461869, + "N":1.0307224, + "P":0.54601464, + "Q":0.019158408, + "R":1.576737, + "S":4.465825, + "T":1.1035243, + "V":1.1341778, + "W":0.8333907699999999, + "Y":2.8086227 + }, + "D":{ + "E":7.0713686, + "F":0.042148499, + "G":0.8257274, + "H":0.63414332, + "I":0.019158408, + "K":0.78932643, + "L":0.019158408, + "M":0.09004452, + "N":8.4967541, + "P":0.32569294, + "Q":0.7663363399999999, + "R":0.082381156, + "S":1.1303461, + "T":0.50961366, + "V":0.14368806, + "W":0.034485135, + "Y":0.53835128 + }, + "E":{ + "F":0.27779692, + "G":0.72610368, + "H":0.31036622, + "I":0.28354444, + "K":5.0367456, + "L":0.15709895, + "M":0.21649002, + "N":2.0212121, + "P":0.35443056, + "Q":5.9812551, + "R":0.29120781, + "S":1.0881976, + "T":0.70694527, + "V":0.38316817, + "W":0.12069797, + "Y":0.2720494 + }, + "F":{ + "G":0.047896021, + "H":0.24331179, + "I":0.86979174, + "K":0.13794054, + "L":2.4292862, + "M":0.6264799599999999, + "N":0.18583656, + "P":0.082381156, + "Q":0.019158408, + "R":0.10153956, + "S":0.93301449, + "T":0.28354444, + "V":0.60732155, + "W":0.89661351, + "Y":4.5405428 + }, + "G":{ + "H":0.036400976, + "I":0.07663363400000001, + "K":0.50386614, + "L":0.038316817, + "M":0.040232658, + "N":1.2510441, + "P":0.053643544, + "Q":0.25480683, + "R":0.46554933, + "S":1.323846, + "T":0.17625736, + "V":0.17434152, + "W":0.15709895, + "Y":0.019158408 + }, + "H":{ + "I":0.055559384, + "K":0.58433146, + "L":0.1264455, + "M":0.019158408, + "N":2.6917564, + "P":0.29120781, + "Q":2.431202, + "R":1.3698262, + "S":0.58049978, + "T":0.061306907, + "V":0.047896021, + "W":0.13219302, + "Y":3.7761223 + }, + "I":{ + "K":0.66096509, + "L":3.3431423, + "M":3.39487, + "N":0.32186126, + "P":0.22415338, + "Q":0.17625736, + "R":0.26055435, + "S":0.41382162, + "T":1.9924745, + "V":9.190288499999999, + "W":0.080465315, + "Y":0.17050984 + }, + "K":{ + "L":0.4176533, + "M":0.36975728, + "N":4.6554933, + "P":0.57858393, + "Q":6.3471807, + "R":8.586798699999999, + "S":1.6629499, + "T":1.7587419, + "V":0.47704437, + "W":0.019158408, + "Y":0.47321269 + }, + "L":{ + "M":2.588301, + "N":0.21649002, + "P":0.41956914, + "Q":0.54793048, + "R":0.38891569, + "S":0.98857388, + "T":0.29887117, + "V":1.6572023, + "W":0.30461869, + "Y":0.36209392 + }, + "M":{ + "N":0.11686629, + "P":0.19158408, + "Q":0.38699985, + "R":0.23948011, + "S":0.1781732, + "T":1.2357173, + "V":0.9100244, + "W":0.16476231, + "Y":0.41190578 + }, + "N":{ + "P":0.33144047, + "Q":1.4713658, + "R":0.68395518, + "S":3.9945282, + "T":2.6687663, + "V":0.15901479, + "W":0.07663363400000001, + "Y":1.444544 + }, + "P":{ + "Q":0.61881659, + "R":0.16667815, + "S":2.3028407, + "T":0.49811862, + "V":0.23373258, + "W":0.09387620100000001, + "Y":0.18583656 + }, + "Q":{ + "R":3.3431423, + "S":0.75867297, + "T":0.46171764, + "V":0.10345541, + "W":0.10153956, + "Y":0.74909377 + }, + "R":{ + "S":0.73759872, + "T":0.60157402, + "V":0.17625736, + "W":0.44064339, + "Y":0.61881659 + }, + "S":{ + "T":4.1209737, + "V":0.31994542, + "W":0.13985638, + "Y":1.0000689 + }, + "T":{ + "V":1.456039, + "W":0.055559384, + "Y":0.1360247 + }, + "V":{ + "W":0.019158408, + "Y":0.22798506 + }, + "W":{ + "Y":0.66288093 + } +}; diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf b/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf index 4671bf672..65718a6bb 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf @@ -18,7 +18,7 @@ function mapMatrixToDict (letters, matrix) { return dict; } -models.protein.WAG.empirical_Q = { +WAG = { {0, 3.26324, 2.34804, 5.02923, 0.668808, 4.50138, 1.00707, 0.6142879999999999, 2.8795, 1.26431, 2.83893, 1.61995, 4.57074, 2.88691, 1.75252, 10.7101, 6.73946, 6.37375, 0.35946, 0.764894} {3.26324, 0, 0.0962568, 0.06784229999999999, 1.26464, 0.974403, 0.791065, 0.540574, 0.23523, 1.22101, 1.24069, 0.842805, 0.347612, 0.313977, 1.67824, 4.4726, 1.62992, 3.18413, 2.27837, 1.72794} {2.34804, 0.0962568, 0, 19.6173, 0.148478, 2.75024, 2.95706, 0.125304, 1.52466, 0.269452, 0.32966, 17.251, 1.34714, 1.95972, 0.468033, 3.40533, 1.19107, 0.484018, 0.412312, 1.03489} @@ -41,12 +41,12 @@ models.protein.WAG.empirical_Q = { {0.764894, 1.72794, 1.03489, 0.623719, 20.5074, 0.329184, 12.3072, 1.33502, 0.423423, 1.26654, 1.36128, 3.45058, 0.686449, 0.723509, 1.21225, 2.50053, 0.925072, 1, 7.8969, 0} }; -//fprintf (stdout, mapMatrixToDict (models.protein.alphabet, models.protein.WAG.empirical_Q), "\n"): +//fprintf (stdout, mapMatrixToDict (models.protein.alphabet, WAG), "\n"): -models.protein.LG.empirical_Q = { +LG = { {0, 7.908630, 1.255501, 3.299796, 0.806091, 6.564482, 1.140209, 0.476059, 1.704692, 1.256114, 3.571425, 0.879541, 3.741781, 3.081669, 1.350659, 15.019796, 6.797891, 8.095413, 0.574197, 0.695704} {7.908630, 0, 0.198761, 0.011117, 3.511742, 1.808740, 2.035214, 1.018736, 0.042150, 1.887354, 2.839512, 1.680068, 0.239513, 0.269463, 1.698443, 8.847193, 3.633208, 6.225305, 2.129215, 3.703275} {1.255501, 0.198761, 0, 16.661482, 0.055336, 2.684605, 2.945743, 0.033966, 0.899053, 0.047901, 0.081174, 16.128578, 1.253315, 1.662968, 0.393842, 3.940757, 1.353096, 0.120634, 0.094970, 0.429279} @@ -68,10 +68,10 @@ models.protein.LG.empirical_Q = { {0.574197, 2.129215, 0.094970, 0.247361, 7.807073, 0.853083, 1.897035, 0.354780, 0.158568, 1.968773, 2.211975, 0.144174, 0.302262, 0.750481, 1.886083, 0.790716, 0.447447, 0.602135, 0, 10.014342} {0.695704, 3.703275, 0.429279, 0.381397, 24.795538, 0.173733, 16.861539, 0.738801, 0.419191, 0.952079, 1.529266, 1.944603, 0.284730, 0.817640, 0.999078, 1.272668, 0.781117, 0.792149, 10.014342, 0} }; -//fprintf (stdout, mapMatrixToDict (models.protein.alphabet, models.protein.LG.empirical_Q), "\n"): +//fprintf (stdout, mapMatrixToDict (models.protein.alphabet, LG), "\n"): -models.protein.JTT.empirical_Q = { +JTT = { {0, 1.825304, 2.629062, 3.389193, 0.439402, 5.529052, 0.698916, 1.149188, 1.173822, 0.984993, 1.491421, 1.772843, 6.226284, 1.768897, 1.689314, 12.350566, 14.560301, 9.291012, 0.267941, 0.443212} {1.825304, 0, 0.335605, 0.171280, 2.155291, 1.736056, 2.303555, 0.478375, 0.155718, 0.522966, 1.300168, 0.995491, 0.392886, 0.290103, 3.240373, 6.848188, 1.492781, 1.974145, 3.508343, 6.719573} {2.629062, 0.335605, 0, 24.676880, 0.103333, 4.042937, 3.280087, 0.368468, 0.897486, 0.195361, 0.603695, 17.632664, 0.404041, 1.657439, 0.492165, 1.872296, 1.350869, 1.001687, 0.182588, 1.442353} @@ -94,89 +94,79 @@ models.protein.JTT.empirical_Q = { {0.443212, 6.719573, 1.442353, 0.201608, 17.425203, 0.166810, 18.582271, 0.964144, 0.279300, 0.766034, 0.603279, 2.226330, 0.361739, 0.809408, 0.748581, 1.997292, 0.638941, 0.525762, 2.376287, 0} }; -//fprintf (stdout, mapMatrixToDict (models.protein.alphabet, models.protein.JTT.empirical_Q), "\n"): - - - -/*****************************************************************************************************************************************************************************************************************************/ - -models.protein.WAG.empirical_Q_normalized = { - {0., 2.081175e-02, 4.424356e-02, 9.644885e-02, 8.490242e-03, 1.237844e-01, 8.127019e-03, 9.834135e-03, 5.899778e-02, 3.600239e-02, 1.828840e-02, 2.091646e-02, 6.909218e-02, 3.502343e-02, 2.545459e-02, 2.459330e-01, 1.358225e-01, 1.492591e-01, 1.708106e-03, 8.912199e-03} - {9.337576e-02, 0., 1.813745e-03, 1.301055e-03, 1.605407e-02, 2.679532e-02, 6.383892e-03, 8.654049e-03, 4.819601e-03, 3.476936e-02, 7.992529e-03, 1.088210e-02, 5.254569e-03, 3.809101e-03, 2.437562e-02, 1.027029e-01, 3.284827e-02, 7.456520e-02, 1.082647e-02, 2.013312e-02} - {6.718774e-02, 6.138903e-04, 0., 3.762142e-01, 1.884863e-03, 7.562952e-02, 2.386347e-02, 2.005993e-03, 3.123852e-02, 7.672926e-03, 2.123675e-03, 2.227414e-01, 2.036354e-02, 2.377493e-02, 6.797970e-03, 7.819566e-02, 2.400406e-02, 1.133463e-02, 1.959249e-03, 1.205807e-02} - {1.439085e-01, 4.326730e-04, 3.696449e-01, 0., 3.272523e-03, 4.960369e-02, 1.461601e-02, 6.480045e-03, 1.682461e-01, 1.395734e-02, 6.450074e-03, 3.885870e-02, 3.277285e-02, 2.108299e-01, 2.026676e-02, 5.143238e-02, 5.268470e-02, 4.380510e-02, 2.363730e-03, 7.267292e-03} - {1.913755e-02, 8.065405e-03, 2.797733e-03, 4.943786e-03, 0., 4.362670e-03, 1.741975e-02, 5.389076e-02, 5.783216e-03, 1.913755e-01, 2.437025e-02, 3.945040e-03, 7.754001e-03, 3.851615e-03, 4.740036e-03, 3.983115e-02, 1.100758e-02, 4.835584e-02, 2.309483e-02, 2.389425e-01} - {1.288044e-01, 6.214386e-03, 5.182222e-02, 3.459307e-02, 2.013959e-03, 0., 6.395123e-03, 1.548868e-03, 2.431859e-02, 5.546612e-03, 3.563543e-03, 4.617598e-02, 1.169843e-02, 1.272240e-02, 2.698185e-02, 9.789926e-02, 1.446092e-02, 1.393229e-02, 5.087841e-03, 3.835501e-03} - {2.881661e-02, 5.045123e-03, 5.571926e-02, 3.473371e-02, 2.740232e-02, 2.179194e-02, 0., 7.029141e-03, 5.796705e-02, 4.519012e-02, 8.272107e-03, 1.623063e-01, 3.343772e-02, 1.655236e-01, 9.862788e-02, 5.400277e-02, 3.030760e-02, 8.806541e-03, 3.964322e-03, 1.433978e-01} - {1.757750e-02, 3.447584e-03, 2.361080e-03, 7.762644e-03, 4.273355e-02, 2.660546e-03, 3.543330e-03, 0., 2.108143e-02, 2.869017e-01, 8.714326e-02, 2.273747e-02, 4.799484e-03, 4.391122e-03, 8.628942e-03, 2.330635e-02, 9.337141e-02, 5.819514e-01, 3.208113e-03, 1.555502e-02} - {8.239521e-02, 1.500209e-03, 2.872875e-02, 1.574787e-01, 3.583186e-03, 3.263925e-02, 2.283157e-02, 1.647196e-02, 0., 2.330296e-02, 1.912310e-02, 1.235674e-01, 2.674718e-02, 1.501354e-01, 2.469640e-01, 7.056185e-02, 8.881349e-02, 2.272611e-02, 2.076079e-03, 4.933538e-03} - {3.617737e-02, 7.787122e-03, 5.077229e-03, 9.399810e-03, 8.531504e-02, 5.356348e-03, 1.280670e-02, 1.612938e-01, 1.676681e-02, 0., 9.935387e-02, 5.395922e-03, 1.997258e-02, 3.351591e-02, 2.296714e-02, 2.515217e-02, 2.091482e-02, 1.339560e-01, 1.004497e-02, 1.475715e-02} - {8.123429e-02, 7.912656e-03, 6.211717e-03, 1.920166e-02, 4.802387e-02, 1.521181e-02, 1.036258e-02, 2.165590e-01, 6.082129e-02, 4.391801e-01, 0., 8.131996e-03, 8.228768e-03, 5.956464e-02, 3.152741e-02, 3.603533e-02, 9.708280e-02, 1.531609e-01, 7.786238e-03, 1.586107e-02} - {4.635403e-02, 5.375099e-03, 3.250575e-01, 5.771624e-02, 3.878683e-03, 9.834466e-02, 1.014432e-01, 2.819164e-02, 1.960816e-01, 1.190033e-02, 4.057260e-03, 0., 9.369553e-03, 5.950219e-02, 2.932074e-02, 2.899600e-01, 1.299922e-01, 1.460187e-02, 1.085813e-03, 4.020457e-02} - {1.307891e-01, 2.216942e-03, 2.538378e-02, 4.157839e-02, 6.511818e-03, 2.128168e-02, 1.785121e-02, 5.082956e-03, 3.625388e-02, 3.762457e-02, 3.506825e-03, 8.003178e-03, 0., 3.597839e-02, 3.135791e-02, 1.177049e-01, 5.093139e-02, 2.342947e-02, 2.104766e-03, 7.998193e-03} - {8.260732e-02, 2.002428e-03, 3.692659e-02, 3.332748e-01, 4.030289e-03, 2.883795e-02, 1.101053e-01, 5.794476e-03, 2.535576e-01, 7.866928e-02, 3.162895e-02, 6.332767e-02, 4.482896e-02, 0., 1.400860e-01, 7.506641e-02, 5.493632e-02, 2.241710e-02, 3.257243e-03, 8.430004e-03} - {5.014737e-02, 1.070316e-02, 8.819041e-03, 2.675944e-02, 4.142831e-03, 5.108451e-02, 5.479867e-02, 9.510832e-03, 3.483770e-01, 4.502808e-02, 1.398321e-02, 2.606500e-02, 3.263520e-02, 1.170084e-01, 0., 8.931696e-02, 3.550112e-02, 1.873906e-02, 1.757311e-02, 1.412465e-02} - {3.064633e-01, 2.852456e-02, 6.416591e-02, 4.295451e-02, 2.202004e-02, 1.172401e-01, 1.897867e-02, 1.624856e-02, 6.296009e-02, 3.119116e-02, 1.010943e-02, 1.630423e-01, 7.748429e-02, 3.965952e-02, 5.649546e-02, 0., 2.803409e-01, 1.731717e-02, 7.907568e-03, 2.913510e-02} - {1.928457e-01, 1.039501e-02, 2.244310e-02, 5.013408e-02, 6.933680e-03, 1.973192e-02, 1.213606e-02, 7.417044e-02, 9.029229e-02, 2.955197e-02, 3.103250e-02, 8.328300e-02, 3.820153e-02, 3.307027e-02, 2.558574e-02, 3.194205e-01, 0., 1.032926e-01, 1.673848e-03, 1.077852e-02} - {1.823811e-01, 2.030718e-02, 9.120245e-03, 3.587353e-02, 2.621329e-02, 1.636051e-02, 3.034818e-03, 3.978365e-01, 1.988373e-02, 1.628904e-01, 4.213311e-02, 8.050972e-03, 1.512372e-02, 1.161338e-02, 1.162264e-02, 1.698065e-02, 8.889353e-02, 0., 5.516418e-03, 1.165155e-02} - {1.028575e-02, 1.453057e-02, 7.769107e-03, 9.539592e-03, 6.169778e-02, 2.944354e-02, 6.732533e-03, 1.080811e-02, 8.951565e-03, 6.019556e-02, 1.055566e-02, 2.950375e-03, 6.695488e-03, 8.315944e-03, 5.371404e-02, 3.821224e-02, 7.099034e-03, 2.718563e-02, 0., 9.201110e-02} - {2.188698e-02, 1.102013e-02, 1.950020e-02, 1.196146e-02, 2.603323e-01, 9.052294e-03, 9.931890e-02, 2.137227e-02, 8.675476e-03, 3.606600e-02, 8.769406e-03, 4.455303e-02, 1.037648e-02, 8.777464e-03, 1.760746e-02, 5.741905e-02, 1.864329e-02, 2.341779e-02, 3.752494e-02, 0.} +//fprintf (stdout, mapMatrixToDict (models.protein.alphabet, JTT), "\n"): + + + +HIVBm = { +{0,0.123758,1.45504,1.48135,0.0141269,2.13536,0.0847613,0.005,0.005,0.215256,0.0186643,0.005,2.12217,0.0551128,0.307507,2.46633,15.9183,7.61428,0.005,0.005} +{0.123758,0,0.005,0.005,9.29815,0.897871,0.240073,0.005,0.005,0.129777,0.005,0.0860642,0.005,0.005,0.351721,4.69314,0.739969,0.420027,2.63277,7.57932} +{1.45504,0.005,0,10.5872,0.005,2.83806,1.9169,0.0176792,0.005,0.00876048,0.005,17.6612,0.0342658,0.005,0.005,0.52823,0.274724,1.04793,0.005,0.674653} +{1.48135,0.005,10.5872,0,0.005,3.92775,0.11974,0.00609079,4.61482,0.005,0.175789,0.0792633,0.0120226,2.5602,0.0749218,0.005,0.289774,1.02847,0.005,0.0792633} +{0.0141269,9.29815,0.005,0.005,0,0.291561,0.145558,3.39836,0.0342658,8.52484,0.188025,0.005,0.005,0.005,0.005,0.956472,0.0141269,0.723274,0.829343,15.34} +{2.13536,0.897871,2.83806,3.92775,0.291561,0,0.005,0.005,0.521705,0.005,0.005,0.323401,0.005,0.0619137,3.65345,4.38041,0.369615,0.953155,1.21674,0.005} +{0.0847613,0.240073,1.9169,0.11974,0.145558,0.005,0,0.103111,0.005,1.74171,0.005,7.64585,2.45318,7.05545,9.04044,0.382747,0.711594,0.005,0.0695179,18.6943} +{0.005,0.005,0.0176792,0.00609079,3.39836,0.005,0.103111,0,0.322319,5.95879,11.2065,0.680565,0.0410593,0.005,0.677289,1.21803,8.61217,17.7389,0.005,0.148168} +{0.005,0.005,0.005,4.61482,0.0342658,0.521705,0.005,0.322319,0,0.0814995,1.28246,7.90443,0.0313862,6.54737,20.45,0.504111,4.67142,0.265829,0.005,0.005} +{0.215256,0.129777,0.00876048,0.005,8.52484,0.005,1.74171,5.95879,0.0814995,0,5.31961,0.005,2.07757,1.49456,0.701427,0.927656,0.0437673,1.41036,0.748843,0.111986} +{0.0186643,0.005,0.005,0.175789,0.188025,0.005,0.005,11.2065,1.28246,5.31961,0,0.005,0.005,0.303676,2.51394,0.005,4.94026,6.8532,0.089078,0.005} +{0.005,0.0860642,17.6612,0.0792633,0.005,0.323401,7.64585,0.680565,7.90443,0.005,0.005,0,0.00739578,0.672052,0.295543,13.1447,6.88667,0.026656,0.005,1.76417} +{2.12217,0.005,0.0342658,0.0120226,0.005,0.005,2.45318,0.0410593,0.0313862,2.07757,0.005,0.00739578,0,4.47211,1.28355,5.37762,2.01417,0.005,0.0444506,0.0304381} +{0.0551128,0.005,0.005,2.5602,0.005,0.0619137,7.05545,0.005,6.54737,1.49456,0.303676,0.672052,4.47211,0,3.4215,0.116311,0.243589,0.0209153,0.026656,0.113033} +{0.307507,0.351721,0.005,0.0749218,0.005,3.65345,9.04044,0.677289,20.45,0.701427,2.51394,0.295543,1.28355,3.4215,0,3.4791,2.86868,0.0812454,0.991338,0.00991826} +{2.46633,4.69314,0.52823,0.005,0.956472,4.38041,0.382747,1.21803,0.504111,0.927656,0.005,13.1447,5.37762,0.116311,3.4791,0,8.93107,0.0749218,0.0248728,0.648024} +{15.9183,0.739969,0.274724,0.289774,0.0141269,0.369615,0.711594,8.61217,4.67142,0.0437673,4.94026,6.88667,2.01417,0.243589,2.86868,8.93107,0,0.709226,0.005,0.105652} +{7.61428,0.420027,1.04793,1.02847,0.723274,0.953155,0.005,17.7389,0.265829,1.41036,6.8532,0.026656,0.005,0.0209153,0.0812454,0.0749218,0.709226,0,0.005,0.0410593} +{0.005,2.63277,0.005,0.005,0.829343,1.21674,0.0695179,0.005,0.005,0.748843,0.089078,0.005,0.0444506,0.026656,0.991338,0.0248728,0.005,0.005,0,1.28022} +{0.005,7.57932,0.674653,0.0792633,15.34,0.005,18.6943,0.148168,0.005,0.111986,0.005,1.76417,0.0304381,0.113033,0.00991826,0.648024,0.105652,0.0410593,1.28022,0} }; -fprintf(stdout, "\n\n\nWAG"); -fprintf (stdout, mapMatrixToDict (models.protein.alphabet, models.protein.WAG.empirical_Q_normalized), "\n"); - - -models.protein.LG.empirical_Q_normalized = { - {0., 3.522956e-02, 2.293460e-02, 8.133689e-02, 1.174132e-02, 1.296008e-01, 8.776705e-03, 1.018879e-02, 3.791848e-02, 4.285406e-02, 2.822381e-02, 1.271276e-02, 5.674114e-02, 4.325807e-02, 2.601647e-02, 3.164948e-01, 1.247291e-01, 1.927457e-01, 2.385593e-03, 8.181845e-03} - {2.153069e-01, 0., 3.630821e-03, 2.740351e-04, 5.115122e-02, 3.570948e-02, 1.566596e-02, 2.180340e-02, 9.375764e-04, 6.438966e-02, 2.243974e-02, 2.428347e-02, 3.632027e-03, 3.782507e-03, 3.271550e-02, 1.864267e-01, 6.666287e-02, 1.482198e-01, 8.846170e-03, 4.355245e-02} - {3.418014e-02, 8.853943e-04, 0., 4.106900e-01, 8.060157e-04, 5.300146e-02, 2.267472e-02, 7.269456e-04, 1.999816e-02, 1.634220e-03, 6.414941e-04, 2.331202e-01, 1.900553e-02, 2.334345e-02, 7.586211e-03, 8.303904e-02, 2.482688e-02, 2.872194e-03, 3.945694e-04, 5.048546e-03} - {8.983463e-02, 4.952354e-05, 3.043602e-01, 0., 8.705765e-04, 2.188286e-02, 1.036699e-02, 3.010126e-03, 1.277224e-01, 7.552471e-03, 4.362376e-03, 2.487791e-02, 2.020781e-02, 1.841385e-01, 2.227563e-02, 4.097288e-02, 3.524391e-02, 1.853676e-02, 1.027702e-03, 4.485425e-03} - {2.194525e-02, 1.564331e-02, 1.010844e-03, 1.473242e-03, 0., 5.619650e-03, 1.668329e-02, 7.566810e-02, 1.690408e-03, 2.810447e-01, 4.516806e-02, 4.111401e-03, 4.551429e-03, 1.599162e-03, 3.226682e-03, 2.422454e-02, 9.619268e-03, 4.952661e-02, 3.243575e-02, 2.916085e-01} - {1.787134e-01, 8.057165e-03, 4.904047e-02, 2.732104e-02, 4.146056e-03, 0., 7.618063e-03, 5.919608e-04, 2.096479e-02, 4.797840e-03, 3.503711e-03, 6.602330e-02, 9.489902e-03, 1.195119e-02, 2.388046e-02, 1.164960e-01, 7.569210e-03, 5.802412e-03, 3.544273e-03, 2.043191e-03} - {3.104138e-02, 9.066007e-03, 5.381075e-02, 3.319756e-02, 3.156951e-02, 1.953911e-02, 0., 7.404237e-03, 4.927923e-02, 3.970833e-02, 1.111019e-02, 2.070850e-01, 2.451727e-02, 2.146863e-01, 1.485124e-01, 6.628340e-02, 3.406144e-02, 9.003304e-03, 7.881540e-03, 1.983005e-01} - {1.296036e-02, 4.538035e-03, 6.204598e-04, 3.466751e-03, 5.149721e-02, 5.460569e-04, 2.662961e-03, 0., 1.124222e-02, 4.493203e-01, 1.073075e-01, 8.794702e-03, 3.771706e-03, 3.249348e-03, 7.772081e-03, 4.291965e-03, 6.026516e-02, 4.910478e-02, 1.473992e-03, 8.688692e-03} - {4.640905e-02, 1.877620e-04, 1.642326e-02, 1.415347e-01, 1.106929e-03, 1.860771e-02, 1.705320e-02, 1.081707e-02, 0., 1.490483e-02, 1.648691e-02, 9.851189e-02, 1.880635e-02, 1.442522e-01, 3.871668e-01, 5.012591e-02, 6.627711e-02, 1.401048e-02, 6.587949e-04, 4.929905e-03} - {3.419683e-02, 8.407354e-03, 8.750282e-04, 5.456658e-03, 1.199902e-01, 2.776453e-03, 8.959132e-03, 2.818745e-01, 9.717832e-03, 0., 1.584993e-01, 3.142484e-03, 1.200011e-02, 2.597806e-02, 1.847365e-02, 1.220450e-02, 1.766063e-02, 1.288122e-01, 8.179586e-03, 1.119695e-02} - {9.722955e-02, 1.264881e-02, 1.482835e-03, 1.360659e-02, 8.325125e-02, 8.753095e-03, 1.082167e-02, 2.906155e-01, 4.640558e-02, 6.842521e-01, 0., 1.703821e-02, 4.810887e-03, 7.459796e-02, 2.962982e-02, 2.322970e-02, 1.177837e-01, 1.436375e-01, 9.190009e-03, 1.798497e-02} - {2.394488e-02, 7.483985e-03, 2.946254e-01, 4.242586e-02, 4.143233e-03, 9.018219e-02, 1.102838e-01, 1.302266e-02, 1.516037e-01, 7.417406e-03, 9.315676e-03, 0., 7.795161e-03, 7.563194e-02, 4.601631e-02, 2.683680e-01, 1.166360e-01, 6.330976e-03, 5.989957e-04, 2.286955e-02} - {1.018673e-01, 1.066928e-03, 2.289467e-02, 3.284732e-02, 4.371811e-03, 1.235518e-02, 1.244513e-02, 5.323295e-03, 2.758606e-02, 2.699781e-02, 2.507145e-03, 7.430006e-03, 0., 2.784403e-02, 2.035162e-02, 8.959077e-02, 3.331558e-02, 2.243022e-02, 1.255797e-03, 3.348570e-03} - {8.389628e-02, 1.200340e-03, 3.037792e-02, 3.233435e-01, 1.659376e-03, 1.680883e-02, 1.177254e-01, 4.954246e-03, 2.285842e-01, 6.313765e-02, 4.199715e-02, 7.787677e-02, 3.007950e-02, 0., 1.718491e-01, 8.193787e-02, 6.297003e-02, 1.591156e-02, 3.117996e-03, 9.615879e-03} - {3.677074e-02, 7.565835e-03, 7.194431e-03, 2.850544e-02, 2.439983e-03, 2.447639e-02, 5.934815e-02, 8.635692e-03, 4.470957e-01, 3.271996e-02, 1.215627e-02, 3.452971e-02, 1.602198e-02, 1.252350e-01, 0., 5.745502e-02, 3.375392e-02, 1.292756e-02, 7.836037e-03, 1.174968e-02} - {4.089034e-01, 3.941046e-02, 7.198697e-02, 4.792857e-02, 1.674505e-02, 1.091480e-01, 2.421304e-02, 4.359293e-03, 5.291328e-02, 1.975969e-02, 8.711946e-03, 1.840823e-01, 6.447338e-02, 5.458374e-02, 5.252041e-02, 0., 3.773224e-01, 7.441590e-03, 3.285156e-03, 1.496724e-02} - {1.850678e-01, 1.618439e-02, 2.471740e-02, 4.734683e-02, 7.636277e-03, 8.144497e-03, 1.428948e-02, 7.029673e-02, 8.034795e-02, 3.283790e-02, 5.073011e-02, 9.188042e-02, 2.753426e-02, 4.817496e-02, 3.543506e-02, 4.333327e-01, 0., 1.655336e-01, 1.858990e-03, 9.186346e-03} - {2.203919e-01, 2.773107e-02, 2.203648e-03, 1.919060e-02, 3.029885e-02, 4.811385e-03, 2.910739e-03, 4.414083e-02, 1.308917e-02, 1.845755e-01, 4.767561e-02, 3.843339e-03, 1.428590e-02, 9.380981e-03, 1.045859e-02, 6.586013e-03, 1.275657e-01, 0., 2.501667e-03, 9.316084e-03} - {1.563210e-02, 9.484742e-03, 1.734849e-03, 6.097222e-03, 1.137160e-01, 1.684220e-02, 1.460234e-02, 7.593148e-03, 3.527113e-03, 6.716738e-02, 1.748051e-02, 2.083875e-03, 4.583566e-03, 1.053467e-02, 3.632983e-02, 1.666183e-02, 8.209850e-03, 1.433638e-02, 0., 1.177739e-01} - {1.894005e-02, 1.649650e-02, 7.841764e-03, 9.401073e-03, 3.611660e-01, 3.429965e-03, 1.297909e-01, 1.581212e-02, 9.324313e-03, 3.248149e-02, 1.208529e-02, 2.810701e-02, 4.317700e-03, 1.147739e-02, 1.924430e-02, 2.681747e-02, 1.433209e-02, 1.886046e-02, 4.160621e-02, 0.} + +HIVWm={ +{0,0.167653,4.43521,5.56325,0.597923,1.8685,0.005,0.005,0.592784,0.16024,0.005,0.617509,1.00981,0.005,0.0744808,8.5942,24.1422,24.8094,0.005,0.005} +{0.167653,0,0.005,0.005,0.362959,0.0489798,0.005,0.005,0.005,0.005,0.005,0.0604932,0.005,0.005,2.86364,1.12195,0.005,0.005,5.49894,8.34835} +{4.43521,0.005,0,12.1233,0.005,10.3969,2.31779,0.145124,0.894313,0.005,0.005,29.4087,0.005,0.005,0.0674539,0.427881,0.630395,2.91786,0.005,2.28154} +{5.56325,0.005,12.1233,0,0.005,14.7801,0.005,0.0390512,23.9626,0.129839,0.005,0.201526,0.005,3.20656,0.0251632,0.005,0.458743,2.19952,0.005,0.005} +{0.597923,0.362959,0.005,0.005,0,0.005,0.005,1.48288,0.005,7.48781,0.005,0.005,0.0342252,0.005,0.005,4.27939,0.114512,2.28,0.005,4.12728} +{1.8685,0.0489798,10.3969,14.7801,0.005,0,0.005,0.005,0.279425,0.0489798,0.0489798,0.0604932,0.005,0.0604932,13.4379,6.27966,0.0489798,2.79622,2.8258,0.005} +{0.005,0.005,2.31779,0.005,0.005,0.005,0,0.005,0.22406,1.76382,0.005,8.59876,13.9444,18.5465,6.84405,0.725157,0.95956,0.827479,0.005,47.4889} +{0.005,0.005,0.145124,0.0390512,1.48288,0.005,0.005,0,0.817481,9.10246,17.3064,0.987028,0.005,0.0342252,1.34069,0.740091,9.36345,24.8231,0.005,0.114512} +{0.592784,0.005,0.894313,23.9626,0.005,0.279425,0.22406,0.817481,0,0.005,4.09564,10.6655,0.111928,13.0705,39.8897,0.005,4.04802,0.128065,0.005,0.005} +{0.16024,0.005,0.005,0.129839,7.48781,0.0489798,1.76382,9.10246,0.005,0,11.3839,0.005,9.83095,2.89048,0.586757,6.14396,0.005,2.95344,1.37031,0.005} +{0.005,0.005,0.005,0.005,0.005,0.0489798,0.005,17.3064,4.09564,11.3839,0,0.201526,0.005,0.005,3.28652,0.392575,7.41313,14.7683,0.005,0.579198} +{0.617509,0.0604932,29.4087,0.201526,0.005,0.0604932,8.59876,0.987028,10.6655,0.005,0.201526,0,0.344848,0.342068,0.16024,14.5699,4.54206,0.0744808,0.005,5.06475} +{1.00981,0.005,0.005,0.005,0.0342252,0.005,13.9444,0.005,0.111928,9.83095,0.005,0.344848,0,3.04502,0.404723,14.249,4.33701,0.005,0.005,0.005} +{0.005,0.005,0.005,3.20656,0.005,0.0604932,18.5465,0.0342252,13.0705,2.89048,0.005,0.342068,3.04502,0,10.6746,0.16024,0.203091,0.005,0.0443298,0.005} +{0.0744808,2.86364,0.0674539,0.0251632,0.005,13.4379,6.84405,1.34069,39.8897,0.586757,3.28652,0.16024,0.404723,10.6746,0,8.35024,0.928203,0.279425,5.96564,0.005} +{8.5942,1.12195,0.427881,0.005,4.27939,6.27966,0.725157,0.740091,0.005,6.14396,0.392575,14.5699,14.249,0.16024,8.35024,0,6.34079,0.862637,1.10156,0.933142} +{24.1422,0.005,0.630395,0.458743,0.114512,0.0489798,0.95956,9.36345,4.04802,0.005,7.41313,4.54206,4.33701,0.203091,0.928203,6.34079,0,0.005,0.005,0.490608} +{24.8094,0.005,2.91786,2.19952,2.28,2.79622,0.827479,24.8231,0.128065,2.95344,14.7683,0.0744808,0.005,0.005,0.279425,0.862637,0.005,0,0.005,1.35482} +{0.005,5.49894,0.005,0.005,0.005,2.8258,0.005,0.005,0.005,1.37031,0.005,0.005,0.005,0.0443298,5.96564,1.10156,0.005,0.005,0,0.005} +{0.005,8.34835,2.28154,0.005,4.12728,0.005,47.4889,0.114512,0.005,0.005,0.579198,5.06475,0.005,0.005,0.005,0.933142,0.490608,1.35482,0.005,0} }; -fprintf(stdout, "\n\n\nLG"); - -fprintf (stdout, mapMatrixToDict (models.protein.alphabet, models.protein.LG.empirical_Q_normalized), "\n"); - - -fprintf(stdout, "\n\n\nJTT"); -models.protein.JTT.empirical_Q_normalized = { - {0., 1.164983e-02, 4.242226e-02, 6.594220e-02, 5.605013e-03, 1.300142e-01, 5.055569e-03, 1.901336e-02, 2.198075e-02, 2.824504e-02, 1.099041e-02, 2.373925e-02, 9.902243e-02, 2.285967e-02, 2.714587e-02, 2.651969e-01, 2.681624e-01, 1.940882e-01, 1.208940e-03, 4.506008e-03} - {4.415494e-02, 0., 5.415286e-03, 3.332529e-03, 2.749291e-02, 4.082289e-02, 1.666262e-02, 7.914733e-03, 2.915936e-03, 1.499622e-02, 9.581053e-03, 1.333012e-02, 6.248431e-03, 3.749032e-03, 5.207011e-02, 1.470474e-01, 2.749309e-02, 4.123968e-02, 1.582953e-02, 6.831604e-02} - {6.359823e-02, 2.141968e-03, 0., 4.801284e-01, 1.318116e-03, 9.506860e-02, 2.372630e-02, 6.096320e-03, 1.680615e-02, 5.602049e-03, 4.448682e-03, 2.361102e-01, 6.425849e-03, 2.141930e-02, 7.908676e-03, 4.020279e-02, 2.487944e-02, 2.092512e-02, 8.238323e-04, 1.466400e-02} - {8.198614e-02, 1.093179e-03, 3.981835e-01, 0., 1.776388e-03, 8.335330e-02, 5.602518e-03, 5.875793e-03, 1.030317e-01, 8.881953e-03, 4.099415e-03, 2.459647e-02, 9.701838e-03, 1.403343e-01, 1.626078e-02, 2.131682e-02, 1.940362e-02, 3.088188e-02, 1.639765e-03, 2.049689e-03} - {1.062933e-02, 1.375595e-02, 1.667369e-03, 2.709508e-03, 0., 3.751538e-03, 1.042113e-02, 4.085083e-02, 1.458950e-03, 2.278042e-01, 1.021273e-02, 3.126321e-03, 7.503140e-03, 1.875789e-03, 3.334736e-03, 6.440240e-02, 8.128382e-03, 3.939149e-02, 7.711647e-03, 1.771572e-01} - {1.337503e-01, 1.108021e-02, 6.523640e-02, 6.896835e-02, 2.035091e-03, 0., 4.635577e-03, 2.826581e-03, 1.605493e-02, 6.331483e-03, 3.052693e-03, 3.290136e-02, 1.051474e-02, 9.497160e-03, 6.941973e-02, 1.278738e-01, 1.854212e-02, 3.120506e-02, 7.801362e-03, 1.695907e-03} - {1.690710e-02, 1.470223e-02, 5.292712e-02, 1.506973e-02, 1.837743e-02, 1.506951e-02, 0., 9.556410e-03, 3.124215e-02, 4.925195e-02, 7.718657e-03, 1.712807e-01, 5.770555e-02, 2.333939e-01, 1.639271e-01, 5.072240e-02, 2.793385e-02, 8.086143e-03, 1.837774e-03, 1.889208e-01} - {2.779938e-02, 3.053185e-03, 5.945561e-03, 6.909805e-03, 3.149544e-02, 4.017296e-03, 4.178032e-03, 0., 1.205203e-02, 2.127567e-01, 1.131285e-01, 2.089020e-02, 4.981443e-03, 3.213843e-03, 1.221257e-02, 2.763923e-02, 1.494435e-01, 6.328057e-01, 1.928334e-03, 9.802181e-03} - {2.839528e-02, 9.938532e-04, 1.448174e-02, 1.070526e-01, 9.938358e-04, 2.016082e-02, 1.206827e-02, 1.064847e-02, 0., 1.334602e-02, 1.462393e-02, 1.076208e-01, 1.093234e-02, 1.218169e-01, 3.333640e-01, 3.237125e-02, 5.650736e-02, 8.234754e-03, 1.277824e-03, 2.839562e-03} - {2.382744e-02, 3.337780e-03, 3.152324e-03, 6.026521e-03, 1.013368e-01, 5.192023e-03, 1.242394e-02, 1.227558e-01, 8.715324e-03, 0., 9.030557e-02, 5.841096e-03, 5.358937e-02, 2.911240e-02, 1.900652e-02, 4.042405e-02, 1.594697e-02, 1.169137e-01, 7.602722e-03, 7.788057e-03} - {3.607815e-02, 8.298205e-03, 9.741158e-03, 1.082369e-02, 1.767841e-02, 9.741134e-03, 7.576573e-03, 2.539957e-01, 3.716131e-02, 3.514064e-01, 0., 1.407080e-02, 8.298110e-03, 1.876080e-02, 2.200785e-02, 1.948259e-02, 1.237496e-01, 2.016795e-01, 2.886323e-03, 6.133368e-03} - {4.288589e-02, 6.353632e-03, 2.845187e-01, 3.573905e-02, 2.978184e-03, 5.777729e-02, 9.252443e-02, 2.581152e-02, 1.505011e-01, 1.250853e-02, 7.743476e-03, 0., 6.154998e-03, 3.156908e-02, 2.303155e-02, 3.450795e-01, 1.375939e-01, 1.092017e-02, 3.971070e-04, 2.263447e-02} - {1.506166e-01, 2.507558e-03, 6.519569e-03, 1.186906e-02, 6.018014e-03, 1.554655e-02, 2.624568e-02, 5.182250e-03, 1.287209e-02, 9.662355e-02, 3.844928e-03, 5.182271e-03, 0., 6.603124e-02, 3.627542e-02, 1.902389e-01, 6.887338e-02, 1.404214e-02, 1.003017e-03, 3.677695e-03} - {4.279042e-02, 1.851553e-03, 2.674426e-02, 2.112825e-01, 1.851531e-03, 1.728089e-02, 1.306371e-01, 4.114574e-03, 1.765145e-01, 6.459804e-02, 1.069787e-02, 3.271080e-02, 8.126180e-02, 0., 1.542939e-01, 3.744234e-02, 3.065318e-02, 1.193211e-02, 2.468744e-03, 8.229025e-03} - {4.086529e-02, 2.068139e-02, 7.941514e-03, 1.968861e-02, 2.647175e-03, 1.015850e-01, 7.379083e-02, 1.257423e-02, 3.884775e-01, 3.391706e-02, 1.009248e-02, 1.919228e-02, 3.590242e-02, 1.240861e-01, 0., 6.833079e-02, 3.805319e-02, 1.141599e-02, 1.803412e-02, 7.610617e-03} - {2.987659e-01, 4.370794e-02, 3.021117e-02, 1.931559e-02, 3.825913e-02, 1.400361e-01, 1.708689e-02, 2.129669e-02, 2.823048e-02, 5.398425e-02, 6.686193e-03, 2.151960e-01, 1.409036e-01, 2.253455e-02, 5.113617e-02, 0., 2.795782e-01, 2.711589e-02, 4.457448e-03, 2.030591e-02} - {3.522204e-01, 9.527538e-03, 2.179747e-02, 2.049851e-02, 5.629777e-03, 2.367402e-02, 1.097104e-02, 1.342509e-01, 5.745369e-02, 2.482901e-02, 4.951422e-02, 1.000388e-01, 5.947417e-02, 2.150877e-02, 3.320143e-02, 3.259548e-01, 0., 7.593050e-02, 1.154850e-03, 6.495937e-03} - {2.247538e-01, 1.259980e-02, 1.616311e-02, 2.876304e-02, 2.405365e-02, 3.512603e-02, 2.799949e-03, 5.011897e-01, 7.381676e-03, 1.604864e-01, 7.114419e-02, 6.999878e-03, 1.069059e-02, 7.381575e-03, 8.781546e-03, 2.787208e-02, 6.694340e-02, 0., 3.436295e-03, 5.345272e-03} - {6.481609e-03, 2.239168e-02, 2.946223e-03, 7.071031e-03, 2.180197e-02, 4.065785e-02, 2.946258e-03, 7.071054e-03, 5.303293e-03, 4.831833e-02, 4.714033e-03, 1.178523e-03, 3.535470e-03, 7.070948e-03, 6.422769e-02, 2.121298e-02, 4.713974e-03, 1.590964e-02, 0., 2.415905e-02} - {1.072149e-02, 4.288707e-02, 2.327365e-02, 3.922601e-03, 2.222760e-01, 3.922483e-03, 1.344137e-01, 1.595179e-02, 5.230110e-03, 2.196630e-02, 4.445615e-03, 2.981167e-02, 5.753066e-03, 1.046008e-02, 1.202907e-02, 4.288676e-02, 1.176761e-02, 1.098310e-02, 1.072173e-02, 0.} + +cpREV={ +{ 0, 1.2816975, 0.33527215, 0.95600458, 0.13027718, 1.2740342, 0.1264455, 0.27779692, 0.45213844, 0.37742065, 0.35443056, 0.43489587, 0.93876201, 0.30078701, 0.20116329, 4.6746517, 2.5672267, 1.8545339, 0.026821772, 0.10728709} +{ 1.2816975, 0, 0.019158408, 0.019158408, 1.3909005, 0.58049978, 0.84488581, 0.53643544, 0.091960361, 0.75867297, 0.30461869, 1.0307224, 0.54601464, 0.019158408, 1.576737, 4.465825, 1.1035243, 1.1341778, 0.83339077, 2.8086227} +{ 0.33527215, 0.019158408, 0, 7.0713686, 0.042148499, 0.8257274, 0.63414332, 0.019158408, 0.78932643, 0.019158408, 0.09004452, 8.4967541, 0.32569294, 0.76633634, 0.082381156, 1.1303461, 0.50961366, 0.14368806, 0.034485135, 0.53835128} +{ 0.95600458, 0.019158408, 7.0713686, 0, 0.27779692, 0.72610368, 0.31036622, 0.28354444, 5.0367456, 0.15709895, 0.21649002, 2.0212121, 0.35443056, 5.9812551, 0.29120781, 1.0881976, 0.70694527, 0.38316817, 0.12069797, 0.2720494} +{ 0.13027718, 1.3909005, 0.042148499, 0.27779692, 0, 0.047896021, 0.24331179, 0.86979174, 0.13794054, 2.4292862, 0.62647996, 0.18583656, 0.082381156, 0.019158408, 0.10153956, 0.93301449, 0.28354444, 0.60732155, 0.89661351, 4.5405428} +{ 1.2740342, 0.58049978, 0.8257274, 0.72610368, 0.047896021, 0, 0.036400976, 0.076633634, 0.50386614, 0.038316817, 0.040232658, 1.2510441, 0.053643544, 0.25480683, 0.46554933, 1.323846, 0.17625736, 0.17434152, 0.15709895, 0.019158408} +{ 0.1264455, 0.84488581, 0.63414332, 0.31036622, 0.24331179, 0.036400976, 0, 0.055559384, 0.58433146, 0.1264455, 0.019158408, 2.6917564, 0.29120781, 2.431202, 1.3698262, 0.58049978, 0.061306907, 0.047896021, 0.13219302, 3.7761223} +{ 0.27779692, 0.53643544, 0.019158408, 0.28354444, 0.86979174, 0.076633634, 0.055559384, 0, 0.66096509, 3.3431423, 3.39487, 0.32186126, 0.22415338, 0.17625736, 0.26055435, 0.41382162, 1.9924745, 9.1902885, 0.080465315, 0.17050984} +{ 0.45213844, 0.091960361, 0.78932643, 5.0367456, 0.13794054, 0.50386614, 0.58433146, 0.66096509, 0, 0.4176533, 0.36975728, 4.6554933, 0.57858393, 6.3471807, 8.5867987, 1.6629499, 1.7587419, 0.47704437, 0.019158408, 0.47321269} +{ 0.37742065, 0.75867297, 0.019158408, 0.15709895, 2.4292862, 0.038316817, 0.1264455, 3.3431423, 0.4176533, 0, 2.588301, 0.21649002, 0.41956914, 0.54793048, 0.38891569, 0.98857388, 0.29887117, 1.6572023, 0.30461869, 0.36209392} +{ 0.35443056, 0.30461869, 0.09004452, 0.21649002, 0.62647996, 0.040232658, 0.019158408, 3.39487, 0.36975728, 2.588301, 0, 0.11686629, 0.19158408, 0.38699985, 0.23948011, 0.1781732, 1.2357173, 0.9100244, 0.16476231, 0.41190578} +{ 0.43489587, 1.0307224, 8.4967541, 2.0212121, 0.18583656, 1.2510441, 2.6917564, 0.32186126, 4.6554933, 0.21649002, 0.11686629, 0, 0.33144047, 1.4713658, 0.68395518, 3.9945282, 2.6687663, 0.15901479, 0.076633634, 1.444544} +{ 0.93876201, 0.54601464, 0.32569294, 0.35443056, 0.082381156, 0.053643544, 0.29120781, 0.22415338, 0.57858393, 0.41956914, 0.19158408, 0.33144047, 0, 0.61881659, 0.16667815, 2.3028407, 0.49811862, 0.23373258, 0.093876201, 0.18583656} +{ 0.30078701, 0.019158408, 0.76633634, 5.9812551, 0.019158408, 0.25480683, 2.431202, 0.17625736, 6.3471807, 0.54793048, 0.38699985, 1.4713658, 0.61881659, 0, 3.3431423, 0.75867297, 0.46171764, 0.10345541, 0.10153956, 0.74909377} +{ 0.20116329, 1.576737, 0.082381156, 0.29120781, 0.10153956, 0.46554933, 1.3698262, 0.26055435, 8.5867987, 0.38891569, 0.23948011, 0.68395518, 0.16667815, 3.3431423, 0, 0.73759872, 0.60157402, 0.17625736, 0.44064339, 0.61881659} +{ 4.6746517, 4.465825, 1.1303461, 1.0881976, 0.93301449, 1.323846, 0.58049978, 0.41382162, 1.6629499, 0.98857388, 0.1781732, 3.9945282, 2.3028407, 0.75867297, 0.73759872, 0, 4.1209737, 0.31994542, 0.13985638, 1.0000689} +{ 2.5672267, 1.1035243, 0.50961366, 0.70694527, 0.28354444, 0.17625736, 0.061306907, 1.9924745, 1.7587419, 0.29887117, 1.2357173, 2.6687663, 0.49811862, 0.46171764, 0.60157402, 4.1209737, 0, 1.456039, 0.055559384, 0.1360247} +{ 1.8545339, 1.1341778, 0.14368806, 0.38316817, 0.60732155, 0.17434152, 0.047896021, 9.1902885, 0.47704437, 1.6572023, 0.9100244, 0.15901479, 0.23373258, 0.10345541, 0.17625736, 0.31994542, 1.456039, 0, 0.019158408, 0.22798506} +{ 0.026821772, 0.83339077, 0.034485135, 0.12069797, 0.89661351, 0.15709895, 0.13219302, 0.080465315, 0.019158408, 0.30461869, 0.16476231, 0.076633634, 0.093876201, 0.10153956, 0.44064339, 0.13985638, 0.055559384, 0.019158408, 0, 0.66288093} +{ 0.10728709, 2.8086227, 0.53835128, 0.2720494, 4.5405428, 0.019158408, 3.7761223, 0.17050984, 0.47321269, 0.36209392, 0.41190578, 1.444544, 0.18583656, 0.74909377, 0.61881659, 1.0000689, 0.1360247, 0.22798506, 0.66288093, 0} }; -fprintf (stdout, mapMatrixToDict (models.protein.alphabet, models.protein.JTT.empirical_Q_normalized), "\n"); +fprintf (stdout, mapMatrixToDict (models.protein.alphabet, cpREV), "\n"): From 676f10b1ce739ffb679667747e2f754b280b7b85 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Wed, 15 Nov 2017 13:23:36 -0500 Subject: [PATCH 04/24] Added antibody AB model of AA evolution from Mirsky et al 2015 --- .../libv3/models/protein.bf | 3 +- .../libv3/models/protein/empirical.bf | 314 +++++++++++++++++- .../libv3/models/protein/matrix2dict_aux.bf | 46 +-- 3 files changed, 336 insertions(+), 27 deletions(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein.bf b/res/TemplateBatchFiles/libv3/models/protein.bf index cd6a0ec90..170c2be49 100644 --- a/res/TemplateBatchFiles/libv3/models/protein.bf +++ b/res/TemplateBatchFiles/libv3/models/protein.bf @@ -17,7 +17,8 @@ models.protein.empirical_models = {{"LG", "Empirical model of protein evolution {"mtMAM", "Empirical model of protein evolution for mammalian mitochondrial genomes from Yang N, Nielsen R, and Hasegawa M. (1998). Ref: http://dx.doi.org/10.1093/oxfordjournals.molbev.a025888"}, {"cpREV", "Empirical model of protein evolution for chloroplast genomes from from Adachi et al. (2000). Ref: https://www.ncbi.nlm.nih.gov/pubmed/10795826"}, {"HIVBm", "Empirical model of protein evolution for between-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, - {"HIVWm", "Empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"} + {"HIVWm", "Empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, + {"AB", "Empirical model of protein evolution for antibody sequences from Mirsky et al. (2015). Ref: https://doi.org/10.1093/molbev/msu340"} }; diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index 0b3025521..96929c6c0 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -13,8 +13,8 @@ models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDes "mtMAM": "models.protein.mtMAM.ModelDescription", "cpREV": "models.protein.cpREV.ModelDescription", "HIVBm": "models.protein.HIVBm.ModelDescription", - "HIVWm": "models.protein.HIVBm.ModelDescription" - }; + "HIVWm": "models.protein.HIVBm.ModelDescription", + "AB" : "models.protein.AB.ModelDescription"}; models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDescription", "WAG": "models.protein.WAGF.ModelDescription", @@ -23,7 +23,8 @@ models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDesc "mtMAM": "models.protein.mtMAMF.ModelDescription", "cpREV": "models.protein.cpREVF.ModelDescription", "HIVBm": "models.protein.HIVBmF.ModelDescription", - "HIVWm": "models.protein.HIVBmF.ModelDescription"}; + "HIVWm": "models.protein.HIVBmF.ModelDescription", + "AB" : "models.protein.ABF.ModelDescription"}; models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDescription", "WAG": "models.protein.WAGML.ModelDescription", @@ -32,8 +33,8 @@ models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDesc "mtMAM": "models.protein.mtMAMML.ModelDescription", "cpREV": "models.protein.cpREVF.ModelDescription", "HIVBm": "models.protein.HIVBmML.ModelDescription", - "HIVWm": "models.protein.HIVBmML.ModelDescription"}; - + "HIVWm": "models.protein.HIVBmML.ModelDescription", + "AB" : "models.protein.ABML.ModelDescription"}; /** @module models.protein.empirical */ /** @@ -634,6 +635,50 @@ function models.protein.HIVWmML.ModelDescription(type) { } +/**************************************** AB functions *************************************/ + + + +/** + * @name models.protein.AB.ModelDescription + * @description Create the baseline schema (dictionary) for the AB model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.AB.ModelDescription(type) { + models.protein.AB.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.AB.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.AB.Rij; + models.protein.AB.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.AB.frequencies"; + return models.protein.AB.ModelDescription.model_definition; +} + +/** + * @name models.protein.ABF.ModelDescription + * @description Create the baseline schema (dictionary) for the AB+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.ABF.ModelDescription(type) { + models.protein.ABF.ModelDescription.model_definition = models.protein.AB.ModelDescription(type); + models.protein.ABF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.ABF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.ABF.ModelDescription.model_definition; +} + +/** + * @name models.protein.ABML.ModelDescription + * @description Create the baseline schema (dictionary) for the AB+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.ABML.ModelDescription(type) { + models.protein.ABML.ModelDescription.model_definition = models.protein.AB.ModelDescription(type); + models.protein.ABML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.ABML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.ABML.ModelDescription.model_definition; +} + + /*=============================================================================================*/ /** Below this section are all of the empirical matrices and frequency vectors, including Rij **/ @@ -2737,3 +2782,262 @@ models.protein.cpREV.Rij = { }; + +lfunction models.protein.AB.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{6.541704e-02} + {4.708366e-02} + {3.168984e-02} + {4.688141e-02} + {2.150693e-02} + {4.240711e-02} + {2.842211e-02} + {1.005278e-01} + {9.812606e-03} + {3.424424e-02} + {6.222565e-02} + {4.844488e-02} + {1.760370e-02} + {3.478555e-02} + {3.962469e-02} + {1.280566e-01} + {8.199314e-02} + {3.393045e-02} + {7.586119e-02} + {4.948141e-02}}; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + +models.protein.AB.Rij = { + "A":{ + "C":0.1784266, + "D":0.09291290000000001, + "E":1.241095, + "F":0.008929181, + "G":0.1992269, + "H":0.9521821, + "I":1.851951, + "K":5.241316, + "L":0.1140412, + "M":0.06969101, + "N":0.07388355000000001, + "P":0.06299270999999999, + "Q":0.1130146, + "R":1.800713, + "S":0.9988358000000001, + "T":2.912317, + "V":0.07939549, + "W":0.1433528, + "Y":3.774477 + }, + "C":{ + "D":0.782913, + "E":0.05795374, + "F":0.1821885, + "G":1.923901, + "H":0.06273863, + "I":1.0894, + "K":10.4955, + "L":0.3245175, + "M":0.3932002, + "N":7.54924, + "P":0.3362326, + "Q":0.08208677, + "R":0.3498713, + "S":1.926435, + "T":1.135258, + "V":0.5724286, + "W":0.1711315, + "Y":0.1366145 + }, + "D":{ + "E":7.185182, + "F":1.374268e-06, + "G":0.08705989, + "H":0.5038373, + "I":0.4868901, + "K":14.05444, + "L":1.762721, + "M":0.02769442, + "N":6.190318, + "P":0.03972173, + "Q":0.1955446, + "R":0.007342554, + "S":7.348346, + "T":2.147175, + "V":0.0007310937, + "W":2.622763, + "Y":0.04931206 + }, + "E":{ + "F":0.02340019, + "G":0.1843856, + "H":7.426619, + "I":2.1124, + "K":11.26995, + "L":0.03916999, + "M":0.03020502, + "N":0.06622772, + "P":0.03357577, + "Q":0.1031734, + "R":0.1509482, + "S":0.5822988, + "T":0.1516881, + "V":0.01423897, + "W":0.9078338, + "Y":0.4076074 + }, + "F":{ + "G":1.046446e-08, + "H":7.519215e-11, + "I":0.05891123, + "K":3.963388, + "L":0.0006594967, + "M":0.006079219, + "N":3.722878e-16, + "P":0.007213178, + "Q":0.1993818, + "R":0.004878395, + "S":0.2639482, + "T":3.225214e-06, + "V":0.4440833, + "W":0.7741612, + "Y":0.02243512 + }, + "G":{ + "H":3.691671, + "I":0.0551634, + "K":8.908434, + "L":6.712736e-06, + "M":0.6802781, + "N":3.030805, + "P":0.001233336, + "Q":0.00149661, + "R":0.7426909, + "S":0.0005906405, + "T":0.1202094, + "V":4.332983e-05, + "W":0.02737091, + "Y":0.009047737 + }, + "H":{ + "I":1.38937, + "K":7.29808, + "L":0.0001029959, + "M":0.001283121, + "N":3.608816, + "P":0.07659566, + "Q":0.05288625, + "R":0.02889815, + "S":0.06776709, + "T":0.06016624, + "V":0.02252612, + "W":0.1240642, + "Y":0.5795409 + }, + "I":{ + "K":9.139518000000001, + "L":0.03560482, + "M":0.02157936, + "N":0.055044, + "P":0.02187264, + "Q":0.1984772, + "R":0.07915055999999999, + "S":0.9984215, + "T":0.07862767, + "V":0.1386853, + "W":0.2295842, + "Y":0.42282 + }, + "K":{ + "L":4.706586, + "M":5.879103, + "N":1.455741, + "P":2.298295, + "Q":5.642309, + "R":10.49496, + "S":5.439116, + "T":3.443285, + "V":7.01389, + "W":20.55414, + "Y":6.890244 + }, + "L":{ + "M":1.601123, + "N":0.5059793, + "P":10.96748, + "Q":2.714705, + "R":0.05016568, + "S":0.6007607, + "T":3.087152, + "V":0.06318748, + "W":0.2903165, + "Y":7.926675 + }, + "M":{ + "N":0.02158451, + "P":5.647985, + "Q":3.390618, + "R":1.149931, + "S":0.1580539, + "T":0.5702792, + "V":0.3378544, + "W":0.152132, + "Y":3.59531 + }, + "N":{ + "P":1.238634, + "Q":0.004649035, + "R":0.009948993999999999, + "S":0.08688405, + "T":1.039298, + "V":0.008024263, + "W":0.07109973, + "Y":0.0349344 + }, + "P":{ + "Q":3.94794, + "R":0.07417279, + "S":0.01861354, + "T":1.415612, + "V":0.1011149, + "W":0.002246759, + "Y":4.39672 + }, + "Q":{ + "R":0.3556198, + "S":0.9813064, + "T":0.03674486, + "V":0.2199856, + "W":7.074464, + "Y":1.643946 + }, + "R":{ + "S":1.284651, + "T":0.9057112, + "V":0.005516074, + "W":0.1992133, + "Y":0.2217442 + }, + "S":{ + "T":3.058575, + "V":0.1385142, + "W":0.8104751, + "Y":0.07477041 + }, + "T":{ + "V":0.01412361, + "W":0.09984255, + "Y":0.2166054 + }, + "V":{ + "W":0.6121284, + "Y":0.09663569 + }, + "W":{ + "Y":0.5010635 + } +}; + diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf b/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf index 65718a6bb..b5507c575 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/matrix2dict_aux.bf @@ -145,27 +145,31 @@ HIVWm={ }; cpREV={ -{ 0, 1.2816975, 0.33527215, 0.95600458, 0.13027718, 1.2740342, 0.1264455, 0.27779692, 0.45213844, 0.37742065, 0.35443056, 0.43489587, 0.93876201, 0.30078701, 0.20116329, 4.6746517, 2.5672267, 1.8545339, 0.026821772, 0.10728709} -{ 1.2816975, 0, 0.019158408, 0.019158408, 1.3909005, 0.58049978, 0.84488581, 0.53643544, 0.091960361, 0.75867297, 0.30461869, 1.0307224, 0.54601464, 0.019158408, 1.576737, 4.465825, 1.1035243, 1.1341778, 0.83339077, 2.8086227} -{ 0.33527215, 0.019158408, 0, 7.0713686, 0.042148499, 0.8257274, 0.63414332, 0.019158408, 0.78932643, 0.019158408, 0.09004452, 8.4967541, 0.32569294, 0.76633634, 0.082381156, 1.1303461, 0.50961366, 0.14368806, 0.034485135, 0.53835128} -{ 0.95600458, 0.019158408, 7.0713686, 0, 0.27779692, 0.72610368, 0.31036622, 0.28354444, 5.0367456, 0.15709895, 0.21649002, 2.0212121, 0.35443056, 5.9812551, 0.29120781, 1.0881976, 0.70694527, 0.38316817, 0.12069797, 0.2720494} -{ 0.13027718, 1.3909005, 0.042148499, 0.27779692, 0, 0.047896021, 0.24331179, 0.86979174, 0.13794054, 2.4292862, 0.62647996, 0.18583656, 0.082381156, 0.019158408, 0.10153956, 0.93301449, 0.28354444, 0.60732155, 0.89661351, 4.5405428} -{ 1.2740342, 0.58049978, 0.8257274, 0.72610368, 0.047896021, 0, 0.036400976, 0.076633634, 0.50386614, 0.038316817, 0.040232658, 1.2510441, 0.053643544, 0.25480683, 0.46554933, 1.323846, 0.17625736, 0.17434152, 0.15709895, 0.019158408} -{ 0.1264455, 0.84488581, 0.63414332, 0.31036622, 0.24331179, 0.036400976, 0, 0.055559384, 0.58433146, 0.1264455, 0.019158408, 2.6917564, 0.29120781, 2.431202, 1.3698262, 0.58049978, 0.061306907, 0.047896021, 0.13219302, 3.7761223} -{ 0.27779692, 0.53643544, 0.019158408, 0.28354444, 0.86979174, 0.076633634, 0.055559384, 0, 0.66096509, 3.3431423, 3.39487, 0.32186126, 0.22415338, 0.17625736, 0.26055435, 0.41382162, 1.9924745, 9.1902885, 0.080465315, 0.17050984} -{ 0.45213844, 0.091960361, 0.78932643, 5.0367456, 0.13794054, 0.50386614, 0.58433146, 0.66096509, 0, 0.4176533, 0.36975728, 4.6554933, 0.57858393, 6.3471807, 8.5867987, 1.6629499, 1.7587419, 0.47704437, 0.019158408, 0.47321269} -{ 0.37742065, 0.75867297, 0.019158408, 0.15709895, 2.4292862, 0.038316817, 0.1264455, 3.3431423, 0.4176533, 0, 2.588301, 0.21649002, 0.41956914, 0.54793048, 0.38891569, 0.98857388, 0.29887117, 1.6572023, 0.30461869, 0.36209392} -{ 0.35443056, 0.30461869, 0.09004452, 0.21649002, 0.62647996, 0.040232658, 0.019158408, 3.39487, 0.36975728, 2.588301, 0, 0.11686629, 0.19158408, 0.38699985, 0.23948011, 0.1781732, 1.2357173, 0.9100244, 0.16476231, 0.41190578} -{ 0.43489587, 1.0307224, 8.4967541, 2.0212121, 0.18583656, 1.2510441, 2.6917564, 0.32186126, 4.6554933, 0.21649002, 0.11686629, 0, 0.33144047, 1.4713658, 0.68395518, 3.9945282, 2.6687663, 0.15901479, 0.076633634, 1.444544} -{ 0.93876201, 0.54601464, 0.32569294, 0.35443056, 0.082381156, 0.053643544, 0.29120781, 0.22415338, 0.57858393, 0.41956914, 0.19158408, 0.33144047, 0, 0.61881659, 0.16667815, 2.3028407, 0.49811862, 0.23373258, 0.093876201, 0.18583656} -{ 0.30078701, 0.019158408, 0.76633634, 5.9812551, 0.019158408, 0.25480683, 2.431202, 0.17625736, 6.3471807, 0.54793048, 0.38699985, 1.4713658, 0.61881659, 0, 3.3431423, 0.75867297, 0.46171764, 0.10345541, 0.10153956, 0.74909377} -{ 0.20116329, 1.576737, 0.082381156, 0.29120781, 0.10153956, 0.46554933, 1.3698262, 0.26055435, 8.5867987, 0.38891569, 0.23948011, 0.68395518, 0.16667815, 3.3431423, 0, 0.73759872, 0.60157402, 0.17625736, 0.44064339, 0.61881659} -{ 4.6746517, 4.465825, 1.1303461, 1.0881976, 0.93301449, 1.323846, 0.58049978, 0.41382162, 1.6629499, 0.98857388, 0.1781732, 3.9945282, 2.3028407, 0.75867297, 0.73759872, 0, 4.1209737, 0.31994542, 0.13985638, 1.0000689} -{ 2.5672267, 1.1035243, 0.50961366, 0.70694527, 0.28354444, 0.17625736, 0.061306907, 1.9924745, 1.7587419, 0.29887117, 1.2357173, 2.6687663, 0.49811862, 0.46171764, 0.60157402, 4.1209737, 0, 1.456039, 0.055559384, 0.1360247} -{ 1.8545339, 1.1341778, 0.14368806, 0.38316817, 0.60732155, 0.17434152, 0.047896021, 9.1902885, 0.47704437, 1.6572023, 0.9100244, 0.15901479, 0.23373258, 0.10345541, 0.17625736, 0.31994542, 1.456039, 0, 0.019158408, 0.22798506} -{ 0.026821772, 0.83339077, 0.034485135, 0.12069797, 0.89661351, 0.15709895, 0.13219302, 0.080465315, 0.019158408, 0.30461869, 0.16476231, 0.076633634, 0.093876201, 0.10153956, 0.44064339, 0.13985638, 0.055559384, 0.019158408, 0, 0.66288093} -{ 0.10728709, 2.8086227, 0.53835128, 0.2720494, 4.5405428, 0.019158408, 3.7761223, 0.17050984, 0.47321269, 0.36209392, 0.41190578, 1.444544, 0.18583656, 0.74909377, 0.61881659, 1.0000689, 0.1360247, 0.22798506, 0.66288093, 0} -}; +{0.0, 0.17842659999999999, 0.092912900000000007, 1.2410950000000001, 0.0089291809999999996, 0.19922690000000001, 0.95218210000000003, 1.8519509999999999, 5.2413160000000003, 0.1140412, 0.069691009999999998, 0.073883550000000006, 0.062992709999999993, 0.11301460000000001, 1.800713, 0.99883580000000005, 2.9123169999999998, 0.079395489999999999, 0.1433528, 3.7744770000000001} +{0.17842659999999999, 0.0, 0.78291299999999997, 0.057953739999999997, 0.1821885, 1.9239010000000001, 0.062738630000000004, 1.0893999999999999, 10.4955, 0.32451750000000001, 0.3932002, 7.5492400000000002, 0.33623259999999999, 0.082086770000000003, 0.3498713, 1.9264349999999999, 1.1352580000000001, 0.57242859999999995, 0.17113149999999999, 0.1366145} +{0.092912900000000007, 0.78291299999999997, 0.0, 7.1851820000000002, 1.3742680000000001e-06, 0.087059890000000001, 0.50383730000000004, 0.48689009999999999, 14.05444, 1.762721, 0.027694420000000001, 6.1903180000000004, 0.039721729999999997, 0.19554460000000001, 0.0073425540000000003, 7.3483460000000003, 2.1471749999999998, 0.00073109369999999996, 2.622763, 0.049312059999999998} +{1.2410950000000001, 0.057953739999999997, 7.1851820000000002, 0.0, 0.023400190000000001, 0.18438560000000001, 7.4266189999999996, 2.1124000000000001, 11.26995, 0.039169990000000002, 0.030205019999999999, 0.066227720000000004, 0.033575769999999998, 0.1031734, 0.1509482, 0.58229880000000001, 0.15168809999999999, 0.01423897, 0.90783380000000002, 0.40760740000000001} +{0.0089291809999999996, 0.1821885, 1.3742680000000001e-06, 0.023400190000000001, 0.0, 1.046446e-08, 7.5192150000000001e-11, 0.058911230000000002, 3.9633880000000001, 0.0006594967, 0.0060792190000000003, 3.7228779999999998e-16, 0.0072131779999999998, 0.1993818, 0.0048783949999999998, 0.26394820000000002, 3.225214e-06, 0.44408330000000001, 0.77416119999999999, 0.022435119999999999} +{0.19922690000000001, 1.9239010000000001, 0.087059890000000001, 0.18438560000000001, 1.046446e-08, 0.0, 3.6916709999999999, 0.055163400000000001, 8.9084339999999997, 6.7127360000000003e-06, 0.6802781, 3.030805, 0.001233336, 0.00149661, 0.74269090000000004, 0.00059064049999999998, 0.12020939999999999, 4.3329830000000002e-05, 0.027370909999999998, 0.0090477370000000001} +{0.95218210000000003, 0.062738630000000004, 0.50383730000000004, 7.4266189999999996, 7.5192150000000001e-11, 3.6916709999999999, 0.0, 1.38937, 7.2980799999999997, 0.00010299589999999999, 0.0012831209999999999, 3.608816, 0.076595659999999996, 0.052886250000000003, 0.028898150000000001, 0.067767090000000002, 0.060166240000000003, 0.02252612, 0.1240642, 0.57954090000000003} +{1.8519509999999999, 1.0893999999999999, 0.48689009999999999, 2.1124000000000001, 0.058911230000000002, 0.055163400000000001, 1.38937, 0.0, 9.1395180000000007, 0.035604820000000002, 0.021579359999999999, 0.055044000000000003, 0.021872639999999999, 0.19847719999999999, 0.079150559999999995, 0.99842149999999996, 0.078627669999999997, 0.13868530000000001, 0.22958419999999999, 0.42281999999999997} +{5.2413160000000003, 10.4955, 14.05444, 11.26995, 3.9633880000000001, 8.9084339999999997, 7.2980799999999997, 9.1395180000000007, 0.0, 4.7065859999999997, 5.8791029999999997, 1.455741, 2.298295, 5.642309, 10.494960000000001, 5.4391160000000003, 3.4432849999999999, 7.01389, 20.55414, 6.890244} +{0.1140412, 0.32451750000000001, 1.762721, 0.039169990000000002, 0.0006594967, 6.7127360000000003e-06, 0.00010299589999999999, 0.035604820000000002, 4.7065859999999997, 0.0, 1.6011230000000001, 0.50597930000000002, 10.96748, 2.7147049999999999, 0.050165679999999997, 0.60076070000000004, 3.0871520000000001, 0.063187480000000004, 0.29031649999999998, 7.9266750000000004} +{0.069691009999999998, 0.3932002, 0.027694420000000001, 0.030205019999999999, 0.0060792190000000003, 0.6802781, 0.0012831209999999999, 0.021579359999999999, 5.8791029999999997, 1.6011230000000001, 0.0, 0.021584510000000001, 5.6479850000000003, 3.3906179999999999, 1.149931, 0.1580539, 0.57027919999999999, 0.3378544, 0.15213199999999999, 3.59531} +{0.073883550000000006, 7.5492400000000002, 6.1903180000000004, 0.066227720000000004, 3.7228779999999998e-16, 3.030805, 3.608816, 0.055044000000000003, 1.455741, 0.50597930000000002, 0.021584510000000001, 0.0, 1.238634, 0.0046490350000000001, 0.0099489939999999992, 0.086884050000000004, 1.0392980000000001, 0.0080242630000000002, 0.07109973, 0.034934399999999997} +{0.062992709999999993, 0.33623259999999999, 0.039721729999999997, 0.033575769999999998, 0.0072131779999999998, 0.001233336, 0.076595659999999996, 0.021872639999999999, 2.298295, 10.96748, 5.6479850000000003, 1.238634, 0.0, 3.94794, 0.074172790000000002, 0.018613540000000001, 1.4156120000000001, 0.10111489999999999, 0.0022467590000000001, 4.3967200000000002} +{0.11301460000000001, 0.082086770000000003, 0.19554460000000001, 0.1031734, 0.1993818, 0.00149661, 0.052886250000000003, 0.19847719999999999, 5.642309, 2.7147049999999999, 3.3906179999999999, 0.0046490350000000001, 3.94794, 0.0, 0.35561979999999999, 0.98130640000000002, 0.036744859999999997, 0.2199856, 7.0744639999999999, 1.6439459999999999} +{1.800713, 0.3498713, 0.0073425540000000003, 0.1509482, 0.0048783949999999998, 0.74269090000000004, 0.028898150000000001, 0.079150559999999995, 10.494960000000001, 0.050165679999999997, 1.149931, 0.0099489939999999992, 0.074172790000000002, 0.35561979999999999, 0.0, 1.284651, 0.90571120000000005, 0.0055160740000000002, 0.19921330000000001, 0.2217442} +{0.99883580000000005, 1.9264349999999999, 7.3483460000000003, 0.58229880000000001, 0.26394820000000002, 0.00059064049999999998, 0.067767090000000002, 0.99842149999999996, 5.4391160000000003, 0.60076070000000004, 0.1580539, 0.086884050000000004, 0.018613540000000001, 0.98130640000000002, 1.284651, 0.0, 3.0585749999999998, 0.1385142, 0.8104751, 0.074770409999999995} +{2.9123169999999998, 1.1352580000000001, 2.1471749999999998, 0.15168809999999999, 3.225214e-06, 0.12020939999999999, 0.060166240000000003, 0.078627669999999997, 3.4432849999999999, 3.0871520000000001, 0.57027919999999999, 1.0392980000000001, 1.4156120000000001, 0.036744859999999997, 0.90571120000000005, 3.0585749999999998, 0.0, 0.01412361, 0.099842550000000002, 0.2166054} +{0.079395489999999999, 0.57242859999999995, 0.00073109369999999996, 0.01423897, 0.44408330000000001, 4.3329830000000002e-05, 0.02252612, 0.13868530000000001, 7.01389, 0.063187480000000004, 0.3378544, 0.0080242630000000002, 0.10111489999999999, 0.2199856, 0.0055160740000000002, 0.1385142, 0.01412361, 0.0, 0.61212840000000002, 0.096635689999999996} +{0.1433528, 0.17113149999999999, 2.622763, 0.90783380000000002, 0.77416119999999999, 0.027370909999999998, 0.1240642, 0.22958419999999999, 20.55414, 0.29031649999999998, 0.15213199999999999, 0.07109973, 0.0022467590000000001, 7.0744639999999999, 0.19921330000000001, 0.8104751, 0.099842550000000002, 0.61212840000000002, 0.0, 0.5010635} +{3.7744770000000001, 0.1366145, 0.049312059999999998, 0.40760740000000001, 0.022435119999999999, 0.0090477370000000001, 0.57954090000000003, 0.42281999999999997, 6.890244, 7.9266750000000004, 3.59531, 0.034934399999999997, 4.3967200000000002, 1.6439459999999999, 0.2217442, 0.074770409999999995, 0.2166054, 0.096635689999999996, 0.5010635, 0.0}}; + + + + + fprintf (stdout, mapMatrixToDict (models.protein.alphabet, cpREV), "\n"): From 3c091da54ecadd582605ce9c2cdf643785b9fade Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Wed, 15 Nov 2017 13:29:28 -0500 Subject: [PATCH 05/24] Typo in generator dictionary --- res/TemplateBatchFiles/libv3/models/protein/empirical.bf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index 96929c6c0..5a69c1a28 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -13,7 +13,7 @@ models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDes "mtMAM": "models.protein.mtMAM.ModelDescription", "cpREV": "models.protein.cpREV.ModelDescription", "HIVBm": "models.protein.HIVBm.ModelDescription", - "HIVWm": "models.protein.HIVBm.ModelDescription", + "HIVWm": "models.protein.HIVWm.ModelDescription", "AB" : "models.protein.AB.ModelDescription"}; models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDescription", @@ -23,7 +23,7 @@ models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDesc "mtMAM": "models.protein.mtMAMF.ModelDescription", "cpREV": "models.protein.cpREVF.ModelDescription", "HIVBm": "models.protein.HIVBmF.ModelDescription", - "HIVWm": "models.protein.HIVBmF.ModelDescription", + "HIVWm": "models.protein.HIVWmF.ModelDescription", "AB" : "models.protein.ABF.ModelDescription"}; models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDescription", @@ -33,7 +33,7 @@ models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDesc "mtMAM": "models.protein.mtMAMML.ModelDescription", "cpREV": "models.protein.cpREVF.ModelDescription", "HIVBm": "models.protein.HIVBmML.ModelDescription", - "HIVWm": "models.protein.HIVBmML.ModelDescription", + "HIVWm": "models.protein.HIVWmML.ModelDescription", "AB" : "models.protein.ABML.ModelDescription"}; /** @module models.protein.empirical */ From fec39591ce5f5e98a1048138c4f633d40a2a4aac Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Wed, 15 Nov 2017 13:30:20 -0500 Subject: [PATCH 06/24] Typo2 in generator dictionary --- res/TemplateBatchFiles/libv3/models/protein/empirical.bf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index 5a69c1a28..43777c43d 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -31,7 +31,7 @@ models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDesc "JTT": "models.protein.JTTML.ModelDescription", "JC69": "models.protein.JC69ML.ModelDescription", "mtMAM": "models.protein.mtMAMML.ModelDescription", - "cpREV": "models.protein.cpREVF.ModelDescription", + "cpREV": "models.protein.cpREVML.ModelDescription", "HIVBm": "models.protein.HIVBmML.ModelDescription", "HIVWm": "models.protein.HIVWmML.ModelDescription", "AB" : "models.protein.ABML.ModelDescription"}; From 6c8ffae71c9b1c43695bef806d79f30864718b39 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Thu, 16 Nov 2017 09:14:42 -0500 Subject: [PATCH 07/24] LEISR version change to 0.2 --- res/TemplateBatchFiles/LEISR.bf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/TemplateBatchFiles/LEISR.bf b/res/TemplateBatchFiles/LEISR.bf index e70a62054..f6712148c 100644 --- a/res/TemplateBatchFiles/LEISR.bf +++ b/res/TemplateBatchFiles/LEISR.bf @@ -30,7 +30,7 @@ utility.ToggleEnvVariable ("NORMALIZE_SEQUENCE_NAMES", 1); leisr.analysis_description = { terms.io.info: "LEISR (Likelihood Estimation of Individual Site Rates) infer relative amino-acid or nucleotide rates from a fixed nucleotide or amino-acid alignment and tree. Relative site-specific substitution rates are inferred by first optimizing alignment-wide branch lengths, and then inferring a site-specific uniform tree scaler", - terms.io.version: "0.1alpha", + terms.io.version: "0.2", terms.io.reference: "Spielman, S.J. and Kosakovsky Pond, S.L. Relative evolutionary rate inference in HyPhy with LEISR. bioRxiv. https://doi.org/10.1101/206011. (2017); Pupko, T., Bell, R. E., Mayrose, I., Glaser, F. & Ben-Tal, N. Rate4Site: an algorithmic tool for the identification of functional regions in proteins by surface mapping of evolutionary determinants within their homologues. Bioinformatics 18, S71–S77 (2002).", terms.io.authors: "Sergei L Kosakovsky Pond and Stephanie J Spielman", terms.io.contact: "{spond,stephanie.spielman}@temple.edu" From efe1156d791ca7272296fcf73dcc718641280b85 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Sat, 25 Nov 2017 14:45:08 -0500 Subject: [PATCH 08/24] RELAX was missing analysis field in JSON, unclear how missed this earlier.. --- .../SelectionAnalyses/RELAX.bf | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/res/TemplateBatchFiles/SelectionAnalyses/RELAX.bf b/res/TemplateBatchFiles/SelectionAnalyses/RELAX.bf index 6c5299c69..3a4be057a 100644 --- a/res/TemplateBatchFiles/SelectionAnalyses/RELAX.bf +++ b/res/TemplateBatchFiles/SelectionAnalyses/RELAX.bf @@ -30,7 +30,17 @@ utility.SetEnvVariable ("ASSUME_REVERSIBLE_MODELS", TRUE); /*------------------------------------------------------------------------------*/ -relax.json = { terms.json.input: {}, +relax.analysis_description = { + terms.io.info : "RELAX (a random effects test of selection relaxation) uses a random effects branch-site model framework to test whether a set of 'Test' branches evolves under relaxed selection relative to a set of 'Reference' branches (R), as measured by the relaxation parameter (K).", + terms.io.version : "2.0", + terms.io.reference : "RELAX: Detecting Relaxed Selection in a Phylogenetic Framework (2015). Mol Biol Evol 32 (3): 820-832", + terms.io.authors : "Sergei L Kosakovsky Pond, Ben Murrell, Steven Weaver and Temple iGEM / UCSD viral evolution group", + terms.io.contact : "spond@temple.edu", + terms.io.requirements : "in-frame codon alignment and a phylogenetic tree, with at least two groups of branches defined using the {} notation (one group can be defined as all unlabeled branches)" + }; + +relax.json = { terms.json.analysis: relax.analysis_description, + terms.json.input: {}, terms.json.fits : {}, terms.json.timers : {}, terms.json.test_results : {} @@ -70,14 +80,7 @@ relax.display_orders = {terms.original_name: -1, /*------------------------------------------------------------------------------*/ -relax.analysis_description = { - terms.io.info : "RELAX (a random effects test of selection relaxation) uses a random effects branch-site model framework to test whether a set of 'Test' branches evolves under relaxed selection relative to a set of 'Reference' branches (R), as measured by the relaxation parameter (K).", - terms.io.version : "2.0", - terms.io.reference : "RELAX: Detecting Relaxed Selection in a Phylogenetic Framework (2015). Mol Biol Evol 32 (3): 820-832", - terms.io.authors : "Sergei L Kosakovsky Pond, Ben Murrell, Steven Weaver and Temple iGEM / UCSD viral evolution group", - terms.io.contact : "spond@temple.edu", - terms.io.requirements : "in-frame codon alignment and a phylogenetic tree, with at least two groups of branches defined using the {} notation (one group can be defined as all unlabeled branches)" - }; + io.DisplayAnalysisBanner ( relax.analysis_description ); From e4762eeabfaa707e4be8551dd20fc563e6f36acf Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Thu, 30 Nov 2017 15:12:27 -0500 Subject: [PATCH 09/24] Added mtMet model, recent model of metazoan mitochondrial evolution which is less pathological than mtmam --- .../libv3/models/protein.bf | 1 + .../libv3/models/protein/empirical.bf | 272 +++++++++++++++++- 2 files changed, 272 insertions(+), 1 deletion(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein.bf b/res/TemplateBatchFiles/libv3/models/protein.bf index 170c2be49..b505c3eba 100644 --- a/res/TemplateBatchFiles/libv3/models/protein.bf +++ b/res/TemplateBatchFiles/libv3/models/protein.bf @@ -15,6 +15,7 @@ models.protein.empirical_models = {{"LG", "Empirical model of protein evolution {"JTT", "Empirical model of protein evolution from Jones, Taylor, and Thornton (1996). Ref: https://doi.org/10.1093/bioinformatics/8.3.275"}, {"JC69", "Empirical model of protein evolution with equal exchangeability rates among all amino acids, also known as JC69."}, {"mtMAM", "Empirical model of protein evolution for mammalian mitochondrial genomes from Yang N, Nielsen R, and Hasegawa M. (1998). Ref: http://dx.doi.org/10.1093/oxfordjournals.molbev.a025888"}, + {"mtMet", "Empirical model of protein evolution for metazoan mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, {"cpREV", "Empirical model of protein evolution for chloroplast genomes from from Adachi et al. (2000). Ref: https://www.ncbi.nlm.nih.gov/pubmed/10795826"}, {"HIVBm", "Empirical model of protein evolution for between-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, {"HIVWm", "Empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index 43777c43d..4bdab1252 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -11,6 +11,7 @@ models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDes "JTT": "models.protein.JTT.ModelDescription", "JC69": "models.protein.JC69.ModelDescription", "mtMAM": "models.protein.mtMAM.ModelDescription", + "mtMet": "models.protein.mtMet.ModelDescription", "cpREV": "models.protein.cpREV.ModelDescription", "HIVBm": "models.protein.HIVBm.ModelDescription", "HIVWm": "models.protein.HIVWm.ModelDescription", @@ -21,6 +22,7 @@ models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDesc "JTT": "models.protein.JTTF.ModelDescription", "JC69": "models.protein.JC69F.ModelDescription", "mtMAM": "models.protein.mtMAMF.ModelDescription", + "mtMet": "models.protein.mtMetF.ModelDescription", "cpREV": "models.protein.cpREVF.ModelDescription", "HIVBm": "models.protein.HIVBmF.ModelDescription", "HIVWm": "models.protein.HIVWmF.ModelDescription", @@ -31,6 +33,7 @@ models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDesc "JTT": "models.protein.JTTML.ModelDescription", "JC69": "models.protein.JC69ML.ModelDescription", "mtMAM": "models.protein.mtMAMML.ModelDescription", + "mtMet": "models.protein.mtMetML.ModelDescription", "cpREV": "models.protein.cpREVML.ModelDescription", "HIVBm": "models.protein.HIVBmML.ModelDescription", "HIVWm": "models.protein.HIVWmML.ModelDescription", @@ -680,6 +683,53 @@ function models.protein.ABML.ModelDescription(type) { + +/**************************************** mtMet functions *************************************/ + + +/** + * @name models.protein.mtMet.ModelDescription + * @description Create the baseline schema (dictionary) for the mtMet model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ + function models.protein.mtMet.ModelDescription(type) { + models.protein.mtMet.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.mtMet.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.mtMet.Rij; + models.protein.mtMet.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.mtMet.frequencies"; + return models.protein.mtMet.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtMetF.ModelDescription + * @description Create the baseline schema (dictionary) for the mtMet+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtMetF.ModelDescription(type) { + models.protein.mtMetF.ModelDescription.model_definition = models.protein.mtMet.ModelDescription(type); + models.protein.mtMetF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.mtMetF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.mtMetF.ModelDescription.model_definition; +} + + +/** + * @name models.protein.mtMetML.ModelDescription + * @description Create the baseline schema (dictionary) for the mtMet+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtMetML.ModelDescription(type) { + models.protein.mtMetML.ModelDescription.model_definition = models.protein.mtMet.ModelDescription(type); + models.protein.mtMetML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.mtMetML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.mtMetML.ModelDescription.model_definition; +} + + + + /*=============================================================================================*/ /** Below this section are all of the empirical matrices and frequency vectors, including Rij **/ @@ -1793,7 +1843,7 @@ lfunction models.protein.mtMAM.frequencies (model, namespace, datafilter) { return model; } -/* Define a dictionary of equal amino-acid exchangeability rates for the MTMam model of protein evolution. */ +/* Define a dictionary of equal amino-acid exchangeability rates for the mtMAM model of protein evolution. */ models.protein.mtMAM.Rij = { "A": {"C": 0.0, @@ -3041,3 +3091,223 @@ models.protein.AB.Rij = { } }; + + + +lfunction models.protein.mtMet.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.043793200} + {0.012957800} + {0.057001300} + {0.016899000} + {0.011330500} + {0.018018100} + {0.022538500} + {0.047050100} + {0.017183700} + {0.089779400} + {0.155226000} + {0.039913500} + {0.067444300} + {0.088448000} + {0.037528200} + {0.093752200} + {0.063579000} + {0.022671300} + {0.041568200} + {0.053317400} + }; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + +models.protein.mtMet.Rij = { +'A': {'C': 0.63325584800000001, + 'D': 0.11915685500000001, + 'E': 0.17916388799999999, + 'F': 0.062762255000000003, + 'G': 1.4658622800000001, + 'H': 0.030192130000000001, + 'I': 0.367600449, + 'K': 0.020509507999999999, + 'L': 0.109872766, + 'M': 0.65336399300000003, + 'N': 0.03289392, + 'P': 0.40807705300000002, + 'Q': 0.052454947000000002, + 'R': 0.058078194999999999, + 'S': 2.7716860149999998, + 'T': 6.7308851599999997, + 'V': 2.815163085, + 'W': 0.013623415999999999, + 'Y': 0.014501406999999999}, + 'C': {'D': 0.077419373999999999, + 'E': 0.050609064000000002, + 'F': 0.92581086400000001, + 'G': 0.91412559000000004, + 'H': 0.60383390000000003, + 'I': 0.235804245, + 'K': 0.015753762000000001, + 'L': 0.29951899700000001, + 'M': 0.49234014399999998, + 'N': 0.29328103, + 'P': 0.029408410999999999, + 'Q': 0.15259520800000001, + 'R': 0.73981385700000002, + 'S': 3.2830148709999998, + 'T': 0.33866819599999998, + 'V': 1.3945280440000001, + 'W': 1.018410485, + 'Y': 1.967371255}, + 'D': {'E': 6.0337889819999999, + 'F': 0.012560742999999999, + 'G': 0.63075329899999999, + 'H': 0.47979111200000002, + 'I': 0.010668856000000001, + 'K': 0.049007455999999998, + 'L': 0.0055291439999999997, + 'M': 0.026109947000000001, + 'N': 4.6584200710000001, + 'P': 0.044609562999999998, + 'Q': 0.13135570199999999, + 'R': 0.049700411999999999, + 'S': 0.36080478100000002, + 'T': 0.102136221, + 'V': 0.084589028999999996, + 'W': 0.040920527999999998, + 'Y': 0.16028995800000001}, + 'E': {'F': 0.017716308, + 'G': 0.76885329499999999, + 'H': 0.105414735, + 'I': 0.014004526, + 'K': 1.3792177830000001, + 'L': 0.019157619000000001, + 'M': 0.128410054, + 'N': 0.81224112400000004, + 'P': 0.048786298999999998, + 'Q': 2.2366176229999999, + 'R': 0.080835481000000001, + 'S': 0.36310446600000001, + 'T': 0.13480267100000001, + 'V': 0.227827051, + 'W': 0.086028795000000005, + 'Y': 0.093214721}, + 'F': {'G': 0.068139280999999996, + 'H': 0.090353066999999995, + 'I': 0.75090054100000003, + 'K': 0.097125533999999999, + 'L': 1.811101233, + 'M': 0.74842499699999998, + 'N': 0.13875929100000001, + 'P': 0.054271888999999997, + 'Q': 0.026306324999999998, + 'R': 0.0080439580000000004, + 'S': 0.49934990099999998, + 'T': 0.053947742999999999, + 'V': 0.46624344200000001, + 'W': 0.330781928, + 'Y': 3.2090833029999999}, + 'G': {'H': 0.025252655999999998, + 'I': 0.013781055, + 'K': 0.13418717499999999, + 'L': 0.027264554, + 'M': 0.14533146599999999, + 'N': 0.54375075699999997, + 'P': 0.005914206, + 'Q': 0.072395535999999996, + 'R': 0.21996712400000001, + 'S': 1.746570145, + 'T': 0.02455829, + 'V': 0.41714895400000002, + 'W': 0.233963371, + 'Y': 0.046746340999999997}, + 'H': {'I': 0.017140138999999999, + 'K': 0.13515366300000001, + 'L': 0.11163893699999999, + 'M': 0.032834314000000003, + 'N': 1.7386796440000001, + 'P': 0.51995437499999997, + 'Q': 4.5184508909999996, + 'R': 1.5222568649999999, + 'S': 0.29758608399999997, + 'T': 0.221010609, + 'V': 0.0035110079999999999, + 'W': 0.037480926999999997, + 'Y': 3.9079185509999999}, + 'I': {'K': 0.064936611000000005, + 'L': 1.8979743680000001, + 'M': 2.9183532080000001, + 'N': 0.244934765, + 'P': 0.024850021, + 'Q': 0.0088756860000000007, + 'R': 0.012428576, + 'S': 0.096272864, + 'T': 2.4534581430000002, + 'V': 10.953425842, + 'W': 0.028656797000000001, + 'Y': 0.135319461}, + 'K': {'L': 0.06132452, + 'M': 0.65931076, + 'N': 2.53039843, + 'P': 0.121234921, + 'Q': 1.8272181860000001, + 'R': 1.057185633, + 'S': 0.69508812799999997, + 'T': 0.39385170400000002, + 'V': 0.055461435000000003, + 'W': 0.073508962999999997, + 'Y': 0.281699174}, + 'L': {'M': 3.4255537089999999, + 'N': 0.046318944000000001, + 'P': 0.27026078100000001, + 'Q': 0.25445246700000002, + 'R': 0.058180015000000002, + 'S': 0.31152513100000001, + 'T': 0.253366704, + 'V': 0.95827374300000001, + 'W': 0.25324301300000002, + 'Y': 0.123555332}, + 'M': {'N': 0.39982772300000002, + 'P': 0.032714699, + 'Q': 0.237094366, + 'R': 0.013494034, + 'S': 0.45873409599999998, + 'T': 3.0352157260000001, + 'V': 2.5624848949999999, + 'W': 0.167575318, + 'Y': 0.31659903099999998}, + 'N': {'P': 0.080313958000000005, + 'Q': 0.83279153299999997, + 'R': 0.14136427500000001, + 'S': 2.6343785139999998, + 'T': 0.96128509299999998, + 'V': 0.051741626999999998, + 'W': 0.049019408, + 'Y': 1.020785491}, + 'P': {'Q': 0.84951243499999995, + 'R': 0.15500856599999999, + 'S': 1.231180819, + 'T': 0.73460491000000006, + 'V': 0.054078532999999998, + 'W': 0.029433866, + 'Y': 0.054012182999999998}, + 'Q': {'R': 2.6731080889999999, + 'S': 0.38480028399999999, + 'T': 0.274195947, + 'V': 0.027669233000000001, + 'W': 0.12314062000000001, + 'Y': 0.319105788}, + 'R': {'S': 0.19737918500000001, + 'T': 0.056079812999999999, + 'V': 0.041063684000000003, + 'W': 0.37081989199999998, + 'Y': 0.12751933200000001}, + 'S': {'T': 3.1147429070000001, + 'V': 0.26710946499999999, + 'W': 0.16921202900000001, + 'Y': 0.37418428599999998}, + 'T': {'V': 1.5140596740000001, 'W': 0.014378616, 'Y': 0.091031787000000003}, + 'V': {'W': 0.093136256000000001, 'Y': 0.069964540000000006}, + 'W': {'Y': 0.48104431600000003}, + 'Y': {}} \ No newline at end of file From 629e0f2fb270652bed89e689d508a7a847a81901 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Thu, 30 Nov 2017 17:12:47 -0500 Subject: [PATCH 10/24] EFV field was incorrect and should say Equilibrium Frequencies. One day all LEISR changes will cease. --- res/TemplateBatchFiles/LEISR.bf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/TemplateBatchFiles/LEISR.bf b/res/TemplateBatchFiles/LEISR.bf index f6712148c..9eeda4e85 100644 --- a/res/TemplateBatchFiles/LEISR.bf +++ b/res/TemplateBatchFiles/LEISR.bf @@ -266,7 +266,7 @@ leisr.json_content = { terms.json.input : terms.json.parameters: leisr.alignment_wide_MLES[terms.parameters], terms.json.AICc: leisr.aicc, terms.json.rate_distribution: leisr.store_global, - terms.efv_estimate: (leisr.alignment_wide_MLES[utility.getGlobalValue("terms.efv_estimate")])["VALUEINDEXORDER"][0] + terms.json.frequencies: (leisr.alignment_wide_MLES[utility.getGlobalValue("terms.efv_estimate")])["VALUEINDEXORDER"][0] } }, terms.json.MLE : {terms.json.headers : leisr.table_headers, From 36c52fc687bbc43daa91b4f0146c1c4ce56d52b1 Mon Sep 17 00:00:00 2001 From: Sergei Kosakovsky Pond Date: Sat, 2 Dec 2017 17:31:34 -0500 Subject: [PATCH 11/24] Closes #703 --- src/core/calcnode.cpp | 13 +++- src/core/calcnode2.cpp | 2 +- src/core/formula.cpp | 103 +++++++++++++++++--------- src/core/include/matrix.h | 3 +- src/core/likefunc.cpp | 21 ++++-- src/core/matrix.cpp | 150 +++++++++++++++++++++++--------------- 6 files changed, 190 insertions(+), 102 deletions(-) diff --git a/src/core/calcnode.cpp b/src/core/calcnode.cpp index 4754a0a6b..46dc4b442 100644 --- a/src/core/calcnode.cpp +++ b/src/core/calcnode.cpp @@ -788,6 +788,9 @@ bool _CalcNode::NeedNewCategoryExponential(long catID) const return false; } +//#define _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL 12733 +#//define _UBER_VERBOSE_MX_UPDATE_DUMP 1 + //_______________________________________________________________________________________________ bool _CalcNode::RecomputeMatrix (long categID, long totalCategs, _Matrix* storeRateMatrix, _List* queue, _SimpleList* tags, _List* bufferedOps) { @@ -832,7 +835,7 @@ bool _CalcNode::RecomputeMatrix (long categID, long totalCategs, _Matrix locVar = LocateVar (iVariables->lData[i]); curVar->SetValue(locVar->Compute()); #ifdef _UBER_VERBOSE_MX_UPDATE_DUMP - if (1 || likeFuncEvalCallCount == _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL) { + if (likeFuncEvalCallCount == _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL) { fprintf (stderr, "[_CalcNode::RecomputeMatrix] Node %s, var %s, value = %15.12g\n", GetName()->sData, curVar->GetName()->sData, curVar->Compute()->Value()); } #endif @@ -847,7 +850,7 @@ bool _CalcNode::RecomputeMatrix (long categID, long totalCategs, _Matrix locVar = LocateVar (dVariables->lData[i]); curVar->SetValue(locVar->Compute()); #ifdef _UBER_VERBOSE_MX_UPDATE_DUMP - if (1 || likeFuncEvalCallCount == _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL) { + if (likeFuncEvalCallCount == _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL) { fprintf (stderr, "[_CalcNode::RecomputeMatrix] Node %s, var %s, value = %15.12g\n", GetName()->sData, curVar->GetName()->sData, curVar->Compute()->Value()); } #endif @@ -855,7 +858,7 @@ bool _CalcNode::RecomputeMatrix (long categID, long totalCategs, _Matrix } #ifdef _UBER_VERBOSE_MX_UPDATE_DUMP - if (1|| likeFuncEvalCallCount == _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL && gVariables) { + if (likeFuncEvalCallCount == _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL && gVariables) { for (unsigned long i=0; ilLength; i++) { _Variable* curVar = LocateVar(gVariables->GetElement(i)); fprintf (stderr, "[_CalcNode::RecomputeMatrix] Node %s, var %s, value = %15.12g\n", GetName()->sData, curVar->GetName()->sData, curVar->Compute()->Value()); @@ -893,7 +896,9 @@ bool _CalcNode::RecomputeMatrix (long categID, long totalCategs, _Matrix if (isExplicitForm && bufferedOps) { _Matrix * bufferedExp = (_Matrix*)GetExplicitFormModel()->Compute (0,nil, bufferedOps); #ifdef _UBER_VERBOSE_MX_UPDATE_DUMP - fprintf (stderr, "[_CalcNode::RecomputeMatrix] Setting (buffered) category %ld/%ld for node %s\n", categID, totalCategs, GetName()->sData); + if (likeFuncEvalCallCount == _UBER_VERBOSE_MX_UPDATE_DUMP_LF_EVAL) { + fprintf (stderr, "[_CalcNode::RecomputeMatrix] Setting (buffered) category %ld/%ld for node %s\n", categID, totalCategs, GetName()->sData); + } #endif SetCompExp ((_Matrix*)bufferedExp->makeDynamic(), totalCategs>1?categID:-1); return false; diff --git a/src/core/calcnode2.cpp b/src/core/calcnode2.cpp index 5d1412156..e0b29e11b 100644 --- a/src/core/calcnode2.cpp +++ b/src/core/calcnode2.cpp @@ -246,7 +246,7 @@ void _TheTree::ExponentiateMatrices (_List& expNodes, long tc, long catI if (isExplicitForm.lData[matrixID] == 0 || !hasExpForm) { // normal matrix to exponentiate ((_CalcNode*) nodesToDo(matrixID))->SetCompExp (((_Matrix*)matrixQueue(matrixID))->Exponentiate(), catID); } else { - (*computedExponentials) [matrixID] = ((_Matrix*)matrixQueue(matrixID))->Exponentiate(); + (*computedExponentials) [matrixID] = ((_Matrix*)matrixQueue(matrixID))->Exponentiate(); } } diff --git a/src/core/formula.cpp b/src/core/formula.cpp index 628068c79..847fe9608 100644 --- a/src/core/formula.cpp +++ b/src/core/formula.cpp @@ -1265,6 +1265,8 @@ long _Formula::NumberOperations(void) const return theFormula.lLength; } +//extern long likeFuncEvalCallCount; + //__________________________________________________________________________________ long _Formula::ExtractMatrixExpArguments (_List* storage) { @@ -1282,6 +1284,15 @@ long _Formula::ExtractMatrixExpArguments (_List* storage) { _Operation* nextOp ((_Operation*)(((BaseRef**)theFormula.lData)[i+1])); if (! cacheUpdated && nextOp->CanResultsBeCached(thisOp)) { + /*if (likeFuncEvalCallCount == 12733 && i == 13) { + _Matrix * this_matrix = (_Matrix *)LocateVar (thisOp->GetAVariable())->GetValue(); + + _String buffer (1024UL, true), id ("TEMP"); + this_matrix->Serialize(buffer, id); + buffer.Finalize(); + fprintf (stderr, "[_Formula::ExtractMatrixExpArguments] Get model matrix \n step %ld \n %s \n\n", i, (const char*) buffer ); + }*/ + _Stack temp; thisOp->Execute (temp); @@ -1300,6 +1311,7 @@ long _Formula::ExtractMatrixExpArguments (_List* storage) { cacheUpdated = true; cacheID++; if (nextOp->CanResultsBeCached(thisOp, true)) { + storage->AppendNewInstance(currentArg); count ++; } @@ -1736,23 +1748,37 @@ void _Formula::ConvertFromSimple (_SimpleList& variableIndex) } } +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL +extern long likeFuncEvalCallCount; +#endif + //__________________________________________________________________________________ _Parameter _Formula::ComputeSimple (_SimpleFormulaDatum* stack, _SimpleFormulaDatum* varValues) { if (!theFormula.lLength) { return 0.0; } - + long stackTop = 0; - + for (int i=0; itheNumber) { stack[stackTop++].value = thisOp->theNumber->Value(); +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL + if (likeFuncEvalCallCount >= __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL) { + fprintf (stderr, "[_Formula::ComputeSimple] Computing step %d, pushed constant %g\n", i, stack[stackTop-1].value ); + } +#endif continue; } else { if (thisOp->theData>-1) { stack[stackTop++] = varValues[thisOp->theData]; +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL + if (likeFuncEvalCallCount >= __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL) { + fprintf (stderr, "[_Formula::ComputeSimple] Computing step %d, pushed variable %g\n", i, stack[stackTop-1].value ); + } +#endif } else { stackTop--; if (thisOp->numberOfTerms==2) { @@ -1763,44 +1789,55 @@ _Parameter _Formula::ComputeSimple (_SimpleFormulaDatum* stack, _SimpleFormulaDa return 0.0; } stack[stackTop-1].value = (*theFunc)(stack[stackTop-1].value,stack[stackTop].value); +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL + if (likeFuncEvalCallCount >= __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL) { + fprintf (stderr, "[_Formula::ComputeSimple] Computing step %d (two op function), value %g\n", i, stack[stackTop-1].value ); + } +#endif + } else { - switch (thisOp->numberOfTerms) { - case -2 : { - _Parameter (*theFunc) (Ptr,_Parameter); - theFunc = (_Parameter(*)(Ptr,_Parameter))thisOp->opCode; - if (stackTop<1L) { - WarnError ("Internal error in _Formula::ComputeSimple - stack underflow.)"); - return 0.0; + switch (thisOp->numberOfTerms) { + case -2 : { + _Parameter (*theFunc) (Ptr,_Parameter); + theFunc = (_Parameter(*)(Ptr,_Parameter))thisOp->opCode; + if (stackTop<1L) { + WarnError ("Internal error in _Formula::ComputeSimple - stack underflow.)"); + return 0.0; + } + stack[stackTop-1].value = (*theFunc)(stack[stackTop-1].reference,stack[stackTop].value); + break; + } + case -3 : { + void (*theFunc) (Ptr,_Parameter,_Parameter); + theFunc = (void(*)(Ptr,_Parameter,_Parameter))thisOp->opCode; + if (stackTop != 2 || i != theFormula.lLength - 1) { + WarnError ("Internal error in _Formula::ComputeSimple - stack underflow or MCoord command is not the last one.)"); + + return 0.0; + } + //stackTop = 0; + // value, reference, index + (*theFunc)(stack[1].reference,stack[2].value, stack[0].value); + break; + } + default: { + _Parameter (*theFunc) (_Parameter); + theFunc = (_Parameter(*)(_Parameter))thisOp->opCode; + stack[stackTop].value = (*theFunc)(stack[stackTop].value); +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL + if (likeFuncEvalCallCount >= __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL) { + fprintf (stderr, "[_Formula::ComputeSimple] Computing step %d (one op function), value %g\n", i, stack[stackTop-1].value ); + } +#endif + ++stackTop; } - stack[stackTop-1].value = (*theFunc)(stack[stackTop-1].reference,stack[stackTop].value); - break; - } - case -3 : { - void (*theFunc) (Ptr,_Parameter,_Parameter); - theFunc = (void(*)(Ptr,_Parameter,_Parameter))thisOp->opCode; - if (stackTop != 2 || i != theFormula.lLength - 1) { - WarnError ("Internal error in _Formula::ComputeSimple - stack underflow or MCoord command is not the last one.)"); - - return 0.0; - } - //stackTop = 0; - // value, reference, index - (*theFunc)(stack[1].reference,stack[2].value, stack[0].value); - break; - } - default: { - _Parameter (*theFunc) (_Parameter); - theFunc = (_Parameter(*)(_Parameter))thisOp->opCode; - stack[stackTop].value = (*theFunc)(stack[stackTop].value); - ++stackTop; } - } - + } } } } - + return stack[0].value; } diff --git a/src/core/include/matrix.h b/src/core/include/matrix.h index bf92717a1..da0cc21c5 100644 --- a/src/core/include/matrix.h +++ b/src/core/include/matrix.h @@ -226,9 +226,10 @@ class _Matrix: public _MathObject { void AplusBx (_Matrix&, _Parameter); // A = A + B*x (scalar) - void Sqr (_Parameter* _hprestrict_); + _Parameter Sqr (_Parameter* _hprestrict_); // square the matrix; takes a scratch vector // of at least lDim doubles + // returns the maximum element-wise difference between X and X^2 _List* ComputeRowAndColSums (void); _Matrix* MutualInformation (void); diff --git a/src/core/likefunc.cpp b/src/core/likefunc.cpp index 7e2f32f2b..1e7ada8f2 100644 --- a/src/core/likefunc.cpp +++ b/src/core/likefunc.cpp @@ -1960,12 +1960,15 @@ _Parameter _LikelihoodFunction::Compute (void) bool done = false; #ifdef _UBER_VERBOSE_LF_DEBUG - fprintf (stderr, "\n*** Likelihood function evaluation %ld ***\n", likeFuncEvalCallCount+1); - for (unsigned long i=0; iHasChanged()) { - fprintf (stderr, "[CHANGED] "); - fprintf (stderr, "%s = %15.12g\n", v->GetName()->sData, v->theValue); + + if (likeFuncEvalCallCount >= 12731) { + fprintf (stderr, "\n*** Likelihood function evaluation %ld ***\n", likeFuncEvalCallCount+1); + for (unsigned long i=0; iHasChanged()) { + fprintf (stderr, "[CHANGED] "); + fprintf (stderr, "%s = %15.12g\n", v->GetName()->sData, v->theValue); + } } } #endif @@ -2169,6 +2172,12 @@ _Parameter _LikelihoodFunction::Compute (void) return -A_LARGE_NUMBER; } + if (result >= 0) { + char buffer [2048]; + snprintf (buffer, 2047, "Internal error: Encountered a positive log-likelihood at evaluation %ld, mode %ld, template %ld", likeFuncEvalCallCount-1, computeMode, templateKind); + WarnError (buffer); + } + ComputeParameterPenalty (); _Parameter regularized_value = result - smoothingPenalty; diff --git a/src/core/matrix.cpp b/src/core/matrix.cpp index 6751e2279..96e1b1839 100644 --- a/src/core/matrix.cpp +++ b/src/core/matrix.cpp @@ -3003,44 +3003,66 @@ void _Matrix::FillInList (_List& fillMe, bool doNumeric) { } } +/*#define __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL 12733 + +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL +extern long likeFuncEvalCallCount; +#endif +*/ + //_____________________________________________________________________________________________ _PMathObj _Matrix::EvaluateSimple (void) // evaluate the matrix overwriting the old one { _Matrix * result = new _Matrix (hDim, vDim, bool (theIndex), true); checkPointer (result); - - + if (cmd->varIndex.lLength) { for (long i=0; ivarIndex.lLength; i++) { _Variable* curVar = LocateVar(cmd->varIndex.lData[i]); if (curVar->ObjectClass () != MATRIX) { + if (curVar->IsIndependent()) { cmd->varValues[i].value = LocateVar (cmd->varIndex.lData[i])->Value(); +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL + if (likeFuncEvalCallCount >= __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL) { + fprintf (stderr, "[_Matrix::EvaluateSimple] Setting variable %s to %g\n", LocateVar (cmd->varIndex.lData[i])->theName->sData,cmd->varValues[i].value); + } +#endif } else { cmd->varValues[i].value = LocateVar (cmd->varIndex.lData[i])->Compute()->Value(); +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL + if (likeFuncEvalCallCount >= __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL) { + fprintf (stderr, "[_Matrix::EvaluateSimple] Setting constrained variable %s to %g\n", LocateVar (cmd->varIndex.lData[i])->theName->sData,cmd->varValues[i].value); + } +#endif } } else { cmd->varValues[i].reference = (Ptr)((_Matrix*)LocateVar (cmd->varIndex.lData[i])->Compute())->theData; } } } - - + + for (long f = 0; f < cmd->formulasToEval.lLength; f++) { cmd->formulaValues [f] = ((_Formula*)cmd->formulasToEval.lData[f])->ComputeSimple(cmd->theStack, cmd->varValues); +#ifdef __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL + if (likeFuncEvalCallCount >= __REPORT_DETAILED_COMPS_FOR_SPECIFIC_CALL) { + fprintf (stderr, "\n[_Matrix::EvaluateSimple] Computing expression %ld, value %g\n", f, cmd->formulaValues [f] ); + } +#endif /*if (terminateExecution) - { - ((_Formula*)cmd->formulasToEval.lData[f])->ConvertFromSimple(cmd->varIndex); - _String * s = (_String*)((_Formula*)cmd->formulasToEval.lData[f])->toStr(); - WarnError (*s); - DeleteObject (s); - return result; - }*/ + { + ((_Formula*)cmd->formulasToEval.lData[f])->ConvertFromSimple(cmd->varIndex); + _String * s = (_String*)((_Formula*)cmd->formulasToEval.lData[f])->toStr(); + WarnError (*s); + DeleteObject (s); + return result; + }*/ } - + long * fidx = cmd->formulaRefs; - + if (theIndex) { result->lDim = lDim; result->bufferPerRow = bufferPerRow; @@ -3048,31 +3070,31 @@ _PMathObj _Matrix::EvaluateSimple (void) result->allocationBlock = allocationBlock; result->theIndex = (long*)MemReallocate((Ptr)result->theIndex,sizeof(long)*lDim); result->theData = (_Parameter*)MemReallocate ((Ptr)result->theData,sizeof(_Parameter)*lDim); - + /*memcpy (result->theIndex,theIndex,sizeof(long)*lDim);*/ - - - - + + + + for (long i = 0; itheData[i] = cmd->formulaValues[fidx[i]]; } - + result->theIndex[i] = idx; } - + /*for (long i = 0; iComputeSimple(cmd->theStack, cmd->varValues); - result.theData[i] = formValue; - } - } */ - + { + if (theIndex[i]!=-1) + { + formValue = theFormulas[i]->ComputeSimple(cmd->theStack, cmd->varValues); + result.theData[i] = formValue; + } + } */ + if (hDim==vDim) { _Parameter* diagStorage = new _Parameter [hDim]; checkPointer ((Ptr)diagStorage); @@ -3096,37 +3118,37 @@ _PMathObj _Matrix::EvaluateSimple (void) } } else { /*long i; - for (i = 0; iComputeSimple(cmd->theStack,cmd->varValues); - result.theData[i] = formValue; - //break; - } - } */ - + for (i = 0; iComputeSimple(cmd->theStack,cmd->varValues); + result.theData[i] = formValue; + //break; + } + } */ + for (long i = 0; i= 0) { result->theData[i] = cmd->formulaValues[fidx[i]]; } } - + if (hDim==vDim) for (long i = 0; iIsEmpty()) - //{ + //if (theFormulas[i]->IsEmpty()) + //{ _Parameter st = 0; long k = i/vDim,j; for (j = k*vDim; jtheData[j]; } - + for (j = k*vDim+k+1; j<(k+1)*vDim; j++) { st-=result->theData[j]; } - + result->theData[i] = st; //} } @@ -4637,8 +4659,7 @@ void _Matrix::CompressSparseMatrix (bool transpose, _Parameter * stash) //_____________________________________________________________________________________________ -_Matrix* _Matrix::Exponentiate (void) -{ +_Matrix* _Matrix::Exponentiate (void) { // find the maximal elements of the matrix long i, power2 = 0; @@ -4646,6 +4667,9 @@ _Matrix* _Matrix::Exponentiate (void) #ifndef _OPENMP matrixExpCount++; #endif + + + _Parameter max = 1.0, *stash = new _Parameter[hDim*(1+vDim)]; @@ -4672,7 +4696,7 @@ _Matrix* _Matrix::Exponentiate (void) } else { max = 1.; } - + _Matrix *result = new _Matrix(hDim, vDim , !storageType, storageType), temp (*this); @@ -4776,12 +4800,16 @@ _Matrix* _Matrix::Exponentiate (void) result->Transpose(); } - + for (long s = 0; sSqr(stash); + _Parameter last_change = result->Sqr(stash); + if (last_change < DBL_EPSILON * 1000.) { + break; + } + } delete [] stash; @@ -5773,19 +5801,21 @@ void _Matrix::AplusBx (_Matrix& B, _Parameter x) //#define _SLKP_USE_SSE_INTRINSICS //_____________________________________________________________________________________________ -void _Matrix::Sqr (_Parameter* _hprestrict_ stash) -{ +_Parameter _Matrix::Sqr (_Parameter* _hprestrict_ stash) { + + _Parameter diff = 0.0; + if (hDim!=vDim) { - return; + return diff; } // not a square matrix - if (theIndex|| storageType!=1 ) + if (theIndex|| storageType!=1 ) { // sparse or non-numeric matrix - { _Matrix temp (hDim, vDim, storageType==0?theIndex!=nil:false, storageType); Multiply (temp, *this); Swap(temp); + return 10000.*DBL_EPSILON; } else { if (hDim==4) // special case for nucleotides @@ -5888,12 +5918,18 @@ void _Matrix::Sqr (_Parameter* _hprestrict_ stash) } } - memcpy (theData, stash, lDim * sizeof (_Parameter)); + + //memcpy (theData, stash, lDim * sizeof (_Parameter)); - /*for (long s = 0; s < lDim; s++) { + + + for (long s = 0; s < lDim; s++) { + StoreIfGreater(diff, fabs (theData[s] - stash[s])); theData[s] = stash[s]; - }*/ + } } + + return diff; } //_____________________________________________________________________________________________ void _Matrix::AgreeObjects (_Matrix& m) From 16ff117310151e8b0856d4f7a7c74b38d59bbc08 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Mon, 4 Dec 2017 18:43:58 -0500 Subject: [PATCH 12/24] Bug fix to MtMet model (wrong EFV order) and new model,mtVer for mitochondrial vertebrate --- .../libv3/models/protein.bf | 1 + .../libv3/models/protein/empirical.bf | 311 ++++++++++++++++-- 2 files changed, 290 insertions(+), 22 deletions(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein.bf b/res/TemplateBatchFiles/libv3/models/protein.bf index b505c3eba..0150dc12f 100644 --- a/res/TemplateBatchFiles/libv3/models/protein.bf +++ b/res/TemplateBatchFiles/libv3/models/protein.bf @@ -16,6 +16,7 @@ models.protein.empirical_models = {{"LG", "Empirical model of protein evolution {"JC69", "Empirical model of protein evolution with equal exchangeability rates among all amino acids, also known as JC69."}, {"mtMAM", "Empirical model of protein evolution for mammalian mitochondrial genomes from Yang N, Nielsen R, and Hasegawa M. (1998). Ref: http://dx.doi.org/10.1093/oxfordjournals.molbev.a025888"}, {"mtMet", "Empirical model of protein evolution for metazoan mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, + {"mtVer", "Empirical model of protein evolution for vertebrate mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, {"cpREV", "Empirical model of protein evolution for chloroplast genomes from from Adachi et al. (2000). Ref: https://www.ncbi.nlm.nih.gov/pubmed/10795826"}, {"HIVBm", "Empirical model of protein evolution for between-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, {"HIVWm", "Empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index 4bdab1252..ec38112b2 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -12,6 +12,7 @@ models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDes "JC69": "models.protein.JC69.ModelDescription", "mtMAM": "models.protein.mtMAM.ModelDescription", "mtMet": "models.protein.mtMet.ModelDescription", + "mtVer": "models.protein.mtVer.ModelDescription", "cpREV": "models.protein.cpREV.ModelDescription", "HIVBm": "models.protein.HIVBm.ModelDescription", "HIVWm": "models.protein.HIVWm.ModelDescription", @@ -23,6 +24,7 @@ models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDesc "JC69": "models.protein.JC69F.ModelDescription", "mtMAM": "models.protein.mtMAMF.ModelDescription", "mtMet": "models.protein.mtMetF.ModelDescription", + "mtVer": "models.protein.mtVerF.ModelDescription", "cpREV": "models.protein.cpREVF.ModelDescription", "HIVBm": "models.protein.HIVBmF.ModelDescription", "HIVWm": "models.protein.HIVWmF.ModelDescription", @@ -34,6 +36,7 @@ models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDesc "JC69": "models.protein.JC69ML.ModelDescription", "mtMAM": "models.protein.mtMAMML.ModelDescription", "mtMet": "models.protein.mtMetML.ModelDescription", + "mtVer": "models.protein.mtVerML.ModelDescription", "cpREV": "models.protein.cpREVML.ModelDescription", "HIVBm": "models.protein.HIVBmML.ModelDescription", "HIVWm": "models.protein.HIVWmML.ModelDescription", @@ -728,6 +731,50 @@ function models.protein.mtMetML.ModelDescription(type) { } +/**************************************** mtVer functions *************************************/ + + +/** + * @name models.protein.mtVer.ModelDescription + * @description Create the baseline schema (dictionary) for the mtVer model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ + function models.protein.mtVer.ModelDescription(type) { + models.protein.mtVer.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.mtVer.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.mtVer.Rij; + models.protein.mtVer.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.mtVer.frequencies"; + return models.protein.mtVer.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtVerF.ModelDescription + * @description Create the baseline schema (dictionary) for the mtVer+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtVerF.ModelDescription(type) { + models.protein.mtVerF.ModelDescription.model_definition = models.protein.mtVer.ModelDescription(type); + models.protein.mtVerF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.mtVerF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.mtVerF.ModelDescription.model_definition; +} + + +/** + * @name models.protein.mtVerML.ModelDescription + * @description Create the baseline schema (dictionary) for the mtVer+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtVerML.ModelDescription(type) { + models.protein.mtVerML.ModelDescription.model_definition = models.protein.mtVer.ModelDescription(type); + models.protein.mtVerML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.mtVerML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.mtVerML.ModelDescription.model_definition; +} + + /*=============================================================================================*/ @@ -3096,27 +3143,27 @@ models.protein.AB.Rij = { lfunction models.protein.mtMet.frequencies (model, namespace, datafilter) { model[utility.getGlobalValue("terms.efv_estimate")] = - {{0.043793200} - {0.012957800} - {0.057001300} - {0.016899000} - {0.011330500} - {0.018018100} - {0.022538500} - {0.047050100} - {0.017183700} - {0.089779400} - {0.155226000} - {0.039913500} - {0.067444300} - {0.088448000} - {0.037528200} - {0.093752200} - {0.063579000} - {0.022671300} - {0.041568200} - {0.053317400} - }; + {{0.0437932} + { 0.0113305} + { 0.016899} + { 0.0225385} + { 0.088448} + { 0.0470501} + { 0.0171837} + { 0.0897794} + { 0.0399135} + { 0.155226} + { 0.0674443} + { 0.0570013} + { 0.0375282} + { 0.0180181} + { 0.0129578} + { 0.0937522} + { 0.063579} + { 0.0533174} + { 0.0226713} + { 0.0415682}}; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; return model; @@ -3310,4 +3357,224 @@ models.protein.mtMet.Rij = { 'T': {'V': 1.5140596740000001, 'W': 0.014378616, 'Y': 0.091031787000000003}, 'V': {'W': 0.093136256000000001, 'Y': 0.069964540000000006}, 'W': {'Y': 0.48104431600000003}, - 'Y': {}} \ No newline at end of file + 'Y': {}}; + + + + lfunction models.protein.mtVer.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.0706288} + { 0.00674192} + { 0.014849} + { 0.0214826} + { 0.0495703} + { 0.0440199} + { 0.0241895} + { 0.0908219} + { 0.0273258} + { 0.172674} + { 0.0563431} + { 0.0455021} + { 0.0542482} + { 0.026439} + { 0.0138991} + { 0.0746629} + { 0.109035} + { 0.0456223} + { 0.0254891} + { 0.0264554}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + +models.protein.mtVer.Rij = { +'A': {'C': 0.25818787799999998, + 'D': 0.15029704599999999, + 'E': 0.18789077500000001, + 'F': 0.069418424000000006, + 'G': 1.1131450629999999, + 'H': 0.027049021999999999, + 'I': 0.419106653, + 'K': 0.020710955999999999, + 'L': 0.084964207, + 'M': 0.77609134000000002, + 'N': 0.031831916000000002, + 'P': 0.285706397, + 'Q': 0.027354705, + 'R': 0.061426074999999997, + 'S': 2.5390917019999999, + 'T': 5.4577877580000003, + 'V': 3.1769759639999999, + 'W': 0.0083503050000000006, + 'Y': 0.013142627}, + 'C': {'D': 0.124361236, + 'E': 0.030812587999999998, + 'F': 1.0711043739999999, + 'G': 0.91074352700000005, + 'H': 1.4477151909999999, + 'I': 0.074268457999999996, + 'K': 0.018885124999999999, + 'L': 0.182360515, + 'M': 0.081020095, + 'N': 0.306981436, + 'P': 0.023520451000000001, + 'Q': 0.14052806900000001, + 'R': 1.1703635489999999, + 'S': 3.378191969, + 'T': 0.16280080499999999, + 'V': 0.37789383399999998, + 'W': 1.764289698, + 'Y': 5.1296218290000004}, + 'D': {'E': 6.6340898380000004, + 'F': 0.0053709409999999997, + 'G': 0.96189642399999997, + 'H': 0.80546838200000004, + 'I': 0.00267315, + 'K': 0.020452689999999999, + 'L': 0.002808236, + 'M': 0.0061562730000000003, + 'N': 8.5772524780000001, + 'P': 0.032172065, + 'Q': 0.084904706999999996, + 'R': 0.063019188000000004, + 'S': 0.376137787, + 'T': 0.088772981000000001, + 'V': 0.123720116, + 'W': 0.024653916000000001, + 'Y': 0.174581453}, + 'E': {'F': 0.0015694050000000001, + 'G': 1.1518345080000001, + 'H': 0.081983093000000007, + 'I': 0.0014573329999999999, + 'K': 2.1130123909999998, + 'L': 0.0091256640000000003, + 'M': 0.059893587999999998, + 'N': 0.33988321399999999, + 'P': 0.023665106000000002, + 'Q': 2.0606641699999999, + 'R': 0.088305718000000005, + 'S': 0.10479923300000001, + 'T': 0.097890385999999996, + 'V': 0.21560053300000001, + 'W': 0.062084663999999998, + 'Y': 0.039546236999999998}, + 'F': {'G': 0.015417345000000001, + 'H': 0.183163356, + 'I': 0.51655272600000002, + 'K': 0.010488183, + 'L': 2.390574145, + 'M': 0.14710124199999999, + 'N': 0.011832201000000001, + 'P': 0.068701822999999995, + 'Q': 0.010980482999999999, + 'R': 0.0023262299999999999, + 'S': 0.86939155099999998, + 'T': 0.064760754000000004, + 'V': 0.344319078, + 'W': 0.095489234000000006, + 'Y': 4.0716517750000003}, + 'G': {'H': 0.01280823, + 'I': 0.0029803109999999998, + 'K': 0.110065675, + 'L': 0.0068902700000000004, + 'M': 0.034003938999999997, + 'N': 0.57376472700000003, + 'P': 0.0015888219999999999, + 'Q': 0.041354439, + 'R': 0.28893165700000001, + 'S': 1.2383013140000001, + 'T': 0.0076788230000000004, + 'V': 0.44479428599999998, + 'W': 0.253335423, + 'Y': 0.020949592999999999}, + 'H': {'I': 0.021069514000000001, + 'K': 0.18206825300000001, + 'L': 0.147175841, + 'M': 0.025326733000000001, + 'N': 2.4725012689999999, + 'P': 0.67394944099999998, + 'Q': 4.324671886, + 'R': 2.1220078999999998, + 'S': 0.450133322, + 'T': 0.15115773399999999, + 'V': 0.0026957690000000002, + 'W': 0.033143636999999997, + 'Y': 9.0196159490000003}, + 'I': {'K': 0.0068528080000000002, + 'L': 1.4138880599999999, + 'M': 2.7358049100000001, + 'N': 0.12218513, + 'P': 0.01898617, + 'Q': 0.0048459089999999998, + 'R': 0.001696908, + 'S': 0.042952525999999998, + 'T': 2.411521891, + 'V': 13.419120277999999, + 'W': 0.0019286209999999999, + 'Y': 0.047323608000000003}, + 'K': {'L': 0.021134276, + 'M': 0.43579328000000001, + 'N': 2.4877313349999999, + 'P': 0.152366262, + 'Q': 2.0310412649999998, + 'R': 0.43113726800000002, + 'S': 0.19358335300000001, + 'T': 0.40837230699999999, + 'V': 0.026318790000000002, + 'W': 0.031311763999999999, + 'Y': 0.071183277000000003}, + 'L': {'M': 3.1559412529999999, + 'N': 0.0051845299999999997, + 'P': 0.35795371599999998, + 'Q': 0.25314762299999999, + 'R': 0.078245354000000003, + 'S': 0.43506549900000002, + 'T': 0.18136720100000001, + 'V': 0.86760021799999998, + 'W': 0.188124443, + 'Y': 0.106687168}, + 'M': {'N': 0.038343725000000002, + 'P': 0.031301259999999997, + 'Q': 0.124183971, + 'R': 0.002391939, + 'S': 0.14830564900000001, + 'T': 3.6958740290000001, + 'V': 4.3789212879999999, + 'W': 0.059361128999999999, + 'Y': 0.079180591999999994}, + 'N': {'P': 0.039069406000000001, + 'Q': 0.41657637800000002, + 'R': 0.14905785299999999, + 'S': 3.7778476159999999, + 'T': 0.86602816100000002, + 'V': 0.013012894000000001, + 'W': 0.0075280260000000002, + 'Y': 0.85544403400000002}, + 'P': {'Q': 0.91506864899999996, + 'R': 0.22110640300000001, + 'S': 1.922238895, + 'T': 0.576413595, + 'V': 0.025284157000000002, + 'W': 0.019550695, + 'Y': 0.072344704999999995}, + 'Q': {'R': 3.1337568619999998, + 'S': 0.25667158400000001, + 'T': 0.11897651200000001, + 'V': 0.0092985359999999996, + 'W': 0.12273951399999999, + 'Y': 0.24379326000000001}, + 'R': {'S': 0.127840652, + 'T': 0.028428747000000001, + 'V': 0.034013496999999997, + 'W': 0.54428200400000004, + 'Y': 0.145341785}, + 'S': {'T': 2.9085797630000001, + 'V': 0.058827342999999997, + 'W': 0.141663396, + 'Y': 0.53309474999999995}, + 'T': {'V': 1.341486679, 'W': 0.003372908, 'Y': 0.086650158000000005}, + 'V': {'W': 0.045879218999999999, 'Y': 0.027607482999999999}, + 'W': {'Y': 0.29464986999999998}, + 'Y': {}}; From 553b9831abf1ae17c796c924862cccb8335fb6fa Mon Sep 17 00:00:00 2001 From: Sergei Kosakovsky Pond Date: Tue, 5 Dec 2017 16:26:52 -0800 Subject: [PATCH 13/24] Further fixes to address #703; small positive log-likelihoods can be returned due to numerical error for sites that have no meaninful data (for example NNN in one sequence and all gaps) --- src/core/likefunc.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/likefunc.cpp b/src/core/likefunc.cpp index 1e7ada8f2..7dc3921d8 100644 --- a/src/core/likefunc.cpp +++ b/src/core/likefunc.cpp @@ -2172,10 +2172,14 @@ _Parameter _LikelihoodFunction::Compute (void) return -A_LARGE_NUMBER; } - if (result >= 0) { - char buffer [2048]; - snprintf (buffer, 2047, "Internal error: Encountered a positive log-likelihood at evaluation %ld, mode %ld, template %ld", likeFuncEvalCallCount-1, computeMode, templateKind); - WarnError (buffer); + if (result >= 0.) { + if (result >= __DBL_EPSILON__ * 1.e4) { + char buffer [2048]; + snprintf (buffer, 2047, "Internal error: Encountered a positive log-likelihood (%g) at evaluation %ld, mode %ld, template %ld", likeFuncEvalCallCount-1, result, computeMode, templateKind); + WarnError (buffer); + } else { + result = 0.; + } } ComputeParameterPenalty (); @@ -4724,8 +4728,7 @@ inline bool CheckOneDStep (_Parameter& val, _Parameter lB, _Parameter uB) } //_______________________________________________________________________________________ -bool CheckEqual (_Parameter a, _Parameter b) -{ +bool CheckEqual (_Parameter a, _Parameter b) { if (a!=0.0) { a = (a>b)?(a-b)/a:(b-a)/a; return a>0.0 ? a<=machineEps : a>=-machineEps; From 9b6b8f91340d7237447eee98dae57921613d7f79 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Wed, 6 Dec 2017 11:46:25 -0500 Subject: [PATCH 14/24] New gcpREV model of green plant chloroplast AA evolution --- .../libv3/models/protein.bf | 1 + .../libv3/models/protein/empirical.bf | 277 +++++++++++++++++- 2 files changed, 275 insertions(+), 3 deletions(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein.bf b/res/TemplateBatchFiles/libv3/models/protein.bf index 0150dc12f..bf1580c99 100644 --- a/res/TemplateBatchFiles/libv3/models/protein.bf +++ b/res/TemplateBatchFiles/libv3/models/protein.bf @@ -18,6 +18,7 @@ models.protein.empirical_models = {{"LG", "Empirical model of protein evolution {"mtMet", "Empirical model of protein evolution for metazoan mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, {"mtVer", "Empirical model of protein evolution for vertebrate mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, {"cpREV", "Empirical model of protein evolution for chloroplast genomes from from Adachi et al. (2000). Ref: https://www.ncbi.nlm.nih.gov/pubmed/10795826"}, + {"gcpREV", "Empirical model of protein evolution for green plant chloroplast genomes from from Cox and Foster (2013). Ref: https://doi.org/10.1016/j.ympev.2013.03.030"}, {"HIVBm", "Empirical model of protein evolution for between-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, {"HIVWm", "Empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, {"AB", "Empirical model of protein evolution for antibody sequences from Mirsky et al. (2015). Ref: https://doi.org/10.1093/molbev/msu340"} diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index ec38112b2..fb65cf8a3 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -14,6 +14,7 @@ models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDes "mtMet": "models.protein.mtMet.ModelDescription", "mtVer": "models.protein.mtVer.ModelDescription", "cpREV": "models.protein.cpREV.ModelDescription", + "gcpREV": "models.protein.gcpREV.ModelDescription", "HIVBm": "models.protein.HIVBm.ModelDescription", "HIVWm": "models.protein.HIVWm.ModelDescription", "AB" : "models.protein.AB.ModelDescription"}; @@ -26,6 +27,7 @@ models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDesc "mtMet": "models.protein.mtMetF.ModelDescription", "mtVer": "models.protein.mtVerF.ModelDescription", "cpREV": "models.protein.cpREVF.ModelDescription", + "gcpREV": "models.protein.gcpREVF.ModelDescription", "HIVBm": "models.protein.HIVBmF.ModelDescription", "HIVWm": "models.protein.HIVWmF.ModelDescription", "AB" : "models.protein.ABF.ModelDescription"}; @@ -35,9 +37,10 @@ models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDesc "JTT": "models.protein.JTTML.ModelDescription", "JC69": "models.protein.JC69ML.ModelDescription", "mtMAM": "models.protein.mtMAMML.ModelDescription", - "mtMet": "models.protein.mtMetML.ModelDescription", - "mtVer": "models.protein.mtVerML.ModelDescription", + "mtMet": "models.protein.mtMetML.ModelDescription", + "mtVer": "models.protein.mtVerML.ModelDescription", "cpREV": "models.protein.cpREVML.ModelDescription", + "gcpREV": "models.protein.gcpREVML.ModelDescription", "HIVBm": "models.protein.HIVBmML.ModelDescription", "HIVWm": "models.protein.HIVWmML.ModelDescription", "AB" : "models.protein.ABML.ModelDescription"}; @@ -776,6 +779,51 @@ function models.protein.mtVerML.ModelDescription(type) { +/**************************************** gcpREV functions *************************************/ + + +/** + * @name models.protein.gcpREV.ModelDescription + * @description Create the baseline schema (dictionary) for the gcpREV model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ + function models.protein.gcpREV.ModelDescription(type) { + models.protein.gcpREV.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.gcpREV.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.gcpREV.Rij; + models.protein.gcpREV.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.gcpREV.frequencies"; + return models.protein.gcpREV.ModelDescription.model_definition; +} + +/** + * @name models.protein.gcpREVF.ModelDescription + * @description Create the baseline schema (dictionary) for the gcpREV+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.gcpREVF.ModelDescription(type) { + models.protein.gcpREVF.ModelDescription.model_definition = models.protein.gcpREV.ModelDescription(type); + models.protein.gcpREVF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.gcpREVF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.gcpREVF.ModelDescription.model_definition; +} + + +/** + * @name models.protein.gcpREVML.ModelDescription + * @description Create the baseline schema (dictionary) for the gcpREV+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.gcpREVML.ModelDescription(type) { + models.protein.gcpREVML.ModelDescription.model_definition = models.protein.gcpREV.ModelDescription(type); + models.protein.gcpREVML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.gcpREVML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.gcpREVML.ModelDescription.model_definition; +} + + + /*=============================================================================================*/ /** Below this section are all of the empirical matrices and frequency vectors, including Rij **/ @@ -3363,7 +3411,7 @@ models.protein.mtMet.Rij = { lfunction models.protein.mtVer.frequencies (model, namespace, datafilter) { model[utility.getGlobalValue("terms.efv_estimate")] = - {{0.0706288} + {{ 0.0706288} { 0.00674192} { 0.014849} { 0.0214826} @@ -3578,3 +3626,226 @@ models.protein.mtVer.Rij = { 'V': {'W': 0.045879218999999999, 'Y': 0.027607482999999999}, 'W': {'Y': 0.29464986999999998}, 'Y': {}}; + + + + + + +lfunction models.protein.gcpREV.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{ 0.07951} + {0.009051} + {0.03322} + {0.049675} + {0.047731} + {0.080233} + {0.02188} + {0.080496} + {0.049324} + {0.107512} + {0.020776} + {0.040459} + {0.039916} + {0.037505} + {0.056001} + {0.07382} + {0.053615} + {0.071781} + {0.016705} + {0.03079}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + +models.protein.gcpREV.Rij = { +'A': {'C': 699.39999999999998, + 'D': 87.700000000000003, + 'E': 288.30000000000001, + 'F': 59.299999999999997, + 'G': 677.89999999999998, + 'H': 32.0, + 'I': 39.5, + 'K': 78.299999999999997, + 'L': 33.799999999999997, + 'M': 197.09999999999999, + 'N': 59.100000000000001, + 'P': 505.80000000000001, + 'Q': 199.5, + 'R': 12.199999999999999, + 'S': 2443.9000000000001, + 'T': 1646.2, + 'V': 1143.8, + 'W': 30.0, + 'Y': 27.899999999999999}, + 'C': {'D': 125.3, + 'E': 102.40000000000001, + 'F': 1540.0999999999999, + 'G': 433.60000000000002, + 'H': 574.79999999999995, + 'I': 96.0, + 'K': 89.200000000000003, + 'L': 446.5, + 'M': 288.5, + 'N': 133.69999999999999, + 'P': 124.90000000000001, + 'Q': 195.09999999999999, + 'R': 1867.9000000000001, + 'S': 3029.8000000000002, + 'T': 516.79999999999995, + 'V': 722.20000000000005, + 'W': 562.60000000000002, + 'Y': 1571.2}, + 'D': {'E': 3638.6999999999998, + 'F': 15.9, + 'G': 464.80000000000001, + 'H': 527.70000000000005, + 'I': 16.800000000000001, + 'K': 78.299999999999997, + 'L': 8.6999999999999993, + 'M': 33.100000000000001, + 'N': 5083.8000000000002, + 'P': 43.600000000000001, + 'Q': 387.60000000000002, + 'R': 40.600000000000001, + 'S': 142.09999999999999, + 'T': 66.099999999999994, + 'V': 18.5, + 'W': 35.0, + 'Y': 272.10000000000002}, + 'E': {'F': 30.699999999999999, + 'G': 393.80000000000001, + 'H': 144.59999999999999, + 'I': 23.399999999999999, + 'K': 1870.9000000000001, + 'L': 26.800000000000001, + 'M': 33.299999999999997, + 'N': 230.90000000000001, + 'P': 39.399999999999999, + 'Q': 2965.3000000000002, + 'R': 51.899999999999999, + 'S': 156.69999999999999, + 'T': 230.0, + 'V': 103.8, + 'W': 57.200000000000003, + 'Y': 79.200000000000003}, + 'F': {'G': 10.1, + 'H': 87.200000000000003, + 'I': 354.39999999999998, + 'K': 9.0, + 'L': 1585.8, + 'M': 183.40000000000001, + 'N': 13.4, + 'P': 82.099999999999994, + 'Q': 10.699999999999999, + 'R': 26.100000000000001, + 'S': 790.5, + 'T': 29.800000000000001, + 'V': 180.59999999999999, + 'W': 558.29999999999995, + 'Y': 2360.1999999999998}, + 'G': {'H': 35.600000000000001, + 'I': 11.800000000000001, + 'K': 193.40000000000001, + 'L': 4.2999999999999998, + 'M': 11.800000000000001, + 'N': 446.5, + 'P': 11.800000000000001, + 'Q': 40.799999999999997, + 'R': 391.19999999999999, + 'S': 709.0, + 'T': 65.5, + 'V': 72.599999999999994, + 'W': 92.599999999999994, + 'Y': 20.600000000000001}, + 'H': {'I': 38.100000000000001, + 'K': 96.900000000000006, + 'L': 46.100000000000001, + 'M': 54.5, + 'N': 2156.8000000000002, + 'P': 185.09999999999999, + 'Q': 1889.5999999999999, + 'R': 1228.7, + 'S': 277.0, + 'T': 77.099999999999994, + 'V': 22.800000000000001, + 'W': 58.5, + 'Y': 4117.5}, + 'I': {'K': 125.7, + 'L': 1657.9000000000001, + 'M': 2493.4000000000001, + 'N': 146.0, + 'P': 63.100000000000001, + 'Q': 48.5, + 'R': 105.40000000000001, + 'S': 75.599999999999994, + 'T': 1227.2, + 'V': 6006.5, + 'W': 21.100000000000001, + 'Y': 35.799999999999997}, + 'K': {'L': 37.600000000000001, + 'M': 220.09999999999999, + 'N': 1930.8, + 'P': 49.799999999999997, + 'Q': 2571.1999999999998, + 'R': 4666.3999999999996, + 'S': 209.30000000000001, + 'T': 648.5, + 'V': 66.200000000000003, + 'W': 15.9, + 'Y': 84.200000000000003}, + 'L': {'M': 1389.5999999999999, + 'N': 11.6, + 'P': 347.69999999999999, + 'Q': 235.40000000000001, + 'R': 124.90000000000001, + 'S': 584.89999999999998, + 'T': 62.899999999999999, + 'V': 661.70000000000005, + 'W': 218.19999999999999, + 'Y': 82.0}, + 'M': {'N': 41.399999999999999, + 'P': 19.199999999999999, + 'Q': 341.80000000000001, + 'R': 112.09999999999999, + 'S': 32.899999999999999, + 'T': 1143.5, + 'V': 465.69999999999999, + 'W': 70.5, + 'Y': 41.100000000000001}, + 'N': {'P': 18.699999999999999, + 'Q': 827.79999999999995, + 'R': 313.0, + 'S': 2505.4000000000001, + 'T': 1373.3, + 'V': 27.600000000000001, + 'W': 19.899999999999999, + 'Y': 316.19999999999999}, + 'P': {'Q': 223.09999999999999, + 'R': 89.400000000000006, + 'S': 1154.5, + 'T': 322.80000000000001, + 'V': 75.5, + 'W': 18.5, + 'Y': 15.800000000000001}, + 'Q': {'R': 2321.3000000000002, + 'S': 246.90000000000001, + 'T': 128.5, + 'V': 50.200000000000003, + 'W': 24.600000000000001, + 'Y': 179.09999999999999}, + 'R': {'S': 269.60000000000002, + 'T': 173.40000000000001, + 'V': 62.0, + 'W': 257.80000000000001, + 'Y': 137.0}, + 'S': {'T': 2042.5, + 'V': 61.200000000000003, + 'W': 102.59999999999999, + 'Y': 501.89999999999998}, + 'T': {'V': 583.70000000000005, 'W': 22.0, 'Y': 64.599999999999994}, + 'V': {'W': 10.800000000000001, 'Y': 37.299999999999997}, + 'W': {'Y': 296.30000000000001}, + 'Y': {}}; \ No newline at end of file From 663a487bf6483bc6c60649819f3ee8640137fd6f Mon Sep 17 00:00:00 2001 From: Sergei Kosakovsky Pond Date: Thu, 7 Dec 2017 07:25:49 -0500 Subject: [PATCH 15/24] More ancestral.bf functions should work in libv3 --- .../SelectionAnalyses/MEME.bf | 2 +- .../libv3/tasks/ancestral.bf | 84 +++++++++---------- res/TemplateBatchFiles/libv3/tasks/trees.bf | 1 + src/core/site.cpp | 1 + 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/res/TemplateBatchFiles/SelectionAnalyses/MEME.bf b/res/TemplateBatchFiles/SelectionAnalyses/MEME.bf index 41ff3b36f..417e8f0b8 100644 --- a/res/TemplateBatchFiles/SelectionAnalyses/MEME.bf +++ b/res/TemplateBatchFiles/SelectionAnalyses/MEME.bf @@ -462,7 +462,7 @@ lfunction meme.handle_a_site (lf_fel, lf_bsrel, filter_data, partition_index, pa ^"meme.site_alpha" = 1; ^"meme.site_beta_plus" = 1; ^"meme.site_beta_nuisance" = 1; - + Optimize (results, ^lf_fel); fel = estimators.ExtractMLEs (lf_fel, model_mapping); diff --git a/res/TemplateBatchFiles/libv3/tasks/ancestral.bf b/res/TemplateBatchFiles/libv3/tasks/ancestral.bf index 31c014965..f9e4ec742 100644 --- a/res/TemplateBatchFiles/libv3/tasks/ancestral.bf +++ b/res/TemplateBatchFiles/libv3/tasks/ancestral.bf @@ -469,11 +469,11 @@ lfunction ancestral._substitutionsBySite(_ancestral_cache, _siteID) { *******************************************/ function _substitutionsBySiteSubset(_ancID, _siteID, _branchSubset) { - if (Abs(_ancestralRecoveryCache[_ancID])) { - if (_siteID >= 0 && _siteID < Columns((_ancestralRecoveryCache[_ancID])["MATRIX"])) { + if (Abs_ancID) { + if (_siteID >= 0 && _siteID < Columns(_ancID["MATRIX"])) { _bacSiteC = {}; - _thisColumn = ((_ancestralRecoveryCache[_ancID])["MATRIX"])[-1][_siteID]; - _bacSiteC["CHARS"] = (_ancestralRecoveryCache[_ancID])["CHARS"]; + _thisColumn = (_ancID["MATRIX"])[-1][_siteID]; + _bacSiteC["CHARS"] = _ancID["CHARS"]; _bacSiteDim = Columns(_bacSiteC["CHARS"]); _bacCounter = Rows(_thisColumn) - 1; _bacSiteMx = { @@ -482,8 +482,8 @@ function _substitutionsBySiteSubset(_ancID, _siteID, _branchSubset) { }; for (_bacTreeIterator = 0; _bacTreeIterator < _bacCounter; _bacTreeIterator = _bacTreeIterator + 1) { - if (_branchSubset[(((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Name"] && 1]) { - _bacParentID = (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; + if (_branchSubset[((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Name"] && 1]) { + _bacParentID = ((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; _myState = _thisColumn[_bacTreeIterator]; _pState = _thisColumn[_bacParentID]; _expandSubstitutionMap(_pState, _myState, _ancID, "_bacSiteMx"); @@ -511,14 +511,14 @@ function _substitutionsBySiteSubset(_ancID, _siteID, _branchSubset) { *******************************************/ function _rootState(_ancID, _siteID) { - if (Abs(_ancestralRecoveryCache[_ancID])) { - if (_siteID >= 0 && _siteID < Columns((_ancestralRecoveryCache[_ancID])["MATRIX"])) { + if (Abs_ancID) { + if (_siteID >= 0 && _siteID < Columns(_ancID["MATRIX"])) { _bacRootState = {}; - _bacRootIndex = (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[0])["Root"] - 1; - _rootStateIndex = ((_ancestralRecoveryCache[_ancID])["MATRIX"])[_bacRootIndex][_siteID]; + _bacRootIndex = ((_ancID["TREE_AVL"])[0])["Root"] - 1; + _rootStateIndex = (_ancID["MATRIX"])[_bacRootIndex][_siteID]; _bacRootState["INDEX"] = _rootStateIndex; if (_rootStateIndex >= 0) { - _bacRootState["CHAR"] = ((_ancestralRecoveryCache[_ancID])["CHARS"])[_rootStateIndex]; + _bacRootState["CHAR"] = (_ancID["CHARS"])[_rootStateIndex]; } else { _bacRootState["CHAR"] = "-"; } @@ -553,22 +553,22 @@ function _mapSNSBySite(_ancID, _siteID, _scaled) { /********************************************/ function _mapSubstitutionsBySiteAux(_ancID, _siteID, _scaled, mode) { - if (Abs(_ancestralRecoveryCache[_ancID])) { - if (_siteID >= 0 && _siteID < Columns((_ancestralRecoveryCache[_ancID])["MATRIX"])) { + if (Abs_ancID) { + if (_siteID >= 0 && _siteID < Columns(_ancID["MATRIX"])) { TREE_OUTPUT_OPTIONS = {}; - _thisColumn = ((_ancestralRecoveryCache[_ancID])["MATRIX"])[-1][_siteID]; - _bacSiteC = (_ancestralRecoveryCache[_ancID])["CHARS"]; + _thisColumn = (_ancID["MATRIX"])[-1][_siteID]; + _bacSiteC = _ancID["CHARS"]; _bacSiteDim = Columns(_bacSiteC); _bacCounter = Rows(_thisColumn) - 1; for (_bacTreeIterator = 0; _bacTreeIterator < _bacCounter; _bacTreeIterator = _bacTreeIterator + 1) { - _bacParentID = (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; + _bacParentID = ((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; _myState = _thisColumn[_bacTreeIterator]; _pState = _thisColumn[_bacParentID]; _bacStateLabel = ""; - _bac_bn = (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Name"]; + _bac_bn = ((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Name"]; TREE_OUTPUT_OPTIONS[_bac_bn] = {}; if (mode == 2) { (TREE_OUTPUT_OPTIONS[_bac_bn])["TREE_OUTPUT_BRANCH_THICKNESS"] = 1; @@ -641,12 +641,12 @@ function _mapSubstitutionsBySiteAux(_ancID, _siteID, _scaled, mode) { } if (mode == 2) { - (TREE_OUTPUT_OPTIONS[(((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Name"]]) = { + (TREE_OUTPUT_OPTIONS[((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Name"]]) = { "TREE_OUTPUT_BRANCH_THICKNESS": 1 }; } - _bacTreeString = PostOrderAVL2StringDL((_ancestralRecoveryCache[_ancID])["TREE_AVL"], _scaled); + _bacTreeString = PostOrderAVL2StringDL(_ancID["TREE_AVL"], _scaled); Tree _bacTempTree = _bacTreeString; _bac_bn = ""; _bac_bn * 128; @@ -688,15 +688,15 @@ function _mapCharactersBySiteNewick(_ancID, _siteID, _scaled) { } function _mapSubstitutionsBySiteNewickAux(_ancID, _siteID, _scaled, mode) { - if (Abs(_ancestralRecoveryCache[_ancID])) { - if (_siteID >= 0 && _siteID < Columns((_ancestralRecoveryCache[_ancID])["MATRIX"])) { - _thisColumn = ((_ancestralRecoveryCache[_ancID])["MATRIX"])[-1][_siteID]; - _bacSiteC = (_ancestralRecoveryCache[_ancID])["CHARS"]; + if (Abs(_ancID)) { + if (_siteID >= 0 && _siteID < Columns(_ancID["MATRIX"])) { + _thisColumn = (_ancID["MATRIX"])[-1][_siteID]; + _bacSiteC = _ancID["CHARS"]; _bacSiteDim = Columns(_bacSiteC); _bacCounter = Rows(_thisColumn) - 1; for (_bacTreeIterator = 0; _bacTreeIterator < _bacCounter; _bacTreeIterator = _bacTreeIterator + 1) { - _bacParentID = (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; + _bacParentID = ((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; _myState = _thisColumn[_bacTreeIterator]; _pState = _thisColumn[_bacParentID]; _bacStateLabel = ""; @@ -712,10 +712,10 @@ function _mapSubstitutionsBySiteNewickAux(_ancID, _siteID, _scaled, mode) { } } - (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["SubLabel"] = _bacStateLabel; + ((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["SubLabel"] = _bacStateLabel; } - return PostOrderAVL2StringAnnotate((_ancestralRecoveryCache[_ancID])["TREE_AVL"], _scaled, "SubLabel"); + return PostOrderAVL2StringAnnotate(_ancID["TREE_AVL"], _scaled, "SubLabel"); } } return ""; @@ -733,9 +733,9 @@ function _filterDimensions(_ancID) { 1, 2 }; - if (Abs(_ancestralRecoveryCache[_ancID])) { - _sites = Columns((_ancestralRecoveryCache[_ancID])["MATRIX"]); - _branches = Rows((_ancestralRecoveryCache[_ancID])["MATRIX"]) - 1; + if (Abs_ancID) { + _sites = Columns(_ancID["MATRIX"]); + _branches = Rows(_ancID["MATRIX"]) - 1; _result[0] = _sites; _result[1] = _branches; } @@ -756,11 +756,11 @@ function _countSubstitutionsByBranchSite(_ancID, _siteID, _filter) { 0, 1 }; - if (Abs(_ancestralRecoveryCache[_ancID])) { - if (_siteID >= 0 && _siteID < Columns((_ancestralRecoveryCache[_ancID])["MATRIX"])) { + if (Abs_ancID) { + if (_siteID >= 0 && _siteID < Columns(_ancID["MATRIX"])) { TREE_OUTPUT_OPTIONS = {}; - _thisColumn = ((_ancestralRecoveryCache[_ancID])["MATRIX"])[-1][_siteID]; - _bacSiteC = (_ancestralRecoveryCache[_ancID])["CHARS"]; + _thisColumn = (_ancID["MATRIX"])[-1][_siteID]; + _bacSiteC = _ancID["CHARS"]; _bacSiteDim = Columns(_bacSiteC); _bacCounter = Rows(_thisColumn) - 1; _result = { @@ -769,7 +769,7 @@ function _countSubstitutionsByBranchSite(_ancID, _siteID, _filter) { }; for (_bacTreeIterator = 0; _bacTreeIterator < _bacCounter; _bacTreeIterator += 1) { - _bacParentID = (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; + _bacParentID = ((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; _myState = _thisColumn[_bacTreeIterator]; _pState = _thisColumn[_bacParentID]; _bacSiteMx = { @@ -798,16 +798,16 @@ function _countSubstitutionsByBranchSite(_ancID, _siteID, _filter) { function _tabulateSubstitutionsAtSiteByBranch(_ancID, _siteID) { _result = {}; - if (Abs(_ancestralRecoveryCache[_ancID])) { - if (_siteID >= 0 && _siteID < Columns((_ancestralRecoveryCache[_ancID])["MATRIX"])) { - _thisColumn = ((_ancestralRecoveryCache[_ancID])["MATRIX"])[-1][_siteID]; - _bacSiteC = (_ancestralRecoveryCache[_ancID])["CHARS"]; + if (Abs_ancID) { + if (_siteID >= 0 && _siteID < Columns(_ancID["MATRIX"])) { + _thisColumn = (_ancID["MATRIX"])[-1][_siteID]; + _bacSiteC = _ancID["CHARS"]; _bacSiteDim = Columns(_bacSiteC); _bacCounter = Rows(_thisColumn) - 1; for (_bacTreeIterator = 0; _bacTreeIterator < _bacCounter; _bacTreeIterator = _bacTreeIterator + 1) { - _bacParentID = (((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; + _bacParentID = ((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Parent"] - 1; _myState = _thisColumn[_bacTreeIterator]; _pState = _thisColumn[_bacParentID]; @@ -818,7 +818,7 @@ function _tabulateSubstitutionsAtSiteByBranch(_ancID, _siteID) { haveS = 0; haveNS = 0; } - _result[(((_ancestralRecoveryCache[_ancID])["TREE_AVL"])[_bacTreeIterator + 1])["Name"]] = { + _result[((_ancID["TREE_AVL"])[_bacTreeIterator + 1])["Name"]] = { { haveS__, haveNS__ @@ -889,7 +889,7 @@ function _convertSubstitutionToCharacters(_state1, _state2, _ancID, _resultMatri }; _vec1[_state1] = 1; } else { - _vec1 = ((_ancestralRecoveryCache[_ancID])["AMBIGS"])[-_state1 - 2]; + _vec1 = (_ancID["AMBIGS"])[-_state1 - 2]; } if (_state2 >= 0) { _vec2 = { @@ -898,7 +898,7 @@ function _convertSubstitutionToCharacters(_state1, _state2, _ancID, _resultMatri }; _vec2[_state2] = 1; } else { - _vec2 = ((_ancestralRecoveryCache[_ancID])["AMBIGS"])[-_state2 - 2]; + _vec2 = (_ancID["AMBIGS"])[-_state2 - 2]; } _vec1 = _vec1 * Transpose(_vec2); _vec2 = { diff --git a/res/TemplateBatchFiles/libv3/tasks/trees.bf b/res/TemplateBatchFiles/libv3/tasks/trees.bf index 7af5af885..b4476580b 100644 --- a/res/TemplateBatchFiles/libv3/tasks/trees.bf +++ b/res/TemplateBatchFiles/libv3/tasks/trees.bf @@ -143,6 +143,7 @@ lfunction trees.GetTreeString(look_for_newick_tree) { if (regexp.Find(treeString, "^#NEXUS")) { ExecuteCommands(treeString); + if (!utility.GetEnvVariable("IS_TREE_PRESENT_IN_DATA")) { fprintf(stdout, "\n> **This NEXUS file doesn't contain a valid tree block**"); return 1; diff --git a/src/core/site.cpp b/src/core/site.cpp index 638e6926e..6dd2aeccf 100644 --- a/src/core/site.cpp +++ b/src/core/site.cpp @@ -2824,6 +2824,7 @@ void _DataSetFilter::SetExclusions (_String* theList, bool filter) _String* kth_token = (_String*)tokens.GetItem(k); long posMarker = MapStringToCharIndex(*kth_token); + if (posMarker < 0) { ReportWarning (_String("Exclusion request for '") & *kth_token &"' does not represent a unique state and will therefore be ignored."); From 95de422b5ac530f325d637cc67cd20cf73cc4abe Mon Sep 17 00:00:00 2001 From: Sergei Kosakovsky Pond Date: Thu, 7 Dec 2017 17:00:49 -0500 Subject: [PATCH 16/24] Fixing a regression bug (unsigned long accident) in Bootstrap --- res/TemplateBatchFiles/SimmondsAI.bf | 28 +++++++++++++--------------- src/core/batchlan2.cpp | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/res/TemplateBatchFiles/SimmondsAI.bf b/res/TemplateBatchFiles/SimmondsAI.bf index a168b9c68..0ae8bbc1a 100644 --- a/res/TemplateBatchFiles/SimmondsAI.bf +++ b/res/TemplateBatchFiles/SimmondsAI.bf @@ -60,6 +60,7 @@ SetDialogPrompt ("Load a nucleotide sequence file:"); DataSet ds = ReadDataFile (PROMPT_FOR_FILE); leafCount = ds.species; +DataSetFilter filteredData = Bootstrap (ds,1); fprintf (stdout, "Read file: ", ds,"\n"); @@ -251,7 +252,7 @@ fprintf (stdout, "Using ", treeIt, " tree bootstraps and ", shuffleIt, " relabel treeAVL = givenTree^0; treeAVL2 = givenTree^1; -baseD = runATreeSample (0); +baseD = runATreeSample (); fprintf (stdout, "\nBaseline d = ", baseD[0], "\n"); totalRes = {treeIt,3}; @@ -265,22 +266,21 @@ meanO = baseD[0]; meanS = baseD[1]; sigB = (propSig < baseD[2]); -for (it = 0; it < treeIt-1; it = it + 1) -{ +for (it = 0; it < treeIt-1; it += 1) { DataSetFilter filteredData = Bootstrap (ds,1); - ts = InferTreeTopology (0); + ts = InferTreeTopology (0); Tree givenTree = ts; ts = RerootTree (givenTree, choiceMatrix); Tree givenTree = ts; treeAVL = givenTree^0; treeAVL2 = givenTree^1; - simD = runATreeSample (0); + simD = runATreeSample (); totalRes[it+1][0] = simD[0]; totalRes[it+1][1] = simD[1]; totalRes[it+1][2] = simD[2]; - meanO = meanO + simD[0]; - meanS = meanS + simD[1]; - sigB = sigB + (propSig < simD[2]); + meanO += simD[0]; + meanS += simD[1]; + sigB += (propSig < simD[2]); } fprintf (stdout, "\n\nAssociation Index: ", meanO/meanS, "\nBootstrap significance :" , sigB, "/", treeIt, "\n"); @@ -310,8 +310,9 @@ ACCEPT_ROOTED_TREES = 0; /*************************************************************************************************/ -function runATreeSample (dummy) -{ +function runATreeSample () { + + mapVec = {1,leafCount}["_MATRIX_ELEMENT_COLUMN_"]; myLeafAlloc = {1,leafCount}; for (_k = 0; _k < leafCount; _k = _k + 1) @@ -326,11 +327,8 @@ function runATreeSample (dummy) { treeAVL = givenTree^0; rsD = computeSimmondsD (myLeafAlloc, Random(mapVec,0), kindCount); - if (rsD > baseD) - { - gte = gte +1; - } - meanRat = meanRat + rsD; + gte += (rsD > baseD); + meanRat += rsD; } outMx = {{baseD, meanRat/shuffleIt, gte/shuffleIt}}; return outMx; diff --git a/src/core/batchlan2.cpp b/src/core/batchlan2.cpp index 764082a80..7590d1ccf 100644 --- a/src/core/batchlan2.cpp +++ b/src/core/batchlan2.cpp @@ -712,7 +712,7 @@ void _ElementaryCommand::ExecuteDataFilterCases (_ExecutionList& chain) { dataset = (_DataSet*)dataSetList(dsID); dataset -> ProcessPartition (hSpecs,hL,false, nil, nil, chain.GetNameSpace()); if (code!=6 && vSpecs.sLength==0) { - vSpecs = _String("0-")&_String(dataset->NoOfColumns()-1); + vSpecs = _String("0-")&_String((long)dataset->NoOfColumns()-1); } dataset->ProcessPartition (vSpecs,vL,true,nil, nil, chain.GetNameSpace()); From e84c0c0d089b0981a8734dd7ec42caf01efdeb62 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Mon, 11 Dec 2017 11:38:17 -0500 Subject: [PATCH 17/24] Update to LEISR to handle multiple partitions --- res/TemplateBatchFiles/LEISR.bf | 259 ++++++++++++++++++++++---------- 1 file changed, 181 insertions(+), 78 deletions(-) diff --git a/res/TemplateBatchFiles/LEISR.bf b/res/TemplateBatchFiles/LEISR.bf index 9eeda4e85..5afc3a82c 100644 --- a/res/TemplateBatchFiles/LEISR.bf +++ b/res/TemplateBatchFiles/LEISR.bf @@ -28,9 +28,9 @@ LoadFunctionLibrary("SelectionAnalyses/modules/io_functions.ibf"); utility.ToggleEnvVariable ("NORMALIZE_SEQUENCE_NAMES", 1); leisr.analysis_description = { - terms.io.info: "LEISR (Likelihood Estimation of Individual Site Rates) infer relative amino-acid or nucleotide rates from a fixed nucleotide or amino-acid alignment and tree. Relative site-specific substitution rates are - inferred by first optimizing alignment-wide branch lengths, and then inferring a site-specific uniform tree scaler", - terms.io.version: "0.2", + terms.io.info: "LEISR (Likelihood Estimation of Individual Site Rates) infer relative amino-acid or nucleotide rates from a fixed nucleotide or amino-acid alignment and tree, with possibility for partitions. Relative site-specific substitution rates are + inferred by first optimizing alignment-wide branch lengths, and then inferring a site-specific uniform tree scaler.", + terms.io.version: "0.3", terms.io.reference: "Spielman, S.J. and Kosakovsky Pond, S.L. Relative evolutionary rate inference in HyPhy with LEISR. bioRxiv. https://doi.org/10.1101/206011. (2017); Pupko, T., Bell, R. E., Mayrose, I., Glaser, F. & Ben-Tal, N. Rate4Site: an algorithmic tool for the identification of functional regions in proteins by surface mapping of evolutionary determinants within their homologues. Bioinformatics 18, S71–S77 (2002).", terms.io.authors: "Sergei L Kosakovsky Pond and Stephanie J Spielman", terms.io.contact: "{spond,stephanie.spielman}@temple.edu" @@ -49,17 +49,23 @@ if (None == leisr.name_mapping) { leisr.name_mapping = {}; utility.ForEach (alignments.GetSequenceNames ("leisr.dataset"), "_value_", "`&leisr.name_mapping`[_value_] = _value_"); } + + leisr.partitions_and_trees = trees.LoadAnnotatedTreeTopology.match_partitions (leisr.alignment_info[utility.getGlobalValue("terms.data.partitions")], leisr.name_mapping); leisr.partition_count = Abs (leisr.partitions_and_trees); +leisr.filter_specification = alignments.DefineFiltersForPartitions (leisr.partitions_and_trees, "leisr.dataset" , "leisr.filter.", leisr.alignment_info); + +// selection.io.json_store_key_value_pair (json, None, utility.getGlobalValue("terms.json.partitions"), +// filter_specification); + +// io.CheckAssertion ("leisr.partition_count==1", "This analysis can only handle a single partition"); -io.CheckAssertion ("leisr.partition_count==1", "This analysis can only handle a single partition"); io.ReportProgressMessageMD ("relative_rates", "Data", "Input alignment description"); io.ReportProgressMessageMD ("relative_rates", "Data", "Loaded **" + leisr.alignment_info [terms.data.sequences] + "** sequences, **" + leisr.alignment_info [terms.data.sites] + "** sites, and **" + leisr.partition_count + "** partitions from \`" + leisr.alignment_info [terms.data.file] + "\`"); -leisr.filter_specification = alignments.DefineFiltersForPartitions (leisr.partitions_and_trees, "leisr.dataset" , "leisr.filter.", leisr.alignment_info); /*******************************************************************************************************************/ @@ -139,93 +145,149 @@ leisr.alignment_wide_MLES = estimators.FitSingleModel_Ext ( leisr.trees, leisr.baseline_model_desc, None, - None); + Nome); estimators.fixSubsetOfEstimates(leisr.alignment_wide_MLES, leisr.alignment_wide_MLES[terms.global]); -io.ReportProgressMessageMD ("relative_rates", "overall", ">Fitted an alignment-wide model. **Log-L = " + leisr.alignment_wide_MLES [terms.fit.log_likelihood] + "**."); +io.ReportProgressMessageMD ("relative_rates", "overall", ">Fitted an alignment-wide model. **Log-L = " + leisr.alignment_wide_MLES [terms.fit.log_likelihood] + "**.\n\nTotal tree lengths by partition\n"); + +utility.ForEachPair (leisr.alignment_wide_MLES[terms.branch_length], "_part_", "_value_", +' +io.ReportProgressMessageMD ("relative_rates", "overall", "" + (1+_part_) + ". " + Format (+(utility.Map (_value_, "_data_", + " + _data_ [terms.fit.MLE] + " +)),6,3) + " subs/site."); +' +); + /** Set up the table to display to the screen */ -leisr.table_screen_output = {{"Site", "Rel. rate (MLE)", "95% profile likelihood CI"}}; +leisr.table_screen_output = {{"Site", "Partition", "Rel. rate (MLE)", "95% profile likelihood CI"}}; leisr.table_output_options = {terms.table_options.header : TRUE, terms.table_options.minimum_column_width : 16, terms.table_options.align : "center"}; + +leisr.table_row_report = {{ + "" + (1+((leisr.filter_specification[leisr.report.partition])[terms.data.coverage])[leisr.report.site]), + leisr.report.partition + 1, + Format(leisr.report.row[0],10,6), + Format(leisr.report.row[1],6,2) + " : " + Format(leisr.report.row[2],6,2) + }}; + + leisr.table_headers = {{"MLE", "Relative rate estimate at a site"} {"Lower", "Lower bound of 95% profile likelihood CI"} {"Upper", "Upper bound of 95% profile likelihood CI"}}; -leisr.site_results = {leisr.alignment_info [terms.data.sites], Rows (leisr.table_headers)}; - -leisr.site_patterns = alignments.Extract_site_patterns (leisr.filter_names[0]); - // set-up model for site-level fitting in the next couple of lines, where rv turned off leisr.site_model = model.generic.DefineModel("leisr.Baseline.ModelDescription", - "relative_rates_site_model_instance", { + "leisr_site_model_instance", { "0": parameters.Quote(terms.global), }, leisr.filter_names[0], None); + +leisr.site_results = {}; +leisr.rate_estimates = {}; // For stats + + + +for (leisr.partition_index = 0; leisr.partition_index < leisr.partition_count; leisr.partition_index += 1) { + + leisr.site_patterns = alignments.Extract_site_patterns ((leisr.filter_specification[leisr.partition_index])[utility.getGlobalValue("terms.data.name")]); + leisr.site_model_mapping = {"leisr_site_model_instance" : leisr.site_model}; + + + // leisr.site_tree is created from the information in leisr.trees[leisr.partition_index] + // and populated with (the default) model + model.ApplyModelToTree( "leisr.site_tree", leisr.trees[leisr.partition_index], {terms.default : leisr.site_model}, None); + + // create a site filter; this is an ugly hack for the time being + // alignments.serialize_site_filter returns HBL code as string in + // which the function `__make_filter` is defined. + ExecuteCommands (alignments.serialize_site_filter + ((leisr.filter_specification[leisr.partition_index])[utility.getGlobalValue("terms.data.name")], + ((leisr.site_patterns[0])[utility.getGlobalValue("terms.data.sites")])[0], + )); + + __make_filter ("leisr.site_filter"); + + LikelihoodFunction leisr.site_likelihood = (leisr.site_filter, leisr.site_tree); + + leisr.site_model_scaler_name = "leisr.site_rate_estimate"; + parameters.DeclareGlobal (leisr.site_model_scaler_name, None); + + + /* + + SLKP 20171210 + + leisr.alignment_wide_MLES will have multiple partitions in general, and applying estimates to a site partition + will ALWAYS copy values from the 0-index global partition to it. + Clearly, this is not the right thing do do. So the solution is to copy the branch lengths from partition + i (>0) to the index zero leisr.alignment_wide_MLES + + This will invalide the MLE set, but we should be done it with it by now + If not, it could be deep copied. + + */ + + if (leisr.partition_index) { + (leisr.alignment_wide_MLES [terms.branch_length])[0] = (leisr.alignment_wide_MLES [terms.branch_length])[leisr.partition_index]; + } + + estimators.ApplyExistingEstimates ("leisr.site_likelihood", leisr.site_model_mapping, leisr.alignment_wide_MLES, + {"0" : leisr.site_model_scaler_name} // proportional scaler + ); -leisr.site_model_mapping = {"relative_rates_site_model_instance" : leisr.site_model}; - -// leisr.site_tree is created from the information in leisr.trees[0] -// and populated with (the default) model -model.ApplyModelToTree( "leisr.site_tree", leisr.trees[0], {terms.default : leisr.site_model}, None); - -// create a site filter; this is an ugly hack for the time being -// alignments.serialize_site_filter returns HBL code as string in -// which the function `__make_filter` is defined. -ExecuteCommands (alignments.serialize_site_filter ( - leisr.filter_names[0], - ((leisr.site_patterns[0])[terms.data.sites])[0])); - -__make_filter ("leisr.site_filter"); - -LikelihoodFunction leisr.site_likelihood = (leisr.site_filter, leisr.site_tree); + leisr.queue = mpi.CreateQueue ({terms.mpi.LikelihoodFunctions: {{"leisr.site_likelihood"}}, + terms.mpi.Models : {{"leisr.site_model"}}, + terms.mpi.Headers : utility.GetListOfLoadedModules ("libv3/"), + terms.mpi.Variables : {{"leisr.site_model_scaler_name"}} + }); + + /* run the main loop over all unique site pattern combinations */ + utility.ForEachPair (leisr.site_patterns, "_pattern_", "_pattern_info_", + ' + mpi.QueueJob (leisr.queue, "leisr.handle_a_site", {"0" : "leisr.site_likelihood", + "1" : alignments.serialize_site_filter + ((leisr.filter_specification[leisr.partition_index])[terms.data.name], + (_pattern_info_[utility.getGlobalValue("terms.data.sites")])[0]), + "2": leisr.partition_index, + "3" : _pattern_info_, + "4" : leisr.site_model_mapping + }, + "leisr.store_results"); + ' + ); -leisr.site_model_scaler_name = "leisr.site_rate_estimate"; -leisr.rate_estimates = {}; + mpi.QueueComplete (leisr.queue); -/** - this will store site estimates, which will then be dumped to JSON -*/ + leisr.partition_matrix = {Abs (leisr.site_results[leisr.partition_index]), 3}; // mle, lower, upper = 3 -parameters.DeclareGlobal (leisr.site_model_scaler_name, None); + utility.ForEachPair (leisr.site_results[leisr.partition_index], "_key_", "_value_", + ' + for (leisr.index = 0; leisr.index < 3; leisr.index += 1) { + leisr.partition_matrix [0+_key_][leisr.index] = _value_[leisr.index]; + } + ' + ); -estimators.ApplyExistingEstimates ("leisr.site_likelihood", leisr.site_model_mapping, leisr.alignment_wide_MLES, - {"0" : leisr.site_model_scaler_name} // proportional scaler - ); + leisr.site_results[leisr.partition_index] = leisr.partition_matrix; +} -leisr.queue = mpi.CreateQueue ({terms.mpi.LikelihoodFunctions: {{"leisr.site_likelihood"}}, - terms.mpi.Models : {{"leisr.site_model"}}, - terms.mpi.Headers : utility.GetListOfLoadedModules ("libv3/"), - terms.mpi.Variables : {{"leisr.site_model_scaler_name"}} - }); - -/* run the main loop over all unique site pattern combinations */ -utility.ForEachPair (leisr.site_patterns, "_pattern_", "_pattern_info_", - ' - mpi.QueueJob (leisr.queue, "leisr.handle_a_site", {"0" : "leisr.site_likelihood", - "1" : alignments.serialize_site_filter - ((leisr.filter_specification[0])[terms.data.name], - (_pattern_info_[terms.data.sites])[0]), - "2" : _pattern_info_, - "3" : leisr.site_model_mapping - }, - "leisr.store_results"); - ' -); -mpi.QueueComplete (leisr.queue); -leisr.site_rates = utility.Map( utility.Values(utility.Map (leisr.rate_estimates, "_value_", "_value_[terms.fit.MLE]")), "_value_", "0+_value_"); +/* TODO: Update for compatibility with partitioning +leisr.site_rates = utility.Map( utility.Values(utility.Map (leisr.site_results, "_value_", "_value_[terms.fit.MLE]")), "_value_", "0+_value_"); leisr.stats = math.GatherDescriptiveStats(leisr.site_rates); io.ReportProgressMessageMD ("relative_rates", "Stats", "Rate distribution summary"); @@ -233,11 +295,12 @@ io.ReportProgressMessageMD ("relative_rates", "Stats", "* **Mean**: " + Format io.ReportProgressMessageMD ("relative_rates", "Stats", "* **Median**: " + Format (leisr.stats[terms.math.median], 6, 2)); io.ReportProgressMessageMD ("relative_rates", "Stats", "* **Std.Dev**: " + Format (leisr.stats[terms.math.stddev], 6, 2)); io.ReportProgressMessageMD ("relative_rates", "Stats", "* **95% Range**: [" + Format (leisr.stats[terms.math._2.5], 5,2) + "," + Format (leisr.stats[terms.math._97.5], 5,2) + "]"); - +*/ /************************************* JSON STORAGE ***********************************/ + leisr.store_global = utility.Map( utility.Map (leisr.alignment_wide_MLES[utility.getGlobalValue("terms.global")], "_value_", ' {terms.fit.MLE : _value_[terms.fit.MLE]}'), "_value_", @@ -270,14 +333,26 @@ leisr.json_content = { terms.json.input : } }, terms.json.MLE : {terms.json.headers : leisr.table_headers, - terms.json.content : {"0":leisr.site_results} + terms.json.content : leisr.site_results } }; -selection.io.json_store_branch_attribute(leisr.json_content, utility.getGlobalValue ("terms.original_name"), utility.getGlobalValue ("terms.json.node_label"), -1, 0, utility.getGlobalValue ("leisr.name_mapping")); -selection.io.json_store_branch_attribute(leisr.json_content, utility.getGlobalValue ("leisr.baseline_model_name"), utility.getGlobalValue ("terms.branch_length"), 0, 0, - selection.io.extract_branch_info((leisr.alignment_wide_MLES[terms.branch_length])[0], "selection.io.branch.length") - ); +for (partition_index = 0; partition_index < leisr.partition_count; partition_index += 1) { + selection.io.json_store_branch_attribute(leisr.json_content, utility.getGlobalValue ("terms.original_name"), utility.getGlobalValue ("terms.json.node_label"), -1, + partition_index, + leisr.name_mapping); + + selection.io.json_store_branch_attribute(leisr.json_content, utility.getGlobalValue ("leisr.baseline_model_name"), utility.getGlobalValue ("terms.branch_length"), 0, + partition_index, + selection.io.extract_branch_info((leisr.alignment_wide_MLES[utility.getGlobalValue ("terms.branch_length")])[partition_index], "selection.io.branch.length")); + +} + +selection.io.json_store_key_value_pair (leisr.json_content, None, utility.getGlobalValue("terms.json.partitions"), + leisr.filter_specification); + + + io.SpoolJSON (leisr.json_content, leisr.alignment_info[terms.data.file] + ".LEISR.json"); @@ -290,14 +365,23 @@ io.SpoolJSON (leisr.json_content, leisr.alignment_info[terms.data.file] + ".LEIS //---------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------- -lfunction leisr.handle_a_site (lf, filter_data, pattern_info, model_mapping) { +lfunction leisr.handle_a_site (lf, filter_data, partition_index, pattern_info, model_mapping) { GetString (lfInfo, ^lf,-1); ExecuteCommands (filter_data); - __make_filter ((lfInfo["Datafilters"])[0]); + + utility.SetEnvVariable ("USE_LAST_RESULTS", TRUE); - + parameters.SetValue (^"leisr.site_model_scaler_name", 1); + /* + + SLKP 20171210 + RESET the global rate value to a default avoid weird optimization issues because of bad starting conditions + (e.g. if the previous site was saturated) + */ + + if (pattern_info [utility.getGlobalValue("terms.data.is_constant")]) { // the MLE for a constant site is 0; // only the CI is non-trivial @@ -317,9 +401,15 @@ lfunction leisr.handle_a_site (lf, filter_data, pattern_info, model_mapping) { //---------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------- +function leisr.report.echo (leisr.report.site, leisr.report.partition, leisr.report.row) { + fprintf (stdout, io.FormatTableRow (leisr.table_row_report,leisr.table_output_options)); + +} + lfunction leisr.store_results (node, result, arguments) { - pattern_info = arguments [2]; + partition_index = arguments [2]; + pattern_info = arguments [3]; if ((^'leisr.table_output_options')[utility.getGlobalValue("terms.table_options.header")]) { @@ -330,27 +420,40 @@ lfunction leisr.store_results (node, result, arguments) { io.FormatTableRow (^'leisr.table_screen_output',^'leisr.table_output_options')); (^'leisr.table_output_options')[utility.getGlobalValue("terms.table_options.header")] = FALSE; } + + utility.EnsureKey (^"leisr.site_results", partition_index); utility.ForEach (pattern_info[utility.getGlobalValue("terms.data.sites")], "_site_index_", " - leisr.rate_estimates [_site_index_+1] = `&result`; + //leisr.rate_estimates [_site_index_+1] = `&result`; result_row = {1,3}; - result_row [0] = '' + (_site_index_ + 1); - result_row [1] = Format((`&result`)[terms.fit.MLE],6,3); - result_row [2] = Format((`&result`)[terms.lower_bound],6,3) + ' :' +Format((`&result`)[terms.upper_bound],6,3); - fprintf (stdout, + result_row [0] = (`&result`)[terms.fit.MLE]; + result_row [1] = (`&result`)[terms.lower_bound]; + result_row [2] = (`&result`)[terms.upper_bound]; + + + leisr.report.echo (_site_index_, `&partition_index`, result_row); + /*fprintf (stdout, io.FormatTableRow (result_row,leisr.table_output_options)); - + */ + out_result_row = {1,3}; + out_result_row[0] = (`&result`)[terms.fit.MLE]; + out_result_row[1] = (`&result`)[terms.lower_bound]; + out_result_row[2] = (`&result`)[terms.upper_bound]; + + + (leisr.site_results[`&partition_index`])[_site_index_] = out_result_row; + + /* // JSON-related - //console.log(_site_index_); leisr.site_results[_site_index_][0] = (leisr.rate_estimates[_site_index_+1])[terms.fit.MLE]; leisr.site_results[_site_index_][1] = (leisr.rate_estimates[_site_index_+1])[terms.lower_bound]; leisr.site_results[_site_index_][2] = (leisr.rate_estimates[_site_index_+1])[terms.upper_bound]; + */ " ); - return rate_statistics; - + //return rate_statistics; } From d5cca1a5fb7df6e0d4a39d862136b98248ac759c Mon Sep 17 00:00:00 2001 From: Steven Weaver Date: Mon, 11 Dec 2017 14:00:31 -0500 Subject: [PATCH 18/24] #712 : removes CMake exclude_from_all warnings --- CMakeLists.txt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95ae73706..202aaf2f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.0.0) project(HyPhy) cmake_policy(VERSION 3.0.0) -cmake_policy(SET CMP0026 OLD) +cmake_policy(SET CMP0026 NEW) set(CMAKE_CONFIGURATION_TYPES Release) @@ -277,7 +277,6 @@ install(DIRECTORY res/ DESTINATION lib/hyphy) #------------------------------------------------------------------------------- add_executable( HYPHYMP - EXCLUDE_FROM_ALL ${SRC_COMMON} ${SRC_UNIXMAIN} ) @@ -306,12 +305,6 @@ if(${OPENCL_FOUND}) include_directories(${OPENCL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src/ocl) target_link_libraries(HYPHYOCL ${DEFAULT_LIBRARIES} ${OPENCL_LIBRARIES}) - install( - TARGETS HYPHYOCL - RUNTIME DESTINATION bin - OPTIONAL - ) - add_custom_target(OCL DEPENDS HYPHYOCL) set_property( TARGET HYPHYOCL @@ -345,7 +338,6 @@ if(${MPI_FOUND}) add_executable( HYPHYMPI - EXCLUDE_FROM_ALL ${SRC_COMMON} ${SRC_UNIXMAIN} ) From 10b54b5f2de12afcaad2f78353392b50e7a88a09 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Tue, 12 Dec 2017 14:11:56 -0500 Subject: [PATCH 19/24] Updated LEISR test to include a partitioned dataset --- tests/hbltests/libv3/LEISR.wbf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/hbltests/libv3/LEISR.wbf b/tests/hbltests/libv3/LEISR.wbf index b01d3c10a..1edf1060e 100644 --- a/tests/hbltests/libv3/LEISR.wbf +++ b/tests/hbltests/libv3/LEISR.wbf @@ -43,4 +43,13 @@ LoadFunctionLibrary("LEISR.bf", { "2": "Nucleotide", "3": "HKY85", "4": "No" -}); \ No newline at end of file +}); + +LoadFunctionLibrary("LEISR.bf", { + "0": PATH_TO_CURRENT_BF + "data/partitioned.nex", + "1": "Nucleotide", + "2": "HKY85", + "3": "Gamma" +}); + + From b8c8c569d2bbced89764c783f7b081d80c67e584 Mon Sep 17 00:00:00 2001 From: "Stephanie J. Spielman" Date: Wed, 13 Dec 2017 12:36:00 -0500 Subject: [PATCH 20/24] Matrix reorganization --- .../libv3/models/protein.bf | 24 +- .../libv3/models/protein/empirical.bf | 2732 +---------------- .../libv3/models/protein/matrices/HIV.ibf | 631 ++++ .../libv3/models/protein/matrices/JC69.ibf | 273 ++ .../libv3/models/protein/matrices/JTT.ibf | 269 ++ .../libv3/models/protein/matrices/LG.ibf | 273 ++ .../libv3/models/protein/matrices/WAG.ibf | 271 ++ .../libv3/models/protein/matrices/gcpREV.ibf | 269 ++ .../libv3/models/protein/matrices/mt.ibf | 817 +++++ 9 files changed, 2855 insertions(+), 2704 deletions(-) create mode 100644 res/TemplateBatchFiles/libv3/models/protein/matrices/HIV.ibf create mode 100644 res/TemplateBatchFiles/libv3/models/protein/matrices/JC69.ibf create mode 100644 res/TemplateBatchFiles/libv3/models/protein/matrices/JTT.ibf create mode 100644 res/TemplateBatchFiles/libv3/models/protein/matrices/LG.ibf create mode 100644 res/TemplateBatchFiles/libv3/models/protein/matrices/WAG.ibf create mode 100644 res/TemplateBatchFiles/libv3/models/protein/matrices/gcpREV.ibf create mode 100644 res/TemplateBatchFiles/libv3/models/protein/matrices/mt.ibf diff --git a/res/TemplateBatchFiles/libv3/models/protein.bf b/res/TemplateBatchFiles/libv3/models/protein.bf index bf1580c99..f43b5c724 100644 --- a/res/TemplateBatchFiles/libv3/models/protein.bf +++ b/res/TemplateBatchFiles/libv3/models/protein.bf @@ -10,18 +10,16 @@ models.protein.alphabet = {{"A","C","D","E","F","G","H","I","K","L","M","N","P", /* Available empirical models */ -models.protein.empirical_models = {{"LG", "Empirical model of protein evolution from Le and Gascuel (2008). Ref: https://doi.org/10.1093/molbev/msn067"}, - {"WAG", "Empirical model of protein evolution from Whelan and Goldman (2001). Ref: https://doi.org/10.1093/oxfordjournals.molbev.a003851"}, - {"JTT", "Empirical model of protein evolution from Jones, Taylor, and Thornton (1996). Ref: https://doi.org/10.1093/bioinformatics/8.3.275"}, - {"JC69", "Empirical model of protein evolution with equal exchangeability rates among all amino acids, also known as JC69."}, - {"mtMAM", "Empirical model of protein evolution for mammalian mitochondrial genomes from Yang N, Nielsen R, and Hasegawa M. (1998). Ref: http://dx.doi.org/10.1093/oxfordjournals.molbev.a025888"}, - {"mtMet", "Empirical model of protein evolution for metazoan mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, - {"mtVer", "Empirical model of protein evolution for vertebrate mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, - {"cpREV", "Empirical model of protein evolution for chloroplast genomes from from Adachi et al. (2000). Ref: https://www.ncbi.nlm.nih.gov/pubmed/10795826"}, - {"gcpREV", "Empirical model of protein evolution for green plant chloroplast genomes from from Cox and Foster (2013). Ref: https://doi.org/10.1016/j.ympev.2013.03.030"}, - {"HIVBm", "Empirical model of protein evolution for between-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, - {"HIVWm", "Empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, - {"AB", "Empirical model of protein evolution for antibody sequences from Mirsky et al. (2015). Ref: https://doi.org/10.1093/molbev/msu340"} +models.protein.empirical_models = {{"LG", "Generalist empirical model of protein evolution from Le and Gascuel (2008). Ref: https://doi.org/10.1093/molbev/msn067"}, + {"WAG", "Generalist empirical model of protein evolution from Whelan and Goldman (2001). Ref: https://doi.org/10.1093/oxfordjournals.molbev.a003851"}, + {"JTT", "Generalist empirical model of protein evolution from Jones, Taylor, and Thornton (1996). Ref: https://doi.org/10.1093/bioinformatics/8.3.275"}, + {"JC69", "Generalist empirical model of protein evolution with equal exchangeability rates among all amino acids, also known as JC69."}, + {"mtMet", "Specialist empirical model of protein evolution for metazoan mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, + {"mtVer", "Specialist empirical model of protein evolution for vertebrate mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, + {"mtInv", "Specialist empirical model of protein evolution for invertebrate mitochondrial genomes from Le, Dang, and Le. (2017). Ref: 10.1186/s12862-017-0987-y"}, + {"gcpREV", "Specialist empirical model of protein evolution for green plant chloroplast genomes from from Cox and Foster (2013). Ref: https://doi.org/10.1016/j.ympev.2013.03.030"}, + {"HIVBm", "Specialist empirical model of protein evolution for between-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"}, + {"HIVWm", "Specialist empirical model of protein evolution for within-host HIV sequences from Nickle et al. (2007). Ref: https://doi.org/10.1371/journal.pone.0000503"} }; @@ -40,7 +38,7 @@ function models.protein.generic.Time (option) { - +/* Function below relocated to protein/empirical.bf and protein/REV.bf, each. /** * @name models.protein.generic.DefineQMatrix * @param {Dictionary} modelSpec diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index fb65cf8a3..d8d94bde6 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -5,45 +5,6 @@ LoadFunctionLibrary("../../UtilityFunctions.bf"); LoadFunctionLibrary("../../all-terms.bf"); - -models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDescription", - "WAG": "models.protein.WAG.ModelDescription", - "JTT": "models.protein.JTT.ModelDescription", - "JC69": "models.protein.JC69.ModelDescription", - "mtMAM": "models.protein.mtMAM.ModelDescription", - "mtMet": "models.protein.mtMet.ModelDescription", - "mtVer": "models.protein.mtVer.ModelDescription", - "cpREV": "models.protein.cpREV.ModelDescription", - "gcpREV": "models.protein.gcpREV.ModelDescription", - "HIVBm": "models.protein.HIVBm.ModelDescription", - "HIVWm": "models.protein.HIVWm.ModelDescription", - "AB" : "models.protein.AB.ModelDescription"}; - -models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDescription", - "WAG": "models.protein.WAGF.ModelDescription", - "JTT": "models.protein.JTTF.ModelDescription", - "JC69": "models.protein.JC69F.ModelDescription", - "mtMAM": "models.protein.mtMAMF.ModelDescription", - "mtMet": "models.protein.mtMetF.ModelDescription", - "mtVer": "models.protein.mtVerF.ModelDescription", - "cpREV": "models.protein.cpREVF.ModelDescription", - "gcpREV": "models.protein.gcpREVF.ModelDescription", - "HIVBm": "models.protein.HIVBmF.ModelDescription", - "HIVWm": "models.protein.HIVWmF.ModelDescription", - "AB" : "models.protein.ABF.ModelDescription"}; - -models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDescription", - "WAG": "models.protein.WAGML.ModelDescription", - "JTT": "models.protein.JTTML.ModelDescription", - "JC69": "models.protein.JC69ML.ModelDescription", - "mtMAM": "models.protein.mtMAMML.ModelDescription", - "mtMet": "models.protein.mtMetML.ModelDescription", - "mtVer": "models.protein.mtVerML.ModelDescription", - "cpREV": "models.protein.cpREVML.ModelDescription", - "gcpREV": "models.protein.gcpREVML.ModelDescription", - "HIVBm": "models.protein.HIVBmML.ModelDescription", - "HIVWm": "models.protein.HIVWmML.ModelDescription", - "AB" : "models.protein.ABML.ModelDescription"}; /** @module models.protein.empirical */ /** @@ -76,6 +37,17 @@ lfunction models.protein.empirical.ModelDescription(type) { }; } +/* +Load model matrices +*/ +LoadFunctionLibrary("matrices/JC69.ibf"); +LoadFunctionLibrary("matrices/JTT.ibf"); +LoadFunctionLibrary("matrices/LG.ibf"); +LoadFunctionLibrary("matrices/WAG.ibf"); +LoadFunctionLibrary("matrices/mt.ibf"); // all three mtMet/mtVer/mtInv models +LoadFunctionLibrary("matrices/gcpREV.ibf"); +LoadFunctionLibrary("matrices/HIV.ibf"); + /** * @name models.protein.Empirical._GenerateRate * @description Generates the r_ij component of q_ij := r_ij * time * freq_j @@ -288,51 +260,42 @@ function models.protein.empirical.DefineQMatrix (modelSpec, namespace) { } +models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDescription", + "WAG": "models.protein.WAG.ModelDescription", + "JTT": "models.protein.JTT.ModelDescription", + "JC69": "models.protein.JC69.ModelDescription", + "mtInv": "models.protein.mtInv.ModelDescription", + "mtMet": "models.protein.mtMet.ModelDescription", + "mtVer": "models.protein.mtVer.ModelDescription", + "gcpREV": "models.protein.gcpREV.ModelDescription", + "HIVBm": "models.protein.HIVBm.ModelDescription", + "HIVWm": "models.protein.HIVWm.ModelDescription"}; + +models.protein.empirical.plusF_generators = {"LG": "models.protein.LGF.ModelDescription", + "WAG": "models.protein.WAGF.ModelDescription", + "JTT": "models.protein.JTTF.ModelDescription", + "JC69": "models.protein.JC69F.ModelDescription", + "mtMet": "models.protein.mtMetF.ModelDescription", + "mtVer": "models.protein.mtVerF.ModelDescription", + "gcpREV": "models.protein.gcpREVF.ModelDescription", + "HIVBm": "models.protein.HIVBmF.ModelDescription", + "HIVWm": "models.protein.HIVWmF.ModelDescription"}; + +models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDescription", + "WAG": "models.protein.WAGML.ModelDescription", + "JTT": "models.protein.JTTML.ModelDescription", + "JC69": "models.protein.JC69ML.ModelDescription", + "mtMet": "models.protein.mtMetML.ModelDescription", + "mtVer": "models.protein.mtVerML.ModelDescription", + "gcpREV": "models.protein.gcpREVML.ModelDescription", + "HIVBm": "models.protein.HIVBmML.ModelDescription", + "HIVWm": "models.protein.HIVWmML.ModelDescription"}; -/**************************************** WAG functions *************************************/ -/** - * @name models.protein.WAG.ModelDescription - * @description Create the baseline schema (dictionary) for the WAG model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.WAG.ModelDescription(type) { - models.protein.WAG.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); - models.protein.WAG.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.WAG.Rij; - models.protein.WAG.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.WAG.frequencies"; - return models.protein.WAG.ModelDescription.model_definition; -} - -/** - * @name models.protein.WAGF.ModelDescription - * @description Create the baseline schema (dictionary) for the WAG+F model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.WAGF.ModelDescription(type) { - models.protein.WAGF.ModelDescription.model_definition = models.protein.WAG.ModelDescription(type); - models.protein.WAGF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; - models.protein.WAGF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); - return models.protein.WAGF.ModelDescription.model_definition; -} - -/** - * @name models.protein.WAGML.ModelDescription - * @description Create the baseline schema (dictionary) for the WAG+ML model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.WAGML.ModelDescription(type) { - models.protein.WAGML.ModelDescription.model_definition = models.protein.WAG.ModelDescription(type); - models.protein.WAGML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; - models.protein.WAGML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); - return models.protein.WAGML.ModelDescription.model_definition; -} @@ -557,92 +520,6 @@ function models.protein.cpREVML.ModelDescription(type) { } -/**************************************** HIVBm functions *************************************/ - - -/** - * @name models.protein.HIVBm.ModelDescription - * @description Create the baseline schema (dictionary) for the HIVBm model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.HIVBm.ModelDescription(type) { - models.protein.HIVBm.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); - models.protein.HIVBm.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.HIVBm.Rij; - models.protein.HIVBm.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.HIVBm.frequencies"; - return models.protein.HIVBm.ModelDescription.model_definition; -} - -/** - * @name models.protein.HIVBmF.ModelDescription - * @description Create the baseline schema (dictionary) for the HIVBm+F model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.HIVBmF.ModelDescription(type) { - models.protein.HIVBmF.ModelDescription.model_definition = models.protein.HIVBm.ModelDescription(type); - models.protein.HIVBmF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; - models.protein.HIVBmF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); - return models.protein.HIVBmF.ModelDescription.model_definition; -} - -/** - * @name models.protein.HIVBmML.ModelDescription - * @description Create the baseline schema (dictionary) for the HIVBm+ML model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.HIVBmML.ModelDescription(type) { - models.protein.HIVBmML.ModelDescription.model_definition = models.protein.HIVBm.ModelDescription(type); - models.protein.HIVBmML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; - models.protein.HIVBmML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); - return models.protein.HIVBmML.ModelDescription.model_definition; -} - - - -/**************************************** HIVWm functions *************************************/ - - -/** - * @name models.protein.HIVWm.ModelDescription - * @description Create the baseline schema (dictionary) for the HIVWm model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.HIVWm.ModelDescription(type) { - models.protein.HIVWm.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); - models.protein.HIVWm.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.HIVWm.Rij; - models.protein.HIVWm.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.HIVWm.frequencies"; - return models.protein.HIVWm.ModelDescription.model_definition; -} - -/** - * @name models.protein.HIVWmF.ModelDescription - * @description Create the baseline schema (dictionary) for the HIVWm+F model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.HIVWmF.ModelDescription(type) { - models.protein.HIVWmF.ModelDescription.model_definition = models.protein.HIVWm.ModelDescription(type); - models.protein.HIVWmF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; - models.protein.HIVWmF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); - return models.protein.HIVWmF.ModelDescription.model_definition; -} - -/** - * @name models.protein.HIVWmML.ModelDescription - * @description Create the baseline schema (dictionary) for the HIVWm+ML model of protein evolution - * @returns {Dictionary} model description - * @param {String} type - */ -function models.protein.HIVWmML.ModelDescription(type) { - models.protein.HIVWmML.ModelDescription.model_definition = models.protein.HIVWm.ModelDescription(type); - models.protein.HIVWmML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; - models.protein.HIVWmML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); - return models.protein.HIVWmML.ModelDescription.model_definition; -} - /**************************************** AB functions *************************************/ @@ -825,556 +702,6 @@ function models.protein.gcpREVML.ModelDescription(type) { -/*=============================================================================================*/ -/** Below this section are all of the empirical matrices and frequency vectors, including Rij **/ - - - -/** - * @name models.protein.WAG.frequencies - * @param {Dictionary} Baseline WAG model - * @returns {Dictionary} Updated WAG model with empirical frequencies - * @description Define the empirical amino acid frequencies associated with the WAG model of protein evolution - */ -lfunction models.protein.WAG.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.0866279} - { 0.0193078} - { 0.0570451} - { 0.0580589} - { 0.0384319} - { 0.0832518} - { 0.0244313} - { 0.048466} - { 0.0620286} - { 0.086209} - { 0.0195027} - { 0.0390894} - { 0.0457631} - { 0.0367281} - { 0.043972} - { 0.0695179} - { 0.0610127} - { 0.0708956} - { 0.0143859} - { 0.0352742} - }; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - - -/* Define a dictionary of amino-acid exchangeability rates for the WAG model of protein evolution. */ -models.protein.WAG.Rij = { - "A":{ - "C":0.02081175, - "D":0.04424356, - "E":0.09644885, - "F":0.008490242, - "G":0.1237844, - "H":0.008127018999999999, - "I":0.009834135000000001, - "K":0.05899778, - "L":0.03600239, - "M":0.0182884, - "N":0.02091646, - "P":0.06909218, - "Q":0.03502343, - "R":0.02545459, - "S":0.245933, - "T":0.1358225, - "V":0.1492591, - "W":0.001708106, - "Y":0.008912199000000001 - }, - "C":{ - "D":0.001813745, - "E":0.001301055, - "F":0.01605407, - "G":0.02679532, - "H":0.006383892, - "I":0.008654049, - "K":0.004819601, - "L":0.03476936, - "M":0.007992529, - "N":0.0108821, - "P":0.005254569, - "Q":0.003809101, - "R":0.02437562, - "S":0.1027029, - "T":0.03284827, - "V":0.0745652, - "W":0.01082647, - "Y":0.02013312 - }, - "D":{ - "E":0.3762142, - "F":0.001884863, - "G":0.07562952000000001, - "H":0.02386347, - "I":0.002005993, - "K":0.03123852, - "L":0.007672926, - "M":0.002123675, - "N":0.2227414, - "P":0.02036354, - "Q":0.02377493, - "R":0.00679797, - "S":0.07819566, - "T":0.02400406, - "V":0.01133463, - "W":0.001959249, - "Y":0.01205807 - }, - "E":{ - "F":0.003272523, - "G":0.04960369, - "H":0.01461601, - "I":0.006480045, - "K":0.1682461, - "L":0.01395734, - "M":0.006450074, - "N":0.0388587, - "P":0.03277285, - "Q":0.2108299, - "R":0.02026676, - "S":0.05143238, - "T":0.0526847, - "V":0.0438051, - "W":0.00236373, - "Y":0.007267292 - }, - "F":{ - "G":0.00436267, - "H":0.01741975, - "I":0.05389076, - "K":0.005783216, - "L":0.1913755, - "M":0.02437025, - "N":0.00394504, - "P":0.007754001, - "Q":0.003851615, - "R":0.004740036, - "S":0.03983115, - "T":0.01100758, - "V":0.04835584, - "W":0.02309483, - "Y":0.2389425 - }, - "G":{ - "H":0.006395123, - "I":0.001548868, - "K":0.02431859, - "L":0.005546612, - "M":0.003563543, - "N":0.04617598, - "P":0.01169843, - "Q":0.0127224, - "R":0.02698185, - "S":0.09789926, - "T":0.01446092, - "V":0.01393229, - "W":0.005087841, - "Y":0.003835501 - }, - "H":{ - "I":0.007029141, - "K":0.05796705, - "L":0.04519012, - "M":0.008272107000000001, - "N":0.1623063, - "P":0.03343772, - "Q":0.1655236, - "R":0.09862788, - "S":0.05400277, - "T":0.0303076, - "V":0.008806540999999999, - "W":0.003964322, - "Y":0.1433978 - }, - "I":{ - "K":0.02108143, - "L":0.2869017, - "M":0.08714326, - "N":0.02273747, - "P":0.004799484, - "Q":0.004391122, - "R":0.008628942000000001, - "S":0.02330635, - "T":0.09337141, - "V":0.5819514, - "W":0.003208113, - "Y":0.01555502 - }, - "K":{ - "L":0.02330296, - "M":0.0191231, - "N":0.1235674, - "P":0.02674718, - "Q":0.1501354, - "R":0.246964, - "S":0.07056185, - "T":0.08881348999999999, - "V":0.02272611, - "W":0.002076079, - "Y":0.004933538 - }, - "L":{ - "M":0.09935387, - "N":0.005395922, - "P":0.01997258, - "Q":0.03351591, - "R":0.02296714, - "S":0.02515217, - "T":0.02091482, - "V":0.133956, - "W":0.01004497, - "Y":0.01475715 - }, - "M":{ - "N":0.008131996000000001, - "P":0.008228767999999999, - "Q":0.05956464, - "R":0.03152741, - "S":0.03603533, - "T":0.0970828, - "V":0.1531609, - "W":0.007786238, - "Y":0.01586107 - }, - "N":{ - "P":0.009369552999999999, - "Q":0.05950219, - "R":0.02932074, - "S":0.28996, - "T":0.1299922, - "V":0.01460187, - "W":0.001085813, - "Y":0.04020457 - }, - "P":{ - "Q":0.03597839, - "R":0.03135791, - "S":0.1177049, - "T":0.05093139, - "V":0.02342947, - "W":0.002104766, - "Y":0.007998193000000001 - }, - "Q":{ - "R":0.140086, - "S":0.07506641, - "T":0.05493632, - "V":0.0224171, - "W":0.003257243, - "Y":0.008430004 - }, - "R":{ - "S":0.08931696, - "T":0.03550112, - "V":0.01873906, - "W":0.01757311, - "Y":0.01412465 - }, - "S":{ - "T":0.2803409, - "V":0.01731717, - "W":0.007907568, - "Y":0.0291351 - }, - "T":{ - "V":0.1032926, - "W":0.001673848, - "Y":0.01077852 - }, - "V":{ - "W":0.005516418, - "Y":0.01165155 - }, - "W":{ - "Y":0.0920111 - } -}; - - - - - - -/** - * @name models.protein.LG.frequencies - * @param {Dictionary} Baseline LG model - * @returns {Dictionary} Updated LG model with empirical frequencies - * @description Define the empirical amino acid frequencies associated with the LG model of protein evolution - */ -lfunction models.protein.LG.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - - {{ 0.07906500000000008} - { 0.012937} - { 0.053052} - { 0.071586} - { 0.042302} - { 0.057337} - { 0.022355} - { 0.062157} - { 0.0646} - { 0.099081} - { 0.022951} - { 0.041977} - { 0.04404} - { 0.040767} - { 0.055941} - { 0.061197} - { 0.053287} - { 0.069147} - { 0.012066} - { 0.034155} - }; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -/* Define a dictionary of amino-acid exchangeability rates for the LG model of protein evolution. */ -models.protein.LG.Rij = { - "A":{ - "C":0.03522956, - "D":0.0229346, - "E":0.08133689, - "F":0.01174132, - "G":0.1296008, - "H":0.008776704999999999, - "I":0.01018879, - "K":0.03791848, - "L":0.04285406, - "M":0.02822381, - "N":0.01271276, - "P":0.05674114, - "Q":0.04325807, - "R":0.02601647, - "S":0.3164948, - "T":0.1247291, - "V":0.1927457, - "W":0.002385593, - "Y":0.008181845 - }, - "C":{ - "D":0.003630821, - "E":0.0002740351, - "F":0.05115122, - "G":0.03570948, - "H":0.01566596, - "I":0.0218034, - "K":0.0009375764, - "L":0.06438966, - "M":0.02243974, - "N":0.02428347, - "P":0.003632027, - "Q":0.003782507, - "R":0.0327155, - "S":0.1864267, - "T":0.06666287, - "V":0.1482198, - "W":0.00884617, - "Y":0.04355245 - }, - "D":{ - "E":0.41069, - "F":0.0008060157, - "G":0.05300146, - "H":0.02267472, - "I":0.0007269456, - "K":0.01999816, - "L":0.00163422, - "M":0.0006414941, - "N":0.2331202, - "P":0.01900553, - "Q":0.02334345, - "R":0.007586211, - "S":0.08303903999999999, - "T":0.02482688, - "V":0.002872194, - "W":0.0003945694, - "Y":0.005048546 - }, - "E":{ - "F":0.0008705765, - "G":0.02188286, - "H":0.01036699, - "I":0.003010126, - "K":0.1277224, - "L":0.007552471, - "M":0.004362376, - "N":0.02487791, - "P":0.02020781, - "Q":0.1841385, - "R":0.02227563, - "S":0.04097288, - "T":0.03524391, - "V":0.01853676, - "W":0.001027702, - "Y":0.004485425 - }, - "F":{ - "G":0.00561965, - "H":0.01668329, - "I":0.0756681, - "K":0.001690408, - "L":0.2810447, - "M":0.04516806, - "N":0.004111401, - "P":0.004551429, - "Q":0.001599162, - "R":0.003226682, - "S":0.02422454, - "T":0.009619268, - "V":0.04952661, - "W":0.03243575, - "Y":0.2916085 - }, - "G":{ - "H":0.007618063, - "I":0.0005919608, - "K":0.02096479, - "L":0.00479784, - "M":0.003503711, - "N":0.06602329999999999, - "P":0.009489902, - "Q":0.01195119, - "R":0.02388046, - "S":0.116496, - "T":0.00756921, - "V":0.005802412, - "W":0.003544273, - "Y":0.002043191 - }, - "H":{ - "I":0.007404237, - "K":0.04927923, - "L":0.03970833, - "M":0.01111019, - "N":0.207085, - "P":0.02451727, - "Q":0.2146863, - "R":0.1485124, - "S":0.06628340000000001, - "T":0.03406144, - "V":0.009003304, - "W":0.007881539999999999, - "Y":0.1983005 - }, - "I":{ - "K":0.01124222, - "L":0.4493203, - "M":0.1073075, - "N":0.008794702, - "P":0.003771706, - "Q":0.003249348, - "R":0.007772081, - "S":0.004291965, - "T":0.06026516, - "V":0.04910478, - "W":0.001473992, - "Y":0.008688692 - }, - "K":{ - "L":0.01490483, - "M":0.01648691, - "N":0.09851189, - "P":0.01880635, - "Q":0.1442522, - "R":0.3871668, - "S":0.05012591, - "T":0.06627711, - "V":0.01401048, - "W":0.0006587949, - "Y":0.004929905 - }, - "L":{ - "M":0.1584993, - "N":0.003142484, - "P":0.01200011, - "Q":0.02597806, - "R":0.01847365, - "S":0.0122045, - "T":0.01766063, - "V":0.1288122, - "W":0.008179586000000001, - "Y":0.01119695 - }, - "M":{ - "N":0.01703821, - "P":0.004810887, - "Q":0.07459796, - "R":0.02962982, - "S":0.0232297, - "T":0.1177837, - "V":0.1436375, - "W":0.009190009000000001, - "Y":0.01798497 - }, - "N":{ - "P":0.007795161, - "Q":0.07563193999999999, - "R":0.04601631, - "S":0.268368, - "T":0.116636, - "V":0.006330976, - "W":0.0005989957, - "Y":0.02286955 - }, - "P":{ - "Q":0.02784403, - "R":0.02035162, - "S":0.08959077, - "T":0.03331558, - "V":0.02243022, - "W":0.001255797, - "Y":0.00334857 - }, - "Q":{ - "R":0.1718491, - "S":0.08193787, - "T":0.06297003, - "V":0.01591156, - "W":0.003117996, - "Y":0.009615879000000001 - }, - "R":{ - "S":0.05745502, - "T":0.03375392, - "V":0.01292756, - "W":0.007836037000000001, - "Y":0.01174968 - }, - "S":{ - "T":0.3773224, - "V":0.00744159, - "W":0.003285156, - "Y":0.01496724 - }, - "T":{ - "V":0.1655336, - "W":0.00185899, - "Y":0.009186346 - }, - "V":{ - "W":0.002501667, - "Y":0.009316084000000001 - }, - "W":{ - "Y":0.1177739 - } -}; -//==================================================================================================================// - - - - /** * @name models.protein.JTT.frequencies @@ -1649,1983 +976,6 @@ models.protein.JTT.Rij = { -/** - * @name models.protein.JC69.frequencies - * @param {Dictionary} Baseline JC69 model - * @returns {Dictionary} Updated JC69 model with empirical frequencies - * @description Define the empirical amino acid frequencies associated with the JC69 model of protein evolution - */ -lfunction models.protein.JC69.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - { 0.05} - }; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -/* Define a dictionary of equal amino-acid exchangeability rates for the JC69 model of protein evolution. */ -models.protein.JC69.Rij = { - "A": - {"C":0.05, - "D":0.05, - "E":0.05, - "F":0.05, - "G":0.05, - "H":0.05, - "I":0.05, - "K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "C": - {"D":0.05, - "E":0.05, - "F":0.05, - "G":0.05, - "H":0.05, - "I":0.05, - "K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "D": - {"E":0.05, - "F":0.05, - "G":0.05, - "H":0.05, - "I":0.05, - "K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "E": - {"F":0.05, - "G":0.05, - "H":0.05, - "I":0.05, - "K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "F": - {"G":0.05, - "H":0.05, - "I":0.05, - "K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "G": - {"H":0.05, - "I":0.05, - "K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "H": - {"I":0.05, - "K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "I": - {"K":0.05, - "L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":30.05, - "W":0.05, - "Y":0.05}, - "K": - {"L":0.05, - "M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "L": - {"M":0.05, - "N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "M": - {"N":0.05, - "P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "N": - {"P":0.05, - "Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "P": - {"Q":0.05, - "R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "Q": - {"R":0.05, - "S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "R": - {"S":0.05, - "T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "S": - {"T":0.05, - "V":0.05, - "W":0.05, - "Y":0.05}, - "T": - {"V":0.05, - "W":0.05, - "Y":0.05}, - "V": - {"W":0.05, - "Y":0.05}, - "W": - {"Y":0.05} -}; - - - -//==================================================================================================================// - - - -/** - * @name models.protein.mtMAM.frequencies - * @param {Dictionary} Baseline mtMAM model - * @returns {Dictionary} Updated mtMAM model with empirical frequencies - * @description Define the empirical amino acid frequencies associated with the mtMAM model of protein evolution - */ -lfunction models.protein.mtMAM.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.0692} - { 0.0065} - { 0.0186} - { 0.0236} - { 0.0611} - { 0.0557} - { 0.0277} - { 0.0905} - { 0.0221} - { 0.1675} - { 0.0561} - { 0.04} - { 0.0536} - { 0.0238} - { 0.0184} - { 0.0725} - { 0.087} - { 0.0428} - { 0.0293} - { 0.034} - }; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -/* Define a dictionary of equal amino-acid exchangeability rates for the mtMAM model of protein evolution. */ -models.protein.mtMAM.Rij = { - "A": - {"C": 0.0, - "D": 0.11, - "E": 0.0, - "F": 0.0, - "G": 0.78, - "H": 0.08, - "I": 0.75, - "K": 0.0, - "L": 0.21, - "M": 0.76, - "N": 0.02, - "P": 0.53, - "Q": 0.0, - "R": 0.32, - "S": 3.42, - "T": 6.81, - "V": 3.98, - "W": 0.05, - "Y": 0.0}, - "C": - {"D": 0.0, - "E": 0.0, - "F": 0.07, - "G": 0.0, - "H": 3.05, - "I": 0.41, - "K": 0.0, - "L": 0.27, - "M": 0.0, - "N": 0.0, - "P": 0.0, - "Q": 0.0, - "R": 1.86, - "S": 3.47, - "T": 1.14, - "V": 0.0, - "W": 0.65, - "Y": 5.3}, - "D": - {"E": 5.69, - "F": 0.05, - "G": 0.79, - "H": 0.11, - "I": 0.0, - "K": 0.0, - "L": 0.0, - "M": 0.0, - "N": 8.64, - "P": 0.02, - "Q": 0.49, - "R": 0.0, - "S": 0.16, - "T": 0.0, - "V": 0.1, - "W": 0.0, - "Y": 0.0}, - "E": - {"F": 0.0, - "G": 0.22, - "H": 0.22, - "I": 0.0, - "K": 2.15, - "L": 0.0, - "M": 0.0, - "N": 0.0, - "P": 0.0, - "Q": 2.74, - "R": 0.0, - "S": 0.21, - "T": 0.04, - "V": 0.2, - "W": 0.0, - "Y": 0.0}, - "F": - {"G": 0.0, - "H": 0.0, - "I": 0.57, - "K": 0.0, - "L": 2.46, - "M": 0.11, - "N": 0.06, - "P": 0.17, - "Q": 0.0, - "R": 0.0, - "S": 0.9, - "T": 0.08, - "V": 0.06, - "W": 0.0, - "Y": 6.82}, - "G": - {"H": 0.0, - "I": 0.0, - "K": 0.0, - "L": 0.0, - "M": 0.0, - "N": 0.47, - "P": 0.0, - "Q": 0.0, - "R": 0.18, - "S": 1.12, - "T": 0.0, - "V": 0.05, - "W": 0.0, - "Y": 0.01}, - "H": - {"I": 0.0, - "K": 0.0, - "L": 0.26, - "M": 0.0, - "N": 4.58, - "P": 0.53, - "Q": 5.5, - "R": 2.32, - "S": 0.2, - "T": 0.01, - "V": 0.0, - "W": 0.0, - "Y": 15.25}, - "I": - {"K": 0.06, - "L": 2.32, - "M": 3.78, - "N": 0.19, - "P": 0.05, - "Q": 0.0, - "R": 0.0, - "S": 0.0, - "T": 3.6, - "V": 22.2, - "W": 0.0, - "Y": 0.16}, - "K": {"L": 0.04, - "M": 0.59, - "N": 4.08, - "P": 0.18, - "Q": 2.42, - "R": 0.5, - "S": 0.65, - "T": 0.5, - "V": 0.0, - "W": 0.0, - "Y": 0.67}, - "L": - {"M": 6.09, - "N": 0.0, - "P": 0.43, - "Q": 0.2, - "R": 0.06, - "S": 0.74, - "T": 0.34, - "V": 1.0, - "W": 0.12, - "Y": 0.25}, - "M": - {"N": 0.21, - "P": 0.0, - "Q": 0.22, - "R": 0.0, - "S": 0.47, - "T": 6.91, - "V": 8.32, - "W": 0.13, - "Y": 0.0}, - "N": - {"P": 0.33, - "Q": 0.08, - "R": 0.04, - "S": 4.46, - "T": 1.1, - "V": 0.0, - "W": 0.06, - "Y": 1.56}, - "P": - {"Q": 0.51, - "R": 0.09, - "S": 2.02, - "T": 0.78, - "V": 0.0, - "W": 0.07, - "Y": 0.08}, - "Q": - {"R": 2.46, - "S": 0.3, - "T": 0.0, - "V": 0.33, - "W": 0.0, - "Y": 0.54}, - "R": - {"S": 0.03, - "T": 0.0, - "V": 0.0, - "W": 0.16, - "Y": 0.0}, - "S": - {"T": 6.14, - "V": 0.0, - "W": 0.17, - "Y": 1.07}, - "T": - {"V": 2.37, - "W": 0.0, - "Y": 0.0}, - "V": - {"W": 0.0, - "Y": 0.0}, - "W": - {"Y": 0.14} -}; - - -lfunction models.protein.HIVWm.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{0.0377494} - {0.0240105} - {0.0342034} - {0.0618606} - {0.0422741} - {0.0838496} - {0.0156076} - {0.0983641} - {0.0641682} - {0.0577867} - {0.0158419} - {0.0891129} - {0.0458601} - {0.0437824} - {0.057321} - {0.0550846} - {0.0813774} - {0.0515639} - {0.019597} - {0.0205847}}; - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -models.protein.HIVWm.Rij = { - "A":{ - "C":0.167653, - "D":4.43521, - "E":5.56325, - "F":0.597923, - "G":1.8685, - "H":0.005, - "I":0.005, - "K":0.592784, - "L":0.16024, - "M":0.005, - "N":0.617509, - "P":1.00981, - "Q":0.005, - "R":0.0744808, - "S":8.594200000000001, - "T":24.1422, - "V":24.8094, - "W":0.005, - "Y":0.005 - }, - "C":{ - "D":0.005, - "E":0.005, - "F":0.362959, - "G":0.0489798, - "H":0.005, - "I":0.005, - "K":0.005, - "L":0.005, - "M":0.005, - "N":0.0604932, - "P":0.005, - "Q":0.005, - "R":2.86364, - "S":1.12195, - "T":0.005, - "V":0.005, - "W":5.49894, - "Y":8.34835 - }, - "D":{ - "E":12.1233, - "F":0.005, - "G":10.3969, - "H":2.31779, - "I":0.145124, - "K":0.894313, - "L":0.005, - "M":0.005, - "N":29.4087, - "P":0.005, - "Q":0.005, - "R":0.0674539, - "S":0.427881, - "T":0.630395, - "V":2.91786, - "W":0.005, - "Y":2.28154 - }, - "E":{ - "F":0.005, - "G":14.7801, - "H":0.005, - "I":0.0390512, - "K":23.9626, - "L":0.129839, - "M":0.005, - "N":0.201526, - "P":0.005, - "Q":3.20656, - "R":0.0251632, - "S":0.005, - "T":0.458743, - "V":2.19952, - "W":0.005, - "Y":0.005 - }, - "F":{ - "G":0.005, - "H":0.005, - "I":1.48288, - "K":0.005, - "L":7.48781, - "M":0.005, - "N":0.005, - "P":0.0342252, - "Q":0.005, - "R":0.005, - "S":4.27939, - "T":0.114512, - "V":2.28, - "W":0.005, - "Y":4.12728 - }, - "G":{ - "H":0.005, - "I":0.005, - "K":0.279425, - "L":0.0489798, - "M":0.0489798, - "N":0.0604932, - "P":0.005, - "Q":0.0604932, - "R":13.4379, - "S":6.27966, - "T":0.0489798, - "V":2.79622, - "W":2.8258, - "Y":0.005 - }, - "H":{ - "I":0.005, - "K":0.22406, - "L":1.76382, - "M":0.005, - "N":8.59876, - "P":13.9444, - "Q":18.5465, - "R":6.84405, - "S":0.7251570000000001, - "T":0.95956, - "V":0.827479, - "W":0.005, - "Y":47.4889 - }, - "I":{ - "K":0.817481, - "L":9.102460000000001, - "M":17.3064, - "N":0.987028, - "P":0.005, - "Q":0.0342252, - "R":1.34069, - "S":0.7400910000000001, - "T":9.36345, - "V":24.8231, - "W":0.005, - "Y":0.114512 - }, - "K":{ - "L":0.005, - "M":4.09564, - "N":10.6655, - "P":0.111928, - "Q":13.0705, - "R":39.8897, - "S":0.005, - "T":4.04802, - "V":0.128065, - "W":0.005, - "Y":0.005 - }, - "L":{ - "M":11.3839, - "N":0.005, - "P":9.83095, - "Q":2.89048, - "R":0.586757, - "S":6.14396, - "T":0.005, - "V":2.95344, - "W":1.37031, - "Y":0.005 - }, - "M":{ - "N":0.201526, - "P":0.005, - "Q":0.005, - "R":3.28652, - "S":0.392575, - "T":7.41313, - "V":14.7683, - "W":0.005, - "Y":0.579198 - }, - "N":{ - "P":0.344848, - "Q":0.342068, - "R":0.16024, - "S":14.5699, - "T":4.54206, - "V":0.0744808, - "W":0.005, - "Y":5.06475 - }, - "P":{ - "Q":3.04502, - "R":0.404723, - "S":14.249, - "T":4.33701, - "V":0.005, - "W":0.005, - "Y":0.005 - }, - "Q":{ - "R":10.6746, - "S":0.16024, - "T":0.203091, - "V":0.005, - "W":0.0443298, - "Y":0.005 - }, - "R":{ - "S":8.350239999999999, - "T":0.928203, - "V":0.279425, - "W":5.96564, - "Y":0.005 - }, - "S":{ - "T":6.34079, - "V":0.862637, - "W":1.10156, - "Y":0.933142 - }, - "T":{ - "V":0.005, - "W":0.005, - "Y":0.490608 - }, - "V":{ - "W":0.005, - "Y":1.35482 - }, - "W":{ - "Y":0.005 - } -}; - - -lfunction models.protein.HIVBm.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.060490222} - { 0.020075899} - { 0.042109048} - { 0.071567447} - { 0.028809447} - { 0.072308239} - { 0.022293943} - { 0.069730629} - { 0.056968211} - { 0.098851122} - { 0.019768318} - { 0.044127815} - { 0.046025282} - { 0.053606488} - { 0.066039665} - { 0.05060433} - { 0.053636813} - { 0.061625237} - { 0.033011601} - { 0.028350243}}; - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -models.protein.HIVBm.Rij = { - "A":{ - "C":0.123758, - "D":1.45504, - "E":1.48135, - "F":0.0141269, - "G":2.13536, - "H":0.0847613, - "I":0.005, - "K":0.005, - "L":0.215256, - "M":0.0186643, - "N":0.005, - "P":2.12217, - "Q":0.0551128, - "R":0.307507, - "S":2.46633, - "T":15.9183, - "V":7.61428, - "W":0.005, - "Y":0.005 - }, - "C":{ - "D":0.005, - "E":0.005, - "F":9.29815, - "G":0.897871, - "H":0.240073, - "I":0.005, - "K":0.005, - "L":0.129777, - "M":0.005, - "N":0.08606419999999999, - "P":0.005, - "Q":0.005, - "R":0.351721, - "S":4.69314, - "T":0.739969, - "V":0.420027, - "W":2.63277, - "Y":7.57932 - }, - "D":{ - "E":10.5872, - "F":0.005, - "G":2.83806, - "H":1.9169, - "I":0.0176792, - "K":0.005, - "L":0.008760479999999999, - "M":0.005, - "N":17.6612, - "P":0.0342658, - "Q":0.005, - "R":0.005, - "S":0.52823, - "T":0.274724, - "V":1.04793, - "W":0.005, - "Y":0.6746529999999999 - }, - "E":{ - "F":0.005, - "G":3.92775, - "H":0.11974, - "I":0.00609079, - "K":4.61482, - "L":0.005, - "M":0.175789, - "N":0.07926329999999999, - "P":0.0120226, - "Q":2.5602, - "R":0.0749218, - "S":0.005, - "T":0.289774, - "V":1.02847, - "W":0.005, - "Y":0.07926329999999999 - }, - "F":{ - "G":0.291561, - "H":0.145558, - "I":3.39836, - "K":0.0342658, - "L":8.524839999999999, - "M":0.188025, - "N":0.005, - "P":0.005, - "Q":0.005, - "R":0.005, - "S":0.956472, - "T":0.0141269, - "V":0.723274, - "W":0.8293430000000001, - "Y":15.34 - }, - "G":{ - "H":0.005, - "I":0.005, - "K":0.521705, - "L":0.005, - "M":0.005, - "N":0.323401, - "P":0.005, - "Q":0.0619137, - "R":3.65345, - "S":4.38041, - "T":0.369615, - "V":0.953155, - "W":1.21674, - "Y":0.005 - }, - "H":{ - "I":0.103111, - "K":0.005, - "L":1.74171, - "M":0.005, - "N":7.64585, - "P":2.45318, - "Q":7.05545, - "R":9.04044, - "S":0.382747, - "T":0.7115939999999999, - "V":0.005, - "W":0.06951789999999999, - "Y":18.6943 - }, - "I":{ - "K":0.322319, - "L":5.95879, - "M":11.2065, - "N":0.680565, - "P":0.0410593, - "Q":0.005, - "R":0.677289, - "S":1.21803, - "T":8.612170000000001, - "V":17.7389, - "W":0.005, - "Y":0.148168 - }, - "K":{ - "L":0.0814995, - "M":1.28246, - "N":7.90443, - "P":0.0313862, - "Q":6.54737, - "R":20.45, - "S":0.504111, - "T":4.67142, - "V":0.265829, - "W":0.005, - "Y":0.005 - }, - "L":{ - "M":5.31961, - "N":0.005, - "P":2.07757, - "Q":1.49456, - "R":0.701427, - "S":0.927656, - "T":0.0437673, - "V":1.41036, - "W":0.748843, - "Y":0.111986 - }, - "M":{ - "N":0.005, - "P":0.005, - "Q":0.303676, - "R":2.51394, - "S":0.005, - "T":4.94026, - "V":6.8532, - "W":0.089078, - "Y":0.005 - }, - "N":{ - "P":0.00739578, - "Q":0.672052, - "R":0.295543, - "S":13.1447, - "T":6.88667, - "V":0.026656, - "W":0.005, - "Y":1.76417 - }, - "P":{ - "Q":4.47211, - "R":1.28355, - "S":5.37762, - "T":2.01417, - "V":0.005, - "W":0.0444506, - "Y":0.0304381 - }, - "Q":{ - "R":3.4215, - "S":0.116311, - "T":0.243589, - "V":0.0209153, - "W":0.026656, - "Y":0.113033 - }, - "R":{ - "S":3.4791, - "T":2.86868, - "V":0.0812454, - "W":0.9913380000000001, - "Y":0.00991826 - }, - "S":{ - "T":8.93107, - "V":0.0749218, - "W":0.0248728, - "Y":0.648024 - }, - "T":{ - "V":0.709226, - "W":0.005, - "Y":0.105652 - }, - "V":{ - "W":0.005, - "Y":0.0410593 - }, - "W":{ - "Y":1.28022 - } -}; - -lfunction models.protein.cpREV.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.076} - { 0.009} - { 0.037} - { 0.049} - { 0.051} - { 0.084} - { 0.025} - { 0.081} - { 0.05} - { 0.101} - { 0.022} - { 0.041} - { 0.043} - { 0.038} - { 0.062} - { 0.062} - { 0.054} - { 0.066} - { 0.018} - { 0.031}}; - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -models.protein.cpREV.Rij = { - "A":{ - "C":1.2816975, - "D":0.33527215, - "E":0.95600458, - "F":0.13027718, - "G":1.2740342, - "H":0.1264455, - "I":0.27779692, - "K":0.45213844, - "L":0.37742065, - "M":0.35443056, - "N":0.43489587, - "P":0.93876201, - "Q":0.30078701, - "R":0.20116329, - "S":4.6746517, - "T":2.5672267, - "V":1.8545339, - "W":0.026821772, - "Y":0.10728709 - }, - "C":{ - "D":0.019158408, - "E":0.019158408, - "F":1.3909005, - "G":0.58049978, - "H":0.84488581, - "I":0.53643544, - "K":0.091960361, - "L":0.75867297, - "M":0.30461869, - "N":1.0307224, - "P":0.54601464, - "Q":0.019158408, - "R":1.576737, - "S":4.465825, - "T":1.1035243, - "V":1.1341778, - "W":0.8333907699999999, - "Y":2.8086227 - }, - "D":{ - "E":7.0713686, - "F":0.042148499, - "G":0.8257274, - "H":0.63414332, - "I":0.019158408, - "K":0.78932643, - "L":0.019158408, - "M":0.09004452, - "N":8.4967541, - "P":0.32569294, - "Q":0.7663363399999999, - "R":0.082381156, - "S":1.1303461, - "T":0.50961366, - "V":0.14368806, - "W":0.034485135, - "Y":0.53835128 - }, - "E":{ - "F":0.27779692, - "G":0.72610368, - "H":0.31036622, - "I":0.28354444, - "K":5.0367456, - "L":0.15709895, - "M":0.21649002, - "N":2.0212121, - "P":0.35443056, - "Q":5.9812551, - "R":0.29120781, - "S":1.0881976, - "T":0.70694527, - "V":0.38316817, - "W":0.12069797, - "Y":0.2720494 - }, - "F":{ - "G":0.047896021, - "H":0.24331179, - "I":0.86979174, - "K":0.13794054, - "L":2.4292862, - "M":0.6264799599999999, - "N":0.18583656, - "P":0.082381156, - "Q":0.019158408, - "R":0.10153956, - "S":0.93301449, - "T":0.28354444, - "V":0.60732155, - "W":0.89661351, - "Y":4.5405428 - }, - "G":{ - "H":0.036400976, - "I":0.07663363400000001, - "K":0.50386614, - "L":0.038316817, - "M":0.040232658, - "N":1.2510441, - "P":0.053643544, - "Q":0.25480683, - "R":0.46554933, - "S":1.323846, - "T":0.17625736, - "V":0.17434152, - "W":0.15709895, - "Y":0.019158408 - }, - "H":{ - "I":0.055559384, - "K":0.58433146, - "L":0.1264455, - "M":0.019158408, - "N":2.6917564, - "P":0.29120781, - "Q":2.431202, - "R":1.3698262, - "S":0.58049978, - "T":0.061306907, - "V":0.047896021, - "W":0.13219302, - "Y":3.7761223 - }, - "I":{ - "K":0.66096509, - "L":3.3431423, - "M":3.39487, - "N":0.32186126, - "P":0.22415338, - "Q":0.17625736, - "R":0.26055435, - "S":0.41382162, - "T":1.9924745, - "V":9.190288499999999, - "W":0.080465315, - "Y":0.17050984 - }, - "K":{ - "L":0.4176533, - "M":0.36975728, - "N":4.6554933, - "P":0.57858393, - "Q":6.3471807, - "R":8.586798699999999, - "S":1.6629499, - "T":1.7587419, - "V":0.47704437, - "W":0.019158408, - "Y":0.47321269 - }, - "L":{ - "M":2.588301, - "N":0.21649002, - "P":0.41956914, - "Q":0.54793048, - "R":0.38891569, - "S":0.98857388, - "T":0.29887117, - "V":1.6572023, - "W":0.30461869, - "Y":0.36209392 - }, - "M":{ - "N":0.11686629, - "P":0.19158408, - "Q":0.38699985, - "R":0.23948011, - "S":0.1781732, - "T":1.2357173, - "V":0.9100244, - "W":0.16476231, - "Y":0.41190578 - }, - "N":{ - "P":0.33144047, - "Q":1.4713658, - "R":0.68395518, - "S":3.9945282, - "T":2.6687663, - "V":0.15901479, - "W":0.07663363400000001, - "Y":1.444544 - }, - "P":{ - "Q":0.61881659, - "R":0.16667815, - "S":2.3028407, - "T":0.49811862, - "V":0.23373258, - "W":0.09387620100000001, - "Y":0.18583656 - }, - "Q":{ - "R":3.3431423, - "S":0.75867297, - "T":0.46171764, - "V":0.10345541, - "W":0.10153956, - "Y":0.74909377 - }, - "R":{ - "S":0.73759872, - "T":0.60157402, - "V":0.17625736, - "W":0.44064339, - "Y":0.61881659 - }, - "S":{ - "T":4.1209737, - "V":0.31994542, - "W":0.13985638, - "Y":1.0000689 - }, - "T":{ - "V":1.456039, - "W":0.055559384, - "Y":0.1360247 - }, - "V":{ - "W":0.019158408, - "Y":0.22798506 - }, - "W":{ - "Y":0.66288093 - } -}; - - - -lfunction models.protein.AB.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{6.541704e-02} - {4.708366e-02} - {3.168984e-02} - {4.688141e-02} - {2.150693e-02} - {4.240711e-02} - {2.842211e-02} - {1.005278e-01} - {9.812606e-03} - {3.424424e-02} - {6.222565e-02} - {4.844488e-02} - {1.760370e-02} - {3.478555e-02} - {3.962469e-02} - {1.280566e-01} - {8.199314e-02} - {3.393045e-02} - {7.586119e-02} - {4.948141e-02}}; - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -models.protein.AB.Rij = { - "A":{ - "C":0.1784266, - "D":0.09291290000000001, - "E":1.241095, - "F":0.008929181, - "G":0.1992269, - "H":0.9521821, - "I":1.851951, - "K":5.241316, - "L":0.1140412, - "M":0.06969101, - "N":0.07388355000000001, - "P":0.06299270999999999, - "Q":0.1130146, - "R":1.800713, - "S":0.9988358000000001, - "T":2.912317, - "V":0.07939549, - "W":0.1433528, - "Y":3.774477 - }, - "C":{ - "D":0.782913, - "E":0.05795374, - "F":0.1821885, - "G":1.923901, - "H":0.06273863, - "I":1.0894, - "K":10.4955, - "L":0.3245175, - "M":0.3932002, - "N":7.54924, - "P":0.3362326, - "Q":0.08208677, - "R":0.3498713, - "S":1.926435, - "T":1.135258, - "V":0.5724286, - "W":0.1711315, - "Y":0.1366145 - }, - "D":{ - "E":7.185182, - "F":1.374268e-06, - "G":0.08705989, - "H":0.5038373, - "I":0.4868901, - "K":14.05444, - "L":1.762721, - "M":0.02769442, - "N":6.190318, - "P":0.03972173, - "Q":0.1955446, - "R":0.007342554, - "S":7.348346, - "T":2.147175, - "V":0.0007310937, - "W":2.622763, - "Y":0.04931206 - }, - "E":{ - "F":0.02340019, - "G":0.1843856, - "H":7.426619, - "I":2.1124, - "K":11.26995, - "L":0.03916999, - "M":0.03020502, - "N":0.06622772, - "P":0.03357577, - "Q":0.1031734, - "R":0.1509482, - "S":0.5822988, - "T":0.1516881, - "V":0.01423897, - "W":0.9078338, - "Y":0.4076074 - }, - "F":{ - "G":1.046446e-08, - "H":7.519215e-11, - "I":0.05891123, - "K":3.963388, - "L":0.0006594967, - "M":0.006079219, - "N":3.722878e-16, - "P":0.007213178, - "Q":0.1993818, - "R":0.004878395, - "S":0.2639482, - "T":3.225214e-06, - "V":0.4440833, - "W":0.7741612, - "Y":0.02243512 - }, - "G":{ - "H":3.691671, - "I":0.0551634, - "K":8.908434, - "L":6.712736e-06, - "M":0.6802781, - "N":3.030805, - "P":0.001233336, - "Q":0.00149661, - "R":0.7426909, - "S":0.0005906405, - "T":0.1202094, - "V":4.332983e-05, - "W":0.02737091, - "Y":0.009047737 - }, - "H":{ - "I":1.38937, - "K":7.29808, - "L":0.0001029959, - "M":0.001283121, - "N":3.608816, - "P":0.07659566, - "Q":0.05288625, - "R":0.02889815, - "S":0.06776709, - "T":0.06016624, - "V":0.02252612, - "W":0.1240642, - "Y":0.5795409 - }, - "I":{ - "K":9.139518000000001, - "L":0.03560482, - "M":0.02157936, - "N":0.055044, - "P":0.02187264, - "Q":0.1984772, - "R":0.07915055999999999, - "S":0.9984215, - "T":0.07862767, - "V":0.1386853, - "W":0.2295842, - "Y":0.42282 - }, - "K":{ - "L":4.706586, - "M":5.879103, - "N":1.455741, - "P":2.298295, - "Q":5.642309, - "R":10.49496, - "S":5.439116, - "T":3.443285, - "V":7.01389, - "W":20.55414, - "Y":6.890244 - }, - "L":{ - "M":1.601123, - "N":0.5059793, - "P":10.96748, - "Q":2.714705, - "R":0.05016568, - "S":0.6007607, - "T":3.087152, - "V":0.06318748, - "W":0.2903165, - "Y":7.926675 - }, - "M":{ - "N":0.02158451, - "P":5.647985, - "Q":3.390618, - "R":1.149931, - "S":0.1580539, - "T":0.5702792, - "V":0.3378544, - "W":0.152132, - "Y":3.59531 - }, - "N":{ - "P":1.238634, - "Q":0.004649035, - "R":0.009948993999999999, - "S":0.08688405, - "T":1.039298, - "V":0.008024263, - "W":0.07109973, - "Y":0.0349344 - }, - "P":{ - "Q":3.94794, - "R":0.07417279, - "S":0.01861354, - "T":1.415612, - "V":0.1011149, - "W":0.002246759, - "Y":4.39672 - }, - "Q":{ - "R":0.3556198, - "S":0.9813064, - "T":0.03674486, - "V":0.2199856, - "W":7.074464, - "Y":1.643946 - }, - "R":{ - "S":1.284651, - "T":0.9057112, - "V":0.005516074, - "W":0.1992133, - "Y":0.2217442 - }, - "S":{ - "T":3.058575, - "V":0.1385142, - "W":0.8104751, - "Y":0.07477041 - }, - "T":{ - "V":0.01412361, - "W":0.09984255, - "Y":0.2166054 - }, - "V":{ - "W":0.6121284, - "Y":0.09663569 - }, - "W":{ - "Y":0.5010635 - } -}; - - - - -lfunction models.protein.mtMet.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{0.0437932} - { 0.0113305} - { 0.016899} - { 0.0225385} - { 0.088448} - { 0.0470501} - { 0.0171837} - { 0.0897794} - { 0.0399135} - { 0.155226} - { 0.0674443} - { 0.0570013} - { 0.0375282} - { 0.0180181} - { 0.0129578} - { 0.0937522} - { 0.063579} - { 0.0533174} - { 0.0226713} - { 0.0415682}}; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -models.protein.mtMet.Rij = { -'A': {'C': 0.63325584800000001, - 'D': 0.11915685500000001, - 'E': 0.17916388799999999, - 'F': 0.062762255000000003, - 'G': 1.4658622800000001, - 'H': 0.030192130000000001, - 'I': 0.367600449, - 'K': 0.020509507999999999, - 'L': 0.109872766, - 'M': 0.65336399300000003, - 'N': 0.03289392, - 'P': 0.40807705300000002, - 'Q': 0.052454947000000002, - 'R': 0.058078194999999999, - 'S': 2.7716860149999998, - 'T': 6.7308851599999997, - 'V': 2.815163085, - 'W': 0.013623415999999999, - 'Y': 0.014501406999999999}, - 'C': {'D': 0.077419373999999999, - 'E': 0.050609064000000002, - 'F': 0.92581086400000001, - 'G': 0.91412559000000004, - 'H': 0.60383390000000003, - 'I': 0.235804245, - 'K': 0.015753762000000001, - 'L': 0.29951899700000001, - 'M': 0.49234014399999998, - 'N': 0.29328103, - 'P': 0.029408410999999999, - 'Q': 0.15259520800000001, - 'R': 0.73981385700000002, - 'S': 3.2830148709999998, - 'T': 0.33866819599999998, - 'V': 1.3945280440000001, - 'W': 1.018410485, - 'Y': 1.967371255}, - 'D': {'E': 6.0337889819999999, - 'F': 0.012560742999999999, - 'G': 0.63075329899999999, - 'H': 0.47979111200000002, - 'I': 0.010668856000000001, - 'K': 0.049007455999999998, - 'L': 0.0055291439999999997, - 'M': 0.026109947000000001, - 'N': 4.6584200710000001, - 'P': 0.044609562999999998, - 'Q': 0.13135570199999999, - 'R': 0.049700411999999999, - 'S': 0.36080478100000002, - 'T': 0.102136221, - 'V': 0.084589028999999996, - 'W': 0.040920527999999998, - 'Y': 0.16028995800000001}, - 'E': {'F': 0.017716308, - 'G': 0.76885329499999999, - 'H': 0.105414735, - 'I': 0.014004526, - 'K': 1.3792177830000001, - 'L': 0.019157619000000001, - 'M': 0.128410054, - 'N': 0.81224112400000004, - 'P': 0.048786298999999998, - 'Q': 2.2366176229999999, - 'R': 0.080835481000000001, - 'S': 0.36310446600000001, - 'T': 0.13480267100000001, - 'V': 0.227827051, - 'W': 0.086028795000000005, - 'Y': 0.093214721}, - 'F': {'G': 0.068139280999999996, - 'H': 0.090353066999999995, - 'I': 0.75090054100000003, - 'K': 0.097125533999999999, - 'L': 1.811101233, - 'M': 0.74842499699999998, - 'N': 0.13875929100000001, - 'P': 0.054271888999999997, - 'Q': 0.026306324999999998, - 'R': 0.0080439580000000004, - 'S': 0.49934990099999998, - 'T': 0.053947742999999999, - 'V': 0.46624344200000001, - 'W': 0.330781928, - 'Y': 3.2090833029999999}, - 'G': {'H': 0.025252655999999998, - 'I': 0.013781055, - 'K': 0.13418717499999999, - 'L': 0.027264554, - 'M': 0.14533146599999999, - 'N': 0.54375075699999997, - 'P': 0.005914206, - 'Q': 0.072395535999999996, - 'R': 0.21996712400000001, - 'S': 1.746570145, - 'T': 0.02455829, - 'V': 0.41714895400000002, - 'W': 0.233963371, - 'Y': 0.046746340999999997}, - 'H': {'I': 0.017140138999999999, - 'K': 0.13515366300000001, - 'L': 0.11163893699999999, - 'M': 0.032834314000000003, - 'N': 1.7386796440000001, - 'P': 0.51995437499999997, - 'Q': 4.5184508909999996, - 'R': 1.5222568649999999, - 'S': 0.29758608399999997, - 'T': 0.221010609, - 'V': 0.0035110079999999999, - 'W': 0.037480926999999997, - 'Y': 3.9079185509999999}, - 'I': {'K': 0.064936611000000005, - 'L': 1.8979743680000001, - 'M': 2.9183532080000001, - 'N': 0.244934765, - 'P': 0.024850021, - 'Q': 0.0088756860000000007, - 'R': 0.012428576, - 'S': 0.096272864, - 'T': 2.4534581430000002, - 'V': 10.953425842, - 'W': 0.028656797000000001, - 'Y': 0.135319461}, - 'K': {'L': 0.06132452, - 'M': 0.65931076, - 'N': 2.53039843, - 'P': 0.121234921, - 'Q': 1.8272181860000001, - 'R': 1.057185633, - 'S': 0.69508812799999997, - 'T': 0.39385170400000002, - 'V': 0.055461435000000003, - 'W': 0.073508962999999997, - 'Y': 0.281699174}, - 'L': {'M': 3.4255537089999999, - 'N': 0.046318944000000001, - 'P': 0.27026078100000001, - 'Q': 0.25445246700000002, - 'R': 0.058180015000000002, - 'S': 0.31152513100000001, - 'T': 0.253366704, - 'V': 0.95827374300000001, - 'W': 0.25324301300000002, - 'Y': 0.123555332}, - 'M': {'N': 0.39982772300000002, - 'P': 0.032714699, - 'Q': 0.237094366, - 'R': 0.013494034, - 'S': 0.45873409599999998, - 'T': 3.0352157260000001, - 'V': 2.5624848949999999, - 'W': 0.167575318, - 'Y': 0.31659903099999998}, - 'N': {'P': 0.080313958000000005, - 'Q': 0.83279153299999997, - 'R': 0.14136427500000001, - 'S': 2.6343785139999998, - 'T': 0.96128509299999998, - 'V': 0.051741626999999998, - 'W': 0.049019408, - 'Y': 1.020785491}, - 'P': {'Q': 0.84951243499999995, - 'R': 0.15500856599999999, - 'S': 1.231180819, - 'T': 0.73460491000000006, - 'V': 0.054078532999999998, - 'W': 0.029433866, - 'Y': 0.054012182999999998}, - 'Q': {'R': 2.6731080889999999, - 'S': 0.38480028399999999, - 'T': 0.274195947, - 'V': 0.027669233000000001, - 'W': 0.12314062000000001, - 'Y': 0.319105788}, - 'R': {'S': 0.19737918500000001, - 'T': 0.056079812999999999, - 'V': 0.041063684000000003, - 'W': 0.37081989199999998, - 'Y': 0.12751933200000001}, - 'S': {'T': 3.1147429070000001, - 'V': 0.26710946499999999, - 'W': 0.16921202900000001, - 'Y': 0.37418428599999998}, - 'T': {'V': 1.5140596740000001, 'W': 0.014378616, 'Y': 0.091031787000000003}, - 'V': {'W': 0.093136256000000001, 'Y': 0.069964540000000006}, - 'W': {'Y': 0.48104431600000003}, - 'Y': {}}; - - - - lfunction models.protein.mtVer.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.0706288} - { 0.00674192} - { 0.014849} - { 0.0214826} - { 0.0495703} - { 0.0440199} - { 0.0241895} - { 0.0908219} - { 0.0273258} - { 0.172674} - { 0.0563431} - { 0.0455021} - { 0.0542482} - { 0.026439} - { 0.0138991} - { 0.0746629} - { 0.109035} - { 0.0456223} - { 0.0254891} - { 0.0264554}}; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -models.protein.mtVer.Rij = { -'A': {'C': 0.25818787799999998, - 'D': 0.15029704599999999, - 'E': 0.18789077500000001, - 'F': 0.069418424000000006, - 'G': 1.1131450629999999, - 'H': 0.027049021999999999, - 'I': 0.419106653, - 'K': 0.020710955999999999, - 'L': 0.084964207, - 'M': 0.77609134000000002, - 'N': 0.031831916000000002, - 'P': 0.285706397, - 'Q': 0.027354705, - 'R': 0.061426074999999997, - 'S': 2.5390917019999999, - 'T': 5.4577877580000003, - 'V': 3.1769759639999999, - 'W': 0.0083503050000000006, - 'Y': 0.013142627}, - 'C': {'D': 0.124361236, - 'E': 0.030812587999999998, - 'F': 1.0711043739999999, - 'G': 0.91074352700000005, - 'H': 1.4477151909999999, - 'I': 0.074268457999999996, - 'K': 0.018885124999999999, - 'L': 0.182360515, - 'M': 0.081020095, - 'N': 0.306981436, - 'P': 0.023520451000000001, - 'Q': 0.14052806900000001, - 'R': 1.1703635489999999, - 'S': 3.378191969, - 'T': 0.16280080499999999, - 'V': 0.37789383399999998, - 'W': 1.764289698, - 'Y': 5.1296218290000004}, - 'D': {'E': 6.6340898380000004, - 'F': 0.0053709409999999997, - 'G': 0.96189642399999997, - 'H': 0.80546838200000004, - 'I': 0.00267315, - 'K': 0.020452689999999999, - 'L': 0.002808236, - 'M': 0.0061562730000000003, - 'N': 8.5772524780000001, - 'P': 0.032172065, - 'Q': 0.084904706999999996, - 'R': 0.063019188000000004, - 'S': 0.376137787, - 'T': 0.088772981000000001, - 'V': 0.123720116, - 'W': 0.024653916000000001, - 'Y': 0.174581453}, - 'E': {'F': 0.0015694050000000001, - 'G': 1.1518345080000001, - 'H': 0.081983093000000007, - 'I': 0.0014573329999999999, - 'K': 2.1130123909999998, - 'L': 0.0091256640000000003, - 'M': 0.059893587999999998, - 'N': 0.33988321399999999, - 'P': 0.023665106000000002, - 'Q': 2.0606641699999999, - 'R': 0.088305718000000005, - 'S': 0.10479923300000001, - 'T': 0.097890385999999996, - 'V': 0.21560053300000001, - 'W': 0.062084663999999998, - 'Y': 0.039546236999999998}, - 'F': {'G': 0.015417345000000001, - 'H': 0.183163356, - 'I': 0.51655272600000002, - 'K': 0.010488183, - 'L': 2.390574145, - 'M': 0.14710124199999999, - 'N': 0.011832201000000001, - 'P': 0.068701822999999995, - 'Q': 0.010980482999999999, - 'R': 0.0023262299999999999, - 'S': 0.86939155099999998, - 'T': 0.064760754000000004, - 'V': 0.344319078, - 'W': 0.095489234000000006, - 'Y': 4.0716517750000003}, - 'G': {'H': 0.01280823, - 'I': 0.0029803109999999998, - 'K': 0.110065675, - 'L': 0.0068902700000000004, - 'M': 0.034003938999999997, - 'N': 0.57376472700000003, - 'P': 0.0015888219999999999, - 'Q': 0.041354439, - 'R': 0.28893165700000001, - 'S': 1.2383013140000001, - 'T': 0.0076788230000000004, - 'V': 0.44479428599999998, - 'W': 0.253335423, - 'Y': 0.020949592999999999}, - 'H': {'I': 0.021069514000000001, - 'K': 0.18206825300000001, - 'L': 0.147175841, - 'M': 0.025326733000000001, - 'N': 2.4725012689999999, - 'P': 0.67394944099999998, - 'Q': 4.324671886, - 'R': 2.1220078999999998, - 'S': 0.450133322, - 'T': 0.15115773399999999, - 'V': 0.0026957690000000002, - 'W': 0.033143636999999997, - 'Y': 9.0196159490000003}, - 'I': {'K': 0.0068528080000000002, - 'L': 1.4138880599999999, - 'M': 2.7358049100000001, - 'N': 0.12218513, - 'P': 0.01898617, - 'Q': 0.0048459089999999998, - 'R': 0.001696908, - 'S': 0.042952525999999998, - 'T': 2.411521891, - 'V': 13.419120277999999, - 'W': 0.0019286209999999999, - 'Y': 0.047323608000000003}, - 'K': {'L': 0.021134276, - 'M': 0.43579328000000001, - 'N': 2.4877313349999999, - 'P': 0.152366262, - 'Q': 2.0310412649999998, - 'R': 0.43113726800000002, - 'S': 0.19358335300000001, - 'T': 0.40837230699999999, - 'V': 0.026318790000000002, - 'W': 0.031311763999999999, - 'Y': 0.071183277000000003}, - 'L': {'M': 3.1559412529999999, - 'N': 0.0051845299999999997, - 'P': 0.35795371599999998, - 'Q': 0.25314762299999999, - 'R': 0.078245354000000003, - 'S': 0.43506549900000002, - 'T': 0.18136720100000001, - 'V': 0.86760021799999998, - 'W': 0.188124443, - 'Y': 0.106687168}, - 'M': {'N': 0.038343725000000002, - 'P': 0.031301259999999997, - 'Q': 0.124183971, - 'R': 0.002391939, - 'S': 0.14830564900000001, - 'T': 3.6958740290000001, - 'V': 4.3789212879999999, - 'W': 0.059361128999999999, - 'Y': 0.079180591999999994}, - 'N': {'P': 0.039069406000000001, - 'Q': 0.41657637800000002, - 'R': 0.14905785299999999, - 'S': 3.7778476159999999, - 'T': 0.86602816100000002, - 'V': 0.013012894000000001, - 'W': 0.0075280260000000002, - 'Y': 0.85544403400000002}, - 'P': {'Q': 0.91506864899999996, - 'R': 0.22110640300000001, - 'S': 1.922238895, - 'T': 0.576413595, - 'V': 0.025284157000000002, - 'W': 0.019550695, - 'Y': 0.072344704999999995}, - 'Q': {'R': 3.1337568619999998, - 'S': 0.25667158400000001, - 'T': 0.11897651200000001, - 'V': 0.0092985359999999996, - 'W': 0.12273951399999999, - 'Y': 0.24379326000000001}, - 'R': {'S': 0.127840652, - 'T': 0.028428747000000001, - 'V': 0.034013496999999997, - 'W': 0.54428200400000004, - 'Y': 0.145341785}, - 'S': {'T': 2.9085797630000001, - 'V': 0.058827342999999997, - 'W': 0.141663396, - 'Y': 0.53309474999999995}, - 'T': {'V': 1.341486679, 'W': 0.003372908, 'Y': 0.086650158000000005}, - 'V': {'W': 0.045879218999999999, 'Y': 0.027607482999999999}, - 'W': {'Y': 0.29464986999999998}, - 'Y': {}}; diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrices/HIV.ibf b/res/TemplateBatchFiles/libv3/models/protein/matrices/HIV.ibf new file mode 100644 index 000000000..1eba92dbb --- /dev/null +++ b/res/TemplateBatchFiles/libv3/models/protein/matrices/HIV.ibf @@ -0,0 +1,631 @@ +/********* HIVm MODELS (within/between) OF PROTEIN EVOLUTION ************/ +LoadFunctionLibrary("../empirical.bf"); +LoadFunctionLibrary("../../protein.bf"); +LoadFunctionLibrary("../../parameters.bf"); +LoadFunctionLibrary("../../frequencies.bf"); +LoadFunctionLibrary("../../../UtilityFunctions.bf"); +LoadFunctionLibrary("../../../all-terms.bf"); + + + +/**************************************** HIVBm functions *************************************/ + + +/** + * @name models.protein.HIVBm.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVBm model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVBm.ModelDescription(type) { + models.protein.HIVBm.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.HIVBm.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.HIVBm.Rij; + models.protein.HIVBm.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.HIVBm.frequencies"; + return models.protein.HIVBm.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVBmF.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVBm+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVBmF.ModelDescription(type) { + models.protein.HIVBmF.ModelDescription.model_definition = models.protein.HIVBm.ModelDescription(type); + models.protein.HIVBmF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.HIVBmF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.HIVBmF.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVBmML.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVBm+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVBmML.ModelDescription(type) { + models.protein.HIVBmML.ModelDescription.model_definition = models.protein.HIVBm.ModelDescription(type); + models.protein.HIVBmML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.HIVBmML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.HIVBmML.ModelDescription.model_definition; +} + + + + +models.protein.HIVBm.Rij = { + "A":{ + "C":0.123758, + "D":1.45504, + "E":1.48135, + "F":0.0141269, + "G":2.13536, + "H":0.0847613, + "I":0.005, + "K":0.005, + "L":0.215256, + "M":0.0186643, + "N":0.005, + "P":2.12217, + "Q":0.0551128, + "R":0.307507, + "S":2.46633, + "T":15.9183, + "V":7.61428, + "W":0.005, + "Y":0.005 + }, + "C":{ + "D":0.005, + "E":0.005, + "F":9.29815, + "G":0.897871, + "H":0.240073, + "I":0.005, + "K":0.005, + "L":0.129777, + "M":0.005, + "N":0.08606419999999999, + "P":0.005, + "Q":0.005, + "R":0.351721, + "S":4.69314, + "T":0.739969, + "V":0.420027, + "W":2.63277, + "Y":7.57932 + }, + "D":{ + "E":10.5872, + "F":0.005, + "G":2.83806, + "H":1.9169, + "I":0.0176792, + "K":0.005, + "L":0.008760479999999999, + "M":0.005, + "N":17.6612, + "P":0.0342658, + "Q":0.005, + "R":0.005, + "S":0.52823, + "T":0.274724, + "V":1.04793, + "W":0.005, + "Y":0.6746529999999999 + }, + "E":{ + "F":0.005, + "G":3.92775, + "H":0.11974, + "I":0.00609079, + "K":4.61482, + "L":0.005, + "M":0.175789, + "N":0.07926329999999999, + "P":0.0120226, + "Q":2.5602, + "R":0.0749218, + "S":0.005, + "T":0.289774, + "V":1.02847, + "W":0.005, + "Y":0.07926329999999999 + }, + "F":{ + "G":0.291561, + "H":0.145558, + "I":3.39836, + "K":0.0342658, + "L":8.524839999999999, + "M":0.188025, + "N":0.005, + "P":0.005, + "Q":0.005, + "R":0.005, + "S":0.956472, + "T":0.0141269, + "V":0.723274, + "W":0.8293430000000001, + "Y":15.34 + }, + "G":{ + "H":0.005, + "I":0.005, + "K":0.521705, + "L":0.005, + "M":0.005, + "N":0.323401, + "P":0.005, + "Q":0.0619137, + "R":3.65345, + "S":4.38041, + "T":0.369615, + "V":0.953155, + "W":1.21674, + "Y":0.005 + }, + "H":{ + "I":0.103111, + "K":0.005, + "L":1.74171, + "M":0.005, + "N":7.64585, + "P":2.45318, + "Q":7.05545, + "R":9.04044, + "S":0.382747, + "T":0.7115939999999999, + "V":0.005, + "W":0.06951789999999999, + "Y":18.6943 + }, + "I":{ + "K":0.322319, + "L":5.95879, + "M":11.2065, + "N":0.680565, + "P":0.0410593, + "Q":0.005, + "R":0.677289, + "S":1.21803, + "T":8.612170000000001, + "V":17.7389, + "W":0.005, + "Y":0.148168 + }, + "K":{ + "L":0.0814995, + "M":1.28246, + "N":7.90443, + "P":0.0313862, + "Q":6.54737, + "R":20.45, + "S":0.504111, + "T":4.67142, + "V":0.265829, + "W":0.005, + "Y":0.005 + }, + "L":{ + "M":5.31961, + "N":0.005, + "P":2.07757, + "Q":1.49456, + "R":0.701427, + "S":0.927656, + "T":0.0437673, + "V":1.41036, + "W":0.748843, + "Y":0.111986 + }, + "M":{ + "N":0.005, + "P":0.005, + "Q":0.303676, + "R":2.51394, + "S":0.005, + "T":4.94026, + "V":6.8532, + "W":0.089078, + "Y":0.005 + }, + "N":{ + "P":0.00739578, + "Q":0.672052, + "R":0.295543, + "S":13.1447, + "T":6.88667, + "V":0.026656, + "W":0.005, + "Y":1.76417 + }, + "P":{ + "Q":4.47211, + "R":1.28355, + "S":5.37762, + "T":2.01417, + "V":0.005, + "W":0.0444506, + "Y":0.0304381 + }, + "Q":{ + "R":3.4215, + "S":0.116311, + "T":0.243589, + "V":0.0209153, + "W":0.026656, + "Y":0.113033 + }, + "R":{ + "S":3.4791, + "T":2.86868, + "V":0.0812454, + "W":0.9913380000000001, + "Y":0.00991826 + }, + "S":{ + "T":8.93107, + "V":0.0749218, + "W":0.0248728, + "Y":0.648024 + }, + "T":{ + "V":0.709226, + "W":0.005, + "Y":0.105652 + }, + "V":{ + "W":0.005, + "Y":0.0410593 + }, + "W":{ + "Y":1.28022 + } +}; + + +lfunction models.protein.HIVBm.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{ 0.060490222} + { 0.020075899} + { 0.042109048} + { 0.071567447} + { 0.028809447} + { 0.072308239} + { 0.022293943} + { 0.069730629} + { 0.056968211} + { 0.098851122} + { 0.019768318} + { 0.044127815} + { 0.046025282} + { 0.053606488} + { 0.066039665} + { 0.05060433} + { 0.053636813} + { 0.061625237} + { 0.033011601} + { 0.028350243}}; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + + + + + + + + + + + +/**************************************** HIVWm functions *************************************/ + + +/** + * @name models.protein.HIVWm.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVWm model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVWm.ModelDescription(type) { + models.protein.HIVWm.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.HIVWm.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.HIVWm.Rij; + models.protein.HIVWm.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.HIVWm.frequencies"; + return models.protein.HIVWm.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVWmF.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVWm+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVWmF.ModelDescription(type) { + models.protein.HIVWmF.ModelDescription.model_definition = models.protein.HIVWm.ModelDescription(type); + models.protein.HIVWmF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.HIVWmF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.HIVWmF.ModelDescription.model_definition; +} + +/** + * @name models.protein.HIVWmML.ModelDescription + * @description Create the baseline schema (dictionary) for the HIVWm+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.HIVWmML.ModelDescription(type) { + models.protein.HIVWmML.ModelDescription.model_definition = models.protein.HIVWm.ModelDescription(type); + models.protein.HIVWmML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.HIVWmML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.HIVWmML.ModelDescription.model_definition; +} + + + + + + +models.protein.HIVWm.Rij = { + "A":{ + "C":0.167653, + "D":4.43521, + "E":5.56325, + "F":0.597923, + "G":1.8685, + "H":0.005, + "I":0.005, + "K":0.592784, + "L":0.16024, + "M":0.005, + "N":0.617509, + "P":1.00981, + "Q":0.005, + "R":0.0744808, + "S":8.594200000000001, + "T":24.1422, + "V":24.8094, + "W":0.005, + "Y":0.005 + }, + "C":{ + "D":0.005, + "E":0.005, + "F":0.362959, + "G":0.0489798, + "H":0.005, + "I":0.005, + "K":0.005, + "L":0.005, + "M":0.005, + "N":0.0604932, + "P":0.005, + "Q":0.005, + "R":2.86364, + "S":1.12195, + "T":0.005, + "V":0.005, + "W":5.49894, + "Y":8.34835 + }, + "D":{ + "E":12.1233, + "F":0.005, + "G":10.3969, + "H":2.31779, + "I":0.145124, + "K":0.894313, + "L":0.005, + "M":0.005, + "N":29.4087, + "P":0.005, + "Q":0.005, + "R":0.0674539, + "S":0.427881, + "T":0.630395, + "V":2.91786, + "W":0.005, + "Y":2.28154 + }, + "E":{ + "F":0.005, + "G":14.7801, + "H":0.005, + "I":0.0390512, + "K":23.9626, + "L":0.129839, + "M":0.005, + "N":0.201526, + "P":0.005, + "Q":3.20656, + "R":0.0251632, + "S":0.005, + "T":0.458743, + "V":2.19952, + "W":0.005, + "Y":0.005 + }, + "F":{ + "G":0.005, + "H":0.005, + "I":1.48288, + "K":0.005, + "L":7.48781, + "M":0.005, + "N":0.005, + "P":0.0342252, + "Q":0.005, + "R":0.005, + "S":4.27939, + "T":0.114512, + "V":2.28, + "W":0.005, + "Y":4.12728 + }, + "G":{ + "H":0.005, + "I":0.005, + "K":0.279425, + "L":0.0489798, + "M":0.0489798, + "N":0.0604932, + "P":0.005, + "Q":0.0604932, + "R":13.4379, + "S":6.27966, + "T":0.0489798, + "V":2.79622, + "W":2.8258, + "Y":0.005 + }, + "H":{ + "I":0.005, + "K":0.22406, + "L":1.76382, + "M":0.005, + "N":8.59876, + "P":13.9444, + "Q":18.5465, + "R":6.84405, + "S":0.7251570000000001, + "T":0.95956, + "V":0.827479, + "W":0.005, + "Y":47.4889 + }, + "I":{ + "K":0.817481, + "L":9.102460000000001, + "M":17.3064, + "N":0.987028, + "P":0.005, + "Q":0.0342252, + "R":1.34069, + "S":0.7400910000000001, + "T":9.36345, + "V":24.8231, + "W":0.005, + "Y":0.114512 + }, + "K":{ + "L":0.005, + "M":4.09564, + "N":10.6655, + "P":0.111928, + "Q":13.0705, + "R":39.8897, + "S":0.005, + "T":4.04802, + "V":0.128065, + "W":0.005, + "Y":0.005 + }, + "L":{ + "M":11.3839, + "N":0.005, + "P":9.83095, + "Q":2.89048, + "R":0.586757, + "S":6.14396, + "T":0.005, + "V":2.95344, + "W":1.37031, + "Y":0.005 + }, + "M":{ + "N":0.201526, + "P":0.005, + "Q":0.005, + "R":3.28652, + "S":0.392575, + "T":7.41313, + "V":14.7683, + "W":0.005, + "Y":0.579198 + }, + "N":{ + "P":0.344848, + "Q":0.342068, + "R":0.16024, + "S":14.5699, + "T":4.54206, + "V":0.0744808, + "W":0.005, + "Y":5.06475 + }, + "P":{ + "Q":3.04502, + "R":0.404723, + "S":14.249, + "T":4.33701, + "V":0.005, + "W":0.005, + "Y":0.005 + }, + "Q":{ + "R":10.6746, + "S":0.16024, + "T":0.203091, + "V":0.005, + "W":0.0443298, + "Y":0.005 + }, + "R":{ + "S":8.350239999999999, + "T":0.928203, + "V":0.279425, + "W":5.96564, + "Y":0.005 + }, + "S":{ + "T":6.34079, + "V":0.862637, + "W":1.10156, + "Y":0.933142 + }, + "T":{ + "V":0.005, + "W":0.005, + "Y":0.490608 + }, + "V":{ + "W":0.005, + "Y":1.35482 + }, + "W":{ + "Y":0.005 + } +}; + + + +lfunction models.protein.HIVWm.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.0377494} + {0.0240105} + {0.0342034} + {0.0618606} + {0.0422741} + {0.0838496} + {0.0156076} + {0.0983641} + {0.0641682} + {0.0577867} + {0.0158419} + {0.0891129} + {0.0458601} + {0.0437824} + {0.057321} + {0.0550846} + {0.0813774} + {0.0515639} + {0.019597} + {0.0205847}}; + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} \ No newline at end of file diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrices/JC69.ibf b/res/TemplateBatchFiles/libv3/models/protein/matrices/JC69.ibf new file mode 100644 index 000000000..bf0b23b51 --- /dev/null +++ b/res/TemplateBatchFiles/libv3/models/protein/matrices/JC69.ibf @@ -0,0 +1,273 @@ +/********* JC69 MODEL OF PROTEIN EVOLUTION ************/ +LoadFunctionLibrary("../empirical.bf"); +LoadFunctionLibrary("../../protein.bf"); +LoadFunctionLibrary("../../parameters.bf"); +LoadFunctionLibrary("../../frequencies.bf"); +LoadFunctionLibrary("../../../UtilityFunctions.bf"); +LoadFunctionLibrary("../../../all-terms.bf"); + + + +/** + * @name models.protein.JC69.ModelDescription + * @description Create the baseline schema (dictionary) for the JC69 model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.JC69.ModelDescription(type) { + models.protein.JC69.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.JC69.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.JC69.Rij; + models.protein.JC69.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.JC69.frequencies"; + return models.protein.JC69.ModelDescription.model_definition; +} + +/** + * @name models.protein.JC69F.ModelDescription + * @description Create the baseline schema (dictionary) for the JC69+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.JC69F.ModelDescription(type) { + models.protein.JC69F.ModelDescription.model_definition = models.protein.JC69.ModelDescription(type); + models.protein.JC69F.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.JC69F.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.JC69F.ModelDescription.model_definition; +} + +/** + * @name models.protein.JC69ML.ModelDescription + * @description Create the baseline schema (dictionary) for the JC69+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.JC69ML.ModelDescription(type) { + models.protein.JC69ML.ModelDescription.model_definition = models.protein.JC69.ModelDescription(type); + models.protein.JC69ML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.JC69ML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.JC69ML.ModelDescription.model_definition; +} + +/* Define a dictionary of amino-acid exchangeability rates for the JC69 model of protein evolution. */ +models.protein.JC69.Rij = { +'A': {'C': 1.0, + 'D': 1.0, + 'E': 1.0, + 'F': 1.0, + 'G': 1.0, + 'H': 1.0, + 'I': 1.0, + 'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'C': {'D': 1.0, + 'E': 1.0, + 'F': 1.0, + 'G': 1.0, + 'H': 1.0, + 'I': 1.0, + 'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'D': {'E': 1.0, + 'F': 1.0, + 'G': 1.0, + 'H': 1.0, + 'I': 1.0, + 'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'E': {'F': 1.0, + 'G': 1.0, + 'H': 1.0, + 'I': 1.0, + 'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'F': {'G': 1.0, + 'H': 1.0, + 'I': 1.0, + 'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'G': {'H': 1.0, + 'I': 1.0, + 'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'H': {'I': 1.0, + 'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'I': {'K': 1.0, + 'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': '10.649107', + 'W': 1.0, + 'Y': 1.0}, + 'K': {'L': 1.0, + 'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'L': {'M': 1.0, + 'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'M': {'N': 1.0, + 'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'N': {'P': 1.0, + 'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'P': {'Q': 1.0, + 'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'Q': {'R': 1.0, + 'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'R': {'S': 1.0, + 'T': 1.0, + 'V': 1.0, + 'W': 1.0, + 'Y': 1.0}, + 'S': {'T': 1.0, 'V': 1.0, 'W': 1.0, 'Y': 1.0}, + 'T': {'V': 1.0, 'W': 1.0, 'Y': 1.0}, + 'V': {'W': 1.0, 'Y': 1.0}, + 'W': {'Y': 1.0}, + 'Y': {}}; + + +/** + * @name models.protein.JC69.frequencies + * @param {Dictionary} Baseline JC69 model + * @returns {Dictionary} Updated JC69 model with empirical frequencies + * @description Define the empirical amino acid frequencies associated with the JC69 model of protein evolution + */ +lfunction models.protein.JC69.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05} + {0.05}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrices/JTT.ibf b/res/TemplateBatchFiles/libv3/models/protein/matrices/JTT.ibf new file mode 100644 index 000000000..a3f4c65be --- /dev/null +++ b/res/TemplateBatchFiles/libv3/models/protein/matrices/JTT.ibf @@ -0,0 +1,269 @@ +/********* JTT MODEL OF PROTEIN EVOLUTION ************/ +LoadFunctionLibrary("../empirical.bf"); +LoadFunctionLibrary("../../protein.bf"); +LoadFunctionLibrary("../../parameters.bf"); +LoadFunctionLibrary("../../frequencies.bf"); +LoadFunctionLibrary("../../../UtilityFunctions.bf"); +LoadFunctionLibrary("../../../all-terms.bf"); + + + +/** + * @name models.protein.JTT.ModelDescription + * @description Create the baseline schema (dictionary) for the JTT model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.JTT.ModelDescription(type) { + models.protein.JTT.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.JTT.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.JTT.Rij; + models.protein.JTT.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.JTT.frequencies"; + return models.protein.JTT.ModelDescription.model_definition; +} + +/** + * @name models.protein.JTTF.ModelDescription + * @description Create the baseline schema (dictionary) for the JTT+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.JTTF.ModelDescription(type) { + models.protein.JTTF.ModelDescription.model_definition = models.protein.JTT.ModelDescription(type); + models.protein.JTTF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.JTTF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.JTTF.ModelDescription.model_definition; +} + +/** + * @name models.protein.JTTML.ModelDescription + * @description Create the baseline schema (dictionary) for the JTT+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.JTTML.ModelDescription(type) { + models.protein.JTTML.ModelDescription.model_definition = models.protein.JTT.ModelDescription(type); + models.protein.JTTML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.JTTML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.JTTML.ModelDescription.model_definition; +} + +/* Define a dictionary of amino-acid exchangeability rates for the JTT model of protein evolution. */ +models.protein.JTT.Rij = { +'A': {'C': 0.56, + 'D': 0.81, + 'E': 1.05, + 'F': 0.15, + 'G': 1.79, + 'H': 0.27, + 'I': 0.36, + 'K': 0.35, + 'L': 0.30, + 'M': 0.54, + 'N': 0.54, + 'P': 1.94, + 'Q': 0.57, + 'R': 0.58, + 'S': 3.78, + 'T': 4.75, + 'V': 2.98, + 'W': 0.09, + 'Y': 0.11}, + 'C': {'D': 0.10, + 'E': 0.05, + 'F': 0.78, + 'G': 0.59, + 'H': 0.69, + 'I': 0.17, + 'K': 0.07, + 'L': 0.23, + 'M': 0.31, + 'N': 0.34, + 'P': 0.14, + 'Q': 0.09, + 'R': 1.13, + 'S': 2.23, + 'T': 0.42, + 'V': 0.62, + 'W': 1.15, + 'Y': 2.09}, + 'D': {'E': 7.67, + 'F': 0.04, + 'G': 1.30, + 'H': 1.12, + 'I': 0.11, + 'K': 0.26, + 'L': 0.07, + 'M': 0.15, + 'N': 5.28, + 'P': 0.15, + 'Q': 0.49, + 'R': 0.16, + 'S': 0.59, + 'T': 0.38, + 'V': 0.31, + 'W': 0.04, + 'Y': 0.46}, + 'E': {'F': 0.05, + 'G': 1.19, + 'H': 0.26, + 'I': 0.12, + 'K': 1.81, + 'L': 0.09, + 'M': 0.18, + 'N': 0.58, + 'P': 0.18, + 'Q': 3.23, + 'R': 0.29, + 'S': 0.30, + 'T': 0.32, + 'V': 0.45, + 'W': 0.10, + 'Y': 0.07}, + 'F': {'G': 0.05, + 'H': 0.40, + 'I': 0.89, + 'K': 0.04, + 'L': 2.48, + 'M': 0.43, + 'N': 0.10, + 'P': 0.17, + 'Q': 0.04, + 'R': 0.05, + 'S': 0.92, + 'T': 0.12, + 'V': 0.62, + 'W': 0.53, + 'Y': 5.36}, + 'G': {'H': 0.23, + 'I': 0.06, + 'K': 0.27, + 'L': 0.06, + 'M': 0.14, + 'N': 0.81, + 'P': 0.24, + 'Q': 0.26, + 'R': 1.37, + 'S': 2.01, + 'T': 0.33, + 'V': 0.47, + 'W': 0.55, + 'Y': 0.08}, + 'H': {'I': 0.16, + 'K': 0.45, + 'L': 0.56, + 'M': 0.33, + 'N': 3.91, + 'P': 1.15, + 'Q': 5.97, + 'R': 3.28, + 'S': 0.73, + 'T': 0.46, + 'V': 0.11, + 'W': 0.08, + 'Y': 5.73}, + 'I': {'K': 0.21, + 'L': 2.29, + 'M': 4.79, + 'N': 0.47, + 'P': 0.10, + 'Q': 0.09, + 'R': 0.22, + 'S': 0.40, + 'T': 2.45, + 'V': 9.61, + 'W': 0.09, + 'Y': 0.32}, + 'K': {'L': 0.14, + 'M': 0.65, + 'N': 2.63, + 'P': 0.21, + 'Q': 2.92, + 'R': 6.46, + 'S': 0.47, + 'T': 1.03, + 'V': 0.14, + 'W': 0.10, + 'Y': 0.08}, + 'L': {'M': 3.88, + 'N': 0.12, + 'P': 1.02, + 'Q': 0.72, + 'R': 0.38, + 'S': 0.59, + 'T': 0.25, + 'V': 1.80, + 'W': 0.52, + 'Y': 0.24}, + 'M': {'N': 0.30, + 'P': 0.16, + 'Q': 0.43, + 'R': 0.44, + 'S': 0.29, + 'T': 2.26, + 'V': 3.23, + 'W': 0.24, + 'Y': 0.18}, + 'N': {'P': 0.15, + 'Q': 0.86, + 'R': 0.45, + 'S': 5.03, + 'T': 2.32, + 'V': 0.16, + 'W': 0.08, + 'Y': 0.70}, + 'P': {'Q': 1.64, + 'R': 0.74, + 'S': 2.85, + 'T': 1.18, + 'V': 0.23, + 'W': 0.06, + 'Y': 0.10}, + 'Q': {'R': 3.10, + 'S': 0.53, + 'T': 0.51, + 'V': 0.20, + 'W': 0.18, + 'Y': 0.24}, + 'R': {'S': 1.01, 'T': 0.64, 'V': 0.17, 'W': 1.26, 'Y': 0.20}, + 'S': {'T': 4.77, 'V': 0.38, 'W': 0.35, 'Y': 0.63}, + 'T': {'V': 1.12, 'W': 0.12, 'Y': 0.21}, + 'V': {'W': 0.25, 'Y': 0.16}, + 'W': {'Y': 0.71}, + 'Y': {}}; + + +/** + * @name models.protein.JTT.frequencies + * @param {Dictionary} Baseline JTT model + * @returns {Dictionary} Updated JTT model with empirical frequencies + * @description Define the empirical amino acid frequencies associated with the JTT model of protein evolution + */ +lfunction models.protein.JTT.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.076748} + {0.019803} + {0.051544} + {0.061830} + {0.040126} + {0.073152} + {0.022944} + {0.053761} + {0.058676} + {0.091904} + {0.023826} + {0.042645} + {0.050901} + {0.040752} + {0.051691} + {0.068765} + {0.058565} + {0.066005} + {0.014261} + {0.032102}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrices/LG.ibf b/res/TemplateBatchFiles/libv3/models/protein/matrices/LG.ibf new file mode 100644 index 000000000..6dd855813 --- /dev/null +++ b/res/TemplateBatchFiles/libv3/models/protein/matrices/LG.ibf @@ -0,0 +1,273 @@ +/********* LG MODEL OF PROTEIN EVOLUTION ************/ +LoadFunctionLibrary("../empirical.bf"); +LoadFunctionLibrary("../../protein.bf"); +LoadFunctionLibrary("../../parameters.bf"); +LoadFunctionLibrary("../../frequencies.bf"); +LoadFunctionLibrary("../../../UtilityFunctions.bf"); +LoadFunctionLibrary("../../../all-terms.bf"); + + + +/** + * @name models.protein.LG.ModelDescription + * @description Create the baseline schema (dictionary) for the LG model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.LG.ModelDescription(type) { + models.protein.LG.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.LG.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.LG.Rij; + models.protein.LG.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.LG.frequencies"; + return models.protein.LG.ModelDescription.model_definition; +} + +/** + * @name models.protein.LGF.ModelDescription + * @description Create the baseline schema (dictionary) for the LG+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.LGF.ModelDescription(type) { + models.protein.LGF.ModelDescription.model_definition = models.protein.LG.ModelDescription(type); + models.protein.LGF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.LGF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.LGF.ModelDescription.model_definition; +} + +/** + * @name models.protein.LGML.ModelDescription + * @description Create the baseline schema (dictionary) for the LG+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.LGML.ModelDescription(type) { + models.protein.LGML.ModelDescription.model_definition = models.protein.LG.ModelDescription(type); + models.protein.LGML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.LGML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.LGML.ModelDescription.model_definition; +} + +/* Define a dictionary of amino-acid exchangeability rates for the LG model of protein evolution. */ +models.protein.LG.Rij = { +'A': {'C': 2.489084, + 'D': 0.395144, + 'E': 1.038545, + 'F': 0.253701, + 'G': 2.066040, + 'H': 0.358858, + 'I': 0.149830, + 'K': 0.536518, + 'L': 0.395337, + 'M': 1.124035, + 'N': 0.276818, + 'P': 1.177651, + 'Q': 0.969894, + 'R': 0.425093, + 'S': 4.727182, + 'T': 2.139501, + 'V': 2.547870, + 'W': 0.180717, + 'Y': 0.218959}, + 'C': {'D': 0.062556, + 'E': 0.003499, + 'F': 1.105251, + 'G': 0.569265, + 'H': 0.640543, + 'I': 0.320627, + 'K': 0.013266, + 'L': 0.594007, + 'M': 0.893680, + 'N': 0.528768, + 'P': 0.075382, + 'Q': 0.084808, + 'R': 0.534551, + 'S': 2.784478, + 'T': 1.143480, + 'V': 1.959291, + 'W': 0.670128, + 'Y': 1.165532}, + 'D': {'E': 5.243870, + 'F': 0.017416, + 'G': 0.844926, + 'H': 0.927114, + 'I': 0.010690, + 'K': 0.282959, + 'L': 0.015076, + 'M': 0.025548, + 'N': 5.076149, + 'P': 0.394456, + 'Q': 0.523386, + 'R': 0.123954, + 'S': 1.240275, + 'T': 0.425860, + 'V': 0.037967, + 'W': 0.029890, + 'Y': 0.135107}, + 'E': {'F': 0.018811, + 'G': 0.348847, + 'H': 0.423881, + 'I': 0.044265, + 'K': 1.807177, + 'L': 0.069673, + 'M': 0.173735, + 'N': 0.541712, + 'P': 0.419409, + 'Q': 4.128591, + 'R': 0.363970, + 'S': 0.611973, + 'T': 0.604545, + 'V': 0.245034, + 'W': 0.077852, + 'Y': 0.120037}, + 'F': {'G': 0.089586, + 'H': 0.682139, + 'I': 1.112727, + 'K': 0.023918, + 'L': 2.592692, + 'M': 1.798853, + 'N': 0.089525, + 'P': 0.094464, + 'Q': 0.035855, + 'R': 0.052722, + 'S': 0.361819, + 'T': 0.165001, + 'V': 0.654683, + 'W': 2.457121, + 'Y': 7.803902}, + 'G': {'H': 0.311484, + 'I': 0.008705, + 'K': 0.296636, + 'L': 0.044261, + 'M': 0.139538, + 'N': 1.437645, + 'P': 0.196961, + 'Q': 0.267959, + 'R': 0.390192, + 'S': 1.739990, + 'T': 0.129836, + 'V': 0.076701, + 'W': 0.268491, + 'Y': 0.054679}, + 'H': {'I': 0.108882, + 'K': 0.697264, + 'L': 0.366317, + 'M': 0.442472, + 'N': 4.509238, + 'P': 0.508851, + 'Q': 4.813505, + 'R': 2.426601, + 'S': 0.990012, + 'T': 0.584262, + 'V': 0.119013, + 'W': 0.597054, + 'Y': 5.306834}, + 'I': {'K': 0.159069, + 'L': 4.145067, + 'M': 4.273607, + 'N': 0.191503, + 'P': 0.078281, + 'Q': 0.072854, + 'R': 0.126991, + 'S': 0.064105, + 'T': 1.033739, + 'V': 10.649107, + 'W': 0.111660, + 'Y': 0.232523}, + 'K': {'L': 0.137500, + 'M': 0.656604, + 'N': 2.145078, + 'P': 0.390322, + 'Q': 3.234294, + 'R': 6.326067, + 'S': 0.748683, + 'T': 1.136863, + 'V': 0.185202, + 'W': 0.049906, + 'Y': 0.131932}, + 'L': {'M': 6.312358, + 'N': 0.068427, + 'P': 0.249060, + 'Q': 0.582457, + 'R': 0.301848, + 'S': 0.182287, + 'T': 0.302936, + 'V': 1.702745, + 'W': 0.619632, + 'Y': 0.299648}, + 'M': {'N': 0.371004, + 'P': 0.099849, + 'Q': 1.672569, + 'R': 0.484133, + 'S': 0.346960, + 'T': 2.020366, + 'V': 1.898718, + 'W': 0.696175, + 'Y': 0.481306}, + 'N': {'P': 0.161787, + 'Q': 1.695752, + 'R': 0.751878, + 'S': 4.008358, + 'T': 2.000679, + 'V': 0.083688, + 'W': 0.045376, + 'Y': 0.612025}, + 'P': {'Q': 0.624294, + 'R': 0.332533, + 'S': 1.338132, + 'T': 0.571468, + 'V': 0.296501, + 'W': 0.095131, + 'Y': 0.089613}, + 'Q': {'R': 2.807908, + 'S': 1.223828, + 'T': 1.080136, + 'V': 0.210332, + 'W': 0.236199, + 'Y': 0.257336}, + 'R': {'S': 0.858151, + 'T': 0.578987, + 'V': 0.170887, + 'W': 0.593607, + 'Y': 0.314440}, + 'S': {'T': 6.472279, 'V': 0.098369, 'W': 0.248862, 'Y': 0.400547}, + 'T': {'V': 2.188158, 'W': 0.140825, 'Y': 0.245841}, + 'V': {'W': 0.189510, 'Y': 0.249313}, + 'W': {'Y': 3.151815}, + 'Y': {}}; + + +/** + * @name models.protein.LG.frequencies + * @param {Dictionary} Baseline LG model + * @returns {Dictionary} Updated LG model with empirical frequencies + * @description Define the empirical amino acid frequencies associated with the LG model of protein evolution + */ +lfunction models.protein.LG.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.079066} + {0.012937} + {0.053052} + {0.071586} + {0.042302} + {0.057337} + {0.022355} + {0.062157} + {0.064600} + {0.099081} + {0.022951} + {0.041977} + {0.044040} + {0.040767} + {0.055941} + {0.061197} + {0.053287} + {0.069147} + {0.012066} + {0.034155}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrices/WAG.ibf b/res/TemplateBatchFiles/libv3/models/protein/matrices/WAG.ibf new file mode 100644 index 000000000..18631fee8 --- /dev/null +++ b/res/TemplateBatchFiles/libv3/models/protein/matrices/WAG.ibf @@ -0,0 +1,271 @@ +/********* WAG MODEL OF PROTEIN EVOLUTION ************/ +LoadFunctionLibrary("../empirical.bf"); +LoadFunctionLibrary("../../protein.bf"); +LoadFunctionLibrary("../../parameters.bf"); +LoadFunctionLibrary("../../frequencies.bf"); +LoadFunctionLibrary("../../../UtilityFunctions.bf"); +LoadFunctionLibrary("../../../all-terms.bf"); + + + +/** + * @name models.protein.WAG.ModelDescription + * @description Create the baseline schema (dictionary) for the WAG model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.WAG.ModelDescription(type) { + models.protein.WAG.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.WAG.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.WAG.Rij; + models.protein.WAG.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.WAG.frequencies"; + return models.protein.WAG.ModelDescription.model_definition; +} + +/** + * @name models.protein.WAGF.ModelDescription + * @description Create the baseline schema (dictionary) for the WAG+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.WAGF.ModelDescription(type) { + models.protein.WAGF.ModelDescription.model_definition = models.protein.WAG.ModelDescription(type); + models.protein.WAGF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.WAGF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.WAGF.ModelDescription.model_definition; +} + +/** + * @name models.protein.WAGML.ModelDescription + * @description Create the baseline schema (dictionary) for the WAG+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.WAGML.ModelDescription(type) { + models.protein.WAGML.ModelDescription.model_definition = models.protein.WAG.ModelDescription(type); + models.protein.WAGML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.WAGML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.WAGML.ModelDescription.model_definition; +} + +/* Define a dictionary of amino-acid exchangeability rates for the WAG model of protein evolution. */ +models.protein.WAG.Rij = { +'A': {'C': 1.027040, + 'D': 0.738998, + 'E': 1.582850, + 'F': 0.210494, + 'G': 1.416720, + 'H': 0.316954, + 'I': 0.193335, + 'K': 0.906265, + 'L': 0.397915, + 'M': 0.893496, + 'N': 0.509848, + 'P': 1.438550, + 'Q': 0.908598, + 'R': 0.551571, + 'S': 3.370790, + 'T': 2.121110, + 'V': 2.006010, + 'W': 0.113133, + 'Y': 0.240735}, + 'C': {'D': 0.0302949, + 'E': 0.021352, + 'F': 0.398020, + 'G': 0.306674, + 'H': 0.248972, + 'I': 0.170135, + 'K': 0.0740339, + 'L': 0.384287, + 'M': 0.390482, + 'N': 0.265256, + 'P': 0.109404, + 'Q': 0.0988179, + 'R': 0.528191, + 'S': 1.407660, + 'T': 0.512984, + 'V': 1.002140, + 'W': 0.717070, + 'Y': 0.543833}, + 'D': {'E': 6.174160, + 'F': 0.0467304, + 'G': 0.865584, + 'H': 0.930676, + 'I': 0.039437, + 'K': 0.479855, + 'L': 0.0848047, + 'M': 0.103754, + 'N': 5.429420, + 'P': 0.423984, + 'Q': 0.616783, + 'R': 0.147304, + 'S': 1.071760, + 'T': 0.374866, + 'V': 0.152335, + 'W': 0.129767, + 'Y': 0.325711}, + 'E': {'F': 0.0811339, + 'G': 0.567717, + 'H': 0.570025, + 'I': 0.127395, + 'K': 2.584430, + 'L': 0.154263, + 'M': 0.315124, + 'N': 0.947198, + 'P': 0.682355, + 'Q': 5.469470, + 'R': 0.439157, + 'S': 0.704939, + 'T': 0.822765, + 'V': 0.588731, + 'W': 0.156557, + 'Y': 0.196303}, + 'F': {'G': 0.049931, + 'H': 0.679371, + 'I': 1.059470, + 'K': 0.088836, + 'L': 2.115170, + 'M': 1.190630, + 'N': 0.0961621, + 'P': 0.161444, + 'Q': 0.0999208, + 'R': 0.102711, + 'S': 0.545931, + 'T': 0.171903, + 'V': 0.649892, + 'W': 1.529640, + 'Y': 6.454280}, + 'G': {'H': 0.249410, + 'I': 0.0304501, + 'K': 0.373558, + 'L': 0.0613037, + 'M': 0.174100, + 'N': 1.125560, + 'P': 0.243570, + 'Q': 0.330052, + 'R': 0.584665, + 'S': 1.341820, + 'T': 0.225833, + 'V': 0.187247, + 'W': 0.336983, + 'Y': 0.103604}, + 'H': {'I': 0.138190, + 'K': 0.890432, + 'L': 0.499462, + 'M': 0.404141, + 'N': 3.956290, + 'P': 0.696198, + 'Q': 4.294110, + 'R': 2.137150, + 'S': 0.740169, + 'T': 0.473307, + 'V': 0.118358, + 'W': 0.262569, + 'Y': 3.873440}, + 'I': {'K': 0.323832, + 'L': 3.170970, + 'M': 4.257460, + 'N': 0.554236, + 'P': 0.0999288, + 'Q': 0.113917, + 'R': 0.186979, + 'S': 0.319440, + 'T': 1.458160, + 'V': 7.821300, + 'W': 0.212483, + 'Y': 0.420170}, + 'K': {'L': 0.257555, + 'M': 0.934276, + 'N': 3.012010, + 'P': 0.556896, + 'Q': 3.894900, + 'R': 5.351420, + 'S': 0.967130, + 'T': 1.386980, + 'V': 0.305434, + 'W': 0.137505, + 'Y': 0.133264}, + 'L': {'M': 4.854020, + 'N': 0.131528, + 'P': 0.415844, + 'Q': 0.869489, + 'R': 0.497671, + 'S': 0.344739, + 'T': 0.326622, + 'V': 1.800340, + 'W': 0.665309, + 'Y': 0.398618}, + 'M': {'N': 0.198221, + 'P': 0.171329, + 'Q': 1.545260, + 'R': 0.683162, + 'S': 0.493905, + 'T': 1.516120, + 'V': 2.058450, + 'W': 0.515706, + 'Y': 0.428437}, + 'N': {'P': 0.195081, + 'Q': 1.543640, + 'R': 0.635346, + 'S': 3.974230, + 'T': 2.030060, + 'V': 0.196246, + 'W': 0.0719167, + 'Y': 1.086000}, + 'P': {'Q': 0.933372, + 'R': 0.679489, + 'S': 1.613280, + 'T': 0.795384, + 'V': 0.314887, + 'W': 0.139405, + 'Y': 0.216046}, + 'Q': {'R': 3.035500, + 'S': 1.028870, + 'T': 0.857928, + 'V': 0.301281, + 'W': 0.215737, + 'Y': 0.227710}, + 'R': {'S': 1.224190, + 'T': 0.554413, + 'V': 0.251849, + 'W': 1.163920, + 'Y': 0.381533}, + 'S': {'T': 4.378020, 'V': 0.232739, 'W': 0.523742, 'Y': 0.786993}, + 'T': {'V': 1.388230, 'W': 0.110864, 'Y': 0.291148}, + 'V': {'W': 0.365369, 'Y': 0.314730}, + 'W': {'Y': 2.485390}, + 'Y': {}}; + +/** + * @name models.protein.WAG.frequencies + * @param {Dictionary} Baseline WAG model + * @returns {Dictionary} Updated WAG model with empirical frequencies + * @description Define the empirical amino acid frequencies associated with the WAG model of protein evolution + */ +lfunction models.protein.WAG.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{ 0.0866279} + { 0.0193078} + { 0.0570451} + { 0.0580589} + { 0.0384319} + { 0.0832518} + { 0.0244313} + { 0.048466} + { 0.0620286} + { 0.086209} + { 0.0195027} + { 0.0390894} + { 0.0457631} + { 0.0367281} + { 0.043972} + { 0.0695179} + { 0.0610127} + { 0.0708956} + { 0.0143859} + { 0.0352742} + }; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrices/gcpREV.ibf b/res/TemplateBatchFiles/libv3/models/protein/matrices/gcpREV.ibf new file mode 100644 index 000000000..a738e0d89 --- /dev/null +++ b/res/TemplateBatchFiles/libv3/models/protein/matrices/gcpREV.ibf @@ -0,0 +1,269 @@ +/********* gcpREV MODEL OF PROTEIN EVOLUTION ************/ +LoadFunctionLibrary("../empirical.bf"); +LoadFunctionLibrary("../../protein.bf"); +LoadFunctionLibrary("../../parameters.bf"); +LoadFunctionLibrary("../../frequencies.bf"); +LoadFunctionLibrary("../../../UtilityFunctions.bf"); +LoadFunctionLibrary("../../../all-terms.bf"); + + + +/** + * @name models.protein.gcpREV.ModelDescription + * @description Create the baseline schema (dictionary) for the gcpREV model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.gcpREV.ModelDescription(type) { + models.protein.gcpREV.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.gcpREV.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.gcpREV.Rij; + models.protein.gcpREV.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.gcpREV.frequencies"; + return models.protein.gcpREV.ModelDescription.model_definition; +} + +/** + * @name models.protein.gcpREVF.ModelDescription + * @description Create the baseline schema (dictionary) for the gcpREV+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.gcpREVF.ModelDescription(type) { + models.protein.gcpREVF.ModelDescription.model_definition = models.protein.gcpREV.ModelDescription(type); + models.protein.gcpREVF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.gcpREVF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.gcpREVF.ModelDescription.model_definition; +} + +/** + * @name models.protein.gcpREVML.ModelDescription + * @description Create the baseline schema (dictionary) for the gcpREV+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.gcpREVML.ModelDescription(type) { + models.protein.gcpREVML.ModelDescription.model_definition = models.protein.gcpREV.ModelDescription(type); + models.protein.gcpREVML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.gcpREVML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.gcpREVML.ModelDescription.model_definition; +} + +/* Define a dictionary of amino-acid exchangeability rates for the gcpREV model of protein evolution. */ +models.protein.gcpREV.Rij = { +'A': {'C': 699.4, + 'D': 87.7, + 'E': 288.3, + 'F': 59.3, + 'G': 677.9, + 'H': 32.0, + 'I': 39.5, + 'K': 78.3, + 'L': 33.8, + 'M': 197.1, + 'N': 59.1, + 'P': 505.8, + 'Q': 199.5, + 'R': 12.2, + 'S': 2443.9, + 'T': 1646.2, + 'V': 1143.8, + 'W': 30.0, + 'Y': 27.9}, + 'C': {'D': 125.3, + 'E': 102.4, + 'F': 1540.1, + 'G': 433.6, + 'H': 574.8, + 'I': 96.0, + 'K': 89.2, + 'L': 446.5, + 'M': 288.5, + 'N': 133.7, + 'P': 124.9, + 'Q': 195.1, + 'R': 1867.9, + 'S': 3029.8, + 'T': 516.8, + 'V': 722.2, + 'W': 562.6, + 'Y': 1571.2}, + 'D': {'E': 3638.7, + 'F': 15.9, + 'G': 464.8, + 'H': 527.7, + 'I': 16.8, + 'K': 78.3, + 'L': 8.7, + 'M': 33.1, + 'N': 5083.8, + 'P': 43.6, + 'Q': 387.6, + 'R': 40.6, + 'S': 142.1, + 'T': 66.1, + 'V': 18.5, + 'W': 35.0, + 'Y': 272.1}, + 'E': {'F': 30.7, + 'G': 393.8, + 'H': 144.6, + 'I': 23.4, + 'K': 1870.9, + 'L': 26.8, + 'M': 33.3, + 'N': 230.9, + 'P': 39.4, + 'Q': 2965.3, + 'R': 51.9, + 'S': 156.7, + 'T': 230.0, + 'V': 103.8, + 'W': 57.2, + 'Y': 79.2}, + 'F': {'G': 10.1, + 'H': 87.2, + 'I': 354.4, + 'K': 9.0, + 'L': 1585.8, + 'M': 183.4, + 'N': 13.4, + 'P': 82.1, + 'Q': 10.7, + 'R': 26.1, + 'S': 790.5, + 'T': 29.8, + 'V': 180.6, + 'W': 558.3, + 'Y': 2360.2}, + 'G': {'H': 35.6, + 'I': 11.8, + 'K': 193.4, + 'L': 4.3, + 'M': 11.8, + 'N': 446.5, + 'P': 11.8, + 'Q': 40.8, + 'R': 391.2, + 'S': 709.0, + 'T': 65.5, + 'V': 72.6, + 'W': 92.6, + 'Y': 20.6}, + 'H': {'I': 38.1, + 'K': 96.9, + 'L': 46.1, + 'M': 54.5, + 'N': 2156.8, + 'P': 185.1, + 'Q': 1889.6, + 'R': 1228.7, + 'S': 277.0, + 'T': 77.1, + 'V': 22.8, + 'W': 58.5, + 'Y': 4117.5}, + 'I': {'K': 125.7, + 'L': 1657.9, + 'M': 2493.4, + 'N': 146.0, + 'P': 63.1, + 'Q': 48.5, + 'R': 105.4, + 'S': 75.6, + 'T': 1227.2, + 'V': 6006.5, + 'W': 21.1, + 'Y': 35.8}, + 'K': {'L': 37.6, + 'M': 220.1, + 'N': 1930.8, + 'P': 49.8, + 'Q': 2571.2, + 'R': 4666.4, + 'S': 209.3, + 'T': 648.5, + 'V': 66.2, + 'W': 15.9, + 'Y': 84.2}, + 'L': {'M': 1389.6, + 'N': 11.6, + 'P': 347.7, + 'Q': 235.4, + 'R': 124.9, + 'S': 584.9, + 'T': 62.9, + 'V': 661.7, + 'W': 218.2, + 'Y': 82.0}, + 'M': {'N': 41.4, + 'P': 19.2, + 'Q': 341.8, + 'R': 112.1, + 'S': 32.9, + 'T': 1143.5, + 'V': 465.7, + 'W': 70.5, + 'Y': 41.1}, + 'N': {'P': 18.7, + 'Q': 827.8, + 'R': 313.0, + 'S': 2505.4, + 'T': 1373.3, + 'V': 27.6, + 'W': 19.9, + 'Y': 316.2}, + 'P': {'Q': 223.1, + 'R': 89.4, + 'S': 1154.5, + 'T': 322.8, + 'V': 75.5, + 'W': 18.5, + 'Y': 15.8}, + 'Q': {'R': 2321.3, + 'S': 246.9, + 'T': 128.5, + 'V': 50.2, + 'W': 24.6, + 'Y': 179.1}, + 'R': {'S': 269.6, 'T': 173.4, 'V': 62.0, 'W': 257.8, 'Y': 137.0}, + 'S': {'T': 2042.5, 'V': 61.2, 'W': 102.6, 'Y': 501.9}, + 'T': {'V': 583.7, 'W': 22.0, 'Y': 64.6}, + 'V': {'W': 10.8, 'Y': 37.3}, + 'W': {'Y': 296.3}, + 'Y': {}}; + + +/** + * @name models.protein.gcpREV.frequencies + * @param {Dictionary} Baseline gcpREV model + * @returns {Dictionary} Updated gcpREV model with empirical frequencies + * @description Define the empirical amino acid frequencies associated with the gcpREV model of protein evolution + */ +lfunction models.protein.gcpREV.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.07951} + {0.009051} + {0.03322} + {0.049675} + {0.047731} + {0.080233} + {0.02188} + {0.080496} + {0.049324} + {0.107512} + {0.020776} + {0.040459} + {0.039916} + {0.037505} + {0.056001} + {0.07382} + {0.053615} + {0.071781} + {0.016705} + {0.03079}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + diff --git a/res/TemplateBatchFiles/libv3/models/protein/matrices/mt.ibf b/res/TemplateBatchFiles/libv3/models/protein/matrices/mt.ibf new file mode 100644 index 000000000..2eb704e13 --- /dev/null +++ b/res/TemplateBatchFiles/libv3/models/protein/matrices/mt.ibf @@ -0,0 +1,817 @@ +/********* MITOCHONDRIAL MODELS OF PROTEIN EVOLUTION ************/ +LoadFunctionLibrary("../empirical.bf"); +LoadFunctionLibrary("../../protein.bf"); +LoadFunctionLibrary("../../parameters.bf"); +LoadFunctionLibrary("../../frequencies.bf"); +LoadFunctionLibrary("../../../UtilityFunctions.bf"); +LoadFunctionLibrary("../../../all-terms.bf"); + + + + +/** + * @name models.protein.mtMet.ModelDescription + * @description Create the baseline schema (dictionary) for the mtMet model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtMet.ModelDescription(type) { + models.protein.mtMet.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.mtMet.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.mtMet.Rij; + models.protein.mtMet.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.mtMet.frequencies"; + return models.protein.mtMet.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtMetF.ModelDescription + * @description Create the baseline schema (dictionary) for the mtMet+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtMetF.ModelDescription(type) { + models.protein.mtMetF.ModelDescription.model_definition = models.protein.mtMet.ModelDescription(type); + models.protein.mtMetF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.mtMetF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.mtMetF.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtMetML.ModelDescription + * @description Create the baseline schema (dictionary) for the mtMet+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtMetML.ModelDescription(type) { + models.protein.mtMetML.ModelDescription.model_definition = models.protein.mtMet.ModelDescription(type); + models.protein.mtMetML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.mtMetML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.mtMetML.ModelDescription.model_definition; +} + + + +models.protein.mtMet.Rij = { +'A': {'C': 0.63325584800000001, + 'D': 0.11915685500000001, + 'E': 0.17916388799999999, + 'F': 0.062762255000000003, + 'G': 1.4658622800000001, + 'H': 0.030192130000000001, + 'I': 0.367600449, + 'K': 0.020509507999999999, + 'L': 0.109872766, + 'M': 0.65336399300000003, + 'N': 0.03289392, + 'P': 0.40807705300000002, + 'Q': 0.052454947000000002, + 'R': 0.058078194999999999, + 'S': 2.7716860149999998, + 'T': 6.7308851599999997, + 'V': 2.815163085, + 'W': 0.013623415999999999, + 'Y': 0.014501406999999999}, + 'C': {'D': 0.077419373999999999, + 'E': 0.050609064000000002, + 'F': 0.92581086400000001, + 'G': 0.91412559000000004, + 'H': 0.60383390000000003, + 'I': 0.235804245, + 'K': 0.015753762000000001, + 'L': 0.29951899700000001, + 'M': 0.49234014399999998, + 'N': 0.29328103, + 'P': 0.029408410999999999, + 'Q': 0.15259520800000001, + 'R': 0.73981385700000002, + 'S': 3.2830148709999998, + 'T': 0.33866819599999998, + 'V': 1.3945280440000001, + 'W': 1.018410485, + 'Y': 1.967371255}, + 'D': {'E': 6.0337889819999999, + 'F': 0.012560742999999999, + 'G': 0.63075329899999999, + 'H': 0.47979111200000002, + 'I': 0.010668856000000001, + 'K': 0.049007455999999998, + 'L': 0.0055291439999999997, + 'M': 0.026109947000000001, + 'N': 4.6584200710000001, + 'P': 0.044609562999999998, + 'Q': 0.13135570199999999, + 'R': 0.049700411999999999, + 'S': 0.36080478100000002, + 'T': 0.102136221, + 'V': 0.084589028999999996, + 'W': 0.040920527999999998, + 'Y': 0.16028995800000001}, + 'E': {'F': 0.017716308, + 'G': 0.76885329499999999, + 'H': 0.105414735, + 'I': 0.014004526, + 'K': 1.3792177830000001, + 'L': 0.019157619000000001, + 'M': 0.128410054, + 'N': 0.81224112400000004, + 'P': 0.048786298999999998, + 'Q': 2.2366176229999999, + 'R': 0.080835481000000001, + 'S': 0.36310446600000001, + 'T': 0.13480267100000001, + 'V': 0.227827051, + 'W': 0.086028795000000005, + 'Y': 0.093214721}, + 'F': {'G': 0.068139280999999996, + 'H': 0.090353066999999995, + 'I': 0.75090054100000003, + 'K': 0.097125533999999999, + 'L': 1.811101233, + 'M': 0.74842499699999998, + 'N': 0.13875929100000001, + 'P': 0.054271888999999997, + 'Q': 0.026306324999999998, + 'R': 0.0080439580000000004, + 'S': 0.49934990099999998, + 'T': 0.053947742999999999, + 'V': 0.46624344200000001, + 'W': 0.330781928, + 'Y': 3.2090833029999999}, + 'G': {'H': 0.025252655999999998, + 'I': 0.013781055, + 'K': 0.13418717499999999, + 'L': 0.027264554, + 'M': 0.14533146599999999, + 'N': 0.54375075699999997, + 'P': 0.005914206, + 'Q': 0.072395535999999996, + 'R': 0.21996712400000001, + 'S': 1.746570145, + 'T': 0.02455829, + 'V': 0.41714895400000002, + 'W': 0.233963371, + 'Y': 0.046746340999999997}, + 'H': {'I': 0.017140138999999999, + 'K': 0.13515366300000001, + 'L': 0.11163893699999999, + 'M': 0.032834314000000003, + 'N': 1.7386796440000001, + 'P': 0.51995437499999997, + 'Q': 4.5184508909999996, + 'R': 1.5222568649999999, + 'S': 0.29758608399999997, + 'T': 0.221010609, + 'V': 0.0035110079999999999, + 'W': 0.037480926999999997, + 'Y': 3.9079185509999999}, + 'I': {'K': 0.064936611000000005, + 'L': 1.8979743680000001, + 'M': 2.9183532080000001, + 'N': 0.244934765, + 'P': 0.024850021, + 'Q': 0.0088756860000000007, + 'R': 0.012428576, + 'S': 0.096272864, + 'T': 2.4534581430000002, + 'V': 10.953425842, + 'W': 0.028656797000000001, + 'Y': 0.135319461}, + 'K': {'L': 0.06132452, + 'M': 0.65931076, + 'N': 2.53039843, + 'P': 0.121234921, + 'Q': 1.8272181860000001, + 'R': 1.057185633, + 'S': 0.69508812799999997, + 'T': 0.39385170400000002, + 'V': 0.055461435000000003, + 'W': 0.073508962999999997, + 'Y': 0.281699174}, + 'L': {'M': 3.4255537089999999, + 'N': 0.046318944000000001, + 'P': 0.27026078100000001, + 'Q': 0.25445246700000002, + 'R': 0.058180015000000002, + 'S': 0.31152513100000001, + 'T': 0.253366704, + 'V': 0.95827374300000001, + 'W': 0.25324301300000002, + 'Y': 0.123555332}, + 'M': {'N': 0.39982772300000002, + 'P': 0.032714699, + 'Q': 0.237094366, + 'R': 0.013494034, + 'S': 0.45873409599999998, + 'T': 3.0352157260000001, + 'V': 2.5624848949999999, + 'W': 0.167575318, + 'Y': 0.31659903099999998}, + 'N': {'P': 0.080313958000000005, + 'Q': 0.83279153299999997, + 'R': 0.14136427500000001, + 'S': 2.6343785139999998, + 'T': 0.96128509299999998, + 'V': 0.051741626999999998, + 'W': 0.049019408, + 'Y': 1.020785491}, + 'P': {'Q': 0.84951243499999995, + 'R': 0.15500856599999999, + 'S': 1.231180819, + 'T': 0.73460491000000006, + 'V': 0.054078532999999998, + 'W': 0.029433866, + 'Y': 0.054012182999999998}, + 'Q': {'R': 2.6731080889999999, + 'S': 0.38480028399999999, + 'T': 0.274195947, + 'V': 0.027669233000000001, + 'W': 0.12314062000000001, + 'Y': 0.319105788}, + 'R': {'S': 0.19737918500000001, + 'T': 0.056079812999999999, + 'V': 0.041063684000000003, + 'W': 0.37081989199999998, + 'Y': 0.12751933200000001}, + 'S': {'T': 3.1147429070000001, + 'V': 0.26710946499999999, + 'W': 0.16921202900000001, + 'Y': 0.37418428599999998}, + 'T': {'V': 1.5140596740000001, 'W': 0.014378616, 'Y': 0.091031787000000003}, + 'V': {'W': 0.093136256000000001, 'Y': 0.069964540000000006}, + 'W': {'Y': 0.48104431600000003}, + 'Y': {}}; + + + +lfunction models.protein.mtMet.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.043793200} + {0.011330500} + {0.016899000} + {0.022538500} + {0.088448000} + {0.047050100} + {0.017183700} + {0.089779400} + {0.039913500} + {0.155226000} + {0.067444300} + {0.057001300} + {0.037528200} + {0.018018100} + {0.012957800} + {0.093752200} + {0.063579000} + {0.053317400} + {0.022671300} + {0.041568200}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + + + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////// + + + + +/** + * @name models.protein.mtVer.ModelDescription + * @description Create the baseline schema (dictionary) for the mtVer model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtVer.ModelDescription(type) { + models.protein.mtVer.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.mtVer.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.mtVer.Rij; + models.protein.mtVer.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.mtVer.frequencies"; + return models.protein.mtVer.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtVerF.ModelDescription + * @description Create the baseline schema (dictionary) for the mtVer+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtVerF.ModelDescription(type) { + models.protein.mtVerF.ModelDescription.model_definition = models.protein.mtVer.ModelDescription(type); + models.protein.mtVerF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.mtVerF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.mtVerF.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtVerML.ModelDescription + * @description Create the baseline schema (dictionary) for the mtVer+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtVerML.ModelDescription(type) { + models.protein.mtVerML.ModelDescription.model_definition = models.protein.mtVer.ModelDescription(type); + models.protein.mtVerML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.mtVerML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.mtVerML.ModelDescription.model_definition; +} + + + + + + +models.protein.mtVer.Rij = { +'A': {'C': 0.246553601, + 'D': 0.159447221, + 'E': 0.191894132, + 'F': 0.064446493, + 'G': 1.094200392, + 'H': 0.023294168, + 'I': 0.412484838, + 'K': 0.020785848, + 'L': 0.078175467, + 'M': 0.751880464, + 'N': 0.032311357, + 'P': 0.285569251, + 'Q': 0.030870527, + 'R': 0.064684561, + 'S': 2.481816654, + 'T': 5.562698831, + 'V': 3.196936472, + 'W': 0.008423051, + 'Y': 0.012484937}, + 'C': {'D': 0.121292172, + 'E': 0.036419095, + 'F': 1.071949752, + 'G': 0.916864782, + 'H': 1.397207302, + 'I': 0.067512547, + 'K': 0.024775616, + 'L': 0.170992927, + 'M': 0.084565906, + 'N': 0.336138766, + 'P': 0.018903613, + 'Q': 0.116173285, + 'R': 1.223667072, + 'S': 3.359147075, + 'T': 0.152312817, + 'V': 0.381859940, + 'W': 1.778858854, + 'Y': 5.248216959}, + 'D': {'E': 6.603635331, + 'F': 0.005847063, + 'G': 0.999256440, + 'H': 0.818111764, + 'I': 0.002450023, + 'K': 0.019527840, + 'L': 0.002303981, + 'M': 0.005454653, + 'N': 8.760492724, + 'P': 0.027518471, + 'Q': 0.083338178, + 'R': 0.060872106, + 'S': 0.371726478, + 'T': 0.090462156, + 'V': 0.128207953, + 'W': 0.026936263, + 'Y': 0.186327964}, + 'E': {'F': 0.000332940, + 'G': 1.162715397, + 'H': 0.081141371, + 'I': 0.001254429, + 'K': 2.154178607, + 'L': 0.007547825, + 'M': 0.064939149, + 'N': 0.335733987, + 'P': 0.027495627, + 'Q': 2.018142888, + 'R': 0.094355832, + 'S': 0.097749730, + 'T': 0.095055175, + 'V': 0.216260840, + 'W': 0.062341360, + 'Y': 0.037356107}, + 'F': {'G': 0.015567812, + 'H': 0.173363873, + 'I': 0.516016404, + 'K': 0.010409040, + 'L': 2.403418258, + 'M': 0.123894544, + 'N': 0.010306990, + 'P': 0.070221272, + 'Q': 0.012628422, + 'R': 0.002480914, + 'S': 0.886724071, + 'T': 0.061992977, + 'V': 0.336159338, + 'W': 0.091906911, + 'Y': 3.987258869}, + 'G': {'H': 0.013333250, + 'I': 0.003122378, + 'K': 0.106373644, + 'L': 0.007030628, + 'M': 0.034441682, + 'N': 0.566906806, + 'P': 0.001858863, + 'Q': 0.042512974, + 'R': 0.292471121, + 'S': 1.247283002, + 'T': 0.008518897, + 'V': 0.442992767, + 'W': 0.258646022, + 'Y': 0.021047197}, + 'H': {'I': 0.022239982, + 'K': 0.176407082, + 'L': 0.148659568, + 'M': 0.024341794, + 'N': 2.462270432, + 'P': 0.679484957, + 'Q': 4.282731418, + 'R': 2.204734553, + 'S': 0.445289092, + 'T': 0.150502662, + 'V': 0.002759960, + 'W': 0.030616607, + 'Y': 9.175807849}, + 'I': {'K': 0.005826058, + 'L': 1.378981232, + 'M': 2.709083916, + 'N': 0.126395546, + 'P': 0.018484688, + 'Q': 0.004179090, + 'R': 0.001173176, + 'S': 0.044144989, + 'T': 2.439177342, + 'V': 13.505137483, + 'W': 0.001901139, + 'Y': 0.045429828}, + 'K': {'L': 0.022236492, + 'M': 0.440831666, + 'N': 2.458222646, + 'P': 0.141827239, + 'Q': 2.001704573, + 'R': 0.418858497, + 'S': 0.187506391, + 'T': 0.399752385, + 'V': 0.025253714, + 'W': 0.029389581, + 'Y': 0.062036726}, + 'L': {'M': 3.102547734, + 'N': 0.004523323, + 'P': 0.366808078, + 'Q': 0.251583659, + 'R': 0.078821913, + 'S': 0.440666821, + 'T': 0.173310893, + 'V': 0.856259068, + 'W': 0.186367593, + 'Y': 0.103344553}, + 'M': {'N': 0.036342261, + 'P': 0.030865929, + 'Q': 0.118300058, + 'R': 0.003339426, + 'S': 0.137172830, + 'T': 3.736804641, + 'V': 4.499323771, + 'W': 0.056840232, + 'Y': 0.079617041}, + 'N': {'P': 0.034476298, + 'Q': 0.392967027, + 'R': 0.153152691, + 'S': 3.854775171, + 'T': 0.865443188, + 'V': 0.013796204, + 'W': 0.006676502, + 'Y': 0.856969381}, + 'P': {'Q': 0.918408255, + 'R': 0.223106214, + 'S': 1.961394689, + 'T': 0.573808110, + 'V': 0.025768070, + 'W': 0.020008899, + 'Y': 0.071930063}, + 'Q': {'R': 3.170385554, + 'S': 0.243906624, + 'T': 0.113601661, + 'V': 0.010633046, + 'W': 0.124212157, + 'Y': 0.228833107}, + 'R': {'S': 0.135104164, + 'T': 0.028643193, + 'V': 0.037629734, + 'W': 0.558540630, + 'Y': 0.146342679}, + 'S': {'T': 2.845372128, + 'V': 0.058280963, + 'W': 0.144081245, + 'Y': 0.543166729}, + 'T': {'V': 1.317930337, 'W': 0.003186141, 'Y': 0.084368257}, + 'V': {'W': 0.047174761, 'Y': 0.028686374}, + 'W': {'Y': 0.288348205}, + 'Y': {}}; + +lfunction models.protein.mtVer.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.070820300} + {0.006814200} + {0.014793700} + {0.021495200} + {0.049775800} + {0.044240000} + {0.024231000} + {0.090735100} + {0.027381200} + {0.172310000} + {0.056194000} + {0.045209900} + {0.054386300} + {0.026340900} + {0.014049900} + {0.074421900} + {0.108810000} + {0.045853700} + {0.025652700} + {0.026484700}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + + + + + +///////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////// + + + + + + +/** + * @name models.protein.mtInv.ModelDescription + * @description Create the baseline schema (dictionary) for the mtInv model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtInv.ModelDescription(type) { + models.protein.mtInv.ModelDescription.model_definition = models.protein.empirical.ModelDescription(type); + models.protein.mtInv.ModelDescription.model_definition [terms.model.empirical_rates] = models.protein.mtInv.Rij; + models.protein.mtInv.ModelDescription.model_definition [terms.model.frequency_estimator] = "models.protein.mtInv.frequencies"; + return models.protein.mtInv.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtInvF.ModelDescription + * @description Create the baseline schema (dictionary) for the mtInv+F model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtInvF.ModelDescription(type) { + models.protein.mtInvF.ModelDescription.model_definition = models.protein.mtInv.ModelDescription(type); + models.protein.mtInvF.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.empirical.protein"; + models.protein.mtInvF.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies._20x1"); + return models.protein.mtInvF.ModelDescription.model_definition; +} + +/** + * @name models.protein.mtInvML.ModelDescription + * @description Create the baseline schema (dictionary) for the mtInv+ML model of protein evolution + * @returns {Dictionary} model description + * @param {String} type + */ +function models.protein.mtInvML.ModelDescription(type) { + models.protein.mtInvML.ModelDescription.model_definition = models.protein.mtInv.ModelDescription(type); + models.protein.mtInvML.ModelDescription.model_definition [terms.model.frequency_estimator] = "frequencies.ML.protein"; + models.protein.mtInvML.ModelDescription.model_definition [terms.model.efv_estimate_name] = utility.getGlobalValue("terms.frequencies.MLE"); + return models.protein.mtInvML.ModelDescription.model_definition; +} + + + + + +lfunction models.protein.mtInv.frequencies (model, namespace, datafilter) { + model[utility.getGlobalValue("terms.efv_estimate")] = + {{0.031742300} + {0.013570100} + {0.016149200} + {0.022311200} + {0.102287000} + {0.047847500} + {0.011641800} + {0.094322300} + {0.044438700} + {0.149407000} + {0.077262500} + {0.061579200} + {0.026290200} + {0.014644100} + {0.010900700} + {0.105939000} + {0.042869100} + {0.059540000} + {0.020701000} + {0.046556700}}; + + model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); + (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; + return model; +} + + +models.protein.mtInv.Rij = { +'A': {'C': 1.303664196, + 'D': 0.100963383, + 'E': 0.145240578, + 'F': 0.111082058, + 'G': 1.931555054, + 'H': 0.045194583, + 'I': 0.209390309, + 'K': 0.014824603, + 'L': 0.153999868, + 'M': 0.592865041, + 'N': 0.023989062, + 'P': 0.629532202, + 'Q': 0.090980805, + 'R': 0.074334248, + 'S': 3.368753997, + 'T': 3.327043094, + 'V': 2.751363323, + 'W': 0.026501482, + 'Y': 0.021939778}, + 'C': {'D': 0.058303817, + 'E': 0.047068481, + 'F': 0.887097368, + 'G': 0.883545442, + 'H': 0.341192032, + 'I': 0.287547623, + 'K': 0.004392613, + 'L': 0.381393652, + 'M': 0.461586134, + 'N': 0.279969535, + 'P': 0.069312754, + 'Q': 0.163006168, + 'R': 0.680712248, + 'S': 3.042785241, + 'T': 0.736861924, + 'V': 1.555397528, + 'W': 0.758572155, + 'Y': 1.342952521}, + 'D': {'E': 6.962512075, + 'F': 0.017157073, + 'G': 0.591216902, + 'H': 0.358935427, + 'I': 0.017124811, + 'K': 0.096074109, + 'L': 0.010524113, + 'M': 0.049089614, + 'N': 3.471724219, + 'P': 0.104690635, + 'Q': 0.204531494, + 'R': 0.070670691, + 'S': 0.505643623, + 'T': 0.141991554, + 'V': 0.088077428, + 'W': 0.071630793, + 'Y': 0.192760013}, + 'E': {'F': 0.027169135, + 'G': 0.599017534, + 'H': 0.217387680, + 'I': 0.020795072, + 'K': 1.172487361, + 'L': 0.033099609, + 'M': 0.189458658, + 'N': 1.159082937, + 'P': 0.120987665, + 'Q': 2.559966130, + 'R': 0.121635308, + 'S': 0.580233246, + 'T': 0.241928717, + 'V': 0.231186579, + 'W': 0.107622629, + 'Y': 0.137649701}, + 'F': {'G': 0.103612519, + 'H': 0.151813293, + 'I': 0.879509936, + 'K': 0.098766166, + 'L': 1.735139585, + 'M': 0.916540366, + 'N': 0.194205186, + 'P': 0.105108176, + 'Q': 0.052545530, + 'R': 0.015357913, + 'S': 0.398961745, + 'T': 0.121269565, + 'V': 0.534676938, + 'W': 0.478877081, + 'Y': 3.234682804}, + 'G': {'H': 0.064352370, + 'I': 0.024809865, + 'K': 0.156144417, + 'L': 0.050781964, + 'M': 0.207637181, + 'N': 0.551419960, + 'P': 0.028323528, + 'Q': 0.114080073, + 'R': 0.217695194, + 'S': 2.020141073, + 'T': 0.043791212, + 'V': 0.396428236, + 'W': 0.244698260, + 'Y': 0.072268144}, + 'H': {'I': 0.025529471, + 'K': 0.250219038, + 'L': 0.080842310, + 'M': 0.070807607, + 'N': 1.728635643, + 'P': 0.312042811, + 'Q': 4.708032587, + 'R': 1.283367123, + 'S': 0.368422409, + 'T': 0.270595612, + 'V': 0.008043438, + 'W': 0.081171898, + 'Y': 2.321702829}, + 'I': {'K': 0.100258581, + 'L': 2.159574141, + 'M': 2.830889408, + 'N': 0.310892314, + 'P': 0.070886418, + 'Q': 0.025100279, + 'R': 0.028420835, + 'S': 0.126690083, + 'T': 1.958518823, + 'V': 8.542592791, + 'W': 0.062889052, + 'Y': 0.177138386}, + 'K': {'L': 0.081982103, + 'M': 0.694473511, + 'N': 2.642320784, + 'P': 0.183146672, + 'Q': 1.933672947, + 'R': 1.631886026, + 'S': 0.879841219, + 'T': 0.511284083, + 'V': 0.056252096, + 'W': 0.106016378, + 'Y': 0.348477791}, + 'L': {'M': 3.494916570, + 'N': 0.075114649, + 'P': 0.154372954, + 'Q': 0.211473563, + 'R': 0.052763492, + 'S': 0.225488096, + 'T': 0.298279866, + 'V': 1.075873286, + 'W': 0.298463258, + 'Y': 0.161052695}, + 'M': {'N': 0.566990153, + 'P': 0.092516680, + 'Q': 0.397060932, + 'R': 0.022385994, + 'S': 0.633585504, + 'T': 2.192059537, + 'V': 1.509852775, + 'W': 0.254195761, + 'Y': 0.393193334}, + 'N': {'P': 0.224156858, + 'Q': 1.287189506, + 'R': 0.147604282, + 'S': 2.084470081, + 'T': 1.186265817, + 'V': 0.065420954, + 'W': 0.075398674, + 'Y': 1.139165497}, + 'P': {'Q': 0.581011465, + 'R': 0.130198061, + 'S': 1.042510137, + 'T': 0.746917102, + 'V': 0.162975938, + 'W': 0.059737849, + 'Y': 0.081395349}, + 'Q': {'R': 2.507738035, + 'S': 0.538789683, + 'T': 0.554297635, + 'V': 0.065221967, + 'W': 0.118046858, + 'Y': 0.476209531}, + 'R': {'S': 0.309426918, + 'T': 0.108593944, + 'V': 0.072153256, + 'W': 0.321740806, + 'Y': 0.182762575}, + 'S': {'T': 3.833300295, + 'V': 0.377288817, + 'W': 0.204318523, + 'Y': 0.345719707}, + 'T': {'V': 1.885339324, 'W': 0.049859223, 'Y': 0.174898703}, + 'V': {'W': 0.128598618, 'Y': 0.080346116}, + 'W': {'Y': 0.636664895}, + 'Y': {}}; \ No newline at end of file From 2dd82b5da381cb47c8ff014e2d8e6b0ab88c59e7 Mon Sep 17 00:00:00 2001 From: Steven Weaver Date: Thu, 14 Dec 2017 10:18:13 -0500 Subject: [PATCH 21/24] Removing stray matrices (#719) * removing stray rate and frequency matrices --- .../libv3/models/protein/empirical.bf | 524 ------------------ 1 file changed, 524 deletions(-) diff --git a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf index d8d94bde6..65c3968a6 100644 --- a/res/TemplateBatchFiles/libv3/models/protein/empirical.bf +++ b/res/TemplateBatchFiles/libv3/models/protein/empirical.bf @@ -86,9 +86,6 @@ lfunction models.protein.empirical._DefineQ(model_dict, namespace) { return model_dict; } - - - /** * @name models.protein.empirical._NormalizeEmpiricalRates * @param {Dictionary} model definition @@ -167,9 +164,6 @@ lfunction models.protein.empirical._NormalizeEmpiricalRates(model_dict, namespac } - - - /** * @name models.protein.empirical.DefineQMatrix * @param {Dictionary} modelSpec @@ -259,7 +253,6 @@ function models.protein.empirical.DefineQMatrix (modelSpec, namespace) { } - models.protein.empirical.default_generators = {"LG": "models.protein.LG.ModelDescription", "WAG": "models.protein.WAG.ModelDescription", "JTT": "models.protein.JTT.ModelDescription", @@ -291,15 +284,6 @@ models.protein.empirical.mleF_generators = {"LG": "models.protein.LGML.ModelDesc "HIVBm": "models.protein.HIVBmML.ModelDescription", "HIVWm": "models.protein.HIVWmML.ModelDescription"}; - - - - - - - - - /**************************************** LG functions *************************************/ @@ -431,8 +415,6 @@ function models.protein.JC69ML.ModelDescription(type) { return models.protein.JC69ML.ModelDescription.model_definition; } - - /**************************************** mtMAM functions *************************************/ @@ -476,8 +458,6 @@ function models.protein.mtMAMML.ModelDescription(type) { return models.protein.mtMAMML.ModelDescription.model_definition; } - - /**************************************** cpREV functions *************************************/ /** @@ -519,12 +499,8 @@ function models.protein.cpREVML.ModelDescription(type) { return models.protein.cpREVML.ModelDescription.model_definition; } - - /**************************************** AB functions *************************************/ - - /** * @name models.protein.AB.ModelDescription * @description Create the baseline schema (dictionary) for the AB model of protein evolution @@ -565,8 +541,6 @@ function models.protein.ABML.ModelDescription(type) { } - - /**************************************** mtMet functions *************************************/ @@ -701,501 +675,3 @@ function models.protein.gcpREVML.ModelDescription(type) { - - -/** - * @name models.protein.JTT.frequencies - * @param {Dictionary} Baseline JTT model - * @returns {Dictionary} Updated JTT model with empirical frequencies - * @description Define the empirical amino acid frequencies associated with the JTT model of protein evolution - */ -function models.protein.JTT.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.07686099999999986} - { 0.020279} - { 0.051269} - { 0.06182} - { 0.04053} - { 0.074714} - { 0.022983} - { 0.052569} - { 0.059498} - { 0.091111} - { 0.023414} - { 0.042546} - { 0.050532} - { 0.041061} - { 0.051057} - { 0.068225} - { 0.058518} - { 0.066374} - { 0.014336} - { 0.032303} - }; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - - - -/* Define a dictionary of amino-acid exchangeability rates for the JTT model of protein evolution. */ -models.protein.JTT.Rij = { - "A":{ - "C":0.01164983, - "D":0.04242226, - "E":0.06594220000000001, - "F":0.005605013, - "G":0.1300142, - "H":0.005055569, - "I":0.01901336, - "K":0.02198075, - "L":0.02824504, - "M":0.01099041, - "N":0.02373925, - "P":0.09902242999999999, - "Q":0.02285967, - "R":0.02714587, - "S":0.2651969, - "T":0.2681624, - "V":0.1940882, - "W":0.00120894, - "Y":0.004506008 - }, - "C":{ - "D":0.005415286, - "E":0.003332529, - "F":0.02749291, - "G":0.04082289, - "H":0.01666262, - "I":0.007914733, - "K":0.002915936, - "L":0.01499622, - "M":0.009581053000000001, - "N":0.01333012, - "P":0.006248431, - "Q":0.003749032, - "R":0.05207011, - "S":0.1470474, - "T":0.02749309, - "V":0.04123968, - "W":0.01582953, - "Y":0.06831603999999999 - }, - "D":{ - "E":0.4801284, - "F":0.001318116, - "G":0.0950686, - "H":0.0237263, - "I":0.00609632, - "K":0.01680615, - "L":0.005602049, - "M":0.004448682, - "N":0.2361102, - "P":0.006425849, - "Q":0.0214193, - "R":0.007908676, - "S":0.04020279, - "T":0.02487944, - "V":0.02092512, - "W":0.0008238323, - "Y":0.014664 - }, - "E":{ - "F":0.001776388, - "G":0.08335330000000001, - "H":0.005602518, - "I":0.005875793, - "K":0.1030317, - "L":0.008881953, - "M":0.004099415, - "N":0.02459647, - "P":0.009701838000000001, - "Q":0.1403343, - "R":0.01626078, - "S":0.02131682, - "T":0.01940362, - "V":0.03088188, - "W":0.001639765, - "Y":0.002049689 - }, - "F":{ - "G":0.003751538, - "H":0.01042113, - "I":0.04085083, - "K":0.00145895, - "L":0.2278042, - "M":0.01021273, - "N":0.003126321, - "P":0.00750314, - "Q":0.001875789, - "R":0.003334736, - "S":0.0644024, - "T":0.008128382, - "V":0.03939149, - "W":0.007711647, - "Y":0.1771572 - }, - "G":{ - "H":0.004635577, - "I":0.002826581, - "K":0.01605493, - "L":0.006331483, - "M":0.003052693, - "N":0.03290136, - "P":0.01051474, - "Q":0.009497159999999999, - "R":0.06941973, - "S":0.1278738, - "T":0.01854212, - "V":0.03120506, - "W":0.007801362, - "Y":0.001695907 - }, - "H":{ - "I":0.00955641, - "K":0.03124215, - "L":0.04925195, - "M":0.007718657, - "N":0.1712807, - "P":0.05770555, - "Q":0.2333939, - "R":0.1639271, - "S":0.0507224, - "T":0.02793385, - "V":0.008086143, - "W":0.001837774, - "Y":0.1889208 - }, - "I":{ - "K":0.01205203, - "L":0.2127567, - "M":0.1131285, - "N":0.0208902, - "P":0.004981443, - "Q":0.003213843, - "R":0.01221257, - "S":0.02763923, - "T":0.1494435, - "V":0.6328057, - "W":0.001928334, - "Y":0.009802181 - }, - "K":{ - "L":0.01334602, - "M":0.01462393, - "N":0.1076208, - "P":0.01093234, - "Q":0.1218169, - "R":0.333364, - "S":0.03237125, - "T":0.05650736, - "V":0.008234754, - "W":0.001277824, - "Y":0.002839562 - }, - "L":{ - "M":0.09030557, - "N":0.005841096, - "P":0.05358937, - "Q":0.0291124, - "R":0.01900652, - "S":0.04042405, - "T":0.01594697, - "V":0.1169137, - "W":0.007602722, - "Y":0.007788057 - }, - "M":{ - "N":0.0140708, - "P":0.008298109999999999, - "Q":0.0187608, - "R":0.02200785, - "S":0.01948259, - "T":0.1237496, - "V":0.2016795, - "W":0.002886323, - "Y":0.006133368 - }, - "N":{ - "P":0.006154998, - "Q":0.03156908, - "R":0.02303155, - "S":0.3450795, - "T":0.1375939, - "V":0.01092017, - "W":0.000397107, - "Y":0.02263447 - }, - "P":{ - "Q":0.06603124, - "R":0.03627542, - "S":0.1902389, - "T":0.06887338, - "V":0.01404214, - "W":0.001003017, - "Y":0.003677695 - }, - "Q":{ - "R":0.1542939, - "S":0.03744234, - "T":0.03065318, - "V":0.01193211, - "W":0.002468744, - "Y":0.008229024999999999 - }, - "R":{ - "S":0.06833079, - "T":0.03805319, - "V":0.01141599, - "W":0.01803412, - "Y":0.007610617 - }, - "S":{ - "T":0.2795782, - "V":0.02711589, - "W":0.004457448, - "Y":0.02030591 - }, - "T":{ - "V":0.0759305, - "W":0.00115485, - "Y":0.006495937 - }, - "V":{ - "W":0.003436295, - "Y":0.005345272 - }, - "W":{ - "Y":0.02415905 - } -}; - -//==================================================================================================================// - - - - - - - - - -lfunction models.protein.gcpREV.frequencies (model, namespace, datafilter) { - model[utility.getGlobalValue("terms.efv_estimate")] = - {{ 0.07951} - {0.009051} - {0.03322} - {0.049675} - {0.047731} - {0.080233} - {0.02188} - {0.080496} - {0.049324} - {0.107512} - {0.020776} - {0.040459} - {0.039916} - {0.037505} - {0.056001} - {0.07382} - {0.053615} - {0.071781} - {0.016705} - {0.03079}}; - - model[utility.getGlobalValue("terms.model.efv_estimate_name")] = utility.getGlobalValue("terms.frequencies.predefined"); - (model[utility.getGlobalValue("terms.parameters")])[utility.getGlobalValue("terms.model.empirical")] = 0; - return model; -} - -models.protein.gcpREV.Rij = { -'A': {'C': 699.39999999999998, - 'D': 87.700000000000003, - 'E': 288.30000000000001, - 'F': 59.299999999999997, - 'G': 677.89999999999998, - 'H': 32.0, - 'I': 39.5, - 'K': 78.299999999999997, - 'L': 33.799999999999997, - 'M': 197.09999999999999, - 'N': 59.100000000000001, - 'P': 505.80000000000001, - 'Q': 199.5, - 'R': 12.199999999999999, - 'S': 2443.9000000000001, - 'T': 1646.2, - 'V': 1143.8, - 'W': 30.0, - 'Y': 27.899999999999999}, - 'C': {'D': 125.3, - 'E': 102.40000000000001, - 'F': 1540.0999999999999, - 'G': 433.60000000000002, - 'H': 574.79999999999995, - 'I': 96.0, - 'K': 89.200000000000003, - 'L': 446.5, - 'M': 288.5, - 'N': 133.69999999999999, - 'P': 124.90000000000001, - 'Q': 195.09999999999999, - 'R': 1867.9000000000001, - 'S': 3029.8000000000002, - 'T': 516.79999999999995, - 'V': 722.20000000000005, - 'W': 562.60000000000002, - 'Y': 1571.2}, - 'D': {'E': 3638.6999999999998, - 'F': 15.9, - 'G': 464.80000000000001, - 'H': 527.70000000000005, - 'I': 16.800000000000001, - 'K': 78.299999999999997, - 'L': 8.6999999999999993, - 'M': 33.100000000000001, - 'N': 5083.8000000000002, - 'P': 43.600000000000001, - 'Q': 387.60000000000002, - 'R': 40.600000000000001, - 'S': 142.09999999999999, - 'T': 66.099999999999994, - 'V': 18.5, - 'W': 35.0, - 'Y': 272.10000000000002}, - 'E': {'F': 30.699999999999999, - 'G': 393.80000000000001, - 'H': 144.59999999999999, - 'I': 23.399999999999999, - 'K': 1870.9000000000001, - 'L': 26.800000000000001, - 'M': 33.299999999999997, - 'N': 230.90000000000001, - 'P': 39.399999999999999, - 'Q': 2965.3000000000002, - 'R': 51.899999999999999, - 'S': 156.69999999999999, - 'T': 230.0, - 'V': 103.8, - 'W': 57.200000000000003, - 'Y': 79.200000000000003}, - 'F': {'G': 10.1, - 'H': 87.200000000000003, - 'I': 354.39999999999998, - 'K': 9.0, - 'L': 1585.8, - 'M': 183.40000000000001, - 'N': 13.4, - 'P': 82.099999999999994, - 'Q': 10.699999999999999, - 'R': 26.100000000000001, - 'S': 790.5, - 'T': 29.800000000000001, - 'V': 180.59999999999999, - 'W': 558.29999999999995, - 'Y': 2360.1999999999998}, - 'G': {'H': 35.600000000000001, - 'I': 11.800000000000001, - 'K': 193.40000000000001, - 'L': 4.2999999999999998, - 'M': 11.800000000000001, - 'N': 446.5, - 'P': 11.800000000000001, - 'Q': 40.799999999999997, - 'R': 391.19999999999999, - 'S': 709.0, - 'T': 65.5, - 'V': 72.599999999999994, - 'W': 92.599999999999994, - 'Y': 20.600000000000001}, - 'H': {'I': 38.100000000000001, - 'K': 96.900000000000006, - 'L': 46.100000000000001, - 'M': 54.5, - 'N': 2156.8000000000002, - 'P': 185.09999999999999, - 'Q': 1889.5999999999999, - 'R': 1228.7, - 'S': 277.0, - 'T': 77.099999999999994, - 'V': 22.800000000000001, - 'W': 58.5, - 'Y': 4117.5}, - 'I': {'K': 125.7, - 'L': 1657.9000000000001, - 'M': 2493.4000000000001, - 'N': 146.0, - 'P': 63.100000000000001, - 'Q': 48.5, - 'R': 105.40000000000001, - 'S': 75.599999999999994, - 'T': 1227.2, - 'V': 6006.5, - 'W': 21.100000000000001, - 'Y': 35.799999999999997}, - 'K': {'L': 37.600000000000001, - 'M': 220.09999999999999, - 'N': 1930.8, - 'P': 49.799999999999997, - 'Q': 2571.1999999999998, - 'R': 4666.3999999999996, - 'S': 209.30000000000001, - 'T': 648.5, - 'V': 66.200000000000003, - 'W': 15.9, - 'Y': 84.200000000000003}, - 'L': {'M': 1389.5999999999999, - 'N': 11.6, - 'P': 347.69999999999999, - 'Q': 235.40000000000001, - 'R': 124.90000000000001, - 'S': 584.89999999999998, - 'T': 62.899999999999999, - 'V': 661.70000000000005, - 'W': 218.19999999999999, - 'Y': 82.0}, - 'M': {'N': 41.399999999999999, - 'P': 19.199999999999999, - 'Q': 341.80000000000001, - 'R': 112.09999999999999, - 'S': 32.899999999999999, - 'T': 1143.5, - 'V': 465.69999999999999, - 'W': 70.5, - 'Y': 41.100000000000001}, - 'N': {'P': 18.699999999999999, - 'Q': 827.79999999999995, - 'R': 313.0, - 'S': 2505.4000000000001, - 'T': 1373.3, - 'V': 27.600000000000001, - 'W': 19.899999999999999, - 'Y': 316.19999999999999}, - 'P': {'Q': 223.09999999999999, - 'R': 89.400000000000006, - 'S': 1154.5, - 'T': 322.80000000000001, - 'V': 75.5, - 'W': 18.5, - 'Y': 15.800000000000001}, - 'Q': {'R': 2321.3000000000002, - 'S': 246.90000000000001, - 'T': 128.5, - 'V': 50.200000000000003, - 'W': 24.600000000000001, - 'Y': 179.09999999999999}, - 'R': {'S': 269.60000000000002, - 'T': 173.40000000000001, - 'V': 62.0, - 'W': 257.80000000000001, - 'Y': 137.0}, - 'S': {'T': 2042.5, - 'V': 61.200000000000003, - 'W': 102.59999999999999, - 'Y': 501.89999999999998}, - 'T': {'V': 583.70000000000005, 'W': 22.0, 'Y': 64.599999999999994}, - 'V': {'W': 10.800000000000001, 'Y': 37.299999999999997}, - 'W': {'Y': 296.30000000000001}, - 'Y': {}}; \ No newline at end of file From 665aba3d74da7c932f58d1441330bb50f50b26c9 Mon Sep 17 00:00:00 2001 From: Sergei Kosakovsky Pond Date: Thu, 14 Dec 2017 12:37:38 -0500 Subject: [PATCH 22/24] Closes #720 --- src/mains/unix.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mains/unix.cpp b/src/mains/unix.cpp index d9a27a397..88132bf0d 100644 --- a/src/mains/unix.cpp +++ b/src/mains/unix.cpp @@ -39,6 +39,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #else #include #include + #include #define __HYPHY_HANDLE_TERM_SIGNAL__ #endif @@ -222,8 +223,12 @@ _String getLibraryPath() { #else pathNames&& &baseDir; - _String libDir = baseDir; + _String libDir = baseDir, + // see if baseDir/res exists + #endif + + // SW20141119: Check environment libpath and override default path if it exists // TODO: Move string to globals in v3 @@ -234,6 +239,15 @@ _String getLibraryPath() { if(hyphyPath.sLength != 0) { libDir = hyphyPath; } + } else { + _String tryLocal = baseDir & "res" & dirSlash; + + struct stat sb; + + if (stat((const char*)tryLocal, &sb) == 0 && S_ISDIR(sb.st_mode)) { + libDir = tryLocal; + } + } return libDir; From df26385d370b8ffcd82eadf60f5592d83795c9bb Mon Sep 17 00:00:00 2001 From: Sergei Kosakovsky Pond Date: Thu, 14 Dec 2017 12:49:09 -0500 Subject: [PATCH 23/24] Adding site-level log likelihood reports to LEISR.bf --- res/TemplateBatchFiles/LEISR.bf | 57 ++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/res/TemplateBatchFiles/LEISR.bf b/res/TemplateBatchFiles/LEISR.bf index 5afc3a82c..faf7b15fd 100644 --- a/res/TemplateBatchFiles/LEISR.bf +++ b/res/TemplateBatchFiles/LEISR.bf @@ -1,5 +1,6 @@ RequireVersion("2.3.5"); + LoadFunctionLibrary("libv3/UtilityFunctions.bf"); LoadFunctionLibrary("libv3/IOFunctions.bf"); LoadFunctionLibrary("libv3/stats.bf"); @@ -55,17 +56,14 @@ leisr.partitions_and_trees = trees.LoadAnnotatedTreeTopology.match_partitions (l leisr.partition_count = Abs (leisr.partitions_and_trees); leisr.filter_specification = alignments.DefineFiltersForPartitions (leisr.partitions_and_trees, "leisr.dataset" , "leisr.filter.", leisr.alignment_info); -// selection.io.json_store_key_value_pair (json, None, utility.getGlobalValue("terms.json.partitions"), -// filter_specification); - -// io.CheckAssertion ("leisr.partition_count==1", "This analysis can only handle a single partition"); - io.ReportProgressMessageMD ("relative_rates", "Data", "Input alignment description"); io.ReportProgressMessageMD ("relative_rates", "Data", "Loaded **" + leisr.alignment_info [terms.data.sequences] + "** sequences, **" + leisr.alignment_info [terms.data.sites] + "** sites, and **" + leisr.partition_count + "** partitions from \`" + leisr.alignment_info [terms.data.file] + "\`"); + + /*******************************************************************************************************************/ @@ -145,9 +143,10 @@ leisr.alignment_wide_MLES = estimators.FitSingleModel_Ext ( leisr.trees, leisr.baseline_model_desc, None, - Nome); - + {terms.run_options.retain_lf_object: TRUE}); +ConstructCategoryMatrix (leisr.site_level_log_likelihoods, ^(leisr.alignment_wide_MLES[terms.likelihood_function]), SITE_LOG_LIKELIHOODS); +DeleteObject (^(leisr.alignment_wide_MLES[terms.likelihood_function])); estimators.fixSubsetOfEstimates(leisr.alignment_wide_MLES, leisr.alignment_wide_MLES[terms.global]); @@ -169,20 +168,27 @@ io.ReportProgressMessageMD ("relative_rates", "overall", "" + (1+_part_) + ". " */ -leisr.table_screen_output = {{"Site", "Partition", "Rel. rate (MLE)", "95% profile likelihood CI"}}; -leisr.table_output_options = {terms.table_options.header : TRUE, terms.table_options.minimum_column_width : 16, terms.table_options.align : "center"}; +leisr.table_screen_output = {{"Site", "Partition", "Rel. rate (MLE)", "95% profile likelihood CI", "Log(L) global", "Log(L) local"}}; +leisr.table_output_options = {terms.table_options.header : TRUE, + terms.table_options.minimum_column_width : 16, + terms.table_options.align : "center"}; leisr.table_row_report = {{ "" + (1+((leisr.filter_specification[leisr.report.partition])[terms.data.coverage])[leisr.report.site]), leisr.report.partition + 1, Format(leisr.report.row[0],10,6), - Format(leisr.report.row[1],6,2) + " : " + Format(leisr.report.row[2],6,2) - }}; + Format(leisr.report.row[1],6,2) + " : " + Format(leisr.report.row[2],6,2), + Format (leisr.report.row[3], 6,3), + Format (leisr.report.row[4], 6,3) + }}; leisr.table_headers = {{"MLE", "Relative rate estimate at a site"} {"Lower", "Lower bound of 95% profile likelihood CI"} - {"Upper", "Upper bound of 95% profile likelihood CI"}}; + {"Upper", "Upper bound of 95% profile likelihood CI"} + {"LogL global", "Site log likelihood under the global (average rate) model fit"} + {"LogL local", "Site log likelihood under the local (site-specific rate) model fit"}}; + // set-up model for site-level fitting in the next couple of lines, where rv turned off leisr.site_model = model.generic.DefineModel("leisr.Baseline.ModelDescription", "leisr_site_model_instance", { @@ -270,11 +276,11 @@ for (leisr.partition_index = 0; leisr.partition_index < leisr.partition_count; l mpi.QueueComplete (leisr.queue); - leisr.partition_matrix = {Abs (leisr.site_results[leisr.partition_index]), 3}; // mle, lower, upper = 3 + leisr.partition_matrix = {Abs (leisr.site_results[leisr.partition_index]), 5}; // mle, lower, upper = 3 utility.ForEachPair (leisr.site_results[leisr.partition_index], "_key_", "_value_", ' - for (leisr.index = 0; leisr.index < 3; leisr.index += 1) { + for (leisr.index = 0; leisr.index < 5; leisr.index += 1) { leisr.partition_matrix [0+_key_][leisr.index] = _value_[leisr.index]; } ' @@ -385,14 +391,19 @@ lfunction leisr.handle_a_site (lf, filter_data, partition_index, pattern_info, m if (pattern_info [utility.getGlobalValue("terms.data.is_constant")]) { // the MLE for a constant site is 0; // only the CI is non-trivial - ^(utility.getGlobalValue("leisr.site_model_scaler_name")) = 0; + parameters.SetValue (^"leisr.site_model_scaler_name", 0); + results = {2,1}; + results[1][0] = estimators.ComputeLF (lf); } else { ^(utility.getGlobalValue("leisr.site_model_scaler_name")) = 1; Optimize (results, ^lf); } - return parameters.GetProfileCI (utility.getGlobalValue("leisr.site_model_scaler_name"), lf, 0.95); + profile = parameters.GetProfileCI (utility.getGlobalValue("leisr.site_model_scaler_name"), lf, 0.95); + profile[utility.getGlobalValue("terms.fit.log_likelihood")] = results[1][0]; + + return profile; } @@ -426,20 +437,22 @@ lfunction leisr.store_results (node, result, arguments) { utility.ForEach (pattern_info[utility.getGlobalValue("terms.data.sites")], "_site_index_", " //leisr.rate_estimates [_site_index_+1] = `&result`; - result_row = {1,3}; + + result_row = {1,5}; result_row [0] = (`&result`)[terms.fit.MLE]; result_row [1] = (`&result`)[terms.lower_bound]; result_row [2] = (`&result`)[terms.upper_bound]; - + result_row [3] = leisr.site_level_log_likelihoods[((leisr.filter_specification[`&partition_index`])[terms.data.coverage])[_site_index_]]; + result_row [4] = (`&result`)[terms.fit.log_likelihood]; leisr.report.echo (_site_index_, `&partition_index`, result_row); - /*fprintf (stdout, - io.FormatTableRow (result_row,leisr.table_output_options)); - */ - out_result_row = {1,3}; + + out_result_row = {1,5}; out_result_row[0] = (`&result`)[terms.fit.MLE]; out_result_row[1] = (`&result`)[terms.lower_bound]; out_result_row[2] = (`&result`)[terms.upper_bound]; + out_result_row[3] = result_row [3]; + out_result_row[4] = (`&result`)[terms.fit.log_likelihood]; (leisr.site_results[`&partition_index`])[_site_index_] = out_result_row; From 95cc99252cd0380ece3b495f81690ed3f923da74 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Fri, 15 Dec 2017 09:25:38 -0500 Subject: [PATCH 24/24] update LEISR version to reflect JSON change (#722) --- res/TemplateBatchFiles/LEISR.bf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/TemplateBatchFiles/LEISR.bf b/res/TemplateBatchFiles/LEISR.bf index faf7b15fd..b3786fa6d 100644 --- a/res/TemplateBatchFiles/LEISR.bf +++ b/res/TemplateBatchFiles/LEISR.bf @@ -31,7 +31,7 @@ utility.ToggleEnvVariable ("NORMALIZE_SEQUENCE_NAMES", 1); leisr.analysis_description = { terms.io.info: "LEISR (Likelihood Estimation of Individual Site Rates) infer relative amino-acid or nucleotide rates from a fixed nucleotide or amino-acid alignment and tree, with possibility for partitions. Relative site-specific substitution rates are inferred by first optimizing alignment-wide branch lengths, and then inferring a site-specific uniform tree scaler.", - terms.io.version: "0.3", + terms.io.version: "0.4", terms.io.reference: "Spielman, S.J. and Kosakovsky Pond, S.L. Relative evolutionary rate inference in HyPhy with LEISR. bioRxiv. https://doi.org/10.1101/206011. (2017); Pupko, T., Bell, R. E., Mayrose, I., Glaser, F. & Ben-Tal, N. Rate4Site: an algorithmic tool for the identification of functional regions in proteins by surface mapping of evolutionary determinants within their homologues. Bioinformatics 18, S71–S77 (2002).", terms.io.authors: "Sergei L Kosakovsky Pond and Stephanie J Spielman", terms.io.contact: "{spond,stephanie.spielman}@temple.edu"