Skip to content

Commit 361fde3

Browse files
authored
Merge pull request #1926 from veg/develop
2.5.86
2 parents 87689d4 + f91c698 commit 361fde3

File tree

7 files changed

+82
-15
lines changed

7 files changed

+82
-15
lines changed

res/TemplateBatchFiles/SelectionAnalyses/RELAX.bf

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ LoadFunctionLibrary("libv3/models/codon/BS_REL.bf");
2525
LoadFunctionLibrary("libv3/convenience/math.bf");
2626
LoadFunctionLibrary("libv3/tasks/mpi.bf");
2727
LoadFunctionLibrary("libv3/models/rate_variation.bf");
28+
LoadFunctionLibrary("libv3/tasks/ancestral.bf");
29+
2830

2931

3032

@@ -179,7 +181,14 @@ namespace relax {
179181
LoadFunctionLibrary ("modules/grid_compute.ibf");
180182
}
181183

182-
KeywordArgument ("output", "Write the resulting JSON to this file (default is to save to the same path as the alignment file + 'RELAX.json')", relax.codon_data_info [terms.json.json]);
184+
185+
relax.default_output = relax.codon_data_info [terms.json.json];
186+
187+
if (relax.multiple_files) {
188+
relax.default_output = (relax.codon_data_info [relax.file_list[0]])[terms.json.json];
189+
}
190+
191+
KeywordArgument ("output", "Write the resulting JSON to this file (default is to save to the same path as the alignment file + 'RELAX.json')", relax.default_output);
183192

184193
relax.codon_data_info [terms.json.json] = io.PromptUserForFilePath ("Save the resulting JSON file to");
185194

@@ -1180,6 +1189,7 @@ function relax.FitMainTestPair (prompt) {
11801189
relax.stashLF = estimators.TakeLFStateSnapshot (relax.alternative_model.fit[terms.likelihood_function]);
11811190

11821191
} else {
1192+
io.ReportProgressMessageMD("RELAX", "alt-2", "> Restoring the original set of parameters (alternative optimization did not yield an improvement).");
11831193
estimators.RestoreLFStateFromSnapshot(relax.alternative_model.fit[terms.likelihood_function], relax.take1_snapshot);
11841194
}
11851195

@@ -1218,6 +1228,16 @@ function relax.FitMainTestPair (prompt) {
12181228
relax.distribution_for_json,
12191229
relax.display_orders[relax.alternative_name]
12201230
);
1231+
1232+
relax.json [^"terms.substitutions"] = {};
1233+
1234+
for (_partition_, _selection_; in; relax.selected_branches) {
1235+
relax.ancestral_info = ancestral.build (relax.alternative_model.fit[terms.likelihood_function],0+_partition_,FALSE);
1236+
(relax.json [^"terms.substitutions"] )[_partition_] = ancestral.ComputeCompressedSubstitutions (relax.ancestral_info);
1237+
DeleteObject (relax.ancestral_info);
1238+
}
1239+
1240+
12211241

12221242
selection.io.json_store_branch_attribute(relax.json, relax.alternative_name, terms.branch_length, relax.display_orders[relax.alternative_name],
12231243
0,
@@ -1231,9 +1251,15 @@ function relax.FitMainTestPair (prompt) {
12311251
relax.tree_ids = estimators.LFObjectGetTrees (relax.alternative_model.fit[terms.likelihood_function]);
12321252

12331253
estimators.RestoreLFStateFromSnapshot (relax.alternative_model.fit[terms.likelihood_function],relax.stashLF);
1254+
12341255

12351256
utility.ToggleEnvVariable ("KEEP_OPTIMAL_ORDER", TRUE);
12361257
relax.er_report.tagged_sites = {};
1258+
relax.json [terms.json.site_logl] = {};
1259+
relax.json [terms.json.evidence_ratios] = {};
1260+
(relax.json [terms.json.site_logl])[terms.json.unconstrained] = selection.ComputeSiteLikelihoods (relax.alternative_model.fit[terms.likelihood_function]);
1261+
1262+
12371263
for (_partition_, _selection_; in; relax.selected_branches) {
12381264

12391265

@@ -1254,10 +1280,8 @@ function relax.FitMainTestPair (prompt) {
12541280
relax.ll_by_branch = {};
12551281
relax.model_by_branch = {};
12561282

1257-
1283+
(relax.json [terms.json.site_logl])[_partition_] = {};
12581284
relax.altLL = relax.alternative_model.fit [terms.fit.log_likelihood];
1259-
relax.json [terms.json.site_logl] = {};
1260-
(relax.json [terms.json.site_logl])[terms.json.unconstrained] = selection.ComputeSiteLikelihoods (relax.alternative_model.fit[terms.likelihood_function]);
12611285

12621286
for (_b_,_ignore_; in; relax.tested_branches) {
12631287
GetString (relax._current_model, ^_b_, -5);
@@ -1272,22 +1296,21 @@ function relax.FitMainTestPair (prompt) {
12721296
SetParameter ( ^_b_ , MODEL, ^relax._current_model);
12731297
}
12741298

1275-
1276-
relax.json [terms.json.evidence_ratios] = {terms.json.by_branch : relax.ll_by_branch};
1299+
(relax.json [terms.json.evidence_ratios])[_partition_] = {terms.json.by_branch : relax.ll_by_branch};
12771300

12781301
for (_b_,_ignore_; in; relax.tested_branches) {
12791302
SetParameter ( ^_b_ , MODEL, ^relax.reference_model_namespace);
12801303
}
12811304
LFCompute (^(relax.alternative_model.fit[terms.likelihood_function]),LF_START_COMPUTE);
12821305
LFCompute (^(relax.alternative_model.fit[terms.likelihood_function]),relax.ll);
12831306
LFCompute (^(relax.alternative_model.fit[terms.likelihood_function]),LF_DONE_COMPUTE);
1284-
(relax.json [terms.json.site_logl])[terms.json.constrained] = selection.ComputeSiteLikelihoods (relax.alternative_model.fit[terms.likelihood_function]);
1307+
((relax.json [terms.json.site_logl])[_partition_])[terms.json.constrained] = selection.ComputeSiteLikelihoods (relax.alternative_model.fit[terms.likelihood_function]);
12851308

12861309
for (_b_,_ignore_; in; relax.tested_branches) {
12871310
SetParameter ( ^_b_ , MODEL, ^(relax.model_by_branch[_b_]));
12881311
}
12891312

1290-
(relax.json [terms.json.evidence_ratios])[terms.json.constrained] = selection.EvidenceRatios ( (relax.json [terms.json.site_logl])[terms.json.unconstrained], (relax.json [terms.json.site_logl])[terms.json.constrained]);
1313+
((relax.json [terms.json.site_logl])[_partition_])[terms.json.constrained] = selection.EvidenceRatios ((relax.json [terms.json.site_logl])[terms.json.unconstrained], ((relax.json [terms.json.site_logl])[_partition_])[terms.json.constrained]);
12911314

12921315

12931316

res/TemplateBatchFiles/libv3/tasks/genetic_code.bf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,21 @@ lfunction genetic_code.ComputeCodonCodeToStringMap(genCode) {
9191

9292
/*----------------------------------------------------------------------------------------------------------*/
9393

94+
lfunction genetic_code.ComputeStringToInteger (genCode) {
95+
_codonMap = {};
96+
_nucLetters = ^"genetic_code.nucleotides";
97+
_cidx = 0;
98+
for (_idx = 0; _idx < Columns(genCode); _idx += 1) {
99+
if (genCode[_idx] != ^ "genetic_code.stop_code") {
100+
_codonMap[(_nucLetters[_idx$16] + _nucLetters[(_idx % 16) $4] + _nucLetters[_idx % 4])] = _cidx;
101+
_cidx += 1;
102+
}
103+
}
104+
return _codonMap;
105+
}
106+
107+
/*----------------------------------------------------------------------------------------------------------*/
108+
94109
lfunction genetic_code.ComputeCodonCodeToStringMapStop (genCode) {
95110
_codonMap = {};
96111
_nucLetters = ^"genetic_code.nucleotides";

res/TemplateBatchFiles/libv3/tasks/trees.bf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,11 @@ lfunction trees.ParentMap (topology_object) {
660660
for (i,k; in; parent_nodes) {
661661
if (node_names / i) {
662662
if (k >= 0) {
663-
res[node_names[i]] = node_names[k];
663+
if (node_names / k) {
664+
res[node_names[i]] = node_names[k];
665+
} else {
666+
res[node_names[i]] = "root";
667+
}
664668
} else {
665669
res[node_names[i]] = None;
666670
}

src/core/global_things.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ _String const kEmptyString, kPromptForFilePlaceholder("PROMPT_FOR_FILE"),
115115
"\"ENV=TOLERATE_NUMERICAL_ERRORS=1;\" as the command line "
116116
"argument. This often resolves the issue, which is "
117117
"indicative of numerical instability."),
118-
kHyPhyVersion = _String("2.5.85"),
118+
kHyPhyVersion = _String("2.5.86"),
119119

120120
kNoneToken = "None", kNullToken = "null",
121121
kNoKWMatch = "__input_value_not_given__",

src/core/matrix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4474,7 +4474,7 @@ void _Matrix::Multiply(_Matrix &storage, _Matrix const &secondArg) const
44744474
__m256d value_op = _mm256_set1_pd(value);
44754475

44764476
#ifdef _SLKP_USE_FMA3_INTRINSICS
4477-
#define CELL_OP(x) \
4477+
#define CELL_OP_2(x) \
44784478
_mm256_storeu_pd(res + x, \
44794479
_mm256_fmadd_pd(value_op, _mm256_loadu_pd(secArg + x), \
44804480
_mm256_loadu_pd(res + x)))

src/core/topology.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,16 @@ _List _TreeTopology::RemoveANode(HBLObjectRef nodeName) {
747747
} else {
748748
throw _String("Matrix-valued argument was expected to contain strings");
749749
}
750+
} else if (nodeName->ObjectClass() == ASSOCIATIVE_LIST) {
751+
_AssociativeList *names = (_AssociativeList *)nodeName;
752+
for (AVLListXLIteratorKeyValue key_value : names->ListIterator()) {
753+
HBLObjectRef var_value = (HBLObjectRef)key_value.get_object();
754+
if (var_value->ObjectClass() == STRING) {
755+
RemoveNodeByName((_FString *)var_value);
756+
}
757+
}
758+
clean_indices.Sort();
759+
_RemoveNodeList(clean_indices);
750760
} else {
751761
throw _String(
752762
"An invalid argument (not a string or a string matrix) supplied");

src/mains/unix.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,17 @@ _String getLibraryPath() {
254254
_String baseDir(buffer);
255255
baseDir.Trim(0, baseDir.FindBackwards(dirSlash, 0, -1) - 1L);
256256
#else
257-
char curWd[_HYPHY_MAX_PATH_LENGTH];
258-
getcwd(curWd, _HYPHY_MAX_PATH_LENGTH);
257+
char *curWd = (char *)malloc(_HYPHY_MAX_PATH_LENGTH);
258+
if (!curWd || !getcwd(curWd, _HYPHY_MAX_PATH_LENGTH)) {
259+
fprintf(stderr,
260+
"Failed to get current working directory path; possibly because it "
261+
"is longer than %ld characters",
262+
_HYPHY_MAX_PATH_LENGTH);
263+
exit(1);
264+
}
259265

260266
_String baseDir(curWd);
267+
free(curWd);
261268
#endif
262269

263270
ensure_trailing_dirSlash(baseDir);
@@ -814,12 +821,20 @@ int main(int argc, char *argv[]) {
814821
printf ("%ld\n", sscanf (" 0.1e2 beavis", "%lf%n", &value, &read));
815822
*/
816823

817-
char curWd[4096], dirSlash = get_platform_directory_char();
824+
char *curWd = (char *)malloc(4096), dirSlash = get_platform_directory_char();
818825

819-
getcwd(curWd, 4096);
826+
if (!curWd || !getcwd(curWd, 4096)) { // failed to get cwd
827+
fprintf(stderr,
828+
"Failed to get current working directory path; possibly because it "
829+
"is longer than %d characters",
830+
4096);
831+
return 1;
832+
}
820833

821834
_String baseDir(curWd);
822835

836+
free(curWd);
837+
823838
auto ensure_trailing_dirSlash = [&dirSlash](auto &str) {
824839
if (str.get_char(str.length() - 1) != dirSlash) {
825840
str = str & dirSlash;

0 commit comments

Comments
 (0)