Skip to content

Commit

Permalink
Merge pull request #1321 from veg/develop
Browse files Browse the repository at this point in the history
2.5.31rc
  • Loading branch information
spond committed Apr 13, 2021
2 parents 6db6c58 + d191f15 commit 54db307
Show file tree
Hide file tree
Showing 13 changed files with 267 additions and 65 deletions.
28 changes: 19 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(CMAKE_CONFIGURATION_TYPES Release)
option(NOAVX OFF)
option(NOSSE3 OFF)
option(NONEON OFF)
option(NOZLIB OFF)

#-------------------------------------------------------------------------------
# SSE MACROS
Expand Down Expand Up @@ -305,16 +306,25 @@ endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
# LIBCurl support
#-------------------------------------------------------------------------------
find_package(CURL)
if(${CURL_FOUND} AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(DEFAULT_LIBRARIES crypto curl ssl)
else(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(DEFAULT_LIBRARIES dl crypto curl ssl)
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
if(${CURL_FOUND})
#if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
# set(DEFAULT_LIBRARIES " crypto curl ssl")
#else(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
# set(DEFAULT_LIBRARIES "dl crypto curl ssl")
#endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
message(${CURL_LIBRARIES})
string(APPEND DEFAULT_LIBRARIES " " ${CURL_LIBRARIES})
add_definitions (-D__HYPHYCURL__)
endif(${CURL_FOUND} AND NOT APPLE)


endif(${CURL_FOUND})

if(NOT NOZLIB)
find_package(ZLIB 1.2.9)
if(${ZLIB_FOUND})
string(APPEND DEFAULT_LIBRARIES " " ${ZLIB_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS})
add_definitions (-D__ZLIB__)
endif(${ZLIB_FOUND})
endif(NOT NOZLIB)

#-------------------------------------------------------------------------------
# uninstall target
Expand Down
2 changes: 1 addition & 1 deletion res/TemplateBatchFiles/SelectionAnalyses/FEL.bf
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ selection.io.startTimer (fel.json [terms.json.timers], "FEL analysis", 2);
function fel.apply_proportional_site_constraint (tree_name, node_name, alpha_parameter, beta_parameter, alpha_factor, beta_factor, branch_length) {

fel.branch_length = (branch_length[terms.parameters.synonymous_rate])[terms.fit.MLE];

node_name = tree_name + "." + node_name;

ExecuteCommands ("
Expand Down
2 changes: 2 additions & 0 deletions res/TemplateBatchFiles/libv3/tasks/trees.bf
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ lfunction trees.KillZeroBranches (tree, estimates, branch_set, zero_internal) {
if ((estimates[branch])[^"terms.fit.MLE"] < 1e-10) {
zero_internal + branch;
}
} else {
zero_internal + branch;
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/core/batchlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ void _ElementaryCommand::ExecuteCase4 (_ExecutionList& chain) {

void _ElementaryCommand::ExecuteCase5 (_ExecutionList& chain) {
chain.currentCommand++;
FILE* df;
hyFile* df;
_String fName (*GetIthParameter(1));
_DataSet*ds;

Expand All @@ -2679,7 +2679,7 @@ void _ElementaryCommand::ExecuteCase5 (_ExecutionList& chain) {
}
SetStatusLine ("Loading Data");

df = doFileOpen (fName.get_str(),"rb");
df = hyFile::openFile (fName.get_str(),"rb");
if (df==nil) {
// try reading this file as a string formula
fName = GetStringFromFormula ((_String*)parameters(1),chain.nameSpacePrefix);
Expand All @@ -2689,15 +2689,18 @@ void _ElementaryCommand::ExecuteCase5 (_ExecutionList& chain) {
return;
}

df = doFileOpen (fName.get_str(),"rb");
df = hyFile::openFile (fName.get_str(),"rb");
if (df==nil) {
HandleApplicationError ((_String ("Could not find source dataset file ") & ((_String*)parameters(1))->Enquote('"')
& " (resolved to '" & fName & "')\nPath stack:\n\t" & GetPathStack ("\n\t")));
return;
}
}
ds = ReadDataSetFile (df,0,nil,nil,chain.nameSpacePrefix?chain.nameSpacePrefix->GetName():nil);
fclose (df);
if (df) {
df->close();
delete df;
}
}
}

Expand Down Expand Up @@ -5099,7 +5102,7 @@ void ReadBatchFile (_String& fName, _ExecutionList& target) {
FetchVar(LocateVarByName (optimizationPrecision))->SetValue(&precvalue);
#endif*/

FILE *f = doFileOpen (fName.get_str (), "rb");
hyFile *f = hyFile::openFile (fName.get_str (), "rb");
SetStatusLine ("Parsing File");
if (!f) {
HandleApplicationError (_String("Could not read batch file '") & fName & "'.\nPath stack:\n\t" & GetPathStack("\n\t"));
Expand All @@ -5112,8 +5115,9 @@ void ReadBatchFile (_String& fName, _ExecutionList& target) {
target.BuildList (source_file);
target.sourceFile = fName;
}
fclose (f);
f->close();
}
if (f) delete f;
}


Expand Down
41 changes: 21 additions & 20 deletions src/core/dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1614,15 +1614,15 @@ void FilterRawString (_String& s, FileState* fs, _DataSet & ds) {

//_________________________________________________________________________________________________

void ProcessTree (FileState *fState, FILE* f, _StringBuffer& CurrentLine) {
void ProcessTree (FileState *fState, hyFile * f, _StringBuffer& CurrentLine) {

// TODO SLKP 20180921 this does extra work to read in the tree string multiple times;
// the solution is to have a proper buffer wrapper, and to

class _MultilineBuffer : public _StringBuffer {
public:

_MultilineBuffer (_String const& current_line, FileState *fs, FILE* f) : _StringBuffer (current_line) {
_MultilineBuffer (_String const& current_line, FileState *fs, hyFile* f) : _StringBuffer (current_line) {
file_state = fs;
file = f;
}
Expand All @@ -1642,7 +1642,7 @@ void ProcessTree (FileState *fState, FILE* f, _StringBuffer& CurrentLine) {
}

FileState *file_state;
FILE * file;
hyFile * file;

};

Expand Down Expand Up @@ -1809,28 +1809,28 @@ bool SkipLine (_StringBuffer& theLine, FileState* fS) {


//_________________________________________________________
void ReadNextLine (FILE* fp, _StringBuffer *s, FileState* fs, bool, bool upCase) {
void ReadNextLine (hyFile * fp, _StringBuffer *s, FileState* fs, bool, bool upCase) {
_StringBuffer tempBuffer (1024L);

fs->currentFileLine ++;

char lastc;

if (fp) {
lastc = getc_unlocked (fp);
lastc = fp->getc();
} else {
lastc = fs->pInSrc<fs->theSource->length()?fs->theSource->char_at(fs->pInSrc++):0;
}


if (fs->fileType != 3) { // not NEXUS - do not skip [..]
if (fp)
while ( !feof_unlocked(fp) && lastc!=10 && lastc!=13 ) {
while ( !fp->feof() && lastc!=10 && lastc!=13 ) {
if (lastc) {
tempBuffer << lastc;
}

lastc = getc_unlocked(fp);
lastc = fp->getc();
}
else
while (lastc && lastc!=10 && lastc!=13 ) {
Expand All @@ -1843,7 +1843,7 @@ void ReadNextLine (FILE* fp, _StringBuffer *s, FileState* fs, bool, bool upCase)
lastc = toupper(lastc);
}

while (((fp&&(!feof_unlocked(fp)))||(fs->theSource&&(fs->pInSrc<=fs->theSource->length ()))) && lastc!='\r' && lastc!='\n') {
while (((fp&&!fp->feof())||(fs->theSource&&(fs->pInSrc<=fs->theSource->length ()))) && lastc!='\r' && lastc!='\n') {
if (lastc=='[') {
if (fs->isSkippingInNEXUS) {
ReportWarning ("Nested comments in NEXUS really shouldn't be used.");
Expand All @@ -1862,9 +1862,9 @@ void ReadNextLine (FILE* fp, _StringBuffer *s, FileState* fs, bool, bool upCase)

if (fp) {
if (upCase) {
lastc = toupper(fgetc(fp));
lastc = toupper(fp->getc());
} else {
lastc = getc_unlocked(fp);
lastc = fp->getc();
}
} else {
if (upCase) {
Expand All @@ -1883,7 +1883,7 @@ void ReadNextLine (FILE* fp, _StringBuffer *s, FileState* fs, bool, bool upCase)

tempBuffer.TrimSpace();

if ( (fp && feof_unlocked (fp)) || (fs->theSource && fs->pInSrc >= fs->theSource->length()) ) {
if ( (fp && fp->feof ()) || (fs->theSource && fs->pInSrc >= fs->theSource->length()) ) {
if (tempBuffer.empty ()) {
*s = "";
return;
Expand Down Expand Up @@ -1918,7 +1918,7 @@ void TrimPhylipLine (_String& CurrentLine, _DataSet& ds) {


//_________________________________________________________
_DataSet* ReadDataSetFile (FILE*f, char execBF, _String* theS, _String* bfName, _String* namespaceID, _TranslationTable* dT, _ExecutionList* ex) {
_DataSet* ReadDataSetFile (hyFile *f, char execBF, _String* theS, _String* bfName, _String* namespaceID, _TranslationTable* dT, _ExecutionList* ex) {

static const _String kNEXUS ("#NEXUS"),
kDefSeqNamePrefix ("Species");
Expand All @@ -1928,7 +1928,8 @@ _DataSet* ReadDataSetFile (FILE*f, char execBF, _String* theS, _String* bfName,

try {

if (f) flockfile (f);
//if (f) flockfile (f);
if (f) f->lock();

hy_env::EnvVariableSet(hy_env::data_file_tree_string, new _Matrix, false);

Expand Down Expand Up @@ -1971,13 +1972,13 @@ _DataSet* ReadDataSetFile (FILE*f, char execBF, _String* theS, _String* bfName,
fState.pInSrc = 0;
fState.theNamespace = namespaceID;

if (!(f||theS)) {
if (! f && !theS) {
throw _String ("ReadDataSetFile received null file AND string references. At least one must be specified");
}
// done initializing

if (f) {
rewind (f);
f->rewind ();
}

_StringBuffer CurrentLine;
Expand Down Expand Up @@ -2029,7 +2030,7 @@ _DataSet* ReadDataSetFile (FILE*f, char execBF, _String* theS, _String* bfName,
if (fState.fileType==1) { // PHYLIP
if ((filePosition<0)&&(fState.autoDetect)) {
filePosition = (f?
ftell (f)
f->tell ()
#ifdef __WINDOZE__
-1
#endif
Expand Down Expand Up @@ -2086,7 +2087,7 @@ _DataSet* ReadDataSetFile (FILE*f, char execBF, _String* theS, _String* bfName,
fState.autoDetect = true;

if(f) {
fseek (f, filePosition, SEEK_SET);
f->seek (filePosition, SEEK_SET);
} else {
fState.pInSrc = filePosition;
}
Expand Down Expand Up @@ -2228,7 +2229,7 @@ _DataSet* ReadDataSetFile (FILE*f, char execBF, _String* theS, _String* bfName,
{
_TranslationTable *trialTable = new _TranslationTable (hy_default_translation_table);
trialTable->baseLength = 2;
if (f) funlockfile (f);
if (f) f->unlock();
_DataSet * res2 = ReadDataSetFile (f, execBF, theS, bfName, namespaceID, trialTable);
if (res2->GetNoTypes()) {
DeleteObject (result);
Expand Down Expand Up @@ -2298,11 +2299,11 @@ _DataSet* ReadDataSetFile (FILE*f, char execBF, _String* theS, _String* bfName,
}
} catch (const _String& err) {
DeleteObject (result);
if (f) funlockfile (f);
if (f) f->unlock();
HandleApplicationError(err);
result = nil;
}
if (f) funlockfile (f);
if (f) f->unlock();
return result;
}

Expand Down

1 comment on commit 54db307

@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: 54db307 Previous: d191f15 Ratio
ABSREL-MH.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.