Skip to content

Commit

Permalink
Merge pull request #1252 from veg/develop
Browse files Browse the repository at this point in the history
2.5.24 / Apple M1 support
  • Loading branch information
spond authored Dec 17, 2020
2 parents fe085e1 + 30845f8 commit d06c7e2
Show file tree
Hide file tree
Showing 15 changed files with 1,418 additions and 481 deletions.
48 changes: 42 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project(HyPhy)
cmake_policy(VERSION 3.0.0)
#cmake_policy(SET CMP0026 OLD)
#cmake_policy(SET CMP0004 OLD)

enable_testing()

Expand All @@ -14,6 +12,7 @@ set(CMAKE_CONFIGURATION_TYPES Release)

option(NOAVX OFF)
option(NOSSE3 OFF)
option(NONEON OFF)

#-------------------------------------------------------------------------------
# SSE MACROS
Expand Down Expand Up @@ -44,6 +43,34 @@ macro(PCL_CHECK_FOR_SSE3)
HAVE_SSE3_EXTENSIONS)
endmacro(PCL_CHECK_FOR_SSE3)

#-------------------------------------------------------------------------------
# NEON MACROS
#-------------------------------------------------------------------------------

macro(PCL_CHECK_FOR_NEON)
include(CheckCXXSourceRuns)
set(CMAKE_REQUIRED_FLAGS)

#if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
set(CMAKE_REQUIRED_FLAGS "-msse3")
#endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)

check_cxx_source_runs("
#include <stdio.h>
#include <arm_neon.h>
int main() {
double array[4] = {4.,2.,3.,4};
float64x2_t a1 = vld1q_f64 (array),
a2 = vld1q_f64 (array+2);
a1 = vmulq_f64 (a1,a2);
vst1q_lane_f64 (array, a1, 0);
printf (\"%g\", array[0]);
return 0;
}"
HAVE_NEON_EXTENSIONS)
endmacro(PCL_CHECK_FOR_NEON)


#-------------------------------------------------------------------------------
# SSE MACROS
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -219,6 +246,13 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif(${HAVE_SSE3_EXTENSIONS})
endif (${HAVE_AVX_EXTENSIONS})
endif(NOAVX)

if(NOT NONEON)
PCL_CHECK_FOR_NEON()
if(${HAVE_NEON_EXTENSIONS})
add_definitions (-D_SLKP_USE_ARM_NEON)
endif(${HAVE_NEON_EXTENSIONS})
endif(NOT NONEON)

set_property(
SOURCE ${SRC_CORE} ${SRC_NEW} ${SRC_UTILS} ${SRC_UNIXMAIN}
Expand Down Expand Up @@ -503,11 +537,13 @@ set_target_properties(
HYPHYDEBUG
PROPERTIES
if(${OPENMP_FOUND})
COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} ${DEFAULT_DEBUG_WARNING_FLAGS} ${OpenMP_CXX_FLAGS} ${MPI_COMPILE_FLAGS} -g -fprofile-arcs -ftest-coverage -fsanitize=address -fsanitize=leak -O0 "
LINK_FLAGS "${DEFAULT_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS} ${MPI_LINK_FLAGS} -g -fprofile-arcs -ftest-coverage -fsanitize=address -O0 "
#COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} ${DEFAULT_DEBUG_WARNING_FLAGS} ${OpenMP_CXX_FLAGS} ${MPI_COMPILE_FLAGS} -g -fsanitize=address -fsanitize=leak -O0 "
COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} ${DEFAULT_DEBUG_WARNING_FLAGS} ${OpenMP_CXX_FLAGS} ${MPI_COMPILE_FLAGS} -g -fsanitize=address -O0 "
LINK_FLAGS "${DEFAULT_COMPILE_FLAGS} ${OpenMP_CXX_FLAGS} ${MPI_LINK_FLAGS} -g -fsanitize=address -O0 "
else(${OPENMP_FOUND})
COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} ${DEFAULT_DEBUG_WARNING_FLAGS} -g -fprofile-arcs -ftest-coverage -fsanitize=address -fsanitize=leak -O0 "
LINK_FLAGS "${DEFAULT_COMPILE_FLAGS} -g -fprofile-arcs -ftest-coverage -fsanitize=address -O0 "
#COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} ${DEFAULT_DEBUG_WARNING_FLAGS} -g -fsanitize=address -fsanitize=leak -O0 "
COMPILE_FLAGS "${DEFAULT_COMPILE_FLAGS} ${DEFAULT_DEBUG_WARNING_FLAGS} -g -fsanitize=address -O0 "
LINK_FLAGS "${DEFAULT_COMPILE_FLAGS} -g -fsanitize=address -O0 "
endif(${OPENMP_FOUND})
)

Expand Down
55 changes: 32 additions & 23 deletions res/TemplateBatchFiles/SelectionAnalyses/BUSTED.bf
Original file line number Diff line number Diff line change
Expand Up @@ -429,41 +429,50 @@ if (busted.do_srv_hmm) {
//parameters.SetConstraint (((busted.test.bsrel_model[terms.parameters])[terms.global])[terms.rate_variation.hmm_lambda],"1e-6", "");
}


parameters.DeclareGlobalWithRanges ("busted.bl.scaler", 1, 0, 1000);
busted.grid_search.results = estimators.FitLF (busted.filter_names, busted.trees, busted.model_map, busted.final_partitioned_mg_results, busted.model_object_map, {
"retain-lf-object": TRUE,
terms.run_options.proportional_branch_length_scaler :
{"0" : "busted.bl.scaler"},
debug.checkpoint = utility.GetEnvVariable ("DEBUG_CHECKPOINT");

if (Type (debug.checkpoint) != "String") {
parameters.DeclareGlobalWithRanges ("busted.bl.scaler", 1, 0, 1000);
busted.grid_search.results = estimators.FitLF (busted.filter_names, busted.trees, busted.model_map, busted.final_partitioned_mg_results, busted.model_object_map, {
"retain-lf-object": TRUE,
terms.run_options.proportional_branch_length_scaler :
{"0" : "busted.bl.scaler"},

terms.run_options.optimization_settings :
{
"OPTIMIZATION_METHOD" : "nedler-mead",
"MAXIMUM_OPTIMIZATION_ITERATIONS" : 500,
"OPTIMIZATION_PRECISION" : busted.nm.precision
} ,
terms.run_options.optimization_settings :
{
"OPTIMIZATION_METHOD" : "nedler-mead",
"MAXIMUM_OPTIMIZATION_ITERATIONS" : 500,
"OPTIMIZATION_PRECISION" : busted.nm.precision
} ,

terms.search_grid : busted.initial_grid,
terms.search_restarts : busted.N.initial_guesses
});
terms.search_grid : busted.initial_grid,
terms.search_restarts : busted.N.initial_guesses
});


busted.full_model = estimators.FitLF (busted.filter_names, busted.trees, busted.model_map, busted.grid_search.results, busted.model_object_map, {
"retain-lf-object": TRUE,
terms.run_options.optimization_settings :
{
"OPTIMIZATION_METHOD" : "hybrid"
}
busted.full_model = estimators.FitLF (busted.filter_names, busted.trees, busted.model_map, busted.grid_search.results, busted.model_object_map, {
"retain-lf-object": TRUE,
terms.run_options.optimization_settings :
{
"OPTIMIZATION_METHOD" : "hybrid",
//"OPTIMIZATION_PRECISION" : 1.
}

});

});
} else {
ExecuteAFile (debug.checkpoint);
GetString (lf, LikelihoodFunction, 0);
busted.full_model = estimators.ExtractMLEs (lf, busted.model_object_map);
busted.full_model[terms.likelihood_function] = lf;
}


KeywordArgument ("save-fit", "Save BUSTED model fit to this file (default is not to save)", "/dev/null");
io.SpoolLFToPath(busted.full_model[terms.likelihood_function], io.PromptUserForFilePath ("Save BUSTED model fit to this file ['/dev/null' to skip]"));

io.ReportProgressMessageMD("BUSTED", "main", "* " + selection.io.report_fit (busted.full_model, 9, busted.codon_data_info[terms.data.sample_size]));

//VERBOSITY_LEVEL = 101;


io.ReportProgressMessageMD("BUSTED", "main", "* For *test* branches, the following rate distribution for branch-site combinations was inferred");
Expand Down
91 changes: 87 additions & 4 deletions res/TemplateBatchFiles/SelectionAnalyses/PRIME.bf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ LoadFunctionLibrary("modules/io_functions.ibf");
LoadFunctionLibrary("modules/selection_lib.ibf");





debug.checkpoint = utility.GetEnvVariable ("DEBUG_CHECKPOINT");
/*------------------------------------------------------------------------------
Display analysis information
Expand Down Expand Up @@ -103,7 +106,11 @@ This table is meant for HTML rendering in the results web-app; can use HTML char
is 'pop-over' explanation of terms. This is ONLY saved to the JSON file. For Markdown screen output see
the next set of variables.
*/
prime.table_screen_output = {{"Codon", "Partition", "alpha", "beta", "Property Description", "Importance", "p-value"}};

prime.site.composition.string = "";


prime.table_screen_output = {{"Codon", "Partition", "alpha", "beta", "Property Description", "Importance", "p-value","Most common codon substitutions at this site"}};
prime.table_output_options = { terms.table_options.header : TRUE,
terms.table_options.minimum_column_width: 12,
terms.table_options.align : "center",
Expand All @@ -112,9 +119,10 @@ prime.table_output_options = { terms.table_options.header : TRUE,
"1" : 12,
"2" : 12,
"3" : 12,
"4" : 50,
"4" : 40,
"5" : 12,
"6" : 12}
"6" : 12,
"7" : 70}
};


Expand All @@ -129,6 +137,7 @@ prime.property_set = io.SelectAnOption (
{
"Atchley":"Use the five properties derived from a factor analysis of 500 amino-acid properties [Table 2 in PNAS (2005) 102(18) 6395-6400 doi: 10.1073/pnas.0408677102]",
"LCAP":"Use the five properties defined in the Conant and Stadler LCAP model [Mol Biol Evol (2009) 26 (5): 1155-1161. doi: 10.1093/molbev/msp031]",
"Random" : "Random properties (for null hypothesis testing)",
"Custom":"Load the set of properties from a file"
},
"The set of properties to use in the model");
Expand All @@ -155,6 +164,7 @@ for (_partition_, _selection_; in; prime.selected_branches) {
}

prime.pairwise_counts = genetic_code.ComputePairwiseDifferencesAndExpectedSites(prime.codon_data_info[terms.code], None);
prime.codon_table = genetic_code.DefineCodonToAAMapping (prime.codon_data_info[terms.code]);

selection.io.startTimer (prime.json [terms.json.timers], "Model fitting",1);

Expand Down Expand Up @@ -296,6 +306,9 @@ prime.lambda_range = {
terms.upper_bound: "15"
};




prime.table_headers = { 6 + 3*prime.properties.N, 2};

prime.table_headers[0][0] = "alpha;"; prime.table_headers[0][1] = "Synonymous substitution rate at a site";
Expand Down Expand Up @@ -375,7 +388,8 @@ prime.report.significant_site = {{"" + (1+((prime.filter_specification[prime.rep
Format(prime.report.row[1],7,3), // beta
prime.property_report_name, // property name
prime.rate_to_screen ( prime.property_report_name,,prime.report_rate), // property importance
Format(prime.report.row[prime.print_index],7,3) // property p-value
Format(prime.report.row[prime.print_index],7,3), // property p-value
Join ("|", prime.site.composition.string[prime.property_report_name])
}};


Expand Down Expand Up @@ -659,6 +673,9 @@ lfunction prime.handle_a_site (lf_fel, lf_prop, filter_data, partition_index, pa

}

ancestral_info = ancestral.build (lf_prop,0,FALSE);
branch_substitution_information = (ancestral.ComputeSubstitutionBySite (ancestral_info,0,None))[^"terms.substitutions"];
DeleteObject (ancestral_info);

alternative = estimators.ExtractMLEsOptions (lf_prop, model_mapping, {});
alternative [utility.getGlobalValue("terms.fit.log_likelihood")] = results[1][0];
Expand Down Expand Up @@ -691,6 +708,7 @@ lfunction prime.handle_a_site (lf_fel, lf_prop, filter_data, partition_index, pa
utility.getGlobalValue("terms.alternative") : alternative,
utility.getGlobalValue("terms.Null"): Null,
utility.getGlobalValue("terms.model.residue_properties") : constrained_models,
utility.getGlobalValue("terms.branch_selection_attributes") : branch_substitution_information,
utility.getGlobalValue("terms.prime_imputed_states") : character_map
};
}
Expand Down Expand Up @@ -738,6 +756,71 @@ function prime.report.echo (prime.report.site, prime.report.partition, prime.rep

lfunction prime.store_results (node, result, arguments) {

sub_profile = result[utility.getGlobalValue("terms.branch_selection_attributes")];



if (None != sub_profile) {

total_sub_count = 0;



sub_by_count = {"Overall" : {}};

for (p,v; in; ^"prime.properties") {
sub_by_count[p] = {};
}

for (i, v; in; sub_profile) {
for (j, b; in; v) {
c = Abs (b);
total_sub_count += c;
ai = (^"prime.codon_table")[i];
aj = (^"prime.codon_table")[j];
if (Abs (ai) == 0) {ai = "?";}
if (Abs (aj) == 0) {aj = "?";}


for (p, counts; in; sub_by_count) {
if ((counts/c)==0) {
counts [c] = {};
}

delta = "";
if (p != "Overall") {
delta = "("+Format (Abs (((^"prime.properties")[p])[ai]-((^"prime.properties")[p])[aj]),0,2) + ")";
}

if (ai != aj) {
counts[c] + (((^"prime.codon_table")[i] + ">" + (^"prime.codon_table")[j]) + delta);
} else {
counts[c] + ai;
}
}
}
}

sub_profile = {};
for (p,count; in; sub_by_count) {

sorted_subs = {Abs (count), 1};
j = 0;
for (i, v; in; count) {
sorted_subs[j] = -(+i);
j += 1;
}
sub_profile1 = {};
for (i; in; sorted_subs % 0) {
sub_profile1 + ("[" + (-i) + "]" + Join (",",count [-i]));
}

sub_profile [p] = sub_profile1;
}
^"prime.site.composition.string" = sub_profile;
}


partition_index = arguments [3];
pattern_info = arguments [4];

Expand Down
Loading

0 comments on commit d06c7e2

Please sign in to comment.