Skip to content

Commit

Permalink
Merge pull request #1664 from veg/develop
Browse files Browse the repository at this point in the history
2.5.56
  • Loading branch information
stevenweaver committed Nov 6, 2023
2 parents cbcb5dd + 91bf31a commit ab6a108
Show file tree
Hide file tree
Showing 30 changed files with 435 additions and 9,201 deletions.
60 changes: 40 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ option(NOSSE4 OFF)
option(NONEON OFF)
option(NOZLIB OFF)


if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(NOAVX ON)
set(NOSSE4 ON)
set(NONEON ON)
set(NOZLIB ON)
endif()
set(NOAVX ON)
#set(NOSSE4 ON)
set(NONEON ON)
set(NOZLIB ON)
set(LIBRARY_PATH "/hyphy")
#set(CMAKE_EXECUTABLE_SUFFIX ".html")
add_definitions (-D_USE_EMSCRIPTEN_)
endif()

#-------------------------------------------------------------------------------
# SSE MACROS
Expand Down Expand Up @@ -191,12 +193,17 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(NOAVX)
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -mno-avx")
if(NOSSE4)
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -mno-sse3")
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -mno-sse3")
endif()
else(NOSSE4)
PCL_CHECK_FOR_SSE4()
if(${HAVE_SSE4_EXTENSIONS})
add_definitions (-D_SLKP_USE_SSE_INTRINSICS)
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -msse4.1 ")
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -msimd128 ")
endif()
endif(${HAVE_SSE4_EXTENSIONS})
endif(NOSSE4)
else(NOAVX)
Expand All @@ -214,6 +221,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if(${HAVE_SSE4_EXTENSIONS})
add_definitions (-D_SLKP_USE_SSE_INTRINSICS)
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -msse4.1 ")


endif(${HAVE_SSE4_EXTENSIONS})
endif(${HAVE_AVX_EXTENSIONS})
endif(NOAVX)
Expand All @@ -222,6 +231,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
PCL_CHECK_FOR_NEON()
if(${HAVE_NEON_EXTENSIONS})
add_definitions (-D_SLKP_USE_ARM_NEON)

endif(${HAVE_NEON_EXTENSIONS})
endif(NOT NONEON)

Expand All @@ -233,13 +243,18 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(DEFAULT_COMPILE_FLAGS "-fsigned-char -O3 -D_FORTIFY_SOURCE=2 -std=c++14 -Wall")
if(NOAVX)
if(NOSSE4)
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -mno-sse3")
else(NOSSE4)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -mno-sse3")
endif()
else(NOSSE4)
PCL_CHECK_FOR_SSE4()
if(${HAVE_SSE4_EXTENSIONS})
add_definitions (-D_SLKP_USE_SSE_INTRINSICS)
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -msse4.1 ")
endif(${HAVE_SSE4_EXTENSIONS})
if("${HAVE_SSE4_EXTENSIONS}" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
add_definitions (-D_SLKP_USE_SSE_INTRINSICS)
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -msse4.1 ")
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -msimd128 ")
endif()
endif()
endif(NOSSE4)
else(NOAVX)
PCL_CHECK_FOR_AVX()
Expand Down Expand Up @@ -275,7 +290,6 @@ endif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")

#set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -fopt-info -fopt-info-vec-missed")
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS}")
MESSAGE ("Set default compiler flags to ${DEFAULT_COMPILE_FLAGS}")

if(NOT DEFINED DEFAULT_COMPILE_FLAGS)
set(DEFAULT_COMPILE_FLAGS "")
Expand All @@ -291,6 +305,11 @@ if(NOT DEFINED DEFAULT_WARNING_FLAGS)
set(DEFAULT_WARNING_FLAGS "")
endif(NOT DEFINED DEFAULT_WARNING_FLAGS)

if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(DEFAULT_COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} -fwasm-exceptions ")
endif()

MESSAGE ("Set default compiler flags to ${DEFAULT_COMPILE_FLAGS}")

#-------------------------------------------------------------------------------
# OpenMP support
Expand Down Expand Up @@ -426,7 +445,11 @@ install(
OPTIONAL
)

if (NOT DEFINED LIBRARY_PATH)
set(LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/share/hyphy")
endif()

MESSAGE (${LIBRARY_PATH})

#-------------------------------------------------------------------------------
# hyphy mpi target
Expand Down Expand Up @@ -460,7 +483,7 @@ if(${MPI_FOUND})
# set definitions here 'cause "s_t_p" below doesn't like lists
set_property(
TARGET HYPHYMPI
APPEND PROPERTY COMPILE_DEFINITIONS __HYPHYMPI__ __UNIX__ _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/share/hyphy"
APPEND PROPERTY COMPILE_DEFINITIONS __HYPHYMPI__ __UNIX__ _HYPHY_LIBDIRECTORY_="${LIBRARY_PATH}"
)

message ("${DEFAULT_LINK_FLAGS} ${MPI_LINK_FLAGS} ${OpenMP_CXX_FLAGS}")
Expand Down Expand Up @@ -592,14 +615,10 @@ set_property(
APPEND PROPERTY COMPILE_DEFINITIONS __MP__ __MP2__
)

set_property(
TARGET hyphy HYPHYDEBUG
APPEND PROPERTY COMPILE_DEFINITIONS _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/share/hyphy"
)

set_property(
TARGET hyphy HYPHYDEBUG HYPHYPROFILE
APPEND PROPERTY COMPILE_DEFINITIONS _HYPHY_LIBDIRECTORY_="${CMAKE_INSTALL_PREFIX}/share/hyphy"
APPEND PROPERTY COMPILE_DEFINITIONS _HYPHY_LIBDIRECTORY_="${LIBRARY_PATH}"
)


Expand Down Expand Up @@ -631,6 +650,7 @@ makeLink(HYPHYMP hyphy hyphy)
# TESTS
#-------------------------------------------------------------------------------


add_test (NAME UNIT-TESTS COMMAND bash run_unit_tests.sh)
add_test (CODON HYPHYMP tests/hbltests/SimpleOptimizations/SmallCodon.bf)
add_test (PROTEIN HYPHYMP CPU=1 tests/hbltests/SimpleOptimizations/IntermediateProtein.bf)
Expand Down
8 changes: 3 additions & 5 deletions res/TemplateBatchFiles/SelectionAnalyses/FEL.bf
Original file line number Diff line number Diff line change
Expand Up @@ -947,12 +947,12 @@ function fel.report.echo (fel.report.site, fel.report.partition, fel.report.row)
if (fel.report.row [4] < fel.pvalue) {
if (fel.report.row[0] < fel.report.row[1]) {
fel.print_row = fel.report.positive_site;
fel.color = "\033[0;31m";
fel.color = "RED" && 8;
fel.report.counts[0] += 1;
} else {
fel.print_row = fel.report.negative_site;
fel.report.counts [1] += 1;
fel.color = "\033[0;32m";
fel.color = "GREEN" && 8;
}
}

Expand All @@ -966,9 +966,7 @@ function fel.report.echo (fel.report.site, fel.report.partition, fel.report.row)
fel.table_output_options[terms.table_options.header] = FALSE;
}

fprintf (stdout, fel.color,
io.FormatTableRow (fel.print_row,fel.table_output_options),"\033[0m"
);
fprintf (stdout, io.FormatTableRowDecorators (fel.print_row,fel.table_output_options, fel.color, "NONE" && 8));
}
}

Expand Down
8 changes: 3 additions & 5 deletions res/TemplateBatchFiles/YangNielsenBranchSite2005.bf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fprintf (stdout, "\nBase composition:\n\tA: ", Format (baseFreqs[0][0],10,5),","
/* 5. prompt for the type of model to run */

ChoiceList (modelKind, "Model", 1, SKIP_NONE,
"Alternative", "Fit Model A with 4 rate classes. Class 1: Negative selection in FG and BG. Class 2: Neutral evolution in FG and BG. Class 3: Negative selection in BG, Positive in FG. Class 4: Neutral evolution in BG, Positive in FG",
"Branch-site alternative", "Fit Model A with 4 rate classes. Class 1: Negative selection in FG and BG. Class 2: Neutral evolution in FG and BG. Class 3: Negative selection in BG, Positive in FG. Class 4: Neutral evolution in BG, Positive in FG",
"Null for Test 1", "Fit a model with 2 rate classes. Class 1: Negative selection in FG and BG. Class 2: Neutral evolution in FG and BG.",
"Null for Test 2", "Fit Model A with 3 rate classes. Class 1: Negative selection in FG and BG. Class 2: Neutral evolution in FG and BG. Class 3: Negative selection in BG, Neutral in FG."
);
Expand All @@ -54,15 +54,13 @@ global P_0 = 0.5;
P_0:<1;
P_0:>0;

if (modelKind == 1)
{
if (modelKind == 1) {
rateClasses = 2;

categFreqMatrix = {{P_0,1-P_0}} ;
categRateMatrix = {{1,2}};
}
else
{
else {
P_0 = 1/4;
global P_1_aux = 1/4;
global P_1 := Min(P_1_aux,1-P_0);
Expand Down
15 changes: 12 additions & 3 deletions res/TemplateBatchFiles/libv3/IOFunctions.bf
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ lfunction io.format_object(object, options) {
* @param row
* @param options
*/
lfunction io.FormatTableRow(row, options) {
lfunction io.FormatTableRowDecorators (row, options, prefix, suffix) {

if (None == options) {
options = {};
Expand Down Expand Up @@ -395,7 +395,7 @@ lfunction io.FormatTableRow(row, options) {
for (k = 0; k < padding$2; k += 1) {
row * " ";
}
row * cells[i];
row * (prefix + cells[i] + suffix);
for (k = 0; k < padding - padding$2; k += 1) {
row * " ";
}
Expand Down Expand Up @@ -428,7 +428,7 @@ lfunction io.FormatTableRow(row, options) {
for (k = 0; k < padding$2; k += 1) {
row * " ";
}
row * cells[i];
row * (prefix + cells[i] + suffix);
for (k = 0; k < padding - padding$2; k += 1) {
row * " ";
}
Expand All @@ -439,6 +439,15 @@ lfunction io.FormatTableRow(row, options) {
return row;
}

/**
* @name io.FormatTableRow
* @param row
* @param options
*/
lfunction io.FormatTableRow(row, options) {
return io.FormatTableRowDecorators (row, options, "", "");
}

/**
* @name io.get_a_list_of_files
* @param filename
Expand Down
71 changes: 65 additions & 6 deletions res/TemplateBatchFiles/libv3/convenience/regexp.bf
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@

/** @module regexp */


namespace terms {

namespace regexp {

strings = "strings";
separators = "separators";

}

}

/**
* @name regexp.Replace
* @param {String} string
* @param {String} re - search for this expression
* @param {String} repl - replace each occurence of re with repl
* @returns {Dictionary} a dictionary containing split strings
*/
* @name regexp.Replace
* @param {String} string
* @param {String} re - search for this expression
* @param {String} repl - replace each occurence of re with repl
* @returns {Dictionary} a dictionary containing split strings
*/

lfunction regexp.Replace(string, re, repl) {
return string ^ {{re,repl}};
}
Expand Down Expand Up @@ -49,6 +62,52 @@ lfunction regexp.Split(string, re) {
};
}

/**
* @name regexp.SplitWithMatches
* @param {String} string
* @param {String} re - the regular expression
* @returns {Dictionary} a dictionary containing split strings under the key "strings" and separators under the key "separators"
*/
lfunction regexp.SplitWithMatches (string, re) {
coordinates = string || re;
if (coordinates[0] >= 0) {
strings = {};
separators = {};

current_end = 0;

for (i = 0; i < Rows(coordinates); i += 2) {
from = coordinates[i];
separators + string[coordinates[i]][coordinates[i+1]];

if (current_end < from) {
strings + string[current_end][from - 1];
} else {
strings + "";
}
current_end = coordinates[i + 1] + 1;
}

if (current_end < Abs(string)) {
strings + string[current_end][Abs(string) - 1];
} else {
strings + "";
}

return {
^("terms.regexp.strings") :strings,
^("terms.regexp.separators") : separators
};
}
return {
^("terms.regexp.strings") : {
"0": string
},
^("terms.regexp.separators") : {
}
};
}

/**
* @name regexp.Find
* @param {String} string
Expand Down
62 changes: 62 additions & 0 deletions res/TemplateBatchFiles/libv3/tasks/trees.bf
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,68 @@ lfunction trees.branch_names(tree, respect_case) {
return result;
}

/**
* @name trees.extract_paml_annotation
* @param tree_string {STRING} : PAML (#N $N annotated string)
* @param dictionary; tree annotation with PAML_GROUP_N
* @returns result
*/

lfunction trees.extract_paml_annotation (tree_string) {

pieces = regexp.SplitWithMatches (tree_string, "\$([0-9])");
N = utility.Array1D (pieces[^("terms.regexp.separators")]);

has_paml_clades = N > 0;
sanitized_string = "";
if (N > 0) {
for (i,s; in; pieces[^("terms.regexp.strings")]) {
sanitized_string += s;
if (+i > 0) {
sanitized_string += "{" + regexp.Replace ((pieces[^("terms.regexp.separators")])[-1+i], "\$", "PAML_CLADE_") + "}";
}
}
}

pieces = regexp.SplitWithMatches (sanitized_string, "\#([0-9])");
N = utility.Array1D (pieces[^("terms.regexp.separators")]);

if (N > 0) {
for (i,s; in; pieces[^("terms.regexp.strings")]) {
sanitized_string += s;
if (+i > 0) {
sanitized_string += "{" + regexp.Replace ((pieces[^("terms.regexp.separators")])[-1+i], "\#", "PAML_GROUP_") + "}";
}
}
}

if (Abs (sanitized_string) == 0) {
sanitized_string = tree_string;
}

result = trees.ExtractTreeInfo (sanitized_string);

if (has_paml_clades) {
additional_annotation = {};
tree_str = result[^"terms.trees.newick"];
Topology T = tree_str;
for (b, m; in; result[^"terms.trees.model_map"]) {
if (None != regexp.Find (m, "^PAML_CLADE_")) {
tag = regexp.Replace (m, "^PAML_CLADE_", "PAML_GROUP_");
for (n,foo; in; T[b]) {
additional_annotation[n] = tag;
}
}
}
result[^"terms.trees.model_map"] * additional_annotation;
result[^"terms.trees.model_list"] = Columns(result[^"terms.trees.model_map"]);
result[^"terms.trees.newick_annotated"] = tree.Annotate (&T, result[^"terms.trees.model_map"], "{}", FALSE);
}

return result;
}



/**
* @name trees.KillZeroBranches
Expand Down

0 comments on commit ab6a108

Please sign in to comment.