[med-svn] [Git][med-team/hyphy][master] 6 commits: d/watch: Fix watch regex
Nilesh Patra (@nilesh)
gitlab at salsa.debian.org
Wed May 12 15:26:06 BST 2021
Nilesh Patra pushed to branch master at Debian Med / hyphy
Commits:
78bfd023 by Nilesh Patra at 2021-05-12T18:59:32+05:30
d/watch: Fix watch regex
- - - - -
0af13b84 by Nilesh Patra at 2021-05-12T18:59:42+05:30
New upstream version 2.5.31+dfsg
- - - - -
9af24f3e by Nilesh Patra at 2021-05-12T18:59:53+05:30
Update upstream source from tag 'upstream/2.5.31+dfsg'
Update to upstream version '2.5.31+dfsg'
with Debian dir f83cd1b96a1e89b077d5196dbf2f4f8e13aadac7
- - - - -
847656cf by Nilesh Patra at 2021-05-12T19:02:52+05:30
Refresh patches
- - - - -
b30fed74 by Nilesh Patra at 2021-05-12T19:49:13+05:30
d/p/use_debian_sqlite.patch: Check for existence of ZLIB *after* DEFAULT_LIBRARIES have been set
- - - - -
3340c404 by Nilesh Patra at 2021-05-12T19:49:49+05:30
Interim changelog entry
- - - - -
25 changed files:
- CMakeLists.txt
- debian/changelog
- debian/patches/rm_arch_specific_flags.patch
- debian/patches/use_debian_sqlite.patch
- debian/watch
- res/TemplateBatchFiles/GARD.bf
- res/TemplateBatchFiles/SelectionAnalyses/FEL.bf
- res/TemplateBatchFiles/SelectionAnalyses/FitMultiModel.bf
- res/TemplateBatchFiles/SelectionAnalyses/MEME.bf
- res/TemplateBatchFiles/libv3/models/codon/MG_REV.bf
- res/TemplateBatchFiles/libv3/tasks/alignments.bf
- res/TemplateBatchFiles/libv3/tasks/estimators.bf
- res/TemplateBatchFiles/libv3/tasks/trees.bf
- src/core/batchlan.cpp
- src/core/dataset.cpp
- src/core/dataset_filter.cpp
- src/core/global_things.cpp
- src/core/include/dataset.h
- src/core/include/dataset_filter.h
- src/core/include/global_things.h
- src/core/include/hy_string_buffer.h
- src/core/likefunc.cpp
- src/core/nexus.cpp
- src/core/string_buffer.cpp
- tests/hbltests/UnitTests/HBLCommands/DataSet.bf
Changes:
=====================================
CMakeLists.txt
=====================================
@@ -3,6 +3,7 @@ project(HyPhy)
cmake_policy(VERSION 3.0.0)
enable_testing()
+#enable_language(Fortran)
set(CMAKE_CONFIGURATION_TYPES Release)
@@ -13,6 +14,7 @@ set(CMAKE_CONFIGURATION_TYPES Release)
option(NOAVX OFF)
option(NOSSE3 OFF)
option(NONEON OFF)
+option(NOZLIB OFF)
#-------------------------------------------------------------------------------
# SSE MACROS
@@ -304,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
=====================================
debian/changelog
=====================================
@@ -1,17 +1,20 @@
-hyphy (2.5.29+dfsg-1) UNRELEASED; urgency=medium
-
- WARNING: new upstream version while in freeze, avoid upload to unstable before
- the release of Debian Bullseye.
- * Team upload.
+hyphy (2.5.31+dfsg-1) UNRELEASED; urgency=medium
[ Michael R. Crusoe ]
- * New upstream version
* Removed spelling patch, it was merged upstream
+ [ Étienne Mollier ]
+ * Remove d/*.maintscriptsL: these have been brought in
+ the earlier release of hyphy 2.5.28+dfsg-3
+
[ Nilesh Patra ]
- * Update email
+ * d/watch: Fix watch regex
+ * New upstream version 2.5.31+dfsg
+ * d/p/*.patch: Refresh patches
+ * d/p/use_debian_sqlite.patch: Check for existence of
+ ZLIB *after* DEFAULT_LIBRARIES have been set
- -- Michael R. Crusoe <crusoe at debian.org> Thu, 25 Feb 2021 17:43:11 +0100
+ -- Nilesh Patra <nilesh at debian.org> Wed, 12 May 2021 19:00:22 +0530
hyphy (2.5.28+dfsg-3) unstable; urgency=medium
=====================================
debian/patches/rm_arch_specific_flags.patch
=====================================
@@ -5,9 +5,9 @@ Forwarded: not-needed
Last-Update: 2020-09-28
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---- hyphy.orig/CMakeLists.txt
-+++ hyphy/CMakeLists.txt
-@@ -181,9 +181,8 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -183,9 +183,8 @@
#set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -fopt-info")
if(NOAVX)
@@ -18,7 +18,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
else(NOSSE3)
PCL_CHECK_FOR_SSE3()
if(${HAVE_SSE3_EXTENSIONS})
-@@ -194,7 +193,7 @@
+@@ -196,7 +195,7 @@
else(NOAVX)
PCL_CHECK_FOR_AVX()
if(${HAVE_AVX_EXTENSIONS})
@@ -27,7 +27,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
add_definitions (-D_SLKP_USE_AVX_INTRINSICS)
PCL_CHECK_FOR_FMA3()
if (${HAVE_FMA3})
-@@ -219,7 +218,7 @@
+@@ -221,7 +220,7 @@
set(DEFAULT_COMPILE_FLAGS "-fsigned-char -O3 ")
if(NOAVX)
if(NOSSE3)
@@ -36,7 +36,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
else(NOSSE3)
PCL_CHECK_FOR_SSE3()
if(${HAVE_SSE3_EXTENSIONS})
-@@ -230,7 +229,7 @@
+@@ -232,7 +231,7 @@
else(NOAVX)
PCL_CHECK_FOR_AVX()
if(${HAVE_AVX_EXTENSIONS})
=====================================
debian/patches/use_debian_sqlite.patch
=====================================
@@ -6,9 +6,9 @@ Reviewed-by: Étienne Mollier <etienne.mollier at mailoo.org>
Last-Update: 2020-09-24
Forwarded: not-needed
---- hyphy.orig/CMakeLists.txt
-+++ hyphy/CMakeLists.txt
-@@ -146,12 +146,11 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -148,12 +148,11 @@
file(GLOB SRC_CONTRIB src/contrib/*.cpp)
set(SRC_LINK src/lib/link/THyPhy.cpp)
@@ -22,9 +22,25 @@ Forwarded: not-needed
set_source_files_properties(${SRC_CORE} ${SRC_NEW} {SRC_UTILS} PROPERTIES COMPILE_FLAGS "-Weffc++ -Wextra -Wall")
#-------------------------------------------------------------------------------
-@@ -313,6 +312,35 @@
+@@ -317,15 +316,6 @@
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
+ #-------------------------------------------------------------------------------
+@@ -348,6 +338,45 @@
+ )
+ endif(NOT NODE)
+#-------------------------------------------------------------------------------
+# check for Debian packaged sqlite
@@ -55,10 +71,20 @@ Forwarded: not-needed
+ set(DEFAULT_LIBRARIES dl pthread crypto curl ssl sqlite3)
+ set(SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
+endif()
-
++
++# Check for existence of ZLIB *after* DEFAULT_LIBRARIES have been set
++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)
#-------------------------------------------------------------------------------
-@@ -347,11 +375,6 @@
+ # setup some source properties so that we don't spam stdout
+@@ -358,11 +387,6 @@
)
set_property(
@@ -70,7 +96,7 @@ Forwarded: not-needed
SOURCE src/core/calcnode2.cpp
APPEND_STRING PROPERTY COMPILE_FLAGS " -fstrict-aliasing -funroll-loops"
)
-@@ -371,7 +394,6 @@
+@@ -382,7 +406,6 @@
src/core/include
src/contrib
src/lib/Link src/new/include
=====================================
debian/watch
=====================================
@@ -1,4 +1,4 @@
version=4
opts="repacksuffix=+dfsg,dversionmangle=s/\+dfsg//g,repack,compression=xz" \
- https://github.com/veg/hyphy/releases .*/archive/v*(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz)
+ https://github.com/veg/hyphy/releases .*/archive/.*/v*(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz)
=====================================
res/TemplateBatchFiles/GARD.bf
=====================================
@@ -212,6 +212,8 @@ Will resume search from the end of the previous run.
}
}
+
+
gard.defaultFitFilePath = (gard.alignment[terms.data.file] + '.best-gard');
KeywordArgument ("output-lf", "Write the best fitting HyPhy analysis snapshot to (default is to save to the same path as the alignment file + 'best-gard')", gard.defaultFitFilePath);
gard.lfFileLocation = io.PromptUserForFilePath ("Save the HyPhy analysis snapshot to");
@@ -428,7 +430,7 @@ namespace gard {
bestOverallModelSoFar = {1, startWithBP};
for (i, v; in; json["breakpointData"]) {
- if (i < startWithBP) {
+ if (+i < startWithBP) {
bestOverallModelSoFar[+i] = +(v['bps'])[1];
}
}
=====================================
res/TemplateBatchFiles/SelectionAnalyses/FEL.bf
=====================================
@@ -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 ("
=====================================
res/TemplateBatchFiles/SelectionAnalyses/FitMultiModel.bf
=====================================
@@ -451,9 +451,17 @@ if (fitter.do_islands) {
if (utility.Array1D (fitter.callout)) {
// reconstruct ancestors here
-
+
+ fitter.site2partition = {};
+ fitter.ancestral_caches = {};
+ for (index, partition; in; fitter.filter_specification) {
+ for (site_index, site; in; partition[terms.data.coverage]) {
+ fitter.site2partition [site] = {{index__,site_index__}};
+ }
+ fitter.ancestral_caches [index] = ancestral.build (fitter.three_hit_results[terms.likelihood_function], +index, None);
+ }
fitter.site_reports = {};
- fitter.ancestral_cache = ancestral.build (fitter.three_hit_results[terms.likelihood_function], 0, None);
+
io.ReportProgressMessageMD ("fitter", "sites", "" + utility.Array1D (fitter.callout) + " individual " + io.SingularOrPlural (utility.Array1D (fitter.callout) , "site", "sites") + " which showed sufficiently strong preference for multiple-hit models");
fitter.table_output_options = {
@@ -489,8 +497,10 @@ if (utility.Array1D (fitter.callout)) {
fitter.table_output_options[utility.getGlobalValue("terms.table_options.header")] = FALSE;
utility.ForEachPair (fitter.callout, "_site_", "_value_", "
+
+ _site_map_ = fitter.site2partition [_site_];
- fitter.site_reports [_site_] = (ancestral.ComputeSubstitutionBySite (fitter.ancestral_cache, +_site_, None))[terms.substitutions];
+ fitter.site_reports [_site_] = (ancestral.ComputeSubstitutionBySite ((fitter.ancestral_caches[_site_map_[0]]), +(_site_map_[1]), None))[terms.substitutions];
if (fitter.do_islands) {
fprintf(stdout, io.FormatTableRow(
=====================================
res/TemplateBatchFiles/SelectionAnalyses/MEME.bf
=====================================
@@ -511,6 +511,8 @@ function meme.apply_proportional_site_constraint.fel (tree_name, node_name, alph
node_name = tree_name + "." + node_name;
ExecuteCommands ("
+ `node_name`.`alpha_parameter` :< 1e10;
+ `node_name`.`beta_parameter` :< 1e10;
`node_name`.`alpha_parameter` := (`alpha_factor`) * meme.branch_length__;
`node_name`.`beta_parameter` := (`beta_factor`) * meme.branch_length__;
");
@@ -524,6 +526,9 @@ function meme.apply_proportional_site_constraint.bsrel (tree_name, node_name, al
node_name = tree_name + "." + node_name;
ExecuteCommands ("
+ `node_name`.`alpha_parameter` :< 1e10;
+ `node_name`.`beta_parameter2` :< 1e10;
+ `node_name`.`beta_parameter` :< 1e10;
`node_name`.`alpha_parameter` := (`alpha_factor`) * meme.branch_length__;
`node_name`.`beta_parameter` := (`omega_factor`) * `node_name`.`alpha_parameter`;
`node_name`.`beta_parameter2` := (`beta_factor`) * meme.branch_length__;
@@ -734,10 +739,16 @@ lfunction meme.handle_a_site (lf_fel, lf_bsrel, filter_data, partition_index, pa
if (^"meme.site_beta_plus" > ^"meme.site_alpha" && ^"meme.site_mixture_weight" < 0.999999) {
+ /*
+ if (^"meme.site_tree_bsrel.aipysurusLaevis.alpha" > 10000) {
+ Export (lfe, ^lf_bsrel);
+ console.log (lfe);
+ }
+ */
+
LFCompute (^lf_bsrel,LF_START_COMPUTE);
LFCompute (^lf_bsrel,baseline);
-
-
+
for (_node_name_; in; ^bsrel_tree_id) {
if (((^"meme.selected_branches") [partition_index])[_node_name_] == utility.getGlobalValue("terms.tree_attributes.test")) {
@@ -747,16 +758,7 @@ lfunction meme.handle_a_site (lf_fel, lf_bsrel, filter_data, partition_index, pa
}
}
- /*utility.ForEach (^bsrel_tree_id, "_node_name_",
- '
- if ((meme.selected_branches [^"`&partition_index`"])[_node_name_] == utility.getGlobalValue("terms.tree_attributes.test")) {
- _node_name_res_ = meme.compute_branch_EBF (^"`&lf_bsrel`", ^"`&bsrel_tree_id`", _node_name_, ^"`&baseline`");
- (^"`&branch_ebf`")[_node_name_] = _node_name_res_[utility.getGlobalValue("terms.empirical_bayes_factor")];
- (^"`&branch_posterior`")[_node_name_] = _node_name_res_[utility.getGlobalValue("terms.posterior")];
- }
- '
- );*/
-
+
LFCompute (^lf_bsrel,LF_DONE_COMPUTE);
^"meme.site_beta_plus" := ^"meme.site_alpha";
=====================================
res/TemplateBatchFiles/libv3/models/codon/MG_REV.bf
=====================================
@@ -142,10 +142,12 @@ function models.codon.MG_REV.set_branch_length(model, value, parameter) {
if ( null != models.codon.MG_REV.set_branch_length.beta && null != models.codon.MG_REV.set_branch_length.alpha) {
+
models.codon.MG_REV.set_branch_length.alpha.p = parameter + "." + models.codon.MG_REV.set_branch_length.alpha;
models.codon.MG_REV.set_branch_length.beta.p = parameter + "." + models.codon.MG_REV.set_branch_length.beta;
if (Type(value) == "AssociativeList") {
+
if (value[terms.model.branch_length_scaler] == terms.model.branch_length_constrain) {
if (parameters.IsIndependent(models.codon.MG_REV.set_branch_length.alpha.p)) {
if (Abs(model[terms.parameters.synonymous_rate]) == 0) {
@@ -173,11 +175,12 @@ 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)) {
=====================================
res/TemplateBatchFiles/libv3/tasks/alignments.bf
=====================================
@@ -103,6 +103,7 @@ lfunction alignments.ReadNucleotideDataSet_aux(dataset_name) {
partitions = Transpose(dfpm);
}
}
+
return {
utility.getGlobalValue("terms.data.sequences"): Eval("`dataset_name`.species"),
=====================================
res/TemplateBatchFiles/libv3/tasks/estimators.bf
=====================================
@@ -772,17 +772,6 @@ lfunction estimators.FitLF(data_filter, tree, model_map, initial_values, model_o
can_do_restarts = null;
-
-
- //Export (lfe, likelihoodFunction);
- //console.log (lfe);
- //GetString (lfe, likelihoodFunction, -1);
- //console.log (lfe);
- //fprintf ("/Users/sergei/Desktop/busted.txt", CLEAR_FILE, lfe);
- //utility.ToggleEnvVariable("VERBOSITY_LEVEL", 10);
-
-
-
if (utility.Has (run_options, utility.getGlobalValue("terms.search_grid"),"AssociativeList")) {
grid_results = mpi.ComputeOnGrid (&likelihoodFunction, run_options [utility.getGlobalValue("terms.search_grid")], "mpi.ComputeOnGrid.SimpleEvaluator", "mpi.ComputeOnGrid.ResultHandler");
@@ -1176,7 +1165,7 @@ lfunction estimators.FitCodonModel(codon_data, tree, generator, genetic_code, op
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) {
/**
=====================================
res/TemplateBatchFiles/libv3/tasks/trees.bf
=====================================
@@ -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;
}
}
}
=====================================
src/core/batchlan.cpp
=====================================
@@ -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;
@@ -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);
@@ -2689,7 +2689,7 @@ 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")));
@@ -2697,7 +2697,10 @@ void _ElementaryCommand::ExecuteCase5 (_ExecutionList& chain) {
}
}
ds = ReadDataSetFile (df,0,nil,nil,chain.nameSpacePrefix?chain.nameSpacePrefix->GetName():nil);
- fclose (df);
+ if (df) {
+ df->close();
+ delete df;
+ }
}
}
@@ -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"));
@@ -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;
}
=====================================
src/core/dataset.cpp
=====================================
@@ -1614,7 +1614,7 @@ 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
@@ -1622,7 +1622,7 @@ void ProcessTree (FileState *fState, FILE* f, _StringBuffer& CurrentLine) {
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;
}
@@ -1642,7 +1642,7 @@ void ProcessTree (FileState *fState, FILE* f, _StringBuffer& CurrentLine) {
}
FileState *file_state;
- FILE * file;
+ hyFile * file;
};
@@ -1809,7 +1809,7 @@ 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 ++;
@@ -1817,7 +1817,7 @@ void ReadNextLine (FILE* fp, _StringBuffer *s, FileState* fs, bool, bool upCase)
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;
}
@@ -1825,12 +1825,12 @@ void ReadNextLine (FILE* fp, _StringBuffer *s, FileState* fs, bool, bool upCase)
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 ) {
@@ -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.");
@@ -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) {
@@ -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;
@@ -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");
@@ -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);
@@ -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;
@@ -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
@@ -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;
}
@@ -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);
@@ -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;
}
=====================================
src/core/dataset_filter.cpp
=====================================
@@ -870,6 +870,20 @@ _List * _DataSetFilter::ComputePatternToSiteMap (void) const {
return result;
}
+//_______________________________________________________________________
+
+_SimpleList const _DataSetFilter::SitesForPattern (unsigned long pattern_id) const {
+ _SimpleList result;
+
+ for (unsigned long s = 0UL; s < duplicateMap.lLength; s++) {
+ if (duplicateMap.get(s) == pattern_id) {
+ result << s;
+ }
+ }
+
+ return result;
+}
+
//_______________________________________________________________________
=====================================
src/core/global_things.cpp
=====================================
@@ -54,6 +54,7 @@
#endif
#endif
+
#include <time.h>
#include <float.h>
#include <signal.h>
@@ -121,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.29"),
+ kHyPhyVersion = _String ("2.5.31"),
kNoneToken = "None",
kNullToken = "null",
@@ -672,10 +673,20 @@ namespace hy_global {
char str[] = "\n";
fwrite (str, 1, 1, hy_message_log_file);
- fwrite (message.get_str(), 1, message.length(), hy_message_log_file);
+ fwrite (message.get_str(), 1, message.length(), hy_message_log_file);
fflush (hy_message_log_file);
#endif
}
+
+ //____________________________________________________________________________________
+ void ReportWarningConsole (_String const message) {
+ if (has_terminal_stdout) {
+ NLToConsole();
+ BufferToConsole("***WARNING***\n");
+ StringToConsole(message);
+ NLToConsole();
+ }
+ }
//____________________________________________________________________________________
void HandleOrStoreApplicationError (_String* error_string, _String const & message) {
@@ -978,4 +989,128 @@ namespace hy_global {
return true;
}
+ //____________________________________________________________________________________
+ hyFile* hyFile::openFile (const char * file_path, const char * mode , bool error, long buffer) {
+ hyFile* f = new hyFile;
+#ifdef __ZLIB__
+ if (file_path) {
+ f->_fileReference = gzopen (file_path, mode);
+ if (!f->_fileReference && error) {
+ HandleApplicationError (_String("Could not open file '") & *file_path & "' with mode '" & *mode & "'.");
+ }
+ }
+#else
+ f->_fileReference = doFileOpen(file_path, mode, error);
+#endif
+ if (!f->_fileReference ) {
+ delete f;
+ f = nil;
+ }
+ return f;
+
+ }
+
+ //____________________________________________________________________________________
+ void hyFile::close (void) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ gzclose (_fileReference);
+ #else
+ fclose (_fileReference);
+ #endif
+ _fileReference = NULL;
+ }
+ }
+
+ //____________________________________________________________________________________
+ void hyFile::lock (void) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ //gzclose (_fileReference);
+ #else
+ flockfile (_fileReference);
+ #endif
+ }
+ }
+
+ //____________________________________________________________________________________
+ void hyFile::unlock (void) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ //gzclose (_fileReference);
+ #else
+ funlockfile (_fileReference);
+ #endif
+ }
+ }
+
+ //____________________________________________________________________________________
+ void hyFile::rewind (void) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ gzrewind (_fileReference);
+ #else
+ ::rewind (_fileReference);
+ #endif
+ }
+ }
+
+ //____________________________________________________________________________________
+ void hyFile::seek (long pos, int whence) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ gzseek (_fileReference, pos, whence);
+ #else
+ fseek (_fileReference, pos, whence);
+ #endif
+ }
+ }
+
+ //____________________________________________________________________________________
+
+ size_t hyFile::tell (void) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ return gztell (_fileReference);
+ #else
+ return ftell (_fileReference);
+ #endif
+ }
+ return 0;
+ }
+ //____________________________________________________________________________________
+ bool hyFile::feof (void) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ return gzeof (_fileReference);
+ #else
+ return feof_unlocked (_fileReference);
+ #endif
+ }
+ return true;
+ }
+ //____________________________________________________________________________________
+ int hyFile::getc (void) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ return gzgetc (_fileReference);
+ #else
+ return getc_unlocked (_fileReference);
+ #endif
+ }
+ return 0;
+ }
+
+ //____________________________________________________________________________________
+ unsigned long hyFile::read (void* buffer, unsigned long size, unsigned long items) {
+ if (valid()) {
+ #ifdef __ZLIB__
+ return gzfread (buffer, size, items, _fileReference);
+ #else
+ return ::fread (buffer, size, items, _fileReference);
+ #endif
+ }
+ return 0;
+ }
+
} // namespace close
=====================================
src/core/include/dataset.h
=====================================
@@ -162,7 +162,7 @@ public:
_SimpleList const &DuplicateMap(void) const { return theMap; }
friend class _DataSetFilter;
- friend _DataSet *ReadDataSetFile(FILE *, char, _String *, _String *,
+ friend _DataSet *ReadDataSetFile(hyFile *, char, _String *, _String *,
_String *, _TranslationTable *,
_ExecutionList *);
friend long ProcessLine(_String &s, FileState *fs, _DataSet &ds);
@@ -200,17 +200,17 @@ private:
bool useHorizontalRep;
};
-void ReadNextLine(FILE *fp, _StringBuffer *s, FileState *fs, bool append = false,
+void ReadNextLine(hyFile *fp, _StringBuffer *s, FileState *fs, bool append = false,
bool upCase = true);
-_DataSet *ReadDataSetFile(FILE *, char = 0, _String * = nil, _String * = nil,
+_DataSet *ReadDataSetFile(hyFile *, char = 0, _String * = nil, _String * = nil,
_String * = nil,
_TranslationTable * = &hy_default_translation_table,
_ExecutionList *target = nil);
bool StoreADataSet(_DataSet *, _String *);
-void ReadNexusFile (FileState& fState, FILE*f, _DataSet& result);
+void ReadNexusFile (FileState& fState, hyFile*f, _DataSet& result);
extern _StringBuffer nexusBFBody;
=====================================
src/core/include/dataset_filter.h
=====================================
@@ -302,6 +302,12 @@ public:
* have the same pattern in the original alignment
*/
+ _SimpleList const SitesForPattern(unsigned long) const;
+
+ /**
+ * return a list of sites matching a given pattern
+ */
+
template<typename SOURCE_TYPE, typename TARGET_TYPE> void PatternToSiteMapper(SOURCE_TYPE const* source, TARGET_TYPE * target, long padup, TARGET_TYPE filler) const {
=====================================
src/core/include/global_things.h
=====================================
@@ -53,7 +53,11 @@
#include <stdio.h>
#ifdef __HYPHYMPI__
-#include <mpi.h>
+ #include <mpi.h>
+#endif
+
+#ifdef __ZLIB__
+ #include <zlib.h>
#endif
class _Variable; // forward decl
@@ -121,6 +125,30 @@ namespace hy_global {
*/
char get_platform_directory_char (void);
+
+ /* pass-through structure for reading / writing from a file that may or may not be compressed */
+
+ class hyFile {
+ public:
+ hyFile (void) {_fileReference = NULL;}
+ static hyFile* openFile (const char * file_path, const char * mode , bool error = false, long buffer = 1024*128);
+ inline bool valid (void) const {return _fileReference != NULL;}
+ void lock (void);
+ void unlock (void);
+ void rewind (void);
+ void seek (long, int);
+ void close ();
+ bool feof (void);
+ unsigned long read (void* buffer, unsigned long size, unsigned long items);
+ size_t tell ();
+ int getc ();
+#ifdef __ZLIB__
+ gzFile _fileReference;
+#else
+ FILE* _fileReference;
+#endif
+ };
+
/**
Open the file located at file_path using mode 'mode'
@@ -173,6 +201,14 @@ namespace hy_global {
*/
void ReportWarning (_String const & message);
+ //_______________________________________________________________________
+
+ /** Push waring message to console (high impact warnings)
+
+ @param message the diagnostic message to report
+ */
+ void ReportWarningConsole (_String const message);
+
//_______________________________________________________________________
/**
=====================================
src/core/include/hy_string_buffer.h
=====================================
@@ -42,7 +42,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//#pragma once
#include "hy_strings.h"
-
+#include "global_things.h"
+using namespace hy_global;
#define HY_STRING_BUFFER_ALLOCATION_CHUNK 16UL
#define kAppendAnAssignmentToBufferPlain 0x00
@@ -178,6 +179,15 @@ public:
- SLKP 20170920 initial implementation
*/
_StringBuffer(_String* buffer);
+
+ /**
+ * A constructor that read a possibly compressed file
+ * @param file the source file
+
+ * Revision history
+ - SLKP 20210411 initial implementation
+ */
+ _StringBuffer(hyFile* file);
/**
* Default constructor initializer
=====================================
src/core/likefunc.cpp
=====================================
@@ -1572,7 +1572,7 @@ _Matrix* _LikelihoodFunction::ConstructCategoryMatrix (const _SimpleList& whi
}
// all sites
else {
- vDim += BlockLength(i);
+ vDim += BlockLength(whichParts.get (i));
}
// only unique patterns for now
@@ -1920,6 +1920,7 @@ bool _LikelihoodFunction::PreCompute (void)
hyFloat tp = cornholio->Compute()->Value();
if (!cornholio->IsValueInBounds(tp)){
ReportWarning (_String ("Failing bound checks on ") & *cornholio->GetName() & " = " & _String (tp, "%25.16g"));
+ //break;
}
}
@@ -3675,8 +3676,14 @@ void _LikelihoodFunction::SetupLFCaches (void) {
if (translation < 0L) {
translation = theFilter->Translate2Frequencies (aState, translationCache, true);
if (translation < 0L) {
+ hyFloat total_weight = 0.;
for (unsigned long j = 0UL; j < stateSpaceDim; j++) {
ambigs->Store(translationCache[j]);
+ total_weight += translationCache[j];
+ }
+ if (CheckEqual(0., total_weight)) {
+ _SimpleList pattern_sites = theFilter->SitesForPattern(siteID);
+ HandleApplicationError(aState.Enquote() & " found at sites " & _String ((_String*)pattern_sites.toStr()) & " of sequence " & theFilter->GetSequenceName(leafID)->Enquote() & " maps to a null probability vector; this will result in an uncomputable likelihood function");
}
translation = -ambig_resolution_count++;
}
@@ -5611,11 +5618,16 @@ long _LikelihoodFunction::Bracket (long index, hyFloat& left, hyFloat& middle
(or involves a paremeter that has very little effect on the LF), recomputation could be within numerical error
**/
- if (rightValue - middleValue > 1e-12*errorTolerance || leftValue - middleValue > 1e-12*errorTolerance) {
+ if (rightValue - middleValue > 1e-10*errorTolerance || leftValue - middleValue > 1e-10*errorTolerance) {
char buf[256], buf2[512];
snprintf (buf, 256, " \n\tERROR: [_LikelihoodFunction::Bracket (index %ld) recomputed the value to midpoint: L(%g) = %g [@%g -> %g:@%g -> %g]]", index, middle, middleValue, left, leftValue,right, rightValue);
snprintf (buf2, 512, "\n\t[_LikelihoodFunction::Bracket (index %ld) BRACKET %s: %20.16g <= %20.16g >= %20.16g. steps, L=%g, R=%g, values %15.12g : %15.12g - %15.12g]", index, successful ? "SUCCESSFUL" : "FAILED", left,middle,right, leftStep, rightStep, leftValue - middleValue, middleValue, rightValue - middleValue);
- _TerminateAndDump (_String (buf) & "\n" & buf2 & "\nParameter name " & (index >= 0 ? *GetIthIndependentName(index) : "line optimization"));
+ if (hy_env::EnvVariableTrue(hy_env::tolerate_numerical_errors)) {
+ ReportWarningConsole (_String (buf) & "\n" & buf2 & "\nParameter name " & (index >= 0 ? *GetIthIndependentName(index) : "line optimization"));
+ } else {
+ _TerminateAndDump (_String (buf) & "\n" & buf2 & "\nParameter name " & (index >= 0 ? *GetIthIndependentName(index) : "line optimization"));
+ }
+
}
successful = rightValue<=middleValue && leftValue<=middleValue;
}
@@ -7062,10 +7074,14 @@ void _LikelihoodFunction::LocateTheBump (long index,hyFloat gPrecision, hyFlo
snprintf (buf, 256, "\n\t[_LikelihoodFunction::LocateTheBump (index %ld) RESETTING THE VALUE (worse log likelihood obtained; current value %20.16g, best value %20.16g) ]\n\n", index, GetIthIndependent(index), bestVal);
BufferToConsole (buf);
}
- if (CheckEqual(GetIthIndependent(index), bestVal) && fabs (middleValue-maxSoFar) > 1e-12*errorTolerance) {
+ if (CheckEqual(GetIthIndependent(index), bestVal) && fabs (middleValue-maxSoFar) > 1e-10*errorTolerance) {
char buf[256];
- snprintf (buf, 256, " \n\tERROR: [_LikelihoodFunction::LocateTheBump (index %ld) current value %20.16g (parameter = %20.16g), best value %20.16g (parameter = %20.16g)); delta = %20.16g, tolerance = %20.16g]\n\n", index, middleValue, GetIthIndependent(index), maxSoFar, bestVal, maxSoFar - middleValue, 1e-12*errorTolerance);
- _TerminateAndDump (_String (buf) & "\n" & "\nParameter name " & *GetIthIndependentName(index));
+ snprintf (buf, 256, " \n\tERROR: [_LikelihoodFunction::LocateTheBump (index %ld) current value %20.16g (parameter = %20.16g), best value %20.16g (parameter = %20.16g)); delta = %20.16g, tolerance = %20.16g]\n\n", index, middleValue, GetIthIndependent(index), maxSoFar, bestVal, maxSoFar - middleValue, 1e-10*errorTolerance);
+ if (hy_env::EnvVariableTrue(hy_env::tolerate_numerical_errors)) {
+ ReportWarningConsole(buf);
+ } else {
+ _TerminateAndDump (_String (buf) & "\n" & "\nParameter name " & *GetIthIndependentName(index));
+ }
}
SetIthIndependent(index,bestVal);
} else {
@@ -8762,10 +8778,7 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c
if (hy_env::EnvVariableTrue(hy_env::tolerate_numerical_errors)) {
- NLToConsole();
- BufferToConsole("***WARNING***\n");
- StringToConsole(err_msg);
- NLToConsole();
+ ReportWarningConsole (err_msg);
} else {
_TerminateAndDump (err_msg);
return -INFINITY;
=====================================
src/core/nexus.cpp
=====================================
@@ -69,15 +69,15 @@ void PadLine (FileState& fState, _DataSet& result);
void ISelector (FileState& fState, _StringBuffer& CurrentLine, _DataSet& result);
bool SkipLine (_StringBuffer& theLine, FileState* fS);
void TrimPhylipLine (_StringBuffer& CurrentLine, _DataSet& ds);
-bool ProcessNexusData (FileState&, long, FILE*, _StringBuffer&, _DataSet&);
-void ProcessNexusHYPHY (FileState&, long, FILE*, _StringBuffer&, _DataSet&);
-void ProcessNexusAssumptions (FileState&, long, FILE*, _StringBuffer&, _DataSet&);
-void ProcessNexusTaxa (FileState&,long, FILE*, _StringBuffer&, _DataSet&);
-void ProcessNexusTrees (FileState&, long, FILE*, _StringBuffer&, _DataSet&);
-bool FindNextNexusToken (FileState& fState, FILE* f, _StringBuffer& CurrentLine, long pos);
-bool SkipUntilNexusBlockEnd (FileState& fState, FILE* f, _StringBuffer& CurrentLine, long pos);
-bool ReadNextNexusStatement (FileState&, FILE* , _StringBuffer&, long, _StringBuffer&, bool, bool = true, bool = true, bool = false, bool = false, bool = false);
-long ReadNextNexusEquate (FileState&, FILE* , _StringBuffer&, long, _String&, bool = false, bool = true);
+bool ProcessNexusData (FileState&, long, hyFile*, _StringBuffer&, _DataSet&);
+void ProcessNexusHYPHY (FileState&, long, hyFile*, _StringBuffer&, _DataSet&);
+void ProcessNexusAssumptions (FileState&, long, hyFile*, _StringBuffer&, _DataSet&);
+void ProcessNexusTaxa (FileState&,long, hyFile*, _StringBuffer&, _DataSet&);
+void ProcessNexusTrees (FileState&, long, hyFile*, _StringBuffer&, _DataSet&);
+bool FindNextNexusToken (FileState& fState, hyFile* f, _StringBuffer& CurrentLine, long pos);
+bool SkipUntilNexusBlockEnd (FileState& fState, hyFile* f, _StringBuffer& CurrentLine, long pos);
+bool ReadNextNexusStatement (FileState&, hyFile* , _StringBuffer&, long, _StringBuffer&, bool, bool = true, bool = true, bool = false, bool = false, bool = false);
+long ReadNextNexusEquate (FileState&, hyFile* , _StringBuffer&, long, _String&, bool = false, bool = true);
void NexusParseEqualStatement (_StringBuffer&);
static auto error_conext = [] (_String const& buffer, long position) -> const _String {return (buffer.Cut (0,position) & " <=? " & buffer.Cut (position+1,kStringEnd)).Enquote();};
@@ -85,7 +85,7 @@ static auto error_conext = [] (_String const& buffer, long position) -> const _
//_________________________________________________________
-bool FindNextNexusToken (FileState& fState, FILE* f, _StringBuffer& CurrentLine, long pos) {
+bool FindNextNexusToken (FileState& fState, hyFile* f, _StringBuffer& CurrentLine, long pos) {
pos = CurrentLine.FirstNonSpaceIndex (pos,-1,kStringDirectionForward);
if (pos==kNotFound) {
@@ -102,7 +102,7 @@ bool FindNextNexusToken (FileState& fState, FILE* f, _StringBuffer& CurrentLi
//_________________________________________________________
-bool SkipUntilNexusBlockEnd (FileState& fState, FILE* file, _StringBuffer& CurrentLine, long pos) {
+bool SkipUntilNexusBlockEnd (FileState& fState, hyFile* file, _StringBuffer& CurrentLine, long pos) {
static const _String endMark ("END");
pos = CurrentLine.Find (endMark,pos+1,kStringEnd);
while (pos == kNotFound) {
@@ -143,7 +143,7 @@ void NexusParseEqualStatement (_StringBuffer& source)
}
//_________________________________________________________
-bool ReadNextNexusStatement (FileState& fState, FILE* f, _StringBuffer& CurrentLine, long pos, _StringBuffer & blank, bool stopOnSpace, bool stopOnComma, bool stopOnQuote, bool NLonly, bool preserveSpaces, bool preserveQuotes) {
+bool ReadNextNexusStatement (FileState& fState, hyFile* f, _StringBuffer& CurrentLine, long pos, _StringBuffer & blank, bool stopOnSpace, bool stopOnComma, bool stopOnQuote, bool NLonly, bool preserveSpaces, bool preserveQuotes) {
bool done = false,
insideLiteral = false,
startedReading = false;
@@ -229,7 +229,7 @@ bool ReadNextNexusStatement (FileState& fState, FILE* f, _StringBuffer& CurrentL
//_________________________________________________________
-long ReadNextNexusEquate (FileState& fState, FILE* f, _StringBuffer& CurrentLine, long pos2, _String& blank, bool resetP, bool demandSemicolon) {
+long ReadNextNexusEquate (FileState& fState, hyFile* f, _StringBuffer& CurrentLine, long pos2, _String& blank, bool resetP, bool demandSemicolon) {
long pos = blank.Find ('=',pos2,-1), res;
if (pos>=0) {
if (pos<blank.length()-1) {
@@ -263,7 +263,7 @@ long ReadNextNexusEquate (FileState& fState, FILE* f, _StringBuffer& CurrentL
}
//_________________________________________________________
-void ProcessNexusTaxa (FileState& fState, long pos, FILE*f, _StringBuffer& CurrentLine, _DataSet& result) {
+void ProcessNexusTaxa (FileState& fState, long pos, hyFile*f, _StringBuffer& CurrentLine, _DataSet& result) {
static const _String key1 = "DIMENSIONS", key2 = "NTAX", key3 = "TAXLABELS", keyEnd = "END";
bool done = false;
@@ -344,7 +344,7 @@ void ProcessNexusTaxa (FileState& fState, long pos, FILE*f, _StringBuffer& Cu
//_________________________________________________________
-void ProcessNexusAssumptions (FileState& fState, long pos, FILE*f, _StringBuffer& CurrentLine, _DataSet&) {
+void ProcessNexusAssumptions (FileState& fState, long pos, hyFile*f, _StringBuffer& CurrentLine, _DataSet&) {
static const _String key1 = "CHARSET", keyEnd = "END";
bool done = false;
@@ -570,7 +570,7 @@ void ProcessNexusAssumptions (FileState& fState, long pos, FILE*f, _StringBuf
//_________________________________________________________
-void ProcessNexusTrees (FileState& fState, long pos, FILE*f, _StringBuffer& CurrentLine, _DataSet& result) {
+void ProcessNexusTrees (FileState& fState, long pos, hyFile*f, _StringBuffer& CurrentLine, _DataSet& result) {
static _String const key1 = "TRANSLATE", key2 = "TREE", errMsg, keyEnd = "END";
bool done = false, readResult, good;
@@ -615,7 +615,7 @@ void ProcessNexusTrees (FileState& fState, long pos, FILE*f, _StringBuffer& C
if (readResult) {
break;
}
- if ((f&&feof(f))||(fState.theSource&&(fState.theSource->length()<=fState.pInSrc))) {
+ if ((f&&f->feof())||(fState.theSource&&(fState.theSource->length()<=fState.pInSrc))) {
break;
}
offset = 0;
@@ -815,7 +815,7 @@ void ProcessNexusTrees (FileState& fState, long pos, FILE*f, _StringBuffer& C
//_________________________________________________________
-void ProcessNexusHYPHY (FileState& fState, long pos, FILE*file, _StringBuffer& CurrentLine, _DataSet&) {
+void ProcessNexusHYPHY (FileState& fState, long pos, hyFile*file, _StringBuffer& CurrentLine, _DataSet&) {
static _String const endMark ("END;");
_StringBuffer bfBody (128UL);
@@ -863,7 +863,7 @@ void ProcessNexusHYPHY (FileState& fState, long pos, FILE*file, _StringBuffer
//_________________________________________________________
-bool ProcessNexusData (FileState& fState, long pos, FILE*f, _StringBuffer& CurrentLine, _DataSet& result) {
+bool ProcessNexusData (FileState& fState, long pos, hyFile*f, _StringBuffer& CurrentLine, _DataSet& result) {
static const _String key1 ("DIMENSIONS"), key11 ("NTAX"), key12 ("NCHAR"),
key2 ("FORMAT"),key21 ("DATATYPE"), key22 ("MISSING"), key23 ("GAP"), key24 ("SYMBOLS"),
key25 ("EQUATE"), key26 ("MATCHCHAR"), key27 ("NOLABELS"), key28 ("INTERLEAVE"), key3 ("MATRIX"), keyEnd ("END");
@@ -1217,7 +1217,7 @@ bool ProcessNexusData (FileState& fState, long pos, FILE*f, _StringBuffer& Cu
break; // finished reading
}
- if ((f&&feof(f))||(fState.theSource&&(fState.theSource->length()<=fState.pInSrc))) {
+ if ((f&&f->feof())||(fState.theSource&&(fState.theSource->length()<=fState.pInSrc))) {
break;
}
}
@@ -1258,7 +1258,7 @@ bool ProcessNexusData (FileState& fState, long pos, FILE*f, _StringBuffer& Cu
//_________________________________________________________
-void ReadNexusFile (FileState& fState, FILE*file, _DataSet& result) {
+void ReadNexusFile (FileState& fState, hyFile*file, _DataSet& result) {
bool dataRead = false, lookForEnd = false;
long f,g, file_line = fState.currentFileLine;
=====================================
src/core/string_buffer.cpp
=====================================
@@ -210,6 +210,25 @@ _StringBuffer::~_StringBuffer (void ){
s_data = allocated_ptr;
sa_length = 0L;
}
+
+//=============================================================
+_StringBuffer::_StringBuffer(hyFile* file): _String () {
+ const unsigned long buffer_size = 65535;
+ this->Initialize();
+ char buffer [buffer_size+1L];
+ unsigned long items_read;
+ _String buffer_str (buffer_size, buffer);
+ do {
+ items_read = file->read (buffer, 1, buffer_size);
+ if (items_read < buffer_size) break;
+ (*this) << buffer_str;
+ } while (items_read == buffer_size);
+ if (items_read) {
+ buffer[items_read] = 0;
+ (*this) << buffer;
+ }
+}
+
/*
==============================================================
Cloners and Copiers
=====================================
tests/hbltests/UnitTests/HBLCommands/DataSet.bf
=====================================
@@ -20,6 +20,7 @@ function runTest () {
DataSet 2fas = ReadDataFile (PATH_TO_CURRENT_BF + '/../../data/2.fas');
DataSet cd2Phylip = ReadDataFile(PATH_TO_CURRENT_BF + '/../../data/CD2.phylip');
+
//---------------------------------------------------------------------------------------------------------
// ERROR HANDLING
@@ -34,7 +35,9 @@ function runTest () {
assert (runCommandWithSoftErrors ('DataSet list_ds = ReadFromString(T1);', "The format of the sequence file has not been recognized and may be invalid"), "Failed error checking for trying to create a data set with ReadFromString(topology)");
assert (runCommandWithSoftErrors ('DataSet list_ds = ReadFromString(TT1);', "The format of the sequence file has not been recognized and may be invalid"), "Failed error checking for trying to create a data set with ReadFromString(tree)");
+
assert (runCommandWithSoftErrors ("DataSet thisIsntAValidFilePath = ReadDataFile('./ThisFileDoesNotExist.txt');", "Could not find source dataset file"), "Failed error checking for trying to create a data set with ReadDataFile with an invalid path");
+
assert (runCommandWithSoftErrors ("DataSet thisFileIsntInAValidFormat = ReadDataFile(PATH_TO_CURRENT_BF + '/assert.bf');", "The format of the sequence file has not been recognized and may be invalid"), "Failed error checking for trying to create a data set with ReadDataFile with a file in an invalid format");
assert (runCommandWithSoftErrors ("DataSet newickFile = ReadDataFile (PATH_TO_CURRENT_BF + '/../../data/CD2.newick');", "The format of the sequence file has not been recognized and may be invalid"), "Failed error checking for trying to create a data set with ReadDataFile with a file file containing a newick string but no sequences");
View it on GitLab: https://salsa.debian.org/med-team/hyphy/-/compare/37b7cdadac7bab8a617c7df5d4d5269099c08aa5...3340c404070398b41ebf95c4601fcade6dfbd6db
--
View it on GitLab: https://salsa.debian.org/med-team/hyphy/-/compare/37b7cdadac7bab8a617c7df5d4d5269099c08aa5...3340c404070398b41ebf95c4601fcade6dfbd6db
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20210512/cd99b9d2/attachment-0001.htm>
More information about the debian-med-commit
mailing list