Skip to content

Commit

Permalink
Fix a bug that caused internal errors when doing multi-partition opti…
Browse files Browse the repository at this point in the history
…mizations; minor improvements
  • Loading branch information
spond committed Sep 14, 2022
1 parent a79e78a commit 1190e19
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 39 deletions.
2 changes: 1 addition & 1 deletion res/TemplateBatchFiles/SelectionAnalyses/BUSTED.bf
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ busted.multi_hit = io.SelectAnOption ({

if (busted.do_srv) {
KeywordArgument ("syn-rates", "The number alpha rate classes to include in the model [1-10, default 3]", busted.synonymous_rate_classes);
busted.synonymous_rate_classes = io.PromptUser ("The number omega rate classes to include in the model", busted.synonymous_rate_classes, 1, 10, TRUE);
busted.synonymous_rate_classes = io.PromptUser ("The number alpha rate classes to include in the model [1-10, default 3]", busted.synonymous_rate_classes, 1, 10, TRUE);
}

KeywordArgument ("grid-size", "The number of points in the initial distributional guess for likelihood fitting", 250);
Expand Down
7 changes: 1 addition & 6 deletions src/core/classes.cp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ template <class node_data> node<node_data>* node<node_data>::duplicate_tree(void

//-------------------------------------------------------------

template <class node_data> void node_count_descendants (node<node_data>* source, node<node_data>* n) {
template <class node_data> void node_count_descendants (node<node_data>* , node<node_data>* n) {
if (n->get_num_nodes() == 0) {
n->in_object = 1L;
} else {
Expand Down Expand Up @@ -314,15 +314,13 @@ template <class node_data> int node<node_data>::tree_depth(void)
template <class node_data>
node<node_data>* NodeTraverser (node<node_data>* root)
{
static int going_up;
static node<node_data>* laststep;
node<node_data>* curstep, *crashdummy;

if (root)
{
laststep = root;
while ((crashdummy = laststep->go_down(1))) laststep = crashdummy;
going_up = false;
return laststep;
}

Expand All @@ -332,11 +330,9 @@ node<node_data>* NodeTraverser (node<node_data>* root)
{
curstep=crashdummy;
while ((crashdummy = curstep->go_down(1))) curstep = crashdummy;
going_up = false;
return laststep = curstep;
}
curstep=curstep->get_parent();
going_up = true;
laststep = curstep;
return curstep;
}
Expand All @@ -363,7 +359,6 @@ template <class node_data> void node<node_data>::replace_node(node<node_data>* e

//-----------------------------------Set Number 1----------------
template <class node_data> int node<node_data>::get_child_num() {
int num_siblings;
if (parent) {
if (this == parent->one) return 1;
if (this == parent->two) return 2;
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 @@ -122,7 +122,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.41"),
kHyPhyVersion = _String ("2.5.42"),

kNoneToken = "None",
kNullToken = "null",
Expand Down
6 changes: 3 additions & 3 deletions src/core/include/batchlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class _ExecutionList: public _List // a sequence of commands to be executed
_String* FetchFromStdinRedirect (_String const * dialog_tag = nil, bool handle_multi_choice = false, bool do_echo = false);

_ElementaryCommand* FetchLastCommand (void) {
if (currentCommand - 1 < lLength && currentCommand > 0) {
return (_ElementaryCommand*)(*this)(currentCommand - 1);
if (currentCommand - 1L < (long)lLength && currentCommand > 0L) {
return (_ElementaryCommand*)(*this)(currentCommand - 1L);
}
return nil;
}
Expand All @@ -135,7 +135,7 @@ class _ExecutionList: public _List // a sequence of commands to be executed
}

void GoToLastInstruction (void) {
currentCommand = MAX(currentCommand,lLength-1);
currentCommand = MAX(currentCommand,(long)lLength-1L);
}

_StringBuffer const GenerateHelpMessage (_AVLList * scanned_functions = nil) const;
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class _DataSet : public _List // a complete data set
_String *GetSequenceCharacters(long seqID) const;

bool SetSequenceName(long index, _String *new_name) {
if (index >= 0L && index < theNames.lLength) {
if (index >= 0L && index < (long)theNames.lLength) {
theNames.Replace(index, new_name, false);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/include/hy_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class _String : public BaseObj {
- SLKP 20170517 reviewed while porting from v3 branch
*/
virtual char get_char(long index) const {
if (index >= 0L && index < s_length) {
if (index >= 0L && index < (long)s_length) {
return s_data[index];
}
return _String::default_return;
Expand Down Expand Up @@ -1130,7 +1130,7 @@ class _String : public BaseObj {
bool do_escape = false;
char quote_state = '\0';

while (current_position < s_length) {
while (current_position < (long)s_length) {
char this_char = s_data[current_position];
if (do_escape) {
do_escape = false;
Expand Down
4 changes: 2 additions & 2 deletions src/core/include/likefunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ class _CustomFunction: public _LikelihoodFunction {
_CustomFunction (const _String& , _VariableContainer const * context = nil);

virtual hyFloat Compute (void);
virtual void RescanAllVariables (bool obtain_variable_mapping = false) {}
virtual void RescanAllVariables (bool = false) {}
virtual void SerializeLF (_StringBuffer& res, char=0, _SimpleList* = nil, _SimpleList* = nil) {
res.AppendNewInstance ((_String*)myBody.toStr(kFormulaStringConversionNormal));
}
Expand Down Expand Up @@ -774,7 +774,7 @@ FindLikeFuncByName (_String&);

template <typename ACTION>
void DoForEachLikelihoodFunction (ACTION cb) {
for (long i = 0; i < likeFuncNamesList.lLength; i++) {
for (unsigned long i = 0UL; i < likeFuncNamesList.lLength; i++) {
if (((_String*)likeFuncNamesList.GetItem(i))->nonempty()) {
cb ((_LikelihoodFunction*)likeFuncList.GetItem (i), i);
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ class _List:public _SimpleList {
_List result;
if (endAt < 0) {
endAt = lLength;
} else if (endAt > lLength) {
} else if (endAt > (long)lLength) {
endAt = lLength;
}
for (unsigned long i = startAt; i<endAt; i++) {
for (long i = startAt; i<endAt; i++) {
result < mapper ( ((BaseRef*)(list_data))[i], i );
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class _Matrix: public _MathObject {
return hDim;
}

bool check_dimension (unsigned long rows, unsigned long columns) const {
bool check_dimension (long rows, long columns) const {
return hDim == rows && vDim == columns;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/include/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void DeleteTreeVariable (long, _SimpleList&, _String * prefix = nil, bool

template <typename ACTION>
void DoForEachVariable(ACTION do_this) {
for (long i = 0; i < variablePtrs.lLength; i++) {
for (unsigned long i = 0; i < variablePtrs.lLength; i++) {
_Variable * ith_var = (_Variable *)variablePtrs.GetItem (i);
if (ith_var) {
do_this (ith_var, i);
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class _Vector: public _Matrix
virtual BaseRef makeDynamic (void) const; // duplicate this object into a dynamic copy
virtual void Duplicate (BaseRefConst); // duplicate an object from reference

virtual void Clear (void);
virtual void Clear (bool complete = true);

virtual unsigned long GetHDim (void) const {
if (is_column) {
Expand Down
9 changes: 8 additions & 1 deletion src/core/likefunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4401,6 +4401,7 @@ _Matrix* _LikelihoodFunction::Optimize (_AssociativeList const * options)
}
ConjugateGradientDescent(precision, bestSoFar, true);
}
//_TerminateAndDump("CHECK ME");
#if !defined __UNIX__ || defined __HEADLESS__
#ifdef __HYPHYMPI__
if (hy_mpi_node_rank == 0) {
Expand Down Expand Up @@ -4934,6 +4935,7 @@ _Matrix* _LikelihoodFunction::Optimize (_AssociativeList const * options)
BufferToConsole (buffer);
StringToConsole (*GetIthIndependentVar(current_index)->GetName());
BufferToConsole (CheckEqual(GetIthIndependentBound (current_index, true), cj)? ("[Lower bound]") : (CheckEqual(GetIthIndependentBound (current_index, false),cj) ? "[Upper bound]" : ""));

}
#if defined __UNIX__ && ! defined __HEADLESS__ && !defined __HYPHYQT__ && !defined __HYPHY_GTK__
else if (verbosity_level==1) {
Expand Down Expand Up @@ -8424,7 +8426,12 @@ bool _LikelihoodFunction::HasPartitionChanged (long index) {
//return LocateVar(value)->HasChanged();
return (LocateVar(value)->varFlags & HY_VARIABLE_CHANGED);
}
);
) || ListAny (*(_SimpleList*)depVarsByPartition(index),
[] (const long value, const unsigned long index) -> bool {
//return LocateVar(value)->HasChanged();
return (LocateVar(value)->HasChanged());
}
);

}

Expand Down
4 changes: 2 additions & 2 deletions src/core/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ void _Vector::operator << (const _SimpleList& list) {

/*--------------------------------------------------------------------------------------------------------------------------------*/

void _Vector::Clear (void) {
_Matrix::Clear();
void _Vector::Clear (bool complete_clear) {
_Matrix::Clear(complete_clear);
ZeroUsed();
vDim = 1UL;
}
Expand Down
17 changes: 2 additions & 15 deletions src/mains/unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,7 @@ const char hy_help_message [] =
"Run a custom analysis and pass it some arguments \n\thyphy path/to/hyphy.script argument1 'argument 2' \n"
;

const char hy_available_cli_analyses [] =
"Available standard analyses and their [standard analysis name] are listed below:\n\n"
" [meme] Test for episodic site-level selection using MEME (Mixed Effects Model of Evolution).\n"
" [contrast-fel] Use a FEL method to test which sites in a gene may be associated with adaptation to a different environment.\n"
" [fel] Test for pervasive site-level selection using FEL (Fixed Effects Likelihood).\n"
" [fubar] Test for pervasive site-level selection using FUBAR (Fast Unconstrained Bayesian AppRoximation for inferring selection).\n"
" [fade] Test a protein alignment for directional selection towards specific amino acids along a specified set of test branches using FADE (a FUBAR Approach to Directional Evolution).\n"
" [slac] Test for pervasive site-level selection using SLAC (Single Likelihood Ancestor Counting).\n"
" [busted] Test for episodic gene-wide selection using BUSTED (Branch-site Unrestricted Statistical Test of Episodic Diversification).\n"
" [bgm] Apply Bayesian Graphical Model inference to substitution histories at individual sites.\n"
" [absrel] Test for lineage-specific evolution using the branch-site method aBS-REL (Adaptive Branch-Site Random Effects Likelihood).\n"
" [relax] Test for relaxation of selection pressure along a specified set of test branches using RELAX (a random effects test of selection relaxation).\n"
" [gard] Screen an alignment for recombination using GARD (Genetic Algorithm for Recombination Detection).\n\n"
;



#ifdef _MINGW32_MEGA_
Expand Down Expand Up @@ -567,7 +554,7 @@ void ProcessKWStr (_String const & conf, _String const & conf2, _AssociativeL
(*(_AssociativeList*)existing_value) < _associative_list_key_value {nil, new _FString (conf2)};
} else {
_AssociativeList * replacement_list = new _AssociativeList;
(*replacement_list) << _associative_list_key_value {nil, existing_value} < _associative_list_key_value {nil, new _FString (conf2)};
((*replacement_list) << _associative_list_key_value {nil, existing_value}) < _associative_list_key_value {nil, new _FString (conf2)};
kwargs.MStore(key, replacement_list, false);
}
} else {
Expand Down

1 comment on commit 1190e19

@kjlevitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Benchmark.js Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 1190e19 Previous: 04b391a Ratio
GARD.wbf Infinity secs/op (±0.000000%) null secs/op (±0.000000%) Infinity

This comment was automatically generated by workflow using github-action-benchmark.

CC: @klevitz

Please sign in to comment.