Skip to content

Commit

Permalink
Merge pull request #1138 from veg/develop
Browse files Browse the repository at this point in the history
2.5.10 rc
  • Loading branch information
spond authored Apr 23, 2020
2 parents 466f29f + 994c79c commit 82a171b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 46 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,6 @@ add_test (BGM HYPHYMP tests/hbltests/libv3/BGM.wbf)
add_test (CONTRAST-FEL HYPHYMP tests/hbltests/libv3/CFEL.wbf)
add_test (GARD HYPHYMP tests/hbltests/libv3/GARD.wbf)
add_test (FADE HYPHYMP tests/hbltests/libv3/FADE.wbf)
add_test (ABSREL HYPHYMP tests/hbltests/libv3/aBSREL.wbf)
add_test (ABSREL-MH HYPHYMP tests/hbltests/libv3/aBSREL-MH.wbf)
add_test (NAME ABSREL COMMAND HYPHYMP tests/hbltests/libv3/ABSREL.wbf)
add_test (NAME ABSREL-MH COMMAND HYPHYMP tests/hbltests/libv3/ABSREL-MH.wbf)

4 changes: 4 additions & 0 deletions res/TemplateBatchFiles/libv3/models/codon/MG_REV.bf
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ function models.codon.MG_REV.set_branch_length(model, value, parameter) {
}
} else {
models.codon.MG_REV.set_branch_length.lp = 0;


if (parameters.IsIndependent(models.codon.MG_REV.set_branch_length.alpha.p)) {
Eval(models.codon.MG_REV.set_branch_length.alpha.p + ":=(" + value[terms.model.branch_length_scaler] + ")*" + value[terms.branch_length]);
models.codon.MG_REV.set_branch_length.lp += 1;

}

if (parameters.IsIndependent(models.codon.MG_REV.set_branch_length.beta.p)) {
Eval(models.codon.MG_REV.set_branch_length.beta.p + ":=(" + value[terms.model.branch_length_scaler] + ")*" + value[terms.branch_length]);
models.codon.MG_REV.set_branch_length.lp += 1;
Expand Down
2 changes: 1 addition & 1 deletion res/TemplateBatchFiles/libv3/models/parameters.bf
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ lfunction parameters.IsIndependent(parameter) {

GetString(info, ^ parameter, -1);

if (Type(info) == "AssociativeList") {
if (Type(info) == "AssociativeList") {
return (utility.CheckKey(info, "Local", "Matrix") && utility.CheckKey(info, "Global", "Matrix")) == FALSE;
}
return TRUE;
Expand Down
63 changes: 22 additions & 41 deletions res/TemplateBatchFiles/libv3/tasks/estimators.bf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ LoadFunctionLibrary("../models/model_functions.bf");
LoadFunctionLibrary("../models/DNA/GTR.bf");
LoadFunctionLibrary("../convenience/regexp.bf");
LoadFunctionLibrary("mpi.bf");
LoadFunctionLibrary("libv3/convenience/math.bf");
LoadFunctionLibrary("libv3/all-terms.bf");


Expand Down Expand Up @@ -44,6 +45,21 @@ lfunction estimators.RestoreLFStateFromSnapshot(lf_id, snapshot) {
}
}

lfunction estimators.ConstrainAndRunLRT (lf_id, constraint) {
savedMLES = estimators.TakeLFStateSnapshot (lf_id);
currentLL = estimators.ComputeLF (lf_id);

df = Call (constraint, TRUE);
Optimize (res, ^lf_id);
lrt = math.DoLRT (res[1][0],currentLL,df);

estimators.RestoreLFStateFromSnapshot (lf_id, savedMLES);

Call (constraint, FALSE);

return lrt;
}

/**
* @name estimators.GetGlobalMLE
* @param {Dictionary} results
Expand Down Expand Up @@ -445,6 +461,7 @@ function estimators.ApplyExistingEstimatesToTree (_tree_name, model_descriptions
_set_branch_length_to[terms.branch_length] = _existing_estimate[terms.fit.MLE];
_set_branch_length_to[terms.model.branch_length_scaler] = _application_type;
keep_track_of_proportional_scalers[_application_type] = 1;

}
}
}
Expand Down Expand Up @@ -525,45 +542,6 @@ function estimators.ApplyExistingEstimates(likelihood_function_id, model_descrip



/*
ExecuteCommands("GetInformation (estimators.ApplyExistingEstimates.map, `_tree_name`);");
estimators.ApplyExistingEstimates.branch_names = Rows(estimators.ApplyExistingEstimates.map);

for (estimators.ApplyExistingEstimates.b = 0; estimators.ApplyExistingEstimates.b < Abs(estimators.ApplyExistingEstimates.map); estimators.ApplyExistingEstimates.b += 1) {
_branch_name = estimators.ApplyExistingEstimates.branch_names[estimators.ApplyExistingEstimates.b];

if ((initial_values[terms.branch_length])[estimators.ApplyExistingEstimates.i] / _branch_name) { // have an entry for this branch name
_existing_estimate = ((initial_values[terms.branch_length])[estimators.ApplyExistingEstimates.i])[_branch_name];

if (Type(_existing_estimate) == "AssociativeList") {
_set_branch_length_to = (((initial_values[terms.branch_length])[estimators.ApplyExistingEstimates.i])[_branch_name])[terms.fit.MLE];
if (None != branch_length_conditions) {
if (Abs(branch_length_conditions)) {
_application_type = branch_length_conditions[estimators.ApplyExistingEstimates.i];

if (Type(_application_type) == "String") {
if (_application_type == terms.model.branch_length_constrain ) {
estimators.ApplyExistingEstimates.df_correction += estimators.constrainBranchLength(_tree_name, _branch_name, model_descriptions[estimators.ApplyExistingEstimates.map[_branch_name]], _set_branch_length_to);
continue;
}
_set_branch_length_to = {};
_set_branch_length_to[terms.branch_length] = _existing_estimate[terms.fit.MLE];
_set_branch_length_to[terms.model.branch_length_scaler] = _application_type;
estimators.ApplyExistingEstimates.keep_track_of_proportional_scalers[_application_type] = 1;
}
}
}

estimators.ApplyExistingEstimates.df_correction += estimators.applyBranchLength(_tree_name, _branch_name, model_descriptions[estimators.ApplyExistingEstimates.map[_branch_name]], _set_branch_length_to);
} else {
if (Type(_existing_estimate) != "Unknown") {
warning.log ("Incorrect type for the initial values object of for branch '" + _branch_name + "' : " + _existing_estimate);
}
}
}

}*/

} else {
if (Type((initial_values[terms.branch_length])[estimators.ApplyExistingEstimates.i]) != "Unknown") {
warning.log ("Incorrect type for the initial values object for partition " + estimators.ApplyExistingEstimates.i
Expand Down Expand Up @@ -1099,17 +1077,20 @@ lfunction estimators.FitCodonModel(codon_data, tree, generator, genetic_code, op
/**
now replicate the local constraint for individual branches
*/



alpha = model.generic.GetLocalParameter(mg_rev, utility.getGlobalValue("terms.parameters.synonymous_rate"));
beta = model.generic.GetLocalParameter(mg_rev, utility.getGlobalValue("terms.parameters.nonsynonymous_rate"));
io.CheckAssertion("None!=`&alpha` && None!=`&beta`", "Could not find expected local synonymous and non-synonymous rate parameters in \`estimators.FitMGREV\`");
io.CheckAssertion("None!=`&alpha` && None!=`&beta`", "Could not find expected local synonymous and non-synonymous rate parameters in \`estimators.FitMGREV\`");

apply_constraint: = component_tree + "." + node_name + "." + beta + ":=" + component_tree + "." + node_name + "." + alpha + "*" + new_globals[branch_map[node_name]];

for (i = 0; i < components; i += 1) {
component_tree = lf_components[2 * i + 1];
ClearConstraints( * component_tree);
branch_map = (option[utility.getGlobalValue("terms.run_options.partitioned_omega")])[i];


component_branches = BranchName( * component_tree, -1);
for (j = 0; j < Columns(component_branches) - 1; j += 1) {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/global_things.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace hy_global {
kErrorStringDatasetRefIndexError ("Dataset index reference out of range"),
kErrorStringMatrixExportError ("Export matrix called with a non-polynomial matrix argument"),
kErrorStringNullOperand ("Attempting to operate on an undefined value; this is probably the result of an earlier 'soft' error condition"),
kHyPhyVersion = _String ("2.5.9"),
kHyPhyVersion = _String ("2.5.10"),

kNoneToken = "None",
kNullToken = "null",
Expand Down
3 changes: 2 additions & 1 deletion src/core/topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ _AssociativeList* _TreeTopology::MainTreeConstructor (_String const& parms,
lastNode = nodeStack.countitems ()-1;
parentNode = (node<long>*)nodeStack.get (lastNode);
if (mapping) {
_FString * mapped_name = (_FString*)mapping->GetByKey (nodeName, STRING);
_FString * mapped_name = (_FString*)mapping->GetByKey (nodeName.ChangeCase(kStringUpperCase), STRING);
if (mapped_name) {
//printf ("%s => %s\n", nodeName.get_str(), mapped_name->get_str().get_str());
nodeName = _String (mapped_name->get_str());
}
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 82a171b

Please sign in to comment.