rate4site-3.0.0/0000755011611301161130000000000012223673503010422 500000000000000rate4site-3.0.0/README0000644011611301161130000000267212223673417011235 00000000000000Overview -------- The rate of evolution is not constant among amino acid sites: some positions evolve slowly and are commonly referred to as "conserved", while others evolve rapidly and are referred to as "variable". The rate variations correspond to different levels of purifying selection acting on these sites. The purifying selection can be the result of geometrical constraints on the folding of the protein into its 3D structure, constraints at amino acid sites involved in enzymatic activity or in ligand binding or, alternatively, at amino acid sites that take part in protein-protein interactions. Rate4Site calculates the relative evolutionary rate at each site using a probabilistic-based evolutionary model. This allows taking into account the stochastic process underlying sequence evolution within protein families and the phylogenetic tree of the proteins in the family. The conservation score at a site corresponds to the site's evolutionary rate. Methodology ----------- The sole obligatory input to Rate4Site is an MSA file. The program then computes a phylogenetic tree that is consistent with the available MSA (the user can also input a pre-calculated tree). It then calculates the relative conservation score for each site in the MSA. This is carried out using either an empirical Bayesian method or a maximum likelihood method (Pupko et al., 2002). The differences between the two methods are explained in details in Mayrose et al (2004). rate4site-3.0.0/configure.ac0000644011611301161130000000127012223673417012634 00000000000000AC_INIT([rate4site], [3.0.0], [http://www.tau.ac.il/~itaymay/cp/rate4site.html]) AC_CONFIG_SRCDIR([src/rate4site/rate4site.cpp]) AM_INIT_AUTOMAKE([1.11]) AM_CONFIG_HEADER([config.h]) AC_CONFIG_FILES([Makefile src/phylogeny/Makefile src/rate4site/Makefile]) # Checks for programs. AC_PROG_CC if test -z $CXXFLAGS; then CXXFLAGS='-O3 -Wno-deprecated' fi # use the C++ compiler for the following checks AC_LANG([C++]) # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([string]) AC_CHECK_HEADERS([iostream]) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T AC_PROG_CXX AC_PROG_CXX AC_PROG_RANLIB AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_OUTPUT rate4site-3.0.0/aclocal.m40000644011611301161130000010503512223673472012213 00000000000000# generated automatically by aclocal 1.11.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, # Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.6], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.6])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR rate4site-3.0.0/Makefile.am0000644011611301161130000000004512223673417012401 00000000000000SUBDIRS=src/phylogeny src/rate4site rate4site-3.0.0/Makefile.in0000644011611301161130000005475112223673476012434 00000000000000# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ depcomp install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src/phylogeny src/rate4site all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then rm -f stamp-h1; else :; fi @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod u+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile config.h installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ dist-lzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-generic distclean-hdr \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: rate4site-3.0.0/config.h.in0000644011611301161130000000321112223673475012372 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_IOSTREAM /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION /* Define to `unsigned int' if does not define. */ #undef size_t rate4site-3.0.0/configure0000755011611301161130000061125512223673475012273 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for rate4site 3.0.0. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: http://www.tau.ac.il/~itaymay/cp/rate4site.html about $0: your system, including any error possibly output before $0: this message. Then install a modern shell, or manually $0: run the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rate4site' PACKAGE_TARNAME='rate4site' PACKAGE_VERSION='3.0.0' PACKAGE_STRING='rate4site 3.0.0' PACKAGE_BUGREPORT='http://www.tau.ac.il/~itaymay/cp/rate4site.html' PACKAGE_URL='' ac_unique_file="src/rate4site/rate4site.cpp" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS LN_S RANLIB EGREP GREP CXXCPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_dependency_tracking ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC CXXCPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures rate4site 3.0.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/rate4site] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of rate4site 3.0.0:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF rate4site configure 3.0.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## -------------------------------------------------------------- ## ## Report this to http://www.tau.ac.il/~itaymay/cp/rate4site.html ## ## -------------------------------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile # ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES # --------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_cxx_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by rate4site $as_me 3.0.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='rate4site' VERSION='3.0.0' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' ac_config_headers="$ac_config_headers config.h" ac_config_files="$ac_config_files Makefile src/phylogeny/Makefile src/rate4site/Makefile" # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test -z $CXXFLAGS; then CXXFLAGS='-O3 -Wno-deprecated' fi # use the C++ compiler for the following checks ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # Checks for header files. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in string do : ac_fn_cxx_check_header_mongrel "$LINENO" "string" "ac_cv_header_string" "$ac_includes_default" if test "x$ac_cv_header_string" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRING 1 _ACEOF fi done for ac_header in iostream do : ac_fn_cxx_check_header_mongrel "$LINENO" "iostream" "ac_cv_header_iostream" "$ac_includes_default" if test "x$ac_cv_header_iostream" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_IOSTREAM 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. ac_fn_cxx_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by rate4site $as_me 3.0.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ rate4site config.status 3.0.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/phylogeny/Makefile") CONFIG_FILES="$CONFIG_FILES src/phylogeny/Makefile" ;; "src/rate4site/Makefile") CONFIG_FILES="$CONFIG_FILES src/rate4site/Makefile" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi rate4site-3.0.0/AUTHORS0000644011611301161130000000013412223673417011414 00000000000000 Files: * Copyright (C) 2004: Mayrose, I. Graur, D. Ben-Tal, N. Pupko, T rate4site-3.0.0/COPYING0000644011611301161130000004311012223673417011400 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. rate4site-3.0.0/ChangeLog0000644011611301161130000000021112223673417012112 00000000000000rate4site (3.0.0) UNRELEASED; urgency=low * Initial release. -- Guy Yachdav Mon, 12 Aug 2013 10:59:54 +0200 rate4site-3.0.0/INSTALL0000644011611301161130000003660012223673417011404 00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX `make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as `configure' are involved. Use GNU `make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. rate4site-3.0.0/NEWS0000644011611301161130000000000012223673417011033 00000000000000rate4site-3.0.0/depcomp0000755011611301161130000005064312223673475011737 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2012-03-27.16; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # A tabulation character. tab=' ' # A newline character. nl=' ' if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' "$nl" < "$tmpdepfile" | ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependent.h'. # Do two passes, one to just change these to # '$object: dependent.h' and one to simply 'dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. # However on # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\': # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... # tcc 0.9.26 (FIXME still under development at the moment of writing) # will emit a similar output, but also prepend the continuation lines # with horizontal tabulation characters. "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form 'foo.o: dependent.h', # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. # Do two passes, one to just change these to # '$object: dependent.h' and one to simply 'dependent.h:'. sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ < "$tmpdepfile" > "$depfile" sed ' s/[ '"$tab"'][ '"$tab"']*/ /g s/^ *// s/ *\\*$// s/^[^:]*: *// /^$/d /:$/d s/$/ :/ ' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' "$nl" < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: rate4site-3.0.0/install-sh0000755011611301161130000003325612223673475012367 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: rate4site-3.0.0/missing0000755011611301161130000002415212223673475011755 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: rate4site-3.0.0/src/0000755011611301161130000000000012223673504011212 500000000000000rate4site-3.0.0/src/phylogeny/0000755011611301161130000000000012223673504013230 500000000000000rate4site-3.0.0/src/phylogeny/replacementMatrixSource/0000755011611301161130000000000012223673503020074 500000000000000rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mitochondriaAscidian.code0000644011611301161130000000100112223673410024751 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG AGA AGG " "H CAT CAC " "I ATT ATC " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG ATA " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG " "W TGG TGA " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG " "i ATG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines " rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mitochondriaProtozoan.code0000644011611301161130000000103412223673410025237 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG AGA AGG " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC ATA " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG " "W TGG TGA " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG " "i ATG GTG ATA ATC ATT CTG TTG TTA " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines "rate4site-3.0.0/src/phylogeny/replacementMatrixSource/nuclearCiliate.code0000644011611301161130000000100012223673410023560 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG AGA AGG " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG TAA TAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC ATA " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG " "W TGG " "Y TAT TAC " "V GTT GTC GTA GTG " "* TGA " "i ATG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines "rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mitochondriaEchinoderm.code0000644011611301161130000000100112223673410025313 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG " "N AAT AAC AAA " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC ATA " "L CTT CTC CTA CTG TTA TTG " "K AAG " "M ATG " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC AGA AGG " "T ACT ACC ACA ACG " "W TGG TGA " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG " "i ATG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines " rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mitochondriaVertebrate.code0000644011611301161130000000102112223673410025343 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG ATA " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG " "W TGG TGA " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG AGG AGA " "i ATG GTG ATA ATC ATT " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines "rate4site-3.0.0/src/phylogeny/replacementMatrixSource/nuclearEuplotid.code0000644011611301161130000000100012223673410023773 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG AGA AGG " "N AAT AAC " "D GAT GAC " "C TGT TGC TGA " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC ATA " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG " "W TGG " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG " "i ATG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines "rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mitochondriaFlatworm.code0000644011611301161130000000100112223673410025031 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG " "N AAT AAC AAA " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC ATA " "L CTT CTC CTA CTG TTA TTG " "K AAG " "M ATG " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC AGA AGG " "T ACT ACC ACA ACG " "W TGG TGA " "Y TAT TAC TAA " "V GTT GTC GTA GTG " "* TAG " "i ATG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines " rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mitochondriaYeast.code0000644011611301161130000000100012223673410024322 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG AGG AGA " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC " "L TTA TTG " "K AAA AAG " "M ATG ATA " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG CTT CTC CTA CTG " "W TGG TGA " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG " "i ATG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines "rate4site-3.0.0/src/phylogeny/replacementMatrixSource/nuclearStandard.code0000644011611301161130000000101012223673410023747 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG AGA AGG " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC ATA " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG " "W TGG " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG TGA " "i ATG CTG TTG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines " rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mitochondriaInvertebrate.code0000644011611301161130000000102512223673410025676 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG ATA " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC AGA AGG " "T ACT ACC ACA ACG " "W TGG TGA " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TAG " "i ATG GTG ATA ATC ATT TTG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines "rate4site-3.0.0/src/phylogeny/replacementMatrixSource/nuclearBlepharisma.code0000644011611301161130000000100012223673410024435 00000000000000"A GCT GCC GCA GCG " "R CGT CGC CGA CGG AGA AGG " "N AAT AAC " "D GAT GAC " "C TGT TGC " "Q CAA CAG TAG " "E GAA GAG " "G GGT GGC GGA GGG " "H CAT CAC " "I ATT ATC ATA " "L CTT CTC CTA CTG TTA TTG " "K AAA AAG " "M ATG " "F TTT TTC " "P CCT CCC CCA CCG " "S TCT TCC TCA TCG AGT AGC " "T ACT ACC ACA ACG " "W TGG " "Y TAT TAC " "V GTT GTC GTA GTG " "* TAA TGA " "i ATG " "### taken from http://bioinformatics.org/JaMBW/2/3/TranslationTables.html " "### NOTE: initiation codons must appear after all codon lines "rate4site-3.0.0/src/phylogeny/replacementMatrixSource/cpREV45.dat0000644011611301161130000000212112223673410021627 00000000000000 105 227 357 175 43 4435 669 823 538 10 157 1745 768 400 10 499 152 1055 3691 10 3122 665 243 653 431 303 133 379 66 715 1405 331 441 1269 162 19 145 136 168 10 280 92 148 40 29 197 203 113 10 396 286 82 20 66 1745 236 4482 2430 412 48 3313 2629 263 305 345 218 185 125 61 47 159 202 113 21 10 1772 1351 193 68 53 97 22 726 10 145 25 127 454 1268 72 327 490 87 173 170 285 323 185 28 152 117 219 302 100 43 2440 385 2085 590 2331 396 568 691 303 216 516 868 93 487 1202 1340 314 1393 266 576 241 369 92 32 1040 156 918 645 148 260 2151 14 230 40 18 435 53 63 82 69 42 159 10 86 468 49 73 29 56 323 754 281 1466 391 142 10 1971 89 189 247 215 2370 97 522 71 346 968 92 83 75 592 54 200 91 25 4797 865 249 475 317 122 167 760 10 119 0.076 0.062 0.041 0.037 0.009 0.038 0.049 0.084 0.025 0.081 0.101 0.050 0.022 0.051 0.043 0.062 0.054 0.018 0.031 0.066 cpREV45 model rate4site-3.0.0/src/phylogeny/replacementMatrixSource/dayhoff.dat0000644011611301161130000000735112223673410022131 00000000000000 27 98 32 120 0 905 36 23 0 0 89 246 103 134 0 198 1 148 1153 0 716 240 9 139 125 11 28 81 23 240 535 86 28 606 43 10 65 64 77 24 44 18 61 0 7 41 15 34 0 0 73 11 7 44 257 26 464 318 71 0 153 83 27 26 46 18 72 90 1 0 0 114 30 17 0 336 527 243 18 14 14 0 0 0 0 15 48 196 157 0 92 250 103 42 13 19 153 51 34 94 12 32 33 17 11 409 154 495 95 161 56 79 234 35 24 17 96 62 46 245 371 26 229 66 16 53 34 30 22 192 33 136 104 13 78 550 0 201 23 0 0 0 0 0 27 0 46 0 0 76 0 75 0 24 8 95 0 96 0 22 0 127 37 28 13 0 698 0 34 42 61 208 24 15 18 49 35 37 54 44 889 175 10 258 12 48 30 157 0 28 0.087127 0.040904 0.040432 0.046872 0.033474 0.038255 0.049530 0.088612 0.033618 0.036886 0.085357 0.080482 0.014753 0.039772 0.050680 0.069577 0.058542 0.010494 0.029916 0.064718 Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val S_ij = S_ji and PI_i for the Dayhoff model, with the rate Q_ij=S_ij*PI_j The rest of the file is not used. Prepared by Z. Yang, March 1995. See the following reference for notation used here: Yang, Z., R. Nielsen and M. Hasegawa. 1998. Models of amino acid substitution and applications to mitochondrial protein evolution. Mol. Biol. Evol. 15:1600-1611. ----------------------------------------------------------------------- 30 109 17 154 0 532 33 10 0 0 93 120 50 76 0 266 0 94 831 0 422 579 10 156 162 10 30 112 21 103 226 43 10 243 23 10 66 30 36 13 17 8 35 0 3 95 17 37 0 0 75 15 17 40 253 57 477 322 85 0 147 104 60 23 43 39 29 17 0 0 0 20 7 7 0 57 207 90 20 7 7 0 0 0 0 17 20 90 167 0 17 345 67 27 10 10 93 40 49 50 7 43 43 4 7 772 137 432 98 117 47 86 450 26 20 32 168 20 40 269 590 20 169 57 10 37 31 50 14 129 52 200 28 10 73 696 0 27 3 0 0 0 0 0 3 0 13 0 0 10 0 17 0 20 3 36 0 30 0 10 0 40 13 23 10 0 260 0 22 23 6 365 20 13 17 33 27 37 97 30 661 303 17 77 10 50 43 186 0 17 A R N D C Q E G H I L K M F P S T W Y V Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val Accepted point mutations (x10) Figure 80 (Dayhoff 1978) ------------------------------------------------------- A 100 /* Ala */ A 0.087 /* Ala */ R 65 /* Arg */ R 0.041 /* Arg */ N 134 /* Asn */ N 0.040 /* Asn */ D 106 /* Asp */ D 0.047 /* Asp */ C 20 /* Cys */ C 0.033 /* Cys */ Q 93 /* Gln */ Q 0.038 /* Gln */ E 102 /* Glu */ E 0.050 /* Glu */ G 49 /* Gly */ G 0.089 /* Gly */ H 66 /* His */ H 0.034 /* His */ I 96 /* Ile */ I 0.037 /* Ile */ L 40 /* Leu */ L 0.085 /* Leu */ K 56 /* Lys */ K 0.081 /* Lys */ M 94 /* Met */ M 0.015 /* Met */ F 41 /* Phe */ F 0.040 /* Phe */ P 56 /* Pro */ P 0.051 /* Pro */ S 120 /* Ser */ S 0.070 /* Ser */ T 97 /* Thr */ T 0.058 /* Thr */ W 18 /* Trp */ W 0.010 /* Trp */ Y 41 /* Tyr */ Y 0.030 /* Tyr */ V 74 /* Val */ V 0.065 /* Val */ scale factor = SUM_OF_PRODUCT = 75.246 Relative Mutability The equilibrium freqs. (Table 21) Table 22 (Dayhoff 1978) Dayhoff (1978) ---------------------------------------------------------------- rate4site-3.0.0/src/phylogeny/replacementMatrixSource/jones.dat0000644011611301161130000002711012223673410021622 00000000000000 58 54 45 81 16 528 56 113 34 10 57 310 86 49 9 105 29 58 767 5 323 179 137 81 130 59 26 119 27 328 391 112 69 597 26 23 36 22 47 11 17 9 12 6 16 30 38 12 7 23 72 9 6 56 229 35 646 263 26 7 292 181 27 45 21 14 54 44 30 15 31 43 18 14 33 479 388 65 15 5 10 4 78 4 5 5 40 89 248 4 43 194 74 15 15 14 164 18 24 115 10 102 21 16 17 378 101 503 59 223 53 30 201 73 40 59 47 29 92 285 475 64 232 38 42 51 32 33 46 245 25 103 226 12 118 477 9 126 8 4 115 18 10 55 8 9 52 10 24 53 6 35 12 11 20 70 46 209 24 7 8 573 32 24 8 18 536 10 63 21 71 298 17 16 31 62 20 45 47 11 961 180 14 323 62 23 38 112 25 16 0.076748 0.051691 0.042645 0.051544 0.019803 0.040752 0.061830 0.073152 0.022944 0.053761 0.091904 0.058676 0.023826 0.040126 0.050901 0.068765 0.058565 0.014261 0.032102 0.066005 Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val S_ij = S_ji and PI_i for the Jones model based on the SWISSPROT Version 22 data. Rate Q_ij=S_ij*PI_j. The rest of the file is not used. Prepared by Z. Yang, March 1995. See the following reference for notation: Yang, Z., R. Nielsen and M. Hasegawa. 1998. Models of amino acid substitution and applications to mitochondrial protein evolution. Mol. Biol. Evol. 15:1600-1611. ----------------------------------------------------------------------- 426 333 185 596 80 2134 159 214 54 20 332 1203 277 192 14 920 176 286 4497 11 1497 1853 954 470 907 158 144 999 88 716 704 244 58 1027 69 71 286 114 198 59 34 37 72 44 37 394 332 88 62 79 497 101 80 217 2086 294 3606 1209 148 15 1289 1210 215 115 121 140 185 100 56 34 27 78 50 47 33 1129 1567 167 84 21 33 16 115 14 23 28 69 354 1690 17 76 1395 360 64 74 27 629 106 171 249 54 882 117 36 66 3664 661 2706 390 559 278 236 1861 214 274 691 351 89 468 1839 3920 360 1069 216 91 227 217 266 116 1420 256 653 579 54 653 3527 19 171 9 5 60 20 17 106 5 13 127 16 15 56 8 64 18 49 62 178 142 246 59 26 34 777 102 131 30 25 1276 32 259 73 60 2771 111 86 195 150 100 336 420 32 6260 2020 99 937 307 142 320 805 44 63 A R N D C Q E G H I L K M F P S T W Y V Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val Accepted point mutations (x10), similar to Figure 80 of Dayhoff et al. (1978). SwissProt version 22 data. ------------------------------------------------------------------------------ 256458 426 333 596 159 332 920 1853 88 286 394 294 185 84 1395 3664 3920 19 49 2771 426 182302 185 80 214 1203 176 954 716 114 332 3606 100 21 360 661 360 171 62 111 333 185 150772 2134 54 277 286 470 704 198 88 1209 56 33 64 2706 1069 9 178 86 596 80 2134 178390 20 192 4497 907 244 59 62 148 34 16 74 390 216 5 142 195 159 214 54 20 68120 14 11 158 58 34 79 15 27 115 27 559 91 60 246 150 332 1203 277 192 14 139546 1497 144 1027 37 497 1289 78 14 629 278 227 20 59 100 920 176 286 4497 11 1497 218432 999 69 72 101 1210 50 23 106 236 217 17 26 336 1853 954 470 907 158 144 999 255274 71 44 80 215 47 28 171 1861 266 106 34 420 88 716 704 244 58 1027 69 71 77124 37 217 115 33 69 249 214 116 5 777 32 286 114 198 59 34 37 72 44 37 191018 2086 121 1129 354 54 274 1420 13 102 6260 394 332 88 62 79 497 101 80 217 2086 319504 140 1567 1690 882 691 256 127 131 2020 294 3606 1209 148 15 1289 1210 215 115 121 140 206568 167 17 117 351 653 16 30 99 185 100 56 34 27 78 50 47 33 1129 1567 167 84670 76 36 89 579 15 25 937 84 21 33 16 115 14 23 28 69 354 1690 17 76 143088 66 468 54 56 1276 307 1395 360 64 74 27 629 106 171 249 54 882 117 36 66 175488 1839 653 8 32 142 3664 661 2706 390 559 278 236 1861 214 274 691 351 89 468 1839 234536 3527 64 259 320 3920 360 1069 216 91 227 217 266 116 1420 256 653 579 54 653 3527 203636 18 73 805 19 171 9 5 60 20 17 106 5 13 127 16 15 56 8 64 18 50486 60 44 49 62 178 142 246 59 26 34 777 102 131 30 25 1276 32 259 73 60 114728 63 2771 111 86 195 150 100 336 420 32 6260 2020 99 937 307 142 320 805 44 63 223724 Observed difference counts from pairwise comparisons, with ancestral sequences constructed by parsimony. F(t) = PI*P(t). Based on the SwissProt 22 data, kindly provided by D. Jones (Jones et al. 1992) ------------------------------------------------------------------------------- Ala 0.98754 0.00030 0.00023 0.00042 0.00011 0.00023 0.00065 0.00130 0.00006 0.00020 0.00028 0.00021 0.00013 0.00006 0.00098 0.00257 0.00275 0.00001 0.00003 0.00194 Arg 0.00044 0.98974 0.00019 0.00008 0.00022 0.00125 0.00018 0.00099 0.00075 0.00012 0.00035 0.00376 0.00010 0.00002 0.00037 0.00069 0.00037 0.00018 0.00006 0.00012 Asn 0.00042 0.00023 0.98720 0.00269 0.00007 0.00035 0.00036 0.00059 0.00089 0.00025 0.00011 0.00153 0.00007 0.00004 0.00008 0.00342 0.00135 0.00001 0.00022 0.00011 Asp 0.00062 0.00008 0.00223 0.98954 0.00002 0.00020 0.00470 0.00095 0.00025 0.00006 0.00006 0.00015 0.00004 0.00002 0.00008 0.00041 0.00023 0.00001 0.00015 0.00020 Cys 0.00043 0.00058 0.00015 0.00005 0.99432 0.00004 0.00003 0.00043 0.00016 0.00009 0.00021 0.00004 0.00007 0.00031 0.00007 0.00152 0.00025 0.00016 0.00067 0.00041 Gln 0.00044 0.00159 0.00037 0.00025 0.00002 0.98955 0.00198 0.00019 0.00136 0.00005 0.00066 0.00170 0.00010 0.00002 0.00083 0.00037 0.00030 0.00003 0.00008 0.00013 Glu 0.00080 0.00015 0.00025 0.00392 0.00001 0.00130 0.99055 0.00087 0.00006 0.00006 0.00009 0.00105 0.00004 0.00002 0.00009 0.00021 0.00019 0.00001 0.00002 0.00029 Gly 0.00136 0.00070 0.00035 0.00067 0.00012 0.00011 0.00074 0.99350 0.00005 0.00003 0.00006 0.00016 0.00003 0.00002 0.00013 0.00137 0.00020 0.00008 0.00003 0.00031 His 0.00021 0.00168 0.00165 0.00057 0.00014 0.00241 0.00016 0.00017 0.98864 0.00009 0.00051 0.00027 0.00008 0.00016 0.00058 0.00050 0.00027 0.00001 0.00182 0.00008 Ile 0.00029 0.00011 0.00020 0.00006 0.00003 0.00004 0.00007 0.00004 0.00004 0.98729 0.00209 0.00012 0.00113 0.00035 0.00005 0.00027 0.00142 0.00001 0.00010 0.00627 Leu 0.00023 0.00019 0.00005 0.00004 0.00005 0.00029 0.00006 0.00005 0.00013 0.00122 0.99330 0.00008 0.00092 0.00099 0.00052 0.00040 0.00015 0.00007 0.00008 0.00118 Lys 0.00027 0.00331 0.00111 0.00014 0.00001 0.00118 0.00111 0.00020 0.00011 0.00011 0.00013 0.99100 0.00015 0.00002 0.00011 0.00032 0.00060 0.00001 0.00003 0.00009 Met 0.00042 0.00023 0.00013 0.00008 0.00006 0.00018 0.00011 0.00011 0.00007 0.00255 0.00354 0.00038 0.98818 0.00017 0.00008 0.00020 0.00131 0.00003 0.00006 0.00212 Phe 0.00011 0.00003 0.00004 0.00002 0.00015 0.00002 0.00003 0.00004 0.00009 0.00047 0.00227 0.00002 0.00010 0.99360 0.00009 0.00063 0.00007 0.00008 0.00171 0.00041 Pro 0.00148 0.00038 0.00007 0.00008 0.00003 0.00067 0.00011 0.00018 0.00026 0.00006 0.00093 0.00012 0.00004 0.00007 0.99270 0.00194 0.00069 0.00001 0.00003 0.00015 Ser 0.00287 0.00052 0.00212 0.00031 0.00044 0.00022 0.00018 0.00146 0.00017 0.00021 0.00054 0.00027 0.00007 0.00037 0.00144 0.98556 0.00276 0.00005 0.00020 0.00025 Thr 0.00360 0.00033 0.00098 0.00020 0.00008 0.00021 0.00020 0.00024 0.00011 0.00131 0.00024 0.00060 0.00053 0.00005 0.00060 0.00324 0.98665 0.00002 0.00007 0.00074 Trp 0.00007 0.00065 0.00003 0.00002 0.00023 0.00008 0.00006 0.00040 0.00002 0.00005 0.00048 0.00006 0.00006 0.00021 0.00003 0.00024 0.00007 0.99686 0.00023 0.00017 Tyr 0.00008 0.00010 0.00030 0.00024 0.00041 0.00010 0.00004 0.00006 0.00130 0.00017 0.00022 0.00005 0.00004 0.00214 0.00005 0.00043 0.00012 0.00010 0.99392 0.00011 Val 0.00226 0.00009 0.00007 0.00016 0.00012 0.00008 0.00027 0.00034 0.00003 0.00511 0.00165 0.00008 0.00076 0.00025 0.00012 0.00026 0.00066 0.00004 0.00005 0.98761 P(0.01), amino acid exchange data generated from SWISSPROT Release 22.0 Ref. Jones D.T., Taylor W.R. and Thornton J.M. (1992) CABIOS 8:275-282 Usable sequences: 23824 Final alignments: 5437 Accepted point mutations: 92883 A R N D C Q E G H I L K M F P S T W Y V 0.0767477 100 0.0516907 82.3263 0.0426448 102.697 0.0515445 83.8924 0.0198027 45.6097 0.0407523 83.8825 0.0618296 75.7914 0.0731516 52.1273 0.0229438 91.1374 0.0537609 101.99 0.0919042 53.7672 0.0586762 72.2308 0.0238262 94.8144 0.0401265 51.3146 0.0509007 58.5874 0.0687652 115.899 0.0585647 107.092 0.0142613 25.2297 0.0321015 48.7629 0.0660051 99.4571 Normalized Relative frequency mutabilities (SUM m*f) = 80.240436 ------------------------------------------- rate4site-3.0.0/src/phylogeny/replacementMatrixSource/mtREV24.dat0000644011611301161130000000443112223673410021650 00000000000000 23.18 26.95 13.24 17.67 1.90 794.38 59.93 103.33 58.94 1.90 1.90 220.99 173.56 55.28 75.24 9.77 1.90 63.05 583.55 1.90 313.56 120.71 23.03 53.30 56.77 30.71 6.75 28.28 13.90 165.23 496.13 113.99 141.49 582.40 49.12 1.90 96.49 1.90 27.10 4.34 62.73 8.34 3.31 5.98 12.26 25.46 15.58 15.16 1.90 25.65 39.70 1.90 2.41 11.49 329.09 8.36 141.40 608.70 2.31 1.90 465.58 313.86 22.73 127.67 19.57 14.88 141.88 1.90 65.41 1.90 6.18 47.37 1.90 1.90 11.97 517.98 537.53 91.37 6.37 4.69 15.20 4.98 70.80 19.11 2.67 1.90 48.16 84.67 216.06 6.44 90.82 54.31 23.64 73.31 13.43 31.26 137.29 12.83 1.90 60.97 20.63 40.10 50.10 18.84 17.31 387.86 6.04 494.39 69.02 277.05 54.11 54.71 125.93 77.46 47.70 73.61 105.79 111.16 64.29 169.90 480.72 2.08 238.46 28.01 179.97 94.93 14.82 11.17 44.78 368.43 126.40 136.33 528.17 33.85 128.22 597.21 1.90 21.95 10.68 19.86 33.60 1.90 1.90 10.92 7.08 1.90 32.44 24.00 21.71 7.84 4.21 38.58 9.99 6.48 1.90 191.36 21.21 254.77 38.82 13.12 3.21 670.14 25.01 44.15 51.17 39.96 465.58 16.21 64.92 38.73 26.25 195.06 7.64 1.90 1.90 1.90 19.00 21.14 2.53 1.90 1222.94 91.67 1.90 387.54 6.35 8.23 1.90 204.54 5.37 1.90 0.072 0.019 0.039 0.019 0.006 0.025 0.024 0.056 0.028 0.088 0.169 0.023 0.054 0.061 0.054 0.072 0.086 0.029 0.033 0.043 Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val S_ij = S_ji and PI_i for the mtREV24 model (Adachi and Hasegawa 1996). The PI's used to sum to 0.999 and I changed one of the freq from 0.168 into 0.169 so that the sum is 1. Prepared by Z. Yang according to data sent by Dr M. Hasegawa. This matrix was obtained from the 12 mitochondrial proteins encoded by the same strand of the DNA from a diverse range of species including bird, fish, frog, lamprey, as well as mammals (see Adachi and Hasegawa 1996 for details). The other matrix (mtmam.dat) included in the package is based on the same proteins from mammals only. Adachi, J. and Hasegawa, M. (1996) MOLPHY version 2.3: programs for molecular phylogenetics based on maximum likelihood. Computer Science Monographs of Institute of Statistical Mathematics 28:1-150. rate4site-3.0.0/src/phylogeny/replacementMatrixSource/wag.dat0000644011611301161130000000623012223673410021262 00000000000000 0.551571 0.509848 0.635346 0.738998 0.147304 5.429420 1.027040 0.528191 0.265256 0.0302949 0.908598 3.035500 1.543640 0.616783 0.0988179 1.582850 0.439157 0.947198 6.174160 0.021352 5.469470 1.416720 0.584665 1.125560 0.865584 0.306674 0.330052 0.567717 0.316954 2.137150 3.956290 0.930676 0.248972 4.294110 0.570025 0.249410 0.193335 0.186979 0.554236 0.039437 0.170135 0.113917 0.127395 0.0304501 0.138190 0.397915 0.497671 0.131528 0.0848047 0.384287 0.869489 0.154263 0.0613037 0.499462 3.170970 0.906265 5.351420 3.012010 0.479855 0.0740339 3.894900 2.584430 0.373558 0.890432 0.323832 0.257555 0.893496 0.683162 0.198221 0.103754 0.390482 1.545260 0.315124 0.174100 0.404141 4.257460 4.854020 0.934276 0.210494 0.102711 0.0961621 0.0467304 0.398020 0.0999208 0.0811339 0.049931 0.679371 1.059470 2.115170 0.088836 1.190630 1.438550 0.679489 0.195081 0.423984 0.109404 0.933372 0.682355 0.243570 0.696198 0.0999288 0.415844 0.556896 0.171329 0.161444 3.370790 1.224190 3.974230 1.071760 1.407660 1.028870 0.704939 1.341820 0.740169 0.319440 0.344739 0.967130 0.493905 0.545931 1.613280 2.121110 0.554413 2.030060 0.374866 0.512984 0.857928 0.822765 0.225833 0.473307 1.458160 0.326622 1.386980 1.516120 0.171903 0.795384 4.378020 0.113133 1.163920 0.0719167 0.129767 0.717070 0.215737 0.156557 0.336983 0.262569 0.212483 0.665309 0.137505 0.515706 1.529640 0.139405 0.523742 0.110864 0.240735 0.381533 1.086000 0.325711 0.543833 0.227710 0.196303 0.103604 3.873440 0.420170 0.398618 0.133264 0.428437 6.454280 0.216046 0.786993 0.291148 2.485390 2.006010 0.251849 0.196246 0.152335 1.002140 0.301281 0.588731 0.187247 0.118358 7.821300 1.800340 0.305434 2.058450 0.649892 0.314887 0.232739 1.388230 0.365369 0.314730 0.0866279 0.043972 0.0390894 0.0570451 0.0193078 0.0367281 0.0580589 0.0832518 0.0244313 0.048466 0.086209 0.0620286 0.0195027 0.0384319 0.0457631 0.0695179 0.0610127 0.0143859 0.0352742 0.0708956 A R N D C Q E G H I L K M F P S T W Y V Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val Symmetrical part of the rate matrix and aa frequencies, estimated from 3905 globular protein amino acid sequences forming 182 protein families. The first part above indicates the symmetric 'exchangeability' parameters, where s_ij = s_ji. The s_ij above are not scaled, but the PAML package will perform this scaling. The second part gives the amino acid frequencies (pi_i) estimated from the 3905 sequences. The net replacement rate from i to j is Q_ij = s_ij*pi_j. Prepared by Simon Whelan and Nick Goldman, September 2000. Citation: Whelan, S. and N. Goldman. In press. A general empirical model of protein evolution derived from multiple protein families using a maximum likelihood approach. Molecular Biology and Evolution. See the following reference for notation used here: Yang, Z., R. Nielsen and M. Hasegawa. 1998. Models of amino acid substitution and applications to mitochondrial protein evolution. Mol. Biol. Evol. 15:1600-1611. rate4site-3.0.0/src/phylogeny/cpREV45.dat.q0000644011611301161130000000224712223673415015237 00000000000000" 105 " " 227 357 " " 175 43 4435 " " 669 823 538 10 " " 157 1745 768 400 10 " " 499 152 1055 3691 10 3122 " " 665 243 653 431 303 133 379 " " 66 715 1405 331 441 1269 162 19 " " 145 136 168 10 280 92 148 40 29 " " 197 203 113 10 396 286 82 20 66 1745 " " 236 4482 2430 412 48 3313 2629 263 305 345 218 " " 185 125 61 47 159 202 113 21 10 1772 1351 193 " " 68 53 97 22 726 10 145 25 127 454 1268 72 327 " " 490 87 173 170 285 323 185 28 152 117 219 302 100 43 " " 2440 385 2085 590 2331 396 568 691 303 216 516 868 93 487 1202 " " 1340 314 1393 266 576 241 369 92 32 1040 156 918 645 148 260 2151 " " 14 230 40 18 435 53 63 82 69 42 159 10 86 468 49 73 29 " " 56 323 754 281 1466 391 142 10 1971 89 189 247 215 2370 97 522 71 346 " " 968 92 83 75 592 54 200 91 25 4797 865 249 475 317 122 167 760 10 119 " " 0.076 0.062 0.041 0.037 0.009 0.038 0.049 0.084 0.025 0.081 " " 0.101 0.050 0.022 0.051 0.043 0.062 0.054 0.018 0.031 0.066 " " cpREV45 model " rate4site-3.0.0/src/phylogeny/dayhoff.dat.q0000644011611301161130000001002712223673415015522 00000000000000" 27 " " 98 32 " " 120 0 905 " " 36 23 0 0 " " 89 246 103 134 0 " " 198 1 148 1153 0 716 " " 240 9 139 125 11 28 81 " " 23 240 535 86 28 606 43 10 " " 65 64 77 24 44 18 61 0 7 " " 41 15 34 0 0 73 11 7 44 257 " " 26 464 318 71 0 153 83 27 26 46 18 " " 72 90 1 0 0 114 30 17 0 336 527 243 " " 18 14 14 0 0 0 0 15 48 196 157 0 92 " " 250 103 42 13 19 153 51 34 94 12 32 33 17 11 " " 409 154 495 95 161 56 79 234 35 24 17 96 62 46 245 " " 371 26 229 66 16 53 34 30 22 192 33 136 104 13 78 550 " " 0 201 23 0 0 0 0 0 27 0 46 0 0 76 0 75 0 " " 24 8 95 0 96 0 22 0 127 37 28 13 0 698 0 34 42 61 " " 208 24 15 18 49 35 37 54 44 889 175 10 258 12 48 30 157 0 28 " " 0.087127 0.040904 0.040432 0.046872 0.033474 0.038255 0.049530 " " 0.088612 0.033618 0.036886 0.085357 0.080482 0.014753 0.039772 " " 0.050680 0.069577 0.058542 0.010494 0.029916 0.064718 " " Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val " " S_ij = S_ji and PI_i for the Dayhoff model, with the rate Q_ij=S_ij*PI_j " " The rest of the file is not used. " " Prepared by Z. Yang, March 1995. " " See the following reference for notation used here: " " Yang, Z., R. Nielsen and M. Hasegawa. 1998. Models of amino acid substitution and " " applications to mitochondrial protein evolution. Mol. Biol. Evol. 15:1600-1611. " " ----------------------------------------------------------------------- " " " " 30 " " 109 17 " " 154 0 532 " " 33 10 0 0 " " 93 120 50 76 0 " " 266 0 94 831 0 422 " " 579 10 156 162 10 30 112 " " 21 103 226 43 10 243 23 10 " " 66 30 36 13 17 8 35 0 3 " " 95 17 37 0 0 75 15 17 40 253 " " 57 477 322 85 0 147 104 60 23 43 39 " " 29 17 0 0 0 20 7 7 0 57 207 90 " " 20 7 7 0 0 0 0 17 20 90 167 0 17 " " 345 67 27 10 10 93 40 49 50 7 43 43 4 7 " " 772 137 432 98 117 47 86 450 26 20 32 168 20 40 269 " " 590 20 169 57 10 37 31 50 14 129 52 200 28 10 73 696 " " 0 27 3 0 0 0 0 0 3 0 13 0 0 10 0 17 0 " " 20 3 36 0 30 0 10 0 40 13 23 10 0 260 0 22 23 6 " " 365 20 13 17 33 27 37 97 30 661 303 17 77 10 50 43 186 0 17 " " A R N D C Q E G H I L K M F P S T W Y V " " Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val " " Accepted point mutations (x10) Figure 80 (Dayhoff 1978) " " ------------------------------------------------------- " " A 100 /* Ala */ A 0.087 /* Ala */ " " R 65 /* Arg */ R 0.041 /* Arg */ " " N 134 /* Asn */ N 0.040 /* Asn */ " " D 106 /* Asp */ D 0.047 /* Asp */ " " C 20 /* Cys */ C 0.033 /* Cys */ " " Q 93 /* Gln */ Q 0.038 /* Gln */ " " E 102 /* Glu */ E 0.050 /* Glu */ " " G 49 /* Gly */ G 0.089 /* Gly */ " " H 66 /* His */ H 0.034 /* His */ " " I 96 /* Ile */ I 0.037 /* Ile */ " " L 40 /* Leu */ L 0.085 /* Leu */ " " K 56 /* Lys */ K 0.081 /* Lys */ " " M 94 /* Met */ M 0.015 /* Met */ " " F 41 /* Phe */ F 0.040 /* Phe */ " " P 56 /* Pro */ P 0.051 /* Pro */ " " S 120 /* Ser */ S 0.070 /* Ser */ " " T 97 /* Thr */ T 0.058 /* Thr */ " " W 18 /* Trp */ W 0.010 /* Trp */ " " Y 41 /* Tyr */ Y 0.030 /* Tyr */ " " V 74 /* Val */ V 0.065 /* Val */ " " scale factor = SUM_OF_PRODUCT = 75.246 " " Relative Mutability The equilibrium freqs. " " (Table 21) Table 22 " " (Dayhoff 1978) Dayhoff (1978) " " ---------------------------------------------------------------- " rate4site-3.0.0/src/phylogeny/jones.dat.q0000644011611301161130000003010112223673417015215 00000000000000" 58 " " 54 45 " " 81 16 528 " " 56 113 34 10 " " 57 310 86 49 9 " " 105 29 58 767 5 323 " " 179 137 81 130 59 26 119 " " 27 328 391 112 69 597 26 23 " " 36 22 47 11 17 9 12 6 16 " " 30 38 12 7 23 72 9 6 56 229 " " 35 646 263 26 7 292 181 27 45 21 14 " " 54 44 30 15 31 43 18 14 33 479 388 65 " " 15 5 10 4 78 4 5 5 40 89 248 4 43 " " 194 74 15 15 14 164 18 24 115 10 102 21 16 17 " " 378 101 503 59 223 53 30 201 73 40 59 47 29 92 285 " " 475 64 232 38 42 51 32 33 46 245 25 103 226 12 118 477 " " 9 126 8 4 115 18 10 55 8 9 52 10 24 53 6 35 12 " " 11 20 70 46 209 24 7 8 573 32 24 8 18 536 10 63 21 71 " " 298 17 16 31 62 20 45 47 11 961 180 14 323 62 23 38 112 25 16 " " 0.076748 0.051691 0.042645 0.051544 0.019803 0.040752 0.061830 " " 0.073152 0.022944 0.053761 0.091904 0.058676 0.023826 0.040126 " " 0.050901 0.068765 0.058565 0.014261 0.032102 0.066005 " " Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val " " S_ij = S_ji and PI_i for the Jones model based on the SWISSPROT " " Version 22 data. " " Rate Q_ij=S_ij*PI_j. " " The rest of the file is not used. " " Prepared by Z. Yang, March 1995. " " See the following reference for notation: " " Yang, Z., R. Nielsen and M. Hasegawa. 1998. Models of amino acid substitution and " " applications to mitochondrial protein evolution. Mol. Biol. Evol. 15:1600-1611. " " ----------------------------------------------------------------------- " " 426 " " 333 185 " " 596 80 2134 " " 159 214 54 20 " " 332 1203 277 192 14 " " 920 176 286 4497 11 1497 " " 1853 954 470 907 158 144 999 " " 88 716 704 244 58 1027 69 71 " " 286 114 198 59 34 37 72 44 37 " " 394 332 88 62 79 497 101 80 217 2086 " " 294 3606 1209 148 15 1289 1210 215 115 121 140 " " 185 100 56 34 27 78 50 47 33 1129 1567 167 " " 84 21 33 16 115 14 23 28 69 354 1690 17 76 " " 1395 360 64 74 27 629 106 171 249 54 882 117 36 66 " " 3664 661 2706 390 559 278 236 1861 214 274 691 351 89 468 1839 " " 3920 360 1069 216 91 227 217 266 116 1420 256 653 579 54 653 3527 " " 19 171 9 5 60 20 17 106 5 13 127 16 15 56 8 64 18 " " 49 62 178 142 246 59 26 34 777 102 131 30 25 1276 32 259 73 60 " " 2771 111 86 195 150 100 336 420 32 6260 2020 99 937 307 142 320 805 44 63 " " A R N D C Q E G H I L K M F P S T W Y V " " Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val " " Accepted point mutations (x10), similar to Figure 80 of Dayhoff et " " al. (1978). SwissProt version 22 data. " " ------------------------------------------------------------------------------ " " 256458 426 333 596 159 332 920 1853 88 286 394 294 185 84 1395 3664 3920 19 49 2771 " " 426 182302 185 80 214 1203 176 954 716 114 332 3606 100 21 360 661 360 171 62 111 " " 333 185 150772 2134 54 277 286 470 704 198 88 1209 56 33 64 2706 1069 9 178 86 " " 596 80 2134 178390 20 192 4497 907 244 59 62 148 34 16 74 390 216 5 142 195 " " 159 214 54 20 68120 14 11 158 58 34 79 15 27 115 27 559 91 60 246 150 " " 332 1203 277 192 14 139546 1497 144 1027 37 497 1289 78 14 629 278 227 20 59 100 " " 920 176 286 4497 11 1497 218432 999 69 72 101 1210 50 23 106 236 217 17 26 336 " " 1853 954 470 907 158 144 999 255274 71 44 80 215 47 28 171 1861 266 106 34 420 " " 88 716 704 244 58 1027 69 71 77124 37 217 115 33 69 249 214 116 5 777 32 " " 286 114 198 59 34 37 72 44 37 191018 2086 121 1129 354 54 274 1420 13 102 6260 " " 394 332 88 62 79 497 101 80 217 2086 319504 140 1567 1690 882 691 256 127 131 2020 " " 294 3606 1209 148 15 1289 1210 215 115 121 140 206568 167 17 117 351 653 16 30 99 " " 185 100 56 34 27 78 50 47 33 1129 1567 167 84670 76 36 89 579 15 25 937 " " 84 21 33 16 115 14 23 28 69 354 1690 17 76 143088 66 468 54 56 1276 307 " " 1395 360 64 74 27 629 106 171 249 54 882 117 36 66 175488 1839 653 8 32 142 " " 3664 661 2706 390 559 278 236 1861 214 274 691 351 89 468 1839 234536 3527 64 259 320 " " 3920 360 1069 216 91 227 217 266 116 1420 256 653 579 54 653 3527 203636 18 73 805 " " 19 171 9 5 60 20 17 106 5 13 127 16 15 56 8 64 18 50486 60 44 " " 49 62 178 142 246 59 26 34 777 102 131 30 25 1276 32 259 73 60 114728 63 " " 2771 111 86 195 150 100 336 420 32 6260 2020 99 937 307 142 320 805 44 63 223724 " " Observed difference counts from pairwise comparisons, with ancestral sequences " " constructed by parsimony. F(t) = PI*P(t). " " Based on the SwissProt 22 data, kindly provided by D. Jones (Jones et al. 1992) " " ------------------------------------------------------------------------------- " " Ala 0.98754 0.00030 0.00023 0.00042 0.00011 0.00023 0.00065 0.00130 0.00006 0.00020 0.00028 0.00021 0.00013 0.00006 0.00098 0.00257 0.00275 0.00001 0.00003 0.00194 " " Arg 0.00044 0.98974 0.00019 0.00008 0.00022 0.00125 0.00018 0.00099 0.00075 0.00012 0.00035 0.00376 0.00010 0.00002 0.00037 0.00069 0.00037 0.00018 0.00006 0.00012 " " Asn 0.00042 0.00023 0.98720 0.00269 0.00007 0.00035 0.00036 0.00059 0.00089 0.00025 0.00011 0.00153 0.00007 0.00004 0.00008 0.00342 0.00135 0.00001 0.00022 0.00011 " " Asp 0.00062 0.00008 0.00223 0.98954 0.00002 0.00020 0.00470 0.00095 0.00025 0.00006 0.00006 0.00015 0.00004 0.00002 0.00008 0.00041 0.00023 0.00001 0.00015 0.00020 " " Cys 0.00043 0.00058 0.00015 0.00005 0.99432 0.00004 0.00003 0.00043 0.00016 0.00009 0.00021 0.00004 0.00007 0.00031 0.00007 0.00152 0.00025 0.00016 0.00067 0.00041 " " Gln 0.00044 0.00159 0.00037 0.00025 0.00002 0.98955 0.00198 0.00019 0.00136 0.00005 0.00066 0.00170 0.00010 0.00002 0.00083 0.00037 0.00030 0.00003 0.00008 0.00013 " " Glu 0.00080 0.00015 0.00025 0.00392 0.00001 0.00130 0.99055 0.00087 0.00006 0.00006 0.00009 0.00105 0.00004 0.00002 0.00009 0.00021 0.00019 0.00001 0.00002 0.00029 " " Gly 0.00136 0.00070 0.00035 0.00067 0.00012 0.00011 0.00074 0.99350 0.00005 0.00003 0.00006 0.00016 0.00003 0.00002 0.00013 0.00137 0.00020 0.00008 0.00003 0.00031 " " His 0.00021 0.00168 0.00165 0.00057 0.00014 0.00241 0.00016 0.00017 0.98864 0.00009 0.00051 0.00027 0.00008 0.00016 0.00058 0.00050 0.00027 0.00001 0.00182 0.00008 " " Ile 0.00029 0.00011 0.00020 0.00006 0.00003 0.00004 0.00007 0.00004 0.00004 0.98729 0.00209 0.00012 0.00113 0.00035 0.00005 0.00027 0.00142 0.00001 0.00010 0.00627 " " Leu 0.00023 0.00019 0.00005 0.00004 0.00005 0.00029 0.00006 0.00005 0.00013 0.00122 0.99330 0.00008 0.00092 0.00099 0.00052 0.00040 0.00015 0.00007 0.00008 0.00118 " " Lys 0.00027 0.00331 0.00111 0.00014 0.00001 0.00118 0.00111 0.00020 0.00011 0.00011 0.00013 0.99100 0.00015 0.00002 0.00011 0.00032 0.00060 0.00001 0.00003 0.00009 " " Met 0.00042 0.00023 0.00013 0.00008 0.00006 0.00018 0.00011 0.00011 0.00007 0.00255 0.00354 0.00038 0.98818 0.00017 0.00008 0.00020 0.00131 0.00003 0.00006 0.00212 " " Phe 0.00011 0.00003 0.00004 0.00002 0.00015 0.00002 0.00003 0.00004 0.00009 0.00047 0.00227 0.00002 0.00010 0.99360 0.00009 0.00063 0.00007 0.00008 0.00171 0.00041 " " Pro 0.00148 0.00038 0.00007 0.00008 0.00003 0.00067 0.00011 0.00018 0.00026 0.00006 0.00093 0.00012 0.00004 0.00007 0.99270 0.00194 0.00069 0.00001 0.00003 0.00015 " " Ser 0.00287 0.00052 0.00212 0.00031 0.00044 0.00022 0.00018 0.00146 0.00017 0.00021 0.00054 0.00027 0.00007 0.00037 0.00144 0.98556 0.00276 0.00005 0.00020 0.00025 " " Thr 0.00360 0.00033 0.00098 0.00020 0.00008 0.00021 0.00020 0.00024 0.00011 0.00131 0.00024 0.00060 0.00053 0.00005 0.00060 0.00324 0.98665 0.00002 0.00007 0.00074 " " Trp 0.00007 0.00065 0.00003 0.00002 0.00023 0.00008 0.00006 0.00040 0.00002 0.00005 0.00048 0.00006 0.00006 0.00021 0.00003 0.00024 0.00007 0.99686 0.00023 0.00017 " " Tyr 0.00008 0.00010 0.00030 0.00024 0.00041 0.00010 0.00004 0.00006 0.00130 0.00017 0.00022 0.00005 0.00004 0.00214 0.00005 0.00043 0.00012 0.00010 0.99392 0.00011 " " Val 0.00226 0.00009 0.00007 0.00016 0.00012 0.00008 0.00027 0.00034 0.00003 0.00511 0.00165 0.00008 0.00076 0.00025 0.00012 0.00026 0.00066 0.00004 0.00005 0.98761 " " P(0.01), amino acid exchange data generated from SWISSPROT Release 22.0 " " Ref. Jones D.T., Taylor W.R. and Thornton J.M. (1992) CABIOS 8:275-282 " " Usable sequences: 23824 " " Final alignments: 5437 " " Accepted point mutations: 92883 " " A R N D C Q E G H I L K M F P S T W Y V " " 0.0767477 100 " " 0.0516907 82.3263 " " 0.0426448 102.697 " " 0.0515445 83.8924 " " 0.0198027 45.6097 " " 0.0407523 83.8825 " " 0.0618296 75.7914 " " 0.0731516 52.1273 " " 0.0229438 91.1374 " " 0.0537609 101.99 " " 0.0919042 53.7672 " " 0.0586762 72.2308 " " 0.0238262 94.8144 " " 0.0401265 51.3146 " " 0.0509007 58.5874 " " 0.0687652 115.899 " " 0.0585647 107.092 " " 0.0142613 25.2297 " " 0.0321015 48.7629 " " 0.0660051 99.4571 " " " " Normalized Relative " " frequency mutabilities " " (SUM m*f) = 80.240436 " " ------------------------------------------- " rate4site-3.0.0/src/phylogeny/mtREV24.dat.q0000644011611301161130000000463712223673415015257 00000000000000" " " 23.18 " " 26.95 13.24 " " 17.67 1.90 794.38 " " 59.93 103.33 58.94 1.90 " " 1.90 220.99 173.56 55.28 75.24 " " 9.77 1.90 63.05 583.55 1.90 313.56 " " 120.71 23.03 53.30 56.77 30.71 6.75 28.28 " " 13.90 165.23 496.13 113.99 141.49 582.40 49.12 1.90 " " 96.49 1.90 27.10 4.34 62.73 8.34 3.31 5.98 12.26 " " 25.46 15.58 15.16 1.90 25.65 39.70 1.90 2.41 11.49 329.09 " " 8.36 141.40 608.70 2.31 1.90 465.58 313.86 22.73 127.67 19.57 14.88 " " 141.88 1.90 65.41 1.90 6.18 47.37 1.90 1.90 11.97 517.98 537.53 91.37 " " 6.37 4.69 15.20 4.98 70.80 19.11 2.67 1.90 48.16 84.67 216.06 6.44 90.82 " " 54.31 23.64 73.31 13.43 31.26 137.29 12.83 1.90 60.97 20.63 40.10 50.10 18.84 17.31 " " 387.86 6.04 494.39 69.02 277.05 54.11 54.71 125.93 77.46 47.70 73.61 105.79 111.16 64.29 169.90 " " 480.72 2.08 238.46 28.01 179.97 94.93 14.82 11.17 44.78 368.43 126.40 136.33 528.17 33.85 128.22 597.21 " " 1.90 21.95 10.68 19.86 33.60 1.90 1.90 10.92 7.08 1.90 32.44 24.00 21.71 7.84 4.21 38.58 9.99 " " 6.48 1.90 191.36 21.21 254.77 38.82 13.12 3.21 670.14 25.01 44.15 51.17 39.96 465.58 16.21 64.92 38.73 26.25 " " 195.06 7.64 1.90 1.90 1.90 19.00 21.14 2.53 1.90 1222.94 91.67 1.90 387.54 6.35 8.23 1.90 204.54 5.37 1.90 " " 0.072 0.019 0.039 0.019 0.006 0.025 0.024 0.056 0.028 0.088 0.169 " " 0.023 0.054 0.061 0.054 0.072 0.086 0.029 0.033 0.043 " " Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val " " S_ij = S_ji and PI_i for the mtREV24 model (Adachi and Hasegawa 1996). " " The PI's used to sum to 0.999 and I changed one of the freq from 0.168 " " into 0.169 so that the sum is 1. Prepared by Z. Yang according to " " data sent by Dr M. Hasegawa. This matrix was obtained from the 12 " " mitochondrial proteins encoded by the same strand of the DNA from a " " diverse range of species including bird, fish, frog, lamprey, as well " " as mammals (see Adachi and Hasegawa 1996 for details). The other " " matrix (mtmam.dat) included in the package is based on the same " " proteins from mammals only. " " Adachi, J. and Hasegawa, M. (1996) MOLPHY version 2.3: programs for " " molecular phylogenetics based on maximum likelihood. Computer Science " " Monographs of Institute of Statistical Mathematics 28:1-150. " rate4site-3.0.0/src/phylogeny/wag.dat.q0000644011611301161130000000647312223673416014673 00000000000000" " " 0.551571 " " 0.509848 0.635346 " " 0.738998 0.147304 5.429420 " " 1.027040 0.528191 0.265256 0.0302949 " " 0.908598 3.035500 1.543640 0.616783 0.0988179 " " 1.582850 0.439157 0.947198 6.174160 0.021352 5.469470 " " 1.416720 0.584665 1.125560 0.865584 0.306674 0.330052 0.567717 " " 0.316954 2.137150 3.956290 0.930676 0.248972 4.294110 0.570025 0.249410 " " 0.193335 0.186979 0.554236 0.039437 0.170135 0.113917 0.127395 0.0304501 0.138190 " " 0.397915 0.497671 0.131528 0.0848047 0.384287 0.869489 0.154263 0.0613037 0.499462 3.170970 " " 0.906265 5.351420 3.012010 0.479855 0.0740339 3.894900 2.584430 0.373558 0.890432 0.323832 0.257555 " " 0.893496 0.683162 0.198221 0.103754 0.390482 1.545260 0.315124 0.174100 0.404141 4.257460 4.854020 0.934276 " " 0.210494 0.102711 0.0961621 0.0467304 0.398020 0.0999208 0.0811339 0.049931 0.679371 1.059470 2.115170 0.088836 1.190630 " " 1.438550 0.679489 0.195081 0.423984 0.109404 0.933372 0.682355 0.243570 0.696198 0.0999288 0.415844 0.556896 0.171329 0.161444 " " 3.370790 1.224190 3.974230 1.071760 1.407660 1.028870 0.704939 1.341820 0.740169 0.319440 0.344739 0.967130 0.493905 0.545931 1.613280 " " 2.121110 0.554413 2.030060 0.374866 0.512984 0.857928 0.822765 0.225833 0.473307 1.458160 0.326622 1.386980 1.516120 0.171903 0.795384 4.378020 " " 0.113133 1.163920 0.0719167 0.129767 0.717070 0.215737 0.156557 0.336983 0.262569 0.212483 0.665309 0.137505 0.515706 1.529640 0.139405 0.523742 0.110864 " " 0.240735 0.381533 1.086000 0.325711 0.543833 0.227710 0.196303 0.103604 3.873440 0.420170 0.398618 0.133264 0.428437 6.454280 0.216046 0.786993 0.291148 2.485390 " " 2.006010 0.251849 0.196246 0.152335 1.002140 0.301281 0.588731 0.187247 0.118358 7.821300 1.800340 0.305434 2.058450 0.649892 0.314887 0.232739 1.388230 0.365369 0.314730 " " 0.0866279 0.043972 0.0390894 0.0570451 0.0193078 0.0367281 0.0580589 0.0832518 0.0244313 0.048466 0.086209 0.0620286 0.0195027 0.0384319 0.0457631 0.0695179 0.0610127 0.0143859 0.0352742 0.0708956 " " A R N D C Q E G H I L K M F P S T W Y V " " Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val " " " " Symmetrical part of the rate matrix and aa frequencies, " " estimated from 3905 globular protein amino acid sequences forming 182 " " protein families. " " The first part above indicates the symmetric 'exchangeability' " " parameters, where s_ij = s_ji. The s_ij above are not scaled, but the " " PAML package will perform this scaling. " " The second part gives the amino acid frequencies (pi_i) " " estimated from the 3905 sequences. The net replacement rate from i to " " j is Q_ij = s_ij*pi_j. " " Prepared by Simon Whelan and Nick Goldman, September 2000. " " Citation: " " Whelan, S. and N. Goldman. In press. A general empirical model of " " protein evolution derived from multiple protein families using " " a maximum likelihood approach. Molecular Biology and " " Evolution. " " See the following reference for notation used here: " " Yang, Z., R. Nielsen and M. Hasegawa. 1998. Models of amino acid substitution and " " applications to mitochondrial protein evolution. Mol. Biol. Evol. 15:1600-1611. " rate4site-3.0.0/src/phylogeny/HIVb.dat.q0000644011611301161130000000466712223673415014707 00000000000000"" "0.16315391 " "0.0026528488 0.15680618 " "0.77200021 0.0026528488 9.3704985 " "0.065662251 0.18661252 0.045663061 0.0026528488 " "0.029241185 1.8153444 0.35657046 0.0026528488 0.0026528488 " "0.7859595 0.039751241 0.042054709 5.6172481 0.0026528488 1.3583647 " "1.1329574 1.9384101 0.17158679 1.5057888 0.47638319 0.032849536 2.0839453 " "0.044971782 4.796584 4.0566567 1.0170492 0.12737547 3.7434084 0.063530422 0.0026528488 " "0.0026528488 0.35934906 0.3610872 0.0093800488 0.0026528488 0.0026528488 0.0032315889 0.0026528488 0.054707578 " "0.11420832 0.37215595 0.0026528488 0.0046480457 0.068855751 0.79296833 0.0026528488 0.0026528488 0.92409864 3.1615537 " "0.0026528488 10.850151 4.1938515 0.0026528488 0.0026528488 3.4738365 2.4484839 0.27680089 0.0026528488 0.17101271 0.04324117 " "0.009902713 1.3338205 0.0026528488 0.0026528488 0.0026528488 0.1611213 0.093268326 0.0026528488 0.0026528488 5.9458299 2.8224242 0.68043448 " "0.0074953058 0.0026528488 0.0026528488 0.0026528488 4.9333171 0.0026528488 0.0026528488 0.15469345 0.077228672 1.803067 4.5230222 0.018180397 0.099760378 " "1.1259592 0.68101281 0.0039239772 0.018180397 0.0026528488 2.3727663 0.0063788279 0.0026528488 1.3015831 0.021784823 1.1022958 0.016652568 0.0026528488 0.0026528488 " "1.3085601 1.8459052 6.9741802 0.28026286 2.4900381 0.061711098 0.0026528488 2.324113 0.20307398 0.64624988 0.49218621 0.26746605 0.0026528488 0.50747511 2.8532025 " "8.4457685 1.5220348 3.6538588 0.14576024 0.39260517 0.12924096 0.15374532 0.19610654 0.37755025 4.5693569 0.023221606 2.4785142 2.6211525 0.0074953058 1.0686577 4.7385556 " "0.0026528488 0.52597396 0.0026528488 0.0026528488 1.3968681 0.014142867 0.0026528488 0.64556544 0.036884095 0.0026528488 0.39731344 0.0026528488 0.047262092 0.44002431 0.023584144 0.013196755 0.0026528488 " "0.0026528488 0.0052623288 0.93601524 0.35795048 4.0213579 0.059971891 0.042054709 0.0026528488 9.9186301 0.078613459 0.059416384 0.0026528488 0.0026528488 8.13894 0.016149535 0.34382193 0.056055755 0.67924601 " "4.0399067 0.043106352 0.014142867 0.55599996 0.22285362 0.011097026 0.54567507 0.50571521 0.0026528488 9.4117238 0.74829436 0.14104083 3.6361006 0.38374731 0.0026528488 0.039751241 0.37629386 0.0026528488 0.021784823 " "0.060490222 0.066039665 0.044127815 0.042109048 0.020075899 0.053606488 0.071567447 0.072308239 0.022293943 0.069730629 0.098851122 0.056968211 0.019768318 0.028809447 0.046025282 0.05060433 0.053636813 0.033011601 0.028350243 0.061625237 " rate4site-3.0.0/src/phylogeny/HIVw.dat.q0000644011611301161130000000464612223673415014731 00000000000000"" "0.021810606 " "0.18082842 0.046923924 " "1.2987859 0.019752881 8.6119047 " "0.049094712 0.83857481 0.017714543 0.0014641764 " "0.0014641764 3.1258994 0.10016958 0.0014641764 0.0014641764 " "1.6291158 0.0073686726 0.059013922 3.5501299 0.0014641764 0.93899388 " "0.54716271 3.9350911 0.017714543 3.0445791 0.014343013 0.017714543 4.3281346 " "0.0014641764 2.0041793 2.5180202 0.67873067 0.0014641764 5.4310694 0.0014641764 0.0014641764 " "0.0014641764 0.39260132 0.28903662 0.042497426 0.0014641764 0.010022346 0.011435569 0.0014641764 0.0014641764 " "0.046923924 0.17182315 0.0014641764 0.0014641764 0.0014641764 0.8464345 0.038021439 0.014343013 0.51650871 2.6655214 " "0.17358807 11.681111 3.1232346 0.26188639 0.0014641764 3.8275035 7.0170946 0.081825497 0.065612672 0.23938727 0.0014641764 " "0.0014641764 0.96240899 0.059013922 0.0014641764 0.0014641764 0.0014641764 0.0014641764 0.014343013 0.0014641764 5.0679244 3.3336075 1.1993479 " "0.17509295 0.0014641764 0.0014641764 0.0014641764 0.1062872 0.0014641764 0.0014641764 0.0014641764 0.0014641764 0.43423957 2.1926949 0.0014641764 0.0014641764 " "0.29570799 0.11851717 0.10098366 0.0014641764 0.0014641764 0.89168927 0.0014641764 0.0014641764 4.0834122 0.0014641764 2.8788489 0.032776467 0.0014641764 0.010022346 " "2.5166849 2.4452448 4.2665807 0.12529865 0.32854654 0.046923924 0.0014641764 1.838906 0.21235155 0.21672475 1.7991682 0.0014641764 0.11495981 1.2531563 4.1726098 " "7.0696878 0.27181058 1.3300754 0.18460189 0.0014641764 0.059472209 0.13433613 0.014343013 0.28099302 2.7419485 0.0014641764 1.185403 2.170826 0.033533153 1.2700295 1.856807 " "0.0014641764 1.7469498 0.0014641764 0.0014641764 1.6102836 0.012981329 0.0014641764 0.82749392 0.0014641764 0.0014641764 0.40127511 0.0014641764 0.0014641764 0.0014641764 0.0014641764 0.32257563 0.0014641764 " "0.0014641764 0.0014641764 1.4831375 0.66811539 2.4446914 0.0014641764 0.0014641764 0.0014641764 13.906425 0.033533153 0.0014641764 0.0014641764 0.16960961 1.2086132 0.0014641764 0.27325689 0.14366733 0.0014641764 " "7.2650675 0.081825497 0.021810606 0.85445233 0.0014641764 0.0014641764 0.64409704 0.81883185 0.24231504 7.2690793 0.86487141 0.037501949 4.3246792 0.66766443 0.0014641764 0.25261054 0.0014641764 0.0014641764 0.39673909 " "0.0377494 0.057321 0.0891129 0.0342034 0.0240105 0.0437824 0.0618606 0.0838496 0.0156076 0.0983641 0.0577867 0.0641682 0.0158419 0.0422741 0.0458601 0.0550846 0.0813774 0.019597 0.0205847 0.0515639 " rate4site-3.0.0/src/phylogeny/adrianCodon.dat.q0000644011611301161130000005545412223673416016341 00000000000000" 634 " " 25105 560 " " 1209 37271 620 " " 1353 344 196 494 " " 112 2048 176 34 21460 " " 0 140 1656 380 71026 41523 " " 238 255 56 2967 35040 33972 43340 " " 8628 295 812 370 1546 65 0 23 " " 328 7142 272 370 715 4680 1286 876 707 " " 1192 289 7588 303 103 124 1929 82 52300 924 " " 509 0 304 10057 836 0 806 6124 1328 45060 1132 " " 607 43 47 105 5067 0 0 0 863 56 221 189 " " 0 301 43 0 0 2141 279 0 0 475 32 0 27331 " " 167 88 393 141 1487 366 3364 545 193 140 538 162 5087 1030 " " 34 0 42 421 0 0 346 3233 0 0 61 718 31469 35230 1626 " " 2841 308 69 647 711 76 0 346 1297 278 124 413 193 49 200 0 " " 195 2491 229 114 57 356 73 12 114 945 197 0 8 74 42 9 2449 " " 286 295 1514 350 199 128 640 63 66 257 565 175 42 15 241 41 31892 2201 " " 352 19 175 3379 195 32 0 441 246 85 129 1259 106 0 126 176 4155 62775 2262 " " 190 36 58 114 2112 0 0 0 0 51 81 158 201 0 114 51 2926 203 490 116 " " 37 204 30 71 0 1701 355 109 35 444 1 0 27 114 56 21 205 1284 335 79 21842 " " 81 99 218 95 183 0 4067 30 94 182 10 76 164 61 192 0 617 512 2569 361 57041 44793 " " 54 30 30 239 134 158 0 2062 10 30 35 370 101 0 70 141 263 0 183 1574 32490 33996 32457 " " 1891 0 623 93 0 147 671 0 46674 151 12628 0 11 0 0 134 8237 543 0 277 818 47 0 0 " " 701 549 1184 0 0 246 241 87 5836 1540 12311 0 6 41 48 0 452 5598 739 0 16 841 253 0 40388 " " 854 120 2602 57 54 69 359 0 13337 47 37725 91 0 31 105 0 0 660 5014 399 118 0 2656 0 82443 40802 " " 695 0 735 893 81 28 0 661 12916 0 6008 2384 89 35 60 56 1344 0 484 9142 0 0 0 1483 85032 87710 53112 " " 208 39 0 46 600 0 0 0 19 0 0 55 7884 0 1512 386 2427 200 95 0 3069 0 0 0 2011 0 15 0 " " 35 133 6 0 0 387 59 0 0 142 42 0 365 3634 769 272 79 813 191 114 0 1470 0 70 95 1012 0 0 17551 " " 0 15 74 0 97 91 378 52 27 44 46 8 876 732 2298 588 106 83 604 90 286 0 1947 0 0 70 707 0 33878 14863 " " 63 0 14 229 8 0 114 484 67 48 0 147 280 278 720 3849 349 0 160 1407 0 0 0 1951 0 3 43 1427 22703 32337 15002 " " 1304 155 0 389 408 75 0 79 444 170 0 236 197 11 45 0 2595 59 234 256 149 35 74 60 51 0 0 143 109 12 0 27 " " 120 2602 73 69 0 258 160 112 46 821 22 78 0 43 18 0 158 647 151 46 14 149 84 17 1 119 23 2 0 42 7 20 2320 " " 0 168 893 221 158 73 415 109 0 180 336 209 35 1 131 44 138 148 1538 143 107 83 168 39 1 91 217 0 0 26 55 14 23280 3052 " " 117 9 91 3406 173 5 0 311 55 62 40 1017 39 0 16 75 274 0 113 787 57 14 76 93 0 16 26 138 10 0 1 44 3660 28072 2533 " " 450 59 100 310 7741 0 0 0 225 220 182 557 1008 0 588 153 639 41 127 145 2469 39 211 190 150 0 48 78 625 0 97 61 1324 82 245 122 " " 28 466 94 52 0 6013 75 0 50 1265 106 0 0 452 240 0 47 248 183 0 14 2010 303 164 55 277 0 61 0 333 64 62 86 670 189 0 17008 " " 130 336 356 168 0 401 16072 0 103 537 357 370 656 161 817 0 379 93 512 228 0 428 10166 0 0 195 789 0 0 83 543 33 0 379 1907 42 47381 29661 " " 89 80 65 525 0 0 0 7268 98 211 0 1307 86 67 226 484 125 11 108 230 58 130 0 2312 0 0 130 252 29 17 64 381 133 0 145 799 30850 26704 28871 " " 285 65 23 253 446 24 106 6 2230 278 0 315 177 0 65 33 468 34 17 54 163 23 55 33 366 0 0 0 145 26 0 28 1661 180 0 104 2231 92 0 278 " " 28 1227 58 189 12 521 129 103 53 5470 0 0 37 87 33 21 31 344 83 26 64 236 268 30 0 941 162 1 0 80 13 28 0 1655 105 0 0 2186 744 149 19297 " " 27 356 299 139 176 0 843 160 0 684 3262 829 29 45 241 0 110 65 309 60 76 115 522 18 0 0 1073 0 0 2 82 0 0 67 1559 183 750 315 5134 73 44365 23295 " " 92 205 66 1727 96 190 0 728 0 13 0 7147 0 0 47 96 0 0 89 555 60 34 0 335 244 0 0 1432 18 0 18 105 59 0 63 2203 356 0 0 2632 28434 37047 23095 " " 318 54 33 115 3527 41 76 0 518 181 0 64 23970 0 1303 260 576 75 64 47 821 131 0 0 179 0 0 0 4505 11 14 274 764 39 80 51 6746 0 0 30 1310 0 179 0 " " 27 179 23 44 3 2249 0 308 11 354 78 34 330 12669 395 164 61 157 53 32 75 413 144 0 0 108 75 38 251 3338 87 38 51 294 54 0 0 4666 0 0 0 797 0 0 22326 " " 20 26 113 25 429 137 2071 322 0 22 220 58 3262 1931 2537 1548 21 38 128 48 121 44 321 57 0 41 121 25 34 50 1723 0 34 0 336 11 1230 167 5933 77 0 0 790 43 45141 19340 " " 76 42 6 207 135 150 294 2554 64 143 0 486 810 110 539 13791 171 2 57 142 0 0 134 537 0 31 5 200 0 58 22 3459 129 0 7 388 0 0 0 5346 0 31 0 1160 31707 35610 22203 " " 18 407 23 0 0 68 19 36 42 165 0 0 2 88 44 2 117 3381 122 0 0 99 45 6 0 290 36 0 0 266 30 38 18 159 13 0 1 58 142 23 0 80 5 0 3 144 35 0 " " 33 0 23 658 24 44 108 126 0 20 64 327 60 14 66 133 254 286 87 4548 15 0 8 90 141 9 0 754 142 1 81 288 33 0 33 255 39 24 0 112 18 0 29 130 37 14 20 166 53555 " " 277 164 108 290 6514 235 482 1018 165 446 8 1100 435 12 319 0 838 111 227 157 5890 0 507 0 340 0 64 3 320 0 0 0 245 73 90 109 6631 419 0 627 412 59 338 125 825 102 176 201 47 59 " " 51 577 50 66 169 4821 1421 355 54 2047 24 106 112 72 80 62 188 439 166 46 0 5279 0 0 0 368 104 23 0 445 72 0 30 239 87 0 264 4869 738 374 122 466 103 38 4 415 40 126 541 37 22923 " " 110 82 145 163 1203 0 14459 754 24 1451 151 763 183 30 477 38 0 233 599 0 273 0 12183 0 111 219 802 0 707 0 0 0 110 158 176 42 520 675 20335 0 0 499 1107 178 0 0 564 0 146 0 76141 40261 " " 112 181 54 602 1180 581 0 5578 112 651 68 1954 0 31 157 150 297 90 115 657 0 135 0 5714 0 0 0 679 0 0 41 578 87 3 74 288 631 521 937 5109 167 107 21 611 147 31 96 454 0 834 31553 32600 44414 " " 31 241 33 0 45 319 0 86 16 1649 42 219 33 130 46 2 125 576 73 12 0 102 64 24 110 1890 226 0 0 317 18 43 0 51 24 0 56 410 279 66 0 774 82 0 50 219 33 124 1297 0 172 1595 327 77 " " 20 14 49 22 39 18 92 0 48 39 549 56 30 14 95 20 79 42 201 130 28 0 142 1 270 84 1199 29 74 19 105 19 10 3 27 6 35 31 67 0 8 14 446 0 13 9 56 41 166 229 174 47 576 33 341 " " 43 8 28 397 156 20 280 403 108 352 75 2043 29 21 59 187 145 43 89 989 22 0 91 211 106 0 104 2711 123 20 35 305 27 19 7 86 180 46 200 423 72 80 88 1072 108 58 112 224 0 2135 495 0 187 2090 61046 387 " " 123 9 9 101 615 6 102 140 180 69 106 0 6752 231 1116 418 193 9 104 167 205 38 23 15 0 83 4 103 54777 7485 8703 8464 67 34 41 0 611 88 0 90 49 0 18 92 6666 153 0 364 159 265 4644 80 0 186 96 51 168 " " 12 70 0 0 23 155 11 48 3 70 0 0 70 742 186 61 38 346 27 46 25 170 6 0 0 117 17 14 220 2693 284 0 5 27 8 0 0 162 124 20 3 48 23 0 28 957 87 0 3979 750 23 924 0 0 574 154 61 1268 " " 59 45 80 75 192 81 637 163 28 0 74 99 1733 57 3345 832 131 42 198 55 181 6 226 149 53 0 94 204 14044 5603 27723 9664 97 0 37 34 172 50 1000 141 1 32 254 0 523 72 2117 491 102 84 1377 107 5207 276 111 744 201 47609 814 " " 9 17 12 85 47 14 107 170 21 21 26 101 326 48 262 910 73 74 23 359 0 0 55 201 17 0 20 146 234 0 387 2714 16 0 5 30 82 2 39 186 30 18 5 66 172 13 125 928 625 4904 160 0 206 991 125 212 787 1638 32469 1494 " " 0.0282483 0.0206292 0.0319075 0.0182494 0.0168831 0.0159757 0.0058938 0.0144022 0.0135116 0.0190724 0.0118542 0.0136325 0.0093705 0.0199714 0.0218874 0.0174818 " " 0.0136792 0.0143825 0.0337043 0.0116006 0.0177685 0.0150006 0.0058835 0.0176118 0.0061893 0.0087184 0.0084944 0.0054224 0.0080368 0.0173529 0.0373569 0.0150280 " " 0.0311168 0.0246045 0.0388972 0.0251865 0.0179100 0.0212765 0.0059683 0.0199671 0.0184506 0.0176209 0.0132786 0.0115579 0.0083782 0.0137699 0.0265260 0.0136025 " " 0.0159995 0.0132055 0.0133496 0.0159777 0.0043280 0.0171276 0.0119089 0.0124708 0.0109899 0.0085271 0.0195872 0.0141357 0.0190797 " " AAA AAC AAG AAT ACA ACC ACG ACT AGA AGC AGG AGT ATA ATC ATG ATT " " CAA CAC CAG CAT CCA CCC CCG CCT CGA CGC CGG CGT CTA CTC CTG CTT " " GAA GAC GAG GAT GCA GCC GCG GCT GGA GGC GGG GGT GTA GTC GTG GTT " " TAC TAT TCA TCC TCG TCT TGC TGG TGT TTA TTC TTG TTT " " S_ij = S_ji and PI_i based on the empirical codon matrix: " " A Schneider, GM Cannarozzi and GH Gonnet. Empirical codon " " substitution matrix. BMC Bioinformatics 6:134. 2005. " rate4site-3.0.0/src/phylogeny/LG.dat.q0000644011611301161130000000400112223673416014400 00000000000000" 0.425093 " " 0.276818 0.751878 " " 0.395144 0.123954 5.076149 " " 2.489084 0.534551 0.528768 0.062556 " " 0.969894 2.807908 1.695752 0.523386 0.084808 " " 1.038545 0.363970 0.541712 5.243870 0.003499 4.128591 " " 2.066040 0.390192 1.437645 0.844926 0.569265 0.267959 0.348847 " " 0.358858 2.426601 4.509238 0.927114 0.640543 4.813505 0.423881 0.311484 " " 0.149830 0.126991 0.191503 0.010690 0.320627 0.072854 0.044265 0.008705 0.108882 " " 0.395337 0.301848 0.068427 0.015076 0.594007 0.582457 0.069673 0.044261 0.366317 4.145067 " " 0.536518 6.326067 2.145078 0.282959 0.013266 3.234294 1.807177 0.296636 0.697264 0.159069 0.137500 " " 1.124035 0.484133 0.371004 0.025548 0.893680 1.672569 0.173735 0.139538 0.442472 4.273607 6.312358 0.656604 " " 0.253701 0.052722 0.089525 0.017416 1.105251 0.035855 0.018811 0.089586 0.682139 1.112727 2.592692 0.023918 1.798853 " " 1.177651 0.332533 0.161787 0.394456 0.075382 0.624294 0.419409 0.196961 0.508851 0.078281 0.249060 0.390322 0.099849 0.094464 " " 4.727182 0.858151 4.008358 1.240275 2.784478 1.223828 0.611973 1.739990 0.990012 0.064105 0.182287 0.748683 0.346960 0.361819 1.338132 " " 2.139501 0.578987 2.000679 0.425860 1.143480 1.080136 0.604545 0.129836 0.584262 1.033739 0.302936 1.136863 2.020366 0.165001 0.571468 6.472279 " " 0.180717 0.593607 0.045376 0.029890 0.670128 0.236199 0.077852 0.268491 0.597054 0.111660 0.619632 0.049906 0.696175 2.457121 0.095131 0.248862 0.140825 " " 0.218959 0.314440 0.612025 0.135107 1.165532 0.257336 0.120037 0.054679 5.306834 0.232523 0.299648 0.131932 0.481306 7.803902 0.089613 0.400547 0.245841 3.151815 " " 2.547870 0.170887 0.083688 0.037967 1.959291 0.210332 0.245034 0.076701 0.119013 10.649107 1.702745 0.185202 1.898718 0.654683 0.296501 0.098369 2.188158 0.189510 0.249313 " " 0.079066 0.055941 0.041977 0.053052 0.012937 0.040767 0.071586 0.057337 0.022355 0.062157 " " 0.099081 0.064600 0.022951 0.042302 0.044040 0.061197 0.053287 0.012066 0.034155 0.069147 " " Si Quang Le and Olivier Gascuel (LG) matrix " rate4site-3.0.0/src/phylogeny/getopt.h0000644011611301161130000001445712223673416014640 00000000000000/* Declarations for getopt. Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but that does not exist if we are standalone. So: if __GNU_LIBRARY__ is not defined, include , which will pull in for us if it's from glibc. (Why ctype.h? It's guaranteed to exist and it doesn't flood the namespace with stuff the way some other headers do.) */ #if !defined __GNU_LIBRARY__ # include #endif #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if (defined __STDC__ && __STDC__) || defined __cplusplus const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if (defined __STDC__ && __STDC__) || defined __cplusplus # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int __argc, char *const *__argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* getopt.h */ rate4site-3.0.0/src/phylogeny/errorMsg.h0000644011611301161130000000141112223673416015120 00000000000000// $Id: errorMsg.h 962 2006-11-07 15:13:34Z privmane $ // version 1.01 // last modified 1 Jan 2004 #ifndef ___ERROR_MSG_H #define ___ERROR_MSG_H #include #include #include using namespace std; // The error is always send to cerr. _errorOut is NULL, unless setErrorOstream is called. class errorMsg { public: static void reportError(const vector& textToPrint, const int exitCode=1); static void reportError(const string& textToPrint, const int exitCode=1); static void setErrorOstream(ostream* errorOut) {_errorOut = errorOut;} private: static ostream* _errorOut; }; // example of how to output to a file called error.txt // ofstream f("error.txt"); // errorMsg::setErrorOstream(&f); // errorMsg::reportError("cheers"); #endif rate4site-3.0.0/src/phylogeny/definitions.h0000644011611301161130000000510112223673415015632 00000000000000// $Id: definitions.h 10679 2012-05-29 19:04:27Z cohenofi $ #ifndef ___DEFINITIONS_H #define ___DEFINITIONS_H #ifdef _MSC_VER #define LIMITS_WORKING #endif #ifdef _MSC_VER #pragma warning (disable: 4786) #pragma warning (disable: 4267) #pragma warning (disable: 4018) #pragma warning (disable: 4305) //truncation from 'double' to 'float' #endif #include #include #ifdef LIMITS_WORKING #include #endif using namespace std; #define MDOUBLE double //#define MDOUBLE float // Contants #define PI (3.1415926535897932384626433832795028841971693993751058) typedef vector Vdouble; typedef vector Vint; typedef vector VVint; typedef vector VVVint; typedef vector Vchar; typedef vector VVdouble; typedef vector VVVdouble; typedef vector VVVVdouble; typedef vector VVVVVdouble; typedef vector Vstring; #ifdef LIMITS_WORKING const MDOUBLE VERYBIG = numeric_limits::max(); const MDOUBLE VERYSMALL = -VERYBIG; const MDOUBLE EPSILON = numeric_limits::epsilon(); #else // IF is not recognized, and MDOUBLE is double. const MDOUBLE VERYBIG = 1.79769e+308; const MDOUBLE VERYSMALL = -VERYBIG; const MDOUBLE EPSILON = 2.22045e-016; #endif //The maximum value for type float is: 3.40282e+038 //The maximum value for type double is: 1.79769e+308 //::epsilon() returns the difference between 1 and the smallest value greater than 1 that is representable for the data type. //epsilon float 1.19209e-007 //epsilon double 2.22045e-016 #ifdef LOGREP class logRep; typedef vector VlogRep; typedef vector > VVlogRep; typedef vector< vector > > VVVlogRep; typedef logRep doubleRep; typedef VlogRep VdoubleRep; typedef VVlogRep VVdoubleRep; typedef VVVlogRep VVVdoubleRep; #include "logRep.h" #elif defined (DOUBLEREP) class doubleRepMantisa; typedef vector VdoubleRepMantisa; typedef vector > VVdoubleRepMantisa; typedef vector VVVdoubleRepMantisa; typedef vector VVVVdoubleRepMantisa; typedef doubleRepMantisa doubleRep; typedef VdoubleRepMantisa VdoubleRep; typedef VVdoubleRepMantisa VVdoubleRep; typedef VVVdoubleRepMantisa VVVdoubleRep; typedef VVVVdoubleRepMantisa VVVVdoubleRep; #include "doubleRep.h" #else typedef MDOUBLE doubleRep; typedef Vdouble VdoubleRep; typedef VVdouble VVdoubleRep; typedef VVVdouble VVVdoubleRep; typedef VVVVdouble VVVVdoubleRep; inline MDOUBLE convert (MDOUBLE d) {return (d);} #endif #endif rate4site-3.0.0/src/phylogeny/doubleRep.h0000644011611301161130000002102512223673416015244 00000000000000#ifndef __DOUBLE_REP_H #define __DOUBLE_REP_H #ifdef DOUBLEREP #include "definitions.h" #include #include #include using namespace std; /* doubleRepMantisa: enables working with much larger or smaller numbers than normally possible by the regular double representation * Representation of a double x as x=_mantissa*2^_expon Note: Base is 2!! */ class doubleRepMantisa{ public: doubleRepMantisa(){}; explicit doubleRepMantisa(MDOUBLE mantissa, int expon); doubleRepMantisa(MDOUBLE a); doubleRepMantisa(const doubleRepMantisa& other); doubleRepMantisa* clone() {return new doubleRepMantisa(*this);} void output(ostream &out) const{ out<<_mantissa<(const doubleRepMantisa& a, const doubleRepMantisa& b); friend inline bool operator>=(const doubleRepMantisa& a, const doubleRepMantisa& b); friend inline doubleRepMantisa abs(const doubleRepMantisa& d); const MDOUBLE d_log() const; // friend ostream& operator<<(ostream &out, const doubleRepMantisa& a); const MDOUBLE mantissa() const {return _mantissa;} const int expon() const {return _expon;} private: void fixParams(); private: MDOUBLE _mantissa; int _expon; }; MDOUBLE convert(const doubleRepMantisa& a); //declaration of this function to be implemented cpp inline doubleRepMantisa& doubleRepMantisa::operator=(const doubleRepMantisa& a){ _mantissa=a.mantissa(); _expon=a.expon(); return *this; } inline doubleRepMantisa& doubleRepMantisa::operator++() { return (*this)+=1; } // matan: inline doubleRepMantisa doubleRepMantisa::operator++(int) { doubleRepMantisa ans = *this; ++(*this); return ans; } // matan: inline doubleRepMantisa& doubleRepMantisa::operator--() { return (*this)-=1; } // matan: inline doubleRepMantisa doubleRepMantisa::operator--(int) { doubleRepMantisa ans = *this; --(*this); return ans; } // Original version by Adi Stern inline doubleRepMantisa& doubleRepMantisa::operator+=(doubleRepMantisa a){ //ensuring that (*this) is bigger than 'a' for sake of convenience if (a.expon()>_expon || ((a.expon()==_expon) && (a.mantissa()>_mantissa))){ MDOUBLE tmpMant=0.0; int tmpExp=0; tmpMant=_mantissa; tmpExp=_expon; _mantissa=a.mantissa(); a._mantissa=tmpMant; tmpExp=_expon; _expon=a.expon(); a._expon=tmpExp; } if (a.mantissa()==0) return *this; if (_mantissa==0){ _mantissa=a.mantissa(); _expon=a.expon(); return *this; } int exp_dif = _expon-a.expon(); if (abs(exp_dif)>51){ //limit of epsilon difference return *this; } _mantissa+=a.mantissa()*pow(2.0,(a.expon()-_expon)*1.0); fixParams(); return *this; } inline doubleRepMantisa operator+(const doubleRepMantisa& a, const doubleRepMantisa& b){ doubleRepMantisa temp(a); temp+=b; return temp; } inline doubleRepMantisa& doubleRepMantisa::operator-=(const doubleRepMantisa& a){ doubleRepMantisa b(-a.mantissa(),a.expon()); doubleRepMantisa me(_mantissa,_expon); me+=b; _mantissa=me.mantissa(); _expon=me.expon(); return *this; } inline doubleRepMantisa operator-(const doubleRepMantisa& a, const doubleRepMantisa& b){ doubleRepMantisa temp(a); temp-=b; return temp; } inline doubleRepMantisa operator-(const doubleRepMantisa& a) { return doubleRepMantisa(0) - a; } inline doubleRepMantisa& doubleRepMantisa::operator*=(const doubleRepMantisa& a){ _mantissa*=a.mantissa(); _expon+=a.expon(); fixParams(); return *this; } inline doubleRepMantisa operator*(const doubleRepMantisa& a, const doubleRepMantisa& b){ doubleRepMantisa temp(a); temp*=b; return temp; } inline doubleRepMantisa& doubleRepMantisa::operator/=(const doubleRepMantisa& a){ _mantissa/=a.mantissa(); _expon-=a.expon(); fixParams(); return *this; } inline doubleRepMantisa operator/(const doubleRepMantisa& a, const doubleRepMantisa& b){ doubleRepMantisa temp(a); temp/=b; return temp; } /************************ * Comparison operators * ************************/ inline bool operator==(const doubleRepMantisa& a, const doubleRepMantisa& b){ return (a._mantissa==b._mantissa && a._expon==b._expon); } inline bool operator!=(const doubleRepMantisa& a, const doubleRepMantisa& b){ return !(a==b); } inline bool operator<(const doubleRepMantisa& a, const doubleRepMantisa& b){ // if the numbers have opposite signs if (a._mantissa*b._mantissa<0.0){ if (a._mantissa 0.0) {return true;} else {return false;} } if (b._mantissa == 0.0) { if (a._mantissa < 0.0) {return true;} else {return false;} } if (a._expon 0.0) {return true;} else {return false;} } else { if (a._mantissa < 0.0) {return true;} else {return false;} } // expon values are identical } else { return (a._mantissa < b._mantissa); } } inline bool operator>(const doubleRepMantisa& a, const doubleRepMantisa& b){ // if the numbers have opposite signs if (a._mantissa*b._mantissa<0.0){ if (a._mantissa>b._mantissa) {return true;} else {return false;} } // if the expon values are different if (a._expon!=b._expon) { // special case where one number is zero if (a._mantissa == 0.0) { if (b._mantissa < 0.0) {return true;} else {return false;} } if (b._mantissa == 0.0) { if (a._mantissa > 0.0) {return true;} else {return false;} } if (a._expon>b._expon) { if (a._mantissa > 0.0) {return true;} else {return false;} } else { if (a._mantissa < 0.0) {return true;} else {return false;} } // expon values are identical } else { return (a._mantissa > b._mantissa); } } inline bool operator<=(const doubleRepMantisa& a, const doubleRepMantisa& b){ return !(a>b); } inline bool operator>=(const doubleRepMantisa& a, const doubleRepMantisa& b){ return !(a>(istream &in, doubleRepMantisa& a); inline MDOUBLE log(const doubleRepMantisa& d) {return d.d_log();} inline ostream &operator<<(ostream &out, const VdoubleRepMantisa &v){ for (int j=0;j #include #include "definitions.h" using namespace std; //a function that turns an integer to string void appendIntToString (string& ioString, const int inValue); string appendDouble2string(const double x, int const howManyDigitsAfterTheDot=5); string appendInt2string(const int x); // Trims spaces at the left side of a string static inline string trim_left(const string& str ) { int i=str.find_first_not_of(" \t"); if(str.size()==0 || i >= str.size()) return str; return str.substr( i ) ; } //// // Trims spaces at the right side of a string static inline string trim_right(const string& str ) { int i=str.find_last_not_of(" \t"); if(str.size()==0 || i >= str.size()) return str; return str.substr(0, i + 1); } //// // Trims spaces at both sides of a string static inline string trim(const string& str ) { return trim_left(trim_right(str)); } #endif rate4site-3.0.0/src/phylogeny/sequenceContainer.h0000644011611301161130000001435412223673415017004 00000000000000// $Id: sequenceContainer.h 10178 2012-01-10 20:32:58Z cohenofi $ #ifndef ___SEQUENCE_CONTAINER #define ___SEQUENCE_CONTAINER #include "definitions.h" #include "sequence.h" #include "gainLossAlphabet.h" class sequenceContainer { public: class taxaIterator; friend class taxaIterator; class constTaxaIterator; friend class constTaxaIterator; //------------------------------------------------------------ //constructors: explicit sequenceContainer(); sequenceContainer(const sequenceContainer& other,const alphabet *inAlph); virtual ~sequenceContainer(); //questions only: const int seqLen() const {return _seqDataVec.empty()? 0 : _seqDataVec[0].seqLen();} const int numberOfSeqs() const {return _seqDataVec.size();} const int alphabetSize() const {return _seqDataVec.empty()? 0 : _seqDataVec[0].getAlphabet()->size();} const vector& getGeneralRemarks() const {return _generalRemarks;} const int makeSureAllSeqAreSameLengthAndGetLen(bool bAugumentShorterSeqs = false); //if bAugumentShorterSeqs=true then add gap characters at the end of short seqeunces const int getId(const string &seqName, bool issueWarninInNotFound=true) const;//return -1 if not found... sequence& operator[](const int id) {return _seqDataVec[_id2place[id]];} // get the ID of the sequence. Return the sequence itself. const sequence& operator[](const int id) const {return _seqDataVec[_id2place[id]];} const bool operator==(const sequenceContainer& sq) const; const sequence& getSeqDirectFromDataVec(int i){return _seqDataVec[i];} const Vstring names() const; // return a vector of the names of all the sequences. const string& name(const int id) const {return _seqDataVec[_id2place[id]].name();}; const alphabet* getAlphabet() const {return _seqDataVec[0].getAlphabet();} const vector getAlphabetDistribution(bool isCountUnknown=false) const; const vector getAlphabetDistribution(int pos,bool isCountUnknown=false) const; //returns the number of positions that are invariable (all seqs are identical int getInvariablePosNum() const; bool isInvariable(const int pos) const; // computed the number of sequences without gaps at a specific position // for example, if the multiple sequence alignment is // AT- // AG- // A-M // numberOfSequencesWithoutGaps(0) = 3 // numberOfSequencesWithoutGaps(1) = 2 // numberOfSequencesWithoutGaps(2) = 1 int numberOfSequencesWithoutGaps(const int pos) const; int numberOfSequencesWithoutUnknowns(const int pos) const; //make changes: void resize(int t,const alphabet* inAlph) { if (inAlph == NULL) { errorMsg::reportError("cannot resize when the alphabet is unknown"); } sequence s(inAlph); _seqDataVec.resize(t,s); } void add(const sequence& inSeq); void remove(const int idSeq); void removeAll(); void removeIdenticalSequences(); int placeToId(const int place) const {return _seqDataVec[place].id();}; //get place in the vector and return the id of the sequence void addGeneralRemark(const string& inRemark) {_generalRemarks.push_back(inRemark);} void changeGaps2MissingData(); //removePositions: the positions to be removed are marked as '1' in posToRemoveVec //all other positions are '0' void removePositions(const Vint & posToRemoveVec); sequenceContainer getSubSeq(const int startPos, const int endPos); int getNumOfOccurancesPerPos(const int pos, const char charId); void removeGapPositions(); void removeGapPositionsAllSeqs(); void removeGapPositionsAccordingToAReferenceSeq(const string & seqName); void changeDotsToGoodCharacters(); void removeUnknownPositionsAccordingToAReferenceSeq(const string & seqName); void concatenate(sequenceContainer& other); void startZeroSequenceContainerGL(const sequenceContainer &sc, const gainLossAlphabet& alph, const int minNumOfOnes=1, const int minNumOfZeros=0); public: sequence::Iterator begin(const int id){//iterface to sequence iterator sequence::Iterator temp; temp.begin(_seqDataVec[id]); return temp; } sequence::Iterator end(const int id){//iterface to sequence iterator sequence::Iterator temp; temp.end(_seqDataVec[id]); return temp; } class taxaIterator { public: explicit taxaIterator(){}; ~taxaIterator(){}; void begin(sequenceContainer & inSeqCont){ _pointer = inSeqCont._seqDataVec.begin(); } void end(sequenceContainer & inSeqCont){ _pointer = inSeqCont._seqDataVec.end(); } sequence& operator* () {return *_pointer;} sequence const & operator* () const {return *_pointer;} sequence * operator-> () {return &*_pointer;} //MATAN- CHECK!!! sequence const * operator-> () const {return &* _pointer;} // MATAN - CHECK!!! void operator ++() {++_pointer;} void operator --() { --_pointer; } bool operator != (const taxaIterator& rhs){return (_pointer != rhs._pointer);} bool operator == (const taxaIterator& rhs){return (_pointer == rhs._pointer);} private: vector::iterator _pointer; };//end if class taxaIterator class constTaxaIterator { public: explicit constTaxaIterator(){}; ~constTaxaIterator(){}; void begin(const sequenceContainer & inSeqCont){ _pointer = inSeqCont._seqDataVec.begin(); } void end(const sequenceContainer & inSeqCont){ _pointer = inSeqCont._seqDataVec.end(); } sequence const & operator*() const {return *_pointer;} sequence const * operator->() const {return &*_pointer;}// MATAN - CHECK!!! void operator ++() {++_pointer;} void operator --() { --_pointer; } bool operator != (const constTaxaIterator& rhs) { return (_pointer != rhs._pointer); } bool operator == (const constTaxaIterator& rhs) { return (_pointer == rhs._pointer); } private: vector::const_iterator _pointer; }; public: // interfaces to iterators taxaIterator taxaBegin(const int id=0){// interface to taxaIterator taxaIterator temp; temp.begin(*this); return temp; } taxaIterator taxaEnd(){// interface to taxaIterator taxaIterator temp; temp.end(*this); return temp; } constTaxaIterator constTaxaBegin() const{ //interface to const taxaIter constTaxaIterator temp; temp.begin(*this); return temp; } constTaxaIterator constTaxaEnd() const{ constTaxaIterator temp; temp.end(*this); return temp; } private: vector _seqDataVec; vector _generalRemarks; vector _id2place; }; #endif rate4site-3.0.0/src/phylogeny/sequence.h0000644011611301161130000000760512223673416015143 00000000000000// $Id: sequence.h 7627 2010-03-06 21:56:30Z cohenofi $ #ifndef ___SEQUENCE #define ___SEQUENCE #include "definitions.h" #include "errorMsg.h" #include "alphabet.h" #include "mulAlphabet.h" #include using namespace std; class sequence { public: class Iterator; friend class Iterator; class constIterator; friend class constIterator; // constructors explicit sequence(const string& str, const string& name, const string& remark, const int id, const alphabet* inAlph); sequence(const sequence& other); sequence(const sequence& other,const alphabet* inAlph); // convert the other sequence to the alphabet inAlph. explicit sequence(const alphabet* inAlph) { if (inAlph == NULL) { errorMsg::reportError("must give a non Null alphabet when constructing sequences"); } _alphabet = inAlph->clone(); } virtual ~sequence(); int seqLen() const {return _vec.size();} int seqLenSpecific() const; //return the number of sites that are isSpecific() const string& name() const {return _name;} void setName(const string & inName) { _name =inName ;} const int id() const {return _id;} void setID(const int inID) { _id =inID ;} const string& remark() const {return _remark;} void setRemarks(const string & inRemarks) { _remark =inRemarks ;} string toString() const; string toString(const int pos) const; void addFromString(const string& str); //push_back: add a single characer to the sequence void push_back(int p) {_vec.push_back(p);} void resize(const int k, const int* val = NULL); void removePositions(const vector & parCol); void setAlphabet(const alphabet* inA) {if (_alphabet) delete _alphabet; _alphabet=inA->clone(); } const alphabet* getAlphabet() const {return _alphabet;} inline sequence& operator=(const sequence& other); inline sequence& operator+=(const sequence& other); int& operator[](const int i) {return _vec[i];} const int& operator[](const int pos) const {return _vec[pos];} bool isUnknown(const int pos) const {return _vec[pos] == _alphabet->unknown();} // "specific" here is not unknown, nor ambiguity, nor gap (for example, for nucleotides it will true for A,C,G, or T). bool isSpecific(const int pos) const {return _alphabet->isSpecific(_vec[pos]);} private: vector _vec; const alphabet* _alphabet; string _remark; string _name; int _id; public: class Iterator { public: explicit Iterator(){}; ~Iterator(){}; void begin(sequence& seq){_pointer = seq._vec.begin();} void end(sequence& seq){_pointer = seq._vec.end();} int& operator* (){return *_pointer;} int const &operator* () const {return *_pointer;} void operator ++() {++_pointer;} void operator --() { --_pointer; } bool operator != (const Iterator& rhs){return (_pointer != rhs._pointer);} bool operator == (const Iterator& rhs){return (_pointer == rhs._pointer);} private: vector::iterator _pointer; }; class constIterator { public: explicit constIterator(){}; ~constIterator(){}; void begin(const sequence& seq){_pointer = seq._vec.begin();} void end(const sequence& seq){_pointer = seq._vec.end();} int const &operator* () const {return *_pointer;} void operator ++(){++_pointer;} void operator --(){--_pointer;} bool operator != (const constIterator& rhs) { return (_pointer != rhs._pointer); } bool operator == (const constIterator& rhs) { return (_pointer == rhs._pointer); } private: vector::const_iterator _pointer; }; } ; inline sequence& sequence::operator=(const sequence& other) { _vec = other._vec; _alphabet = other._alphabet->clone(); _name=other.name(); _id=other.id(); _remark=other.remark(); return *this; } inline sequence& sequence::operator+=(const sequence& other) { for (int i=0; i #include using namespace std; class alphabet { public: virtual int relations(const int charInSeq, const int charToCheck) const =0; virtual int fromChar(const string& seq,const int pos) const =0; virtual string fromInt(const int in_id) const =0; virtual int size() const =0; virtual ~alphabet()=0; virtual int unknown() const =0; virtual int gap() const =0; virtual alphabet* clone() const = 0; virtual int stringSize() const =0; virtual vector fromString(const string& str) const =0; // "specific" here is not unknown, nor ambiguity, nor gap (for example, for nucleotides it will true for A,C,G, or T). virtual bool isSpecific(const int in_id) const =0; }; #endif rate4site-3.0.0/src/phylogeny/mulAlphabet.h0000644011611301161130000000316312223673415015563 00000000000000// $Id: mulAlphabet.h 6420 2009-06-25 11:17:08Z adist $ // version 1.01 // last modified 1 Jan 2004 #ifndef ___MUL_ALPHABET_H #define ___MUL_ALPHABET_H #include "definitions.h" #include "alphabet.h" #include "someUtil.h" class mulAlphabet : public alphabet { public: mulAlphabet(const alphabet* baseAlphabet, int mulFactor); mulAlphabet(const mulAlphabet& other); virtual ~mulAlphabet(); virtual alphabet* clone() const { return new mulAlphabet(*this); } mulAlphabet& operator=(const mulAlphabet &other); int unknown() const ; int gap() const; int size() const {return _size;} int stringSize() const ; bool isSpecific(const int id) const ; int fromChar(const string& str, const int pos) const; vector fromString(const string& str) const; string fromInt(const int id) const; int relations(const int charInSeq, const int charToCheck) const; int compareCategories(int charA, int charB) const; enum rateShiftType {noRateShift=0, acceleration, deceleration}; static rateShiftType compareCategories(int charA, int charB, int baseAlphabetSize, int multiplicationFactor) ; const alphabet* getBaseAlphabet() const {return _baseAlphabet;} public: int convertFromBasedAlphaInt(int id) const; int convertToBasedAlphaInt(int id) const; private: alphabet* _baseAlphabet; // This alphabet must use single characters, i.e. - not codon. (or we will have to add to every alphabet a member which holds its character's size) int _mulFactor ; // number of times that the alphabet is multiplied by = Number of categories (g in Galtier paper) int _size ; // this is simply the _baseAlphabet->size() * _mulFactor }; #endif rate4site-3.0.0/src/phylogeny/someUtil.h0000644011611301161130000001677712223673416015146 00000000000000// $Id: someUtil.h 10689 2012-05-30 16:27:22Z cohenofi $ #ifndef ___SOME_UTIL_H #define ___SOME_UTIL_H #include "logFile.h" #include "definitions.h" #include "alphabet.h" #include #include using namespace std; //to be used for orderVec template class vecElem { public: vecElem(); virtual ~vecElem() {}; void setValue(const T val) {m_value = val;} T getValue() {return m_value;} void setPlace(const int place) {m_place = place;} int getPlace() {return m_place;} inline bool operator< (const vecElem& elemIn) const; private: int m_place; T m_value; }; template vecElem< T >::vecElem() { m_value = -1; m_place = -1; } //template //vecElement< T >::~vecElement() //{ //} template bool vecElem< T >::operator<(const vecElem& elemIn) const { if (m_value == elemIn.m_value) return (m_place < elemIn.m_place); else return (m_value < elemIn.m_value); } // STATISTICAL UTILITIES: MDOUBLE computeAverage(const vector& vec); MDOUBLE computeAverage(const vector& vec, const Vdouble* weightsV = NULL); MDOUBLE computeAverageOfAbs(const vector& vec, const Vdouble* weightsV = NULL); MDOUBLE computeMedian(const vector& vec); MDOUBLE computeQuantile(const vector& vec, MDOUBLE quantile); MDOUBLE computeQuantileFrac(const vector& vec, MDOUBLE quantile); MDOUBLE computeStd(const vector& vec);// page 60, Sokal and Rohlf MDOUBLE computeStd(const vector& vec);// page 60, Sokal and Rohlf MDOUBLE copmutePoissonProbability(const int& k, const long double& lamda); // re-computes a vector of frequencies after one value is changed: // all other values are set according to their relative value void computeRelativeFreqsFollowingOneChanged(MDOUBLE newValFreq, int indexNewFreq,Vdouble &freqs);//freqs is the old vector into which we write the new values // SIMULATIONS: int giveRandomState(const int alphabetSize, const int beginningState, const VVdouble &changeProbabilities); int giveRandomState(const int alphabetSize, const Vdouble &frequencies); // TIME UTILITIES void printTime(ostream& out); // TEXT UTILITIES string int2string(const int i); string double2string(const double x, int const howManyDigitsAfterTheDot=5); MDOUBLE string2double(const string& inString); bool allowCharSet(const string& allowableChars, const string& string2check); bool isCharInString(const string& stringToCheck, const char charToCheck); void putFileIntoVectorStringArray(istream &infile,vector &inseqFile); bool fromStringIterToInt(string::const_iterator & it, const string::const_iterator endOfString, int& res); string takeCharOutOfString(const string& charsToTakeOut, const string& fromString); void toLower(string& str); void toUpper(string& str); string toUpper2(const string& str); //splits the string to substr according to the given delimiter (parallel to split in perl) void splitString(const string& str,vector& subStrs,const string& delimiter); //input: a list of INTs seperated by commas ("1,3,5") returns the int in the vector Vint getVintFromStr(const string& str); //return a list of INTs seperated by commas ("1,3,5") string getStrFromVint(const Vint& inVec); // FILE UTILITIES bool checkThatFileExist(const string& fileName); string* searchStringInFile(const string& string2find, const int index, const string& inFileName); string* searchStringInFile(const string& string2find, const string& inFileName); bool doesWordExistInFile(const string& string2find,const string& inFileName); void createDir(const string& curDir,const string& dirName); //BIT UTILITIES //void nextBit(bitset<64> &cur); //ARITHMETIC UTILITIES //DEQUAL: == UP TO EPSILON //DBIG_EQUAL: >= UP TO EPSILON //DSMALL_EQUAL: <= UP TO EPSILON bool DEQUAL(const MDOUBLE x1, const MDOUBLE x2, const MDOUBLE epsilon = 1.192092896e-07F); // epsilon taken from WINDOW'S FILE FLOAT.H bool DBIG_EQUAL(const MDOUBLE x1, const MDOUBLE x2, const MDOUBLE epsilon = 1.192092896e-07F); bool DSMALL_EQUAL(const MDOUBLE x1, const MDOUBLE x2, const MDOUBLE epsilon = 1.192092896e-07F); // {return ((x1 < x2) || DEQUAL(x1, x2));} //swap between the 4 variables such that the first becomes the second, second becomes the third and third becomes the fourth. //used in functoin mnbrack below. void shift3(MDOUBLE &a, MDOUBLE &b, MDOUBLE &c, const MDOUBLE d); // print vector and VVdoulbe util ostream &operator<<(ostream &out, const Vdouble &v); ostream &operator<<(ostream &out, const VVdouble &m); void mult(Vdouble& vec, const MDOUBLE factor); void mult(VVdouble& vec, const MDOUBLE factor); //scale vecToScale so that its new average is AvgIn. return the scaling factor. MDOUBLE scaleVec(Vdouble& vecToScale, const MDOUBLE avgIn); //determine the relative order of vecIn. The order vector is returned //ex: vecIn = [0.1 0.4 0.01 0.9 1.8] orderVecOut = [1 2 0 3 4] MDOUBLE orderVec(const vector& vecIn, vector& orderVecOut); void orderRankNoTies(const vector& vecIn, vector& orderVecOut); //in this version orderVecOut does not preserv the same order as vecIn. //orderVecOut[0] cotains the lowest score and it is stored in orderVecOut[0].getValue() //The place in the original vector is stored in orderVecOut[0].getPlace() void orderVec(const Vdouble& vecIn, vector< vecElem >& orderVecOut); //calculates the spearman rank correlation value MDOUBLE calcRankCorrelation(const Vdouble& oneRatesVec, const Vdouble& otherRatesVec); //calculates the spearman rank correlation value, Ofir implementation MDOUBLE calcRankCorrelation2(const Vdouble& oneRatesVec, const Vdouble& otherRatesVec); MDOUBLE calcCoVariance(const Vdouble& oneRatesVec, const Vdouble& otherRatesVec); MDOUBLE calcPearsonCorrelation(const Vdouble& oneRatesVec, const Vdouble& otherRatesVec, const int numberOfSignificantDigits=5); MDOUBLE computeFDRthreshold(Vdouble& sortedPVals, MDOUBLE levelOfFDRcontroled, bool isPValsSorted=false); MDOUBLE calcRelativeMSEDistBetweenVectors(const Vdouble& trueValues, const Vdouble& inferredValues, const MDOUBLE threshhold = 0.0); MDOUBLE calcMSEDistBetweenVectors(const Vdouble& trueValues, const Vdouble& inferredValues); //MAD = mean absolute deviations distance MDOUBLE calcMADDistBetweenVectors(const Vdouble& oneRatesVec, const Vdouble& otherRatesVec); MDOUBLE calcRelativeMADDistBetweenVectors(const Vdouble& trueValues, const Vdouble& inferredValues, const MDOUBLE threshhold = 0.0); MDOUBLE sumVdouble(const Vdouble & vec); /* Will split a string into 2 by the given seperator Example for usage: string a, b, c; a.assign("Hello world!"); splitString2(a, " ", b, c); cout << "b = " << b << endl << "c = " << c << endl; //b == Hello //c == world! */ void splitString2(string str, string seperater, string &first, string &second); // used for gainLoss project int fromIndex2gainIndex(const int i, const int gainCategories, const int lossCategories); int fromIndex2lossIndex(const int i, const int gainCategories, const int lossCategories); int sign(MDOUBLE r); MDOUBLE factorial(int x); MDOUBLE BinomialCoeff(int a, int b); int round2int(MDOUBLE num); //This function does: ln(e**(valuesVec[0])+e**(valuesVec[1])+..e**(valuesVec[n])) //Which is: ln(e**(valuesVec[x]))*(1+sum_over_i_leave_x(e**(valuesVec[i]-valuesVec[x]))) //Which is: valuesVec[x]+ln(1+sum_over_i_leave_x(e**(valuesVec[i]-valuesVec[x]))) //Where: x is the index of the largest element in valuesVec and every valuesVec[i] which is really small should be neglected in order to avoid underflow MDOUBLE exponentResolver(Vdouble& valuesVec); #endif rate4site-3.0.0/src/phylogeny/logFile.h0000644011611301161130000000231312223673415014702 00000000000000// $Id: logFile.h 6067 2009-04-14 19:12:28Z itaymay $ #ifndef ___LOG #define ___LOG #include #include #include using namespace std; class myLog { public: static int LogLevel() { return _loglvl;} static ostream& LogFile(void) { if (_out == NULL) return cerr; return *_out; } static void setLogLvl(const int newLogLvl) {_loglvl = newLogLvl;} static void setLogOstream(ostream* out) {_out = out;} // this function is problematic, because it issue a call to NEW // which because the function is static - cannot be deleted. // but, this will not effect the program, because there is only // 1 instance of _out and it will be released anyway in the end of the program. static void setLog(const string logfilename, const int loglvl); static void endLog(void); static void printArgv(int loglvl, int argc, char *argv[]) ; private: static ostream* _out; static int _loglvl; static bool _firstTime; }; #ifdef LOG #undef LOG #endif #define LOG(Lev, ex) { if( Lev <= myLog::LogLevel() ) myLog::LogFile() ex; } #define LOGnOUT(Lev, ex) { if( Lev <= myLog::LogLevel() ) {myLog::LogFile() ex; cerr ex; }} #define LOGDO(Lev, ex) { if( Lev <= myLog::LogLevel() ) ex; } #endif rate4site-3.0.0/src/phylogeny/gainLossAlphabet.h0000644011611301161130000000162612223673415016547 00000000000000#ifndef ___GAIN_LOSS_ALPH #define ___GAIN_LOSS_ALPH #include "alphabet.h" #include "errorMsg.h" class gainLossAlphabet : public alphabet { public: explicit gainLossAlphabet(); virtual ~gainLossAlphabet() {} virtual alphabet* clone() const { return new gainLossAlphabet(*this); } int unknown() const {return -2;} int gap() const {errorMsg::reportError("The method indel::gap() is used"); return -1;} // What is it for ? I don't need this !!! int size() const {return 2;} // presence or absence only int stringSize() const {return 1;} // one letter code. int relations(const int charInSeq, const int charToCheck) const; int fromChar(const string& str, const int pos) const; int fromChar(const char s) const; string fromInt(const int in_id) const; vector fromString(const string& str) const; bool isSpecific(const int id) const {return (id>=0 && id < size());} }; #endif rate4site-3.0.0/src/phylogeny/pijAccelerator.h0000644011611301161130000000135012223673416016251 00000000000000// $Id: pijAccelerator.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___PIJ_ACCELERATOR #define ___PIJ_ACCELERATOR #include "definitions.h" #include "replacementModel.h" class pijAccelerator { public: virtual pijAccelerator* clone() const = 0; virtual ~pijAccelerator() = 0; virtual const MDOUBLE Pij_t(const int i, const int j, const MDOUBLE t) const = 0; virtual const MDOUBLE freq(const int i) const = 0; // P(i) virtual const MDOUBLE dPij_dt(const int i, const int j, const MDOUBLE t) const =0; virtual const MDOUBLE d2Pij_dt2(const int i, const int j, const MDOUBLE t) const =0; virtual replacementModel* getReplacementModel() const =0; // @@@@ this const is a lie !!! virtual const int alphabetSize() const =0; }; #endif rate4site-3.0.0/src/phylogeny/replacementModel.h0000644011611301161130000000162012223673415016601 00000000000000// $Id: replacementModel.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___REPLACEMENT_MODEL #define ___REPLACEMENT_MODEL #include "definitions.h" class replacementModel{ public: virtual const MDOUBLE Pij_t(const int i, const int j, const MDOUBLE t) const = 0; virtual const MDOUBLE freq(const int i) const = 0; virtual const MDOUBLE dPij_dt(const int i, const int j, const MDOUBLE t) const =0; virtual const MDOUBLE d2Pij_dt2(const int i, const int j, const MDOUBLE t) const =0; virtual replacementModel* clone() const = 0; virtual ~replacementModel()=0; virtual const int alphabetSize() const =0; //virtual const MDOUBLE Q(const int i, const int j, const MDOUBLE r = 1.0) const = 0; //note that we ask that sigma over i sigma over j!=i of p(i)Qij = 1; //this is beacuse we ask the [sigma over i sigma over j!=i p(i)*pij(d)]/d approaches //1 as d -> 0. (and l'hopital from here). }; #endif rate4site-3.0.0/src/phylogeny/distribution.h0000644011611301161130000000216512223673416016046 00000000000000// $Id: distribution.h 2709 2007-11-19 14:49:21Z itaymay $ // version 2.00 // last modified 21 Mar 2004 /************************************************************ This is a virtual class from which all types of distribution classes inherit from. ************************************************************/ #ifndef ___DISTRIBUTION #define ___DISTRIBUTION #include "definitions.h" class distribution { public: virtual distribution* clone() const = 0; virtual ~distribution() = 0; virtual const int categories() const=0; // @@@@ there is no need to return a const int. virtual void change_number_of_categories(int in_number_of_categories); virtual const MDOUBLE rates(const int i) const=0; // @@@@ there is no need to return a const MDOUBLE. virtual const MDOUBLE ratesProb(const int i) const=0; // @@@@ there is no need to return a const MDOUBLE. virtual void setGlobalRate(const MDOUBLE x)=0; virtual MDOUBLE getGlobalRate()const=0; // @@@@ there is no need to return a const MDOUBLE. virtual const MDOUBLE getCumulativeProb(const MDOUBLE x) const = 0; // @@@@ there is no need to return a const MDOUBLE. }; #endif rate4site-3.0.0/src/phylogeny/readTree.h0000644011611301161130000000217412223673416015062 00000000000000// $Id: readTree.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___READ_TREE #define ___READ_TREE #include "definitions.h" #include using namespace std; #define REMARK ';' #define MAX_LENGTH_OF_NAME 20 #define MAX_FILE_SIZE 1000000 #define FATHER 0 #define LEFT 1 #define RIGHT 2 #define OPENING_BRACE '(' #define CLOSING_BRACE ')' #define OPENING_BRACE2 '{' #define CLOSING_BRACE2 '}' #define COMMA ',' #define COLON ':' #define SEMI_COLLON ';' #define PERIOD '.' bool DistanceExists(vector::const_iterator& p_itCurrent); bool verifyChar(vector::const_iterator &p_itCurrent, const char p_cCharToFind); int GetNumberOfLeaves(const vector& tree_contents); int GetNumberOfInternalNodes(const vector& tree_contents); bool IsAtomicPart(const vector::const_iterator p_itCurrent); vector PutTreeFileIntoVector(istream &in); MDOUBLE getDistance(vector::const_iterator &p_itCurrent); bool DistanceExists(vector::const_iterator& p_itCurrent); void clearPosibleComment(vector::const_iterator& p_itCurrent); string readPosibleComment(vector::const_iterator& p_itCurrent); #endif rate4site-3.0.0/src/phylogeny/nucleotide.h0000644011611301161130000000701712223673415015462 00000000000000// $Id: nucleotide.h 1901 2007-03-15 13:21:06Z nimrodru $ #ifndef ___NUCLEOTIDE_H #define ___NUCLEOTIDE_H #include #include "definitions.h" #include "alphabet.h" /* ======================================================================= This is the nucleotide class. It is derived from the class alphabet. All alphabets are internally stored as integers. So what has to implement is a way to translate from strings to array (vector) of integers and back. Starting with the easiest functions to explain: size() gives the size of the alphabet: 4 in this case. stringSize() say if it is a one letter code (unlike codon which is 3 letters code). clone() is a general machanism in C++. The idea is that if you have a derived class, and a pointer to the base class, and you want to self-copy the derived class. In such case you use the clone() machanism. Ref: More effective C++ page. 126. int unknown(): sometimes one doesn't know if it is A, C, G, or T. In such case we use the int that represents unknown. In this class it is set to 15. This is used for example when gap characters are converted to unknown characters. int fromChar(const string& str, const int pos) and int fromChar(const char s) give the same answer: there is a map from integers to characters. For example, A is zero, C is 1, etc. However, the function fromChar(const char s) is specific to nucleotide and to amino - because these are one letter alphabet. For codon - this function won't work. This is why the general function is in the form int fromChar(const string& str, const int pos); In the case of codon - it will read 3 letters each time. =========================================================================*/ class nucleotide : public alphabet { public: explicit nucleotide(); virtual ~nucleotide() {} virtual alphabet* clone() const { return new nucleotide(*this); } int unknown() const {return 15;} int gap() const {return -1;} int size() const {return 4;} int stringSize() const {return 1;} // one letter code. int fromChar(const string& str, const int pos) const; int fromChar(const char s) const; vector fromString(const string& str) const; string fromInt(const int id) const; int relations(const int charInSeq, const int charToCheck) const{ // see explanation below assert (charInSeq != -1);//gaps in the sequences return _relation[charToCheck][charInSeq]; } // "specific" here is not unknown, nor ambiguity, nor gap (for example, for nucleotides it will true for A,C,G, or T). // in this speical case, in fact it will be true also for U which is coded by 4. // this is why it is <= size. bool isSpecific(const int id) const {return (id>=0 && id <= size());} private: VVint _relation; char fromIntInternal(const int in_id) const; int relationsInternal(const int ctc,const int charInSeq) const; }; #endif // Explanation about relations: // Sometimes the sequences contain letters like R which means G or A. // When calculating the likelihood of such sequences we have to take this into acount. // For example, the tree : A /* / \ t1 / \ t2 / \ R A L = P(A)*P(A->A)(t1)*P(A->A)(t2) + P(A)*P(A->G)(t1)*P(A->A)(t2) = P(A)*P(A->A)(t2)* [ P(A->A)(t1) + P(A->G)(t1) ] Note that we don't divide it by 2. VVint _relation keeps this information : A C G T A 1 0 0 0 C 0 1 0 0 G 0 0 1 0 T 0 0 0 1 U 0 0 0 1 R 1 0 1 0 Y 0 1 0 1 K . . . */ rate4site-3.0.0/src/phylogeny/amino.h0000644011611301161130000000252012223673415014424 00000000000000// $Id: amino.h 1901 2007-03-15 13:21:06Z nimrodru $ #ifndef ____AMINO #define ____AMINO #include "definitions.h" #include "errorMsg.h" #include "alphabet.h" #include "geneticCodeHolder.h" #include "codon.h" //utility of amino acid class aminoUtility { public: static vector codonOf(const int a, codon &cod); //returns vector of codons that code to a under a specific genetic code. }; //based on the amino-acid list found in http://www.dur.ac.uk/~dbl0www/Bioinformatics/aminoacids.htm class amino : public alphabet { public: explicit amino(); virtual ~amino() {} virtual alphabet* clone() const { return new amino(*this); } int unknown() const {return -2;} int gap() const {return -1;} int size() const {return 20;} int stringSize() const {return 1;} // one letter code. int relations(const int charInSeq, const int charToCheck) const; int fromChar(const string& str, const int pos) const; int fromChar(const char s) const; string fromInt(const int in_id) const; vector fromString(const string& str) const; // "specific" here is not unknown, nor ambiguity, nor gap (for example, for nucleotides it will true for A,C,G, or T). bool isSpecific(const int id) const {return (id>=0 && id < size());} private: int relations_internal(const int charInSeq, const int charToCheck) const; VVint _relation; };//end of class #endif rate4site-3.0.0/src/phylogeny/geneticCodeHolder.h0000644011611301161130000000213612223673416016674 00000000000000// $Id: geneticCodeHolder.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___GENMATRIXHOLDER #define ___GENMATRIXHOLDER #include using namespace std; // THIS CONSTRUCT IS USED TO KEEP A STRING THAT IS THE AA SUBSTITUTION MATRIX // THE datMatrixString IS TO BE USED WHENEVER WE USE ONE OF THE BUILD-IN AA SUBSTITUTION MATRICES. class geneticCodeString { public: const string Val; explicit geneticCodeString(const char * str): Val(str){}; }; class geneticCodeHolder { public: static const geneticCodeString nuclearStandard; static const geneticCodeString nuclearEuplotid; static const geneticCodeString nuclearCiliate; static const geneticCodeString nuclearBlepharisma; static const geneticCodeString mitochondriaYeast; static const geneticCodeString mitochondriaVertebrate; static const geneticCodeString mitochondriaProtozoan; static const geneticCodeString mitochondriaInvertebrate; static const geneticCodeString mitochondriaFlatworm; static const geneticCodeString mitochondriaEchinoderm; static const geneticCodeString mitochondriaAscidian; }; #endif // ___GENMATRIXHOLDER rate4site-3.0.0/src/phylogeny/codon.h0000644011611301161130000001100012223673416014415 00000000000000// $Id: codon.h 5975 2009-03-17 08:00:37Z rubi $ #ifndef ____CODON #define ____CODON #include #include "definitions.h" #include "errorMsg.h" #include "someUtil.h" #include "alphabet.h" #include "geneticCodeHolder.h" #include class codon; class sequenceContainer; class codonUtility { public: enum diffType {equal =0, tr, tv, twoTrs, twoTvs ,trtv, threesub}; static diffType codonDiff(const int c1, const int c2, const codon &cod); static diffType codonDiff(const int c1, const int c2) {return _trtvDiff[c1][c2];} enum replacementType {sameCodon=0, synonymous, non_synonymous}; static replacementType codonReplacement(const int c1, const int c2, const codon &cod); static replacementType codonReplacement(const int c1, const int c2) {return _synNonsynDiff[c1][c2];} enum nucDiffPlaceType {A1=0, A2, A3,C1, C2, C3, G1,G2,G3,T1,T2,T3, EQUAL, MUL_SUB}; static nucDiffPlaceType nucDiffPlace(const int fromCodon, const int targetCodon, const codon &cod); static nucDiffPlaceType nucDiffPlace(const int fromCodon, const int targetCodon) {return _nucDiffPlace[fromCodon][targetCodon];} enum nucsDiffType {AC=0, AG, AT, CG, CT, GT, SAME, DIFF}; //The difference between two codons: For exampe nucsDiff(ACT, ACG) returns GT. DIFF = more than one change. static nucsDiffType nucsDiff(const int fromCodon, const int targetCodon, const codon &cod); static nucsDiffType nucsDiff(const int fromCodon, const int targetCodon) {return _nucsDiff[fromCodon][targetCodon];} static int aaOf(const int c1, const codon &cod); static void initSubMatrices(const codon& cod); //returns the number (codonCounter) and frequency (codonUsage) of each codon in the sequnece container static void getCodonUsage(const sequenceContainer& sc, Vint& codonCounter, Vdouble& codonUsage); static void readCodonUsage(const string& codonUsageFileName, Vdouble& codonUsage,const codon &inCodonAlpa); //calculates the CAI for the whole MSA and for each position. //The calculation is based on a pre-calculated codonUsage vector. static MDOUBLE calcCodonAdaptationIndex(const sequenceContainer& sc, const Vdouble& codonUsage, Vdouble& cai4site); private: static vector > _trtvDiff; static vector > _synNonsynDiff; static vector > _nucDiffPlace; static vector > _nucsDiff; }; class codon : public alphabet { public: explicit codon(); //default constructor: reads "nuclearCode.txt" explicit codon(const geneticCodeString& matrixFileString); virtual ~codon() {} // explicit codon( codon& other); codon& operator=(const codon& other); virtual alphabet* clone() const { return new codon(*this); } void readMatrixFromFile(const string& matrixFileName); const map & geneticCode()const {return _geneticCode;} int unknown() const {return 64;} int gap() const {return -1;} int size() const {return _alphabetSize;} // 3 stop codon excluded int stringSize() const {return 3;} // 3 letter code. vector fromString(const string& str) const; bool isStopCodon(const int in_id) const; bool isStopCodon(const string& str) const {return isStopCodon(fromChar(str));}; bool isInitiationCodon(const int in_id) const; bool isInitiationCodon(const string& str) const {return isInitiationCodon(fromChar(str));}; int fromChar(const string& s, const int pos=0) const; string fromInt(const int in_id) const; // "specific" here is not unknown, nor ambiguity, nor gap (for example, for nucleotides it will true for A,C,G, or T). bool isSpecific(const int id) const {return (id>=0 && id < size());} int relations(const int charInSeq, const int charToCheck) const{ if (charInSeq == -1) { errorMsg::reportError("gaps in the sequences. Either change gaps to ? or remove gap positions"); } else if (charInSeq == unknown()) return 1; else if (charInSeq == charToCheck) return 1; if (charInSeq >= _alphabetSize) { string err= ""; err+="charInSeq = "; err += int2string(charInSeq); err+= " _alphabetSize = "; err+=int2string(_alphabetSize); errorMsg::reportError(err); } assert(charInSeq < _alphabetSize); return 0; } private: void init(const geneticCodeString& matrixFileString); private: map _geneticCode; //key - codon, value - amino acid map _codon2Int;//key string of codon int= integer value of codon map _initiationIndex2codon;//key: integer value of codon; value: string of initiation codon. the keys is an integer so that the value of the init codon can be found int _alphabetSize; }; #endif rate4site-3.0.0/src/phylogeny/evaluateCharacterFreq.h0000644011611301161130000000217412223673416017570 00000000000000// $Id: evaluateCharacterFreq.h 3895 2008-04-21 07:38:32Z itaymay $ #ifndef __Evaluate_Character_Freq_h #define __Evaluate_Character_Freq_h #include using namespace std; #include "sequenceContainer.h" #include "definitions.h" vector sumAlphabetCounts(const sequenceContainer & sc); vector evaluateCharacterFreq(const sequenceContainer & sc); VVdouble evaluateCharacterFreqOneForEachGene(const vector & scVec); vector evaluateCharacterFreqBasedOnManyGenes(const vector & scVec); void changeCountsToFreqs(vector& charFreq); void makeSureNoZeroFreqs(vector & charFreq); //returns the number of each character in each position void getCharacterCounts(const sequenceContainer & sc, VVint& counts4pos); //returns the number of different character types in each position void getCharacterType4pos(const sequenceContainer & sc, Vint& charactersType4pos); //returns the distribution of the different character types in each position along the whole alignment void getCharacterTypeDistribution(const sequenceContainer & sc, Vint& charactersTypeDist); #endif rate4site-3.0.0/src/phylogeny/uniDistribution.h0000644011611301161130000000220312223673416016513 00000000000000// $Id: uniDistribution.h 2812 2007-11-25 10:32:11Z itaymay $ // version 2.00 // last modified 21 Mar 2004 #ifndef ___UNIFORM_DIST #define ___UNIFORM_DIST #include "distribution.h" /*********************************************************** This represents a distribution of one line over the value 1: | ________|________ 1 _globalRate represents the rate for two joint genes. ************************************************************/ class uniDistribution : public distribution { public: uniDistribution() {_globalRate=1;} virtual const int categories() const { return 1;} virtual void change_number_of_categories(int in_number_of_categories); virtual const MDOUBLE rates(const int i) const { return _globalRate;}; virtual const MDOUBLE ratesProb(const int i) const { return 1.0;}; virtual distribution* clone() const { return new uniDistribution(*this); } virtual void setGlobalRate(const MDOUBLE x) {_globalRate = x;} virtual MDOUBLE getGlobalRate() const{return _globalRate;} virtual const MDOUBLE getCumulativeProb(const MDOUBLE x) const { if (x<1.0) return 0.0; else return 1.0; } MDOUBLE _globalRate; }; #endif rate4site-3.0.0/src/phylogeny/generalGammaDistribution.h0000644011611301161130000000440312223673416020304 00000000000000// $Id: generalGammaDistribution.h 3044 2007-12-18 15:54:50Z itaymay $ #ifndef ___GENERAL_GAMMA_DIST #define ___GENERAL_GAMMA_DIST /************************************************************ This distribution can take several forms depending on its free parameters alpha,beta (unalike gammaDist. alpha is not necessarily equal to beta). For an extensive exlpanation of this distribution see http://mathworld.wolfram.com/GammaDistribution.html ************************************************************/ #include "definitions.h" #include "distribution.h" enum quadratureType {QUANTILE, LAGUERRE}; class generalGammaDistribution : public distribution { public: explicit generalGammaDistribution(); explicit generalGammaDistribution(MDOUBLE alpha, MDOUBLE beta, int in_number_of_categories); explicit generalGammaDistribution(const generalGammaDistribution& other); virtual ~generalGammaDistribution() {} virtual distribution* clone() const { return new generalGammaDistribution(*this); } virtual void setGammaParameters(int numOfCategories ,MDOUBLE alpha, MDOUBLE beta); virtual const int categories() const {return _rates.size();} virtual const MDOUBLE rates(const int i) const {return _rates[i]*_globalRate;} virtual const MDOUBLE ratesProb(const int i) const {return _ratesProb[i];} virtual void setGlobalRate(const MDOUBLE x) {_globalRate = x;} virtual MDOUBLE getGlobalRate()const {return _globalRate;} virtual const MDOUBLE getCumulativeProb(const MDOUBLE x) const; virtual void setAlpha(MDOUBLE newAlpha); virtual MDOUBLE getAlpha() const {return _alpha;} virtual void setBeta(MDOUBLE newBeta); virtual MDOUBLE getBeta() const {return _beta;} virtual void change_number_of_categories(int in_number_of_categories); virtual MDOUBLE getBorder(const int i) const {return _bonderi[i];} //return the ith border. Note: _bonderi[0] = 0, _bondery[categories()] = infinite virtual Vdouble getBorders() const {return _bonderi;} virtual Vdouble getRates() const {return _rates;} protected: virtual void fill_mean(); virtual void fill_bonderi(); protected: MDOUBLE _alpha; MDOUBLE _beta; vector _rates; vector _ratesProb; MDOUBLE _globalRate; vector _bonderi; //Note: _bonderi[0] = 0, _bondery[categories()] = infinite }; #endif rate4site-3.0.0/src/phylogeny/readDatMatrix.h0000644011611301161130000000512012223673416016052 00000000000000// $Id: readDatMatrix.h 5805 2009-01-20 09:19:26Z adido $ #ifndef ___READ_DAT_MATRIX #define ___READ_DAT_MATRIX #include "definitions.h" #include #include #include #include "datMatrixHolder.h" using namespace std; void normalizeQ(VVdouble& q, const Vdouble& freq); void readDatMatrixFromFile(const string & matrixFileName, VVdouble & subMatrix, Vdouble & freq); void readDatMatrixFromString(const string & matrixFileString, VVdouble & subMatrix, Vdouble & freq, int alphaSize = 20); VVdouble fromWagSandFreqToQ(const VVdouble & s,const Vdouble& freq); #include "replacementModel.h" #include "definitions.h" #include "errorMsg.h" class pupAll : public replacementModel { public: // get matrix from file: explicit pupAll(const string& matrixFileString) : err_allow_for_pijt_function(1e-4) {fillMatricesFromFile(matrixFileString);} explicit pupAll(const string& matrixFileString, const vector& freq) : err_allow_for_pijt_function(1e-4) {fillMatricesFromFile(matrixFileString,freq);} // get matrix from within the .exe explicit pupAll(const datMatrixString& matrixFileString,int alphaSize = 20) : err_allow_for_pijt_function(1e-4) {fillMatrices(matrixFileString.Val,alphaSize); } explicit pupAll(const datMatrixString& matrixFileString, const vector& freq) : err_allow_for_pijt_function(1e-4) {fillMatrices(matrixFileString.Val,freq);} const int alphabetSize() const {return _freq.size();}//20 or 61 const MDOUBLE err_allow_for_pijt_function; //1e-4 virtual replacementModel* clone() const { return new pupAll(*this); } const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE t) const; const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE t) const; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE t) const; const MDOUBLE freq(const int i) const {return _freq[i];} const MDOUBLE Pij_tAlpha (const int i,const int j, const MDOUBLE t, const MDOUBLE alpha) const; const MDOUBLE Pij_tAlpha_dt (const int i,const int j, const MDOUBLE t, const MDOUBLE alpha) const; const MDOUBLE Pij_tAlpha_dt2(const int i,const int j, const MDOUBLE t, const MDOUBLE alpha) const; private: void fillMatrices(const string & matrixName,const vector& freq); void fillMatrices(const string & matrixName,int alphaSize); void fillMatricesFromFile(const string & dataFileString,const vector& freq); void fillMatricesFromFile(const string & dataFileString); bool currectFloatingPointProblems(MDOUBLE& sum) const; VVdouble _leftEigen; VVdouble _rightEigen; Vdouble _eigenVector; Vdouble _freq; }; #endif rate4site-3.0.0/src/phylogeny/datMatrixHolder.h0000644011611301161130000000164712223673416016426 00000000000000// $Id: datMatrixHolder.h 5804 2009-01-20 09:18:05Z adido $ #ifndef ___DATMATRIXHOLDER #define ___DATMATRIXHOLDER #include using namespace std; // THIS CONSTRUCT IS USED TO KEEP A STRING THAT IS THE AA SUBSTITUTION MATRIX // THE datMatrixString IS TO BE USED WHENEVER WE USE ONE OF THE BUILD-IN AA SUBSTITUTION MATRICES. class datMatrixString { public: const string Val; explicit datMatrixString(const char * str): Val(str){}; }; class datMatrixHolder { public: static const datMatrixString cpREV45; static const datMatrixString dayhoff; static const datMatrixString jones; // This is JTT static const datMatrixString mtREV24; static const datMatrixString wag; static const datMatrixString HIVb; static const datMatrixString HIVw; static const datMatrixString lg; static const datMatrixString empiriCodon; //This is the empirical matrix for codon by gina and adrian }; #endif // ___DATMATRIXHOLDER rate4site-3.0.0/src/phylogeny/chebyshevAccelerator.h0000644011611301161130000000323012223673416017446 00000000000000// $Id: chebyshevAccelerator.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___CHEBYSHEV_ACCELERATOR #define ___CHEBYSHEV_ACCELERATOR #include "pijAccelerator.h" #include "replacementModel.h" class chebyshevAccelerator : public pijAccelerator { public: explicit chebyshevAccelerator( replacementModel* pb, const int alphanetSize=20, const int totalNumOfCoef=60, const int usingNumberOfCoef=13, const MDOUBLE rightRange=0,const MDOUBLE leftRange=2); chebyshevAccelerator(const chebyshevAccelerator& other); const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const; const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const; const MDOUBLE freq(const int i) const {return _pb->freq(i);} virtual pijAccelerator* clone() const { return new chebyshevAccelerator(*this); } virtual ~chebyshevAccelerator() {delete _pb;} virtual replacementModel* getReplacementModel() const {return (_pb);} virtual const int alphabetSize() const {return _pb->alphabetSize();} private: VVVdouble chebi_coff;//[N_ABC][N_ABC][NUMBER_OF_TOTAL_COFF+1]; VVVdouble chebi_dervation_coff;//[N_ABC][N_ABC][NUMBER_OF_TOTAL_COFF+1]; VVVdouble chebi_sec_dervation_coff;//[N_ABC][N_ABC][NUMBER_OF_TOTAL_COFF+1]; const int _alphabetSize; const int _totalNumOfCoef; const int _usingNumberOfCoef; replacementModel* _pb; void chebft(Vdouble& c, int n, int from_aa, int to_aa); void chder(Vdouble &c, Vdouble &cder, int n); const MDOUBLE _rightRange; const MDOUBLE _leftRange; }; // This is an accelerator of Pij(t) calculation, using a proximity to polynomial. #endif rate4site-3.0.0/src/phylogeny/nucJC.h0000644011611301161130000000335312223673416014331 00000000000000// $Id: nucJC.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___NUC_JC #define ___NUC_JC #include #include "replacementModel.h" namespace nucDef { const MDOUBLE Alp = 4.0; const MDOUBLE odAl = 1.0/Alp; // one divided by alphabet const MDOUBLE om_odAl = 1.0-odAl; // one minus odAl; const MDOUBLE alDiv_omalp = Alp/(Alp-1.0); const MDOUBLE m_alDiv_omalp = -alDiv_omalp; } class nucJC : public replacementModel { public: const int alphabetSize() const {return 4;} virtual replacementModel* clone() const { return new nucJC(*this); } explicit nucJC(){}; const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const { // return ((i==j) ? 0.25+0.75*exp(-4.0/3.0*d): 0.25-0.25*exp(-4.0/3.0*d)); return ((i==j) ? nucDef::odAl+nucDef::om_odAl*exp(nucDef::m_alDiv_omalp*d): nucDef::odAl-nucDef::odAl*exp(nucDef::m_alDiv_omalp*d)); } const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const{ // return ((i==j) ? -exp(-4.0/3.0*d): exp(-4.0/3.0*d)/3.0); return ((i==j) ? -exp(nucDef::m_alDiv_omalp*d): exp(nucDef::m_alDiv_omalp*d)/(nucDef::Alp-1)); } const MDOUBLE freq(const int i) const {return 0.25;}; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const{ // return ((i==j) ? 4.0/3.0*exp(-4.0/3.0*d): -4.0/3.0*exp(-4.0/3.0*d)); return ((i==j) ? nucDef::alDiv_omalp*exp(nucDef::m_alDiv_omalp*d): nucDef::m_alDiv_omalp*exp(nucDef::m_alDiv_omalp*d)); } const MDOUBLE Q(const int i, const int j) const { return ((i == j) ? ( - 1.0) : (1.0 / 3.0)); } }; #endif // note: according to the new C++ rules, the clone function should be like this: // virtual nucJC* clone() const { return new nucJC(*this); } // however, not all compiler support it yet. look at More Effective C++ page 126. rate4site-3.0.0/src/phylogeny/aaJC.h0000644011611301161130000000334112223673416014122 00000000000000// $Id: aaJC.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___AA_JC #define ___AA_JC #include "replacementModel.h" #include using namespace std; namespace aaDef { const MDOUBLE Alp = 20.0; const MDOUBLE odAl = 1.0/Alp; // one divided by alphabet const MDOUBLE om_odAl = 1.0-odAl; // one minus odAl; const MDOUBLE alDiv_omalp = Alp/(Alp-1.0); const MDOUBLE m_alDiv_omalp = -alDiv_omalp; } class aaJC : public replacementModel { public: virtual replacementModel* clone() const { return new aaJC(*this); }// see note down: // virtual aaJC* clone() const { return new aaJC(*this); } const int alphabetSize() const {return 20;} explicit aaJC(){}; const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const { //(wrong!) return ((i==j) ? 0.05+0.95*exp(-20.0*d): 0.05-0.05*exp(-20.0*d)); return ((i==j) ? aaDef::odAl+aaDef::om_odAl*exp(aaDef::m_alDiv_omalp*d): aaDef::odAl-aaDef::odAl*exp(aaDef::m_alDiv_omalp*d)); } const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const{ //(worng!)return ((i==j) ? -19.0*exp(-20.0*d): exp(-20.0*d)); return ((i==j) ? -exp(aaDef::m_alDiv_omalp*d): exp(aaDef::m_alDiv_omalp*d)/(aaDef::Alp-1)); } const MDOUBLE freq(const int i) const {return aaDef::odAl;}; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const{ //(wrong!) return ((i==j) ? 19.0*20.0*exp(-20.0*d): 0.0-20.0*exp(-20.0*d)); return ((i==j) ? aaDef::alDiv_omalp*exp(aaDef::m_alDiv_omalp*d): aaDef::m_alDiv_omalp*exp(aaDef::m_alDiv_omalp*d)); } }; #endif // note: according to the new C++ rules, the clone function should be like this: // virtual aaJC* clone() const { return new aaJC(*this); } // however, not all compiler support it yet. look at More Effective C++ page 126. rate4site-3.0.0/src/phylogeny/gtrModel.h0000644011611301161130000000344012223673416015101 00000000000000#ifndef _GTR_MODEL #define _GTR_MODEL #include "replacementModel.h" #include "fromQtoPt.h" class gtrModel : public replacementModel { public: enum modelElements {a = 0,c,g,t}; explicit gtrModel(const Vdouble& freq, const MDOUBLE a2c = 0.25, const MDOUBLE a2g = 0.25, const MDOUBLE a2t = 0.25, const MDOUBLE c2g = 0.25, const MDOUBLE c2t = 0.25, const MDOUBLE g2t = 0.25); virtual replacementModel* clone() const { return new gtrModel(*this); } virtual gtrModel& operator=(const gtrModel &other); explicit gtrModel(const gtrModel &other); const int alphabetSize() const {return _freq.size();} const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const {return _q2pt.Pij_t(i,j,d);} const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const{return _q2pt.dPij_dt(i,j,d);} const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const{return _q2pt.d2Pij_dt2(i,j,d);} const MDOUBLE freq(const int i) const {return _freq[i];}; void set_a2c(const MDOUBLE a2c); void set_a2g(const MDOUBLE a2g); void set_a2t(const MDOUBLE a2t); void set_c2g(const MDOUBLE c2g); void set_c2t(const MDOUBLE c2t); void set_g2t(const MDOUBLE g2t); MDOUBLE get_a2c() const; MDOUBLE get_a2g() const; MDOUBLE get_a2t() const; MDOUBLE get_c2g() const; MDOUBLE get_c2t() const; MDOUBLE get_g2t() const; const VVdouble& getQ() const {return _Q;} private: void updateQ(const MDOUBLE a2c,const MDOUBLE a2g,const MDOUBLE a2t,const MDOUBLE c2g,const MDOUBLE c2t,const MDOUBLE g2t); void norm(const MDOUBLE scale); MDOUBLE sumPijQij(); private: VVdouble _Q; Vdouble _freq; q2pt _q2pt; MDOUBLE _a2c; MDOUBLE _a2g; MDOUBLE _a2t; MDOUBLE _c2g; MDOUBLE _c2t; MDOUBLE _g2t; }; #endif rate4site-3.0.0/src/phylogeny/fromQtoPt.h0000644011611301161130000000376312223673416015267 00000000000000// $Id: fromQtoPt.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___FROM_Q_TO_PT #define ___FROM_Q_TO_PT #include "replacementModel.h" #include #include int MyJacobi(VVdouble &Insym, VVdouble &RightEigenV, Vdouble &EigenValues);// num rec VVdouble get1PamFromCountMatrix(const vector& freq, const VVdouble & sub_matrix); class q2pt : public replacementModel { public: void fillFromRateMatrix(const vector& freq, const VVdouble & qMatrix); void fillFrom1PAMMatrix(const vector& freq, const VVdouble & onePam); explicit q2pt(): err_allow_for_pijt_function(1e-4){} // @@@@ I'm not sure why I had to implement this operator=, but it doesn't work without it. q2pt& operator=(const q2pt &other) { _freq = other._freq; _leftEigen = other._leftEigen; _rightEigen = other._rightEigen; _eigenVector = other._eigenVector; return (*this); } virtual replacementModel* clone() const { return new q2pt(*this); } // virtual nucJC* clone() const { return new nucJC(*this); } // see note down: const int alphabetSize() const {return _freq.size();} const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const; const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const; const MDOUBLE freq(const int i) const {return _freq[i];}; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const; const MDOUBLE err_allow_for_pijt_function; //1e-4 VVdouble getLeftEigen() const {return _leftEigen;} ; VVdouble getRightEigen() const {return _rightEigen;}; Vdouble getEigenVec() const {return _eigenVector;}; private: Vdouble _freq; VVdouble _leftEigen; VVdouble _rightEigen; Vdouble _eigenVector; bool currectFloatingPointProblems(MDOUBLE& sum) const; public: // to become private: void calc_symmetric_q(const VVdouble &q_matrix,VVdouble &symmetric_q,const Vdouble & freq); void calc_left_and_right_eig_of_pam( VVdouble &left_eig_of_pam, VVdouble &right_eig_of_pam, const VVdouble &v, const Vdouble& freq); }; #endif rate4site-3.0.0/src/phylogeny/trivialAccelerator.h0000644011611301161130000000251212223673417017143 00000000000000// $Id: trivialAccelerator.h 1925 2007-04-04 16:40:22Z privmane $ #ifndef ___TRIVIAL_ACCELERATOR #define ___TRIVIAL_ACCELERATOR #include "pijAccelerator.h" #include "replacementModel.h" class trivialAccelerator : public pijAccelerator { public: explicit trivialAccelerator(const replacementModel* pb): _pb(pb->clone()) {}; trivialAccelerator(const trivialAccelerator& other):_pb(NULL){if (other._pb != NULL) _pb = other._pb->clone();} const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const {return _pb->Pij_t(i,j,d);} const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const{return _pb->dPij_dt(i,j,d);}; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const{return _pb->d2Pij_dt2(i,j,d);}; const MDOUBLE freq(const int i) const{return _pb->freq(i);} virtual pijAccelerator* clone() const { return new trivialAccelerator(*this);} virtual ~trivialAccelerator() {delete _pb;} virtual const int alphabetSize() const {return _pb->alphabetSize();} virtual replacementModel* getReplacementModel() const {return (_pb);} private: replacementModel* _pb; }; #endif // There is no distribution in the trivial accelerator. Actually, it's just an interface // to the replacement Model and it doesn't accelerate anything. // Every method retruns exactly the replacementModel corresponding method result. rate4site-3.0.0/src/phylogeny/distanceMethod.h0000644011611301161130000000123012223673416016252 00000000000000// $Id: distanceMethod.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___DISTANCE_METHOD #define ___DISTANCE_METHOD #include "definitions.h" #include "sequence.h" /********************************************************* Distance method is a class for computing pairwise distance between 2 different sequences *******************************************************/ class distanceMethod { public: virtual const MDOUBLE giveDistance(const sequence& s1, const sequence& s2, const vector * weights=NULL, MDOUBLE* score=NULL) const=0; virtual distanceMethod* clone(void) const=0; virtual ~distanceMethod() {} }; #endif rate4site-3.0.0/src/phylogeny/distanceTable.h0000644011611301161130000000061612223673416016070 00000000000000// $Id: distanceTable.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___DISTANCE_TABLE #define ___DISTANCE_TABLE #include "definitions.h" #include "distanceMethod.h" #include "sequenceContainer.h" void giveDistanceTable(const distanceMethod* dis, const sequenceContainer& sc, VVdouble& res, vector& names, const vector * weights = NULL); #endif rate4site-3.0.0/src/phylogeny/nj.h0000644011611301161130000000623112223673415013733 00000000000000// $Id: nj.h 962 2006-11-07 15:13:34Z privmane $ // version 1.00 // last modified 3 Nov 2002 #ifndef ___NJ #define ___NJ #include "definitions.h" #include "tree.h" #include "sequenceContainer.h" #include "njConstrain.h" #include "distances2Tree.h" using namespace std; class NJalg : public distances2Tree { public: virtual NJalg* clone() const {return new NJalg(*this);} // changed from computeNJtree to computeTree for competability to "distances2Tree" virtual tree computeTree(VVdouble distances, const vector& names, const tree * const constriantTree = NULL); tree startingTree(const vector& names); tree startingTree(const tree& inTree); void NJiterate(tree& et,vector& currentNodes, VVdouble& distanceTable); void NJiterate(tree& et,vector& currentNodes, VVdouble& distanceTable, njConstraint& njc); void calc_M_matrix(vector& currentNodes, const VVdouble& distanceTable, const Vdouble & r_values, int& minRaw,int& minCol); void calc_M_matrix(vector& currentNodes, const VVdouble& distanceTable, const Vdouble & r_values, int& minRaw,int& minCol, const njConstraint& njc); Vdouble calc_r_values(vector& currentNodes,const VVdouble& distanceTable); tree::nodeP SeparateNodes(tree& et,tree::nodeP node1,tree::nodeP node2); void update3taxaLevel(VVdouble& distanceTable,Vdouble & r_values,vector& currentNodes); void updateBranchDistance(const VVdouble& disT, const Vdouble& rValues, tree::nodeP nodeNew, tree::nodeP nodeI, tree::nodeP nodeJ, int Iplace, int Jplace); void UpdateDistanceTableAndCurrentNodes(vector& currentNodes, VVdouble& distanceTable, tree::nodeP nodeI, tree::nodeP nodeJ, tree::nodeP theNewNode, int Iplace, int Jplace); }; /* //explicit NJalg(const tree& inTree, const computeDistance* cd); explicit NJalg(); tree getNJtree() const {return *_myET;}// return a copy... void computeTree(const sequenceContainer& sd,const computeDistance* cd,const vector * weights = NULL); VVdouble getDistanceTable(vector& names) { names.erase(names.begin(),names.end()); names = _nodeNames; return _startingDistanceTable;} VVdouble getLTable(vector& names) { names.erase(names.begin(),names.end()); names = _nodeNames; return LTable;} private: //void starTreeFromInputTree(const tree& inTree); void starTreeFromInputsequenceContainer(const sequenceContainer& sd); void GetDisTable(const sequenceContainer& sd,const vector * weights); MDOUBLE dis(const int i, const int j) const{ return (i currentNodes; const computeDistance* _cd; VVdouble _startingDistanceTable; // for printing etc... not used by the algorithm. vector _nodeNames; // for printing etc... not used by the algorithm. VVdouble LTable;// for printing etc... not used by the algorithm. */ #endif rate4site-3.0.0/src/phylogeny/njConstrain.h0000644011611301161130000000127712223673416015622 00000000000000// $Id: njConstrain.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___NJ_CONSTRAINT #define ___NJ_CONSTRAINT #include #include "sequenceContainer.h" #include "tree.h" using namespace std; class njConstraint { public: njConstraint(const tree& starttree, const tree& constraintTree); bool isCompatible(const tree::nodeP& n1, const tree::nodeP& n2, const bool verbose=false) const; void join(const tree::nodeP& n1, const tree::nodeP& n2, const tree::nodeP& newFather); void output(ostream &out) const; private: tree _cTree; // constriant tree map _interTreeMap; }; ostream &operator<<(ostream &out, const njConstraint &c); #endif // ___NJ_CONSTRAINT rate4site-3.0.0/src/phylogeny/distances2Tree.h0000644011611301161130000000066712223673416016213 00000000000000// $Id: distances2Tree.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___DISTANCES2TREE #define ___DISTANCES2TREE #include "definitions.h" #include "tree.h" #include using namespace std; class distances2Tree { public: virtual ~distances2Tree() {} virtual distances2Tree* clone() const =0; virtual tree computeTree(VVdouble distances, const vector& names, const tree * const constriantTree = NULL) = 0; }; #endif rate4site-3.0.0/src/phylogeny/numRec.h0000644011611301161130000003022412223673416014555 00000000000000// $Id: numRec.h 9652 2011-07-12 13:59:26Z rubi $ // version 1.00 // last modified 2 Nov 2002 #ifndef ___NUM_REC #define ___NUM_REC #include #include #include using namespace std; #include "definitions.h" #include "errorMsg.h" #include "uniformDistribution.h" #include "logFile.h" //#define VERBOS #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) //========================== function brent ========================================= template MDOUBLE brent(MDOUBLE ax, MDOUBLE bx, MDOUBLE cx, regF f, MDOUBLE tol, MDOUBLE *xmin) { const int ITMAX = 100; const MDOUBLE CGOLD = 0.3819660f; const MDOUBLE ZEPS = 1.0e-10f; int iter; MDOUBLE a,b,d=0.0,etemp,fu,fv,fw,fx,p,q,r,tol1,tol2,u,v,w,x,xm; MDOUBLE e=0.0; a=(ax < cx ? ax : cx); b=(ax > cx ? ax : cx); x=w=v=bx; fw=fv=fx=f(x); LOG(10,<<"brent, f("< tol1) { r=(x-w)*(fx-fv); q=(x-v)*(fx-fw); p=(x-v)*q-(x-w)*r; q=2.0*(q-r); if (q > 0.0) p = -p; q=fabs(q); etemp=e; e=d; if (fabs(p) >= fabs(0.5*q*etemp) || p <= q*(a-x) || p >= q*(b-x)) d=CGOLD*(e=(x >= xm ? a-x : b-x)); else { d=p/q; u=x+d; if (u-a < tol2 || b-u < tol2) d=SIGN(tol1,xm-x); } } else { d=CGOLD*(e=(x >= xm ? a-x : b-x)); } u=(fabs(d) >= tol1 ? x+d : x+SIGN(tol1,d)); fu=f(u); LOG(10,<<"brent, f("<= x) a=x; else b=x; v=w;w=x;x=u; fv=fw;fw=fx; fx=fu; } else { if (u < x) a=u; else b=u; if (fu <= fw || w == x) { v=w; w=u; fv=fw; fw=fu; } else if (fu <= fv || v == x || v == w) { v=u; fv=fu; } } } errorMsg::reportError(" too many iterations in function, brent. "); // also quit the program return -1; } /* //A doubleRep implementation of brent cause return type function overloading is forbidden in c++ template doubleRep brentDoubleRep(doubleRep ax, doubleRep bx, doubleRep cx, regF f, doubleRep tol, MDOUBLE *xmin) { const int ITMAX = 100; const doubleRep CGOLD(0.3819660f); const doubleRep ZEPS(1.0e-10f); doubleRep minusOne(-1.0); int iter; doubleRep fu,fv,fw,fx,a,b,etemp,p,q,r,u,v,w,x; doubleRep d(0.0); doubleRep e(0.0); doubleRep half(0.5); doubleRep two(2.0); doubleRep zero(0.0); a=(ax < cx ? ax : cx); b=(ax > cx ? ax : cx); x=w=v=bx; fw=fv=fx=f(convert(x)); LOG(10,<<"brent, f("< convert(tol1)) { r=(x+minusOne*w)*(fx+minusOne*fv); q=(x+minusOne*v)*(fx+minusOne*fw); p=(x+minusOne*v)*q+minusOne*(x+minusOne*w)*r; q=two*(q+minusOne*r); if (q > zero) p = minusOne*p; doubleRep newQ(fabs(convert(q))); q=newQ; etemp=e; e=d; if (fabs(convert(p)) >= fabs(convert(half*q*etemp)) || p <= q*(a+minusOne*x) || p >= q*(b+minusOne*x)) d=CGOLD*(e=(x >= xm ? a+minusOne*x : b+minusOne*x)); else { d=p/q; u=x+d; if (u+minusOne*a < tol2 || b+minusOne*u < tol2){ doubleRep newD(SIGN(convert(tol1),convert(xm+minusOne*x))); d=newD; } } } else { d=CGOLD*(e=(x >= xm ? a+minusOne*x : b+minusOne*x)); } u=(fabs(convert(d)) >= convert(tol1) ? x+d : x+SIGN(convert(tol1),convert(d))); fu=f(convert(u)); LOG(10,<<"brent, f("<= x) a=x; else b=x; v=w;w=x;x=u; fv=fw;fw=fx; fx=fu; } else { if (u < x) a=u; else b=u; if (fu <= fw || w == x) { v=w; w=u; fv=fw; fw=fu; } else if (fu <= fv || v == x || v == w) { v=u; fv=fu; } } } errorMsg::reportError(" too many iterations in function, brentDoubleRep. "); // also quit the program return minusOne; } */ // ===================================== function dbrent ======================================== /* The efficiency of this function for likelihood computations can be improved by replacing functors regF f and dF df with one objects that preforms the likelihood computation once and produces both L(t) and dL(t)/dt. This object will provide methods: MDOUBLE f(MDOUBLE x) MDOUBLE df(MDOUBLE x) */ #define ITMAX 100 #define ZEPS 1.0e-10 #define MOV3(a,b,c, d,e,f) (a)=(d);(b)=(e);(c)=(f); template MDOUBLE dbrent(MDOUBLE ax, MDOUBLE bx, MDOUBLE cx, regF f, dF df, MDOUBLE tol, MDOUBLE *xmin) { int iter,ok1,ok2; MDOUBLE a,b,d=0.0,d1,d2,du,dv,dw,dx,e=0.0; MDOUBLE fu,fv,fw,fx,olde,tol1,tol2,u,u1,u2,v,w,x,xm; a=(ax < cx ? ax : cx); b=(ax > cx ? ax : cx); //ensuring x is between a and b if (bx>b) { x=w=v=b;b=bx;} else if (bx10) cout<<"iteration: "< doubleRep dbrentDoubleRep(doubleRep ax, doubleRep bx, doubleRep cx, regF f, dF df, doubleRep tol, MDOUBLE *xmin) { int iter,ok1,ok2; doubleRep a,b,d1,d2; doubleRep d(0.0); doubleRep e(0.0); doubleRep olde,u,u1,u2,v,w,x,xm; doubleRep fu,fv,fw,fx,du,dv,dw,dx; doubleRep minusOne(-1.0); doubleRep half(0.5); doubleRep two(2.0); doubleRep zero(0.0); a=(ax < cx ? ax : cx); b=(ax > cx ? ax : cx); //ensuring x is between a and b if (bx>b) { x=w=v=b;b=bx;} else if (bx10) cout<<"iteration: "< MDOUBLE rtbis(regF func,MDOUBLE x1, MDOUBLE x2, MDOUBLE xacc) { const int max_number_of_iter = 100; MDOUBLE f = func(x1); MDOUBLE fmid = func(x2); if (f*fmid >=0.0) { errorMsg::reportError(" error in function rtbis, root must be bracketed for bisection in rtbis "); // also quit the program } MDOUBLE dx, rtb; if (f<0.0) { dx = x2-x1; rtb = x1; } else { dx = x1-x2; rtb = x2; } for (int j=1; j <= max_number_of_iter; ++j) { dx *= 0.5; MDOUBLE xmid = rtb+dx; MDOUBLE fmid = func(xmid); if (fmid <= 0.0) rtb = xmid; if ((fabs(dx) < xacc) || (fmid == 0.0)) return rtb; } errorMsg::reportError("Error in function rtbis..."); // also quit the program... return -1.0; } //Given a function func and an initial guessed range (x1,x2), the routine expands the range //geometrically until a root is bracketed by the returned values x1 and x2 (in which case zbrac retruns true) //or until the range becomes large unacceptably large (in which case zbrac return false). template bool zbrac(regF func, MDOUBLE &x1, MDOUBLE &x2) { const int NTRY=50; const MDOUBLE FACTOR= 1.6; int j; MDOUBLE f1,f2; if (x1 == x2) errorMsg::reportError("Bad initial range in zbrac"); f1 = func(x1); f2 = func(x2); for (j = 0; j < NTRY; j++) { if (f1 * f2 < 0.0) return true; if (fabs(f1) < fabs(f2)) f1=func(x1 += FACTOR*(x1-x2)); else f2=func(x2 += FACTOR*(x2-x1)); } return false; } // ================================ function brent new ====================================== int MyJacobi(VVdouble &Insym, VVdouble &RightEigenV, Vdouble &EigenValues); MDOUBLE sign(MDOUBLE a,MDOUBLE b); MDOUBLE pythag(const MDOUBLE a, const MDOUBLE b); void houseHolder(VVdouble &mat,VVdouble &Q); void tred2(VVdouble &a, Vdouble &d, Vdouble &e); void QL(Vdouble &d, Vdouble &e, VVdouble &z); void computeEigenSystem(VVdouble &symmetricMatrix,VVdouble &eigenVectros,Vdouble &diagonal); MDOUBLE performKSTest(const uniformDistribution& empiricalDist, Vdouble& observedDist); // perform Kolomogorov-Smirnoff test MDOUBLE computeProbForKS (const MDOUBLE QsParam); // function called only by performKSTest #endif rate4site-3.0.0/src/phylogeny/uniformDistribution.h0000644011611301161130000000404212223673415017401 00000000000000// $Id: uniformDistribution.h 5807 2009-01-20 09:23:51Z adido $ // version 2.00 // last modified 21 Mar 2004 #ifndef ___FLAT_DIST #define ___FLAT_DIST /************************************************************ This represents a uniform distribution of one column (rectangular distribution) between a (lower_bound) and b (upper_bound) |---| ________|___|_____ a b the distribution (or rather (a,b)) is divided into categories (portions of the distribution) , where _rates is a vector with the median value for each category. _ratesProb represents the probability of each category. _globalRate represents the rate for two joint genes. ************************************************************/ #include "definitions.h" #include "distribution.h" class uniformDistribution : public distribution { public: explicit uniformDistribution(const int numOfCategories, MDOUBLE lowerBound, MDOUBLE upperBound); explicit uniformDistribution(){_globalRate=1.0;}; explicit uniformDistribution(const uniformDistribution& other); virtual ~uniformDistribution() {}; const int categories() const {return _rates.size();} virtual void change_number_of_categories(int in_number_of_categories); virtual const MDOUBLE rates(const int i) const {return _rates[i]*_globalRate;} virtual const MDOUBLE ratesProb(const int i) const {return _ratesProb[i];} virtual distribution* clone() const { return new uniformDistribution(*this); } virtual void setGlobalRate(const MDOUBLE x) {_globalRate = x;} virtual MDOUBLE getGlobalRate() const {return _globalRate;} virtual const MDOUBLE getCumulativeProb(const MDOUBLE x) const; MDOUBLE getBorder(const int i) const ; //return the ith border. Note: _bonderi[0] = m_lowerLimit, _bondery[categories()] = m_upperLimit void setUniformParameters(const int numOfCategories, MDOUBLE lowerBound, MDOUBLE upperBound); private: Vdouble _rates; Vdouble _ratesProb; MDOUBLE _globalRate; MDOUBLE _interval; MDOUBLE _upperBound; MDOUBLE _lowerBound; }; #endif //TO DO: //1. change categories() to numOfCategories() rate4site-3.0.0/src/phylogeny/checkcovFanctors.h0000644011611301161130000000517612223673415016620 00000000000000// $Id: checkcovFanctors.h 6634 2009-07-20 07:00:05Z osnatz $ #ifndef ____CHECKCOV__FANCTORS #define ____CHECKCOV__FANCTORS #include "definitions.h" #include "tree.h" #include "likelihoodComputation.h" using namespace likelihoodComputation; #include "sequenceContainer.h" #include "stochasticProcess.h" #include "logFile.h" #include //#define VERBOS #ifdef VERBOS #include using namespace std; #endif class Cevaluate_L_given_r{ public: explicit Cevaluate_L_given_r( const sequenceContainer& sd, const tree& t1, const stochasticProcess& sp, const int pos) :_sd(sd),_t1(t1),_pos(pos), _sp(sp) {} private: const sequenceContainer& _sd; const tree& _t1; const int _pos; const stochasticProcess& _sp; public: MDOUBLE operator() (const MDOUBLE r) { MDOUBLE tmp1= convert(getLofPos(_pos,_t1,_sd,_sp,r)); #ifdef VERBOS LOG(5,<<" r = "<& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, const Vdouble * const weights = NULL); // likelihood computation - per pos (1.1) //Old - remove when QA is done doubleRep getLofPosProportional(const int pos, // this function is used const tree& et, // when gamma, and the br-len const sequenceContainer& sc, // are the same for all pos. const computePijGam& pi, const stochasticProcess& sp, const MDOUBLE globalRateProb); doubleRep getLofPosProportional(const int pos, // this function is used const tree& et, // when gamma, and the br-len const sequenceContainer& sc, // are the same for all pos. const computePijGam& pi, const stochasticProcess& sp); //r4s_Proportional // used when the likelihood given each category is needed, not only the sum Vdouble getLofPosPerCat(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp); // used to fill the likelihood for the unobservable for each category doubleRep getLofPos(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp, Vdouble& likePerCat); // all the likdelhoodsPerCat and rateProb are filled // -------------------------------------------------------------------------------- // this function should be used only when the branch lengths are not the same for // all positions. Otherwise, computePijHom should be calculated once, // and be used for all calls. In this function, computePijHom is being computed for // each position. doubleRep getLofPosHomModelEachSiteDifferentRate(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp); // --------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // this function should be used only when the branch lengths are not the same for // all positions. Otherwise, computePijHom should be calculated once, // and be used for all calls. In this function, computePijHom is being computed for // each position. doubleRep getLofPosGamModelEachSiteDifferentRate(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp); // -------------------------------------------------------------------------------- doubleRep getLofPos(const int pos, // with a site specific rate. const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const MDOUBLE gRate); doubleRep getProbOfPosWhenUpIsFilledHom(const int pos, // to be used for homogenous model const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalHomPos& ssc); doubleRep getProbOfPosWhenUpIsFilledGam(const int pos, // to be used for Gamma model. const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGamPos& cup); doubleRep getLofPosAndPosteriorOfRates(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp, VdoubleRep& postrior); MDOUBLE getTreeLikelihoodFromUp(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, const Vdouble * weights =0 ); MDOUBLE getTreeLikelihoodFromUp2(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, VdoubleRep& posLike, // fill this vector with each position likelihood but without the weights. const Vdouble * weights=0, unObservableData* unObservableData_p=NULL); //old MDOUBLE getTreeLikelihoodFromUp2(const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const suffStatGlobalGamProportional& cup, const gammaDistribution* pProportionDist, VdoubleRep& posLike, // fill this vector with each position likelihood but without the weights. const Vdouble * weights=0); //new MDOUBLE getTreeLikelihoodFromUp2(const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const suffStatGlobalGamProportional& cup, const gammaDistribution* pProportionDist, VVdoubleRep& posLike, // fill this vector with each position likelihood but without the weights. const Vdouble * weights=0); // fill this vector with each position posterior rate (p(r|D)) // but without the weights. // the weights are used only because we return the likelihood // (this takes these weights into account). MDOUBLE getPosteriorOfRates(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, VVdoubleRep& posteriorLike, const Vdouble * weights = NULL); MDOUBLE getPosteriorOfRates(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, VVdoubleRep& posteriorLike, const Vdouble * weights = NULL); // fill the posteriorLike matrix with each position posterior rate (p(r|D)) // and the LLPP, but without the weights. MDOUBLE getPosteriorOfRatesAndLLPP(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, VVdoubleRep& posteriorLike, VdoubleRep& LLPerPos, const Vdouble * weights=NULL); // From Itay M. // this function forces non gamma computation of likelihoods from up. // i.e., even if the stochastic process is really gamma - the likelihood is computed as if there's no gamma. MDOUBLE getTreeLikelihoodFromUpSpecifcRates(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalHom& cup, VdoubleRep& posLike, // fill this vector with each position likelihood but without the weights. const Vdouble * weights = NULL); // added from main semphy on 23.5.2005 (eyal privman + matan ninio). MDOUBLE computeLikelihoodAndLikelihoodPerPosition(const sequenceContainer &sc, const tree &et, const stochasticProcess &sp, Vdouble &LLPerPos); MDOUBLE getTreeLikelihoodFromPosteriorAndAlpha(const MDOUBLE alpha, const Vdouble originalBounderi, const VVdouble& posteriorLike, const VdoubleRep& LLPP, const Vdouble* weights); }; #endif rate4site-3.0.0/src/phylogeny/computePijComponent.h0000644011611301161130000000354212223673416017331 00000000000000// $Id: computePijComponent.h 9253 2011-01-31 01:37:21Z rubi $ #ifndef ___COMPUTE_PIJ_COMPONENT #define ___COMPUTE_PIJ_COMPONENT #include "definitions.h" #include "tree.h" #include "stochasticProcess.h" #include "multipleStochasticProcess.h" #include "gammaDistribution.h" class computePijHomSpec {//specific node, no rate variation public: virtual ~computePijHomSpec(){}; void fillPij(const MDOUBLE dis, const stochasticProcess& sp, int derivationOrder = 0, bool isReversible =true); void resize(const int alphabetSize) { _V.resize(alphabetSize); for (int z=0;z _V; // let, let }; class computePijGam {// public: virtual ~computePijGam(){}; void fillPij(const tree& et, const stochasticProcess& sp, int derivationOrder = 0, bool isReversible =true); int categories() const {return _V.size();} int alphabetSize() const {return _V[0].alphabetSize();} int getNodesNum() const {return _V[0].getNodesNum();} MDOUBLE getPij(const int rateCategor,const int nodeId,const int let1,const int let2)const{ return _V[rateCategor].getPij(nodeId,let1,let2); } computePijHom& operator[] (int i) {return _V[i];} const computePijHom& operator[] (int i) const {return _V[i];} vector _V; // each rate category }; #endif rate4site-3.0.0/src/phylogeny/stochasticProcess.h0000644011611301161130000000417312223673416017033 00000000000000// $Id: stochasticProcess.h 2511 2007-11-04 12:08:50Z cohenofi $ #ifndef ___STOCHASTIC_PROCESS #define ___STOCHASTIC_PROCESS #include "pijAccelerator.h" #include "distribution.h" #include class stochasticProcess{ public: explicit stochasticProcess(const distribution *in_distr,const pijAccelerator *pijAccelerator, bool isReversible = true); explicit stochasticProcess() { _distr=NULL; _pijAccelerator=NULL; _isReversible=true; } stochasticProcess(const stochasticProcess& other); virtual stochasticProcess* clone() const {return new stochasticProcess(*this);} const int alphabetSize() const {return _pijAccelerator->alphabetSize();} // The alphabet size is the same as the matrix Pij size virtual const int categories() const {return _distr->categories();} virtual const MDOUBLE rates(const int i) const {return _distr->rates(i);} virtual const MDOUBLE ratesProb(const int i) const {return _distr->ratesProb(i);} virtual const MDOUBLE Pij_t(const int i, const int j, const MDOUBLE t) const { if (t!=0) return _pijAccelerator->Pij_t(i,j,t); return (i==j)? 1 : 0; } const MDOUBLE freq(const int i) const {assert(i>=0);return _pijAccelerator->freq(i);} // P(i) const MDOUBLE dPij_dt(const int i,const int j,const MDOUBLE t) const { return _pijAccelerator->dPij_dt(i,j,t);} const MDOUBLE d2Pij_dt2(const int i, const int j, const MDOUBLE t) const { return _pijAccelerator->d2Pij_dt2(i,j,t);} virtual distribution* distr() const {return _distr;} // @@@@ this const is a lie !!! virtual const pijAccelerator* getPijAccelerator() const {return _pijAccelerator;} virtual void setDistribution(const distribution* in_distr); stochasticProcess& operator=(const stochasticProcess &otherStoc); virtual ~stochasticProcess(); virtual void setGlobalRate(const MDOUBLE x) {_distr->setGlobalRate(x);} virtual MDOUBLE getGlobalRate() const {return _distr->getGlobalRate();} const bool isReversible() const {return _isReversible;} protected: distribution *_distr; pijAccelerator *_pijAccelerator; bool _isReversible; }; #endif // Stochastic process is composed of two objects: a distribution of rates and a Pij accelerator. rate4site-3.0.0/src/phylogeny/suffStatComponent.h0000644011611301161130000002124012223673416017004 00000000000000// $Id: suffStatComponent.h 9253 2011-01-31 01:37:21Z rubi $ #ifndef ___SUFF_STAT_COMPONENT #define ___SUFF_STAT_COMPONENT #include "definitions.h" #include using namespace std; // spec = for a specific node. global = for all the nodes // hom = no rate variation. gam = with rate variation. gamProportional = with gobal and local rate variation // pos = for one position //------------------------------------------------------------- class suffStatSpecHomPos{ // this is for a specific node. public: void set(const int letter,const doubleRep& val) { _V[letter]=val; } doubleRep get(const int letter) const { doubleRep tmp=_V[letter]; // cout << "tmp ="; // tmp.outputn(cout); return tmp; } void allocatePlace(const int alphabetSize) { _V.resize(alphabetSize); } bool isEmpty (){return (_V.empty());}; int size() const {return _V.size();} private: vector _V;//size = letter }; //------------------------------------------------------------- /* class suffStatSpecGamPos{// this is for a specific node with rates public: void set(const int rateCategor, const int letter,const MDOUBLE val) { _V[rateCategor].set(letter,val); } MDOUBLE get(const int rateCategor, const int letter) const { return _V[rateCategor].get(letter); } void allocatePlace(const int numberOfrateCategories,const int alphabetSize) { _V.resize(numberOfrateCategories); for (int i=0; i < numberOfrateCategories; ++i) { _V[i].allocatePlace(alphabetSize); } } bool isEmpty (){return (_V.empty());}; private: vector _V;//rateCategor,letter }; */ //------------------------------------------------------------- /* class suffStatSpecGam{// this is for a specific node with rates public: void set(const int pos,const int rateCategor, const int letter,const MDOUBLE val) { _V[pos].set(rateCategor,letter,val); } MDOUBLE get(const int pos,const int rateCategor, const int letter) const { return _V[pos].get(rateCategor,letter); } void allocatePlace(const int pos,const int numberOfrateCategories,const int alphabetSize) { _V.resize(pos); for (int i=0;i _V;//pos,rateCategor,letter }; */ //------------------------------------------------------------- /* class suffStatGlobalGam { public: MDOUBLE get(const int nodeId, const int pos,const int rateCategor, const int letter) const { return _V[nodeId].get(pos,rateCategor,letter); } void allocatePlace(const int numOfNodes, const int pos, const int numberOfrateCategories, const int alphabetSize) { _V.resize(numOfNodes); for (int i=0;i _V; }; */ //------------------------------------------------------------- class suffStatGlobalHomPos{ // this is for all nodes public: void set(const int nodeId,const int letter,const doubleRep val) { _V[nodeId].set(letter,val); } doubleRep get(const int nodeId,const int letter) const { doubleRep tmp(_V[nodeId].get(letter)); // tmp; // cout << "tmp2="; // tmp.outputn(cout); return tmp; } void allocatePlace(const int numOnNodes,const int alphabetSize) { _V.resize(numOnNodes); for (int i=0;i<_V.size();++i) {_V[i].allocatePlace(alphabetSize);} } bool isEmpty (){return (_V.empty());}; int size() const {return _V.size();} private: vector _V;//size = number of nodes. }; //------------------------------------------------------------- class suffStatGlobalGamPos{ // this is for all nodes public: void set(const int categor,const int nodeId,const int letter,const doubleRep val) { _V[categor].set(nodeId,letter,val); } doubleRep get(const int categor,const int nodeId,const int letter) const { return _V[categor].get(nodeId,letter); } void allocatePlace(const int categor,const int numOnNodes,const int alphabetSize) { _V.resize(categor); for (int i=0;i<_V.size();++i) {_V[i].allocatePlace(numOnNodes,alphabetSize);} } bool isEmpty (){return (_V.empty());} int size() const {return _V.size();} suffStatGlobalHomPos& operator[] (int index) {return _V[index];} const suffStatGlobalHomPos& operator[] (int index) const {return _V[index];} private: vector _V;//size = number of categories }; //------------------------------------------------------------- class suffStatGlobalGamProportionalPos{ // this is for all nodes public: void set(const int globalRateCategor,const int localRateCategor,const int nodeId,const int letter,const doubleRep val) { _V[globalRateCategor].set(localRateCategor,nodeId,letter,val); } doubleRep get(const int globalRateCategor,const int localRateCategor,const int nodeId,const int letter) const { return _V[globalRateCategor].get(localRateCategor,nodeId,letter); } void allocatePlace(const int globalRateCategor,const int localRateCategor,const int numOnNodes,const int alphabetSize) { _V.resize(globalRateCategor); for (int i=0;i<_V.size();++i) {_V[i].allocatePlace(localRateCategor,numOnNodes,alphabetSize);} } bool isEmpty (){return (_V.empty());} int size() const {return _V.size();} suffStatGlobalGamPos& operator[] (int index) {return _V[index];} const suffStatGlobalGamPos& operator[] (int index) const {return _V[index];} private: vector _V;//size = number of global rate categories }; //------------------------------------------------------------- class suffStatGlobalGam{ // this is for all positions (and for all nodes). public: void set(const int pos,const int categor,const int nodeId,const int letter,const doubleRep val) { _V[pos].set(categor,nodeId,letter,val); } doubleRep get(const int pos,const int categor,const int nodeId,const int letter) const { return _V[pos].get(categor,nodeId,letter); } void allocatePlace(const int pos,const int categor,const int numOnNodes,const int alphabetSize) { _V.resize(pos); for (int i=0;i<_V.size();++i) {_V[i].allocatePlace(categor,numOnNodes,alphabetSize);} } bool isEmpty (){return (_V.empty());} int size() const {return _V.size();} suffStatGlobalGamPos& operator[] (int index) {return _V[index];} const suffStatGlobalGamPos& operator[] (int index) const {return _V[index];} private: vector _V; }; //------------------------------------------------------------- class suffStatGlobalGamProportional{ // this is for all positions (and for all nodes). public: void set(const int pos,const int globalRateCategor,const int localRateCategor,const int nodeId,const int letter,const doubleRep val) { _V[pos].set(globalRateCategor,localRateCategor,nodeId,letter,val); } doubleRep get(const int pos,const int globalRateCategor,const int localRateCategor,const int nodeId,const int letter) const { return _V[pos].get(globalRateCategor,localRateCategor,nodeId,letter); } void allocatePlace(const int pos,const int globalRateCategor,const int localRateCategor,const int numOnNodes,const int alphabetSize) { _V.resize(pos); for (int i=0;i<_V.size();++i) {_V[i].allocatePlace(globalRateCategor,localRateCategor,numOnNodes,alphabetSize);} } bool isEmpty (){return (_V.empty());} int size() const {return _V.size();} suffStatGlobalGamProportionalPos& operator[] (int index) {return _V[index];} const suffStatGlobalGamProportionalPos& operator[] (int index) const {return _V[index];} private: vector _V; }; // from ItayM not to use with the EM algorithm. class suffStatGlobalHom{ // this is for all positions (and for all nodes). public: void set(const int pos, const int nodeId, const int letter,const doubleRep val) { _V[pos].set(nodeId, letter, val); } doubleRep get(const int pos, const int nodeId, const int letter) const { return _V[pos].get(nodeId, letter); } void allocatePlace(const int pos, const int numOnNodes, const int alphabetSize) { _V.resize(pos); for (int i=0;i<_V.size();++i) {_V[i].allocatePlace(numOnNodes, alphabetSize);} } bool isEmpty (){return (_V.empty());}; suffStatGlobalHomPos& operator[] (int index) {return _V[index];} const suffStatGlobalHomPos& operator[] (int index) const {return _V[index];} private: vector _V; }; #endif rate4site-3.0.0/src/phylogeny/unObservableData.h0000644011611301161130000000303112223673415016540 00000000000000#ifndef ___unObservableData___GL #define ___unObservableData___GL #include "definitions.h" #include "tree.h" #include "stochasticProcess.h" #include "sequenceContainer.h" #include "gainLossAlphabet.h" #include "computePijComponent.h" /******************************************************************************************** unObservableData *********************************************************************************************/ class unObservableData{ public: explicit unObservableData(const sequenceContainer& sc,const stochasticProcess* sp ,const gainLossAlphabet alph, const int minNumOfOnes, const int minNumOfZeros); unObservableData(const unObservableData& other); //const virtual ~unObservableData(){}; virtual unObservableData* clone() const {return new unObservableData(*this);} Vdouble* getpLforMissingDataPerCat(); Vdouble getLforMissingDataPerCat(); MDOUBLE getlogLforMissingData(); int getNumOfUnObservablePatterns(); void setLforMissingData(const tree& _tr, const stochasticProcess* _sp); //void setLforMissingData(const tree& _tr, const stochasticProcess* _sp); void setLforMissingData(const tree& _tr, const vector >& spVVec, const distribution * distGain, const distribution* distLoss); //MDOUBLE getCorrectedLikelihood(MDOUBLE likePre){return } protected: //func protected: //members sequenceContainer _scZero; Vdouble _LforMissingDataPerCat; // used foreach rate category MDOUBLE _logLforMissingData; computePijGam _pi; }; #endif rate4site-3.0.0/src/phylogeny/likeDist.h0000644011611301161130000002006512223673415015075 00000000000000// $Id: likeDist.h 9752 2011-08-05 20:27:25Z rubi $ #ifndef ___LIKE_DIST_H #define ___LIKE_DIST_H #include "definitions.h" #include "countTableComponent.h" #include "distanceMethod.h" #include "stochasticProcess.h" #include "logFile.h" #include "jcDistance.h" #include "unObservableData.h" #include using namespace std; class likeDist : public distanceMethod { public: // WARNING: the stochasticProcess is NOT copied. The same object is used explicit likeDist(const stochasticProcess& sp, const MDOUBLE toll =0.0001, const MDOUBLE maxPairwiseDistance = 5.0, const MDOUBLE minPairwiseDistance = 0.0000001, unObservableData* unObservableData_p=NULL) : _sp(sp),_nonConstSpPtr(NULL),_toll(toll),_maxPairwiseDistance(maxPairwiseDistance),_minPairwiseDistance(minPairwiseDistance),_unObservableData_p(unObservableData_p) {} likeDist(const likeDist& other) : _sp(other._sp),_nonConstSpPtr(other._nonConstSpPtr),_toll(other._toll),_maxPairwiseDistance(other._maxPairwiseDistance),_minPairwiseDistance(other._minPairwiseDistance),_jcDist(other._jcDist) {} virtual likeDist* clone() const {return new likeDist(*this);} // This constructor allows non-const stochasticProcess so that likeDist will be able to change alpha, etc. explicit likeDist(stochasticProcess& sp, const MDOUBLE toll =0.0001, const MDOUBLE maxPairwiseDistance = 5.0, const MDOUBLE minPairwiseDistance = 0.0000001) : _sp(sp),_nonConstSpPtr(&sp),_toll(toll),_maxPairwiseDistance(maxPairwiseDistance),_minPairwiseDistance(minPairwiseDistance) {} // THIS FUNCTION DOES NOT RETURN THE LOG LIKELIHOOD IN RESQ, BUT RATHER "Q", THE CONTRIBUTION of this edge // TO THE EXPECTED LOG-LIKELIHOOD (SEE SEMPHY PAPER). // NEVERTHELESS, THE t that optimizes Q is the same t that optimizes log-likelihood. const MDOUBLE giveDistance(const countTableComponentGam& ctc, MDOUBLE& resQ, const MDOUBLE initialGuess= 0.03) const; // initial guess // given two sequences, it evaluates the log likelihood. MDOUBLE evalLogLikelihoodGivenDistance(const sequence& s1, const sequence& s2, const MDOUBLE dis2evaluate); // returns the estimated ML distance between the 2 sequences. // if score is given, it will be the log-likelihood. const MDOUBLE giveDistance(const sequence& s1, const sequence& s2, const vector * weights, MDOUBLE* score=NULL) const; // this function creates a countTableComponent (ctc) from the two sequences. // it then computes the distance from this ctc. // THIS FUNCTION DOES NOT RETURN THE LOG LIKELIHOOD IN score, BUT RATHER "Q", THE CONTRIBUTION of this edge // TO THE EXPECTED LOG-LIKELIHOOD (SEE SEMPHY PAPER). // NEVERTHELESS, THE t that optimizes Q is the same t that optimizes log-likelihood. MDOUBLE giveDistanceThroughCTC(const sequence& s1, const sequence& s2, const vector * weights, MDOUBLE* score=NULL) const; const MDOUBLE giveLikelihood(const sequence& s1, const sequence& s2, MDOUBLE distance, const vector * weights=NULL) const; // return the stochasticProcess const stochasticProcess& getStochasticProcess() const {return _sp;} stochasticProcess& getNonConstStochasticProcess(); bool isTheInternalStochasticProcessConst() const {return !_nonConstSpPtr;} MDOUBLE getToll() const {return _toll;} MDOUBLE getMaxPairwiseDistance() const {return _maxPairwiseDistance;} protected: const stochasticProcess &_sp; stochasticProcess *_nonConstSpPtr; const MDOUBLE _toll; const MDOUBLE _maxPairwiseDistance; const MDOUBLE _minPairwiseDistance; jcDistance _jcDist; unObservableData* _unObservableData_p; private: const MDOUBLE giveDistanceBrent( const countTableComponentGam& ctc, MDOUBLE& resL, const MDOUBLE initialGuess= 0.03) const; // initial guess const MDOUBLE giveDistanceNR( const countTableComponentGam& ctc, MDOUBLE& resL, const MDOUBLE initialGuess= 0.03) const; // initial guess public: static MDOUBLE evalLikelihoodForDistance(const stochasticProcess& sp, const sequence& s1, const sequence& s2, const MDOUBLE dist, const vector * weights=NULL); }; ////////////////////////////////////////////////////////////////////////// class C_evalLikeDist{ private: const countTableComponentGam& _ctc; const stochasticProcess& _sp; unObservableData* _unObservableData_p; public: C_evalLikeDist(const countTableComponentGam& ctc, const stochasticProcess& inS1,unObservableData* unObservableData_p=NULL) :_ctc(ctc), _sp(inS1),_unObservableData_p(unObservableData_p) {}; MDOUBLE operator() (MDOUBLE dist) { const MDOUBLE epsilonPIJ = 1e-10; MDOUBLE sumL=0.0; for (int alph1=0; alph1 < _ctc.alphabetSize(); ++alph1){ for (int alph2=0; alph2 < _ctc.alphabetSize(); ++alph2){ for (int rateCategor = 0; rateCategor<_sp.categories(); ++rateCategor) { MDOUBLE rate = _sp.rates(rateCategor); MDOUBLE pij= _sp.Pij_t(alph1,alph2,dist*rate); if (pijgetlogLforMissingData())); // need to find an efficient way to update LofMissingData with dist LOG(8,<<"check bl="< #include class countTableComponentHom{ public: void setCount( const int letter1, const int letter2, const MDOUBLE val) { _countValues[letter1][letter2]=val; } int alphabetSize() const {return _countValues.size();} void zero(); MDOUBLE getCounts( const int letter1, const int letter2) const { return _countValues[letter1][letter2]; } void addToCounts(const int let1,const int let2,const MDOUBLE val) { _countValues[let1][let2]+=val; } int getSize() const {return _countValues.size();} bool isEmpty (){return (_countValues.empty());}; void countTableComponentAllocatePlace(const int alphabetSize); void printTable(ostream & out) const; const Vdouble& operator[] (int i) const {return _countValues[i];} private: VVdouble _countValues;//letter1,letter2 }; class countTableComponentGam{ public: void setCount( const int letter1, const int letter2, const int rateCategor, const MDOUBLE val) { _countValues[rateCategor].setCount(letter1,letter2,val); } int alphabetSize() const {return _countValues.empty()?0:_countValues[0].alphabetSize();} void zero(){ for (int rateCat=0; rateCat < _countValues.size(); ++rateCat) _countValues[rateCat].zero(); } MDOUBLE getCounts( const int letter1, const int letter2, const int rateCategor) const { assert(_countValues[rateCategor].getCounts(letter1,letter2)>=0); return _countValues[rateCategor].getCounts(letter1,letter2); } void addToCounts(const int let1,const int let2, const int rate,const MDOUBLE val) { _countValues[rate].addToCounts(let1,let2,val); } bool isEmpty (){return (_countValues.empty());}; void countTableComponentAllocatePlace(const int alphabetSize, const int numberOfrateCategories) { _countValues.resize(numberOfrateCategories); for (int rateCat=0; rateCat < _countValues.size(); ++rateCat){ _countValues[rateCat].countTableComponentAllocatePlace(alphabetSize); } } void printTable(ostream & out) const { for (int rateCat=0; rateCat < _countValues.size(); ++rateCat) { _countValues[rateCat].printTable(out); } } int getSize() const {return _countValues.size();} countTableComponentHom& operator[] (int i) {return _countValues[i];} const countTableComponentHom& operator[] (int i) const {return _countValues[i];} private: vector _countValues;//letter1,letter2,rateCategor }; class countTableComponentGamProportional{ public: void setCount( const int letter1, const int letter2, const int globalRateCategor, const int localRateCategor, const MDOUBLE val) { _countValues[globalRateCategor].setCount(letter1,letter2,localRateCategor,val); } int alphabetSize() const {return _countValues.empty()?0:_countValues[0].alphabetSize();} void zero(){ for (int globalRateCat=0; globalRateCat < _countValues.size(); ++globalRateCat) _countValues[globalRateCat].zero(); } MDOUBLE getCounts( const int letter1, const int letter2, const int globalRateCategor, const int localRateCategor) const { assert(_countValues[globalRateCategor].getCounts(letter1,letter2,localRateCategor)>=0); return _countValues[globalRateCategor].getCounts(letter1,letter2,localRateCategor); } void addToCounts(const int let1,const int let2, const int globalRate,const int localRate,const MDOUBLE val) { _countValues[globalRate].addToCounts(let1,let2,localRate,val); } bool isEmpty (){return (_countValues.empty());} void countTableComponentAllocatePlace(const int alphabetSize, const int numberOfGlobalRateCategories,const int numberOfLocalRateCategories) { _countValues.resize(numberOfGlobalRateCategories); for(int globalRateCat = 0;globalRateCat < _countValues.size(); ++globalRateCat){ _countValues[globalRateCat].countTableComponentAllocatePlace(alphabetSize,numberOfLocalRateCategories); } } void printTable(ostream & out) const { for (int globalRateCat=0; globalRateCat < _countValues.size(); ++globalRateCat) { _countValues[globalRateCat].printTable(out); } } int getSize() const {return _countValues.size();} countTableComponentGam& operator[] (int i) {return _countValues[i];} const countTableComponentGam& operator[] (int i) const {return _countValues[i];} private: vector _countValues;//letter1,letter2,globalRateCategor,localRateCategor }; #endif rate4site-3.0.0/src/phylogeny/jcDistance.h0000644011611301161130000001047512223673415015400 00000000000000// $Id: jcDistance.h 1928 2007-04-04 16:46:12Z privmane $ #ifndef ___JC_DISTANCE #define ___JC_DISTANCE #include "definitions.h" #include "distanceMethod.h" #include #include /********************************************************* Jukes-Cantor distance method. Assumes no constraints on replacement from one state to another. Receives size of alphabet in constructor, and this enables to have one class for JC-distance for nucleotides, a.a., and codons Weights are an input vector for giving additional weight to positions in the sequences. *******************************************************/ class jcDistance : public distanceMethod { public: explicit jcDistance() {} virtual jcDistance* clone() const{ return new jcDistance(*this);} const MDOUBLE giveDistance( const sequence& s1, const sequence& s2, const vector * weights, MDOUBLE* score=NULL) const {//score is not used here if (typeid(s1.getAlphabet()) != typeid(s2.getAlphabet())) errorMsg::reportError("Error in jcDistance::giveDistance, s1 and s2 contain different type of alphabet"); // pS1Base and pS2Base are references to s1 and s2 respectively. // The method uses seq1 and seq2 and not s1 and s2, because when // the sequences contain mulAlphabet we must first convert them to the base alphabet const sequence* pS1Base(&s1); const sequence* pS2Base(&s2); const alphabet* alph = s1.getAlphabet(); // if s1 and contains mulAlphabet const mulAlphabet* mulAlph = dynamic_cast(alph); if (mulAlph!=NULL) { pS1Base = new sequence(s1,mulAlph->getBaseAlphabet()); pS2Base = new sequence(s2,mulAlph->getBaseAlphabet()); } int alphabetSize = pS1Base->getAlphabet()->size(); // const MDOUBLE MAXDISTANCE=2.0; const MDOUBLE MAXDISTANCE=15; MDOUBLE p =0; MDOUBLE len=0.0; if (weights == NULL) { for (int i = 0; i < pS1Base->seqLen() ; ++i) { if ((*pS1Base)[i]<0 || (*pS2Base)[i]<0) continue; //gaps and missing data. len+=1.0; if ((*pS1Base)[i] != (*pS2Base)[i]) p++; } if (len==0) p=1; else p = p/len; } else { for (int i = 0; i < pS1Base->seqLen() ; ++i) { if ((*pS1Base)[i]<0 || (*pS2Base)[i]<0) continue; //gaps and missing data. len += (*weights)[i]; if ((*pS1Base)[i] != (*pS2Base)[i]) p+=((*weights)[i]); } if (len==0) p=1; else { p = p/len; } } if (pS1Base != &s1) { delete pS1Base; delete pS2Base; } const MDOUBLE inLog = 1 - (MDOUBLE)alphabetSize*p/(alphabetSize-1.0); if (inLog<=0) { // LOG(6,<<" DISTANCES FOR JC DISTANCE ARE TOO BIG"); // LOG(6,<<" p="< * weights, MDOUBLE* score=NULL) const {//score is not used here // const MDOUBLE MAXDISTANCE=2.0; const MDOUBLE MAXDISTANCE=15; MDOUBLE p =0; MDOUBLE len=0.0; if (weights == NULL) { for (int i = 0; i < s1.seqLen() ; ++i) { //if (s1[i]<0 || s2[i]<0) continue; //gaps and missing data. len+=1.0; if (s1[i] != s2[i]) p++; } if (len==0) p=1; else p = p/len; } else { for (int i = 0; i < s1.seqLen() ; ++i) { //if (s1[i]<0 || s2[i]<0) continue; //gaps and missing data. len += (*weights)[i]; if (s1[i] != s2[i]) p+=((*weights)[i]); } if (len==0) p=1; else { p = p/len; } } const MDOUBLE inLog = 1 - (MDOUBLE)_alphabetSize*p/(_alphabetSize-1.0); if (inLog<=0) { // LOG(6,<<" DISTANCES FOR JC DISTANCE ARE TOO BIG"); // LOG(6,<<" p="< using namespace std; tree getBestMLTreeFromManyNJtrees(sequenceContainer & allTogether, stochasticProcess& sp, const int numOfNJtrees, const MDOUBLE tmpForStartingTreeSearch, const MDOUBLE epslionWeights, ostream& out); #endif rate4site-3.0.0/src/phylogeny/checkcovFanctorsWithFactors.h0000644011611301161130000000234612223673416020773 00000000000000// $Id: checkcovFanctorsWithFactors.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ____CHECKCOV__FANCTORS_WITH_FACTORS #define ____CHECKCOV__FANCTORS_WITH_FACTORS #include "definitions.h" #include "tree.h" #include "likelihoodComputation.h" #include "likelihoodComputationFactors.h" //<-new. using namespace likelihoodComputation; #include "sequenceContainer.h" #include "stochasticProcess.h" //#define VERBOS #ifdef VERBOS #include using namespace std; #endif // USING FACTORS: THE IDEA HERE IS THAT WHEN WE HAVE TOO MANY SEQUENCES, // WE MUST TAKE SPECIAL CARE TO USE "FACTORS" AT INTERNAL NODES, TO AVOID UNDERFLOW. // HERE WE ALSO RETURN LOG LIKELIHOOD OF A POSITION AND NOT THE LIKELIHOOD ITSELF. class Cevaluate_LOG_L_given_r{ public: explicit Cevaluate_LOG_L_given_r( const sequenceContainer& sd, const tree& t1, const stochasticProcess& sp, const int pos) :_sd(sd),_t1(t1),_pos(pos), _sp(sp){} private: const sequenceContainer& _sd; const tree& _t1; const int _pos; const stochasticProcess& _sp; public: MDOUBLE operator() (const MDOUBLE r) { MDOUBLE tmp1= getLOG_LofPos(_pos,_t1,_sd,_sp,r); #ifdef VERBOS LOG(5,<<" r = "<& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalRateAlphas, const MDOUBLE upperBoundOnLocalRateAlpha, const MDOUBLE initGlobalRateAlpha, const MDOUBLE upperBoundOnGlobalRateAlpha, const int maxBBLIterations, const int maxTotalIterations, const bool optimizeSelectedBranches=false, const bool optimizeTree = true, const string branchLengthOptimizationMethod="bblLS", const bool optimizeLocalAlpha = true, const bool optimizeGlobalAlpha = true, const Vdouble * weights=NULL, const MDOUBLE epsilonLoglikelihoodForLocalRateAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForGlobalRateAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.05); MDOUBLE getBestLocalAlpha(int spIndex){return _bestLocalAlphaVec[spIndex];} MDOUBLE getBestGlobalAlpha(){return _bestGlobalAlpha;} Vdouble getBestL() {return _bestLvec;} private: Vdouble _bestLocalAlphaVec; MDOUBLE _bestGlobalAlpha; Vdouble _bestLvec; }; class bestBetaAndBBL { public: explicit bestBetaAndBBL(tree& et, //find Best Beta and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const MDOUBLE initBeta = 1.5, const MDOUBLE upperBoundOnBeta = 5.0, const MDOUBLE epsilonLoglikelihoodForBetaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.05, const int maxBBLIterations=10, const int maxTotalIterations=5); MDOUBLE getBestBeta() {return _bestBeta;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestBeta; MDOUBLE _bestL; }; class bestAlphaAndBetaAndBBL { public: explicit bestAlphaAndBetaAndBBL(tree& et, //find Best Alpha and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const MDOUBLE initAlpha = 1.5, const MDOUBLE initBeta = 1.5, const MDOUBLE upperBoundOnAlpha = 5.0, const MDOUBLE upperBoundOnBeta = 5.0, const MDOUBLE epsilonLoglikelihoodForAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBetaOptimization = 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.05, const int maxBBLIterations=10, const int maxTotalIterations=5); MDOUBLE getBestAlpha() {return _bestAlpha;} MDOUBLE getBestBeta() {return _bestBeta;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestAlpha; MDOUBLE _bestBeta; MDOUBLE _bestL; }; class C_evalAlpha{ public: C_evalAlpha( const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights = NULL) : _et(et),_sc(sc),_weights(weights),_sp(sp){}; private: const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; public: MDOUBLE operator() (MDOUBLE alpha) { if (_sp.categories() == 1) { errorMsg::reportError(" one category when trying to optimize alpha"); } (static_cast(_sp.distr()))->setAlpha(alpha); MDOUBLE res = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,_sp,_weights); //LOG(5,<<" with alpha = "<(_sp.distr()))->setAlpha(alpha); vector tmpScVec; tmpScVec.push_back(_sc); vector tmpSpVec; tmpSpVec.push_back(_sp); multipleStochasticProcess * tmpMsp = new multipleStochasticProcess(); tmpMsp->setSpVec(tmpSpVec); Vdouble likeVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(_et,tmpScVec,tmpMsp,_pProportionDist); MDOUBLE res = likeVec[0]; delete(tmpMsp); LOG(5,<<" with local alpha = "<setAlpha(alpha); Vdouble likeVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(_et,_sc,_msp,_pProportionDist); MDOUBLE res = sumVdouble(likeVec); LOG(5,<<" with global alpha = "<(_sp.distr()))->setBeta(beta); MDOUBLE res = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,_sp,_weights); //LOG(5,<<" with alpha = "< & etVec, const vector & spVec, const sequenceContainer& sc, const MDOUBLE maxRate, const MDOUBLE tol); // this function is the same as the one above, but here, // there are only tree attributes. MDOUBLE computeML_siteSpecificRate(Vdouble & ratesV, Vdouble & likelihoodsV, const Vint& treeAttributesVec, const vector & etVec, const stochasticProcess& sp, const sequenceContainer& sc, const MDOUBLE maxRate, const MDOUBLE tol); // this function is the same as the one above, but here, // there are only stochastic process attributes. MDOUBLE computeML_siteSpecificRate(Vdouble & ratesV, Vdouble & likelihoodsV, const Vint& spAttributesVec, const tree & et, const vector & spVec, const sequenceContainer& sc, const MDOUBLE maxRate, const MDOUBLE tol); void computeML_siteSpecificRate(int pos, const sequenceContainer& sc, const stochasticProcess& sp, const tree &et, MDOUBLE& bestRate, MDOUBLE& posL, const MDOUBLE maxRate, const MDOUBLE tol); // BAYESIAN PART // 1 sequence container, 1 tree, 1 position void computeEB_EXP_siteSpecificRate(int pos, const sequenceContainer& sc, const stochasticProcess& sp, const computePijGam& cpg, const tree &et, MDOUBLE& bestRate, MDOUBLE & stdRate, MDOUBLE & lowerConf, MDOUBLE & upperConf, const MDOUBLE alphaConf, VVdouble* LpostPerCat=NULL, unObservableData* unObservableData_p=NULL); // 1 stochastic process, 1 tree, all positions void computeEB_EXP_siteSpecificRate(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const sequenceContainer& sc, const stochasticProcess& sp, const tree& et, const MDOUBLE alphaConf, VVdouble* LpostPerCat=NULL, unObservableData* unObservableData_p=NULL); // many stochastic process, many tree, all positions void computeEB_EXP_siteSpecificRate(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const Vint& spAttributesVec, const Vint& treeAttributesVec, const sequenceContainer& sc, const vector & etVec, const vector & spVec, const MDOUBLE alphaConf); // many stochastic process, 1 tree, all positions void computeEB_EXP_siteSpecificRate(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const Vint& spAttributesVec, const sequenceContainer& sc, const tree & et, const vector & spVec, const MDOUBLE alphaConf); // 1 stochastic process, many tree, all positions void computeEB_EXP_siteSpecificRate(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const Vint& treeAttributesVec, const sequenceContainer& sc, const vector & etVec, const stochasticProcess & sp, const MDOUBLE alphaConf); // PROPORTIONAL BAYESIAN PART // Many stochastic processes controlled by their distribution, 1 sequence container, 1 tree, 1 position void computeEB_EXP_siteSpecificRateProportional(int pos, const sequenceContainer& sc, stochasticProcess& sp, const gammaDistribution* pProportionDist, const tree &et, MDOUBLE& bestRate, MDOUBLE & stdRate, MDOUBLE & lowerConf, MDOUBLE & upperConf, const MDOUBLE alphaConf, VVVdouble* LpostPerCats=NULL); // Many stochastic processes controlled by their distribution, 1 tree, all positions void computeEB_EXP_siteSpecificRateProportional(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const sequenceContainer& sc, stochasticProcess& sp, const gammaDistribution* pProportionDist, const tree& et, const MDOUBLE alphaConf, VVVdouble* LpostPerCats=NULL); #endif rate4site-3.0.0/src/phylogeny/recognizeFormat.h0000644011611301161130000000100412223673416016454 00000000000000// $Id: recognizeFormat.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___RECOGNIZE_FORMAT #define ___RECOGNIZE_FORMAT #include "sequenceContainer.h" class recognizeFormat{ public: static sequenceContainer read(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); }; #endif rate4site-3.0.0/src/phylogeny/bblEM.h0000644011611301161130000000312112223673416014301 00000000000000// $Id: bblEM.h 8174 2010-06-20 08:38:12Z cohenofi $ #ifndef ___BBL_EM_H #define ___BBL_EM_H #include "definitions.h" #include "tree.h" #include "stochasticProcess.h" #include "sequenceContainer.h" #include "countTableComponent.h" #include "computePijComponent.h" #include "suffStatComponent.h" #include "unObservableData.h" #include using namespace std; class bblEM { public: explicit bblEM(tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const Vdouble * weights = NULL, const int maxIterations=50, const MDOUBLE epsilon=0.05, const MDOUBLE tollForPairwiseDist=0.001, unObservableData* unObservableData_p=NULL, const MDOUBLE* likelihoodLast=NULL); MDOUBLE getTreeLikelihood() const {return _treeLikelihood;} private: MDOUBLE compute_bblEM(const int maxIterations, const MDOUBLE epsilon, const MDOUBLE tollForPairwiseDist, const MDOUBLE* likelihoodLast=NULL); void bblEM_it(const MDOUBLE tollForPairwiseDist); void computeDown(const int pos); void computeUp(); void addCounts(const int pos); void addCounts(const int pos, tree::nodeP mynode, const doubleRep posProb, const MDOUBLE weig); void optimizeBranches(const MDOUBLE tollForPairwiseDist); void allocatePlace(); MDOUBLE _treeLikelihood; tree& _et; const sequenceContainer& _sc; const stochasticProcess& _sp; vector _computeCountsV; // for each node - a table of rate*alph*alph computePijGam _pij; suffStatGlobalGam _cup; suffStatGlobalGamPos _cdown; const Vdouble * _weights; VdoubleRep _posLike; unObservableData* _unObservableData_p; }; #endif rate4site-3.0.0/src/phylogeny/bestGtrModelParams.h0000644011611301161130000001627212223673416017072 00000000000000// $Id: bestGtrModelparams.h 2008-28-04 15:13:34Z nimrod $ #ifndef ___BEST_GTRMODEL_PARAMS #define ___BEST_GTRMODEL_PARAMS #include "definitions.h" #include "likelihoodComputation.h" #include "sequenceContainer.h" #include "stochasticProcess.h" #include "gammaDistribution.h" #include "generalGammaDistribution.h" #include "tree.h" #include "gtrModel.h" typedef enum { Invalid = 0, a2c, a2g, a2t, c2g, c2t, g2t, }GTRParam; #define maxBBLIt 10 #define epsilonLoglikeForBBL 0.01 #define inAlpha 1.5 #define epsilonLoglikeForAlphaOptimization 0.01 #define upperBoundForAlpha 5.0 class bestGtrModel { public: explicit bestGtrModel(tree& et, // find best Gtr Model Params const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const int maxTotalIterations = 5, const MDOUBLE epsilonLikelihoodImprovment = 0.05, const MDOUBLE epsilonLoglikelihoodForGTRParam = 0.01, const MDOUBLE upperBoundGTRParam = 5.0, const bool optimizeTree = true, const bool optimizeAlpha = true); MDOUBLE getBesta2c() {return _best_a2c;} MDOUBLE getBesta2g() {return _best_a2g;} MDOUBLE getBesta2t() {return _best_a2t;} MDOUBLE getBestc2g() {return _best_c2g;} MDOUBLE getBestc2t() {return _best_c2t;} MDOUBLE getBestg2t() {return _best_g2t;} MDOUBLE getBestAlpha() {return _bestAlpha;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _best_a2c; MDOUBLE _best_a2g; MDOUBLE _best_a2t; MDOUBLE _best_c2g; MDOUBLE _best_c2t; MDOUBLE _best_g2t; MDOUBLE _bestAlpha; MDOUBLE _bestL; }; class bestGtrModelProportional { public: explicit bestGtrModelProportional(tree& et, // find best Gtr Model Params under a proportional model vector& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalAlphas, Vdouble initLocala2cs, Vdouble initLocala2gs, Vdouble initLocala2ts, Vdouble initLocalc2gs, Vdouble initLocalc2ts, Vdouble initLocalg2ts, const MDOUBLE upperBoundOnLocalAlpha, const MDOUBLE initGlobalAlpha, const MDOUBLE upperBoundOnGlobalAlpha, const MDOUBLE upperBoundGTRParam, const int maxTotalIterations, const int maxBBLIterations, const bool optimizeSelectedBranches=false, const bool optimizeTree = true, const string branchLengthOptimizationMethod="bblLS", const bool optimizeLocalParams = true, const bool optimizeGlobalAlpha = true, const Vdouble * weights=NULL, const MDOUBLE epsilonLikelihoodImprovment = 0.05, const MDOUBLE epsilonLoglikelihoodForGTRParam = 0.01, const MDOUBLE epsilonLoglikelihoodForLocalAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForGlobalAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.01); MDOUBLE getBesta2c(int spIndex) {return _best_a2cVec[spIndex];} MDOUBLE getBesta2g(int spIndex) {return _best_a2gVec[spIndex];} MDOUBLE getBesta2t(int spIndex) {return _best_a2tVec[spIndex];} MDOUBLE getBestc2g(int spIndex) {return _best_c2gVec[spIndex];} MDOUBLE getBestc2t(int spIndex) {return _best_c2tVec[spIndex];} MDOUBLE getBestg2t(int spIndex) {return _best_g2tVec[spIndex];} MDOUBLE getBestLocalAlpha(int spIndex) {return _bestLocalAlphaVec[spIndex];} MDOUBLE getBestGlobalAlpha() {return _bestGlobalAlpha;} Vdouble getBestL() {return _bestLvec;} private: Vdouble _best_a2cVec; Vdouble _best_a2gVec; Vdouble _best_a2tVec; Vdouble _best_c2gVec; Vdouble _best_c2tVec; Vdouble _best_g2tVec; Vdouble _bestLocalAlphaVec; MDOUBLE _bestGlobalAlpha; Vdouble _bestLvec; }; class C_evalGTRParam{ public: C_evalGTRParam( const GTRParam param, const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights = NULL) :_param(param), _et(et),_sc(sc),_weights(weights),_sp(sp){}; private: const GTRParam _param; const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; public: MDOUBLE operator() (MDOUBLE paramVal) { switch (_param){ case a2c: (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->set_a2c(paramVal); break; case a2g: (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->set_a2g(paramVal); break; case a2t: (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->set_a2t(paramVal); break; case c2g: (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->set_c2g(paramVal); break; case c2t: (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->set_c2t(paramVal); break; case g2t: (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->set_g2t(paramVal); break; default: errorMsg::reportError("Missing GTR parameter in C_evalGTRParam::operator ()"); break; } MDOUBLE res = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,_sp,_weights); LOG(5,<<" with " + int2string(_param) + " = "< tmpScVec; tmpScVec.push_back(_sc); vector tmpSpVec; tmpSpVec.push_back(_sp); multipleStochasticProcess * tmpMsp = new multipleStochasticProcess(); tmpMsp->setSpVec(tmpSpVec); Vdouble likeVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(_et,tmpScVec,tmpMsp,_pProportionDist); MDOUBLE res = likeVec[0]; delete(tmpMsp); LOG(5,<<" with " + int2string(_param) + " = "< class tamura92 : public replacementModel { public: explicit tamura92(const MDOUBLE theta, const MDOUBLE TrTv); virtual replacementModel* clone() const { return new tamura92 (*this); } const int alphabetSize() const {return 4;} inline void changeTrTv(const MDOUBLE TrTv) { _TrTv = TrTv; } void changeTheta(const MDOUBLE theta); MDOUBLE getTrTv() const {return _TrTv;} MDOUBLE getTheta() const {return _theta;} const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const; const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const; const MDOUBLE freq(const int i) const {return _freq[i];}; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const; const MDOUBLE dPij_tdBeta(const int i, const int j, const MDOUBLE t) const; private: Vdouble _freq; MDOUBLE _theta; MDOUBLE _TrTv; }; #endif rate4site-3.0.0/src/phylogeny/bestHKYparam.h0000644011611301161130000001265712223673415015667 00000000000000// $Id: bestHKYparam.h 9992 2011-11-08 03:57:29Z rubi $ #ifndef ___BEST_HKY_PARAM #define ___BEST_HKY_PARAM #include "definitions.h" #include "likelihoodComputation.h" #include "sequenceContainer.h" #include "stochasticProcess.h" #include "gammaDistribution.h" #include "tree.h" #include "hky.h" #include "multipleStochasticProcess.h" class bestHkyParamFixedTree { public: explicit bestHkyParamFixedTree(const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const MDOUBLE upperBoundOnHkyParam = 0.5, const MDOUBLE epsilonHkyParamOptimization = 0.01); MDOUBLE getBestHkyParam() {return _bestHkyParam;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestHkyParam; MDOUBLE _bestL; }; class bestHkyParamAndBBL { public: explicit bestHkyParamAndBBL(tree& et, //find Best HkyParam and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const MDOUBLE upperBoundOnHkyParam = 5.0, const MDOUBLE epsilonHkyParamOptimization= 0.01, const MDOUBLE epsilonLikelihoodImprovment= 0.05, const int maxBBLIterations=10, const int maxTotalIterations=5); MDOUBLE getBestHkyParam() {return _bestHkyParam;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestHkyParam; MDOUBLE _bestL; }; class C_evalHkyParam{ public: C_evalHkyParam( const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights = NULL) : _et(et),_sc(sc),_weights(weights),_sp(sp){}; private: const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; public: MDOUBLE operator() (MDOUBLE HkyParam) { (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(HkyParam); MDOUBLE res = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,_sp,_weights); //LOG(5,<<" with HkyParam = "< class hky : public replacementModel { public: explicit hky(const MDOUBLE inProb_a, const MDOUBLE inProb_c, const MDOUBLE inProb_g, const MDOUBLE inProb_t, const MDOUBLE TrTv); explicit hky(vector inProbs, const MDOUBLE TrTv); virtual replacementModel* clone() const { return new hky(*this); } // virtual nucJC* clone() const { return new nucJC(*this); } // see note down: const int alphabetSize() const {return 4;} void changeTrTv(const MDOUBLE In_TrTv); MDOUBLE getTrTv() const; const MDOUBLE Pij_t(const int i,const int j, const MDOUBLE d) const; const MDOUBLE dPij_dt(const int i,const int j, const MDOUBLE d) const; const MDOUBLE freq(const int i) const {return _freq[i];}; const MDOUBLE d2Pij_dt2(const int i,const int j, const MDOUBLE d) const; const MDOUBLE dPij_tdBeta(const int i, const int j, const MDOUBLE t) const; private: void initParams(MDOUBLE TrTv); // init _a, _b, _c, and _y by using _freq and TrTv private: Vdouble _freq; MDOUBLE _a; // MDOUBLE _b; // MDOUBLE _c,_y; // relationship between probA, probC, prob G, prob T. }; #endif rate4site-3.0.0/src/phylogeny/bestTamura92param.h0000644011611301161130000001761612223673415016640 00000000000000// $Id: bestTamura92param.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___BEST_TAMURA92_PARAM #define ___BEST_TAMURA92_PARAM #include "definitions.h" #include "likelihoodComputation.h" #include "sequenceContainer.h" #include "stochasticProcess.h" #include "multipleStochasticProcess.h" #include "gammaDistribution.h" #include "tree.h" #include "tamura92.h" class bestTamura92ParamFixedTree { public: explicit bestTamura92ParamFixedTree(const tree& et, // find best TrTv and theta const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const int maxTotalIterations = 5, const MDOUBLE epsilonLikelihoodImprovment = 0.05, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization = 0.01, const MDOUBLE epsilonLoglikelihoodForThetaOptimization = 0.01, const MDOUBLE upperBoundOnTrTv = 5.0); MDOUBLE getBestTrTv() {return _bestTrTv;} MDOUBLE getBestTheta() {return _bestTheta;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestTrTv; MDOUBLE _bestTheta; MDOUBLE _bestL; }; class bestTamura92ParamAndBBL{ public: explicit bestTamura92ParamAndBBL(tree& et, //find best TrTv, theta and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const int maxTotalIterations=5, const MDOUBLE epsilonLikelihoodImprovment=0.05, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization=0.01, const MDOUBLE epsilonLoglikelihoodForThetaOptimization=0.01, const MDOUBLE epsilonLoglikelihoodForBBL=0.01, const MDOUBLE upperBoundOnTrTv=5.0, const int maxBBLIterations=10); MDOUBLE getBestTrTv() {return _bestTrTv;} MDOUBLE getBestTheta(int spIndex) {return _bestTheta;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestTrTv; MDOUBLE _bestTheta; MDOUBLE _bestL; }; class bestTamura92ParamAlphaAndBBL { public: explicit bestTamura92ParamAlphaAndBBL( //find best TrTv, theta, Alpha and best branch lengths tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights=NULL, const int maxTotalIterations=5, const MDOUBLE epsilonLikelihoodImprovment= 0.05, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForThetaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.01, const MDOUBLE upperBoundOnTrTv = 5.0, const int maxBBLIterations=10, const MDOUBLE initAlpha = 1.5, const MDOUBLE upperBoundOnAlpha = 5.0); MDOUBLE getBestTrTv() {return _bestTrTv;} MDOUBLE getBestTheta() {return _bestTheta;} MDOUBLE getBestAlpha() {return _bestAlpha;} MDOUBLE getBestL() {return _bestL;} private: MDOUBLE _bestTrTv; MDOUBLE _bestTheta; MDOUBLE _bestAlpha; MDOUBLE _bestL; }; class bestTamura92ParamAlphaAndBBLProportional { public: explicit bestTamura92ParamAlphaAndBBLProportional( //find best TrTv, theta, loca Alpha for each gene, global Alpha and best branch lengths tree& et, vector& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalAlphas, Vdouble initLocalKappas, Vdouble initLocalThetas, const MDOUBLE upperBoundOnLocalAlpha, const MDOUBLE initGlobalAlpha, const MDOUBLE upperBoundOnGlobalAlpha, const MDOUBLE upperBoundOnTrTv, const int maxTotalIterations, const int maxBBLIterations, const bool optimizeSelectedBranches=false, const bool optimizeTree = true, const string branchLengthOptimizationMethod="bblLS", const bool optimizeLocalParams = true, const bool optimizeGlobalAlpha = true, const Vdouble * weights=NULL, const MDOUBLE epsilonLikelihoodImprovment= 0.05, const MDOUBLE epsilonLoglikelihoodForLocalTrTvOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForLocalThetaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForLocalAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForGlobalAlphaOptimization= 0.01, const MDOUBLE epsilonLoglikelihoodForBBL= 0.01); MDOUBLE getBestTrTv(int spIndex) {return _bestTrTvVec[spIndex];} MDOUBLE getBestTheta(int spIndex) {return _bestThetaVec[spIndex];} MDOUBLE getBestLocalAlpha(int spIndex) {return _bestLocalAlphaVec[spIndex];} MDOUBLE getBestGlobalAlpha() {return _bestGlobalAlpha;} Vdouble getBestL() {return _bestLvec;} private: Vdouble _bestTrTvVec; Vdouble _bestThetaVec; Vdouble _bestLocalAlphaVec; MDOUBLE _bestGlobalAlpha; Vdouble _bestLvec; }; class C_evalTrTvParam{ public: C_evalTrTvParam( const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights = NULL) : _et(et),_sc(sc),_weights(weights),_sp(sp){}; private: const tree& _et; const sequenceContainer& _sc; const Vdouble * _weights; stochasticProcess& _sp; public: MDOUBLE operator() (MDOUBLE TrTv) { (static_cast(_sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(TrTv); MDOUBLE res = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,_sp,_weights); LOG(5,<<" with TrTv = "< #include #include class RandintTal { unsigned long randx; public: RandintTal(long s=0) {randx=s;} void seedTal(long s) {randx=s;} int absTal(int x) {return x&0x7fffffff;} static MDOUBLE maxTal() {return 2147483648.0;} int drawTal() {return randx = randx*1103515245+12345;} MDOUBLE fdrawTal() {return absTal(drawTal())/maxTal();} //random number between zero and 1 }; class talRandom { public: // note the number you get is between 0 and entry not including entry! static MDOUBLE giveRandomNumberBetweenZeroAndEntry(MDOUBLE entry) { MDOUBLE tm=r.fdrawTal(); return (tm * entry); } static bool flipCoin() { return ((talRandom::giveRandomNumberBetweenZeroAndEntry(1.0)-0.5)>0); } // note the number you get is between 0 and entry not including entry! static int giveIntRandomNumberBetweenZeroAndEntry(int entry) { return (int)(giveRandomNumberBetweenZeroAndEntry(entry)); } static void setSeed(const unsigned long seed) { r.seedTal(seed); } static const MDOUBLE rand_gaussian(const MDOUBLE mean, const MDOUBLE variance) { const int N=100; static MDOUBLE X; X=0.0-N/2; /* set mean to 0 */ for (int ri = 0;ri< N;ri++){ // X += 1.0*rand()/RAND_MAX; X += giveRandomNumberBetweenZeroAndEntry(1.0); } /* for uniform randoms in [0,1], mu = 0.5 and var = 1/12 */ /* adjust X so mu = 0 and var = 1 */ // X = X * sqrt(12 / N); /* adjust variance to 1 */ // cout < 0.0); if( dblAlpha < 1.0 ) return DblGammaLessThanOne(dblAlpha); else if( dblAlpha > 1.0 ) return DblGammaGreaterThanOne(dblAlpha); return -log(giveRandomNumberBetweenZeroAndEntry(1.0)); } static MDOUBLE DblGammaGreaterThanOne(MDOUBLE dblAlpha); static MDOUBLE DblGammaLessThanOne(MDOUBLE dblAlpha); }; #endif rate4site-3.0.0/src/phylogeny/computeSubstitutionCounts.h0000644011611301161130000000603512223673415020633 00000000000000#ifndef ___COMPUTE_SUBSTITUTION_COUNTS #define ___COMPUTE_SUBSTITUTION_COUNTS #include "definitions.h" #include "replacementModel.h" #include "sequenceContainer.h" #include "tree.h" #include class multipleStochasticProcess; class computeSubstitutionCounts{ public: explicit computeSubstitutionCounts(const sequenceContainer& sc, const tree& tr, multipleStochasticProcess* MultSpPtr, string& outDir, VVVdouble& LpostPerSpPerCat, const int simulationsIterNum=1000, const MDOUBLE probCutOffSum=0.5, bool isSilent=false);//DEBUG: Change simulationsIterNum back to 10000 computeSubstitutionCounts(const computeSubstitutionCounts& other) {*this = other;} computeSubstitutionCounts& operator=(const computeSubstitutionCounts &other); virtual ~computeSubstitutionCounts() {} void run(); void computePosteriorOfChangeGivenTerminalsPerSpPerCat(); void printProbExp(); void printProbabilityPerPosPerBranch(); void printProbExpPerPosPerBranch(MDOUBLE probCutOff =0.5,MDOUBLE countsCutOff= 0.2); void printExpectationPerBranch(); void printTreesWithExpectationValuesAsBP(int from,int to); void printTreesWithProbabilityValuesAsBP(int from,int to); void printProbabilityPerPosPerBranch(int pos, VVVdouble& probChanges, ostream& out, ostream& outCount); void printExpectationPerBranch(VVVdouble& expectChanges, ostream& out); void printProbExpPerPosPerBranch(int pos, MDOUBLE probCutOff, MDOUBLE countCutOff, VVVdouble& probChanges, VVVdouble& expChanges, ostream& out, ostream& outCount); map > > get_expMap_father2son() {return _expMap_father2son;}; map > > get_probMap_father2son() {return _probMap_father2son;}; VVVVdouble getExpChanges(){return _expChanges_PosNodeXY;}; // expChanges_PosNodeXY[pos][nodeID][x][y] VVVVdouble getProbChanges(){return _probChanges_PosNodeXY;}; // probChangesForBranch[pos][nodeID][x][y] VVVVdouble getJointProb(){return _jointProb_PosNodeXY;}; // _jointProb_PosNodeXY[pos][nodeID][x][y] protected: //members int _alphabetSize; const tree _tr; const sequenceContainer _sc; multipleStochasticProcess* _pMSp; sequence* _refSeq; // the reference sequence string _outDir; bool _isSilent; int _simulationsIterNum; MDOUBLE _probCutOffSum; VVdouble _LpostPerCat; // the posterior probability for each position for each rate category VVVdouble _LpostPerSpPerCat; // _LpostPerSpPerCat[sp][rateCat][pos] map > > _expMap_father2son; map > > _probMap_father2son; //VVVVdouble _posteriorsGivenTerminals; // posteriorsGivenTerminals[pos][nodeID][x][y] VVVVdouble _probChanges_PosNodeXY; // probChanges_PosNodeXY[pos][nodeID][fatherState][sonState] - after simulations VVVVdouble _expChanges_PosNodeXY; // expChanges_PosNodeXY[pos][nodeID][fatherState][sonState] - after simulations and postProb VVVVdouble _jointProb_PosNodeXY; // probJoint_PosNodeXY[pos][nodeID][fatherState][sonState] - after computePosteriorOfChangeGivenTerminals }; #endif rate4site-3.0.0/src/phylogeny/fromCountTableComponentToDistance.h0000644011611301161130000000216012223673416022107 00000000000000// $Id: fromCountTableComponentToDistance.h 4742 2008-08-19 17:40:56Z cohenofi $ #ifndef ___FROM_COUNT_TABLE_COMPONENT_TO_DISTANCE #define ___FROM_COUNT_TABLE_COMPONENT_TO_DISTANCE #include "definitions.h" #include "countTableComponent.h" #include "stochasticProcess.h" #include "unObservableData.h" static const MDOUBLE startingGuessForTreeBrLen = 0.029; class fromCountTableComponentToDistance { public: explicit fromCountTableComponentToDistance( const countTableComponentGam& ctc, const stochasticProcess &sp, const MDOUBLE toll, const MDOUBLE brLenIntialGuess, // =startingGuessForTreeBrLen unObservableData* unObservableData_p = NULL); // a class used to for presence/absence void computeDistance();// return the likelihood MDOUBLE getDistance() { return _distance;} // return the distance. MDOUBLE getLikeDistance() { return _likeDistance;} // return the distance. private: const stochasticProcess & _sp; const countTableComponentGam& _ctc; MDOUBLE _toll; MDOUBLE _distance; MDOUBLE _likeDistance; unObservableData* _unObservableData_p; int alphabetSize() {return _ctc.alphabetSize();} }; #endif rate4site-3.0.0/src/phylogeny/computeCounts.h0000644011611301161130000000604712223673415016201 00000000000000// $Id: computeCounts.h 9903 2011-10-11 20:16:28Z rubi $ // version 1.00 // last modified 3 Nov 2002 #ifndef ___COMPUTE_COUNTS #define ___COMPUTE_COUNTS #include "definitions.h" #include "countTableComponent.h" #include "sequenceContainer.h" #include "computePijComponent.h" #include "suffStatComponent.h" // things included for the function "fillCountTableComponentGam" #include "sequenceContainer.h" class computeCounts { public: explicit computeCounts() {}; void computeCountsNodeFatherNodeSonHomPos(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, const MDOUBLE weight, const doubleRep posProb, const tree::nodeP nodeSon, countTableComponentHom& _ctc, const MDOUBLE rateCategorProb = 1.0); //CODE_RED //Proportional rate implementation - old void computeCountsNodeFatherNodeSonHomPosProportionalEB(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, const MDOUBLE weight, const doubleRep posProb, const tree::nodeP nodeSon, countTableComponentHom& _ctc, const MDOUBLE globalLocalRateCategorProb = 1.0); //CODE_RED //Proportional rate implementation - new void computeCountsNodeFatherNodeSonHomPosProportionalEB(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, const MDOUBLE weight, const VdoubleRep posProbVec, const tree::nodeP nodeSon, countTableComponentHom& _ctc); void computeCountsNodeFatherNodeSonHomPos(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, const MDOUBLE weight, const doubleRep posProb, const tree::nodeP nodeSon, countTableComponentHom& _ctc, const MDOUBLE rateCategorProb, const int letterInRoot); void fillCountTableComponentGam(countTableComponentGam& ctcGam, const stochasticProcess& sp, const sequenceContainer& sc, const computePijGam& pij0, const suffStatGlobalGam& cup, const suffStatGlobalGam& cdown, const Vdouble * weights, tree::nodeP nodeSon, const VdoubleRep& posProbVec); void fillCountTableComponentGamSpecRateCategor(const int rateCategor, countTableComponentHom& ctcHom, const stochasticProcess& sp, const sequenceContainer& sc, const computePijHom& pi, const suffStatGlobalGam& cup, const suffStatGlobalGam& cdown, const Vdouble * weights, const VdoubleRep& posProbVec, //prob of the position with gamma tree::nodeP nodeSon); }; #endif rate4site-3.0.0/src/phylogeny/computeDownAlg.h0000644011611301161130000000270312223673416016255 00000000000000// $Id: computeDownAlg.h 3107 2007-12-27 12:38:05Z adist $ #ifndef ___COMPUTE_DOWN_ALG #define ___COMPUTE_DOWN_ALG #include "definitions.h" #include "tree.h" #include "suffStatComponent.h" #include "sequenceContainer.h" #include "computePijComponent.h" class computeDownAlg { public: void fillComputeDown(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalHomPos& ssc, const suffStatGlobalHomPos& cup); void fillComputeDown(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const suffStatGlobalHomPos& cup); void fillComputeDownSpecificRate(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const suffStatGlobalHomPos& cup, const MDOUBLE gRate); /** compute the down computation for a non-reversible model: each down computation is conditioned on the state at the root. This means that the vector field is of one additional dimension (the alphabet at the root) and hence the use of the suffStatGlobalGamPos (=vector) **/ void fillComputeDownNonReversible(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalGamPos& sscGivenRoot, const suffStatGlobalHomPos& cup); }; #endif rate4site-3.0.0/src/phylogeny/computeUpAlg.h0000644011611301161130000000363312223673416015735 00000000000000// $Id: computeUpAlg.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___COMPUTE_UP_ALG #define ___COMPUTE_UP_ALG #include "definitions.h" #include "tree.h" #include "suffStatComponent.h" #include "sequenceContainer.h" #include "computePijComponent.h" class computeUpAlg { public: void fillComputeUp(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalHomPos& ssc); void fillComputeUp(const tree& et, const sequenceContainer & sc, const computePijGam& pi, suffStatGlobalGam& ssc); /*void fillComputeUp(const tree& et, // not to be used at all. problematic in case of a gamma function. const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc);*/ /*void fillComputeUp(const tree& et, // not to be used, accept for debuging (very slow func.) const sequenceContainer& sc, const stochasticProcess& sp, suffStatGlobalGam& ssc);*/ void fillComputeUpSpecificGlobalRate(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const MDOUBLE gRate); // my attemp to add factors void fillComputeUpWithFactors(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalHomPos& ssc, vector& factors); void fillComputeUpWithFactors(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, vector& factors); void fillComputeUpSpecificGlobalRateFactors(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const MDOUBLE gRate, vector& factors); }; #endif rate4site-3.0.0/src/phylogeny/gammaUtilities.h0000644011611301161130000000450112223673416016301 00000000000000// $Id: gammaUtilities.h 10786 2012-06-13 17:05:21Z cohenofi $ #ifndef ___GAMMA_UTILITIES #define ___GAMMA_UTILITIES #include "definitions.h" #include "numRec.h" //fot the ITMAX /****************************************************************************** gamma utilities include calculating ln gamma and integral of gamma. used mainly in building the gamma function and creating categories within it ******************************************************************************/ //gammln(xx): computes the ln of the Gamma function //the Gamma function is the integral from 0 to infinity of (t^(xx-1)*e^(-t)) dt. MDOUBLE gammln(MDOUBLE xx); //gammp(a, x): computes the incomplete Gamma function which is: // 1/Gamma(a) * (the integral from 0 to x of (t^(a-1)*e^(-t)) dt) //gammp can be computed in two different ways: by a series representation (gser(..)) //or by a continued fraction representation (gcf(..)) //gammp chooses to function will be used, according to the values of a and x MDOUBLE gammp(MDOUBLE a, MDOUBLE x); void gser(MDOUBLE *gamser, MDOUBLE a, MDOUBLE x, MDOUBLE *gln); void gcf(MDOUBLE *gammcf, MDOUBLE a, MDOUBLE x, MDOUBLE *gln); MDOUBLE search_for_z_in_dis_with_any_beta(MDOUBLE alpha,MDOUBLE beta, MDOUBLE ahoson); MDOUBLE search_for_z_in_dis_with_beta_1(MDOUBLE alpha, MDOUBLE ahoson); MDOUBLE the_avarage_r_in_category_between_a_and_b(MDOUBLE a, MDOUBLE b, MDOUBLE alpha, MDOUBLE beta, int k); //const int ITMAX = 100; const MDOUBLE EPS = static_cast(0.0000003); const MDOUBLE FPMIN = static_cast(1.0e-30); const MDOUBLE ERR_FOR_GAMMA_CALC = static_cast(0.00001); const MDOUBLE MINIMUM_ALPHA_PARAM = static_cast(0.05); //was 0.05 const MDOUBLE MAXIMUM_ALPHA_PARAM = static_cast(20.0); //was 10.0, when the distribution is more 'gaussian' and uniform , need higher alpha const MDOUBLE MINIMUM_BETA_PARAM = static_cast(0.05); //was 0.05 const MDOUBLE MAXIMUM_BETA_PARAM = static_cast(20.0); // was 5.0, require high values for scaling //gammq(a, x) : computes 1 - the incomplete Gamma function (1-gammp(a,x)) which is: //1/Gamma(a) * (the integral from infinite to x of (t^(a-1)*e^(-t)) dt). //use for computing Chi-Square probability function (for the LRT): //chiSquareProb(df,chiSquare) = gammq(df/2.0,chiSquare/2.0) MDOUBLE gammq(MDOUBLE a, MDOUBLE x); #endif rate4site-3.0.0/src/phylogeny/seqContainerTreeMap.h0000644011611301161130000000221012223673415017226 00000000000000// $Id: seqContainerTreeMap.h 8985 2010-11-16 19:56:20Z cohenofi $ #ifndef ___SEQUENCE_CONTAINER_TREE_MAP #define ___SEQUENCE_CONTAINER_TREE_MAP #include "definitions.h" #include "tree.h" #include "treeIt.h" #include "sequenceContainer.h" void checkThatNamesInTreeAreSameAsNamesInSequenceContainer(const tree& et,const sequenceContainer & sc, bool bLeavesOnly = true); void intersectNamesInTreeAndSequenceContainer(tree& et,sequenceContainer & sc, bool bLeavesOnly= true); void getLeavesSequences(const sequenceContainer& sc, const tree& tr, sequenceContainer& sc_leaves); class seqContainerTreeMap { public: explicit seqContainerTreeMap(const sequenceContainer& sc, const tree& et) { checkThatNamesInTreeAreSameAsNamesInSequenceContainer(et,sc); _V.resize(et.getNodesNum()); treeIterTopDownConst tit(et); for (tree::nodeP myN = tit.first();myN!=tit.end(); myN = tit.next()) { if (myN->isInternal()) { _V[myN->id()] = -1; } else { _V[myN->id()] = sc.getId(myN->name(),false); } } } int seqIdOfNodeI(const int nodeID) { return _V[nodeID]; } private: vector _V;// _V[i] is the sequenceId of node I. }; #endif rate4site-3.0.0/src/phylogeny/treeUtil.h0000644011611301161130000000272512223673415015125 00000000000000// $Id: treeUtil.h 10476 2012-03-18 07:57:33Z itaymay $ #ifndef ___TREE_UTIL #define ___TREE_UTIL #include "definitions.h" #include "tree.h" vector getStartingTreeVecFromFile(string fileName); tree starTree(const vector& names); void getStartingTreeVecFromFile(string fileName, vector& vecT, vector& constraintsOfT0); vector getNexusTreesFromFile (const string& nexusTreesFile); bool sameTreeTolopogy(tree t1, tree t2); bool cutTreeToTwo(tree bigTree, const string& nameOfNodeToCut, tree &small1, tree &small2); tree::nodeP makeNodeBetweenTwoNodes( tree& et, tree::nodeP nodePTR1, tree::nodeP nodePTR2, const string &interName); void cutTreeToTwoSpecial(const tree& source, tree::nodeP intermediateNode, tree &resultT1PTR, tree &resultT2PTR); vector getSequencesNames(const tree& t); MDOUBLE getSumOfBranchLengths(const tree &t); void printDataOnTreeAsBPValues(ostream &out, Vstring &data, tree &tr) ; void printDataOnTreeAsBPValues(ostream &out, Vstring &data, const tree::nodeP &myNode) ; MDOUBLE getDistanceFromNode2ROOT(const tree::nodeP &myNode); void fillAllNodesNames(Vstring& Vnames,const tree& tr); void printTreeWithValuesAsBP(ostream &out, const tree &tr, Vstring values, VVVdouble *probs, int from, int to); void printTreeWithValuesAsBP(ostream &out, const tree::nodeP &myNode, Vstring values, VVVdouble *probs, int from, int to); #endif rate4site-3.0.0/src/phylogeny/matrixUtils.h0000644011611301161130000001100012223673417015641 00000000000000#ifndef ___MATRIX_UTIL_H #define ___MATRIX_UTIL_H #include "definitions.h" #include "logFile.h" #include "errorMsg.h" #include #include #include #include class sequenceContainer; using namespace std; void printMatrix(const VVdouble &mat, ostream &out); void printMatrix(const VVint &mat, ostream &out) ; void readMatrixFromFile(VVdouble &mat,string fileName); Vdouble getDiagonalFromMatrix(VVdouble &mat); Vdouble getSubDiagonalFromMatrix(VVdouble &mat); //get the first norm sum{abs(Mij)} MDOUBLE getMatrixNorm(const VVdouble &mat); // Same for vector of Matrices MDOUBLE getVMatrixNorm(const VVVdouble &mat); //get the specific coordinates sum from vector of Matrices MDOUBLE getVMatrixJK(const VVVdouble &mat, const int j, const int k); template void resizeMatrix(vector > &mat, int rows, int columns){ mat.resize(rows); for (int i=0; i void unitMatrix(vector > &m, int n){ resizeMatrix(m,n,n); for (int i=0; i void zeroMatrix(vector > &m){ for (int i=0; i < m.size(); i++) for (int j=0; j void oneMatrix(vector > &m){ for (int i=0; i < m.size(); i++) for (int j=0; j vector > multiplyMatrixes(vector > &mat1, vector > &mat2){ vector > mat; if ((mat1.size()==0) || (mat2.size() ==0)) errorMsg::reportError("Error in multiplyMatrixes, one of the matrices inputted is of size 0");; int numColumns=mat1[0].size(); int numRows = mat2.size(); resizeMatrix(mat,numColumns,numRows); for (int i=0; i vector > multiplyMatrixByScalar(const vector > &mat, MDOUBLE scalar) { vector > mat_copy = mat; for (int i=0; i vector > add(const vector > &mat1,const vector > &mat2){ if (mat1.size()!=mat2.size()) errorMsg::reportError("different sized matrices in matrixUtils::add"); vector > newMat(mat1.size()); for (int i=0;i void printVec(vector< _T> &vec,ostream &out=cout,bool printVertical=true) { for (int i=0; i &vec1, const vector &vec2); void appendVectors(Vint &vec1, const Vint &vec2); void appendVectors(VVdouble &vec1, const VVdouble &vec2); Vint complementBinaryVec(vector &bufferVec) ; // returns complementary binary vector void readDoubleVecFromFile(Vdouble &vec,string fileName); //reads a vertical vector (separated by \n) void normalize(Vdouble &vec); void scaleByAverage(Vdouble &vec); //solve nxn linear equations of the form Ax=b; return x; Vdouble solveLinearEquations(VVdouble A,Vdouble b); // functions from numerical recipes that solve nxn linear equations void lubksb(VVdouble &a, Vdouble &indx, Vdouble &b); void ludcmp(VVdouble &a, Vdouble &indx, MDOUBLE &d); void resize_VVVV(int dim1, int dim2, int dim3, int dim4, VVVVdouble& vetor); void resize_VVV(int dim1, int dim2, int dim3, VVVdouble& vetor); #endif rate4site-3.0.0/src/phylogeny/computePosteriorExpectationOfSubstitutions.h0000644011611301161130000000437312223673416024226 00000000000000 #ifndef ___COMPUTE_POSTERIOR_EXPECTATION_OF_SUBSTITUTIONS #define ___COMPUTE_POSTERIOR_EXPECTATION_OF_SUBSTITUTIONS /* This is a father class where it implements the computePosteriorExpectationOfSubstitutions procedure for a reversible stochastic process. Its son, computePosteriorExpectationOfSubstitutions_nonReversibleSp implements the computePosteriorExpectationOfSubstitutions for a non-reversible stochastic process. The implementation difference is in two functions: computePosteriorOfChangeGivenTerminals and computePosterioGivenTerminalsPerBranch */ #include "definitions.h" #include "simulateJumps.h" #include "tree.h" #include "sequenceContainer.h" #include "stochasticProcess.h" #include "suffStatComponent.h" #include "computePijComponent.h" #include "simulateJumpsAbstract.h" class computePosteriorExpectationOfSubstitutions { public: explicit computePosteriorExpectationOfSubstitutions(const tree &tr, const sequenceContainer &sc, const stochasticProcess *sp); virtual ~computePosteriorExpectationOfSubstitutions(){}; VVdouble computeExpectationAcrossTree(simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbs, VVVdouble &expForBranch); VVdouble computePosteriorAcrossTree(simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbsGivenTerminals,VVVdouble &probsForBranch); virtual void computePosteriorOfChangeGivenTerminals(VVVdouble &posteriorPerNodePer2States, int pos); private: MDOUBLE computePosteriorOfChangePerBranch( simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbs, tree::nodeP node, int fromState, int toState); MDOUBLE computeExpectationOfChangePerBranch( simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbsGivenTerminals, tree::nodeP node, int fromState, int toState); MDOUBLE computePosterioGivenTerminalsPerBranch (int nodeId,int sonState, int fatherState,suffStatGlobalHomPos &sscUp, suffStatGlobalHomPos &sscDown,computePijHom &pi, MDOUBLE &LLData, const string nodeName); protected: const tree &_tr; const sequenceContainer &_sc; const stochasticProcess *_sp; }; #endif rate4site-3.0.0/src/phylogeny/computePosteriorExpectationOfSubstitutions_nonReversibleSp.h0000644011611301161130000000167012223673416027423 00000000000000#ifndef ___COMPUTE_POSTERIOR_EXPECTATION_OF_SUBSTITUTIONS_NONREVERSIBLESP #define ___COMPUTE_POSTERIOR_EXPECTATION_OF_SUBSTITUTIONS_NONREVERSIBLESP #include "computePosteriorExpectationOfSubstitutions.h" class computePosteriorExpectationOfSubstitutions_nonReversibleSp:public computePosteriorExpectationOfSubstitutions { public: explicit computePosteriorExpectationOfSubstitutions_nonReversibleSp(const tree &tr, const sequenceContainer &sc, stochasticProcess *sp):computePosteriorExpectationOfSubstitutions(tr,sc,sp){} virtual ~computePosteriorExpectationOfSubstitutions_nonReversibleSp(){}; void computePosteriorOfChangeGivenTerminals(VVVdouble &posteriorPerNodePer2States, int pos); private: MDOUBLE computePosterioGivenTerminalsPerBranch (int nodeId,int sonState, int fatherState,suffStatGlobalHomPos &sscUp, suffStatGlobalGamPos &sscDown,computePijHom &pi, MDOUBLE &LLData, const string nodeName); }; #endif rate4site-3.0.0/src/phylogeny/multipleStochasticProcess.h0000644011611301161130000000113412223673416020541 00000000000000#ifndef _MULTIPLE_STOCHASTIC_PROCESS #define _MULTIPLE_STOCHASTIC_PROCESS #include "stochasticProcess.h" class multipleStochasticProcess { public: multipleStochasticProcess(); virtual ~multipleStochasticProcess(); virtual MDOUBLE getProb(int spPlace) const; virtual stochasticProcess* getSp(int spPlace); virtual int getSPVecSize() const {return _spVec.size();} virtual void setSpVec(vector& spVec); protected: virtual void copy(const multipleStochasticProcess * pOther); protected: vector _spVec; Vdouble _spProb; }; #endif rate4site-3.0.0/src/phylogeny/simulateJumps.h0000644011611301161130000000442212223673415016166 00000000000000#ifndef ___SIMULATE_JUMPS__ #define ___SIMULATE_JUMPS__ #include "simulateJumpsAbstract.h" using namespace std; /****************************************************************** This class implements simulateJumpsAbstract for small alphabets: (tested so far up to 3) *******************************************************************/ class simulateJumps:public simulateJumpsAbstract { public: simulateJumps(const tree& inTree, const stochasticProcess& sp, const int alphabetSize); virtual ~simulateJumps(); //for a branch length specified by a nodeName: //give the expected number of jumps (changes) from fromId to toId that occured along the specified branh length, //in which the starting character is terminalStart and the terminal character is terminalEnd MDOUBLE getExpectation(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId); //same as above, except here we return the probability of a jump from fromId to toId given //terminal states terminalStart, terminalEnd in this branch MDOUBLE getProb(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId); private: void init(); void runOneIter(int state); void computeExpectationsAndPosterior(); private: //_node2Jumps: maps a node name (which specify a branch length) to //the expected number of jumps between any two characters along the branch leading from the father to this node //given the terminal characters of this branch. //The matrix is 2D and not 4D because we use a "combined alphabet" to make access easier. see getCombinedState() for details //The first dimension is the combined terminal state and the second dimension is the combined jump state map _nodes2JumpsExp; //_node2JumpsProb: maps a node name (which specify a branch length) to //the probability of a jump between any two characters along the branch leading from the father to this node //given the terminal characters of this branch. //The matrix is 2D and not 4D because we use a "combined alphabet" to make access easier. see getCombinedState() for details //The first dimension is the combined terminal state and the second dimension is the combined jump state map _nodes2JumpsProb; }; #endif rate4site-3.0.0/src/phylogeny/simulateJumpsAbstract.h0000644011611301161130000000673212223673416017661 00000000000000#ifndef ___SIMULATE_JUMPS_ABSTRACT_ #define ___SIMULATE_JUMPS_ABSTRACT_ #include "definitions.h" #include "tree.h" #include "stochasticProcess.h" #include "alphabet.h" #include #include using namespace std; /****************************************************************** This is an abstract class to various implementations of simulateJumps. It was created to be a father class to the generic (original) implementation of simulateJumps class simulateJumps (working on alphabets of either 0,1,2 or 0,1 and class simulateCodonsJumps which is a variant simulateJumps that can handle the 61 sized alphabet without memory limitations. The simulateJumps algorithm simulates jumps (events) along differing branch lengths (according to a given tree), with the aim of giving the expectation of the number of jumps from state a to state b given that the terminal states at the end of the branch are x and y. *******************************************************************/ class simulateJumpsAbstract { public: simulateJumpsAbstract(const tree& inTree, const stochasticProcess& sp, const int alphabetSize); virtual ~simulateJumpsAbstract(){} virtual void runSimulation(int iterNum = 10000); //for a branch length specified by a nodeName: //give the expected number of jumps (changes) from fromId to toId that occured along the specified branh length, //in which the starting character is terminalStart and the terminal character is terminalEnd virtual MDOUBLE getExpectation(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId) = 0; //same as above, except here we return the probability of a jump from fromId to toId given //terminal states terminalStart, terminalEnd in this branch virtual MDOUBLE getProb(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId) = 0; virtual int getTotalTerminal(const string& nodeName, int terminalStart, int terminalEnd){ map::iterator iterTerm = _totalTerminals.find(nodeName); return (int)iterTerm->second[getCombinedState(terminalStart,terminalEnd)]; } protected: virtual int getCombinedState(int terminalStart, int terminalEnd) const; virtual int getCombinedAlphabetSize() const {return _alphabetSize*_alphabetSize;} virtual int getStartId(int combinedState) const; virtual int getEndId(int combinedState) const; virtual void init() = 0; virtual void runOneIter(int state) = 0; virtual void computeExpectationsAndPosterior() = 0; // a comparison function to be used in sort init static bool compareDist(tree::nodeP node1, tree::nodeP node2){ return (node1->dis2father() < node2->dis2father());} protected: tree _tree; stochasticProcess _sp; const int _alphabetSize; Vdouble _waitingTimeParams;//each entry is the lambda parameter of the exponential distribution modeling the waiting time for "getting out" of state i //_jumpProbs[i][j] is the probability of jumping from state i to state j (given that a change has ocured). VVdouble _jumpProbs; //the number of times we reached a certain combination of terminal states for each branch lengths //e.g. the number of times we observed 0,1 at terminal states given branch length 0.03 //this is used to to afterwards normalize (i.e. compute the expectation) the _nodes2JumpsExp values map _totalTerminals; vector _orderNodesVec; //internal use: the branch are sorted in ascending order }; #endif rate4site-3.0.0/src/phylogeny/simulateCodonsJumps.h0000644011611301161130000000517112223673415017336 00000000000000#ifndef ___SIMULATE_CODONS_JUMPS__ #define ___SIMULATE_CODONS_JUMPS__ #include "simulateJumpsAbstract.h" #include "codon.h" using namespace std; /****************************************************************** This class implements simulateJumpsAbstract for small alphabets: (tested so far up to 3) *******************************************************************/ class simulateCodonsJumps:public simulateJumpsAbstract { public: simulateCodonsJumps(const tree& inTree, const stochasticProcess& sp, const int alphabetSize); virtual ~simulateCodonsJumps(); //for a branch length specified by a nodeName: //give the expected number of jumps (changes) from fromId to toId that occured along the specified branh length, //in which the starting character is terminalStart and the terminal character is terminalEnd MDOUBLE getExpectation(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId); MDOUBLE getExpectation(const string& nodeName, int terminalStart, int terminalEnd, codonUtility::replacementType substitutionType); //same as above, except here we return the probability of a jump from fromId to toId given //terminal states terminalStart, terminalEnd in this branch MDOUBLE getProb(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId); MDOUBLE getProb(const string& nodeName, int terminalStart, int terminalEnd, codonUtility::replacementType substitutionType); private: void init(); void runOneIter(int state); void computeExpectationsAndPosterior(); private: //_node2Jumps: maps a node name (which specify a branch length) to //the expected number of synonymous and nonsynonymous jumps between any two characters along the branch leading from the father to this node //given the terminal characters of this branch. //We use a "combined alphabet" to make access easier. see getCombinedState() for details //The dimension of the vector is the combined terminal state and the pair elements are: synonymous and non-synonymous jumps, respectively. map > > _nodes2JumpsExp; //_node2JumpsProb: maps a node name (which specify a branch length) to //the probability of a synonymous and non-synonymous jump between any two characters along the branch leading from the father to this node //given the terminal characters of this branch. //We use a "combined alphabet" to make access easier. see getCombinedState() for details //The dimension of the vector is the combined terminal state and the pair elements are: synonymous and non-synonymous jumps, respectively map > > _nodes2JumpsProb; }; #endif rate4site-3.0.0/src/phylogeny/treeIt.h0000644011611301161130000000661312223673416014565 00000000000000// $Id: treeIt.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___TREE_IT #define ___TREE_IT #include "definitions.h" #include "errorMsg.h" #include "tree.h" class treeIterTopDown{ public: treeIterTopDown(tree& t) : _t(t) , _current(_t.getRoot()) { _childCheck.push_back(0); } tree::nodeP first() { _childCheck.clear(); _childCheck.push_back(0); _current = _t.getRoot(); return _t.getRoot(); } tree::nodeP next() { if (_childCheck.empty()) return NULL; if (_childCheck[_childCheck.size()-1]<_current->getNumberOfSons()) { _current = _current->getSon(_childCheck[_childCheck.size()-1]); _childCheck[_childCheck.size()-1]++; _childCheck.push_back(0); } else { _current = _current->father(); _childCheck.pop_back(); return next(); } return _current; } tree::nodeP operator++(int) {return next();} tree::nodeP operator++() {return next();} tree::nodeP end(){ return NULL;} tree::nodeP operator-> (){ return _current;} tree::TreeNode& operator* (){return *_current;} bool operator!= (tree::nodeP t) {return (t != this->_current);} private: vector _childCheck; tree& _t; tree::nodeP _current; }; class treeIterTopDownConst{ public: treeIterTopDownConst(const tree& t) : _t(t) , _current(_t.getRoot()) { _childCheck.push_back(0); } tree::nodeP first() { _childCheck.clear(); _childCheck.push_back(0); _current = _t.getRoot(); return _t.getRoot(); } tree::nodeP next() { if (_childCheck.empty()) return NULL; if (_childCheck[_childCheck.size()-1]<_current->getNumberOfSons()) { _current = _current->getSon(_childCheck[_childCheck.size()-1]); _childCheck[_childCheck.size()-1]++; _childCheck.push_back(0); } else { _current = _current->father(); _childCheck.pop_back(); return next(); } return _current; } tree::nodeP operator++(int) {return next();} tree::nodeP operator++() {return next();} tree::nodeP end(){ return NULL;} tree::nodeP operator-> (){ return _current;} tree::TreeNode& operator* (){return *_current;} bool operator!= (tree::nodeP t) {return (t != this->_current);} private: vector _childCheck; const tree& _t; tree::nodeP _current; }; class treeIterDownTopConst{ public: treeIterDownTopConst(const tree& t) : _t(t) , _current(_t.getRoot()) { _childCheck.push_back(0); } const tree::nodeP first() { _childCheck.clear(); _childCheck.push_back(0); _current = _t.getRoot(); return next(); } const tree::nodeP next() { if (_childCheck[_childCheck.size()-1]>_current->getNumberOfSons()) {//checked _current = _current->father(); if (!_current) return NULL; _childCheck.pop_back(); _childCheck[_childCheck.size()-1]++; return next(); } else if (_childCheck[_childCheck.size()-1]<_current->getNumberOfSons()) { _current = _current->getSon(_childCheck[_childCheck.size()-1]); _childCheck.push_back(0); return next(); } // else //if (_childCheck[_childCheck.size()-1]==_current->getNumberOfSons()) // { _childCheck[_childCheck.size()-1]++; return _current; // } // return next(); } const tree::nodeP operator++(int) {return next();} const tree::nodeP operator++() {return next();} const tree::nodeP end(){ return NULL;} const tree::nodeP operator-> (){ return _current;} const tree::TreeNode& operator* (){return *_current;} bool operator!= (tree::nodeP t) {return (t != this->_current);} private: vector _childCheck; const tree& _t; tree::nodeP _current; }; #endif rate4site-3.0.0/src/phylogeny/likelihoodComputationGL.h0000644011611301161130000000752712223673416020127 00000000000000#ifndef ___LIKELIHOOD_COMPUTATION_GL #define ___LIKELIHOOD_COMPUTATION_GL #include "definitions.h" #include "computePijComponent.h" #include "sequenceContainer.h" #include "suffStatComponent.h" #include "unObservableData.h" #include "computeUpAlg.h" namespace likelihoodComputationGL { MDOUBLE getTreeLikelihoodAllPosAlphTheSame(const tree& tr, const sequenceContainer& sc, const vector >& spVVec, const distribution * distGain, const distribution * distLoss, const Vdouble * const weights, unObservableData *unObservableData_p =NULL); void fillPijAndUp(const tree& tr, const sequenceContainer& sc, const vector >& spVVec, const distribution * distGain, const distribution * distLoss, vector& pi_vec, vector& ssc_vec, vector& cup_vec); MDOUBLE getProbOfPosUpIsFilledSelectionGam(const int pos,const tree& tr, const sequenceContainer& sc, const vector >& spVVec, // only needed for sp.freq(let) const suffStatGlobalGamPos& cup, const distribution * distGain, const distribution * distLoss); MDOUBLE getTreeLikelihoodFromUp2(const tree& tr, const sequenceContainer& sc, const vector >& spVVec,// only needed for sp.freq(let) const suffStatGlobalGam& cup, const distribution * distGain, const distribution * distLoss, const Vdouble * weights, unObservableData *unObservableData_p, Vdouble* posLike =NULL); MDOUBLE getTreeLikelihoodFromUp2(const tree& tr, const sequenceContainer& sc, const vector >& spVVec,// only needed for sp.freq(let) const vector& cup_vec, const distribution * distGain, const distribution * distLoss, const Vdouble * weights, unObservableData *unObservableData_p, Vdouble* posLike =NULL); // Error //MDOUBLE getTreeLikelihoodAllPosAlphTheSameNoComputeUp(const tree& tr, // const sequenceContainer& sc, // const vector >& spVVec, // const distribution * distGain, const distribution * distLoss, // unObservableData *unObservableData_p); ///******************************************************************************************** //un-obervable data //*********************************************************************************************/ //// used to fill the likelihood for the unobservable for each category // doubleRep getLofPos(const int pos, // const tree& tr, // const sequenceContainer& sc, // const computePijGam& pi, // const stochasticProcess& sp, // Vdouble& likePerCat); // all the likdelhoodsPerCat and rateProb are filled //// likelihood computation - full data (1) // MDOUBLE getTreeLikelihoodAllPosAlphTheSame(const tree& tr, // const sequenceContainer& sc, // const stochasticProcess& sp, // const Vdouble * const weights, // Vdouble *pLforMissingDataPerCat=NULL); //// likelihood computation - per pos (1.1) // doubleRep getLofPos(const int pos, // this function is used // const tree& tr, // when gamma, and the br-len // const sequenceContainer& sc, // are the same for all pos. // const computePijGam& pi, // const stochasticProcess& sp, // Vdouble *pLforMissingDataPerCat=NULL); //// likelihood computation - per pos, per cat (1.1.1) // doubleRep getLofPos(const int pos, // this function is used // const tree& tr, // when the br-len // const sequenceContainer& sc, // are the same for all // const computePijHom& pi, // positions. // const stochasticProcess& sp); // // Vdouble getLofPosPerCat(const int pos, // used when the likelihood given each category is needed, not only the sum // const tree& tr, // const sequenceContainer& sc, // const computePijGam& pi, // const stochasticProcess& sp); }; #endif rate4site-3.0.0/src/phylogeny/tree.h0000644011611301161130000002230512223673416014264 00000000000000// $Id: tree.h 9777 2011-08-08 20:09:42Z rubi $ #ifndef ___TREE #define ___TREE #include "definitions.h" #include "readTree.h" #include "errorMsg.h" #include "logFile.h" //*********************************************************************************** // class tree represents only the topology. It has no MSA and assumes no model of evolution. //*********************************************************************************** class tree { public: static const MDOUBLE FLAT_LENGTH_VALUE;// = 0.3; static const int TREE_NULL;// = -1; static const MDOUBLE SHORT_LENGTH_VALUE;// = 0.000001f; //---------------------------- TREE NODE ---------------------- public: class TreeNode { public: explicit TreeNode(const int id) :_sons(0),_father(NULL),_id(id),_name( (string)"" ),_dis2father(TREE_NULL),_comment((string)"") {} const int id() const {return _id;} const string name() const {return _name;} const MDOUBLE dis2father() const {return _dis2father;} MDOUBLE getDistance2ROOT(); MDOUBLE getMinimalDistance2OTU(); int getMinimalNumOfNodes2OTU(); TreeNode* father() {return _father;} void setName(const string &inS) {_name = inS;} void setID(const int inID) {_id = inID;} void setDisToFather(const MDOUBLE dis) {_dis2father = dis;} void setFather(TreeNode* tn){_father=tn;} int getNumberOfSons() const {return _sons.size();} TreeNode* getSon (int i) {return _sons[i];} TreeNode* getLastSon () {return _sons.back();} void removeLastSon() {_sons.pop_back();} void removeSon(TreeNode* pSon); //setSon: updates only the father pointer to the son! void setSon(TreeNode* pSon) {_sons.push_back(pSon);} void setSon(TreeNode* pSon, int i) {_sons[i]=pSon;} // this will overwrite previous pointer! bool isRoot() const {return (_father == NULL);} bool isLeaf() const { return ( (getNumberOfSons() ==0) || (isRoot() && (getNumberOfSons() ==1)) ) ; } bool isInternal() const {return (!isLeaf());} //claimSons: sets the _father pointer of all sons to (this) //this function is used after setSon has been called without updating the son pointer. void claimSons(); void removeAllSons() {_sons.clear();} void copySons(TreeNode* other) {//copy the vector of nodeP only from one node to the other _sons=other->_sons; } void setComment(string comment) {_comment = comment; if (comment.length()) LOG(16,<<"comment for "<<_name<<" set to "< _sons; TreeNode* _father; int _id; string _name; MDOUBLE _dis2father; string _comment; friend class tree; }; //------------------------------------------------------------ public: //NEWICK is the standard format //ANCESTOR/ANCESTORID are for debugging purposes: output a list of nodes one for each line. //for each node print the name, dist2father and its sons. id are printed only in ANCESTORID. //PAML is like Newick format but with extra line: #of leaves space and #of trees typedef enum { PHYLIP, ANCESTOR, ANCESTORID, PAML } TREEformats; typedef TreeNode* nodeP; public: //******************************************************************************* // constructors //******************************************************************************* tree(); tree(const string& treeFileName); tree(istream &treeFile); tree(const vector& tree_contents); tree(const string& treeFileName,vector& isFixed); tree(const vector& tree_contents, vector& isFixed); tree(istream &in, vector& isFixed); tree(const tree &otherTree); tree& operator=(const tree &otherTree); virtual ~tree() {clear();}; //******************************************************************************* // questions on the tree topology //******************************************************************************* nodeP getRoot() const {return _root;}; inline int getLeavesNum() const; inline int getNodesNum() const; inline int getInternalNodesNum() const; //findNodeByName: searches the subtree of myNode for a node with a specified name. //if myNode==NULL: the search starts from the root nodeP findNodeByName(const string inName, nodeP myNode=NULL) const; nodeP findNodeById(const int inId, nodeP myNode=NULL) const; bool withBranchLength() const; //getNeigboursOfNode: stores into neighbourVec the father and sons of myNode void getNeigboursOfNode(vector &neighbourVec, const nodeP myNode) const; void getTreeDistanceTableAndNames(VVdouble& disTab, vector & vNames) const; MDOUBLE findLengthBetweenAnyTwoNodes(const nodeP node1,const nodeP node2) const; //lengthBetweenNodes: find length between two neighbouring nodes only MDOUBLE lengthBetweenNodes(const nodeP i, const nodeP j) const; //check if the distances from the root to all leaves are equal up to the given tollerance bool isUltrametric(MDOUBLE tol, bool bErrorIfNot) const; void getPathBetweenAnyTwoNodes(vector &path,const nodeP node1, const nodeP node2) const; void getFromLeavesToRoot(vector &vNeighbourVector) const; void getFromRootToLeaves(vector &vec) const; void getFromNodeToLeaves(vector &vec, const nodeP fromHereDown) const; void getAllHTUs(vector &vec,const nodeP fromHereDown) const ; void getAllNodes(vector &vec,const nodeP fromHereDown) const ; void getAllLeaves(vector &vec,const nodeP fromHereDown) const; //******************************************************************************* // change tree topoplogy parameters - should be applied carefully //******************************************************************************* //rootAt: sets newRoot as the root. updates the iterator order lists. void rootAt(const nodeP newRoot); void rootToUnrootedTree(); void multipleAllBranchesByFactor(const MDOUBLE InFactor); void create_names_to_internal_nodes(); void makeSureAllBranchesArePositive(); void makeSureAllBranchesAreLargerThanEpsilon(MDOUBLE epsilon); MDOUBLE getAllBranchesLengthSum(); // removeNodeFromSonListOfItsFather: // removes sonNode from its father according to the name of sonNode // this function should ONLY be used when sonNode is to be recycled soon! // because this function does not change the number of leaves nor the number of nodes! // nor does it change the father of sonNode. void removeNodeFromSonListOfItsFather(nodeP sonNode); void shrinkNode(nodeP nodePTR); //removeLeaf: removes nodePTR from tree. also deletes nodePTR void removeLeaf(nodeP nodePTR); //getAllBranches: returns two vectors such that nodesUp[i] is the father of nodesDown[i] void getAllBranches(vector &nodesUP, vector & nodesDown); //createRootNode: erase the current tree and create a tree with one node. void createRootNode(); nodeP createNode(nodeP fatherNode, const int id); void updateNumberofNodesANDleaves(); // ********************************************************** // initialization // ********************************************************** //createFlatLengthMatrix: sets the distance of all branches to newFlatDistance void createFlatLengthMatrix(const MDOUBLE newFlatDistance = FLAT_LENGTH_VALUE); //recursiveBuildTree: copy the information from other_nodePTR to a new node, and set the father to father_nodePTR //used by treeUtil nodeP recursiveBuildTree(tree::nodeP father_nodePTR,const tree::nodeP other_nodePTR); //******************************************************************************* // Input-Output //******************************************************************************* void output(string treeOutFile, TREEformats fmt= PHYLIP,bool withHTU=false) const; void output(ostream& os, TREEformats fmt= PHYLIP,bool withHTU=false) const; string stringTreeInPhylipTreeFormat(bool withHTU=false) const; private: void clear(); void outputInAncestorTreeFormat(ostream& treeOutStream, bool withDist = false) const; void outputInPhylipTreeFormat(ostream& treeOutStream,bool withHTU=false) const; void outputInAncestorIdTreeFormat(ostream& treeOutStream, bool withDist = false) const; void outputInPamlTreeFormat(ostream& treeOutStream, bool withHTU = false) const; int print_from(nodeP from_node, ostream& os, bool withHTU) const; int print_from(nodeP from_node, ostream& os, bool withHTU); int string_print_from(nodeP from_node, string& s, bool withHTU) const; bool readPhylipTreeTopology(istream& in,vector& isFixed); //same as the constructor with file name bool readPhylipTreeTopology(const vector& tree_contents,vector& isFixed); bool readPhylipTreeTopology(istream& in); //same as the constructor with file name bool readPhylipTreeTopology(const vector& tree_contents); nodeP readPart(vector::const_iterator& p_itCurrent, int& nextFreeID, vector & isFixed); void getAllHTUsPrivate(vector &vec,nodeP fromHereDown) const ; void getAllNodesPrivate(vector &vec,nodeP fromHereDown) const ; void getAllLeavesPrivate(vector &vec,nodeP fromHereDown) const; protected: TreeNode *_root; int _leaves; int _nodes; }; inline int tree::getLeavesNum() const {return _leaves;} inline int tree::getNodesNum() const {return _nodes;} inline int tree::getInternalNodesNum() const {return getNodesNum() - getLeavesNum();} ostream &operator<<(ostream &out, const tree &tr); #endif rate4site-3.0.0/src/phylogeny/bblEMProportionalEB.h0000644011611301161130000000441312223673416017126 00000000000000// $Id: bblEMProportional.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___BBL_EM_PROPORTIONALEB_H #define ___BBL_EM_PROPORTIONALEB_H #include "definitions.h" #include "tree.h" #include "stochasticProcess.h" #include "sequenceContainer.h" #include "multipleStochasticProcess.h" #include using namespace std; class bblEMProportionalEB { public: explicit bblEMProportionalEB(tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, const bool optimizeSelectedBranches=false, const vector * weights = NULL, const int maxIterations=50, const MDOUBLE epsilon=0.05, const MDOUBLE tollForPairwiseDist=0.0001, const MDOUBLE* likelihoodLast=NULL); Vdouble getTreeLikelihood() const {return _treeLikelihoodVec;} private: Vdouble compute_bblEMPropEB(const int maxIterations,const MDOUBLE epsilon,const MDOUBLE tollForPairwiseDist,const MDOUBLE* likelihoodLast=NULL); void allocatePlacePropEB(); void computeUpPropEB(); void bblEM_itPropEB(const MDOUBLE tollForPairwiseDist); void computeDownPropEB(const int gene, const int pos); void addCountsPropEB(const int gene, const int pos); void addCountsPropEB(const int gene,const int pos, tree::nodeP mynode, const VdoubleRep posProb, const MDOUBLE weig); void optimizeBranchesPropEB(const MDOUBLE tollForPairwiseDist); Vdouble _treeLikelihoodVec; tree& _et; const vector& _sc; multipleStochasticProcess* _msp; const gammaDistribution* _pProportionDist; const vector * _weights; int _numberOfGenes; vector< vector > _computeCountsV; // for each gene, for each node - a table of globalRate*localRate*alph*alph - [globalRateCategory][localRateCategory][character] vector _cup; //[gene][pos][globalRateCategory][localRateCategory][nodeID][character] vector _cdown; //[gene][globalRateCategory][localRateCategory][nodeID][character] vector< vector > _pij;//[gene][globalRateCategory] VVVdoubleRep _posLike;//[gene][pos][globalRateCategory] const bool _optimizeSelectedBranches; }; #endif rate4site-3.0.0/src/phylogeny/fromCountTableComponentToDistancePropEB.h0000644011611301161130000000234712223673415023165 00000000000000// $Id: fromCountTableComponentToDistanceProp.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___FROM_COUNT_TABLE_COMPONENT_TO_DISTANCE_PROP_EB #define ___FROM_COUNT_TABLE_COMPONENT_TO_DISTANCE_PROP_EB #include "definitions.h" #include "countTableComponent.h" #include "multipleStochasticProcess.h" #include "gammaDistribution.h" class fromCountTableComponentToDistancePropEB { public: explicit fromCountTableComponentToDistancePropEB( const vector< vector >& ctc, const int nodeID, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, const MDOUBLE toll, const MDOUBLE brLenIntialGuess = 0.029);// =startingGuessForTreeBrLen void computeDistance();// return the likelihood MDOUBLE getDistance() { return _distance;} // return the distance. MDOUBLE getLikeDistance() { return _likeDistance;} // return the distance. private: multipleStochasticProcess * _msp; const vector< vector >& _ctc; const gammaDistribution* _pProportionDist; const int _nodeID; MDOUBLE _toll; MDOUBLE _distance; MDOUBLE _likeDistance; int alphabetSize() {return (_ctc.empty()?0:_ctc[0][_nodeID].alphabetSize());} }; #endif rate4site-3.0.0/src/phylogeny/likeDistPropEB.h0000644011611301161130000001205012223673415016140 00000000000000// $Id: likeDistProp.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___LIKE_DIST_PROP_EB #define ___LIKE_DIST_PROP_EB #include "definitions.h" #include "countTableComponent.h" #include "multipleStochasticProcess.h" #include "gammaDistribution.h" #include "logFile.h" #include class likeDistPropEB { private: multipleStochasticProcess * _msp; const gammaDistribution* _pProportionDist; const MDOUBLE _maxPairwiseDistance; const MDOUBLE _minPairwiseDistance; const MDOUBLE _toll; public: const MDOUBLE giveDistance( const vector< vector >& ctc,const int nodeID, MDOUBLE& resL,const MDOUBLE initialGuess= 0.03) const; explicit likeDistPropEB(multipleStochasticProcess * msp, const gammaDistribution* pProportionDist, const MDOUBLE toll =0.0001, const MDOUBLE maxPairwiseDistance = 5.0, const MDOUBLE minPairwiseDistance = 0.0000001) : _msp(msp) ,_pProportionDist(pProportionDist), _maxPairwiseDistance(maxPairwiseDistance), _minPairwiseDistance(minPairwiseDistance),_toll(toll){ } likeDistPropEB(const likeDistPropEB & other) : _msp(other._msp),_pProportionDist(other._pProportionDist),_maxPairwiseDistance(other._maxPairwiseDistance),_minPairwiseDistance(other._minPairwiseDistance),_toll(other._toll){} virtual likeDistPropEB* clone() const {return new likeDistPropEB(*this);} }; class C_evallikeDistPropEB_d{ // derivative. public: C_evallikeDistPropEB_d(const vector< vector >& ctc, multipleStochasticProcess* msp,const gammaDistribution* pProportionDist,const int nodeID) : _ctc(ctc), _msp(msp), _pProportionDist(pProportionDist), _nodeID(nodeID) {}; private: const vector< vector >& _ctc; multipleStochasticProcess* _msp; const gammaDistribution* _pProportionDist; const int _nodeID; public: MDOUBLE operator() (MDOUBLE dist) { const MDOUBLE epsilonPIJ = 1e-10; MDOUBLE sumDL = 0.0; for (int gene=0; gene < _msp->getSPVecSize(); ++gene) { for (int alph1=0; alph1 < _ctc[gene][_nodeID].alphabetSize(); ++alph1){ for (int alph2=0; alph2 < _ctc[gene][_nodeID].alphabetSize(); ++alph2){ for(int globalRateCategor = 0;globalRateCategor < _pProportionDist->categories();++globalRateCategor){ _msp->getSp(gene)->setGlobalRate(_pProportionDist->rates(globalRateCategor)); MDOUBLE globalRate = _pProportionDist->rates(globalRateCategor); for (int localRateCategor = 0; localRateCategor < _msp->getSp(gene)->categories(); ++localRateCategor) { MDOUBLE localRate = _msp->getSp(gene)->rates(localRateCategor); MDOUBLE pij= _msp->getSp(gene)->Pij_t(alph1,alph2,dist*globalRate*localRate); if (pijgetSp(gene)->dPij_dt(alph1,alph2,dist*globalRate*localRate); //sumDL+= _ctc[gene][_nodeID].getCounts(alph1,alph2,globalRateCategor,localRateCategor)*dpij*_pProportionDist->ratesProb(globalRateCategor)*sp->ratesProb(localRateCategor) // *globalRate*localRate/pij; sumDL+= _ctc[gene][_nodeID].getCounts(alph1,alph2,globalRateCategor,localRateCategor)*dpij*globalRate*localRate/pij; } } } } } LOG(12,<<"check bl="< >& _ctc; multipleStochasticProcess* _msp; const gammaDistribution* _pProportionDist; const int _nodeID; public: C_evallikeDistPropEB(const vector< vector >& ctc, multipleStochasticProcess* msp,const gammaDistribution* pProportionDist,const int nodeID):_ctc(ctc), _msp(msp), _pProportionDist(pProportionDist), _nodeID(nodeID) {}; MDOUBLE operator() (MDOUBLE dist) { const MDOUBLE epsilonPIJ = 1e-10; MDOUBLE sumL = 0.0; for (int gene=0; gene < _msp->getSPVecSize(); ++gene) { for (int alph1=0; alph1 < _ctc[gene][_nodeID].alphabetSize(); ++alph1){ for (int alph2=0; alph2 < _ctc[gene][_nodeID].alphabetSize(); ++alph2){ for(int globalRateCategor = 0;globalRateCategor < _pProportionDist->categories();++globalRateCategor){ _msp->getSp(gene)->setGlobalRate(_pProportionDist->rates(globalRateCategor)); MDOUBLE globalRate = _pProportionDist->rates(globalRateCategor); for (int localRateCategor = 0; localRateCategor < _msp->getSp(gene)->categories(); ++localRateCategor) { MDOUBLE localRate = _msp->getSp(gene)->rates(localRateCategor); MDOUBLE pij= _msp->getSp(gene)->Pij_t(alph1,alph2,dist*globalRate*localRate); if (pijgetSp(gene)->freq(alph2)));//*_pProportionDist->ratesProb(globalRateCategor)*sp->ratesProb(localRateCategor); } } } } } LOG(8,<<"check bl="< using namespace std; #define MAX_BRANCH_LENGTH 10.0 /* This class optimize the branches using "naive" line search methodology. go over each branch and optimize it using brent. In one iteration it optimze seperatly all branches. This procedure continues until convergence is reached or until the maximum number of iteration is reached. */ class bblLSProportionalEB { public: explicit bblLSProportionalEB(tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, Vdouble& treeLikelihoodVec, const bool optimizeSelectedBranches=false, int maxIter=50, MDOUBLE epsilon=0.05); ~bblLSProportionalEB() {}; Vdouble getTreeLikelihoodVec() const {return _treeLikelihoodVec;} private: Vdouble optimizeBranches(tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, Vdouble& treeLikelihoodVec, const bool optimizeSelectedBranches=false, int maxIter=50, MDOUBLE epsilon=0.05); private: Vdouble _treeLikelihoodVec; }; class evalR4SPBranch{ public: explicit evalR4SPBranch(tree::nodeP pNode, tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist) :_pNode(pNode),_et(et), _sc(sc), _msp(msp), _pProportionDist(pProportionDist){}; private: tree::nodeP _pNode; tree& _et; const vector& _sc; multipleStochasticProcess* _msp; const gammaDistribution* _pProportionDist; public: MDOUBLE operator() (MDOUBLE bl) { _pNode->setDisToFather(bl); Vdouble likeVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(_et,_sc,_msp,_pProportionDist); MDOUBLE res = sumVdouble(likeVec); return -res; } }; #endif rate4site-3.0.0/src/phylogeny/phylipFormat.h0000644011611301161130000000324112223673415016000 00000000000000// $Id: phylipFormat.h 1812 2007-03-01 09:29:12Z adist $ #ifndef ___PHYLIP_FORMAT #define ___PHYLIP_FORMAT #include "definitions.h" #include "sequenceContainer.h" class phylipFormat { public: static sequenceContainer read(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd, const int numOfPositionInLine = 50, const int spaceEvery = 10); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); }; #endif /* EXAMPLE OF PHYLIP FORMAT (interleaved): 6 128 Langur KIFERCELAR TLKKLGLDGY KGVSLANWVC LAKWESGYNT EATNYNPGDE Baboon KIFERCELAR TLKRLGLDGY RGISLANWVC LAKWESDYNT QATNYNPGDQ Human KVFERCELAR TLKRLGMDGY RGISLANWMC LAKWESGYNT RATNYNAGDR Rat KTYERCEFAR TLKRNGMSGY YGVSLADWVC LAQHESNYNT QARNYDPGDQ Cow KVFERCELAR TLKKLGLDGY KGVSLANWLC LTKWESSYNT KATNYNPSSE Horse KVFSKCELAH KLKAQEMDGF GGYSLANWVC MAEYESNFNT RAFNGKNANG STDYGIFQIN SRYWCNNGKP GAVDACHISC SALLQNNIAD AVACAKRVVS STDYGIFQIN SHYWCNDGKP GAVNACHISC NALLQDNITD AVACAKRVVS STDYGIFQIN SRYWCNDGKP GAVNACHLSC SALLQDNIAD AVACAKRVVR STDYGIFQIN SRYWCNDGKP RAKNACGIPC SALLQDDITQ AIQCAKRVVR STDYGIFQIN SKWWCNDGKP NAVDGCHVSC SELMENDIAK AVACAKKIVS SSDYGLFQLN NKWWCKDNKR SSSNACNIMC SKLLDENIDD DISCAKRVVR DQGIRAWVAW RNHCQNKDVS QYVKGCGV DQGIRAWVAW RNHCQNRDVS QYVQGCGV DQGIRAWVAW RNRCQNRDVR QYVQGCGV DQGIRAWVAW QRHCKNRDLS GYIRNCGV EQGITAWVAW KSHCRDHDVS SYVEGCTL DKGMSAWKAW VKHCKDKDLS EYLASCNL */ rate4site-3.0.0/src/phylogeny/maseFormat.h0000644011611301161130000000262212223673415015422 00000000000000// $Id: maseFormat.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___MASE_FORMAT #define ___MASE_FORMAT #include "sequenceContainer.h" class maseFormat{ public: static sequenceContainer read(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); }; #endif /* EXAMPLE OF THE FORMAT: ;;this is the place for general remarks. ;here we put sequence specific remark. Langur KIFERCELARTLKKLGLDGYKGVSLANWVCLAKWESGYNTEATNYNPGDESTDYGIFQINSRYWCNNGKPGAVDACHISCSALLQNNIADAVACAKRVVSDQGIRAWVAWRNHCQNKDVSQYVKGCGV ; Baboon KIFERCELARTLKRLGLDGYRGISLANWVCLAKWESDYNTQATNYNPGDQSTDYGIFQINSHYWCNDGKPGAVNACHISCNALLQDNITDAVACAKRVVSDQGIRAWVAWRNHCQNRDVSQYVQGCGV ; Human KVFERCELARTLKRLGMDGYRGISLANWMCLAKWESGYNTRATNYNAGDRSTDYGIFQINSRYWCNDGKPGAVNACHLSCSALLQDNIADAVACAKRVVRDQGIRAWVAWRNRCQNRDVRQYVQGCGV ; Rat KTYERCEFARTLKRNGMSGYYGVSLADWVCLAQHESNYNTQARNYDPGDQSTDYGIFQINSRYWCNDGKPRAKNACGIPCSALLQDDITQAIQCAKRVVRDQGIRAWVAWQRHCKNRDLSGYIRNCGV ; Cow KVFERCELARTLKKLGLDGYKGVSLANWLCLTKWESSYNTKATNYNPSSESTDYGIFQINSKWWCNDGKPNAVDGCHVSCSELMENDIAKAVACAKKIVSEQGITAWVAWKSHCRDHDVSSYVEGCTL ; Horse KVFSKCELAHKLKAQEMDGFGGYSLANWVCMAEYESNFNTRAFNGKNANGSSDYGLFQLNNKWWCKDNKRSSSNACNIMCSKLLDENIDDDISCAKRVVRDKGMSAWKAWVKHCKDKDLSEYLASCNL */ rate4site-3.0.0/src/phylogeny/clustalFormat.h0000644011611301161130000000315612223673416016150 00000000000000// $Id: clustalFormat.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___CLUSTAL_FORMAT #define ___CLUSTAL_FORMAT #include "sequenceContainer.h" class clustalFormat{ public: static sequenceContainer read(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); }; #endif /* EXAMPLE OF THE FORMAT: CLUSTAL V Langur KIFERCELARTLKKLGLDGYKGVSLANWVCLAKWESGYNTEATNYNPGDESTDYGIFQIN Baboon KIFERCELARTLKRLGLDGYRGISLANWVCLAKWESDYNTQATNYNPGDQSTDYGIFQIN Human KVFERCELARTLKRLGMDGYRGISLANWMCLAKWESGYNTRATNYNAGDRSTDYGIFQIN Rat KTYERCEFARTLKRNGMSGYYGVSLADWVCLAQHESNYNTQARNYDPGDQSTDYGIFQIN Cow KVFERCELARTLKKLGLDGYKGVSLANWLCLTKWESSYNTKATNYNPSSESTDYGIFQIN Horse KVFSKCELAHKLKAQEMDGFGGYSLANWVCMAEYESNFNTRAFNGKNANGSSDYGLFQLN Langur SRYWCNNGKPGAVDACHISCSALLQNNIADAVACAKRVVSDQGIRAWVAWRNHCQNKDVS Baboon SHYWCNDGKPGAVNACHISCNALLQDNITDAVACAKRVVSDQGIRAWVAWRNHCQNRDVS Human SRYWCNDGKPGAVNACHLSCSALLQDNIADAVACAKRVVRDQGIRAWVAWRNRCQNRDVR Rat SRYWCNDGKPRAKNACGIPCSALLQDDITQAIQCAKRVVRDQGIRAWVAWQRHCKNRDLS Cow SKWWCNDGKPNAVDGCHVSCSELMENDIAKAVACAKKIVSEQGITAWVAWKSHCRDHDVS Horse NKWWCKDNKRSSSNACNIMCSKLLDENIDDDISCAKRVVRDKGMSAWKAWVKHCKDKDLS Langur QYVKGCGV Baboon QYVQGCGV Human QYVQGCGV Rat GYIRNCGV Cow SYVEGCTL Horse EYLASCNL */ rate4site-3.0.0/src/phylogeny/fastaFormat.h0000644011611301161130000000250312223673415015571 00000000000000// $Id: fastaFormat.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___FASTA_FORMAT #define ___FASTA_FORMAT #include "sequenceContainer.h" class fastaFormat{ public: static sequenceContainer read(istream &infile, const alphabet* alph); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd); }; #endif /* EXAMPLE OF FASTA FORMAT: >Langur KIFERCELARTLKKLGLDGYKGVSLANWVCLAKWESGYNTEATNYNPGDESTDYGIFQINSRYWCNNGKPGAVDACHISCSALLQNNIADAVACAKRVVSDQGIRAWVAWRNHCQNKDVSQYVKGCGV >Baboon KIFERCELARTLKRLGLDGYRGISLANWVCLAKWESDYNTQATNYNPGDQSTDYGIFQINSHYWCNDGKPGAVNACHISCNALLQDNITDAVACAKRVVSDQGIRAWVAWRNHCQNRDVSQYVQGCGV >Human KVFERCELARTLKRLGMDGYRGISLANWMCLAKWESGYNTRATNYNAGDRSTDYGIFQINSRYWCNDGKPGAVNACHLSCSALLQDNIADAVACAKRVVRDQGIRAWVAWRNRCQNRDVRQYVQGCGV >Rat KTYERCEFARTLKRNGMSGYYGVSLADWVCLAQHESNYNTQARNYDPGDQSTDYGIFQINSRYWCNDGKPRAKNACGIPCSALLQDDITQAIQCAKRVVRDQGIRAWVAWQRHCKNRDLSGYIRNCGV >Cow KVFERCELARTLKKLGLDGYKGVSLANWLCLTKWESSYNTKATNYNPSSESTDYGIFQINSKWWCNDGKPNAVDGCHVSCSELMENDIAKAVACAKKIVSEQGITAWVAWKSHCRDHDVSSYVEGCTL >Horse KVFSKCELAHKLKAQEMDGFGGYSLANWVCMAEYESNFNTRAFNGKNANGSSDYGLFQLNNKWWCKDNKRSSSNACNIMCSKLLDENIDDDISCAKRVVRDKGMSAWKAWVKHCKDKDLSEYLASCNL */ rate4site-3.0.0/src/phylogeny/phylipSequentialFormat.h0000644011611301161130000000231012223673416020030 00000000000000// $Id: phylipFormat.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___PHYLIP_INTERLEAVED_FORMAT #define ___PHYLIP_INTERLEAVED_FORMAT #include "definitions.h" #include "sequenceContainer.h" class phylipSequentialFormat { public: static sequenceContainer read(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd, const int numOfPositionInLine = 50, const int spaceEvery = 10); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); }; #endif /* EXAMPLE OF PHYLIP FORMAT (sequential): 6 128 Langur KIFERCELAR TLKKLGLDGY KGVSLANWVC LAKWESGYNT EATNYNPGDE STDYGIFQIN SRYWCNNGKP GAVDACHISC SALLQNNIAD AVACAKRVVS DQGIRAWVAW RNHCQNKDVS QYVKGCGV Baboon KIFERCELAR TLKRLGLDGY RGISLANWVC LAKWESDYNT QATNYNPGDQ STDYGIFQIN SHYWCNDGKP GAVNACHISC NALLQDNITD AVACAKRVVS DQGIRAWVAW RNHCQNRDVS QYVQGCGV Human KVFERCELAR TLKRLGMDGY RGISLANWMC LAKWESGYNT RATNYNAGDR STDYGIFQIN SRYWCNDGKP GAVNACHLSC SALLQDNIAD AVACAKRVVR DQGIRAWVAW RNRCQNRDVR QYVQGCGV */ rate4site-3.0.0/src/phylogeny/molphyFormat.h0000644011611301161130000000252312223673416016006 00000000000000// $Id: molphyFormat.h 962 2006-11-07 15:13:34Z privmane $ #ifndef ___MOLPHY_FORMAT #define ___MOLPHY_FORMAT #include "sequenceContainer.h" class molphyFormat{ public: static sequenceContainer read(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); }; #endif /* EXAMPLE OF MOLPHY FORMAT: 6 128 Langur KIFERCELARTLKKLGLDGYKGVSLANWVCLAKWESGYNTEATNYNPGDESTDYGIFQIN SRYWCNNGKPGAVDACHISCSALLQNNIADAVACAKRVVSDQGIRAWVAWRNHCQNKDVS QYVKGCGV Baboon KIFERCELARTLKRLGLDGYRGISLANWVCLAKWESDYNTQATNYNPGDQSTDYGIFQIN SHYWCNDGKPGAVNACHISCNALLQDNITDAVACAKRVVSDQGIRAWVAWRNHCQNRDVS QYVQGCGV Human KVFERCELARTLKRLGMDGYRGISLANWMCLAKWESGYNTRATNYNAGDRSTDYGIFQIN SRYWCNDGKPGAVNACHLSCSALLQDNIADAVACAKRVVRDQGIRAWVAWRNRCQNRDVR QYVQGCGV Rat KTYERCEFARTLKRNGMSGYYGVSLADWVCLAQHESNYNTQARNYDPGDQSTDYGIFQIN SRYWCNDGKPRAKNACGIPCSALLQDDITQAIQCAKRVVRDQGIRAWVAWQRHCKNRDLS GYIRNCGV Cow KVFERCELARTLKKLGLDGYKGVSLANWLCLTKWESSYNTKATNYNPSSESTDYGIFQIN SKWWCNDGKPNAVDGCHVSCSELMENDIAKAVACAKKIVSEQGITAWVAWKSHCRDHDVS SYVEGCTL Horse KVFSKCELAHKLKAQEMDGFGGYSLANWVCMAEYESNFNTRAFNGKNANGSSDYGLFQLN NKWWCKDNKRSSSNACNIMCSKLLDENIDDDISCAKRVVRDKGMSAWKAWVKHCKDKDLS EYLASCNL */ rate4site-3.0.0/src/phylogeny/getRandomWeights.h0000644011611301161130000000205512223673416016600 00000000000000// $Id: getRandomWeights.h 962 2006-11-07 15:13:34Z privmane $ #ifndef __GET_RANDOM_WEIGHTS #define __GET_RANDOM_WEIGHTS #include "definitions.h" class getRandomWeights { public: // this function starts with a vector of weights like that (1,1,1,1,1,1,...1) // it then take two positions by random // add 1 to the first, and substract 1 from the second. // if it can not substract 1 from the second, it draw a new "second" static void randomWeights(Vdouble& weights, const MDOUBLE expectedNumberOfSwapsPerPosition); // a position is chosen randomly and the weight of this position is // sampled from a gamma distribution with parameters alpha = 1/temperature // and beta = 1/temperature. static void randomWeightsGamma(Vdouble& weights, const MDOUBLE temperature); // this function starts with a vector of weights like that (0,0,0,...,0) // a position is chosen randomly and the weight of this position // is increased by 1. This process is repeated weights.size() times. static void standardBPWeights(Vdouble& weights); }; #endif rate4site-3.0.0/src/phylogeny/nexusFormat.h0000644011611301161130000000341512223673417015642 00000000000000// $Id: nexusFormat.h 5158 2008-11-06 17:44:08Z itaymay $ #ifndef ___NEXUS_FORMAT #define ___NEXUS_FORMAT #include "sequenceContainer.h" class nexusFormat{ public: static sequenceContainer read(istream &infile, const alphabet* alph); static void write(ostream &out, const sequenceContainer& sd); //readUnAligned: the input sequences do not need to be aligned (not all sequences are the same length). static sequenceContainer readUnAligned(istream &infile, const alphabet* alph); }; #endif /* EXAMPLE OF THE FORMAT: #NEXUS begin data; dimensions ntax=6 nchar=128; format datatype=Protein gap=-; matrix Horse KVFSKCELAHKLKAQEMDGFGGYSLANWVCMAEYESNFNTRAFNGKNANGSSDYGLFQLNNKWWCKDNKRSSSNACNIMCSKLLDENIDDDISCAKRVVRDKGMSAWKAWVKHCKDKDLSEYLASCNL Langur KIFERCELARTLKKLGLDGYKGVSLANWVCLAKWESGYNTEATNYNPGDESTDYGIFQINSRYWCNNGKPGAVDACHISCSALLQNNIADAVACAKRVVSDQGIRAWVAWRNHCQNKDVSQYVKGCGV Human KVFERCELARTLKRLGMDGYRGISLANWMCLAKWESGYNTRATNYNAGDRSTDYGIFQINSRYWCNDGKPGAVNACHLSCSALLQDNIADAVACAKRVVRDQGIRAWVAWRNRCQNRDVRQYVQGCGV Rat KTYERCEFARTLKRNGMSGYYGVSLADWVCLAQHESNYNTQARNYDPGDQSTDYGIFQINSRYWCNDGKPRAKNACGIPCSALLQDDITQAIQCAKRVVRDQGIRAWVAWQRHCKNRDLSGYIRNCGV Cow KVFERCELARTLKKLGLDGYKGVSLANWLCLTKWESSYNTKATNYNPSSESTDYGIFQINSKWWCNDGKPNAVDGCHVSCSELMENDIAKAVACAKKIVSEQGITAWVAWKSHCRDHDVSSYVEGCTL Baboon KIFERCELARTLKRLGLDGYRGISLANWVCLAKWESDYNTQATNYNPGDQSTDYGIFQINSHYWCNDGKPGAVNACHISCNALLQDNITDAVACAKRVVSDQGIRAWVAWRNHCQNRDVSQYVQGCGV ; end; NOTE!!!! The seqeunces can also be ordered in an "interleaved" way: Horse KVFSKCELAHKLKAQEMDGFGGYSLANWVCMAEYESNFNTRAFNGKNANGS Langur KIFERCELARTLKKLGLDGYKGVSLANWVCLAKWESGYNTEATNYNPGDES Horse SDYGLFQLNNKWWCKDNKRSSSNACNIMCSKLLDENIDDDISCAKRVVRDKGMSAWKAWVKHCKDKDLSEYLASCNL Langur TDYGIFQINSRYWCNNGKPGAVDACHISCSALLQNNIADAVACAKRVVSDQGIRAWVAWRNHCQNKDVSQYVKGCGV */ rate4site-3.0.0/src/phylogeny/Makefile.am0000755011611301161130000001321312223673415015210 00000000000000# where to install the headers on the system libphylo_adir = $(includedir)/libphylo lib_LIBRARIES = libphylo.a # AM_CPPFLAGS = -O3 -Wno-deprecated AM_CXXFLAGS = -O3 -Wno-deprecated -I$(top_srcdir)/src libphylo_a_HEADERS = \ replacementMatrixSource/mitochondriaAscidian.code \ replacementMatrixSource/mitochondriaProtozoan.code \ replacementMatrixSource/nuclearCiliate.code \ replacementMatrixSource/mitochondriaEchinoderm.code \ replacementMatrixSource/mitochondriaVertebrate.code \ replacementMatrixSource/nuclearEuplotid.code \ replacementMatrixSource/mitochondriaFlatworm.code \ replacementMatrixSource/mitochondriaYeast.code \ replacementMatrixSource/nuclearStandard.code \ replacementMatrixSource/mitochondriaInvertebrate.code\ replacementMatrixSource/nuclearBlepharisma.code \ cpREV45.dat.q \ dayhoff.dat.q \ jones.dat.q \ mtREV24.dat.q \ wag.dat.q \ HIVb.dat.q \ HIVw.dat.q \ adrianCodon.dat.q \ LG.dat.q \ replacementMatrixSource/cpREV45.dat \ replacementMatrixSource/dayhoff.dat \ replacementMatrixSource/jones.dat \ replacementMatrixSource/mtREV24.dat \ replacementMatrixSource/wag.dat \ getopt.h \ errorMsg.h \ definitions.h \ doubleRep.h \ ConversionUtils.h \ sequenceContainer.h \ sequence.h \ alphabet.h \ mulAlphabet.h \ someUtil.h \ logFile.h \ gainLossAlphabet.h \ pijAccelerator.h \ replacementModel.h \ distribution.h \ readTree.h \ nucleotide.h \ amino.h \ geneticCodeHolder.h \ codon.h \ evaluateCharacterFreq.h \ uniDistribution.h \ generalGammaDistribution.h \ readDatMatrix.h \ datMatrixHolder.h \ chebyshevAccelerator.h \ nucJC.h \ aaJC.h \ gtrModel.h \ fromQtoPt.h \ trivialAccelerator.h \ distanceMethod.h \ distanceTable.h \ nj.h \ njConstrain.h \ distances2Tree.h \ numRec.h \ uniformDistribution.h \ checkcovFanctors.h \ likelihoodComputation.h \ computePijComponent.h \ stochasticProcess.h \ suffStatComponent.h \ unObservableData.h\ likeDist.h \ countTableComponent.h \ jcDistance.h \ fastStartTree.h \ checkcovFanctorsWithFactors.h \ likelihoodComputationFactors.h \ bestAlpha.h \ gammaDistribution.h \ siteSpecificRate.h \ recognizeFormat.h \ bblEM.h \ bestGtrModelParams.h \ tamura92.h \ bestHKYparam.h \ hky.h \ bestTamura92param.h \ talRandom.h \ computeSubstitutionCounts.h \ fromCountTableComponentToDistance.h \ computeCounts.h \ computeDownAlg.h \ computeUpAlg.h \ gammaUtilities.h \ seqContainerTreeMap.h \ treeUtil.h \ matrixUtils.h \ computePosteriorExpectationOfSubstitutions.h \ computePosteriorExpectationOfSubstitutions_nonReversibleSp.h \ multipleStochasticProcess.h \ simulateJumps.h \ simulateJumpsAbstract.h \ simulateCodonsJumps.h \ treeIt.h \ likelihoodComputationGL.h \ tree.h \ bblEMProportionalEB.h \ fromCountTableComponentToDistancePropEB.h \ likeDistPropEB.h \ bblLSProportionalEB.h \ phylipFormat.h \ maseFormat.h \ clustalFormat.h \ fastaFormat.h \ phylipSequentialFormat.h \ molphyFormat.h \ getRandomWeights.h \ nexusFormat.h libphylo_a_SOURCES = \ $(libphylo_a_HEADERS) \ alphabet.cpp \ sequenceContainer.cpp \ sequence.cpp \ mulAlphabet.cpp \ someUtil.cpp \ logFile.cpp \ gainLossAlphabet.cpp \ pijAccelerator.cpp \ replacementModel.cpp \ distribution.cpp \ readTree.cpp \ errorMsg.cpp \ nucleotide.cpp \ amino.cpp \ geneticCodeHolder.cpp \ codon.cpp \ doubleRep.cpp \ evaluateCharacterFreq.cpp \ uniDistribution.cpp \ generalGammaDistribution.cpp \ readDatMatrix.cpp \ datMatrixHolder.cpp \ chebyshevAccelerator.cpp \ nucJC.cpp \ aaJC.cpp \ gtrModel.cpp \ fromQtoPt.cpp \ distanceTable.cpp \ nj.cpp \ njConstrain.cpp \ numRec.cpp \ uniformDistribution.cpp \ computePijComponent.cpp \ stochasticProcess.cpp \ suffStatComponent.cpp \ unObservableData.cpp \ likeDist.cpp \ countTableComponent.cpp \ fastStartTree.cpp \ likelihoodComputationFactors.cpp \ bestAlpha.cpp \ gammaDistribution.cpp \ siteSpecificRate.cpp \ likelihoodComputation.cpp \ recognizeFormat.cpp \ bblEM.cpp \ hky.cpp \ bestGtrModelParams.cpp \ tamura92.cpp \ bestHKYparam.cpp \ bestTamura92param.cpp \ talRandom.cpp \ computeSubstitutionCounts.cpp \ fromCountTableComponentToDistance.cpp \ computeCounts.cpp \ computeDownAlg.cpp \ computeUpAlg.cpp \ computeUpAlgFactors.cpp \ gammaUtilities.cpp \ seqContainerTreeMap.cpp \ treeUtil.cpp \ matrixUtils.cpp \ simulateCodonsJumps.cpp \ computePosteriorExpectationOfSubstitutions.cpp \ computePosteriorExpectationOfSubstitutions_nonReversibleSp.cpp \ multipleStochasticProcess.cpp \ simulateJumps.cpp \ simulateJumpsAbstract.cpp \ treeIt.cpp \ likelihoodComputationGL.cpp \ tree.cpp \ bblEMProportionalEB.cpp \ fromCountTableComponentToDistancePropEB.cpp \ likeDistPropEB.cpp \ bblLSProportionalEB.cpp \ phylipFormat.cpp \ maseFormat.cpp \ clustalFormat.cpp \ fastaFormat.cpp \ phylipSequentialFormat.cpp \ molphyFormat.cpp \ getRandomWeights.cpp \ nexusFormat.cpp rate4site-3.0.0/src/phylogeny/Makefile.in0000644011611301161130000007514412223673476015240 00000000000000# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = src/phylogeny DIST_COMMON = $(libphylo_a_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libphylo_adir)" LIBRARIES = $(lib_LIBRARIES) AR = ar ARFLAGS = cru libphylo_a_AR = $(AR) $(ARFLAGS) libphylo_a_LIBADD = am__objects_1 = am_libphylo_a_OBJECTS = $(am__objects_1) alphabet.$(OBJEXT) \ sequenceContainer.$(OBJEXT) sequence.$(OBJEXT) \ mulAlphabet.$(OBJEXT) someUtil.$(OBJEXT) logFile.$(OBJEXT) \ gainLossAlphabet.$(OBJEXT) pijAccelerator.$(OBJEXT) \ replacementModel.$(OBJEXT) distribution.$(OBJEXT) \ readTree.$(OBJEXT) errorMsg.$(OBJEXT) nucleotide.$(OBJEXT) \ amino.$(OBJEXT) geneticCodeHolder.$(OBJEXT) codon.$(OBJEXT) \ doubleRep.$(OBJEXT) evaluateCharacterFreq.$(OBJEXT) \ uniDistribution.$(OBJEXT) generalGammaDistribution.$(OBJEXT) \ readDatMatrix.$(OBJEXT) datMatrixHolder.$(OBJEXT) \ chebyshevAccelerator.$(OBJEXT) nucJC.$(OBJEXT) aaJC.$(OBJEXT) \ gtrModel.$(OBJEXT) fromQtoPt.$(OBJEXT) distanceTable.$(OBJEXT) \ nj.$(OBJEXT) njConstrain.$(OBJEXT) numRec.$(OBJEXT) \ uniformDistribution.$(OBJEXT) computePijComponent.$(OBJEXT) \ stochasticProcess.$(OBJEXT) suffStatComponent.$(OBJEXT) \ unObservableData.$(OBJEXT) likeDist.$(OBJEXT) \ countTableComponent.$(OBJEXT) fastStartTree.$(OBJEXT) \ likelihoodComputationFactors.$(OBJEXT) bestAlpha.$(OBJEXT) \ gammaDistribution.$(OBJEXT) siteSpecificRate.$(OBJEXT) \ likelihoodComputation.$(OBJEXT) recognizeFormat.$(OBJEXT) \ bblEM.$(OBJEXT) hky.$(OBJEXT) bestGtrModelParams.$(OBJEXT) \ tamura92.$(OBJEXT) bestHKYparam.$(OBJEXT) \ bestTamura92param.$(OBJEXT) talRandom.$(OBJEXT) \ computeSubstitutionCounts.$(OBJEXT) \ fromCountTableComponentToDistance.$(OBJEXT) \ computeCounts.$(OBJEXT) computeDownAlg.$(OBJEXT) \ computeUpAlg.$(OBJEXT) computeUpAlgFactors.$(OBJEXT) \ gammaUtilities.$(OBJEXT) seqContainerTreeMap.$(OBJEXT) \ treeUtil.$(OBJEXT) matrixUtils.$(OBJEXT) \ simulateCodonsJumps.$(OBJEXT) \ computePosteriorExpectationOfSubstitutions.$(OBJEXT) \ computePosteriorExpectationOfSubstitutions_nonReversibleSp.$(OBJEXT) \ multipleStochasticProcess.$(OBJEXT) simulateJumps.$(OBJEXT) \ simulateJumpsAbstract.$(OBJEXT) treeIt.$(OBJEXT) \ likelihoodComputationGL.$(OBJEXT) tree.$(OBJEXT) \ bblEMProportionalEB.$(OBJEXT) \ fromCountTableComponentToDistancePropEB.$(OBJEXT) \ likeDistPropEB.$(OBJEXT) bblLSProportionalEB.$(OBJEXT) \ phylipFormat.$(OBJEXT) maseFormat.$(OBJEXT) \ clustalFormat.$(OBJEXT) fastaFormat.$(OBJEXT) \ phylipSequentialFormat.$(OBJEXT) molphyFormat.$(OBJEXT) \ getRandomWeights.$(OBJEXT) nexusFormat.$(OBJEXT) libphylo_a_OBJECTS = $(am_libphylo_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libphylo_a_SOURCES) DIST_SOURCES = $(libphylo_a_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(libphylo_a_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # where to install the headers on the system libphylo_adir = $(includedir)/libphylo lib_LIBRARIES = libphylo.a # AM_CPPFLAGS = -O3 -Wno-deprecated AM_CXXFLAGS = -O3 -Wno-deprecated -I$(top_srcdir)/src libphylo_a_HEADERS = \ replacementMatrixSource/mitochondriaAscidian.code \ replacementMatrixSource/mitochondriaProtozoan.code \ replacementMatrixSource/nuclearCiliate.code \ replacementMatrixSource/mitochondriaEchinoderm.code \ replacementMatrixSource/mitochondriaVertebrate.code \ replacementMatrixSource/nuclearEuplotid.code \ replacementMatrixSource/mitochondriaFlatworm.code \ replacementMatrixSource/mitochondriaYeast.code \ replacementMatrixSource/nuclearStandard.code \ replacementMatrixSource/mitochondriaInvertebrate.code\ replacementMatrixSource/nuclearBlepharisma.code \ cpREV45.dat.q \ dayhoff.dat.q \ jones.dat.q \ mtREV24.dat.q \ wag.dat.q \ HIVb.dat.q \ HIVw.dat.q \ adrianCodon.dat.q \ LG.dat.q \ replacementMatrixSource/cpREV45.dat \ replacementMatrixSource/dayhoff.dat \ replacementMatrixSource/jones.dat \ replacementMatrixSource/mtREV24.dat \ replacementMatrixSource/wag.dat \ getopt.h \ errorMsg.h \ definitions.h \ doubleRep.h \ ConversionUtils.h \ sequenceContainer.h \ sequence.h \ alphabet.h \ mulAlphabet.h \ someUtil.h \ logFile.h \ gainLossAlphabet.h \ pijAccelerator.h \ replacementModel.h \ distribution.h \ readTree.h \ nucleotide.h \ amino.h \ geneticCodeHolder.h \ codon.h \ evaluateCharacterFreq.h \ uniDistribution.h \ generalGammaDistribution.h \ readDatMatrix.h \ datMatrixHolder.h \ chebyshevAccelerator.h \ nucJC.h \ aaJC.h \ gtrModel.h \ fromQtoPt.h \ trivialAccelerator.h \ distanceMethod.h \ distanceTable.h \ nj.h \ njConstrain.h \ distances2Tree.h \ numRec.h \ uniformDistribution.h \ checkcovFanctors.h \ likelihoodComputation.h \ computePijComponent.h \ stochasticProcess.h \ suffStatComponent.h \ unObservableData.h\ likeDist.h \ countTableComponent.h \ jcDistance.h \ fastStartTree.h \ checkcovFanctorsWithFactors.h \ likelihoodComputationFactors.h \ bestAlpha.h \ gammaDistribution.h \ siteSpecificRate.h \ recognizeFormat.h \ bblEM.h \ bestGtrModelParams.h \ tamura92.h \ bestHKYparam.h \ hky.h \ bestTamura92param.h \ talRandom.h \ computeSubstitutionCounts.h \ fromCountTableComponentToDistance.h \ computeCounts.h \ computeDownAlg.h \ computeUpAlg.h \ gammaUtilities.h \ seqContainerTreeMap.h \ treeUtil.h \ matrixUtils.h \ computePosteriorExpectationOfSubstitutions.h \ computePosteriorExpectationOfSubstitutions_nonReversibleSp.h \ multipleStochasticProcess.h \ simulateJumps.h \ simulateJumpsAbstract.h \ simulateCodonsJumps.h \ treeIt.h \ likelihoodComputationGL.h \ tree.h \ bblEMProportionalEB.h \ fromCountTableComponentToDistancePropEB.h \ likeDistPropEB.h \ bblLSProportionalEB.h \ phylipFormat.h \ maseFormat.h \ clustalFormat.h \ fastaFormat.h \ phylipSequentialFormat.h \ molphyFormat.h \ getRandomWeights.h \ nexusFormat.h libphylo_a_SOURCES = \ $(libphylo_a_HEADERS) \ alphabet.cpp \ sequenceContainer.cpp \ sequence.cpp \ mulAlphabet.cpp \ someUtil.cpp \ logFile.cpp \ gainLossAlphabet.cpp \ pijAccelerator.cpp \ replacementModel.cpp \ distribution.cpp \ readTree.cpp \ errorMsg.cpp \ nucleotide.cpp \ amino.cpp \ geneticCodeHolder.cpp \ codon.cpp \ doubleRep.cpp \ evaluateCharacterFreq.cpp \ uniDistribution.cpp \ generalGammaDistribution.cpp \ readDatMatrix.cpp \ datMatrixHolder.cpp \ chebyshevAccelerator.cpp \ nucJC.cpp \ aaJC.cpp \ gtrModel.cpp \ fromQtoPt.cpp \ distanceTable.cpp \ nj.cpp \ njConstrain.cpp \ numRec.cpp \ uniformDistribution.cpp \ computePijComponent.cpp \ stochasticProcess.cpp \ suffStatComponent.cpp \ unObservableData.cpp \ likeDist.cpp \ countTableComponent.cpp \ fastStartTree.cpp \ likelihoodComputationFactors.cpp \ bestAlpha.cpp \ gammaDistribution.cpp \ siteSpecificRate.cpp \ likelihoodComputation.cpp \ recognizeFormat.cpp \ bblEM.cpp \ hky.cpp \ bestGtrModelParams.cpp \ tamura92.cpp \ bestHKYparam.cpp \ bestTamura92param.cpp \ talRandom.cpp \ computeSubstitutionCounts.cpp \ fromCountTableComponentToDistance.cpp \ computeCounts.cpp \ computeDownAlg.cpp \ computeUpAlg.cpp \ computeUpAlgFactors.cpp \ gammaUtilities.cpp \ seqContainerTreeMap.cpp \ treeUtil.cpp \ matrixUtils.cpp \ simulateCodonsJumps.cpp \ computePosteriorExpectationOfSubstitutions.cpp \ computePosteriorExpectationOfSubstitutions_nonReversibleSp.cpp \ multipleStochasticProcess.cpp \ simulateJumps.cpp \ simulateJumpsAbstract.cpp \ treeIt.cpp \ likelihoodComputationGL.cpp \ tree.cpp \ bblEMProportionalEB.cpp \ fromCountTableComponentToDistancePropEB.cpp \ likeDistPropEB.cpp \ bblLSProportionalEB.cpp \ phylipFormat.cpp \ maseFormat.cpp \ clustalFormat.cpp \ fastaFormat.cpp \ phylipSequentialFormat.cpp \ molphyFormat.cpp \ getRandomWeights.cpp \ nexusFormat.cpp all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/phylogeny/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/phylogeny/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLIBRARIES: $(lib_LIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(libdir)'"; \ $(INSTALL_DATA) $$list2 "$(DESTDIR)$(libdir)" || exit $$?; } @$(POST_INSTALL) @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ if test -f $$p; then \ $(am__strip_dir) \ echo " ( cd '$(DESTDIR)$(libdir)' && $(RANLIB) $$f )"; \ ( cd "$(DESTDIR)$(libdir)" && $(RANLIB) $$f ) || exit $$?; \ else :; fi; \ done uninstall-libLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LIBRARIES)'; test -n "$(libdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libdir)'; $(am__uninstall_files_from_dir) clean-libLIBRARIES: -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) libphylo.a: $(libphylo_a_OBJECTS) $(libphylo_a_DEPENDENCIES) $(EXTRA_libphylo_a_DEPENDENCIES) -rm -f libphylo.a $(libphylo_a_AR) libphylo.a $(libphylo_a_OBJECTS) $(libphylo_a_LIBADD) $(RANLIB) libphylo.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aaJC.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alphabet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/amino.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bblEM.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bblEMProportionalEB.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bblLSProportionalEB.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestAlpha.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestGtrModelParams.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestHKYparam.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bestTamura92param.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chebyshevAccelerator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clustalFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/codon.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computeCounts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computeDownAlg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computePijComponent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computePosteriorExpectationOfSubstitutions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computePosteriorExpectationOfSubstitutions_nonReversibleSp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computeSubstitutionCounts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computeUpAlg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/computeUpAlgFactors.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/countTableComponent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/datMatrixHolder.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/distanceTable.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/distribution.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/doubleRep.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errorMsg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evaluateCharacterFreq.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fastStartTree.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fastaFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fromCountTableComponentToDistance.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fromCountTableComponentToDistancePropEB.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fromQtoPt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gainLossAlphabet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gammaDistribution.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gammaUtilities.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/generalGammaDistribution.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geneticCodeHolder.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getRandomWeights.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtrModel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hky.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/likeDist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/likeDistPropEB.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/likelihoodComputation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/likelihoodComputationFactors.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/likelihoodComputationGL.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logFile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maseFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/matrixUtils.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/molphyFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mulAlphabet.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multipleStochasticProcess.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nexusFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nj.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/njConstrain.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nucJC.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nucleotide.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numRec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/phylipFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/phylipSequentialFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pijAccelerator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readDatMatrix.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readTree.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/recognizeFormat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/replacementModel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seqContainerTreeMap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sequence.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sequenceContainer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simulateCodonsJumps.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simulateJumps.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simulateJumpsAbstract.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/siteSpecificRate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/someUtil.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stochasticProcess.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/suffStatComponent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/talRandom.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tamura92.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tree.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/treeIt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/treeUtil.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unObservableData.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uniDistribution.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uniformDistribution.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` install-libphylo_aHEADERS: $(libphylo_a_HEADERS) @$(NORMAL_INSTALL) @list='$(libphylo_a_HEADERS)'; test -n "$(libphylo_adir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(libphylo_adir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libphylo_adir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libphylo_adir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(libphylo_adir)" || exit $$?; \ done uninstall-libphylo_aHEADERS: @$(NORMAL_UNINSTALL) @list='$(libphylo_a_HEADERS)'; test -n "$(libphylo_adir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(libphylo_adir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libphylo_adir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-libphylo_aHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-libLIBRARIES uninstall-libphylo_aHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-libLIBRARIES install-libphylo_aHEADERS \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ ps ps-am tags uninstall uninstall-am uninstall-libLIBRARIES \ uninstall-libphylo_aHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: rate4site-3.0.0/src/phylogeny/alphabet.cpp0000644011611301161130000000031512223673417015436 00000000000000// $Id: alphabet.cpp 962 2006-11-07 15:13:34Z privmane $ #include "alphabet.h" alphabet::~alphabet(){} // this must be here. see Effective c++ page 63 (item 14, constructors, destructors, // assignment rate4site-3.0.0/src/phylogeny/sequenceContainer.cpp0000644011611301161130000003410312223673416017332 00000000000000// $Id: sequenceContainer.cpp 10475 2012-03-18 07:54:50Z itaymay $ #include "sequenceContainer.h" #include "logFile.h" #include "someUtil.h" #include "fastaFormat.h" sequenceContainer::sequenceContainer(const sequenceContainer& other,const alphabet *inAlph) : _generalRemarks(other._generalRemarks), _id2place(other._id2place) { for (int i=0; i < other._seqDataVec.size(); ++i) _seqDataVec.push_back(sequence(other._seqDataVec[i],inAlph)); } //if bAugumentShorterSeqs=true then add gap characters at the end of short seqeunces const int sequenceContainer::makeSureAllSeqAreSameLengthAndGetLen(bool bAugumentShorterSeqs) { if (_seqDataVec.size() == 0) return 0; const int len = _seqDataVec[0].seqLen(); for (int i=1; i < _seqDataVec.size(); ++i) { if (_seqDataVec[i].seqLen()!=len) { if (bAugumentShorterSeqs) { for (int pos = _seqDataVec[i].seqLen(); pos < len; ++pos) _seqDataVec[i].push_back(getAlphabet()->gap()); } else { cerr<<_seqDataVec[i].name()<<" length = "<<_seqDataVec[i].seqLen()<<" "<<_seqDataVec[0].name()<<" length = "" "<name() == _seqDataVec[i].name()) { // _seqDataVec[i]+=(*tit); // break; // } // } // ++tit; // } // } //} void sequenceContainer::changeGaps2MissingData() { for (int i = 0; i < seqLen();++i) {//going over al positions for (int j = 0; j < _seqDataVec.size();++j) { if (_seqDataVec[j][i] == -1){ _seqDataVec[j][i]=getAlphabet()->unknown(); // missing data } } } } const int sequenceContainer::getId(const string &seqName, bool issueWarningIfNotFound) const { int k; for (k=0 ; k < _seqDataVec.size() ; ++k) { if (_seqDataVec[k].name() == seqName) return (_seqDataVec[k].id()); } if (k == _seqDataVec.size() && issueWarningIfNotFound) { // debuggin LOG(5,<<"seqName = "< res; for (int i=0; i < _seqDataVec.size(); ++i) { res.push_back(_seqDataVec[i].name()); } return res; } sequenceContainer::sequenceContainer() { _id2place.resize(100,-1); } sequenceContainer::~sequenceContainer(){} void sequenceContainer::add(const sequence& inSeq) { _seqDataVec.push_back(inSeq); if (_id2place.size() < inSeq.id()+1) { _id2place.resize(inSeq.id()+100,-1); } if (_id2place[inSeq.id()] != -1) { string err = "Two sequences with the same id - error in function sequenceContainer::add"; err+= "\nThe id of the sequence you are trying to add = "; err += int2string(inSeq.id()); errorMsg::reportError(err); } _id2place[inSeq.id()] = _seqDataVec.size()-1; } //given a sequence id the sequence is removed from the sequence container //and the vector _id2place is updated. void sequenceContainer::remove(const int idSeq) { if (idSeq > _id2place.size()-1 || idSeq<0) errorMsg::reportError("the id of sequence is not mapped by id2place in function sequenceContainer::remove"); int place = _id2place[idSeq]; if (place < 0) errorMsg::reportError("cannot find place of the id in the sequence container in function sequenceContainer::remove"); _seqDataVec.erase(_seqDataVec.begin()+place); _id2place[idSeq] = -1; for (int i=place;i<_seqDataVec.size();i++) { int id = _seqDataVec[i].id(); _id2place[id]--; } } // remove all sequences from the sequence container void sequenceContainer::removeAll(){ Vint ids2remove(numberOfSeqs()); for(int i= 0; i posToRemove(seqLen(),0); bool gapCol; int i,j; for (i = 0; i < seqLen();++i) {//going over al positions gapCol = false; for (j = 0; j < _seqDataVec.size();++j) { if (_seqDataVec[j][i] == -1) posToRemove[i] = 1; } } removePositions(posToRemove); } void sequenceContainer::removeGapPositionsAllSeqs(){ vector posToRemove(seqLen(),1); bool gapCol; int i,j; for (i = 0; i < seqLen();++i) {//going over al positions gapCol = false; for (j = 0; j < _seqDataVec.size();++j) { if (_seqDataVec[j][i] != -1) posToRemove[i] = 0; } } removePositions(posToRemove); } void sequenceContainer::removeGapPositionsAccordingToAReferenceSeq(const string & seqName){ int idOfRefSeq = getId(seqName,true); vector posToRemove(seqLen(),0); int i; for (i = 0; i < seqLen();++i) {//going over al positions if (_seqDataVec[idOfRefSeq][i] == -1) posToRemove[i] = 1; } removePositions(posToRemove); } void sequenceContainer::removeUnknownPositionsAccordingToAReferenceSeq(const string & seqName){ int idOfRefSeq = getId(seqName,true); vector posToRemove(seqLen(),0); int i; for (i = 0; i < seqLen();++i) {//going over al positions if (_seqDataVec[idOfRefSeq][i] == getAlphabet()->unknown()) posToRemove[i] = 1; } removePositions(posToRemove); } //removePositions: the positions to be removed are marked as '1' in posToRemoveVec //all othehr positions are '0' void sequenceContainer::removePositions(const Vint & posToRemoveVec) { for (int z = 0; z < _seqDataVec.size();++z) { _seqDataVec[z].removePositions(posToRemoveVec); } } sequenceContainer sequenceContainer::getSubSeq(const int startPos, const int endPos) { sequenceContainer subSeq(*this); vector posToRemove(seqLen(),true); for (int i = startPos; i <= endPos;++i) {//going over al positions posToRemove[i] = false; } subSeq.removePositions(posToRemove); return subSeq; } void sequenceContainer::changeDotsToGoodCharacters() { for (int i = 0; i < seqLen();++i) {//going over al positions int charInFirstSeq = _seqDataVec[0][i]; if (charInFirstSeq == -3) { LOG(5,<<" position is "<unknown(); for (int i=0; i < numberOfSeqs(); ++i) { if ((*this)[i][pos] == unknown ) --numOfNonCharPos; } return numOfNonCharPos; } bool sequenceContainer::isInvariable(const int pos) const { int charFound = getAlphabet()->unknown(); for (int i=0; i < numberOfSeqs(); ++i) { if ((*this)[i][pos] >= 0) { if (charFound == getAlphabet()->unknown()) charFound = (*this)[i][pos]; else if (charFound != (*this)[i][pos]) return false; } } return true; } int sequenceContainer::getInvariablePosNum() const { int sum = 0; for (int pos = 0; pos < seqLen(); ++pos) { if (isInvariable(pos)) ++sum; } return sum; } // new func for gainLoss project void sequenceContainer::startZeroSequenceContainerGL(const sequenceContainer &sc, const gainLossAlphabet& alph, const int minNumOfOnes, const int minNumOfZeros) { //if(minNumOfOnes==0 && minNumOfZeros==0) // return; string str0 = "0"; string str1 = "1"; vector strV; strV.resize(sc.numberOfSeqs()); string remark =""; switch (minNumOfOnes) { case (1) : for(int i=0; iadd(sequence(strV[i],sc.name(i),remark,i,&alph)); } } //concatenate two sequecneContainers. //The sequence names must be identical in the two containers. //returns false if: (1) A sequence_name in one of the containers does not match any sequence_name in the other container. void sequenceContainer::concatenate(sequenceContainer& other) { if (other.numberOfSeqs() != numberOfSeqs()){ string msg = "Not the same number of taxa, can't concatenate\n"; errorMsg::reportError(msg); return; } for (sequenceContainer::taxaIterator itThis=(*this).taxaBegin();itThis!=(*this).taxaEnd();++itThis) { //for(int i = 0; i < numberOfSeqs(); ++i) { bool bFound = false; //out << (*this)[i].name()<name().compare(itOther->name()) == 0) { //(*this)[i] += other[j]; // was i ????? *(itThis) += *(itOther); bFound = true; break; } } if (bFound == false) { string msg = "Can't find sequence name in the second MSA: " +itThis->name(); errorMsg::reportError(msg); } } } ////////////////////////////////////////////////////////////////////////// const bool sequenceContainer::operator==(const sequenceContainer& sq) const { if (_seqDataVec.size() != sq._seqDataVec.size()) // not the same number of sequences in sequenceContainer return false; const int numberOfSeqs = _seqDataVec.size(); const int len = _seqDataVec[0].seqLen(); for (int i=0; i < numberOfSeqs; ++i) { string nameI = name(i); int idI = getId(nameI); int idSq = sq.getId(nameI); if (_seqDataVec[idI].seqLen()!=sq._seqDataVec[idSq].seqLen()) return false; for (int pos = 0; pos < len; ++pos) { if (_seqDataVec[idI][pos]!=sq._seqDataVec[idSq][pos]) return false; } } return true; } ////////////////////////////////////////////////////////////////////////// int sequenceContainer::getNumOfOccurancesPerPos(const int pos, const char charId){ int numOfOccurancesPerPos = 0; const int numberOfSeqs = _seqDataVec.size(); const int len = _seqDataVec[0].seqLen(); for (int i=0; i < numberOfSeqs; ++i) { string nameI = name(i); int idI = getId(nameI); if (_seqDataVec[idI][pos]==charId) numOfOccurancesPerPos++; } return numOfOccurancesPerPos; } ////////////////////////////////////////////////////////////////////////// // added counts for unKnown data const vector sequenceContainer::getAlphabetDistribution(bool isCountUnknown) const { vector alphabetVec; int alphSize = alphabetSize()+1; //unKnown int UnknownVal = getAlphabet()->unknown(); alphabetVec.resize( alphSize); const int numberOfSeqs = _seqDataVec.size(); const int len = _seqDataVec[0].seqLen(); for (int i=0; i < numberOfSeqs; ++i) { for (int pos = 0; pos < len; ++pos) { for(int alph = 0 ; alph sequenceContainer::getAlphabetDistribution(int pos,bool isCountUnknown) const { vector alphabetVec; alphabetVec.resize( alphabetSize()); const int numberOfSeqs = _seqDataVec.size(); for (int i=0; i < numberOfSeqs; ++i) { for(int alph = 0 ; alph using namespace std; sequence::sequence(const string& str, const string& name, const string& remark, const int id, const alphabet* inAlph) : _alphabet(inAlph->clone()), _remark(remark), _name(name),_id(id) { for (int k=0; k < str.size() ;k += _alphabet->stringSize()) { int charId = inAlph->fromChar(str, k); if (charId == -99) { string textToPrint = "unable to read sequence: " + name; errorMsg::reportError(textToPrint); } _vec.push_back(charId); } } sequence::sequence(const sequence& other) : _vec(other._vec), _alphabet(other._alphabet->clone()), _remark(other._remark), _name(other._name),_id(other._id) { } // convert the other sequence to the alphabet inAlph. sequence::sequence(const sequence& other,const alphabet* inAlph) : _alphabet(inAlph->clone()), _remark(other._remark), _name(other._name), _id(other._id) { const mulAlphabet* pMulAlphabet; // if the other.alphabet is amino or nucleotide and the inAlph is indel if ( (other._alphabet->size() == 20 && inAlph->size() == 2) || (other._alphabet->size() == 4 && inAlph->size() == 2) ) { for (int k=0; k < other.seqLen() ;k += other._alphabet->stringSize()) { int charId = other._vec[k]; if (charId == other._alphabet->gap()) _vec.push_back(inAlph->fromChar("-",0)); else _vec.push_back(inAlph->fromChar("X",0)); //also converts "." (charId==-3) to "X" // unknown amino/nucleotide is converted to "X" and not to "?" } } // if the other.alphabet is amino or nucleotide and the inAlph is mulAlphabet else if ( (other._alphabet->size() == 20 && inAlph->size()%20 == 0) || (other._alphabet->size() == 4 && inAlph->size()%4 == 0) ) { for (int k=0; k < other.seqLen() ;++k) { int charId = other._vec[k]; string ch = other._alphabet->fromInt(charId); int mulCharId = _alphabet->fromChar(ch,0); _vec.push_back(mulCharId); } // debug OZ //cout << "other sequence: " << other << endl; //cout << "mul sequence " << (*this) << endl; // end of debug } // if the other.alphabet is mulAlphabet and the inAlph is it's baseAlphabet // (for example, if other.alphabet is a multiplied-amino and inAlph is amino, then the converted sequence // will have alphabet amino) else if ( ((inAlph->size() == 20) && (other._alphabet->size()%20 == 0)) || (inAlph->size() == 4) && (other._alphabet->size()%4 == 0)) { pMulAlphabet=(mulAlphabet*)(other._alphabet); for (int k=0; k < other.seqLen() ;++k) { int mulCharId = other._vec[k]; int baseId = pMulAlphabet->convertToBasedAlphaInt(mulCharId); _vec.push_back(baseId); } } // for gainLoss project - {0,1} in both, hence no conversion needed. // it should be the same for all cases with same alphabet else if ( inAlph->size() == other._alphabet->size() ) { pMulAlphabet=(mulAlphabet*)(other._alphabet); for (int k=0; k < other.seqLen() ;++k) { int mulCharId = other._vec[k]; //int baseId = pMulAlphabet->convertToBasedAlphaInt(mulCharId); _vec.push_back(mulCharId); } } // I tried to implement it using dynamic_cast but it doesn't work... /*else if ( (pMulAlphabet = dynamic_cast(other._alphabet)) != NULL ) { if (pMulAlphabet->getBaseAlphabet()->size() == inAlph->size()) { for (int k=0; k < other.seqLen() ;++k) { int mulCharId = other._vec[k]; int baseId = pMulAlphabet->convertToBasedAlphaInt(mulCharId); _vec.push_back(baseId); } } }*/ // (currently, there is no implimentions for other converts) else { string error = "unable to convert this kind of alphabet"; errorMsg::reportError(error); } } sequence::~sequence() { if (_alphabet) delete _alphabet; } void sequence::resize(const int k, const int* val) { if (val == NULL) { _vec.resize(k,_alphabet->unknown()); } else { _vec.resize(k,*val); } } string sequence::toString() const{ string tmp; for (int k=0; k < _vec.size() ; ++k ){ tmp+= _alphabet->fromInt(_vec[k]); } return tmp; } string sequence::toString(const int pos) const{ return _alphabet->fromInt(_vec[pos]); } void sequence::addFromString(const string& str) { for (int k=0; k < str.size() ; k+=_alphabet->stringSize()) { _vec.push_back(_alphabet->fromChar(str,k)); } } class particip { public: explicit particip() {} bool operator()(int i) { return (i==-1000); } }; //removePositions: the poitions to be removed are marked as '1' in posToRemoveVec //all othehr positions are '0' void sequence::removePositions(const vector & posToRemoveVec) { if(posToRemoveVec.size() != seqLen()) errorMsg::reportError("the input vector must be same size as sequence length. in sequence::removePositions"); for (int k=0; k < posToRemoveVec.size(); ++k) { if (posToRemoveVec[k] == 1) _vec[k] = -1000; } vector::iterator vec_iter; vec_iter = remove_if(_vec.begin(),_vec.end(),particip()); _vec.erase(vec_iter,_vec.end()); // pg 1170, primer. } //return the number of sites that are specific = not unknown, nor ambiguity, nor gap (for example, for nucleotides it will true for A,C,G, or T). int sequence::seqLenSpecific() const { int res = 0; for (int pos = 0; pos < seqLen(); ++pos) { if (isSpecific(pos)) ++res; } return res; } rate4site-3.0.0/src/phylogeny/mulAlphabet.cpp0000644011611301161130000001040512223673415016113 00000000000000// $Id: mulAlphabet.cpp 6420 2009-06-25 11:17:08Z adist $ #include "mulAlphabet.h" #include "distribution.h" #include "errorMsg.h" #include #include "logFile.h" mulAlphabet::mulAlphabet(const alphabet* baseAlphabet, int mulFactor) : _baseAlphabet(baseAlphabet->clone()), _mulFactor(mulFactor), _size(baseAlphabet->size() * mulFactor) {} mulAlphabet::mulAlphabet(const mulAlphabet& other) : _baseAlphabet(other._baseAlphabet->clone()), _mulFactor(other._mulFactor), _size(other._size) {} mulAlphabet::~mulAlphabet() { if (_baseAlphabet) delete (_baseAlphabet); } mulAlphabet& mulAlphabet::operator=(const mulAlphabet &other) { if (_baseAlphabet) delete (_baseAlphabet); _baseAlphabet = other._baseAlphabet->clone(); _mulFactor = other._mulFactor; _size = other._size; return (*this); } int mulAlphabet::unknown() const { return (convertFromBasedAlphaInt(_baseAlphabet->unknown())); } int mulAlphabet::gap() const { return (convertFromBasedAlphaInt(_baseAlphabet->gap())); } int mulAlphabet::stringSize() const { return _baseAlphabet->stringSize(); } bool mulAlphabet::isSpecific(const int id) const { if (id >= _size) return false; else return _baseAlphabet->isSpecific(convertToBasedAlphaInt(id)); } /* The first _size characters should be first. The rest of the characters aren't multiplied. For example, when using nucleotides as the based alphabet and _mulFactor = 2 : 0 A0 1 C0 2 G0 3 T0 4 A1 5 C1 6 G1 7 T1 8 A 9 C 10 G 11 T 12 U 13 R 14 Y 15 K 16 M 17 S 18 W 19 B 20 D 21 H 22 V 23 N -1 - */ string mulAlphabet::fromInt(const int id) const { // category and categoryName are for debug purpose int category(_mulFactor); if (id>=0) category = min(id / _baseAlphabet->size() , _mulFactor) ; string categoryName(""); categoryName = int2string(category); int inCategoryId = convertToBasedAlphaInt(id); return (_baseAlphabet->fromInt(inCategoryId) + categoryName); } int mulAlphabet::convertFromBasedAlphaInt(int id) const { if (id < 0) return (id); return (id + _size); } int mulAlphabet::fromChar(const string& str, const int pos) const { int id = _baseAlphabet->fromChar(str,pos); return (convertFromBasedAlphaInt(id)); } vector mulAlphabet::fromString(const string &str) const { vector result = _baseAlphabet->fromString(str); vector::iterator itr = result.begin(); for (; itr != result.end(); ++itr) *itr = convertFromBasedAlphaInt(*itr); return (result); } int mulAlphabet::convertToBasedAlphaInt(int id) const { if (id<0) return (id); if (id >= _size) return (id - _size); return (id % _baseAlphabet->size()); } int mulAlphabet::relations(const int charInSeq, const int charToCheck) const { int baseAlphabetSize = _baseAlphabet->size(); int categoryInSeq(_mulFactor); if (charInSeq>=0) categoryInSeq = min(charInSeq/baseAlphabetSize , _mulFactor); int categoryToCheck(_mulFactor); if (charToCheck>=0) categoryToCheck = min(charToCheck/baseAlphabetSize , _mulFactor); if (categoryToCheck == _mulFactor) LOG(4,<<"mulAlphabet::relations charToCheck should belong to category < _mulFactor = " << _mulFactor << endl); if ((categoryInSeq == categoryToCheck) || (categoryInSeq == _mulFactor)) return _baseAlphabet->relations(convertToBasedAlphaInt(charInSeq),convertToBasedAlphaInt(charToCheck)); return 0; } int mulAlphabet::compareCategories(int charA, int charB) const { // TO DO should combine code by calling mulAlphabet::rateShiftType mulAlphabet::compareCategories int baseAlphabetSize = _baseAlphabet->size(); int categoryA(_mulFactor); if (categoryA>=0) categoryA = min(charA/baseAlphabetSize,_mulFactor); int categoryB(_mulFactor); if (categoryB>=0) categoryB = min(charB/baseAlphabetSize,_mulFactor); if (categoryA=0) categoryA = min(charA/baseAlphabetSize,multiplicationFactor); int categoryB(multiplicationFactor); if (categoryB>=0) categoryB = min(charB/baseAlphabetSize,multiplicationFactor); if (categoryA #include #include #include #include #include #include using namespace std; // for the _mkdir call #if defined(WIN32) || defined(SunOS) || defined(solaris) #include #else #include #include // #include #endif //swap between the 4 variables such that the first becomes the second, second becomes the third and third becomes the fourth. //used in functoin mnbrack below. void shift3(MDOUBLE &a, MDOUBLE &b, MDOUBLE &c, const MDOUBLE d) { a=b; b=c; c=d; } MDOUBLE computeAverage(const vector& vec) { MDOUBLE sum=0.0; for (int i=0; i < vec.size(); ++i) { sum+=static_cast(vec[i]); } return sum/static_cast(vec.size()); } // X ~ Poisson(lamda) --> P(X=k) = ((lamda^k)/k!) * e^(-lamda) // It isn't smart to first calculate factorial(k) because the size of long int limits this calculation to k<=13 MDOUBLE copmutePoissonProbability(const int& k, const long double& lamda) { assert(k>=0); long double tmp = pow(lamda,k); // tmp = (lamda^k)/k! for (int i=2; i<=k; ++i) tmp/=i; return (tmp * exp(-lamda)); } MDOUBLE computeAverage(const vector& vec, const Vdouble* weightsV) { MDOUBLE sum=0.0; if(weightsV && !(weightsV->size() == vec.size() )) errorMsg::reportError("Using computeAverage with weights, where the number of weights not equal values"); for (int i=0; i < vec.size(); ++i){ if(weightsV) sum+=vec[i]* (*weightsV)[i]; else sum+=vec[i]; } return sum/static_cast(vec.size()); } MDOUBLE computeAverageOfAbs(const vector& vec, const Vdouble* weightsV) { MDOUBLE sum=0.0; if(weightsV && !(weightsV->size() == vec.size() )) errorMsg::reportError("Using computeAverage with weights, where the number of weights not equal values"); for (int i=0; i < vec.size(); ++i){ if(weightsV) sum+=abs(vec[i]* (*weightsV)[i]); else sum+=abs(vec[i]); } return sum/static_cast(vec.size()); } MDOUBLE computeMedian(const vector& vec) { int vecSize = vec.size(); if (vecSize<1) return 0; vector< vecElem > sortVec(vecSize); for (int x =0; x < vecSize ; ++x) { sortVec[x].setValue(vec[x]); sortVec[x].setPlace(x); } sort(sortVec.begin(), sortVec.end()); sort(sortVec.begin(), sortVec.end()); int highMedianIndex = int((vecSize+1)/2); MDOUBLE median = sortVec[highMedianIndex].getValue(); return median; } //// if quantile=0.5, the median is returned, if quantile=0.1, the low-ton-percentile is returned, quantile=0.9, the top-90-percentile is returned MDOUBLE computeQuantileFrac(const vector& vec, MDOUBLE quantile) { int vecSize = vec.size(); vector< vecElem > sortVec(vecSize); for (int x =0; x < vecSize ; ++x) { sortVec[x].setValue(vec[x]); sortVec[x].setPlace(x); } sort(sortVec.begin(), sortVec.end()); sort(sortVec.begin(), sortVec.end()); int qIndex = int((vecSize+1)*quantile); MDOUBLE quantileVal = sortVec[qIndex].getValue(); return quantileVal; } //// if quantile=2, the median is returned, if quantile=10, the ten-percentile is returned MDOUBLE computeQuantile(const vector& vec, MDOUBLE quantile) { MDOUBLE dividerForRank = 1+ 1.0/(quantile-1); int vecSize = vec.size(); vector< vecElem > sortVec(vecSize); for (int x =0; x < vecSize ; ++x) { sortVec[x].setValue(vec[x]); sortVec[x].setPlace(x); } sort(sortVec.begin(), sortVec.end()); sort(sortVec.begin(), sortVec.end()); int qIndex = int((vecSize+1)/dividerForRank); MDOUBLE quantileVal = sortVec[qIndex].getValue(); return quantileVal; } MDOUBLE computeStd(const vector& vec) {// page 60, Sokal and Rohlf MDOUBLE sum=0.0; MDOUBLE sumSqr=0.0; MDOUBLE vecSize = static_cast(vec.size()); for (int i=0; i < vec.size(); ++i) { sum+=static_cast(vec[i]); sumSqr+=(static_cast(vec[i])*static_cast(vec[i])); } MDOUBLE res= sumSqr-(sum*sum/vecSize); res /= (vecSize-1.0); res = sqrt(res); return res; } MDOUBLE computeStd(const vector& vec) {// page 60, Sokal and Rohlf MDOUBLE sum=0.0; MDOUBLE sumSqr=0.0; MDOUBLE vecSize = static_cast(vec.size()); for (int i=0; i < vec.size(); ++i) { sum+=vec[i]; sumSqr+=(vec[i]*vec[i]); } MDOUBLE res= sumSqr-(sum*sum/vecSize); res /= (vecSize-1.0); res = sqrt(res); return res; } void computeRelativeFreqsFollowingOneChanged(MDOUBLE newValFreq, int indexNewFreq,Vdouble &freqs){ MDOUBLE proportionAfterOptimization = 1.0 - newValFreq; MDOUBLE proportionBeforeOptimization = 1.0 - freqs[indexNewFreq]; MDOUBLE sum = 0.0; for (int i=0; i(x_abs); double theRemainingPart = fabs(x_abs-theIntegerPart); int integerRepresentingTheRemainingPart = static_cast(theRemainingPart*pow(10.0,lenght)); string part1 = int2string(theIntegerPart); string part2 = int2string(integerRepresentingTheRemainingPart); while (part2.length()0 && result[i]=='0'){ result.erase(i); i--; } // removing "." if this is the last character in the string. if (result[result.length()-1]=='.') result.erase(result.length()-1); return result; } string int2string(const int num) { // the input to this program is say 56 // the output is the string "56" // this version of int2string is more portable // than sprintf like functions from c; // or sstream of stl. if (num == 0) return "0"; string res; int i = abs(num); int leftover; char k; while (i) { leftover = i%10; k = '0'+leftover; res = k+res; i/=10; } if (num<0) res = "-" + res; return res; }; void printTime(ostream& out) { time_t ltime; time( <ime ); out<<"# the date is "<< ctime( <ime )< &inseqFile){ inseqFile.clear(); string tmp1; while (getline(infile,tmp1, '\n' ) ) { if (tmp1.size() > 15000) { vector err; err.push_back("Unable to read file. It is required that each line is no longer than"); err.push_back("15000 characters. "); errorMsg::reportError(err,1); } if (tmp1[tmp1.size()-1]=='\r') {// in case we are reading a dos file tmp1.erase(tmp1.size()-1); }// remove the traling carrige-return inseqFile.push_back(tmp1); } } bool fromStringIterToInt(string::const_iterator & it, // ref must be here const string::const_iterator endOfString, int& res) {// the ref is so that we can use the it after the func. while (it != endOfString) { if ((*it == ' ') || (*it == '\t')) ++it;else break; // skeeping white spaces. } if (it != endOfString) { if (isdigit(*it) || (*it == '-')){ int k = atoi(&*it); if (*it == '-') ++it; for (int numDig = abs(k); numDig>0; numDig/=10) ++it; res = k; return true; } else return false; //unable to read int From String } return false; //unable to read int From String } string* searchStringInFile(const string& string2find, const int index, const string& inFileName) { ifstream f; f.open(inFileName.c_str()); if (f==NULL) { string tmp = "Unable to open file name: "+inFileName+" in function searchStringInFile"; errorMsg::reportError(tmp); } string numm = int2string(index); string realString2find = string2find+numm; istream_iterator is_string(f); istream_iterator end_of_stream; is_string = find(is_string,end_of_stream,realString2find); if(is_string == end_of_stream) {f.close();return NULL;} else { is_string++; if(is_string == end_of_stream) {f.close();return NULL;}; string* s = new string(*is_string); f.close(); return s; } f.close(); return NULL; } string* searchStringInFile(const string& string2find, const string& inFileName) {// return the string that is AFTER the string to search. ifstream f; f.open(inFileName.c_str()); if (f==NULL) { string tmp = "Unable to open file name: "+inFileName+" in function searchStringInFile"; errorMsg::reportError(tmp); } string realString2find = string2find; istream_iterator is_string(f); istream_iterator end_of_stream; is_string = find(is_string,end_of_stream,realString2find); if(is_string == end_of_stream) {f.close();return NULL;} else { is_string++; if(is_string == end_of_stream) {f.close();return NULL;}; string* s = new string(*is_string); f.close(); return s; } f.close(); return NULL; } bool doesWordExistInFile(const string& string2find,const string& inFileName) { ifstream f; f.open(inFileName.c_str()); if (f==NULL) { string tmp = "Unable to open file name: "+inFileName+" in function searchStringInFile"; errorMsg::reportError(tmp); } istream_iterator is_string(f); istream_iterator end_of_stream; is_string = find(is_string,end_of_stream,string2find); if(is_string == end_of_stream) return false; else return true; } string takeCharOutOfString(const string& charsToTakeOut, const string& fromString) { string finalString; for (int i=0; i x2) || DEQUAL(x1, x2,epsilon)); } bool DSMALL_EQUAL(const MDOUBLE x1, const MDOUBLE x2, MDOUBLE epsilon/*1.192092896e-07F*/){ return ((x1 < x2) || DEQUAL(x1, x2,epsilon)); } void createDir(const string & curDir, const string & dirName){// COPYRIGHT OF ITAY MAYROSE. string newDir; if (curDir == "") newDir = dirName; else newDir = curDir + string("/") + dirName; #ifdef WIN32 if( _mkdir(newDir.c_str()) == 0 ){ LOG(5, << "Directory " < 0.001) errorMsg::reportError(" problem - scalled average is not avgIn after scalling!!!"); return scaleFactor; } //calculates the mean square error distance between 2 vectors: MDOUBLE calcMSEDistBetweenVectors(const Vdouble& oneRatesVec, const Vdouble& otherRatesVec) { MDOUBLE res = 0.0; if (oneRatesVec.size() != otherRatesVec.size()) errorMsg::reportError("the two vectors to be compared are not the same size in function SimulateRates::calcDistBetweenRatesVectors()"); for (int i=0; i 0: if trueValues[i] < threshhold then do not add the rse for this psition to the result MDOUBLE calcRelativeMSEDistBetweenVectors(const Vdouble& trueValues, const Vdouble& inferredValues, const MDOUBLE threshhold/*0.0*/ ) { MDOUBLE res = 0.0; if (inferredValues.size() != trueValues.size()) errorMsg::reportError("the two vectors to be compared are not the same size in function SimulateRates::calcDistBetweenRatesVectors()"); int counter = 0; for (int i=0; i(seqLength), 2.0) -1)); //n^3 -n MDOUBLE numerator = 1.0 - ((6/en3n) * (sum_diff_sqr + (s_one + s_two)/12.0)); MDOUBLE denum = sqrt((1.0 - s_one/en3n) * (1.0 - s_two/en3n)); res = numerator/ denum; return res; } /******************************************************************************************** calculates the spearman rank correlation value, Ofir implementation *********************************************************************************************/ MDOUBLE calcRankCorrelation2(const Vdouble& oneRatesVec, const Vdouble& otherRatesVec) { int vecLen = oneRatesVec.size(); if(vecLen != otherRatesVec.size()) errorMsg::reportError("calcRankCorrelation2. Vectors length differ"); Vdouble orderVec1, orderVec2; orderRankNoTies(oneRatesVec, orderVec1); orderRankNoTies(otherRatesVec, orderVec2); MDOUBLE n = (double)vecLen; MDOUBLE dif,r,sum_dif=0; for (int i=0; i > sortVec(vecSize); // for (int x =0; x < vecSize ; ++x) // { // sortVec[x].setValue(vecIn[x]); // sortVec[x].setPlace(x); // } // sort(sortVec.begin(), sortVec.end()); // // //check for ties and correct their rank // Vdouble rankVec(vecSize); // MDOUBLE rank; // for (int i=0; i < vecSize; ) // { // if (sortVec[i].getValue() != sortVec[i+1].getValue()) // {//no tie // rankVec[i] = i; // ++i; // } // else // {//tie // int to =0; // for (to = i+1; (to<=vecSize) && (sortVec[i].getValue() == sortVec[to].getValue());++to) // ;//check how far the tie goes // to--; // rank = 0.5*(to + i); // for (int ji = i; ji<= to; ji++) // { // rankVec[ji] = rank; // } // // i = to+1; // } // } // for (int j =0; j < vecSize; ++j) { // assert ((rankVec[j] >= 0) && (rankVec[j] < vecSize)); // orderVecOut[sortVec[j].getPlace()] = rankVec[j]; // } // return orderVecOut; //} //orderVec - determine the relative order of vecIn //orderVecOut[i] is the rank of vecIn[i] //note that in case of ties the rank will be the midrank of the tied group //return sum of n^3 - n where n is the number of elements in each tied group - see spearman rank correlation MDOUBLE orderVec(const vector& vecIn, vector& orderVecOut) { int vecSize = vecIn.size(); orderVecOut.resize(vecSize); vector< vecElem > sortVec(vecSize); for (int x =0; x < vecSize ; ++x) { sortVec[x].setValue(vecIn[x]); sortVec[x].setPlace(x); } sort(sortVec.begin(), sortVec.end()); //check for ties and correct their rank Vdouble rankVec(vecSize); MDOUBLE sumRankDif = 0; //sum(Fk^3 - Fk) MDOUBLE rank; for (int i=0; i < vecSize-1; ) // loop was till vecSize, out of range with sortVec[i+1]. Fixed (?) { if (sortVec[i].getValue() != sortVec[i+1].getValue()) {//no tie rankVec[i] = i; ++i; } else {//tie int to =0; for (to = i+1; (to<=vecSize) && (sortVec[i].getValue() == sortVec[to].getValue());++to) ;//check how far the tie goes to--; rank = 0.5*(to + i); for (int ji = i; ji<= to; ji++) { rankVec[ji] = rank; } int numTies = to - i +1; //number o fties in this group sumRankDif += numTies*numTies*numTies - numTies; i = to+1; } } for (int j =0; j < vecSize; ++j) { assert ((rankVec[j] >= 0) && (rankVec[j] < vecSize)); orderVecOut[sortVec[j].getPlace()] = rankVec[j]; } return sumRankDif; } void orderRankNoTies(const vector& vecIn, vector& orderVecOut) { int vecSize = vecIn.size(); orderVecOut.resize(vecSize); vector< vecElem > sortVec(vecSize); for (int x =0; x < vecSize ; ++x) { sortVec[x].setValue(vecIn[x]); sortVec[x].setPlace(x); } sort(sortVec.begin(), sortVec.end()); for (int j =0; j < vecSize; ++j) { orderVecOut[sortVec[j].getPlace()] = j; } } void orderVec(const Vdouble& vecIn, vector< vecElem >& orderVecOut) { int vecSize = vecIn.size(); orderVecOut.resize(vecSize); for (int x =0; x < vecSize ; ++x) { orderVecOut[x].setValue(vecIn[x]); orderVecOut[x].setPlace(x); } sort(orderVecOut.begin(), orderVecOut.end()); } void splitString2(string str, string seperater, string &first, string &second) { int i = (int)str.find(seperater); //find seperator if(i != -1) { int y = 0; if(!str.empty()) { while(y != i) { first += str[y++]; //creating first string } y = y+(int)seperater.length(); //jumping forward seperater length while(y != str.length()) { second += str[y++]; //creating second string } } } else { first = str; second = "NULL"; //if seperator is not there then second string == null } } void splitString(const string& str,vector& subStrs,const string& delimiter) { // Skip delimiter at beginning. string::size_type lastPos = str.find_first_not_of(delimiter,0); // Find first "non-delimiter". string::size_type pos = str.find_first_of(delimiter,lastPos); while (string::npos != pos || string::npos != lastPos) { // Found a subStr, add it to the vector. subStrs.push_back(str.substr(lastPos,pos - lastPos)); // Skip delimiter. Note the "not_of" lastPos = str.find_first_not_of(delimiter,pos); // Find next "non-delimiter" pos = str.find_first_of(delimiter,lastPos); } } Vint getVintFromStr(const string& inStr) { Vint res; vector outStr; splitString(inStr, outStr, ","); for (int i = 0; i < outStr.size(); ++i) { int x = atoi(outStr[i].c_str()); res.push_back(x); } return res; } string getStrFromVint(const Vint& inVec) { string res(""); for (int i = 0; i < inVec.size(); ++i) { if (i > 0) res += ","; res += int2string(inVec[i]); } return res; } /******************************************************************************************** gainLoss project *********************************************************************************************/ int fromIndex2gainIndex(const int i, const int gainCategories, const int lossCategories){ int gainIndex; if(lossCategories<=gainCategories){ gainIndex = (int)floor((double)i/(lossCategories) ); } else{ gainIndex = i%(gainCategories); } return gainIndex; } int fromIndex2lossIndex(const int i, const int gainCategories, const int lossCategories){ int lossIndex; if(lossCategories<=gainCategories){ lossIndex = i%(lossCategories); } else{ lossIndex = (int)floor((double)i/(gainCategories) ); } return lossIndex; } int giveRandomState(const int alphabetSize, const int beginningState, const VVdouble &changeProbabilities) { for (int loop = 0 ; loop < 100000 ; ++loop) { MDOUBLE theRandNum = talRandom::giveRandomNumberBetweenZeroAndEntry(1.0); MDOUBLE sum = 0.0; for (int state = 0; state < alphabetSize; ++state) { sum += changeProbabilities[beginningState][state]; if (theRandNum < sum) { return state; } } } errorMsg::reportError("giveRandomState: could not give random character. The reason is unknown."); return 1; } int giveRandomState(const int alphabetSize, const Vdouble &frequencies) { for (int loop =0 ;loop<100000 ;loop++) { MDOUBLE theRandNum = talRandom::giveRandomNumberBetweenZeroAndEntry(0.999); MDOUBLE sum = 0.0; for (int j=0; j < alphabetSize;++j) { sum+=frequencies[j]; if (theRandNum0) return 1; else return -1; } MDOUBLE factorial(int x) { MDOUBLE fac = 1; for (int i=2; i<=x; i++) fac *= i; return fac; } MDOUBLE BinomialCoeff(int a, int b) { return factorial(a)/(factorial(b)*factorial(a-b)); } MDOUBLE exponentResolver(Vdouble& valuesVec){ //First find largest element in valuesVec MDOUBLE largest = VERYSMALL; int largestIndex = -1; for(int i = 0;i < valuesVec.size();++i){ if(valuesVec[i] > largest){ largest = valuesVec[i]; largestIndex = i; } } if(largestIndex == -1){ errorMsg::reportError("exponentResolver: Could not find the largest element in the input vector"); return 1; } //Now sum over all elements that are greater than -50. Note that exp(-50) is way smaller than the famous EPSILON so we are pretty safe from neglecting anything significant MDOUBLE sum = 1.0; MDOUBLE cutoff = -50; for(int i = 0;i < valuesVec.size();++i){ if(i == largestIndex) continue; if((valuesVec[i]-largest) < cutoff) continue; sum += exp(valuesVec[i]-largest); } MDOUBLE result = largest+log(sum); return(result); } MDOUBLE sumVdouble(const Vdouble & vec){ MDOUBLE sum = 0.0; for(int i = 0;i < vec.size();++i){ sum += vec[i]; } return(sum); } rate4site-3.0.0/src/phylogeny/logFile.cpp0000644011611301161130000000223312223673416015237 00000000000000// $Id: logFile.cpp 962 2006-11-07 15:13:34Z privmane $ #include "logFile.h" #include "errorMsg.h" int myLog::_loglvl = 3; ostream *myLog::_out= NULL; bool myLog::_firstTime = true; void myLog::setLog(const string logfilename, const int loglvl) { if (_out != NULL) myLog::endLog(); if ((logfilename == "-")|| (logfilename == "")) { myLog::setLogOstream(&cout); } else { ofstream* outLF = new ofstream; if (_firstTime) { outLF->open(logfilename.c_str()); _firstTime = false; } else outLF->open(logfilename.c_str(), ofstream::out | ofstream::app); // append if (!outLF->is_open()) { errorMsg::reportError(string("Can't open for writing the log file ")+logfilename); } myLog::setLogOstream(outLF); } myLog::setLogLvl(loglvl); LOG(3,<<"START OF LOG FILE"<close(); delete _out; _out = NULL; _firstTime=false; } } void myLog::printArgv(int loglvl, int argc, char *argv[]) { LOG(loglvl,<<"argv ="); for (int i=0;i err; err.push_back(" The gainLoss sequences contained the character: "); err[0]+=s; err.push_back(" gainLoss was not one of the following: "); err.push_back(" 0, 1, or for unknown '?'/'-'"); errorMsg::reportError(err); }// end of switch return -99; // never suppose to be here. }// end of function vector gainLossAlphabet::fromString(const string &str) const { vector vec; for (unsigned int i=0;i err; err.push_back("unable to print gainLoss_id. gainLossl_id was not one of the following: "); err.push_back("0,1"); errorMsg::reportError(err); }//end of switch string vRes; vRes.append(1,res); return vRes; }// end of function // There are no relations here. int gainLossAlphabet::relations(const int charInSeq, const int charToCheck) const{ if (charInSeq == charToCheck) return 1; if(charInSeq == -1 || charInSeq == -2) return 1 ;// missing data return 0; } int gainLossAlphabet::fromChar(const string& str, const int pos) const{ return fromChar(str[pos]); } rate4site-3.0.0/src/phylogeny/pijAccelerator.cpp0000644011611301161130000000034712223673416016611 00000000000000// $Id: pijAccelerator.cpp 962 2006-11-07 15:13:34Z privmane $ #include "pijAccelerator.h" pijAccelerator::~pijAccelerator(){} // this must be here. see Effective c++ page 63 (item 14, constructors, destructors, // assignment rate4site-3.0.0/src/phylogeny/replacementModel.cpp0000644011611301161130000000035712223673416017143 00000000000000// $Id: replacementModel.cpp 962 2006-11-07 15:13:34Z privmane $ #include "replacementModel.h" replacementModel::~replacementModel(){} // this must be here. see Effective c++ page 63 (item 14, constructors, destructors, // assignment rate4site-3.0.0/src/phylogeny/distribution.cpp0000644011611301161130000000063412223673417016401 00000000000000// $Id: distribution.cpp 2709 2007-11-19 14:49:21Z itaymay $ #include "distribution.h" #include "errorMsg.h" distribution::~distribution(){} // this must be here. see Effective c++ page 63 (item 14, constructors, destructors, // assignment void distribution::change_number_of_categories(int in_number_of_categories) { errorMsg::reportError("not implemented: distribution::change_number_of_categories()!"); }rate4site-3.0.0/src/phylogeny/readTree.cpp0000644011611301161130000001220312223673415015406 00000000000000// $Id: readTree.cpp 5525 2008-12-19 20:17:05Z itaymay $ #include "definitions.h" #include "errorMsg.h" #include "someUtil.h" #include "readTree.h" #include using namespace std; // forward declarations //---------------------------------------------------------------------------------------------- // about reading tree topology from files: // usually a tree topology is represented by a line like this // (((Langur:0.8,Baboon:0.55):0.3,Human:0.44):0.5,Rat:0.02,(Cow:0.2,Horse:0.04):0.03); // the syntax of such a line is (part, part, part, part) // where part is either (part,part, part, ...):distace or name:distance // or without the distance! // it should notice that the tree is unrooted. // if we look at the above file format, one can notice that the number of comas (",") is // always one less than the number of leaves (synonyms for leaves are OTUs and external nodes) // the function GetNumberOfLeaves counts the numnber of comas and returns the number of leaves. // in the example below there are 6 leaves. //******************************************************************************* // constructors //******************************************************************************* vector PutTreeFileIntoVector(istream &in) { vector tree_contents; bool endWithDotComa = false; char chTemp; while (( !in.eof()) && (tree_contents.size() < MAX_FILE_SIZE)) { in.get(chTemp); #ifdef WIN32 if (chTemp == -52) return tree_contents; //tal addition. #endif if ( !isspace( chTemp ) ) tree_contents.push_back(chTemp); if (chTemp == ';') { endWithDotComa = true; break; } } if (tree_contents.size() >= MAX_FILE_SIZE) { vector err; err.push_back("Error reading tree file. The tree file is too large"); errorMsg::reportError(err,1); // also quit the program } if (endWithDotComa == false) tree_contents.clear(); // remove junk from the last ; till the end of the file. return tree_contents; } int GetNumberOfLeaves(const vector &tree_contents) { int iCommasCounter = 0; vector::const_iterator itCurrent = tree_contents.begin(); for ( ; itCurrent != tree_contents.end(); ++itCurrent ) { if (*itCurrent==COMMA) ++iCommasCounter; } return ++iCommasCounter; //#leaves is always one more than number of comas } int GetNumberOfInternalNodes(const vector &tree_contents) { int iCloseCounter = 0; vector::const_iterator itCurrent = tree_contents.begin(); for ( ; itCurrent != tree_contents.end(); ++itCurrent ) { if (*itCurrent==CLOSING_BRACE) ++iCloseCounter; if (*itCurrent==CLOSING_BRACE2) ++iCloseCounter; } return iCloseCounter; //number of HTUs is always the number of ")" } bool verifyChar(vector::const_iterator &p_itCurrent, const char p_cCharToFind) { if ( (*p_itCurrent)==p_cCharToFind ) return true; return false; } // IsAtomicPart decides whether we will now read a taxa name (return true), // or read an OPENING_BRACE which will say us, that we will read a complicated strucure. bool IsAtomicPart(const vector::const_iterator p_itCurrent) { if ( (*p_itCurrent)==OPENING_BRACE ) return false; else if ( (*p_itCurrent)==OPENING_BRACE2 ) return false; return true; } //----------------------------------------------------------------------------- // there are 2 options for the tree format. // either (name1:0.43, name2: 0.45 , (name3 : 2 , name 4: 5) : 3.332) // or without the distances (name1, name2 , (name3 , name4) ) // here we return true if the tree file is with the distance, or false, if the tree file // has not distances. // if distances exist: after the name there will always be a colon // if distance exist, also move the iterator, to the beggining of the number //----------------------------------------------------------------------------- bool DistanceExists(vector::const_iterator& p_itCurrent) { if ((*p_itCurrent)==COLON ) { ++p_itCurrent; return true; } return false; } void clearPosibleComment(vector::const_iterator& p_itCurrent) { if ((*p_itCurrent)=='[' ) { while (*(++p_itCurrent) != ']'); ++p_itCurrent; // move over "]" } } string readPosibleComment(vector::const_iterator& p_itCurrent) { string comment = ""; if ((*p_itCurrent)=='[' ) { vector::const_iterator tmp= (p_itCurrent+1); if ((*tmp++)=='&' && (*tmp++)=='&' && (*tmp++)=='N' && (*tmp++)=='H' && (*tmp++)=='X') // see http://www.genetics.wustl.edu/eddy/forester/NHX.pdf // [&&NHX...] { p_itCurrent += 5; while (*(++p_itCurrent) != ']') { comment += *(p_itCurrent); } ++p_itCurrent; // move over "]" } else // [...] { // Skip over the text in [] ++p_itCurrent; while (*(p_itCurrent) != ']') ++p_itCurrent; ++p_itCurrent; // move over "]" } } if (comment.size()) LOG(10,<<"comment ="<::const_iterator &p_itCurrent) { string sTempNumber; for ( ; isdigit(*p_itCurrent) || (*p_itCurrent)==PERIOD || (*p_itCurrent)=='E'|| (*p_itCurrent)=='e'|| (*p_itCurrent)=='-' || (*p_itCurrent)=='+'; ++p_itCurrent) sTempNumber += (*p_itCurrent); MDOUBLE dDistance = string2double(sTempNumber); return dDistance; } rate4site-3.0.0/src/phylogeny/errorMsg.cpp0000644011611301161130000000230612223673416015457 00000000000000// $Id: errorMsg.cpp 6066 2009-04-14 19:11:10Z itaymay $ // version 1.01 // last modified 1 Jan 2004 #include "definitions.h" #include #include "errorMsg.h" #include "logFile.h" #include #include //for strerror #include //for exit() ostream *errorMsg::_errorOut= NULL; void errorMsg::reportError(const vector& textToPrint, const int exitCode) { for (int i =0 ; i < textToPrint.size() ; ++i) { LOG(1,< nucleotide::fromString(const string &str) const { vector vec; for (int i=0;i err; err.push_back(" The nucleotide sequences contained the character: "); err[0]+=s; err.push_back(" The nucleotide was not one of the following: "); err.push_back("A, C, G, T, X, -, ?"); err.push_back("a, c, g, t, x, _, *"); errorMsg::reportError(err); } return -99; } string nucleotide::fromInt(const int id) const { char x= fromIntInternal(id); string res; res.append(1,x); return res; } char nucleotide::fromIntInternal(const int in_id) const { switch (in_id) { case 0 : return 'A' ; break; case 1 : return 'C' ; break; case 2 : return 'G' ; break; case 3 : return 'T' ; break; case -1: return '-' ; break; case 4 : return 'U'; break; case 5 : return 'R'; break; case 6 : return 'Y'; break; case 7 : return 'K'; break; case 8 : return 'M'; break; case 9 : return 'S'; break; case 10 : return 'W'; break; case 11 : return 'B'; break; case 12 : return 'D'; break; case 13 : return 'H'; break; case 14 : return 'V'; break; case 15 : return 'N'; break; default: vector err; err.push_back(" unable to print nucleotide. nucleotide was not one of the following: "); err.push_back("A, C, G, T, -, ?"); err.push_back("a, c, g, t, _, *"); errorMsg::reportError(err); // make the program quit }//end of switch return '!' ; // for the lousy compiler } int nucleotide::relationsInternal(const int ctc,const int charInSeq ) const{ //ctc=charToCheck switch (charInSeq){ case 0 : if (ctc==0) return 1 ; break;// A = adenine case 1 : if (ctc==1) return 1 ; break;// C = cytosine case 2 : if (ctc==2) return 1 ; break;// G = guanine case 3 : if (ctc==3) return 1 ; break;// T = thymine case 4 : if (ctc==4) return 1 ; break; // U = uracil case 5 : if (ctc==2||ctc==0) return 1 ; break;// R = purine (same as [GA]) case 6 : if (ctc==3||ctc==1) return 1 ; break;// Y = pyrimidine (same as [TC]) case 7 : if (ctc==2||ctc==3) return 1 ; break;// K = keto (same as [GT]) case 8 : if (ctc==0||ctc==1) return 1 ; break;// M = amino (same as [AC]) case 9 : if (ctc==2||ctc==1) return 1 ; break;// S = (same as [GC]) case 10: if (ctc==0||ctc==3) return 1 ; break;// W = (same as [AT]) case 11: if (ctc==2||ctc==3||ctc==1) return 1 ; break;// B = (same as [GTC]) case 12: if (ctc==2||ctc==0||ctc==3) return 1 ; break;// D = (same as [GAT]) case 13: if (ctc==0||ctc==1||ctc==3) return 1 ; break;// H = (same as [ACT]) case 14: if (ctc==2||ctc==1||ctc==0) return 1 ; break;// V = (same as [GCA]) case 15: if (ctc==0||ctc==1||ctc==2||ctc==3) return 1 ; break;// N = any (same as [ACGT]) }; return 0; }; rate4site-3.0.0/src/phylogeny/amino.cpp0000644011611301161130000001175412223673416014771 00000000000000// $Id: amino.cpp 2414 2007-10-08 14:34:42Z adist $ #include "amino.h" //VVint amino::_relation; amino::amino() { _relation.resize(24); // relation should realy be an allocted, two dimentional array, not a vector. for (int i=0; i < _relation.size(); ++i) { // this implementation would be much faster. with some c-tricks, this checkup could be done with one access only. _relation[i].resize(20); } for (int k=-2;k<=21;++k){ for (int j=0;j<20;++j){ _relation[k+2][j]=relations_internal(k,j); } } } int amino::fromChar(const char s) const{ switch (s) { case 'A' : case'a' : return 0 ; break; case 'R' : case'r' : return 1 ; break; case 'N' : case'n' : return 2 ; break; case 'D' : case'd' : return 3 ; break; case 'C' : case'c' : return 4 ; break; case 'Q' : case'q' : return 5 ; break; case 'E' : case'e' : return 6 ; break; case 'G' : case'g' : return 7 ; break; case 'H' : case'h' : return 8 ; break; case 'I' : case'i' : return 9 ; break; case 'L' : case'l' : return 10; break; case 'K' : case'k' : return 11; break; case 'M' : case'm' : return 12; break; case 'F' : case'f' : return 13; break; case 'P' : case'p' : return 14; break; case 'S' : case's' : return 15; break; case 'T' : case't' : return 16; break; case 'W' : case'w' : return 17; break; case 'Y' : case'y' : return 18; break; case 'V' : case'v' : return 19; break; case 'B' : case'b' : return 20 ; break; // aspartate(D) or asparagine(N) case 'Z' : case'z' : return 21 ; break; // glutamate (E) or glutamine(Q) case '-' : case'_' : return -1; break; case '?' : case'*' : return -2; break; case 'x' : case'X' : return -2; break; case '.' : return -3; break; default: vector err; err.push_back(" The amino-acid sequences contained the character: "); err[0]+=s; err.push_back(" Amino acid was not one of the following: "); err.push_back(" A, B, R, N, D, C, Q, E, G, H, I, L, K, M, F, P, S, T, W, Y, V, X, Z, -, ?"); err.push_back(" a, b, r, n, d, c, q, e, g, h, i, l, k, m, f, p, s, t, w, y, v, x, z, _, *"); errorMsg::reportError(err); }// end of switch return -99; // never suppose to be here. }// end of function vector amino::fromString(const string &str) const { vector vec; for (int i=0;i err; err.push_back(" unable to print amino ac_id. amino ac_id was not one of the following: "); err.push_back("A, B, R, N, D, C, Q, E, G, H, I, L, K, M, F, P, S, T, W, Y, V, Z, -, ?"); err.push_back("a, b, r, n, d, c, q, e, g, h, i, l, k, m, f, p, s, t, w, y, v, z, _, *"); errorMsg::reportError(err); }//end of switch string vRes; vRes.append(1,res); return vRes; }// end of function int amino::relations(const int charInSeq, const int charToCheck) const{ if (charInSeq == -1) { errorMsg::reportError("gaps in the sequences. Either change gaps to ? or remove gap positions"); } return _relation[charInSeq+2][charToCheck];// <-MATAN, HERE YOU SWITHCED THE ORDER... } int amino::fromChar(const string& str, const int pos) const{ return fromChar(str[pos]); } int amino::relations_internal(const int charInSeq, const int charToCheck) const{ if (charInSeq == charToCheck) return 1; else if (charInSeq == fromChar('?')) return 1; else if ((charInSeq == fromChar('B')) && ((charToCheck == fromChar('N')) || (charToCheck == fromChar('D')))) return 1; // B is either N or D else if ((charInSeq == fromChar('Z')) && ((charToCheck == fromChar('Q')) || (charToCheck == fromChar('E')))) return 1; // Z is either E or Q return 0; } vector aminoUtility::codonOf(const int a, codon &cod){ vector codons; amino amin; string strAmino=amin.fromInt(a); map genCode=cod.geneticCode(); map ::iterator it=genCode.begin(); int tmp2=genCode.size(); while (it!=genCode.end()){ string tmp=(*it).second; if ((*it).second==strAmino){ string strCodon=(*it).first; int c=cod.fromChar(strCodon,0); codons.push_back(c); } it++; } if (codons.empty()){ cout< #include #define INITIATION_CODON "i" vector > codonUtility::_trtvDiff; vector > codonUtility::_synNonsynDiff; vector > codonUtility::_nucDiffPlace; vector > codonUtility::_nucsDiff; codon::codon(){ geneticCodeString gcs=geneticCodeHolder::nuclearStandard; init(gcs); } codon::codon(const geneticCodeString& matrixFileString){ init(matrixFileString); } void codon::init(const geneticCodeString& matrixFileString) { readMatrixFromFile(matrixFileString.Val); } void codon::readMatrixFromFile(const string& matrixFileName){ //default value: "nuclearCode.txt" // cout<<"in codon constructor"<>val; if (val.size()==1) { //amino acid if(val == INITIATION_CODON) isInitCodon = true; else{ aa++; strAmino=val; if (strAmino=="*") { _alphabetSize=noOfCodons;} isInitCodon = false; } } else if (val.size()==3 && val[0]!='#'){ //codon, # symbolizes a comment if(isInitCodon){ map ::const_iterator iniItr =_codon2Int.find(val); if(iniItr == _codon2Int.end()) errorMsg::reportError("Initiation codon with undefined index at codon::readMatrixFromFile"); else _initiationIndex2codon[iniItr->second] = val; } else{ _geneticCode[val]=strAmino; _codon2Int[val]=noOfCodons; noOfCodons++; } } else { if (noOfCodons!=64){ string err="in codon::readMatrixFromFile: total number of codons = "+int2string(noOfCodons); errorMsg::reportError(err); } return; } } } codon& codon::operator=(const codon& other) { _geneticCode = other._geneticCode; //key - codon, value - amino acid _codon2Int = other._codon2Int;//key string of codon int= integer value of codon _alphabetSize = other._alphabetSize; _initiationIndex2codon = other._initiationIndex2codon; return *this; } // codon::codon(const codon& other): // _geneticCode(other._geneticCode), //key - codon, value - amino acid // _codon2Int(other._codon2Int),//key string of codon int= integer value of codon // _alphabetSize(other._alphabetSize){} //return -99 if not succeeds. int codon::fromChar(const string& s, const int pos) const { if (s.size() <= pos+2) { //errorMsg::reportError("Trying to read a codon pass the end of the string. The number of nucleotide may not be divisible by three"); string textToPrint("Trying to read a codon pass the end of the string. The number of nucleotide may not be divisible by three"); LOG(1,<4) || (p2 >4) || (p3 >4)) return unknown(); //unknown. string strCodon=""; //change U --> T if (p1==4) strCodon+="T"; else strCodon+=toupper(s[pos]); if (p2==4) strCodon+="T"; else strCodon+=toupper(s[pos+1]); if (p3==4) strCodon+="T"; else strCodon+=toupper(s[pos+2]); //const string strCodon = s.substr(pos,3); map tmpMap=_codon2Int; map ::iterator it1; it1=tmpMap.find(strCodon); if (it1==tmpMap.end()){ string err="error in codon::fromChar cannot find codon "+strCodon; errorMsg::reportError(err); } return tmpMap[strCodon]; } vector codon::fromString(const string &str) const { vector vec; if (str.size()%3!=0) { errorMsg::reportError("error in function codon::fromString. String length should be a multiplication of 3"); } for (int i=0;i tmpMap = _codon2Int; map ::iterator it=tmpMap.begin(); while (it!=tmpMap.end()){ if ((*it).second==in_id){ return (*it).first; } it++; } string err="error in function codon::fromInt: no codon found for the integer"; errorMsg::reportError(err); return (string("we should never get here - the reportError above will exit")); } codonUtility::replacementType codonUtility::codonReplacement(const int c1, const int c2, const codon &cod){ if (c1 == c2) return codonUtility::sameCodon; else if (codonUtility::aaOf(c1,cod) == codonUtility::aaOf(c2,cod)) return codonUtility::synonymous; return codonUtility::non_synonymous; } int codonUtility::aaOf(const int c1, const codon &cod){ amino a; if (c1==cod.gap()) return a.gap(); if (c1==cod.unknown()) return a.unknown(); string strCodon=cod.fromInt(c1); map geneticCode=cod.geneticCode(); map ::iterator pos; if ((pos=geneticCode.find(strCodon)) == geneticCode.end()){ string err="error in codonUtility::aaOf: cannot find codon "+strCodon; errorMsg::reportError(err); } if (pos->second.size() > 1){ errorMsg::reportError("error in codonUtility::aaOf: amino acid 1 letter code > 1"); } return a.fromChar(*pos->second.c_str()); } codonUtility::diffType codonUtility::codonDiff(const int c1, const int c2, const codon &cod){ if (c1==c2) return codonUtility::equal; nucleotide n; string s1 = cod.fromInt(c1); string s2 = cod.fromInt(c2); int pos1 = n.fromChar(s1[0])+n.fromChar(s2[0]); int pos2 = n.fromChar(s1[1])+n.fromChar(s2[1]); int pos3 = n.fromChar(s1[2])+n.fromChar(s2[2]); if (s1[0]!=s2[0] && s1[1]!=s2[1] && s1[2]!=s2[2]) return codonUtility::threesub; if (s1[0]==s2[0] && s1[1]==s2[1] && s1[2]!=s2[2]) { if (pos3%2==0) return codonUtility::tr; else return codonUtility::tv; } if (s1[1]==s2[1] && s1[2]==s2[2] && s1[0]!=s2[0]) { if (pos1%2==0) return codonUtility::tr; else return codonUtility::tv; } if (s1[0]==s2[0] && s1[2]==s2[2] && s1[1]!=s2[1]) { if (pos2%2==0) return codonUtility::tr; else return codonUtility::tv; } if (s1[0]==s2[0] && pos2%2==0 && pos3%2==0) return codonUtility::twoTrs; if (s1[1]==s2[1] && pos1%2==0 && pos3%2==0) return codonUtility::twoTrs; if (s1[2]==s2[2] && pos1%2==0 && pos2%2==0) return codonUtility::twoTrs; if (s1[0]==s2[0] && pos2%2!=0 && pos3%2!=0) return codonUtility::twoTvs; if (s1[1]==s2[1] && pos1%2!=0 && pos3%2!=0) return codonUtility::twoTvs; if (s1[2]==s2[2] && pos1%2!=0 && pos2%2!=0) return codonUtility::twoTvs; return codonUtility::trtv; } //return the place (0, 1, or 2) that the two codons are different //and the identity of the different nucleotide in the target codon. //For example, nucDiffPlace(ATG, ACG) retruns C2 codonUtility::nucDiffPlaceType codonUtility::nucDiffPlace(const int fromCodon, const int targetCodon, const codon &cod){ if (fromCodon == targetCodon) return codonUtility::EQUAL; codonUtility::nucDiffPlaceType res = A1; nucleotide nuc; string s1 = cod.fromInt(fromCodon); string s2 = cod.fromInt(targetCodon); int diffNum = 0; if (s1[0] != s2[0]){ ++diffNum; switch (s2[0]) { case 'A': res = A1; break; case 'C': res = C1; break; case 'G': res = G1; break; case 'T': res = T1; break; default: errorMsg::reportError("error in codonUtility::nucDiffPlace."); break; } } if (s1[1] != s2[1]){ ++diffNum; switch (s2[1]) { case 'A': res = A2; break; case 'C': res = C2; break; case 'G': res = G2; break; case 'T': res = T2; break; default: errorMsg::reportError("error in codonUtility::nucDiffPlace."); break; } } if (s1[2] != s2[2]){ ++diffNum; switch (s2[2]) { case 'A': res = A3; break; case 'C': res = C3; break; case 'G': res = G3; break; case 'T': res = T3; break; default: errorMsg::reportError("error in codonUtility::nucDiffPlace."); break; } } if (diffNum == 0) errorMsg::reportError("error in codonUtility::nucDiffPlace. Can't find different nucleotide"); if (diffNum > 1) res = MUL_SUB; return res; } //return the different nucleotides between the fron and target codons. //For example, nucsPlace(ATG, ACG) retruns TC codonUtility::nucsDiffType codonUtility::nucsDiff(const int fromCodon, const int targetCodon, const codon &cod){ if (fromCodon == targetCodon) return codonUtility::SAME; codonUtility::nucsDiffType res = AC; nucleotide nuc; string s1 = cod.fromInt(fromCodon); string s2 = cod.fromInt(targetCodon); int diffNum = 0; int from = 0; int to = 0; if (s1[0] != s2[0]) { ++diffNum; from = s1[0]; to = s2[0]; } if (s1[1] != s2[1]) { ++diffNum; from = s1[1]; to = s2[1]; } if (s1[2] != s2[2]) { ++diffNum; from = s1[2]; to = s2[2]; } switch(from) { case 'A': switch(to) { case 'G':res = AG;break; case 'T':res = AT;break; case 'C':res = AC;break; default: errorMsg::reportError("error in codonUtility::nucsDiff."); break; } break; case 'G': switch(to) { case 'A':res = AG;break; case 'T':res = GT;break; case 'C':res = CG;break; default: errorMsg::reportError("error in codonUtility::nucsDiff."); break; } break; case 'C': switch(to) { case 'G':res = CG;break; case 'T':res = CT;break; case 'A':res = AC;break; default: errorMsg::reportError("error in codonUtility::nucsDiff."); break; } break; case 'T': switch(to) { case 'G':res = GT;break; case 'A':res = AT;break; case 'C':res = CT;break; default: errorMsg::reportError("error in codonUtility::nucsDiff."); break; } break; default: errorMsg::reportError("error in codonUtility::nucsDiff."); break; } if (diffNum == 0) errorMsg::reportError("error in codonUtility::nucsDiff. Can't find different nucleotide"); if (diffNum > 1) res = DIFF; return res; } void codonUtility::initSubMatrices(const codon& cod){ if ((_trtvDiff.size() == cod.size()) && (_synNonsynDiff.size() == cod.size()) && (_nucDiffPlace.size() == cod.size()) && (_nucsDiff.size() == cod.size())) return; _trtvDiff.resize(cod.size()); _synNonsynDiff.resize(cod.size()); _nucDiffPlace.resize(cod.size()); _nucsDiff.resize(cod.size()); for (int i = 0; i < _trtvDiff.size(); ++i) { _trtvDiff[i].resize(cod.size()); _synNonsynDiff[i].resize(cod.size()); _nucDiffPlace[i].resize(cod.size()); _nucsDiff[i].resize(cod.size()); } //resizeMatrix(_trtvDiff, cod.size(), cod.size()); //resizeMatrix(_synNonsynDiff, cod.size(), cod.size()); //resizeMatrix(_nucDiffPlace, cod.size(), cod.size()); for (int i = 0; i < cod.size(); ++i){ for (int j =0; j <= i; ++j){ _trtvDiff[i][j] = _trtvDiff[j][i] = codonDiff(i, j, cod); _synNonsynDiff[i][j] = _synNonsynDiff[j][i] = codonReplacement(i, j, cod); _nucDiffPlace[i][j] = nucDiffPlace(i, j, cod); _nucDiffPlace[j][i] = nucDiffPlace(j, i, cod); _nucsDiff[i][j] = nucsDiff(i,j,cod); _nucsDiff[j][i] = nucsDiff(j,i,cod); } } } //returns the number (codonCounter) and frequency (codonUsage) of each codon in the sequnece container void codonUtility::getCodonUsage(const sequenceContainer& sc, Vint& codonCounter, Vdouble& codonUsage) { if (sc.getAlphabet()->size() != 61) errorMsg::reportError("cannot calculate codon usage when alphabet is not codon"); codonCounter.resize(61, 0); codonUsage.resize(61, 0.0); codon alph; int sum = 0; for (int s = 0; s < sc.numberOfSeqs();++s) { int id = sc.placeToId(s); for (int pos = 0; pos < sc.seqLen(); ++pos) { int cod = sc[id][pos]; if (alph.isSpecific(cod)) { ++sum; ++codonCounter[cod]; } } } for (int c = 0; c < codonCounter.size(); ++c) codonUsage[c] = static_cast(codonCounter[c]) / sum; } //in codonUsageFile: only 3-letter-codon and frequency seperated by "\t" void codonUtility::readCodonUsage(const string& codonUsageFileName, Vdouble& codonUsage,const codon &alph) { codonUsage.resize(alph.size(), 0.0); ifstream inFile(codonUsageFileName.c_str()); vector inFileData; putFileIntoVectorStringArray(inFile, inFileData); inFile.close(); if (inFileData.empty()){ errorMsg::reportError("unable to open file, or file is empty in codonUtility::readCodonUsage"); } vector::const_iterator it = inFileData.begin(); for (; it!= inFileData.end(); ++it) { if (it->empty()) //empty line continue; int endCodon = it->find_first_of("\t", 0); int startFreq = it->find_first_not_of("\t ", endCodon); if (startFreq>0) { string codonStr = it->substr(0, endCodon); string freqStr = it->substr(startFreq); MDOUBLE freq = string2double(freqStr); if(freq == 0.0) freq = EPSILON; codonUsage[alph.fromChar(codonStr, 0)] = freq; } } } //calculates the CAI for the whole MSA and for each position. //The calculation is based on a pre-calculated codonUsage vector. //The calculation is based on Sharp & Li (1987) NAR, 15:1281-1295 MDOUBLE codonUtility::calcCodonAdaptationIndex(const sequenceContainer& sc, const Vdouble& codonUsage, Vdouble& cai4site) { //the returned value: calculated as the average CAI for the MSA, rather than the geometrical mean as in Sharp & Li MDOUBLE wholeAlignmentCai = 0.0; codon alph; amino am; //1. calculate Wk = the frequency of codon k relative to the frequency of the optimal codon for that amino acid. Vdouble Wk(codonUsage.size(), 0.0); int aaId; for (aaId = 0; aaId < am.size(); ++aaId) { Vint codonsOfAa = aminoUtility::codonOf(aaId, alph); //finding the most frequent codon for this aa MDOUBLE mostFrequent = 0.0; Vint::const_iterator iter; for (iter = codonsOfAa.begin(); iter != codonsOfAa.end(); ++iter) { if (codonUsage[*iter] > mostFrequent) mostFrequent = codonUsage[*iter]; } //calculating Wk for (iter = codonsOfAa.begin(); iter != codonsOfAa.end(); ++iter) Wk[*iter] = codonUsage[*iter] / mostFrequent; } //2. calculate CAI cai4site.resize(sc.seqLen(), 0.0); int pos; for (pos = 0; pos < sc.seqLen(); ++pos) { MDOUBLE cai = 0.0; int informativeCodons = 0; for (int s = 0; s < sc.numberOfSeqs();++s) { int id = sc.placeToId(s); int cod = sc[id][pos]; if(!alph.isSpecific(cod)) continue; cai += Wk[cod]; ++informativeCodons; } cai /= static_cast(informativeCodons); cai4site[pos] = cai; wholeAlignmentCai += cai; } return wholeAlignmentCai; } bool codon::isStopCodon(const int in_id) const { if (in_id == unknown()) return false; if (in_id == gap()) return false; if ((in_id >= 0 ) && (in_id < _alphabetSize)) return false; return true; } bool codon::isInitiationCodon(const int in_id) const { bool result = true; map ::const_iterator itr = _initiationIndex2codon.find(in_id); if(itr == _initiationIndex2codon.end()){ result = false; } return result; } rate4site-3.0.0/src/phylogeny/doubleRep.cpp0000644011611301161130000000260612223673415015602 00000000000000#ifdef DOUBLEREP #include "doubleRep.h" #include doubleRepMantisa::doubleRepMantisa(MDOUBLE mantissa, int expon){ _mantissa=mantissa; _expon=expon; fixParams(); } doubleRepMantisa::doubleRepMantisa(MDOUBLE a){ int answerExp; MDOUBLE answerMantissa=frexp(a,&answerExp); _mantissa=answerMantissa; _expon=answerExp; } doubleRepMantisa::doubleRepMantisa(const doubleRepMantisa& other): _mantissa(other._mantissa), _expon(other._expon) { } //make sure 0.5<=mantissa<1, as a matter of convention void doubleRepMantisa::fixParams(){ while (_mantissa>=1){ _expon++; _mantissa/=2.0; } while ((_mantissa<0.5) && (_mantissa>0)){ _expon--; _mantissa*=2.0; } while (_mantissa<=-1){ _expon++; _mantissa/=2.0; } while ((_mantissa>-0.5) && (_mantissa<0)){ _expon--; _mantissa*=2.0; } } MDOUBLE convert(const doubleRepMantisa& a){ MDOUBLE aFullRep= ldexp(a._mantissa,a._expon); return aFullRep; } //switches from base 2 to base e const MDOUBLE doubleRepMantisa::d_log() const{ static const MDOUBLE log2(log(2.0)); return log(_mantissa)+log2*_expon; } ostream& operator<<(ostream &out, const doubleRepMantisa& a){ a.output(out); // a.output0x(out); // out<>(istream &in, doubleRepMantisa& a) { MDOUBLE num; in >> num; a = num; return in; } #endif rate4site-3.0.0/src/phylogeny/evaluateCharacterFreq.cpp0000644011611301161130000001034212223673415020116 00000000000000// $Id: evaluateCharacterFreq.cpp 10474 2012-03-18 07:54:07Z itaymay $ #include "evaluateCharacterFreq.h" #include "someUtil.h" #include vector sumAlphabetCounts(const sequenceContainer & sc) { vector charFreq(sc.alphabetSize(),0.0); sequenceContainer::constTaxaIterator tIt; sequenceContainer::constTaxaIterator tItEnd; tIt.begin(sc); tItEnd.end(sc); while (tIt!= tItEnd) { sequence::constIterator sIt; sequence::constIterator sItEnd; sIt.begin(*tIt); sItEnd.end(*tIt); while (sIt != sItEnd) { if ((*sIt >= 0) && (*sIt & charFreq){ MDOUBLE sumA = 0; int i=0; for (i=0; i < charFreq.size(); ++i) { sumA+=charFreq[i] ; } for (i=0; i < charFreq.size(); ++i) { charFreq[i] /= sumA; } } void makeSureNoZeroFreqs(vector & charFreq){ // CORRECT SO THAT THERE ARE NO ZERO FREQUENCIES. // ALL FREQS THAT WERE ZERO ARE CHANGED MDOUBLE ZERO_FREQ = 0.0000000001; MDOUBLE sumB=0; int charWithZeroFreq = 0; int i=0; for (i=0; i < charFreq.size(); ++i) { if (DSMALL_EQUAL(charFreq[i], ZERO_FREQ)) { charFreq[i] = ZERO_FREQ; ++charWithZeroFreq; } else sumB +=charFreq[i]; } if (!DEQUAL(sumB, 1.0, 0.01)) { cerr.precision(10); cerr<<"sumFreq = "< evaluateCharacterFreq(const sequenceContainer & sc) { vector charFreq=sumAlphabetCounts(sc); changeCountsToFreqs(charFreq); makeSureNoZeroFreqs(charFreq); return charFreq; } VVdouble evaluateCharacterFreqOneForEachGene(const vector & scVec){ VVdouble charFreq; for (int k=0; k < scVec.size(); ++k) { charFreq.push_back(evaluateCharacterFreq(scVec[k])); } return charFreq; } vector evaluateCharacterFreqBasedOnManyGenes(const vector & scVec) { // note: all alphabets have to be the same! vector charFreq(scVec[0].alphabetSize(),0.0); for (int i=0; i < scVec.size();++i) { assert(scVec[0].getAlphabet()->size()==scVec[i].getAlphabet()->size()); vector charFreqTmp=sumAlphabetCounts(scVec[i]); for (int z=0; z < charFreq.size();++z) charFreq[z]+=charFreqTmp[z]; } changeCountsToFreqs(charFreq); makeSureNoZeroFreqs(charFreq); return charFreq; } //returns the number of each character in each position. //NOTE: returns also the number of unknown charecters in the last place in each vector, so that the actual vector size for each position is alphabetSize()+1 void getCharacterCounts(const sequenceContainer & sc, VVint& counts4pos) { const alphabet* pAlph = sc.getAlphabet(); int alphSize = sc.alphabetSize(); int pos; counts4pos.resize(sc.seqLen()); for (pos = 0; pos < sc.seqLen(); ++pos) counts4pos[pos].resize(alphSize + 1, 0); for (int seq = 0; seq < sc.numberOfSeqs();++seq) { int id = sc.placeToId(seq); for (pos = 0; pos < sc.seqLen(); ++pos) { int charType = sc[id][pos]; if (pAlph->isSpecific(charType)) { ++counts4pos[pos][charType]; } else ++counts4pos[pos][alphSize]; } } } //returns the number of different character types in each position void getCharacterType4pos(const sequenceContainer & sc, Vint& charactersType4pos) { VVint counts4Pos; getCharacterCounts(sc, counts4Pos); charactersType4pos.resize(sc.seqLen(), 0); for (int pos = 0; pos < sc.seqLen(); ++pos) { for (int c = 0; c < counts4Pos[pos].size()-1; ++c) { if (counts4Pos[pos][c] > 0) ++charactersType4pos[pos]; } } } //returns the distribution of the different character types in each position along the whole alignment void getCharacterTypeDistribution(const sequenceContainer & sc, Vint& charactersTypeDist) { Vint charactersType4pos; getCharacterType4pos(sc, charactersType4pos); charactersTypeDist.resize(sc.numberOfSeqs()+1, 0); for (int pos = 0; pos < sc.seqLen(); ++pos) { int count = charactersType4pos[pos]; ++charactersTypeDist[count]; } } rate4site-3.0.0/src/phylogeny/uniDistribution.cpp0000644011611301161130000000054012223673415017047 00000000000000// $Id: uniDistribution.cpp 2711 2007-11-19 14:49:54Z itaymay $ #include "uniDistribution.h" #include "errorMsg.h" void uniDistribution::change_number_of_categories(int in_number_of_categories) { if (in_number_of_categories != 1) errorMsg::reportError("error in uniDistribution::change_number_of_categories() - number of categories is not 1"); } rate4site-3.0.0/src/phylogeny/generalGammaDistribution.cpp0000644011611301161130000000615412223673417020645 00000000000000// $Id: generalGammaDistribution.cpp 2768 2007-11-22 12:57:44Z osnatz $ #include "generalGammaDistribution.h" #include "gammaUtilities.h" #include "errorMsg.h" #include "logFile.h" #include generalGammaDistribution::generalGammaDistribution() : _alpha(0.0), _beta(0.0), _globalRate(1.0) { _bonderi.resize(0,0); _rates.resize(0,0); _ratesProb.resize(0,0); } generalGammaDistribution::generalGammaDistribution(const generalGammaDistribution& other) : _alpha(other._alpha), _beta(other._beta), _rates(other._rates), _ratesProb(other._ratesProb), _globalRate(other._globalRate), _bonderi(other._bonderi) {} generalGammaDistribution::generalGammaDistribution(MDOUBLE alpha,MDOUBLE beta,int in_number_of_categories) : _globalRate(1.0) { setGammaParameters(in_number_of_categories,alpha,beta); } void generalGammaDistribution::setAlpha(MDOUBLE in_alpha) { if (in_alpha == _alpha) return; setGammaParameters(categories(), in_alpha, _beta); } void generalGammaDistribution::setBeta(MDOUBLE in_beta) { if (in_beta == _beta) return; setGammaParameters( categories(), _alpha, in_beta); } void generalGammaDistribution::change_number_of_categories(int in_number_of_categories) { if (in_number_of_categories == categories()) return; setGammaParameters( in_number_of_categories, _alpha, _beta); } void generalGammaDistribution::setGammaParameters(int in_number_of_categories, MDOUBLE in_alpha, MDOUBLE in_beta) { if ((in_alpha == _alpha) && (in_beta == _beta) && (in_number_of_categories == categories())) return; if (in_alpha < MINIMUM_ALPHA_PARAM) in_alpha = MINIMUM_ALPHA_PARAM;// when alpha is very small there are underflaw problems if (in_beta < MINIMUM_ALPHA_PARAM) in_beta = MINIMUM_ALPHA_PARAM;// when beta is very small there are underflaw problems _alpha = in_alpha; _beta = in_beta; _rates.clear(); _rates.resize(in_number_of_categories); _ratesProb.clear(); _ratesProb.resize(in_number_of_categories, 1.0/in_number_of_categories); _bonderi.clear(); _bonderi.resize(in_number_of_categories+1); if (in_number_of_categories==1) { _rates[0] = 1.0; return; } if (categories() > 1) { fill_mean(); return ; } } void generalGammaDistribution::fill_mean() { fill_bonderi(); int i; //for (i=0; i<=categories(); ++i) cout<(i)/categories()); } _bonderi[0]=0; _bonderi[i]=VERYBIG/10000.0;// this is becuase we multiply bondei[i] by alpha or beta, and // by this manipulation we avoid overflows...; //return 0; } const MDOUBLE generalGammaDistribution::getCumulativeProb(const MDOUBLE x) const {// //since r~gamma(alpha, beta) then beta*r~ gamma(alpha,1)=gammp //here we assume alpha=beta return gammp(_alpha, x*_beta); } rate4site-3.0.0/src/phylogeny/readDatMatrix.cpp0000644011611301161130000001757012223673416016421 00000000000000// $Id: readDatMatrix.cpp 5805 2009-01-20 09:19:26Z adido $ //#ifndef unix //#define SSTREAM_KNOWN //#endif //#ifdef SSTREAM_KNOWN #include //#else //#include //oldVersion //#endif #include #include "readDatMatrix.h" #include "errorMsg.h" #include "logFile.h" //#define VERBOS void normalizeQ(VVdouble& q, const Vdouble& freq) { MDOUBLE sum =0; int i=0,j=0; for (i=0; i < q.size(); ++i) { sum += q[i][i]*freq[i]; } assert(sum!=0); MDOUBLE oneDividedBySum = -1.0/sum; // to avoid many divisions. for (i=0; i < q.size(); ++i) { for (j=0; j < q.size(); ++j) { q[i][j] = q[i][j]*oneDividedBySum; } } } void readDatMatrixFromFile(const string & matrixFileName, VVdouble & subMatrix, Vdouble & freq) { cout<<"****readDatMatrixFromFile******"<>subMatrix[i][j]; subMatrix[j][i] = subMatrix[i][j]; } } for (i=0; i < subMatrix.size(); ++i) { in>>freq[i]; } in.close(); //check: //LOG(5,<<" priting the 5*5 top part of the sub matrix: "<>subMatrix[i][j]; subMatrix[j][i] = subMatrix[i][j]; } } for (i=0; i < alphaSize; ++i) { in>>freq[i]; } } #include "fromQtoPt.h" #include "definitions.h" #include using namespace std; void pupAll::fillMatricesFromFile(const string & dataFileString) { VVdouble sMatrix; readDatMatrixFromFile(dataFileString,sMatrix,_freq); // readDatMatrixFromString(dataFileString,sMatrix,_freq); VVdouble qMatrix = fromWagSandFreqToQ(sMatrix,_freq); q2pt q2pt1; q2pt1.fillFromRateMatrix(_freq,qMatrix); _leftEigen = q2pt1.getLeftEigen(); _rightEigen = q2pt1.getRightEigen(); _eigenVector = q2pt1.getEigenVec(); } void pupAll::fillMatricesFromFile(const string & dataFileString, const Vdouble & freq) { #ifdef VERBOS LOG(5,<<"dataFileString = "<1) || (sum<0)) return false; return true; } VVdouble fromWagSandFreqToQ(const VVdouble & s,const Vdouble& freq){ VVdouble q(s.size()); for (int z=0; z < q.size(); ++z) q[z].resize(s.size(),0.0); int i,j; MDOUBLE sum; for ( i=0; i < s.size(); ++i) { sum =0; for (j=0; j < s.size(); ++j) { if (i!=j) q[i][j] = s[i][j]* freq[j]; sum += q[i][j]; } q[i][i] = -sum; } // normalizing q: normalizeQ(q,freq); // check: //sum =0; //for (i=0; i < s.size(); ++i){ // sum += q[i][i]*freq[i]; //} //LOG(5,<<" SUM OF DIAGOPNAL Q IS (should be -1) "< #include chebyshevAccelerator::chebyshevAccelerator(const chebyshevAccelerator& other): _alphabetSize(other._alphabetSize), _totalNumOfCoef(other._totalNumOfCoef), _usingNumberOfCoef(other._usingNumberOfCoef), _pb(NULL), _rightRange(other._rightRange), _leftRange(other._leftRange){ if (other._pb != NULL) _pb = other._pb->clone(); chebi_coff=other.chebi_coff; chebi_dervation_coff=other.chebi_dervation_coff; chebi_sec_dervation_coff=other.chebi_sec_dervation_coff; } chebyshevAccelerator::chebyshevAccelerator( replacementModel* pb, const int alphanetSize, const int totalNumOfCoef, const int usingNumberOfCoef, const MDOUBLE rightRange, const MDOUBLE leftRange ): _alphabetSize(alphanetSize), _totalNumOfCoef(totalNumOfCoef), _usingNumberOfCoef(usingNumberOfCoef),_pb(pb->clone()), _rightRange(rightRange), _leftRange(leftRange) //---------------------------------------------------------------------------------- //input: non //output: non //doing: filling the member chebi_coff[][][]; chebi_coff[1][2][4] is the forth // chebichev coefficient in the chebichev polynom of the function // slow_pij(1,2,t); //---------------------------------------------------------------------------------- { int tmp, tmp1; for (tmp = 0; tmp < _alphabetSize ; tmp ++) { chebi_coff.resize(_alphabetSize); chebi_dervation_coff.resize(_alphabetSize); chebi_sec_dervation_coff.resize(_alphabetSize); for (tmp1 = 0; tmp1 < _alphabetSize ; tmp1 ++) { chebi_coff[tmp].resize(_alphabetSize); chebi_dervation_coff[tmp].resize(_alphabetSize); chebi_sec_dervation_coff[tmp].resize(_alphabetSize); for (tmp1 = 0; tmp1 < _alphabetSize ; tmp1 ++) { chebi_coff[tmp][tmp1].resize(_totalNumOfCoef); chebi_dervation_coff[tmp][tmp1].resize(_totalNumOfCoef); chebi_sec_dervation_coff[tmp][tmp1].resize(_totalNumOfCoef); } } } Vdouble coffij(_totalNumOfCoef); Vdouble coffij_of_derviation(_totalNumOfCoef); Vdouble coffij_of_second_derivation(_totalNumOfCoef); for (int from_aa =0; from_aa<_alphabetSize ; ++ from_aa) { for (int to_aa =0; to_aa<_alphabetSize ; ++ to_aa) { chebft(coffij,_totalNumOfCoef,from_aa,to_aa); chder(coffij,coffij_of_derviation,_totalNumOfCoef); chder(coffij_of_derviation,coffij_of_second_derivation,_totalNumOfCoef); for (int tmp=0; tmp<_totalNumOfCoef;++tmp) { chebi_coff[from_aa][to_aa][tmp] = coffij[tmp]; chebi_dervation_coff[from_aa][to_aa][tmp] = coffij_of_derviation[tmp]; chebi_sec_dervation_coff[from_aa][to_aa][tmp] = coffij_of_second_derivation[tmp]; } } } } void chebyshevAccelerator::chebft(Vdouble& c, int n, int from_aa, int to_aa) { //---------------------------------------------------------------------------------- //input: c[] is the vector where the cofficient will be // from aa and to_aa are for chosing the right function to be developed //output: non //doing: calculating the chebichev coefficient in the chebichev polynom of the function // slow_pij(from_aa,to_aa,t), and put them in the c[] vector //---------------------------------------------------------------------------------- int k,j; MDOUBLE fac,bpa,bma; Vdouble f; f.resize(n); bma=0.5*(_rightRange-_leftRange); bpa=0.5*(_rightRange+_leftRange); for (k=0;kPij_t(from_aa,to_aa,y*bma+bpa); //(*func)(y*bma+bpa); } fac=2.0/n; for (j=0;j 0.0) { return _pb->Pij_t(from_aa,to_aa,x); // errorMsg::reportError("x not in range in routine fast_Pij_t");// also quit the program } y2=2.0*(y=(2.0*x-_leftRange-_rightRange)/(_rightRange-_leftRange)); for (j=_usingNumberOfCoef;j>0;j--) { sv=d; d=y2*d-dd+chebi_coff[from_aa][to_aa][j]; dd=sv; } check = y*d-dd+0.5*chebi_coff[from_aa][to_aa][0]; if ((check>1) || (check<=0)) check = _pb->Pij_t(from_aa,to_aa,x); assert(check<=1); assert(check>=0); return check; } const MDOUBLE chebyshevAccelerator::dPij_dt(const int from_aa, const int to_aa, const MDOUBLE x) const //---------------------------------------------------------------------------------- //input: like pij_t //output: the derivation of probabilty //doing: calculating with the polinom of chebi and via eigenvalue decomposition //---------------------------------------------------------------------------------- { MDOUBLE d=0.0,dd=0.0,sv,y,y2; int j; if ((x-_leftRange)*(x-_rightRange) > 0.0) { return _pb->dPij_dt(from_aa,to_aa,x); } y2=2.0*(y=(2.0*x-_leftRange-_rightRange)/(_rightRange-_leftRange)); for (j=_usingNumberOfCoef;j>0;j--) { sv=d; d=y2*d-dd+chebi_dervation_coff[from_aa][to_aa][j]; dd=sv; } return y*d-dd+0.5*chebi_dervation_coff[from_aa][to_aa][0]; } const MDOUBLE chebyshevAccelerator::d2Pij_dt2(const int from_aa, const int to_aa, const MDOUBLE x) const { //---------------------------------------------------------------------------------- //input: like pij_t //output: the second derivation of the probabilty //doing: calculating with the polynom of chebi and via eigenvalue decomposition //---------------------------------------------------------------------------------- MDOUBLE d=0.0,dd=0.0,sv,y,y2; int j; if ((x-_leftRange)*(x-_rightRange) > 0.0) { return _pb->d2Pij_dt2(from_aa,to_aa,x); } y2=2.0*(y=(2.0*x-_leftRange-_rightRange)/(_rightRange-_leftRange)); for (j=_usingNumberOfCoef;j>0;j--) { sv=d; d=y2*d-dd+chebi_sec_dervation_coff[from_aa][to_aa][j]; dd=sv; } return y*d-dd+0.5*chebi_sec_dervation_coff[from_aa][to_aa][0]; } void chebyshevAccelerator::chder(Vdouble &c, Vdouble &cder, int n) { //---------------------------------------------------------------------------------- //input: chebicev coff of f(x) i.e. in c[]. n is the vector size //output: chebicev coff of df(x)/dx i.e. in cder[] //doing: calculating the coff of the dervation from the coff of f. //reference:numercal recepies in c, pg 195. //---------------------------------------------------------------------------------- int j; MDOUBLE con; cder[n-1]=0.0; cder[n-2]=2*(n-1)*c[n-1]; for (j=n-3;j>=0;j--) cder[j]=cder[j+2]+2*(j+1)*c[j+1]; con=2.0f/(_rightRange-_leftRange); for (j=0;j using namespace std; #include //#define VERBOS void q2pt::fillFromRateMatrix(const vector& freq, const VVdouble & qMatrix) { // we first decompose Q to (F^0.5) M (F^-0.5) // F is a diagonal matrix of the frequencies // M is the symetrical matrix representation of Q. VVdouble q_sym; const int matrix_size = qMatrix.size(); q_sym.resize(matrix_size); int k=0; for (k=0; k < q_sym.size(); ++k) q_sym[k].resize(matrix_size); calc_symmetric_q(qMatrix,q_sym,freq); // now we have to find the eigen-vector decomposition of the q_sym. VVdouble v; // v is the eigen vectors of the symetrical matrix. v.resize(matrix_size); for (k=0; k < qMatrix.size(); ++k) v[k].resize(matrix_size); Vdouble eigenValues(matrix_size); // symmetric_1pam = [v] [eigenValues] [transpose(v)] //MyJacobi(q_sym,v, eigenValues); // notice that inv([v]) = [v] transpose; /////i changed computeEigenSystem(q_sym,v,eigenValues); //// //#ifdef VERBOS // LOG(5,<<"The eigen-vector matrix of the decomposition of the symetric matrix\n"); // for (int k1=0; k1 < v.size(); ++k1) { // for (int k2=0; k2& freq,const VVdouble & onePam) { fillFromRateMatrix(freq,onePam); for (int i=0; i < _eigenVector.size(); ++i) { assert(_eigenVector[i]>0); _eigenVector[i] = log(_eigenVector[i])* 100; } } bool q2pt::currectFloatingPointProblems(MDOUBLE& sum) const { if ((sum * (sum+err_allow_for_pijt_function))<0) sum=0; if (((sum-1) * (sum-1.0-err_allow_for_pijt_function))<0) sum=1; if (!((sum<=1) && (sum>=0))) return false; return true; } // Pij(t) = Sigma[k]{ [V]ik * [V^-1]kj * e^(Lamda_k*t) } const MDOUBLE q2pt::Pij_t(const int i, const int j, const MDOUBLE t) const { if (t<0) errorMsg::reportError("negative length in routine Pij_t"); // if ((_freq[i] == 0.0) || (_freq[j] == 0.0)) return 0.0; MDOUBLE sum=0; for (int k=0 ; k<_eigenVector.size() ; ++k) { sum+=( _leftEigen[i][k]*_rightEigen[k][j]*exp(_eigenVector[k]*t) ); } if (currectFloatingPointProblems(sum)) return sum; // LOG(1,<<"err Pij_t i="<>lll; } VVdouble get1PamFromCountMatrix(const vector& freq, const VVdouble & sub_matrix){ //---------------------------------------------------------------------------------- //input: pam1 : a pointer to the matrix where pam1 will be. // sub_matrix: the substitution matrix // freq vector: the amino acid's frequenceis. //output: non //doing: fill in 1 pam from sub matrix and freq vector //calculation: sub_matrix[a][b] is the substitution matrix, between a and b // (sub_matrix[a][b]=sub_matrix[b][a]) // we use f[a][b] insted of sub_matrix[a][b] to be the same as the book //(reference) "introduction to computational molecular biology by setubal and meidanis pg 80; // let f[a] be sigma f[a][b] on all b (we made f[a][a] = 0;) // i.e. f[a] is the number of mutation from a observed // let f be sigma f[a] on all a; (=the total mutations*2) // now, the mutaibility of a is defined as // // (1) m[a] = f[a] / (100*f*freq[a]) // // 100*f is a scaling factor for 1 pam. // then pam1[a][b] will be pr(a->b/a changed) * pr(a changed) // // (2) pam1[a][b] = (f[a][b]/f[a])*m[a] // // (3) f[a][a] = 1-m[a] (easy to show) // // notice that sigma 1pam[a][b] over all b is 1 and that // sigma freq[a]*1pam[a][a] over all a is 0.99 //---------------------------------------------------------------------------------- const int _alphabetSize=sub_matrix.size(); VVdouble pam1; pam1.resize(_alphabetSize); for (int z=0; z < _alphabetSize; ++z) { pam1[z].resize(_alphabetSize,0); } int i,j;//indices MDOUBLE total=0; // i.e.f in the above explanation for (i=0;i<_alphabetSize;++i) { for (j=0; j<_alphabetSize; ++j){ total+=sub_matrix[i][j]; } } MDOUBLE tmsum; for (i=0;i<_alphabetSize;++i) { tmsum = 0.0; for (j=i+1; j<_alphabetSize; ++j){ if ((freq[i] == 0.0) || (freq[j] == 0.0)) { pam1[i][j] = 0.0;pam1[j][i] = 0.0; } else { pam1[i][j] = sub_matrix[i][j]/(100.0*total*freq[i]); pam1[j][i] = sub_matrix[i][j]/(100.0*total*freq[j]); } } } for (i=0;i<_alphabetSize;++i) { tmsum = 0.0; for (j=0;j<_alphabetSize;++j) { if (j!=i) tmsum += pam1[i][j]; } if (freq[i] != 0.0) { pam1[i][i]=1.0-tmsum; } } #ifdef VERBOS LOG(5,<<" priting the 4*4 top-left corner of the 1pam matrix * 10^6 "<& names, const vector * weights){ res.resize(sc.numberOfSeqs()); for (int z=0; z< sc.numberOfSeqs();++z) res[z].resize(sc.numberOfSeqs(),0.0); for (int i=0; i < sc.numberOfSeqs();++i) { for (int j=i+1; j < sc.numberOfSeqs();++j) { res[i][j] = dis->giveDistance(sc[sc.placeToId(i)],sc[sc.placeToId(j)],weights,NULL); //LOG(5,<<"res["< #include #include using namespace std; //------------------------------------------ // general outline: // we follow Swofford's book, "Molecular Systematics" pg489. // currentNodes is the vector of the nodes that are "in process". // in the beggining, these are all the leaves. Once, 2 leaves are separeted, // they are excluded from currentNodes, and their father is added to currentNodes. // we (almost) finish the algorithm when currentNodes's size is 3. (i.e., we know the topology). // thus when we start from an evolutionary tree, all we do, is to construct a star (start) tree //------------------------------------------ //------------------------------------------ // constructor and start //------------------------------------------ tree NJalg::computeTree(VVdouble distances,const vector& names, const tree * const constriantTree /*= NULL*/){ assert(distances.size() == names.size()); tree resTree = startingTree(names); if (distances.size()<3) return resTree; vector currentNodes; resTree.getAllLeaves(currentNodes,resTree.getRoot()); if (constriantTree) { njConstraint njc(resTree, *constriantTree); while (currentNodes.size() >= 3) NJiterate(resTree,currentNodes,distances, njc); } else { while (currentNodes.size() >= 3) NJiterate(resTree,currentNodes,distances); } resTree.create_names_to_internal_nodes(); resTree.makeSureAllBranchesArePositive(); LOGDO(5,resTree.output(myLog::LogFile())); return resTree; } tree NJalg::startingTree(const vector& names) { return starTree(names); } tree NJalg::startingTree(const tree& inTree) { tree et; et.createRootNode(); vector allLeaves; inTree.getAllLeaves(allLeaves,inTree.getRoot()); vector names(allLeaves.size()); for (int k = 0 ; k < allLeaves.size(); ++k) names[k]=allLeaves[k]->name(); return startingTree(names); } void NJalg::updateBranchDistance(const VVdouble& distanceTable, const Vdouble& rValues, tree::nodeP nodeNew, tree::nodeP nodeI, tree::nodeP nodeJ, int Iplace, int Jplace) { MDOUBLE dis= (IplacesetDisToFather(DisI_new); nodeJ->setDisToFather(DisJ_new); } void NJalg::NJiterate(tree& et, vector& currentNodes, VVdouble& distanceTable) { Vdouble rVector = calc_r_values(currentNodes,distanceTable);//CHECK2 if (currentNodes.size() == 3) { update3taxaLevel(distanceTable,rVector,currentNodes); currentNodes.clear(); return; } int minRaw,minCol; calc_M_matrix(currentNodes,distanceTable,rVector,minRaw,minCol);//CHECK3 tree::nodeP nodeI = currentNodes[minRaw]; tree::nodeP nodeJ = currentNodes[minCol]; tree::nodeP theNewNode; theNewNode= SeparateNodes(et,nodeI,nodeJ); //CHECK4 updateBranchDistance(distanceTable,rVector,theNewNode,nodeI,nodeJ,minRaw,minCol); //CHECK6 et.create_names_to_internal_nodes(); UpdateDistanceTableAndCurrentNodes(currentNodes,distanceTable,nodeI,nodeJ,theNewNode,minRaw,minCol); } void NJalg::NJiterate(tree& et, vector& currentNodes, VVdouble& distanceTable, njConstraint& njc) { Vdouble rMatrix = calc_r_values(currentNodes,distanceTable);//CHECK2 if (currentNodes.size() == 3) { update3taxaLevel(distanceTable,rMatrix,currentNodes); currentNodes.clear(); return; } int minRaw,minCol; calc_M_matrix(currentNodes,distanceTable,rMatrix,minRaw,minCol, njc);//CHECK3 tree::nodeP nodeI = currentNodes[minRaw]; tree::nodeP nodeJ = currentNodes[minCol]; tree::nodeP theNewNode; theNewNode= SeparateNodes(et,nodeI,nodeJ); njc.join(nodeI, nodeJ, theNewNode); //CHECK4 updateBranchDistance(distanceTable,rMatrix,theNewNode,nodeI,nodeJ,minRaw,minCol); //CHECK6 et.create_names_to_internal_nodes(); UpdateDistanceTableAndCurrentNodes(currentNodes,distanceTable,nodeI,nodeJ,theNewNode,minRaw,minCol); LOGDO(15,et.output(myLog::LogFile(),tree::ANCESTORID)); } Vdouble NJalg::calc_r_values(vector& currentNodes, const VVdouble& distanceTable) { Vdouble r_values(currentNodes.size(),0.0); for (int i=0; i & currentNodes, const VVdouble& distanceTable, const Vdouble & r_values, int& minRaw,int& minCol){ MDOUBLE min = VERYBIG; for (int i=0; i < currentNodes.size();++i){ for (int j =i+1; j < currentNodes.size();++j) { MDOUBLE dis= (i& currentNodes, const VVdouble& distanceTable, const Vdouble & r_values, int& minRaw,int& minCol, const njConstraint& njc){ MDOUBLE min = VERYBIG; MDOUBLE min_noc = VERYBIG; int minRaw_noc=-1,minCol_noc=-1; for (int i=0; i < currentNodes.size();++i){ for (int j =i+1; j < currentNodes.size();++j) { if (njc.isCompatible(currentNodes[i],currentNodes[j])) { MDOUBLE dis= (iname()<<","<name() <<"-> " << currentNodes[minRaw] ->name()<<","<name()<< " ("<father() != node2->father()) errorMsg::reportError(" error in function NJalg::SeparateNodes - nodes don't have the same father"); tree::nodeP fatherNode = node1->father(); tree::nodeP theNewNode = et.createNode(fatherNode,et.getNodesNum()); node1->setFather(theNewNode); theNewNode->setSon(node1); node2->setFather(theNewNode); theNewNode->setSon(node2); // remove from son list of father node. fatherNode->removeSon(node1); fatherNode->removeSon(node2); return theNewNode; } void NJalg::update3taxaLevel(VVdouble& distanceTable,Vdouble & r_values, vector& currentNodes) { // update the distance of the 3 taxa that are left in the end, to the root. MDOUBLE dis0root = distanceTable[0][1]/2+0.5*(r_values[0]-r_values[1]); MDOUBLE dis1root = distanceTable[0][1]/2+0.5*(r_values[1]-r_values[0]); MDOUBLE dis2root = distanceTable[0][2]/2+0.5*(r_values[2]-r_values[0]); if (dis0rootsetDisToFather(dis0root); currentNodes[1]->setDisToFather(dis1root); currentNodes[2]->setDisToFather(dis2root); } void NJalg::UpdateDistanceTableAndCurrentNodes(vector& currentNodes, VVdouble& distanceTable, tree::nodeP nodeI, tree::nodeP nodeJ, tree::nodeP theNewNode, int Iplace, int Jplace) { // Iplace is the place of i in the "old" currentNodes vector int i,j; // updating currentNodes vector newCurrentNode= currentNodes; vector::iterator vec_iter1=remove( newCurrentNode.begin(),newCurrentNode.end(),nodeI ); newCurrentNode.erase(vec_iter1,newCurrentNode.end()); vector::iterator vec_iter2=remove( newCurrentNode.begin(),newCurrentNode.end(),nodeJ ); newCurrentNode.erase(vec_iter2,newCurrentNode.end()); newCurrentNode.push_back(theNewNode); map nodeIntMap1; for (int z=0; z::value_type(currentNodes[z],z)); } VVdouble newDisTable; newDisTable.resize(newCurrentNode.size()); for (int z1=0;z1 * weights) { VVresize(_startingDistanceTable,distanceTable.size(),distanceTable.size());// for printing stuff later. VVresize(LTable,distanceTable.size(),distanceTable.size());// for printing stuff later. int i,j; _nodeNames.resize(currentNodes.size()); for ( i=0; i < currentNodes.size(); i++) { _nodeNames[i] =(currentNodes[i]->name()); for ( j=i+1; j < currentNodes.size(); j++) { MDOUBLE tempDis = -2000.0; MDOUBLE resLikelihood; int seqnodeI_ID = sd.getId(currentNodes[i]->name()); int seqnodeJ_ID = sd.getId(currentNodes[j]->name()); const sequence& snodeI = *sd.getSeqPtr(seqnodeI_ID,true); const sequence& snodeJ = *sd.getSeqPtr(seqnodeJ_ID,true); tempDis = _cd->giveDistance(snodeI,snodeJ,weights,&resLikelihood); distanceTable[i][j] = tempDis; LTable[i][j] = resLikelihood; } } if (myLog::LogLevel()>4) { for (i=0; i < currentNodes.size(); i++) { for (j=i+1; j < currentNodes.size(); j++) { LOG(100,<<"nj distance ["<4) { // for (i=0; i < currentNodes.size(); i++) { // for (j=i+1; j < currentNodes.size(); j++) { // LOG(4,<<"nj likelihood for distance["<name()<<" = "<SetName(htuname); //CHECK5 //_myET->getRoot()->SetName("RootOfStar"); //CHECK6 // et.output(cout,et.getRoot(),tree::ANCESTOR); */ rate4site-3.0.0/src/phylogeny/njConstrain.cpp0000644011611301161130000001135212223673416016150 00000000000000// $Id: njConstrain.cpp 962 2006-11-07 15:13:34Z privmane $ #include "definitions.h" #include #include "njConstrain.h" #include "logFile.h" njConstraint::njConstraint(const tree& starttree, const tree& constraintTree):_cTree(constraintTree), _interTreeMap(){ vector currentNodes; starttree.getAllLeaves(currentNodes,starttree.getRoot()); vector constraintNodes; _cTree.getAllLeaves(constraintNodes,_cTree.getRoot()); assert(currentNodes.size()==constraintNodes.size()); map name2Node; for (vector::iterator vec_iter=constraintNodes.begin();vec_iter!=constraintNodes.end();++vec_iter){ // name2Node[test];//=*vec_iter; name2Node[(*vec_iter)->name()]=*vec_iter; } for (vector::iterator vec_iter2=currentNodes.begin();vec_iter2!=currentNodes.end();++vec_iter2){ assert(name2Node.find((*vec_iter2)->name()) != name2Node.end()); // cant find the taxa in the constratin tree! _interTreeMap[*vec_iter2]=name2Node[(*vec_iter2)->name()]; } } bool njConstraint::isCompatible(const tree::nodeP& n1, const tree::nodeP& n2, const bool verbose) const { bool compatible; assert( _interTreeMap.find(n1) != _interTreeMap.end()); // cant find the taxa in the map! assert( _interTreeMap.find(n2) != _interTreeMap.end()); // cant find the taxa in the map! tree::nodeP s1=_interTreeMap.find(n1)->second; tree::nodeP s2=_interTreeMap.find(n2)->second; if (s1==_cTree.getRoot()) { // we are asking undirected questions from a directed tree compatible = (s2 != _cTree.getRoot()) && (s2->father() != _cTree.getRoot()) && (s2->father()->father() == _cTree.getRoot()); if (verbose) LOG(11,<<"isCompatible - s1 is root"<father() != _cTree.getRoot()) && (s1->father()->father() == _cTree.getRoot()); if (verbose) LOG(11,<<"isCompatible - s2 is root"<father()==s2->father()); } if (verbose) LOG(11,<<"isCompatible:" <name()<<" + "<name()<<"-->" <father()==s2->father()); // we can only do this if both nodes have same father LOG(10,<name()<<" and "<name()<father(); if (fatherNode->getNumberOfSons()==2) { // fatherNode->sons.clear(); return (fatherNode); // no splitting needed } if (s1->father()==t.getRoot() && t.getRoot()->getNumberOfSons()==3) { // no split needed, but the root needs to change LOG(10,<<"************************* spacial case of constratin join"<name()<<" and "<name()<father()->name()<<" and father "<father()->name()<father(); for (int i=0; i<3; ++i) if (t.getRoot()->getSon(i)!= s1 && t.getRoot()->getSon(i)!= s2){ t.rootAt(t.getRoot()->getSon(i)); LOGDO(10,t.output(myLog::LogFile(),tree::ANCESTORID)); LOG(10,<setSon(s1); newNode->setSon(s2); newNode->claimSons(); int k = fatherNode->getNumberOfSons(); fatherNode->removeSon(s1); fatherNode->removeSon(s2); assert (k=fatherNode->getNumberOfSons()+2); // both s1 and s2 should have been skiped // fatherNode->sons.resize(k); t.updateNumberofNodesANDleaves(); t.create_names_to_internal_nodes(); return(newNode); } void njConstraint::join(const tree::nodeP& n1, const tree::nodeP& n2, const tree::nodeP& newFather) { assert(_interTreeMap.find(n1) != _interTreeMap.end()); // cant find the taxa in the map! assert(_interTreeMap.find(n2) != _interTreeMap.end()); // cant find the taxa in the map! assert(_interTreeMap.find(newFather) == _interTreeMap.end()); // should not find the new father in the map! assert(isCompatible(n1,n2)); // tree::nodeP origFather=_interTreeMap.find(n1)->father(); // do tree things LOG(10,<name()<<" AND "<name()< #include #ifndef VERBOS #define VERBOS #endif void validateSym(VVdouble & v) { const MDOUBLE epsilon = 0.00000001; for (int i=0; i < v.size(); ++i) { for (int j=i+1; j < v.size(); ++j) { if (fabs(v[i][j] - v[j][i])> epsilon) { LOG(5,<<"v["<3 && (fabs(d[ip]+g) == fabs(d[ip])) && (fabs(d[iq]+g)==fabs(d[iq])))==false) { LOG(5,<<"g is small: "<3 && (fabs(d[ip]+g) == fabs(d[ip])) && (fabs(d[iq]+g)==fabs(d[iq])) ) { a[ip][iq] = 0.0; } else if (fabs(a[ip][iq]) > tresh) { MDOUBLE h; MDOUBLE t; MDOUBLE theta; h = d[iq]-d[ip]; // assert(h!=0); if (fabs(h) + g == fabs(h)) { assert(h!=0); t = a[ip][iq] / h; } else { theta = 0.5*h/(a[ip][iq]); t = 1.0 / (fabs(theta)+sqrt(1.0+theta*theta)); if (theta<0.0) t = -t; } MDOUBLE c,s; c = 1.0 / sqrt(1.0+t*t); s = t*c; MDOUBLE tau; tau = s/ (1.0 + c); h = t * a[ip][iq]; d[ip] = d[ip] - t * a[ip][iq]; d[iq] = d[iq] + t * a[ip][iq]; a[ip][iq]=0.0; MDOUBLE tmp1, tmp2; for (j = 0; j < ip; ++j) { tmp1 = a[j][ip] - s*(a[j][iq]+a[j][ip]*tau); // updating the above element of a... tmp2 = a[j][iq] + s*(a[j][ip]-a[j][iq]*tau); a[j][ip] = tmp1; a[j][iq] = tmp2; } for (j = ip+1;j tresh)" } // end of for (iq = ... } // end of for (ip = ... } // end of for (i = 0; i< MaxNumberOfSweeps ; ++i) { vector err; err.push_back("problems in function MyJacobi. more than MaxNumberOfSweeps were necessary."); errorMsg::reportError(err); return -1; } //end of function /////////////////////////////////////////// //Adi cahnges ////////////////////////// ///////////////////////////////////////// MDOUBLE sign(MDOUBLE a,MDOUBLE b){ return (b>0?fabs(a):-fabs(a)); } MDOUBLE pythag(const MDOUBLE a, const MDOUBLE b){ return sqrt(pow(a,2)+pow(b,2)); } void houseHolder(VVdouble &mat,VVdouble &Q){ MDOUBLE sigma=0,H,sqrtSigma,K=0,tmp; int c,r,j,i,n = mat.size(); Q.resize(n); for(i=0;i1;i--){ sigma=0; //init sigma K=0; //init K for(j=0;j=0.0 ? sqrt(sigma) : -sqrt(sigma); //compute sqrt of sigma +/- H=sigma+mat[i][i-1]*sqrtSigma; //comute H = 0.5*|u|^2. until here O(n) /***createing U*******/ for(r=0;r=i. u[r]=0.0; /***********************/ for(r=0;rAU/H } for(r=0;r0;i--) { l=i-1; h=scale=0.0; if (l > 0) { for (k=0;k= 0.0 ? -sqrt(h) : sqrt(h)); e[i]=scale*g; h -= f*g; a[i][l]=f-g; f=0.0; for (j=0;j=l;i--) { f=s*e[i]; b=c*e[i]; e[i+1]=(r=pythag(f,g)); if (r == 0.0) { d[i+1] -= p; e[m]=0.0; break; } s=f/r; c=g/r; g=d[i+1]-p; r=(d[i]-g)*s+2.0*c*b; d[i+1]=g+(p=s*r); g=c*r-b; // Next loop can be omitted if eigenvectors not wanted for (k=0;k= l) continue; d[l] -= p; e[l]=g; e[m]=0.0; } } while (m != l); } } */ //called if tred2 was used - the original QL implementation from numerical recepies void QL(Vdouble &d, Vdouble &e, VVdouble &z){ int m,l,iter,i,k; MDOUBLE s,r,p,g,f,dd,c,b; int n=d.size(); for(i=1;i=l;i--){ f=s*e[i]; b=c*e[i]; e[i+1]=(r=pythag(f,g)); if(r==0.0){ d[i+1]-=p; e[m]=0.0; break; } s=f/r; c=g/r; g=d[i+1]-p; r=(d[i]-g)*s+2.0*c*b; d[i+1]=g+(p=s*r); g=c*r-b; for(k=0;k=l) continue; d[l]-=p; e[l]=g; e[m]=0.0; } } while(m!=l); } } /************************************************************************/ //diaganol will be eigen values and fill matrix of eigen vectors. */ /************************************************************************/ //A modified implementation for eigen analysis, using the house holder function. /* void computeEigenSystem(VVdouble &symmetricMatrix,VVdouble &eigenVectros,Vdouble &diagonal){ houseHolder(symmetricMatrix,eigenVectros); Vdouble offdiagonal; offdiagonal.resize(symmetricMatrix.size()); for (int i=0; i distance) distance = dt; fo = fn; } en = sqrt(en); pVal = computeProbForKS((en+0.12+0.11/en)*distance); return pVal; } // function called only by performKSTest MDOUBLE computeProbForKS (const MDOUBLE QsParam) { const MDOUBLE EPS1 = 1.0e-6,EPS2 = 1.0e-16; int j; MDOUBLE a2,fac = 2.0, sum = 0.0, term, termbf = 0.0; a2 = -2.0*QsParam*QsParam; for(j = 1; j <= 100; ++j){ term = fac*exp(a2*j*j); sum += term; if(fabs(term) <= EPS1*termbf || fabs(term) <= EPS2*sum) return sum; fac = -fac; termbf = fabs(term); } return 1.0; //get here only by failing to converge } rate4site-3.0.0/src/phylogeny/uniformDistribution.cpp0000644011611301161130000000355412223673415017743 00000000000000// $Id: uniformDistribution.cpp 2712 2007-11-19 14:50:12Z itaymay $ #include "uniformDistribution.h" uniformDistribution::uniformDistribution(const int numOfCategories, MDOUBLE lowerBound, MDOUBLE upperBound) :distribution() { _globalRate=1.0; setUniformParameters(numOfCategories, lowerBound, upperBound); } //copy constructor uniformDistribution::uniformDistribution(const uniformDistribution& other) : _rates(other._rates), _ratesProb(other._ratesProb), _globalRate(other._globalRate), _interval(other._interval), _upperBound(other._upperBound), _lowerBound(other._lowerBound) { } void uniformDistribution::setUniformParameters(const int number_of_categories, MDOUBLE lowerBound, MDOUBLE upperBound){ _upperBound = upperBound; _lowerBound = lowerBound; _interval = ((upperBound - lowerBound) / (number_of_categories+0.0)); _rates.clear(); _rates.resize(number_of_categories); _ratesProb.erase(_ratesProb.begin(),_ratesProb.end()); _ratesProb.resize(number_of_categories, 1.0/number_of_categories); //setting _rates[i] as the middle value of each category for (int i = 0; i < number_of_categories; ++i) { _rates[i] = _lowerBound + (_interval * (i + 0.5)); } } //returns the ith border between categories //getBorder(0) = _lowerBound, getBorder(categories()) = _upperBound MDOUBLE uniformDistribution::getBorder(int i) const { return (i == categories()) ? _upperBound : (_rates[i] - (_interval/2)); } const MDOUBLE uniformDistribution::getCumulativeProb(const MDOUBLE x) const { if (x<_lowerBound) return 0; else if (x>= _upperBound) return 1; else return ((x-_lowerBound) / (_upperBound - _lowerBound)); } void uniformDistribution::change_number_of_categories(int in_number_of_categories) { if (in_number_of_categories == categories()) return; setUniformParameters(in_number_of_categories, _lowerBound, _upperBound); } rate4site-3.0.0/src/phylogeny/computePijComponent.cpp0000644011611301161130000000576212223673415017671 00000000000000 // $Id: computePijComponent.cpp 9253 2011-01-31 01:37:21Z rubi $ #include "definitions.h" #include "treeIt.h" #include "computePijComponent.h" #include "logFile.h" void computePijHomSpec::fillPij(const MDOUBLE dis, const stochasticProcess& sp, int derivationOrder, bool isReversible) { if (!(isReversible && sp.isReversible())) // if one is false isReversible = false; resize(sp.alphabetSize()); int i,j; for (i=0; iid()].resize(sp.alphabetSize()); } LOGDO(50,et.output(myLog::LogFile(),tree::ANCESTOR)); LOGDO(50,et.output(myLog::LogFile(),tree::PHYLIP)); for (; myNode != tIt.end(); myNode = tIt.next()) { if (!(myNode->isRoot())) _V[myNode->id()].fillPij(myNode->dis2father()*sp.getGlobalRate(),sp,derivationOrder,isReversible); // else // myLog::LogFile()<<"ROOT IS "<name()<clone(); // Create the new one FIRST... _pijAccelerator = p2; } else _pijAccelerator = NULL; if (_distr) delete _distr; if (otherStoc._distr) { distribution* d2 = otherStoc._distr->clone(); _distr = d2; } else{ _distr = NULL; _isReversible = otherStoc.isReversible(); } } // if (_distr) delete _distr; // _distr = new distribution(*otherStoc._distr); return *this; } stochasticProcess::stochasticProcess(const distribution *in_distr,const pijAccelerator *pijAccelerator, bool isReversible) : _distr(in_distr->clone()), _pijAccelerator(pijAccelerator->clone()), _isReversible(isReversible){ } stochasticProcess::stochasticProcess(const stochasticProcess& other): _distr(NULL), _pijAccelerator(NULL){ if (other._pijAccelerator != NULL) _pijAccelerator = other._pijAccelerator->clone(); if (other._distr != NULL) _distr = other._distr->clone(); _isReversible = other.isReversible(); } stochasticProcess::~stochasticProcess() { delete _distr; delete _pijAccelerator; } void stochasticProcess::setDistribution(const distribution* in_distr) { if (_distr) delete _distr; if (in_distr == NULL) _distr = NULL; else _distr = in_distr->clone(); } rate4site-3.0.0/src/phylogeny/suffStatComponent.cpp0000644011611301161130000000014512223673416017340 00000000000000// $Id: suffStatComponent.cpp 962 2006-11-07 15:13:34Z privmane $ #include "suffStatComponent.h" rate4site-3.0.0/src/phylogeny/unObservableData.cpp0000644011611301161130000000706112223673415017102 00000000000000#include "unObservableData.h" #include "likelihoodComputation.h" #include "likelihoodComputationGL.h" #include using namespace std; unObservableData::unObservableData(const sequenceContainer& sc,const stochasticProcess* sp ,const gainLossAlphabet alph, const int minNumOfOnes, const int minNumOfZeros) { _scZero.startZeroSequenceContainerGL(sc,alph, minNumOfOnes, minNumOfZeros); _LforMissingDataPerCat.resize(sp->categories()); } unObservableData::unObservableData(const unObservableData& other) //const { _scZero = other._scZero; _pi = other._pi; _logLforMissingData = other._logLforMissingData; _LforMissingDataPerCat = other._LforMissingDataPerCat; } Vdouble* unObservableData::getpLforMissingDataPerCat(){return &_LforMissingDataPerCat;} Vdouble unObservableData::getLforMissingDataPerCat(){return _LforMissingDataPerCat;} MDOUBLE unObservableData::getlogLforMissingData(){return _logLforMissingData;} int unObservableData::getNumOfUnObservablePatterns(){return _scZero.seqLen();} //void unObservableData::setLforMissingData(const tree& _tr, const stochasticProcess* _sp){ // _pi.fillPij(_tr,*_sp); //// NOTE: The "perCat" is out // _LforMissingDataPerCat = likelihoodComputation::getLofPosPerCat(0,_tr,_scZero,_pi,*_sp); // L * sp.ratesProb(i) // _logLforMissingData = 0; // for (int i=0; i < _sp->categories();++i) { // _logLforMissingData += _LforMissingDataPerCat[i]; // } // _logLforMissingData = log(_logLforMissingData); //} /******************************************************************************************** *********************************************************************************************/ void unObservableData::setLforMissingData(const tree& tr, const stochasticProcess* sp){ _pi.fillPij(tr,*sp); _logLforMissingData = 0; for(int pos=0; pos<_scZero.seqLen(); ++pos){ _logLforMissingData += convert(likelihoodComputation::getLofPos(pos,tr,_scZero,_pi,*sp)); } _logLforMissingData = log(_logLforMissingData); } /******************************************************************************************** *********************************************************************************************/ void unObservableData::setLforMissingData(const tree& tr, const vector >& spVVec, const distribution* distGain, const distribution* distLoss) { _logLforMissingData = 0; int numOfRateCategories = spVVec[0][0]->categories(); vector pi_vec(numOfRateCategories); vector ssc_vec(numOfRateCategories); vector cup_vec(numOfRateCategories); likelihoodComputationGL::fillPijAndUp(tr,_scZero, spVVec,distGain,distLoss,pi_vec,ssc_vec,cup_vec); for (int k=0; k < _scZero.seqLen(); ++k) { MDOUBLE resGivenRate = 0.0; MDOUBLE lnL = 0; for(int rateIndex=0 ; rateIndexratesProb(rateIndex); } _logLforMissingData += exp(resGivenRate); } _logLforMissingData = log(_logLforMissingData); //for(int rateIndex=0 ; rateIndexratesProb(rateIndex); //} } rate4site-3.0.0/src/phylogeny/likeDist.cpp0000644011611301161130000003021312223673416015425 00000000000000// $Id: likeDist.cpp 9582 2011-06-21 11:31:21Z cohenofi $ #include "likeDist.h" #include "numRec.h" #include "someUtil.h" stochasticProcess& likeDist::getNonConstStochasticProcess() { if (!_nonConstSpPtr) { errorMsg::reportError("likeDist::getNonConstStochasticProcess: Can't give non-const stochasticProcess because the stochasticProcess that was given to the constructor of this likeDist object was const"); } return *_nonConstSpPtr; } // ======================= functors needed for the computations ============= class C_evalLikeDistDirect{ private: const stochasticProcess& _sp; const sequence& _s1; const sequence& _s2; const vector * _weights; public: C_evalLikeDistDirect(const stochasticProcess& inS1, const sequence& s1, const sequence& s2, const vector * weights): _sp(inS1),_s1(s1),_s2(s2),_weights(weights) {}; MDOUBLE operator() (MDOUBLE dist) const { return -likeDist::evalLikelihoodForDistance(_sp,_s1,_s2,dist,_weights); } }; MDOUBLE likeDist::evalLikelihoodForDistance(const stochasticProcess& sp, const sequence& s1, const sequence& s2, const MDOUBLE dist, const vector * weights) { MDOUBLE sumL=0.0; // sum of log likelihoods MDOUBLE posLikelihood = 0.0; // likelihood of a specific position for (int pos=0; pos < s1.seqLen(); ++pos){ if (s1.isUnknown(pos) && s2.isUnknown(pos)) continue; // the case of two unknowns posLikelihood = 0.0; if (s1.isUnknown(pos) && s2.isSpecific(pos)) { // this is the more complicated case, where s1 = ?, s2 = specific posLikelihood = sp.freq(s2[pos]); } else if (s2.isUnknown(pos) && s1.isSpecific(pos)) { posLikelihood = sp.freq(s1[pos]); } else { for (int rateCategor = 0; rateCategorrelations(s1[pos],iS1)) && (s2.getAlphabet()->relations(s2[pos],iS2))) { posLikelihood += sp.freq(iS1)*sp.Pij_t(iS1,iS2,dist*rate)*sp.ratesProb(rateCategor); } } } } } // end of for on the rates } assert(posLikelihood!=0.0); sumL += log(posLikelihood)*(weights ? (*weights)[pos]:1.0); } return sumL; }; class C_evalLikeDistDirect_d{ // derivative. private: const stochasticProcess& _sp; const sequence& _s1; const sequence& _s2; const vector * _weights; public: C_evalLikeDistDirect_d(const stochasticProcess& sp, const sequence& s1, const sequence& s2, const vector * weights): _sp(sp),_s1(s1),_s2(s2),_weights(weights) {}; MDOUBLE operator() (MDOUBLE dist) const { MDOUBLE sumL=0.0; // sum of log likelihoods MDOUBLE posLikelihood = 0.0; // likelihood of a specific position MDOUBLE posLikelihood_d = 0.0; // derivative of the likelihood at a specific position for (int pos=0; pos < _s1.seqLen(); ++pos){ if (_s1.isUnknown(pos) && _s2.isUnknown(pos)) continue; // the case of two unknowns posLikelihood = 0.0; posLikelihood_d = 0.0; if (_s1.isUnknown(pos) && _s2.isSpecific(pos)) { // this is the more complicated case, where s1 = ?, s2 = specific posLikelihood = _sp.freq(_s2[pos]); posLikelihood_d =0.0; } else if (_s2.isUnknown(pos) && _s1.isSpecific(pos)) { posLikelihood = _sp.freq(_s1[pos]); posLikelihood_d =0.0; } else { for (int rateCategor = 0; rateCategor<_sp.categories(); ++rateCategor) { MDOUBLE rate = _sp.rates(rateCategor); MDOUBLE pij= 0.0; MDOUBLE dpij=0.0; if (_s1.isSpecific(pos) && _s2.isSpecific(pos)) { //simple case, where AA i is changing to AA j pij= _sp.Pij_t(_s1[pos],_s2[pos],dist*rate); dpij= _sp.dPij_dt(_s1[pos],_s2[pos],dist*rate)*rate; MDOUBLE tmp = _sp.freq(_s1[pos])*_sp.ratesProb(rateCategor); posLikelihood += pij *tmp; posLikelihood_d += dpij*tmp; } else {// this is the most complicated case, when you have combinations of letters, // for example B in one sequence and ? in the other. for (int iS1 =0; iS1< _sp.alphabetSize(); ++iS1) { for (int iS2 =0; iS2< _sp.alphabetSize(); ++iS2) { if ((_s1.getAlphabet()->relations(_s1[pos],iS1)) && (_s2.getAlphabet()->relations(_s2[pos],iS2))) { MDOUBLE exp = _sp.freq(iS1)*_sp.ratesProb(rateCategor); posLikelihood += exp* _sp.Pij_t(iS1,iS2,dist*rate); posLikelihood_d += exp * _sp.dPij_dt(iS1,iS2,dist*rate)*rate; } } } } }// end of for rate categories } assert(posLikelihood>0.0); sumL += (posLikelihood_d/posLikelihood)*(_weights ? (*_weights)[pos]:1.0); } return -sumL; }; }; // THIS FUNCTION EVALUATES THE LIKELIHOOD GIVEN THE DISTANCE MDOUBLE likeDist::evalLogLikelihoodGivenDistance(const sequence& s1, const sequence& s2, const MDOUBLE dis2evaluate) { C_evalLikeDistDirect Cev(_sp,s1,s2,NULL); return -Cev.operator ()(dis2evaluate); } MDOUBLE likeDist::giveDistanceThroughCTC( const sequence& s1, const sequence& s2, const vector * weights, MDOUBLE* score) const { // only in the case of homogenous model - work through pairwise EM like countTableComponentGam ctc; if (_sp.categories() != 1) { errorMsg::reportError("this function only work for homogenous model."); } ctc.countTableComponentAllocatePlace(s1.getAlphabet()->size(),1); for (int i=0; i MDOUBLE myNRmethod(MDOUBLE low, MDOUBLE current, MDOUBLE high, regF f, dF df, const MDOUBLE tol, const int max_it, int & zeroFound) { // finding zero of a function. zeroFound = 1; MDOUBLE currentF = f(current); if (fabs(currentF)0) && (highF>0)) || ((lowF<0) && (highF<0))) {// unable to find a zero zeroFound = 0; return 0; } if (lowF>0) {// fixing things to be in the right order. MDOUBLE tmp = low; low = high; high = tmp; tmp = lowF; lowF = highF; highF = tmp; } if (currentF>0) { high = current; highF = currentF; } else { low = current; lowF = currentF; } // now the zero is between current and either low or high. MDOUBLE currentIntervalSize = fabs(low-high); MDOUBLE oldIntervalSize = currentIntervalSize; // we have to decide if we do NR or devide the interval by two: // we want to check if the next NR step is within our interval // recall the the next NR guess is Xn+1 = Xn - f(Xn) / f(Xn+1) // So we want (current - currentF/currentDF) to be between low and high for (int i=0 ; i < max_it; ++i) { MDOUBLE currentDF = df(current); MDOUBLE newGuess = current - currentF/currentDF; if ((newGuess high) || (newGuess>low && newGuess< high)) { // in this case we should do a NR step. current = newGuess; currentF = f(current); if (currentF > 0){ high = current; highF = currentF; } else { low = current; lowF = currentF; } oldIntervalSize = currentIntervalSize; currentIntervalSize =fabs (high-low); if (currentIntervalSize < tol) { return current; } //LOG(5,<<"NR: low= "< using namespace std; using namespace likelihoodComputation; vector eliminateHalf(vector& tVec, sequenceContainer& orginal, stochasticProcess& sp, ostream& out, const int maxIterEM){ vector likeScore(tVec.size(),0.0); int i; for (i=0; i < tVec.size(); ++i) { bblEM bblEM1(tVec[i],orginal,sp,NULL,maxIterEM,0.01); likeScore[i] = bblEM1.getTreeLikelihood(); LOG(5,<<"~"); } vector sortedL = likeScore; sort(sortedL.begin(),sortedL.end()); MDOUBLE median = sortedL[sortedL.size()/2]; // printing the top ten with their scores; // int toPrint = sortedL.size()>10? 10 : sortedL.size(); // MDOUBLE treshToPrint = sortedL[sortedL.size()-toPrint]; // out<<"current best 10 (or less) trees: "<treshToPrint) { // out<<"likelihood of tree: "< vNames; giveDistanceTable(&pd1, allTogether, disTab, vNames, &startingTreeWeights); NJalg nj1; tree et = nj1.computeTree(disTab,vNames); bool treeAlreadyThere = false; for (int z=0; z< tVec.size();++z) { if (sameTreeTolopogy(tVec[z],et)) treeAlreadyThere=true; } if (treeAlreadyThere == false) { tVec.push_back(et); } } LOG(5,<<"from number of tree tried: "< 1) { LOG(5,<<" current size = "< #include using namespace likelihoodComputation; MDOUBLE likelihoodComputation::getLOG_LofPos(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const MDOUBLE gRate){ // when there is a global rate for this position // using the pij of stochastic process rather than pre computed pij's... vector factors; computeUpAlg cup; suffStatGlobalHomPos ssc; cup.fillComputeUpSpecificGlobalRateFactors(et,sc,pos,sp,ssc,gRate,factors); doubleRep tmp = 0.0; for (int let = 0; let < sp.alphabetSize(); ++let) { doubleRep tmpLcat= ssc.get(et.getRoot()->id(),let)* sp.freq(let);; assert(tmpLcat>=0); tmp+=tmpLcat; } return log(tmp)-factors[et.getRoot()->id()]*log(10.0); } rate4site-3.0.0/src/phylogeny/bestAlpha.cpp0000644011611301161130000003634012223673416015567 00000000000000// $Id: bestAlpha.cpp 10046 2011-12-09 15:35:00Z rubi $ #include using namespace std; #include "bestAlpha.h" #include "bblEM.h" #include "bblEMProportionalEB.h" #include "bblLSProportionalEB.h" #include "numRec.h" #include "logFile.h" #include "errorMsg.h" #ifndef VERBOS #define VERBOS #endif //void bestAlpha::checkAllocation() { // if (_pi->stocProcessFromLabel(0)->getPijAccelerator() == NULL) { // errorMsg::reportError(" error in function findBestAlpha"); // } //} // // @@@@ The method works with oldL,oldA,bestA and newL,newA. // Only when it's about to end, the members _bestAlpha and _bestL are filled. bestAlphaAndBBL::bestAlphaAndBBL(tree& et, //find Best Alpha and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const MDOUBLE initAlpha, const MDOUBLE upperBoundOnAlpha, const MDOUBLE epsilonLoglikelihoodForAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForBBL, const int maxBBLIterations, const int maxTotalIterations){ // LOG(5,<<"find Best Alpha and best BBL"< oldL+epsilonLoglikelihoodForBBL) { oldL = newL; } else { oldL=newL; _bestL = oldL; _bestAlpha= oldA; (static_cast(sp.distr()))->setAlpha(bestA); break; } } if (i==maxTotalIterations) { _bestL = newL; _bestAlpha= bestA; (static_cast(sp.distr()))->setAlpha(bestA); } } bestAlphasAndBBLProportional::bestAlphasAndBBLProportional(tree& et, //find Best Alphas (per gene - local and proportional factors - global) and best BBL vector& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalRateAlphas, const MDOUBLE upperBoundOnLocalRateAlpha, const MDOUBLE initGlobalRateAlpha, const MDOUBLE upperBoundOnGlobalRateAlpha, const int maxBBLIterations, const int maxTotalIterations, const bool optimizeSelectedBranches, const bool optimizeTree, const string branchLengthOptimizationMethod, const bool optimizeLocalAlpha, const bool optimizeGlobalAlpha, const Vdouble * weights, const MDOUBLE epsilonLoglikelihoodForLocalRateAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForGlobalRateAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForBBL){ // LOG(5,<<"find Best Alpha and best BBL"<setAlpha(_bestGlobalAlpha); _bestLocalAlphaVec = initLocalRateAlphas; for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ (static_cast(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); } //First compute the likelihood _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); if((!optimizeTree) && (!optimizeLocalAlpha) && (!optimizeGlobalAlpha)) return; MDOUBLE currentGlobalAlpha; currentGlobalAlpha = initGlobalRateAlpha; Vdouble currentLocalAlphaVec; Vdouble newLvec; //doubleRep newL;//DR MDOUBLE newL; //doubleRep oldL(VERYSMALL);//DR MDOUBLE oldL = VERYSMALL; currentLocalAlphaVec = initLocalRateAlphas; newLvec.resize(msp->getSPVecSize()); //doubleRep epsilonLoglikelihoodForGlobalRateAlphaOptimizationDR(epsilonLoglikelihoodForGlobalRateAlphaOptimization);//DR string alphas; //doubleRep minusOne(-1.0);//DR int i; MDOUBLE a_localAlpha_x = 0.0; MDOUBLE c_localAlpha_x = upperBoundOnLocalRateAlpha; for(i=0; i < maxTotalIterations; ++i) { //Find best local alphas if(optimizeLocalAlpha){ for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ MDOUBLE b_localAlpha_x = _bestLocalAlphaVec[spIndex]; newLvec[spIndex] = -brent(a_localAlpha_x,b_localAlpha_x,c_localAlpha_x, C_evalLocalAlpha(et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForLocalRateAlphaOptimization, ¤tLocalAlphaVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _bestLocalAlphaVec[spIndex] = currentLocalAlphaVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing local alpha"<(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); } LOGnOUT(2,<<"Done with local alpha optimization"<= sumVdouble(_bestLvec)) { //converged _bestGlobalAlpha = currentGlobalAlpha; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing global alpha"<setAlpha(_bestGlobalAlpha); //whether or not likelihood has improved we need to update _bestLvec _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); LOGnOUT(2,<<"Done with global alpha optimization"< oldL+epsilonLoglikelihoodForBBL) { //global and local alpha have already been updated individually oldL = sumVdouble(_bestLvec); } else { break; } LOGnOUT(2,<<"Done with optimization iteration "< oldL+epsilonLoglikelihoodForBBL) { oldL = newL; } else { oldL=newL; _bestL = oldL; _bestBeta= oldB; (static_cast(sp.distr()))->setBeta(bestB); break; } } if (i==maxTotalIterations) { _bestL = newL; _bestBeta= bestB; (static_cast(sp.distr()))->setBeta(bestB); } } bestAlphaFixedTree::bestAlphaFixedTree(const tree& et, //findBestAlphaFixedTree const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const MDOUBLE upperBoundOnAlpha, const MDOUBLE epsilonLoglikelihoodForAlphaOptimization){ //LOG(5,<<"findBestAlphaFixedTree"<(sp.distr())->getAlpha(); const MDOUBLE ax=0.0; _bestL = -brent(ax,bx,cx, C_evalAlpha(et,sc,sp,weights), epsilonLoglikelihoodForAlphaOptimization, &bestA); (static_cast(sp.distr()))->setAlpha(bestA); _bestAlpha= bestA; } bestAlphaAndBetaAndBBL::bestAlphaAndBetaAndBBL(tree& et, //find Best Alpha and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const MDOUBLE initAlpha, const MDOUBLE initBeta, const MDOUBLE upperBoundOnAlpha, const MDOUBLE upperBoundOnBeta, const MDOUBLE epsilonLoglikelihoodForAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForBetaOptimization, const MDOUBLE epsilonLoglikelihoodForBBL, const int maxBBLIterations, const int maxTotalIterations){ // LOG(5,<<"find Best Alpha and Beta and best BBL"< oldL+epsilonLoglikelihoodForBBL) { optimize = true; } (static_cast(sp.distr()))->setAlpha(bestA); //optimize beta newL = -brent(dx,ex,fx, C_evalBeta(et,sc,sp,weights), epsilonLoglikelihoodForBetaOptimization, &bestB); ex = bestB; #ifdef VERBOS LOG(5,<<"# bestAlphaAndBetaAndBBL::bestAlphaAndBetaAndBBL iteration " << i < oldL+epsilonLoglikelihoodForBBL) { optimize = true; } (static_cast(sp.distr()))->setBeta(bestB); //bblEM bblEM bblEM1(et,sc,sp,NULL,maxBBLIterations,epsilonLoglikelihoodForBBL);//maxIterations=1000 newL =bblEM1.getTreeLikelihood(); #ifdef VERBOS LOG(5,<<"# bestAlphaAndBetaAndBBL::bestAlphaAndBetaAndBBL iteration " << i < oldL+epsilonLoglikelihoodForBBL) { optimize = true; } if (!optimize) break; } } rate4site-3.0.0/src/phylogeny/gammaDistribution.cpp0000644011611301161130000000246412223673415017345 00000000000000// $Id: gammaDistribution.cpp 2862 2007-11-27 10:59:03Z itaymay $ #include "definitions.h" #include "gammaDistribution.h" #include "gammaUtilities.h" #include "logFile.h" #include gammaDistribution::gammaDistribution(MDOUBLE alpha,int in_number_of_categories) : generalGammaDistribution(alpha,alpha,in_number_of_categories) {} gammaDistribution::gammaDistribution(const gammaDistribution& other) : generalGammaDistribution(other) {} void gammaDistribution::setAlpha(MDOUBLE in_alpha) { if (in_alpha == _alpha) return; setGammaParameters( categories(), in_alpha); } //this function builds the gamma distribution void gammaDistribution::setGammaParameters(int in_number_of_categories, MDOUBLE in_alpha) { generalGammaDistribution::setGammaParameters(in_number_of_categories,in_alpha,in_alpha); } void gammaDistribution::change_number_of_categories(int in_number_of_categories) { if (in_number_of_categories == categories()) return; setGammaParameters( in_number_of_categories, _alpha, _alpha); } void gammaDistribution::setGammaParameters(int numOfCategories ,MDOUBLE alpha, MDOUBLE beta) { if (alpha!=beta) errorMsg::reportError("gammaDistribution::setGammaParameters : can not set beta because alpha must be equal to beta"); generalGammaDistribution::setGammaParameters(numOfCategories,alpha,beta); } rate4site-3.0.0/src/phylogeny/siteSpecificRate.cpp0000644011611301161130000004464712223673416017123 00000000000000// $Id: siteSpecificRate.cpp 10215 2012-01-23 18:57:15Z cohenofi $ #include "siteSpecificRate.h" #include "numRec.h" #include "checkcovFanctors.h" #include "definitions.h" /******************************************************************************************** ML - full data (1) *********************************************************************************************/ MDOUBLE computeML_siteSpecificRate(Vdouble & ratesV, Vdouble & likelihoodsV, const sequenceContainer& sc, const stochasticProcess& sp, const tree& et, const MDOUBLE maxRate,//20.0f const MDOUBLE tol){//=0.0001f; ratesV.resize(sc.seqLen()); likelihoodsV.resize(sc.seqLen()); MDOUBLE Lsum = 0.0; for (int pos=0; pos < sc.seqLen(); ++pos) { computeML_siteSpecificRate(pos,sc,sp,et,ratesV[pos],likelihoodsV[pos],maxRate,tol); assert(log(likelihoodsV[pos])>0.0); Lsum += log(likelihoodsV[pos]); LOG(6,<<" rate of pos: "< & etVec, const vector & spVec, const sequenceContainer& sc, const MDOUBLE maxRate, const MDOUBLE tol){ MDOUBLE Lsum = 0.0; ratesV.resize(sc.seqLen()); // the rates themselves likelihoodsV.resize(sc.seqLen()); // the log likelihood of each position for (int pos=0; pos < sc.seqLen(); ++pos) { LOG(6,<<"."); MDOUBLE bestR=-1.0; // tree1 // MDOUBLE LmaxR1=0; // getting the right tree for the specific position: const tree* treeForThisPosition=NULL; if ((etVec.size() >0 ) && (treeAttributesVec[pos]>0)) { treeForThisPosition = & etVec[ treeAttributesVec[pos] -1]; } else { errorMsg::reportError("tree vector is empty, or treeAttribute is empty, or treeAttribute[pos] is zero (it should be one)"); } // getting the right stochastic process for the specific position: const stochasticProcess* spForThisPosition=NULL; if ((spVec.size() >0 ) && (spAttributesVec[pos]>0)) { spForThisPosition = spVec[ spAttributesVec[pos] -1]; } else { errorMsg::reportError("stochastic process vector is empty, or spAttributesVec is empty, or spAttribute[pos] is zero (it should be one)"); } computeML_siteSpecificRate(pos,sc,*spForThisPosition,*treeForThisPosition,bestR,likelihoodsV[pos],maxRate,tol); ratesV[pos] = bestR; assert(log(likelihoodsV[pos])>0.0); Lsum += log(likelihoodsV[pos]); LOG(6,<<" rate of pos: "< & etVec, const stochasticProcess& sp, const sequenceContainer& sc, const MDOUBLE maxRate, const MDOUBLE tol) { Vint spAttributesVec(sc.seqLen(),1); vector spVec; spVec.push_back(&sp); return computeML_siteSpecificRate(ratesV,likelihoodsV, spAttributesVec,treeAttributesVec,etVec,spVec,sc,maxRate,tol); } /******************************************************************************************** ML - AttributesVecs (1.1) *********************************************************************************************/ MDOUBLE computeML_siteSpecificRate(Vdouble & ratesV, Vdouble & likelihoodsV, const Vint& spAttributesVec, // spAttributesVec const tree & et, const vector & spVec, const sequenceContainer& sc, const MDOUBLE maxRate, const MDOUBLE tol){ Vint treeAttributesVec(sc.seqLen(),1); vector etVec; etVec.push_back(et); return computeML_siteSpecificRate(ratesV,likelihoodsV, spAttributesVec,treeAttributesVec,etVec,spVec,sc,maxRate,tol); } // THE BAYESIAN EB_EXP PART OF RATE ESTIMATION. // /******************************************************************************************** EB_EXP - full data (1) *********************************************************************************************/ void computeEB_EXP_siteSpecificRate(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const sequenceContainer& sc, const stochasticProcess& sp, const tree& et, const MDOUBLE alphaConf, VVdouble* LpostPerCat, //2 fill (*LpostPerCat)[cat][pos] unObservableData* unObservableData_p) { ratesV.resize(sc.seqLen()); stdV.resize(sc.seqLen()); lowerBoundV.resize(sc.seqLen()); upperBoundV.resize(sc.seqLen()); computePijGam cpg; cpg.fillPij(et,sp); for (int pos=0; pos < sc.seqLen(); ++pos) { computeEB_EXP_siteSpecificRate(pos,sc,sp,cpg, et,ratesV[pos],stdV[pos],lowerBoundV[pos],upperBoundV[pos],alphaConf,LpostPerCat,unObservableData_p); LOG(6,<<" rate of pos: "<getLforMissingDataPerCat()[cat]); //} // ver2 - fix likelihoodForEachCat by LforMissingDataAll if(unObservableData_p){ LofPos_givenRateCat = LofPos_givenRateCat/(1- exp(unObservableData_p->getlogLforMissingData())); } pGivenR[cat] = LofPos_givenRateCat * sp.ratesProb(cat); sum+=pGivenR[cat]; } LOG(8,<<"\n"); //DEBUG assert(sum!=0); // here we compute sigma r * P(r | data) doubleRep sumOfSquares(0.0); doubleRep bestRate_dblRep(0.0); LOG(6,<<"Pos "<=-tolerance)) varRate = 0; stdRate = sqrt(varRate); // detecting the confidence intervals. MDOUBLE oneSideConfAlpha = alphaConf/2.0; // because we are computing the two tail. MDOUBLE cdf = 0.0; // cumulative density function. MDOUBLE lower_interval = 0; MDOUBLE total_interval = 0; int k=0; while (k < sp.categories()){ cdf += convert(pGivenR[k]); if (cdf >oneSideConfAlpha) { if(k>0) { lowerConf = sp.rates(k-1); lower_interval = convert(pGivenR[k-1]); } else { lowerConf = 0; lower_interval = convert(pGivenR[k-1]); } break; } k++; } while (k < sp.categories()) { if (cdf >(1.0-oneSideConfAlpha)) { upperConf = sp.rates(k); total_interval = cdf - lower_interval; break; } ++k; cdf += convert(pGivenR[k]); } if (k==sp.categories()){ upperConf = sp.rates(k-1); total_interval = 1.0 - lower_interval; } LOG(7,<<"Pos: "<categories()); for(globalRateCat = 0;globalRateCat < pProportionDist->categories();++globalRateCat){ pGivenRs[globalRateCat].resize(sp.categories(),0.0); } doubleRep sum=0; doubleRep LofPos_givenRatesCats; LOG(8,<categories();++globalRateCat){ sp.setGlobalRate(pProportionDist->rates(globalRateCat)); computePijGam cpg; cpg.fillPij(et,sp); for(localRateCat=0;localRateCat < sp.categories(); ++localRateCat) { LofPos_givenRatesCats = likelihoodComputation::getLofPos(pos,et,sc,cpg[localRateCat],sp); pGivenRs[globalRateCat][localRateCat] = LofPos_givenRatesCats*pProportionDist->ratesProb(globalRateCat)*sp.ratesProb(localRateCat); sum+=pGivenRs[globalRateCat][localRateCat]; } } LOG(8,<<"\n"); //DEBUG assert(sum!=0); // here we compute sigma r * P(r | data) doubleRep sumOfSquares(0.0); doubleRep bestRate_dblRep(0.0); LOG(6,<<"Pos "<rates(globalRateCat)<<"\t"<rates(globalRateCat)*sp.rates(localRateCat)); } } bestRate = convert(bestRate_dblRep); MDOUBLE varRate = convert(sumOfSquares) - convert(bestRate*bestRate); MDOUBLE tolerance = 0.0001; // tolerance for variance is not very exact, and also exact computation not very important if (varRate<-tolerance) LOGnOUT(3,<<"Error in computeEB_EXP_siteSpecificRateProportional pos="<=-tolerance)) varRate = 0; stdRate = sqrt(varRate); // detecting the confidence intervals. i assume that this is supposed to hold for the proportional implementation MDOUBLE oneSideConfAlpha = alphaConf/2.0; // because we are computing the two tail. MDOUBLE cdf; // cumulative density function. globalRateCat = 0; bool flag = true; while((globalRateCat < pProportionDist->categories())&&(flag)){ cdf = 0.0; localRateCat = 0; while (localRateCat < sp.categories()){ cdf += convert(pGivenRs[globalRateCat][localRateCat]); if (cdf >oneSideConfAlpha) { lowerConf = sp.rates(localRateCat-1); break; } localRateCat++; } while (localRateCat < sp.categories()){ if (cdf >(1.0-oneSideConfAlpha)) { upperConf = sp.rates(localRateCat); flag = false; break; } ++localRateCat; cdf += convert(pGivenRs[globalRateCat][localRateCat]); } ++globalRateCat; } if (localRateCat==sp.categories()) upperConf = sp.rates(localRateCat-1); } /******************************************************************************************** EB_EXP - full data AttributesVecs (1) *********************************************************************************************/ void computeEB_EXP_siteSpecificRate(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const Vint& spAttributesVec, const Vint& treeAttributesVec, const sequenceContainer& sc, const vector & etVec, const vector & spVec, const MDOUBLE alphaConf){ ratesV.resize(sc.seqLen()); stdV.resize(sc.seqLen()); lowerBoundV.resize(sc.seqLen()); upperBoundV.resize(sc.seqLen()); for (int treeNum=0; treeNum0 ) && (treeAttributesVec[pos]>0)); treeForThisPosition = & etVec[ treeAttributesVec[pos] -1]; const stochasticProcess* spForThisPosition=NULL; assert ((spVec.size() >0 ) && (spAttributesVec[pos]>0)); spForThisPosition = spVec[ spAttributesVec[pos] -1]; computeEB_EXP_siteSpecificRate(pos,sc,*spForThisPosition,cpg, *treeForThisPosition,ratesV[pos],stdV[pos],lowerBoundV[pos],upperBoundV[pos],alphaConf); LOG(6,<<" rate of pos: "< & spVec, const MDOUBLE alphaConf){ Vint etAttributesVec(sc.seqLen(),1); vector etVec; etVec.push_back(et); computeEB_EXP_siteSpecificRate(ratesV,stdV,lowerBoundV,upperBoundV,spAttributesVec,etAttributesVec,sc,etVec,spVec,alphaConf); } /******************************************************************************************** EB_EXP - AttributesVecs - one sp many trees *********************************************************************************************/ void computeEB_EXP_siteSpecificRate(Vdouble & ratesV, Vdouble & stdV, Vdouble & lowerBoundV, Vdouble & upperBoundV, const Vint& treeAttributesVec, const sequenceContainer& sc, const vector & etVec, const stochasticProcess & sp, const MDOUBLE alphaConf){ Vint spAttributesVec(sc.seqLen(),1); vector spVec; spVec.push_back(&sp); computeEB_EXP_siteSpecificRate(ratesV,stdV,lowerBoundV,upperBoundV,spAttributesVec,treeAttributesVec,sc,etVec,spVec,alphaConf); } rate4site-3.0.0/src/phylogeny/likelihoodComputation.cpp0000644011611301161130000005676112223673415020242 00000000000000// $Id: likelihoodComputation.cpp 9899 2011-10-11 19:56:48Z rubi $ #include "definitions.h" #include "tree.h" #include "computeUpAlg.h" #include "likelihoodComputation.h" #include "gammaUtilities.h" #include #include using namespace likelihoodComputation; /******************************************************************************************** likelihood computation - full data (1) *********************************************************************************************/ MDOUBLE likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const Vdouble * const weights, unObservableData *unObservableData_p) { computePijGam pi; pi.fillPij(et,sp); MDOUBLE logLforMissingData; MDOUBLE LforMissingData; if(unObservableData_p){ logLforMissingData = unObservableData_p->getlogLforMissingData(); LforMissingData = exp(logLforMissingData); } MDOUBLE res =0; doubleRep LofPos; int k; for (k=0; k < sc.seqLen(); ++k) { LofPos = likelihoodComputation::getLofPos(k,//pos, et, //const tree& sc, // sequenceContainer& sc, pi, //const computePijGam& , sp, NULL); if(unObservableData_p){ // conditioning on observability for all rateCat. LofPos = LofPos / (1- LforMissingData); } res += log(LofPos) * (weights?(*weights)[k]:1);//const stochasticProcess& ); } //if(unObservableData_p){ // conditioning on observability for allPos & allRateCat // res = res - sc.seqLen()*log(1- exp(unObservableData_p->getlogLforMissingData())); //} return res; } /******************************************************************************************** likelihood computation - per pos (1.1) *********************************************************************************************/ doubleRep likelihoodComputation::getLofPos(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp, unObservableData *unObservableData_p) { // with the pi already computed. doubleRep tmp=0; int numOfCat = sp.categories(); VdoubleRep tmpPerCat; tmpPerCat.resize(numOfCat); for (int i=0; i < sp.categories();++i) { tmpPerCat[i] = getLofPos(pos,et,sc,pi[i],sp); // ver1 - fix likelihoodForEachCat by LforMissingDataPerCat - Wrong version... //if(pLforMissingDataPerCat){ // tmpPerCat[i] = tmpPerCat[i]/(1- (*pLforMissingDataPerCat)[i]); //} tmp += tmpPerCat[i]*sp.ratesProb(i); } // ver2 - fix likelihoodForEachCat by LforMissingDataAll if(unObservableData_p){ // conditioning on observability for all rateCat. tmp = tmp / (1- exp(unObservableData_p->getlogLforMissingData())); } return tmp; } /******************************************************************************************** likelihood computation - per pos, per cat (1.1.1) *********************************************************************************************/ doubleRep likelihoodComputation::getLofPos(const int pos, const tree& et, const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, unObservableData *unObservableData_p) { computeUpAlg cup; suffStatGlobalHomPos ssc; cup.fillComputeUp(et,sc,pos,pi,ssc); doubleRep tmp = 0.0; for (int let = 0; let < sp.alphabetSize(); ++let) { doubleRep tmpLcat= ssc.get(et.getRoot()->id(),let)* sp.freq(let); if (!DBIG_EQUAL(convert(tmpLcat), 0.0)) { cerr<<"tmpLcat = "<=0.0); tmp+=tmpLcat; } // cout<<"likelihoodComputation::getLofPos: tmp = "; tmp.outputn(cout); // DEBUG EP if (!DBIG_EQUAL(convert(tmp), 0.0)){ LOG(5,<<"likelihoodComputation::getLofPos: "<< tmp<getlogLforMissingData())); } return tmp; } //r4s_proportional /******************************************************************************************** likelihood computation - full data (1) *********************************************************************************************/ Vdouble likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(const tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, const Vdouble * const weights) { Vdouble geneLikelihoodVec; //geneRateLikelihoodVec[geneN][globalRateCateg] will hold the LL of the gene given the global rate VVdouble geneRateLikelihoodVec; geneLikelihoodVec.resize(sc.size(),0.0); geneRateLikelihoodVec.resize(sc.size()); for(int geneN = 0;geneN < sc.size();++geneN){ geneRateLikelihoodVec[geneN].resize(pProportionDist->categories(),0.0); for(int globalRateCateg = 0;globalRateCateg < pProportionDist->categories();++globalRateCateg){ msp->getSp(geneN)->setGlobalRate(pProportionDist->rates(globalRateCateg)); computePijGam pi; pi.fillPij(et,*msp->getSp(geneN)); doubleRep LofPos; for (int k=0; k < sc[geneN].seqLen(); ++k) { //LofPos is sum LofPos_LocalRateCat_i*p(LocalRateCat_i) LofPos = likelihoodComputation::getLofPosProportional(k,//pos, et, //const tree& sc[geneN], // sequenceContainer& sc, pi, //const computePijGam& , *msp->getSp(geneN)); //removed the prior of the globar rate categ cause it is multiplied below geneRateLikelihoodVec[geneN][globalRateCateg] += log(LofPos)*(weights?(*weights)[k]:1); } } //Once we are finished iterating over all globalRateCategs we need to sum the log likelihood for this gene //which is: log(prior(globalRateCateg_i)*exp(geneRateLikelihoodVec[geneN][globalRateCateg_i]+prior(globalRateCateg_j)*exp(geneRateLikelihoodVec[geneN][globalRateCateg_j]..) //assuming a flat prior this equals: log(prior(globalRateCateg))+log(exp(geneRateLikelihoodVec[geneN][globalRateCateg_i]+exp(geneRateLikelihoodVec[geneN][globalRateCateg_j]..) //which can be written as:log(prior(globalRateCateg))+log(exp(geneRateLikelihoodVec[geneN][globalRateCateg_i]))(1+exp(geneRateLikelihoodVec[geneN][globalRateCateg_j]-geneRateLikelihoodVec[geneN][globalRateCateg_i]..) geneLikelihoodVec[geneN] = log(pProportionDist->ratesProb(0))+exponentResolver(geneRateLikelihoodVec[geneN]);//Strictly assumes a flat prior distribution } return geneLikelihoodVec; } /******************************************************************************************** likelihood computation - per pos (1.1) *********************************************************************************************/ //Old - remove when QA is done doubleRep likelihoodComputation::getLofPosProportional(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp, const MDOUBLE globalRateProb) { // with the pi already computed. doubleRep tmp=0; int numOfCat = sp.categories(); VdoubleRep tmpPerCat; tmpPerCat.resize(numOfCat); for (int i=0; i < sp.categories();++i) { tmpPerCat[i] = getLofPos(pos,et,sc,pi[i],sp); tmp += tmpPerCat[i]*sp.ratesProb(i)*globalRateProb; //old - now globalRateProb is multipled outside } return tmp; } /******************************************************************************************** likelihood computation - per pos (1.1) *********************************************************************************************/ doubleRep likelihoodComputation::getLofPosProportional(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp) { // with the pi already computed. doubleRep tmp=0; int numOfCat = sp.categories(); VdoubleRep tmpPerCat; tmpPerCat.resize(numOfCat); for (int i=0; i < sp.categories();++i) { tmpPerCat[i] = getLofPos(pos,et,sc,pi[i],sp); tmp += tmpPerCat[i]*sp.ratesProb(i); } return tmp; } //r4s_proportional /******************************************************************************************** *********************************************************************************************/ doubleRep likelihoodComputation::getProbOfPosWhenUpIsFilledHom(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalHomPos& ssc){ // using the pij of stochastic process rather than pre computed pij's... if (ssc.size()==0) {errorMsg::reportError("error in function likelihoodComputation::getLofPosWhenUpIsFilled");} doubleRep tmp = 0.0; for (int let = 0; let < sp.alphabetSize(); ++let) { doubleRep tmpLcat= ssc.get(et.getRoot()->id(),let)* sp.freq(let); tmp+=tmpLcat; } return tmp; } /******************************************************************************************** *********************************************************************************************/ doubleRep likelihoodComputation::getLofPosHomModelEachSiteDifferentRate(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp){ // using the pij of stochastic process rather than pre computed pij's... if (sp.categories()!=1) { errorMsg::reportError("num of categories in function getLofPosHomModel must be one"); } computeUpAlg cup; suffStatGlobalHomPos ssc; computePijHom cpij; cpij.fillPij(et,sp); cup.fillComputeUp(et,sc,pos,cpij,ssc); return getProbOfPosWhenUpIsFilledHom(pos,et,sc,sp,ssc); } /******************************************************************************************** *********************************************************************************************/ doubleRep likelihoodComputation::getLofPosGamModelEachSiteDifferentRate(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp){ computePijGam pi; pi.fillPij(et,sp); return getLofPos(pos,et,sc,pi,sp); } /******************************************************************************************** *********************************************************************************************/ doubleRep likelihoodComputation::getLofPos(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const MDOUBLE gRate){ // when there is a global rate for this position // using the pij of stochastic process rather than pre computed pij's... computeUpAlg cup; suffStatGlobalHomPos ssc; cup.fillComputeUpSpecificGlobalRate(et,sc,pos,sp,ssc,gRate); doubleRep tmp = 0.0; for (int let = 0; let < sp.alphabetSize(); ++let) { doubleRep tmpLcat= ssc.get(et.getRoot()->id(),let)* sp.freq(let);; assert(tmpLcat>=0.0); tmp+=tmpLcat; } return tmp; } /******************************************************************************************** *********************************************************************************************/ doubleRep likelihoodComputation::getLofPosAndPosteriorOfRates(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp, VdoubleRep& postrior){ // with the pi already computed. doubleRep tmp=0; for (int i=0; i < sp.categories();++i) { postrior[i]=getLofPos(pos,et,sc,pi[i],sp)*sp.ratesProb(i); tmp += postrior[i]; } for (int i=0; i < sp.categories();++i) postrior[i] /= tmp; return tmp; } /******************************************************************************************** *********************************************************************************************/ MDOUBLE likelihoodComputation::getTreeLikelihoodFromUp(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, const Vdouble * weights) { MDOUBLE like = 0; //computing the likelihood from up: for (int pos = 0; pos < sc.seqLen(); ++pos) { doubleRep tmp=0; for (int categor = 0; categor < sp.categories(); ++categor) { doubleRep veryTmp =0; for (int let =0; let < sc.getAlphabet()->size(); ++let) { veryTmp+=cup.get(pos,categor,et.getRoot()->id(),let) * sp.freq(let); } tmp += veryTmp*sp.ratesProb(categor); } like += log(tmp) * (weights?(*weights)[pos]:1); } return like; } /******************************************************************************************** *********************************************************************************************/ MDOUBLE likelihoodComputation::getTreeLikelihoodFromUp2(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, VdoubleRep& posLike, // fill this vector with each position likelihood but without the weights. const Vdouble * weights, unObservableData* unObservableData_p) { posLike.clear(); MDOUBLE like = 0; //computing the likelihood from up: for (int pos = 0; pos < sc.seqLen(); ++pos) { doubleRep tmp=0; for (int categor = 0; categor < sp.categories(); ++categor) { doubleRep veryTmp =0; for (int let =0; let < sc.alphabetSize(); ++let) { veryTmp+=cup.get(pos,categor,et.getRoot()->id(),let) * sp.freq(let); } tmp += veryTmp*sp.ratesProb(categor); } assert(tmp>0.0); if(unObservableData_p){ tmp = tmp/(1- exp(unObservableData_p->getlogLforMissingData())); } like += log(tmp) * (weights?(*weights)[pos]:1); posLike.push_back(tmp); } return like; } /******************************************************************************************** *********************************************************************************************/ //old MDOUBLE likelihoodComputation::getTreeLikelihoodFromUp2(const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const suffStatGlobalGamProportional& cup, const gammaDistribution* pProportionDist, VdoubleRep& posLike, // fill this vector with each position likelihood but without the weights. const Vdouble * weights) { posLike.clear(); MDOUBLE like = 0.0; //computing the likelihood from up: for (int pos = 0; pos < sc.seqLen(); ++pos) { doubleRep tmp(0.0); for(int globalRateCategor = 0;globalRateCategor < pProportionDist->categories();++globalRateCategor){ for (int localRateCategor = 0; localRateCategor < sp.categories(); ++localRateCategor) { doubleRep veryTmp =0; for (int let =0; let < sc.alphabetSize(); ++let) { veryTmp+=cup.get(pos,globalRateCategor,localRateCategor,et.getRoot()->id(),let) * sp.freq(let); } tmp += veryTmp*pProportionDist->ratesProb(globalRateCategor)*sp.ratesProb(localRateCategor); } } assert(tmp>0.0); like += log(tmp) * (weights?(*weights)[pos]:1); posLike.push_back(tmp); } return like; } //new MDOUBLE likelihoodComputation::getTreeLikelihoodFromUp2(const tree& et, const sequenceContainer& sc, stochasticProcess& sp, const suffStatGlobalGamProportional& cup, const gammaDistribution* pProportionDist, VVdoubleRep& posLike, const Vdouble * weights) { for(int pos = 0;pos < sc.seqLen();++pos){ posLike[pos].resize(pProportionDist->categories(),0.0); } Vdouble geneRateLikelihoodVec; geneRateLikelihoodVec.resize(pProportionDist->categories(),0.0); MDOUBLE like = 0.0; //computing the likelihood from up: for (int pos = 0; pos < sc.seqLen(); ++pos) { VdoubleRep tmpVec; //hold the LofPos for each global rate category tmpVec.resize(pProportionDist->categories(),0.0);//This would sum for every global rate category for(int globalRateCategor = 0;globalRateCategor < pProportionDist->categories();++globalRateCategor){ doubleRep tmp1(0.0); doubleRep tmp2(0.0); for (int localRateCategor = 0; localRateCategor < sp.categories(); ++localRateCategor) { doubleRep veryTmp(0.0); for (int let =0; let < sc.alphabetSize(); ++let) { veryTmp+=cup.get(pos,globalRateCategor,localRateCategor,et.getRoot()->id(),let) * sp.freq(let); } tmp1 += veryTmp; tmp2 += veryTmp*sp.ratesProb(localRateCategor); } tmpVec[globalRateCategor] += tmp2; posLike[pos][globalRateCategor] = tmp1; } for(int globalRateCategor = 0;globalRateCategor < pProportionDist->categories();++globalRateCategor){ assert(tmpVec[globalRateCategor]>0.0); geneRateLikelihoodVec[globalRateCategor] += log(tmpVec[globalRateCategor])*(weights?(*weights)[pos]:1); } } like = log(pProportionDist->ratesProb(0))+exponentResolver(geneRateLikelihoodVec); return like; } /******************************************************************************************** fill the posteriorLike matrix with each position posterior rate (p(r|D)) but without the weights. *********************************************************************************************/ MDOUBLE likelihoodComputation::getPosteriorOfRates(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, VVdoubleRep& posteriorLike, const Vdouble * weights) { suffStatGlobalGam cup; computeUpAlg cupAlg; computePijGam cpGam; cpGam.fillPij(et,sp); cupAlg.fillComputeUp(et,sc,cpGam,cup); return getPosteriorOfRates(et,sc,sp,cup,posteriorLike,weights); } // fill the posteriorLike matrix with each position posterior rate (p(r|D)) // but without the weights. MDOUBLE likelihoodComputation::getPosteriorOfRates(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, VVdoubleRep& posteriorLike, const Vdouble * weights) { posteriorLike.clear(); posteriorLike.resize(sc.seqLen()); for (int z=0; z < posteriorLike.size(); ++z) posteriorLike[z].resize(sp.categories()); MDOUBLE like = 0; //computing the likelihood from up: for (int pos = 0; pos < sc.seqLen(); ++pos) { doubleRep posProb=0; for (int categor = 0; categor < sp.categories(); ++categor) { doubleRep veryTmp =0; for (int let =0; let < sc.getAlphabet()->size(); ++let) { veryTmp+=cup.get(pos,categor,et.getRoot()->id(),let) * sp.freq(let); } posProb += veryTmp*sp.ratesProb(categor); posteriorLike[pos][categor] += veryTmp*sp.ratesProb(categor); } like += log(posProb) * (weights?(*weights)[pos]:1); for (int categor1 = 0; categor1 < sp.categories(); ++categor1) { posteriorLike[pos][categor1] /= posProb; } } return like; } // fill the posteriorLike matrix with each position posterior rate (p(r|D)) // and the LLPP, but without the weights. MDOUBLE likelihoodComputation::getPosteriorOfRatesAndLLPP(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGam& cup, VVdoubleRep& posteriorLike, VdoubleRep& LLPerPos, const Vdouble * weights) { posteriorLike.clear(); posteriorLike.resize(sc.seqLen()); for (int z=0; z < posteriorLike.size(); ++z) posteriorLike[z].resize(sp.categories()); MDOUBLE like = 0; //computing the likelihood from up: for (int pos = 0; pos < sc.seqLen(); ++pos) { LLPerPos[pos] = 0.0; for (int categor = 0; categor < sp.categories(); ++categor) { doubleRep veryTmp =0; for (int let =0; let < sc.getAlphabet()->size(); ++let) { veryTmp+=cup.get(pos,categor,et.getRoot()->id(),let) * sp.freq(let); } LLPerPos[pos] += veryTmp*sp.ratesProb(categor); posteriorLike[pos][categor] += veryTmp*sp.ratesProb(categor); } like += log(LLPerPos[pos]) * (weights?(*weights)[pos]:1); for (int categor1 = 0; categor1 < sp.categories(); ++categor1) { posteriorLike[pos][categor1] /= LLPerPos[pos]; } } return like; } // this function forces non gamma computation of likelihoods from up. // i.e., even if the stochastic process is really gamma - the likelihood is computed as if there's no gamma. MDOUBLE likelihoodComputation::getTreeLikelihoodFromUpSpecifcRates(const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalHom& cup, VdoubleRep& posLike, // fill this vector with each position likelihood but without the weights. const Vdouble * weights) { posLike.clear(); MDOUBLE like = 0; //computing the likelihood from up: for (int pos = 0; pos < sc.seqLen(); ++pos) { doubleRep tmp=0; for (int let =0; let < sc.getAlphabet()->size(); ++let) { tmp += cup.get(pos, et.getRoot()->id(), let) * sp.freq(let); } assert(tmp > 0); like += log(tmp) * (weights?(*weights)[pos]:1); posLike.push_back(tmp); } return like; } /******************************************************************************************** *********************************************************************************************/ doubleRep likelihoodComputation::getProbOfPosWhenUpIsFilledGam(const int pos, const tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const suffStatGlobalGamPos& cup) { doubleRep tmp=0; for (int categor = 0; categor < sp.categories(); ++categor) { doubleRep veryTmp =0; for (int let =0; let < sc.alphabetSize(); ++let) { veryTmp+=cup.get(categor,et.getRoot()->id(),let) * sp.freq(let); } tmp += veryTmp*sp.ratesProb(categor); } assert(tmp>0.0); return tmp; } /******************************************************************************************** *********************************************************************************************/ MDOUBLE likelihoodComputation::computeLikelihoodAndLikelihoodPerPosition(const sequenceContainer &sc, const tree &et, const stochasticProcess &sp, Vdouble &LLPerPos) { MDOUBLE treeLogLikelihood = 0.0; computePijGam cpij; cpij.fillPij(et, sp); LLPerPos.resize(sc.seqLen()); doubleRep LofPos; for (int pos=0; pos < sc.seqLen() ;++pos) { LofPos = likelihoodComputation::getLofPos(pos, et, sc, cpij, sp); MDOUBLE tmpLL = log(LofPos); treeLogLikelihood += tmpLL; LLPerPos[pos] = tmpLL; } return treeLogLikelihood; } /******************************************************************************************** likelihood for each category - used for unObservableData *********************************************************************************************/ Vdouble likelihoodComputation::getLofPosPerCat(const int pos, const tree& et, const sequenceContainer& sc, const computePijGam& pi, const stochasticProcess& sp) { // with the pi already computed. int numOfCat = sp.categories(); Vdouble tmp; tmp.resize(numOfCat); for (int i=0; i < numOfCat;++i) { tmp[i] = convert(getLofPos(pos,et,sc,pi[i],sp))*sp.ratesProb(i); } return tmp; } //doubleRep likelihoodComputation::getLofPos(const int pos, // const tree& et, // const sequenceContainer& sc, // const computePijGam& pi, // const stochasticProcess& sp){ //// with the pi already computed. // doubleRep tmp=0; // for (int i=0; i < sp.categories();++i) { // tmp += getLofPos(pos,et,sc,pi[i],sp)*sp.ratesProb(i); // } // return tmp; //} // MDOUBLE likelihoodComputation::getTreeLikelihoodFromPosteriorAndAlpha(const MDOUBLE alpha, // const Vdouble originalBounderi, // const VVdouble& posteriorLike, // const VdoubleRep& LLPP, // const Vdouble* weights) // { // int nCategories = originalBounderi.size()-1; // Vdouble rateWeights; rateWeights.resize(nCategories); // for (int i=0; i': sc=fastaFormat::readUnAligned(infile,alph); break; case 'C': sc=clustalFormat::readUnAligned(infile,alph); break; case ';': sc=maseFormat::readUnAligned(infile,alph); break; default: if (isdigit(check)){ // here it can be either MOLPHY format or one of the PHYLIP type formats (interleaved, sequential) // in PHYLIP format there are lines that are not empty, but the first 10 characters // are space. string s; getline(infile,s, '\n' ); // read the first line which are numbers in both formats getline(infile,s, '\n' ); // read the second line bool phylipFormat = false; int r = s.find_first_of(' '); // if there is a space somewhere - this is phylip format if ((r==(s.size()-1)) || (r==-1)) phylipFormat = false; else phylipFormat = true; if (phylipFormat == false) { infile.seekg(0, ios::beg); // file return to the beginning sc=molphyFormat::readUnAligned(infile,alph); } else { getline(infile,s, '\n' ); // read the third line: interleaved will begin with a space, sequential not infile.seekg(0, ios::beg); // file return to the beginning if (s[0] == ' ') sc = phylipSequentialFormat::readUnAligned(infile, alph); else sc = phylipFormat::readUnAligned(infile,alph); } } else{ string line; getline(infile, line, '\n'); string tmp2 = "The program can't recognise your format!"; tmp2+="\nThis is the first line in your format:\n"; tmp2+=line; errorMsg::reportError(tmp2); } break; } return sc; } rate4site-3.0.0/src/phylogeny/bblEM.cpp0000644011611301161130000001655112223673415014646 00000000000000// $Id: bblEM.cpp 9854 2011-09-15 11:36:23Z cohenofi $ #include "bblEM.h" #include "likelihoodComputation.h" using namespace likelihoodComputation; #include "computeUpAlg.h" #include "computeDownAlg.h" #include "computeCounts.h" #include "treeIt.h" #include "fromCountTableComponentToDistance.h" #include bblEM::bblEM(tree& et, const sequenceContainer& sc, const stochasticProcess& sp, const Vdouble * weights, const int maxIterations, const MDOUBLE epsilon, const MDOUBLE tollForPairwiseDist, unObservableData* _unObservableData_p, const MDOUBLE* likelihoodLast) : _et(et),_sc(sc),_sp(sp),_weights(weights),_unObservableData_p(_unObservableData_p) { time_t ltime1; time( <ime1 ); _treeLikelihood = compute_bblEM(maxIterations,epsilon,tollForPairwiseDist,likelihoodLast); time_t ltime2; time( <ime2 ); int t = static_cast(ltime2 - ltime1); LOG(4,<<"Overall running time for BBL = "<setLforMissingData(_et,&_sp); return oldL; // keep the old tree, and old likelihood } else { //update the tree and likelihood and return return currL; } } bblEM_it(tollForPairwiseDist); oldL = currL; time_t ltime2; time( <ime2 ); int t = static_cast(ltime2 - ltime1); LOG(6,<<"Time BBL iteration = "<setLforMissingData(_et,&_sp); return oldL; // keep the old tree, and old likelihood } else return currL; } /******************************************************************************************** *********************************************************************************************/ void bblEM::allocatePlace() { _computeCountsV.resize(_et.getNodesNum()); //initiateTablesOfCounts for (int i=0; i < _computeCountsV.size(); ++i) { _computeCountsV[i].countTableComponentAllocatePlace(_sp.alphabetSize(),_sp.categories()); } _cup.allocatePlace(_sc.seqLen(),_sp.categories(), _et.getNodesNum(), _sc.alphabetSize()); _cdown.allocatePlace(_sp.categories(), _et.getNodesNum(), _sc.alphabetSize()); } /******************************************************************************************** *********************************************************************************************/ void bblEM::bblEM_it(const MDOUBLE tollForPairwiseDist){ //string costTable = "countBBLEMTable.txt"; //ofstream costTableStream(costTable.c_str()); for (int i=0; i < _computeCountsV.size(); ++i) { _computeCountsV[i].zero(); //_computeCountsV[i].printTable(costTableStream); } for (int i=0; i < _sc.seqLen(); ++i) { computeDown(i); addCounts(i); // computes the counts and adds to the table. } //for (int i=0; i < _computeCountsV.size(); ++i) { // used for Debug - check the need for 'zero()' // _computeCountsV[i].printTable(costTableStream); //} optimizeBranches(tollForPairwiseDist); if(_unObservableData_p){ _unObservableData_p->setLforMissingData(_et,&_sp); } } /******************************************************************************************** *********************************************************************************************/ void bblEM::optimizeBranches(const MDOUBLE tollForPairwiseDist){ treeIterDownTopConst tIt(_et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { if (!tIt->isRoot()) { fromCountTableComponentToDistance from1(_computeCountsV[mynode->id()],_sp,tollForPairwiseDist,mynode->dis2father(),_unObservableData_p); from1.computeDistance(); mynode->setDisToFather(from1.getDistance()); if(_unObservableData_p){ // needed only before likelihood computation _unObservableData_p->setLforMissingData(_et,&_sp); } } } } /******************************************************************************************** *********************************************************************************************/ void bblEM::computeUp(){ _pij.fillPij(_et,_sp,0); // 0 is becaues we compute Pij(t) and not its derivations... computeUpAlg cupAlg; for (int pos=0; pos < _sc.seqLen(); ++pos) { for (int categor = 0; categor < _sp.categories(); ++categor) { cupAlg.fillComputeUp(_et,_sc,pos,_pij[categor],_cup[pos][categor]); } } } void bblEM::computeDown(const int pos){ computeDownAlg cdownAlg; for (int categor = 0; categor < _sp.categories(); ++categor) { cdownAlg.fillComputeDown(_et,_sc,pos,_pij[categor],_cdown[categor],_cup[pos][categor]); } } /******************************************************************************************** *********************************************************************************************/ void bblEM::addCounts(const int pos){ //MDOUBLE posProb = // likelihoodComputation::getProbOfPosWhenUpIsFilledGam(pos,_et,_sc,_sp,_cup); MDOUBLE weig = (_weights ? (*_weights)[pos] : 1.0); if (weig == 0) return; treeIterDownTopConst tIt(_et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { if (!tIt->isRoot()) { addCounts(pos,mynode,_posLike[pos],weig); } } } /******************************************************************************************** *********************************************************************************************/ void bblEM::addCounts(const int pos, tree::nodeP mynode, const doubleRep posProb, const MDOUBLE weig){ computeCounts cc; for (int categor =0; categor< _sp.categories(); ++ categor) { cc.computeCountsNodeFatherNodeSonHomPos(_sc, _pij[categor], _sp, _cup[pos][categor], _cdown[categor], weig, posProb, mynode, _computeCountsV[mynode->id()][categor], _sp.ratesProb(categor)); } } rate4site-3.0.0/src/phylogeny/hky.cpp0000644011611301161130000002722612223673417014463 00000000000000// $Id: hky.cpp 4291 2008-06-23 10:23:10Z itaymay $ #include "hky.h" #include "errorMsg.h" hky::hky(const MDOUBLE inProb_a, const MDOUBLE inProb_c, const MDOUBLE inProb_g, const MDOUBLE inProb_t, const MDOUBLE TrTv) { _freq.resize(4); _freq[0] = inProb_a; _freq[1] = inProb_c; _freq[2] = inProb_g; _freq[3] = inProb_t; initParams(TrTv); } hky::hky(vector inProbs, const MDOUBLE TrTv) : _freq(inProbs) { if (inProbs.size()!=4) errorMsg::reportError("hky::hky(vector inProbs, const MDOUBLE TrTv) : the size of inProbs is not 4"); initParams(TrTv); } void hky::initParams(MDOUBLE TrTv) // init _a, _b, _c, and _y by using _freq and TrTv { MDOUBLE In_k = TrTv*2; // k is defined as alpha / beta. // In k2p Tr/Tv = alpha / 2*beta. _c = 2*(_freq[0]*_freq[2]+_freq[3]*_freq[1]); _y = 2*(_freq[0]+_freq[2])*(_freq[1]+_freq[3]); // c*_a + y*_b = 1; //_a/_b = k; _b = 1.0 / (_c*In_k+_y); _a = _b*In_k; } void hky::changeTrTv(const MDOUBLE TrTv){ MDOUBLE In_k = TrTv*2; // k is defined as alpha / beta. // In k2p Tr/Tv = alpha / 2*beta. _b = 1.0 / (_c*In_k+_y); _a = _b*In_k; } MDOUBLE hky::getTrTv() const { return (_a/(2.0*_b)); } const MDOUBLE hky::Pij_t(const int i, const int j, const MDOUBLE t) const { const MDOUBLE &pa = _freq[0]; const MDOUBLE &pc = _freq[1]; const MDOUBLE &pg = _freq[2]; const MDOUBLE &pt = _freq[3]; const MDOUBLE py = pc+pt; const MDOUBLE pr = pa+pg; const MDOUBLE &b = _b; const MDOUBLE &a = _a; const MDOUBLE lamda3 = -(py*b+pr*a); const MDOUBLE lamda4 = -(py*a+pr*b); MDOUBLE term1=0.0; MDOUBLE term2=0.0; MDOUBLE term3=0.0; MDOUBLE termAll=0.0; switch (i) { case 0: switch (j) { case 0: term1 = pa; term2 = exp(-b*t)*(py)*pa/pr; term3 = pg*exp(t*lamda3)/pr; termAll = term1 + term2+term3; return termAll; break; case 1: termAll = pc - exp(-b*t)*pc; return termAll; break; case 2: term1 = pg; term2 = exp(-b*t)*py*pg/pr; term3 = -pg*exp(t*lamda3)/pr; termAll = term1 + term2+term3; return termAll; break; case 3: termAll = pt - exp(-b*t)*pt; return termAll; break; } break; case 1: switch (j) { case 0: termAll = pa - exp(-b*t)*pa; return termAll; break; case 1: term1 = pc; term2 = exp(-b*t)*pr*pc/py; term3 = pt*exp(t*lamda4)/py; termAll = term1 + term2+term3; return termAll; break; case 2: termAll = pg - exp(-b*t)*pg; return termAll; break; case 3: term1 = pt; term2 = exp(-b*t)*pr*pt/py; term3 = -pt*exp(t*lamda4)/py; termAll = term1 + term2 + term3; return termAll; break; } break; case 2: switch (j) { case 0: term1 = pa; term2 = exp(-b*t)*py*pa/pr; term3 = -pa*exp(t*lamda3)/pr; termAll = term1 + term2+term3; return termAll; break; case 1: termAll = pc - exp(-b*t)*pc; return termAll; break; case 2: term1 = pg; term2 = exp(-b*t)*py*pg/pr; term3 = pa*exp(t*lamda3)/pr; termAll = term1 + term2 + term3; return termAll; break; case 3: termAll = pt - exp(-b*t)*pt; return termAll; break; } break; case 3: switch (j) { case 0: termAll = pa - exp(-b*t)*pa; return termAll; break; case 1: term1 = pc; term2 = exp(-b*t)*pr*pc/py; term3 = -pc*exp(t*lamda4)/py; termAll = term1 + term2+term3; return termAll; break; case 2: termAll = pg - exp(-b*t)*pg; return termAll; break; case 3: term1 = pt; term2 = exp(-b*t)*(pr)*pt/(py); term3 = pc*exp(t*lamda4)/(py); termAll = term1 + term2 + term3; return termAll; break; } break; } return -1; } const MDOUBLE hky::dPij_dt(const int i,const int j, const MDOUBLE t) const { const MDOUBLE &pa = _freq[0]; const MDOUBLE &pc = _freq[1]; const MDOUBLE &pg = _freq[2]; const MDOUBLE &pt = _freq[3]; const MDOUBLE py = pc+pt; const MDOUBLE pr = pa+pg; const MDOUBLE &b = _b; const MDOUBLE &a = _a; const MDOUBLE lamda3 = -(py*b+pr*a); const MDOUBLE lamda4 = -(py*a+pr*b); MDOUBLE term1, term2, term3,termAll; switch (i) { case 0: switch (j) { case 0://ok term1 = 0; term2 = exp(-b*t)*(py)*pa/pr; term2 *= -b; term3 = pg*exp(t*lamda3)/pr; term3*= lamda3; termAll = term1 + term2+term3; return termAll; break; case 1://ok termAll = b* exp(-b*t)*pc; return termAll; break; case 2://ok term1 = 0; term2 = (-b)*exp(-b*t)*py*pg/pr; term3 = -pg*exp(t*lamda3)/pr; term3*=lamda3; termAll = term1 + term2+term3; return termAll; break; case 3://ok termAll = b*exp(-b*t)*pt; return termAll; break; } break; case 1: switch (j) { case 0://ok termAll = b*exp(-b*t)*pa; return termAll; break; case 1://ok term1 = 0; term2 = (-b)*exp(-b*t)*pr*pc/py; term3 = lamda4*pt*exp(t*lamda4)/py; termAll = term1 + term2+term3; return termAll; break; case 2://ok termAll = b*exp(-b*t)*pg; return termAll; break; case 3://ok term1 = 0; term2 = (-b)*exp(-b*t)*pr*pt/py; term3 = (lamda4)*(-pt)*exp(t*lamda4)/py; termAll = term1 + term2 + term3; return termAll; break; } break; case 2: switch (j) { case 0://ok term1 = 0; term2 = (-b)*exp(-b*t)*py*pa/pr; term3 = lamda3*(-pa)*exp(t*lamda3)/pr; termAll = term1 + term2+term3; return termAll; break; case 1://ok termAll = b*exp(-b*t)*pc; return termAll; break; case 2://ok term1 = 0; term2 = (-b)*exp(-b*t)*py*pg/pr; term3 = lamda3*pa*exp(t*lamda3)/pr; termAll = term1 + term2 + term3; return termAll; break; case 3://ok termAll = b*exp(-b*t)*pt; return termAll; break; } break; case 3: switch (j) { case 0://ok termAll = b*exp(-b*t)*pa; return termAll; break; case 1://ok term1 = 0; term2 = (-b)*exp(-b*t)*pr*pc/py; term3 = lamda4*(-pc)*exp(t*lamda4)/py; termAll = term1 + term2+term3; return termAll; break; case 2://ok termAll = b* exp(-b*t)*pg; return termAll; break; case 3://ok term1 = 0; term2 = (-b)*exp(-b*t)*(pr)*pt/(py); term3 = (lamda4)*pc*exp(t*lamda4)/(py); termAll = term1 + term2 + term3; return termAll; break; } break; } return -1; } const MDOUBLE hky::d2Pij_dt2(const int i,const int j, const MDOUBLE t) const { const MDOUBLE &pa = _freq[0]; const MDOUBLE &pc = _freq[1]; const MDOUBLE &pg = _freq[2]; const MDOUBLE &pt = _freq[3]; const MDOUBLE py = pc+pt; const MDOUBLE pr = pa+pg; const MDOUBLE &b = _b; const MDOUBLE &a = _a; const MDOUBLE lamda3 = -(py*b+pr*a); const MDOUBLE lamda4 = -(py*a+pr*b); MDOUBLE term1, term2, term3,termAll; switch (i) { case 0: switch (j) { case 0://ok2 term1 = 0; term2 = b*b*exp(-b*t)*(py)*pa/pr; term3 = lamda3*lamda3*pg*exp(t*lamda3)/pr; termAll = term1 + term2+term3; return termAll; break; case 1://ok2 termAll = -b*b* exp(-b*t)*pc; return termAll; break; case 2://ok2 term1 = 0; term2 = b*b*exp(-b*t)*py*pg/pr; term3 = lamda3*lamda3*(-pg)*exp(t*lamda3)/pr; termAll = term1 + term2+term3; return termAll; break; case 3://ok2 termAll = -b*b*exp(-b*t)*pt; return termAll; break; } break; case 1: switch (j) { case 0://ok2 termAll = -b*b*exp(-b*t)*pa; return termAll; break; case 1://ok2 term1 = 0; term2 = b*b*exp(-b*t)*pr*pc/py; term3 = lamda4*lamda4*pt*exp(t*lamda4)/py; termAll = term1 + term2+term3; return termAll; break; case 2://ok2 termAll = -b*b*exp(-b*t)*pg; return termAll; break; case 3://ok2 term1 = 0; term2 = b*b*exp(-b*t)*pr*pt/py; term3 = lamda4*lamda4*(-pt)*exp(t*lamda4)/py; termAll = term1 + term2 + term3; return termAll; break; } break; case 2: switch (j) { case 0://ok2 term1 = 0; term2 = b*b*exp(-b*t)*py*pa/pr; term3 = lamda3*lamda3*(-pa)*exp(t*lamda3)/pr; termAll = term1 + term2+term3; return termAll; break; case 1://ok2 termAll = -b*b*exp(-b*t)*pc; return termAll; break; case 2://ok2 term1 = 0; term2 = b*b*exp(-b*t)*py*pg/pr; term3 = lamda3*lamda3*pa*exp(t*lamda3)/pr; termAll = term1 + term2 + term3; return termAll; break; case 3://ok2 termAll = -b*b*exp(-b*t)*pt; return termAll; break; } break; case 3: switch (j) { case 0://ok2 termAll = -b*b*exp(-b*t)*pa; return termAll; break; case 1://ok2 term1 = 0; term2 = b*b*exp(-b*t)*pr*pc/py; term3 = lamda4*lamda4*(-pc)*exp(t*lamda4)/py; termAll = term1 + term2+term3; return termAll; break; case 2://ok2 termAll = -b*b* exp(-b*t)*pg; return termAll; break; case 3://ok2 term1 = 0; term2 = b*b*exp(-b*t)*(pr)*pt/(py); term3 = lamda4*lamda4*pc*exp(t*lamda4)/(py); termAll = term1 + term2 + term3; return termAll; break; } break; } return -1; } const MDOUBLE hky::dPij_tdBeta(const int i, const int j, const MDOUBLE t) const { const MDOUBLE &pa = _freq[0]; const MDOUBLE &pc = _freq[1]; const MDOUBLE &pg = _freq[2]; const MDOUBLE &pt = _freq[3]; const MDOUBLE &py = pc+pt; const MDOUBLE &pr = pa+pg; const MDOUBLE &b = _b; const MDOUBLE &a = _a; const MDOUBLE &lamda3 = -(py*b+pr*a); const MDOUBLE &lamda4 = -(py*a+pr*b); MDOUBLE term2, term3,termAll; const MDOUBLE& dlamda3= -py+_y*pr/_c; const MDOUBLE& dlamda4= -pr+_y*py/_c; switch (i) { case 0: switch (j) { case 0: term2 = (-t)*exp(-b*t)*(py)*pa/pr; term3 = t*dlamda3*pg*exp(t*lamda3)/pr; termAll = term2+term3; return termAll; break; case 1: termAll = t* exp(-b*t)*pc; return termAll; break; case 2: term2 = (-t)*exp(-b*t)*py*pg/pr; term3 = t*dlamda3*(-pg)*exp(t*lamda3)/pr; termAll = term2+term3; return termAll; break; case 3: termAll = t* exp(-b*t)*pt; return termAll; break; } break; case 1: switch (j) { case 0: termAll = t* exp(-b*t)*pa; return termAll; break; case 1: term2 = (-t)*exp(-b*t)*pr*pc/py; term3 = t*dlamda4*pt*exp(t*lamda4)/py; termAll = term2+term3; return termAll; break; case 2: termAll = t* exp(-b*t)*pg; return termAll; break; case 3: term2 = (-t)*exp(-b*t)*pr*pt/py; term3 = t*dlamda4*(-pt)*exp(t*lamda4)/py; termAll = term2 + term3; return termAll; break; } break; case 2: switch (j) { case 0: term2 = (-t)*exp(-b*t)*py*pa/pr; term3 = t*dlamda3*(-pa)*exp(t*lamda3)/pr; termAll = term2+term3; return termAll; break; case 1: termAll = t*exp(-b*t)*pc; return termAll; break; case 2: term2 = (-t)*exp(-b*t)*py*pg/pr; term3 = t*dlamda3*pa*exp(t*lamda3)/pr; termAll = term2 + term3; return termAll; break; case 3: termAll = t* exp(-b*t)*pt; return termAll; break; } break; case 3: switch (j) { case 0: termAll = t* exp(-b*t)*pa; return termAll; break; case 1: term2 = (-t)*exp(-b*t)*pr*pc/py; term3 = t*dlamda4*(-pc)*exp(t*lamda4)/py; termAll = term2+term3; return termAll; break; case 2: termAll = t* exp(-b*t)*pg; return termAll; break; case 3: term2 = (-t)*exp(-b*t)*(pr)*pt/(py); term3 = t*dlamda4*pc*exp(t*lamda4)/(py); termAll = term2 + term3; return termAll; break; } break; } return -1; } //Q[0][1] = freq[1]*_b ; Q[0][2] = freq[2]*_a ; Q[0][3] = freq[3]*_b; //Q[1][0] = freq[0]*_b; ; Q[1][2] = freq[2]*_b ; Q[1][3] = freq[3]*_a; //Q[2][0] = freq[0]*_a; Q[2][1] = freq[1]*_b ; ; Q[2][3] = freq[3]*_b; //Q[3][0] = freq[0]*_b; Q[3][1] = freq[1]*_a ; Q[3][2] = freq[2]*_b; rate4site-3.0.0/src/phylogeny/bestGtrModelParams.cpp0000644011611301161130000004466712223673416017436 00000000000000// $Id: bestGtrModelparams.cpp 2008-29-04 10:57:00Z nimrod $ #include "bestGtrModelParams.h" #include using namespace std; #include "bblEM.h" #include "bblEMProportionalEB.h" #include "bblLSProportionalEB.h" #include "numRec.h" #include "logFile.h" #include "bestAlpha.h" bestGtrModel::bestGtrModel(tree& et, // find best Gtr Model Params const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const int maxTotalIterations, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonLoglikelihoodForGTRParam, const MDOUBLE upperBoundGTRParam, const bool optimizeTree, const bool optimizeAlpha){ LOG(5,<<"Starting bestGtrModel: find Best replacement matrix parameters"<(sp.getPijAccelerator()->getReplacementModel()))->get_a2c(); MDOUBLE prev_a2g = (static_cast(sp.getPijAccelerator()->getReplacementModel()))->get_a2g(); MDOUBLE prev_a2t = (static_cast(sp.getPijAccelerator()->getReplacementModel()))->get_a2t(); MDOUBLE prev_c2g = (static_cast(sp.getPijAccelerator()->getReplacementModel()))->get_c2g(); MDOUBLE prev_c2t = (static_cast(sp.getPijAccelerator()->getReplacementModel()))->get_c2t(); MDOUBLE prev_g2t = (static_cast(sp.getPijAccelerator()->getReplacementModel()))->get_g2t(); MDOUBLE prevAlpha = epsilonLoglikeForBBL; for (int i=0; i < maxTotalIterations; ++i) { //optimize a2c newL = -brent(0.0, prev_a2c, upperBoundGTRParam, C_evalGTRParam(a2c,et,sc,sp,weights), epsilonLoglikelihoodForGTRParam, &_best_a2c); if (newL >= _bestL) { _bestL = newL; (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_a2c(_best_a2c);//safety } else {//likelihood went down! (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_a2c(prev_a2c); LOG(5,<<"likelihood went down in optimizing a2c"<= _bestL) { _bestL = newL; (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_a2t(_best_a2t);//safety } else {//likelihood went down! (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_a2t(prev_a2t); LOG(5,<<"likelihood went down in optimizing a2t"<= _bestL) { _bestL = newL; (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_a2g(_best_a2g);//safety } else {//likelihood went down! (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_a2g(prev_a2g); LOG(5,<<"likelihood went down in optimizing a2g"<= _bestL) { _bestL = newL; (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_c2g(_best_c2g);//safety } else {//likelihood went down! (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_c2g(prev_c2g); LOG(5,<<"likelihood went down in optimizing c2g"<= _bestL) { _bestL = newL; (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_c2t(_best_c2t);//safety } else {//likelihood went down! (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_c2t(prev_c2t); LOG(5,<<"likelihood went down in optimizing c2t"<= _bestL) { _bestL = newL; (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_g2t(_best_g2t);//safety } else {//likelihood went down! (static_cast(sp.getPijAccelerator()->getReplacementModel()))->set_g2t(prev_g2t); LOG(5,<<"likelihood went down in optimizing g2t"<(sp.distr()))->setAlpha(_bestAlpha); if (newL >= _bestL) { _bestL = newL; (static_cast(sp.distr()))->setAlpha(_bestAlpha); //safety } else {//likelihood went down! (static_cast(sp.distr()))->setAlpha(prevAlpha); LOG(5,<<"likelihood went down in optimizing alpha"< oldL+epsilonLikelihoodImprovment) { oldL = _bestL; prev_a2c = _best_a2c; prev_a2g = _best_a2g; prev_a2t = _best_a2t; prev_c2g = _best_c2g; prev_c2t = _best_c2t; prev_g2t = _best_g2t; prevAlpha = _bestAlpha; } else { break; } } } bestGtrModelProportional::bestGtrModelProportional(tree& et, // find best Gtr Model Params under a proportional model vector& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalAlphas, Vdouble initLocala2cs, Vdouble initLocala2gs, Vdouble initLocala2ts, Vdouble initLocalc2gs, Vdouble initLocalc2ts, Vdouble initLocalg2ts, const MDOUBLE upperBoundOnLocalAlpha, const MDOUBLE initGlobalAlpha, const MDOUBLE upperBoundOnGlobalAlpha, const MDOUBLE upperBoundGTRParam, const int maxTotalIterations, const int maxBBLIterations, const bool optimizeSelectedBranches, const bool optimizeTree, const string branchLengthOptimizationMethod, const bool optimizeLocalParams, const bool optimizeGlobalAlpha, const Vdouble * weights, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonLoglikelihoodForGTRParam, const MDOUBLE epsilonLoglikelihoodForLocalAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForGlobalAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForBBL){ LOG(5,<<"Starting bestGtrModelProportional"<getSPVecSize()); //doubleRep oldL(VERYSMALL);//DR //doubleRep newL;//DR MDOUBLE oldL = VERYSMALL; MDOUBLE newL; _bestLvec.resize(msp->getSPVecSize(),0.0); _bestLocalAlphaVec = initLocalAlphas; _bestGlobalAlpha = initGlobalAlpha; int spIndex; _best_a2cVec = current_a2cVec; _best_a2gVec = current_a2gVec; _best_a2tVec = current_a2tVec; _best_c2gVec = current_c2gVec; _best_c2tVec = current_c2tVec; _best_g2tVec = current_g2tVec; pProportionDist->setAlpha(_bestGlobalAlpha); for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ (static_cast(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_a2c(_best_a2cVec[spIndex]); (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_a2g(_best_a2gVec[spIndex]); (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_a2t(_best_a2tVec[spIndex]); (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_c2g(_best_c2gVec[spIndex]); (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_c2t(_best_c2tVec[spIndex]); (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_g2t(_best_g2tVec[spIndex]); } //first compute the likelihood; _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); MDOUBLE ax_local = 0.0; MDOUBLE c_GTRParam_x = upperBoundGTRParam; MDOUBLE c_localAlpha_x = upperBoundOnLocalAlpha; for (int i=0; i < maxTotalIterations; ++i) { if(optimizeLocalParams){ for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ //optimize a2c MDOUBLE a2c_x = _best_a2cVec[spIndex]; newLvec[spIndex] = -brent(ax_local,a2c_x,c_GTRParam_x, C_evalGTRParamProportional(a2c,et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForGTRParam, ¤t_a2cVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _best_a2cVec[spIndex] = current_a2cVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing a2c"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_a2c(_best_a2cVec[spIndex]);//safety //optimize a2t MDOUBLE a2t_x = _best_a2tVec[spIndex]; newLvec[spIndex] = -brent(ax_local,a2t_x,c_GTRParam_x, C_evalGTRParamProportional(a2t,et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForGTRParam, ¤t_a2tVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _best_a2tVec[spIndex] = current_a2tVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing a2t"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_a2t(_best_a2tVec[spIndex]);//safety //optimize a2g MDOUBLE a2g_x = _best_a2gVec[spIndex]; newLvec[spIndex] = -brent(ax_local,a2g_x,c_GTRParam_x, C_evalGTRParamProportional(a2g,et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForGTRParam, ¤t_a2gVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _best_a2gVec[spIndex] = current_a2gVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing a2g"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_a2g(_best_a2gVec[spIndex]);//safety //optimize c2g MDOUBLE c2g_x = _best_c2gVec[spIndex]; newLvec[spIndex] = -brent(ax_local,c2g_x,c_GTRParam_x, C_evalGTRParamProportional(c2g,et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForGTRParam, ¤t_c2gVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _best_c2gVec[spIndex] = current_c2gVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing c2g"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_c2g(_best_c2gVec[spIndex]);//safety //optimize c2t MDOUBLE c2t_x = _best_c2tVec[spIndex]; newLvec[spIndex] = -brent(ax_local,c2t_x,c_GTRParam_x, C_evalGTRParamProportional(c2t,et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForGTRParam, ¤t_c2tVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _best_c2tVec[spIndex] = current_c2tVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing c2t"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_c2t(_best_c2tVec[spIndex]);//safety //optimize g2t MDOUBLE g2t_x = _best_g2tVec[spIndex]; newLvec[spIndex] = -brent(ax_local,g2t_x,c_GTRParam_x, C_evalGTRParamProportional(g2t,et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForGTRParam, ¤t_g2tVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _best_g2tVec[spIndex] = current_g2tVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing g2t"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->set_g2t(_best_g2tVec[spIndex]);//safety //optimize local alpha MDOUBLE localAlpha_x = _bestLocalAlphaVec[spIndex]; newLvec[spIndex] = -brent(ax_local,localAlpha_x,c_localAlpha_x, C_evalLocalAlpha(et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForLocalAlphaOptimization, ¤tLocalAlphaVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _bestLocalAlphaVec[spIndex] = currentLocalAlphaVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing local alpha"<(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); //safety } LOGnOUT(2,<<"Done with GTR local params optimization"<= sumVdouble(_bestLvec)) { _bestGlobalAlpha = currentGlobalAlpha; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing global alpha"<setAlpha(_bestGlobalAlpha); //safety //whether or not likelihood has improved we need to update _bestLvec _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); LOGnOUT(2,<<"Done with global alpha optimization"< oldL+epsilonLikelihoodImprovment) { //all params have already been updated oldL = sumVdouble(_bestLvec); } else { break; } LOGnOUT(4,<<"Done with optimization iteration "< using namespace std; #include "bblEM.h" #include "bblEMProportionalEB.h" #include "bblLSProportionalEB.h" #include "numRec.h" #include "logFile.h" #include "bestAlpha.h" bestHkyParamFixedTree::bestHkyParamFixedTree(const tree& et, //findBestHkyParamFixedTree const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const MDOUBLE upperBoundOnHkyParam, const MDOUBLE epsilonHkyParamOptimization){ LOG(5,<<"findBestHkyParamFixedTree"<(sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(bestA); } bestHkyParamAndBBL::bestHkyParamAndBBL(tree& et, //find Best HkyParam and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const MDOUBLE upperBoundOnHkyParam, const MDOUBLE epsilonHkyParamOptimization, const MDOUBLE epsilonLikelihoodImprovment, const int maxBBLIterations, const int maxTotalIterations){ LOG(5,<<"find Best HkyParam and best BBL"< oldL+epsilonLikelihoodImprovment) { oldL = _bestL; } else {//LL converged if (_bestL > oldL) (static_cast(sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(bestA); else _bestL = oldL; break; } _bestHkyParam = bestA; (static_cast(sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(bestA); LOG(5,<<"bestHkyParamAndBBL: trtv = "<<_bestHkyParam< oldL+epsilonLikelihoodImprovment) { oldL = _bestL; } else { _bestL = oldL; break; } } } bestHkyParamAlphaAndBBL::bestHkyParamAlphaAndBBL( //find best TrTv (=HkyParam), Alpha and best branch lengths tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const int maxTotalIterations, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonHkyParamOptimization, const MDOUBLE epsilonAlphaOptimization, const MDOUBLE epsilonBBL, const MDOUBLE upperBoundOnHkyParam, const int maxBBLIterations, const MDOUBLE initAlpha, const MDOUBLE upperBoundOnAlpha) { MDOUBLE oldL = VERYSMALL; MDOUBLE newL = VERYSMALL; // first guess for the parameters MDOUBLE prevHkyParam = static_cast(sp.getPijAccelerator()->getReplacementModel())->getTrTv(); MDOUBLE prevAlpha = initAlpha; tree prevTree; for (int i=0; i < maxTotalIterations; ++i) { // optimize HkyParam newL = -brent(0.0, prevHkyParam, upperBoundOnHkyParam, C_evalHkyParam(et,sc,sp,weights), epsilonHkyParamOptimization, &_bestHkyParam); (static_cast(sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(_bestHkyParam); LOG(5,<<"bestHkyParamAlphaAndBBL: trtv = "<<_bestHkyParam<(sp.distr()))->setAlpha(_bestAlpha); LOG(5,<<"# bestHkyParamAlphaAndBBL::bestHkyParamAlphaAndBBL iteration " << i << ": after param optimization:" < oldL+epsilonLikelihoodImprovment) { oldL = newL; _bestL = newL; prevHkyParam = _bestHkyParam; prevAlpha = _bestAlpha; prevTree = et; } else { if (newL>oldL) { _bestL = newL; } else { _bestL = oldL; _bestHkyParam = prevHkyParam; et = prevTree; } break; } } } bestHkyParamAlphaAndBBLProportional::bestHkyParamAlphaAndBBLProportional( //find best TrTv (=HkyParam), global Alpha, local Alpha, and best branch lengths tree& et, vector& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalAlphas, Vdouble initLocalKappas, const MDOUBLE upperBoundOnLocalAlpha, const MDOUBLE initGlobalAlpha, const MDOUBLE upperBoundOnGlobalAlpha, const MDOUBLE upperBoundOnHkyParam, const int maxTotalIterations, const int maxBBLIterations, const bool optimizeSelectedBranches, const bool optimizeTree, const string branchLengthOptimizationMethod, const bool optimizeLocalParams, const bool optimizeGlobalAlpha, const Vdouble * weights, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonHkyParamOptimization, const MDOUBLE epsilonLocalAlphaOptimization, const MDOUBLE epsilonGlobalAlphaOptimization, const MDOUBLE epsilonBBL) { LOG(5,<<"Starting bestHkyParamAlphaAndBBLProportional"<getSPVecSize()); //doubleRep oldL(VERYSMALL);//DR //doubleRep newL; MDOUBLE oldL = VERYSMALL; MDOUBLE newL; _bestLvec.resize(msp->getSPVecSize(),0.0); _bestLocalAlphaVec = initLocalAlphas; _bestGlobalAlpha = initGlobalAlpha; int spIndex; //initial HKY params _bestHkyParamVec = initLocalKappas; pProportionDist->setAlpha(_bestGlobalAlpha); for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->changeTrTv(_bestHkyParamVec[spIndex]); (static_cast(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); } //first compute the likelihood; _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); MDOUBLE ax_local = 0.0; MDOUBLE c_HKYParam_x = upperBoundOnHkyParam; MDOUBLE c_localAlpha_x = upperBoundOnLocalAlpha; for (int i=0; i < maxTotalIterations; ++i) { if(optimizeLocalParams){ for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ //optimize hky MDOUBLE hky_x(_bestHkyParamVec[spIndex]); newLvec[spIndex] = -brent(ax_local,hky_x,c_HKYParam_x, C_evalLocalHkyParam(et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonHkyParamOptimization, ¤t_HkyParamVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _bestHkyParamVec[spIndex] = current_HkyParamVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing hky param"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->changeTrTv(_bestHkyParamVec[spIndex]);//safety //optimize local alpha MDOUBLE localAlpha_x(_bestLocalAlphaVec[spIndex]); newLvec[spIndex] = -brent(ax_local,localAlpha_x,c_localAlpha_x, C_evalLocalAlpha(et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLocalAlphaOptimization, ¤tLocalAlphaVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _bestLocalAlphaVec[spIndex] = currentLocalAlphaVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing local alpha"<(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); } LOGnOUT(2,<<"Done with HKY local params optimization. LL: "<= sumVdouble(_bestLvec)) { _bestGlobalAlpha = currentGlobalAlpha; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing global alpha"<setAlpha(_bestGlobalAlpha); //whether or not likelihood has improved we need to update _bestLvec _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); LOGnOUT(2,<<"Done with global alpha optimization"< oldL+epsilonLikelihoodImprovment) { //all params have already been updated oldL = sumVdouble(_bestLvec); } else { break; } LOGnOUT(4,<<"Done with optimization iteration "< using namespace std; #include "bblEM.h" #include "bblEMProportionalEB.h" #include "bblLSProportionalEB.h" #include "numRec.h" #include "logFile.h" #include "bestAlpha.h" bestTamura92ParamFixedTree::bestTamura92ParamFixedTree(const tree& et, // find best TrTv and theta const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const int maxTotalIterations, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization, const MDOUBLE epsilonLoglikelihoodForThetaOptimization, const MDOUBLE upperBoundOnTrTv) { LOG(5,<<"Starting bestTamura92ParamFixedTree: find Best TrTv and theta"< oldL+epsilonLikelihoodImprovment) { prevTrTv = _bestTrTv; prevTheta = _bestTheta; oldL = newL; _bestL = newL; } else { if (newL>oldL) { _bestL = newL; } else { _bestL = oldL; _bestTrTv = prevTrTv; _bestTheta = prevTheta; } break; } } } bestTamura92ParamAndBBL::bestTamura92ParamAndBBL(tree& et, //find best TrTv, theta and best BBL const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const int maxTotalIterations, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization, const MDOUBLE epsilonLoglikelihoodForThetaOptimization, const MDOUBLE epsilonLoglikelihoodForBBL, const MDOUBLE upperBoundOnTrTv, const int maxBBLIterations){ LOG(5,<<"Starting bestTamura92ParamAndBBL: find best TrTv, theta and BBL"<(sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(_bestTrTv); // optimize Theta newL = -brent(0.0, prevTheta, 1.0, C_evalTheta(et,sc,sp,weights), epsilonLoglikelihoodForThetaOptimization, &_bestTheta); (static_cast(sp.getPijAccelerator()->getReplacementModel()))->changeTheta(_bestTheta); // optimize branch lengths bblEM bblEM1(et,sc,sp,NULL,maxBBLIterations,epsilonLoglikelihoodForBBL);//maxIterations=1000 newL =bblEM1.getTreeLikelihood(); // check for improvement in the likelihood if (newL > oldL+epsilonLikelihoodImprovment) { prevTrTv = _bestTrTv; prevTheta = _bestTheta; oldL = newL; _bestL = newL; prevTree = et; } else { if (newL>oldL) { _bestL = newL; } else { _bestL = oldL; _bestTrTv = prevTrTv; _bestTheta = prevTheta; et = prevTree; } break; } } } bestTamura92ParamAlphaAndBBL::bestTamura92ParamAlphaAndBBL( //find best TrTv, theta, Alpha and best branch lengths tree& et, const sequenceContainer& sc, stochasticProcess& sp, const Vdouble * weights, const int maxTotalIterations, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonLoglikelihoodForTrTvOptimization, const MDOUBLE epsilonLoglikelihoodForThetaOptimization, const MDOUBLE epsilonLoglikelihoodForAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForBBL, const MDOUBLE upperBoundOnTrTv, const int maxBBLIterations, const MDOUBLE initAlpha, const MDOUBLE upperBoundOnAlpha) { MDOUBLE oldL = VERYSMALL; MDOUBLE newL = VERYSMALL; // first guess for the parameters MDOUBLE prevTrTv = static_cast(sp.getPijAccelerator()->getReplacementModel())->getTrTv(); MDOUBLE prevTheta = static_cast(sp.getPijAccelerator()->getReplacementModel())->getTheta(); MDOUBLE prevAlpha = initAlpha; tree prevTree; for (int i=0; i < maxTotalIterations; ++i) { // optimize TrTv newL = -brent(0.0, prevTrTv, upperBoundOnTrTv, C_evalTrTvParam(et,sc,sp,weights), epsilonLoglikelihoodForTrTvOptimization, &_bestTrTv); (static_cast(sp.getPijAccelerator()->getReplacementModel()))->changeTrTv(_bestTrTv); // optimize Theta newL = -brent(0.0, prevTheta, 1.0, C_evalTheta(et,sc,sp,weights), epsilonLoglikelihoodForThetaOptimization, &_bestTheta); (static_cast(sp.getPijAccelerator()->getReplacementModel()))->changeTheta(_bestTheta); // optimize Alpha newL = -brent(0.0, prevAlpha, upperBoundOnAlpha, C_evalAlpha(et,sc,sp,weights), epsilonLoglikelihoodForAlphaOptimization, &_bestAlpha); (static_cast(sp.distr()))->setAlpha(_bestAlpha); LOG(5,<<"# bestTamura92ParamAlphaAndBBL::bestTamura92ParamAlphaAndBBL iteration " << i << ": after param optimization:" < oldL+epsilonLikelihoodImprovment) { oldL = newL; _bestL = newL; prevTrTv = _bestTrTv; prevTheta = _bestTheta; prevAlpha = _bestAlpha; prevTree = et; } else { if (newL>oldL) { _bestL = newL; } else { _bestL = oldL; _bestTrTv = prevTrTv; _bestTheta = prevTheta; et = prevTree; } break; } } } bestTamura92ParamAlphaAndBBLProportional::bestTamura92ParamAlphaAndBBLProportional( //find best TrTv, theta, loca Alpha for each gene, global Alpha and best branch lengths tree& et, vector& sc, multipleStochasticProcess* msp, gammaDistribution* pProportionDist, Vdouble initLocalAlphas, Vdouble initLocalKappas, Vdouble initLocalThetas, const MDOUBLE upperBoundOnLocalAlpha, const MDOUBLE initGlobalAlpha, const MDOUBLE upperBoundOnGlobalAlpha, const MDOUBLE upperBoundOnTrTv, const int maxTotalIterations, const int maxBBLIterations, const bool optimizeSelectedBranches, const bool optimizeTree, const string branchLengthOptimizationMethod, const bool optimizeLocalParams, const bool optimizeGlobalAlpha, const Vdouble * weights, const MDOUBLE epsilonLikelihoodImprovment, const MDOUBLE epsilonLoglikelihoodForLocalTrTvOptimization, const MDOUBLE epsilonLoglikelihoodForLocalThetaOptimization, const MDOUBLE epsilonLoglikelihoodForLocalAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForGlobalAlphaOptimization, const MDOUBLE epsilonLoglikelihoodForBBL) { LOG(5,<<"Starting bestTamura92ParamAlphaAndBBLProportional"<getSPVecSize()); //doubleRep oldL(VERYSMALL);//DR //doubleRep newL;//DR MDOUBLE oldL = VERYSMALL; MDOUBLE newL; //doubleRep epsilonLoglikelihoodForGlobalAlphaOptimizationDR(epsilonLoglikelihoodForGlobalAlphaOptimization);//DR _bestLvec.resize(msp->getSPVecSize(),0.0); _bestLocalAlphaVec = initLocalAlphas; _bestGlobalAlpha = initGlobalAlpha; int spIndex; _bestTrTvVec = currentTrTvVec; _bestThetaVec = currentThetaVec; pProportionDist->setAlpha(_bestGlobalAlpha); for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->changeTheta(_bestThetaVec[spIndex]);//safety (static_cast(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->changeTrTv(_bestTrTvVec[spIndex]); (static_cast(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); } //first compute the likelihood; _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); MDOUBLE ax_local = 0.0; MDOUBLE c_TrTv_x = upperBoundOnTrTv; MDOUBLE c_theta_x = 1.0; MDOUBLE c_localAlpha_x = upperBoundOnLocalAlpha; for (int i=0; i < maxTotalIterations; ++i) { if(optimizeLocalParams){ for(spIndex = 0;spIndex < msp->getSPVecSize();++spIndex){ //optimize Theta MDOUBLE theta_x(_bestThetaVec[spIndex]); newLvec[spIndex] = -brent(ax_local,theta_x,c_theta_x, C_evalLocalTheta(et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForLocalThetaOptimization, ¤tThetaVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _bestThetaVec[spIndex] = currentThetaVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing TrTv param"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->changeTheta(_bestThetaVec[spIndex]);//safety //optimize TrTv MDOUBLE TrTv_x(_bestTrTvVec[spIndex]); newLvec[spIndex] = -brent(ax_local,TrTv_x,c_TrTv_x, C_evalLocalTrTvParam(et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForLocalTrTvOptimization, ¤tTrTvVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _bestTrTvVec[spIndex] = currentTrTvVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing TrTv param"<(msp->getSp(spIndex)->getPijAccelerator()->getReplacementModel()))->changeTrTv(_bestTrTvVec[spIndex]);//safety //optimize local alpha MDOUBLE localAlpha_x(_bestLocalAlphaVec[spIndex]); newLvec[spIndex] = -brent(ax_local,localAlpha_x, c_localAlpha_x, C_evalLocalAlpha(et,sc[spIndex],*msp->getSp(spIndex),pProportionDist,weights), epsilonLoglikelihoodForLocalAlphaOptimization, ¤tLocalAlphaVec[spIndex]); if (newLvec[spIndex] >= _bestLvec[spIndex]) { _bestLvec[spIndex] = newLvec[spIndex]; _bestLocalAlphaVec[spIndex] = currentLocalAlphaVec[spIndex]; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing local alpha"<(msp->getSp(spIndex)->distr()))->setAlpha(_bestLocalAlphaVec[spIndex]); //safety } LOGnOUT(2,<<"Done with Tamura92 local params optimization. LL: "<= sumVdouble(_bestLvec)) { _bestGlobalAlpha = currentGlobalAlpha; } else {//likelihood went down! LOG(2,<<"likelihood went down in optimizing global alpha"<setAlpha(_bestGlobalAlpha); //safety //whether or not likelihood has improved we need to update _bestLvec _bestLvec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist,weights); LOGnOUT(2,<<"Done with global alpha optimization"< oldL+epsilonLikelihoodImprovment) { //all params have already been updated oldL = sumVdouble(_bestLvec); } else { break; } LOGnOUT(4,<<"Done with optimization iteration "<(time(0)) ; MDOUBLE talRandom::DblGammaGreaterThanOne(MDOUBLE dblAlpha) { // Code adopted from David Heckerman //----------------------------------------------------------- // DblGammaGreaterThanOne(dblAlpha) // // routine to generate a gamma random variable with unit scale and // alpha > 1 // reference: Ripley, Stochastic Simulation, p.90 // Chang and Feast, Appl.Stat. (28) p.290 //----------------------------------------------------------- MDOUBLE rgdbl[6]; rgdbl[1] = dblAlpha - 1.0; rgdbl[2] = (dblAlpha - (1.0 / (6.0 * dblAlpha))) / rgdbl[1]; rgdbl[3] = 2.0 / rgdbl[1]; rgdbl[4] = rgdbl[3] + 2.0; rgdbl[5] = 1.0 / sqrt(dblAlpha); for (;;) { MDOUBLE dblRand1; MDOUBLE dblRand2; do { dblRand1 = giveRandomNumberBetweenZeroAndEntry(1.0); dblRand2 = giveRandomNumberBetweenZeroAndEntry(1.0); if (dblAlpha > 2.5) dblRand1 = dblRand2 + rgdbl[5] * (1.0 - 1.86 * dblRand1); } while (!(0.0 < dblRand1 && dblRand1 < 1.0)); MDOUBLE dblTemp = rgdbl[2] * dblRand2 / dblRand1; if (rgdbl[3] * dblRand1 + dblTemp + 1.0 / dblTemp <= rgdbl[4] || rgdbl[3] * log(dblRand1) + dblTemp - log(dblTemp) < 1.0) { return dblTemp * rgdbl[1]; } } assert(false); return 0.0; } MDOUBLE talRandom::DblGammaLessThanOne(MDOUBLE dblAlpha){ //routine to generate a gamma random variable with //unit scale and alpha < 1 //reference: Ripley, Stochastic Simulation, p.88 MDOUBLE dblTemp; const MDOUBLE dblexp = exp(1.0); for (;;){ MDOUBLE dblRand0 = giveRandomNumberBetweenZeroAndEntry(1.0); MDOUBLE dblRand1 = giveRandomNumberBetweenZeroAndEntry(1.0); if (dblRand0 <= (dblexp / (dblAlpha + dblexp))){ dblTemp = pow(((dblAlpha + dblexp) * dblRand0) / dblexp, 1.0 / dblAlpha); if (dblRand1 <= exp(-1.0 * dblTemp)) return dblTemp; } else { dblTemp = -1.0 * log((dblAlpha + dblexp) * (1.0 - dblRand0) / (dblAlpha * dblexp)); if (dblRand1 <= pow(dblTemp,dblAlpha - 1.0)) return dblTemp; } } assert(false); return 0.0; } // DblGammaLessThanOne rate4site-3.0.0/src/phylogeny/computeSubstitutionCounts.cpp0000644011611301161130000004773412223673415021201 00000000000000#include "computeSubstitutionCounts.h" #include "computePosteriorExpectationOfSubstitutions.h" #include "computePosteriorExpectationOfSubstitutions_nonReversibleSp.h" #include "multipleStochasticProcess.h" #include "matrixUtils.h" #include "simulateJumps.h" #include "simulateCodonsJumps.h" #include "simulateJumpsAbstract.h" #include "treeIt.h" #include "treeUtil.h" /******************************************************************************************** computeSubstitutionCounts *********************************************************************************************/ computeSubstitutionCounts::computeSubstitutionCounts(const sequenceContainer& sc, const tree& tr, multipleStochasticProcess* MultSpPtr, string& outDir, VVVdouble& LpostPerSpPerCat, const int simulationsIterNum, const MDOUBLE probCutOffSum, bool isSilent): _tr(tr),_sc(sc),_pMSp(MultSpPtr),_outDir(outDir),_LpostPerSpPerCat(LpostPerSpPerCat), _simulationsIterNum(simulationsIterNum), _probCutOffSum(probCutOffSum),_isSilent(isSilent) { if(!_pMSp->getSPVecSize()){ errorMsg::reportError("Trying to call computeSubstitutionCounts with an empty multipleStochasticProcess object at computeSubstitutionCounts::computeSubstitutionCounts"); } _alphabetSize = _pMSp->getSp(0)->alphabetSize(); } computeSubstitutionCounts& computeSubstitutionCounts::operator=(const computeSubstitutionCounts &other){ if (this != &other) { // Check for self-assignment } return *this; } /******************************************************************************************** *********************************************************************************************/ void computeSubstitutionCounts::run() { for(int fatherStateIndex = 0;fatherStateIndex < _alphabetSize;++fatherStateIndex){ for(int sonStateIndex = 0;sonStateIndex < _alphabetSize;++sonStateIndex){ //if(sonStateIndex == fatherStateIndex) continue; _expMap_father2son[fatherStateIndex][sonStateIndex].resize(_sc.seqLen(),0); _probMap_father2son[fatherStateIndex][sonStateIndex].resize(_sc.seqLen(),0); } } resize_VVVV(_sc.seqLen(),_tr.getNodesNum(),_alphabetSize,_alphabetSize,_jointProb_PosNodeXY); resize_VVVV(_sc.seqLen(),_tr.getNodesNum(),_alphabetSize,_alphabetSize,_probChanges_PosNodeXY); resize_VVVV(_sc.seqLen(),_tr.getNodesNum(),_alphabetSize,_alphabetSize,_expChanges_PosNodeXY); computePosteriorOfChangeGivenTerminalsPerSpPerCat(); // GLM - multiple SPs } /******************************************************************************************** *********************************************************************************************/ void computeSubstitutionCounts::computePosteriorOfChangeGivenTerminalsPerSpPerCat() { int numOfSPs = _pMSp->getSPVecSize(); // per Sp for (int spIndex=0; spIndex < numOfSPs; ++spIndex) { // Per RateCategory -- All the computations are done while looping over rate categories stochasticProcess * currentSp = _pMSp->getSp(spIndex); int numOfRateCategories = currentSp->categories(); for (int rateCategIndex=0 ; rateCategIndex < numOfRateCategories;++rateCategIndex) { tree copy_et = _tr; MDOUBLE rateCategVal = currentSp->rates(rateCategIndex); MDOUBLE minimumRateCategVal = 0.0000001; MDOUBLE rate2multiply = max(rateCategVal,minimumRateCategVal); if(rateCategVal < minimumRateCategVal){ LOGnOUT(4, <<" >>> NOTE: the rate category "<runSimulation(_simulationsIterNum); if(!_isSilent) LOGnOUT(4,<<"finished simulations"<isReversible()) cpesPerRateCategoryPerPos = new computePosteriorExpectationOfSubstitutions(copy_et,_sc,currentSp); // Per POS,CAT else cpesPerRateCategoryPerPos = new computePosteriorExpectationOfSubstitutions_nonReversibleSp(copy_et,_sc,currentSp); // Per POS,CAT cpesPerRateCategoryPerPos->computePosteriorOfChangeGivenTerminals(posteriorsGivenTerminalsPerRateCategoryPerPos,pos); // II) Exp - take in account both: 1) simulations 2) posteriorsGivenTerminal VVVdouble expChangesForBranchPerRateCategoryPerPos; // Sim+Exp resize_VVV(_tr.getNodesNum(),_alphabetSize,_alphabetSize,expChangesForBranchPerRateCategoryPerPos); VVdouble expVV = cpesPerRateCategoryPerPos->computeExpectationAcrossTree(*simPerRateCategory,posteriorsGivenTerminalsPerRateCategoryPerPos, expChangesForBranchPerRateCategoryPerPos); // Per POS for(int fatherStateIndex = 0;fatherStateIndex < _alphabetSize;++fatherStateIndex){ for(int sonStateIndex = 0;sonStateIndex < _alphabetSize;++sonStateIndex){ if(sonStateIndex == fatherStateIndex) continue; _expMap_father2son[fatherStateIndex][sonStateIndex][pos] += expVV[fatherStateIndex][sonStateIndex]*_LpostPerSpPerCat[spIndex][rateCategIndex][pos]; } } // III) Sim - take in account both: 1) simulations 2) posteriorsGivenTerminal VVVdouble probChangesForBranchPerRateCategoryPerPos; // Sim+Prob resize_VVV(_tr.getNodesNum(),_alphabetSize,_alphabetSize,probChangesForBranchPerRateCategoryPerPos); VVdouble probVV = cpesPerRateCategoryPerPos->computePosteriorAcrossTree(*simPerRateCategory,posteriorsGivenTerminalsPerRateCategoryPerPos,probChangesForBranchPerRateCategoryPerPos); for(int fatherStateIndex = 0;fatherStateIndex < _alphabetSize;++fatherStateIndex){ for(int sonStateIndex = 0;sonStateIndex < _alphabetSize;++sonStateIndex){ if(sonStateIndex == fatherStateIndex) continue; _probMap_father2son[fatherStateIndex][sonStateIndex][pos] += probVV[fatherStateIndex][sonStateIndex]*_LpostPerSpPerCat[spIndex][rateCategIndex][pos]; } } // Store all information PerCat,PerPOS for(int i=0;i<_probChanges_PosNodeXY[pos].size();++i){ // nodeId for(int j=0;j<_probChanges_PosNodeXY[pos][i].size();++j){ // fatherState for(int k=0;k<_probChanges_PosNodeXY[pos][i][j].size();++k){ // sonState _jointProb_PosNodeXY[pos][i][j][k] += posteriorsGivenTerminalsPerRateCategoryPerPos[i][j][k]*_LpostPerSpPerCat[spIndex][rateCategIndex][pos]; _probChanges_PosNodeXY[pos][i][j][k] += probChangesForBranchPerRateCategoryPerPos[i][j][k]*_LpostPerSpPerCat[spIndex][rateCategIndex][pos]; _expChanges_PosNodeXY[pos][i][j][k] += expChangesForBranchPerRateCategoryPerPos[i][j][k]*_LpostPerSpPerCat[spIndex][rateCategIndex][pos]; } } } delete(cpesPerRateCategoryPerPos); } delete(simPerRateCategory); // Per POS } // per rateCat } // Per Sp } /******************************************************************************************** printProbExp() print perPos (over all branches) use the members _expV01, _expV10 for basic *********************************************************************************************/ void computeSubstitutionCounts::printProbExp() { string posteriorExpectationOfChangeString = _outDir + "//" + "posteriorExpectationOfChange.txt"; ofstream posteriorExpectationStream(posteriorExpectationOfChangeString.c_str()); string posteriorProbabilityOfChangeString = _outDir + "//" + "posteriorProbabilityOfChange.txt"; ofstream posteriorProbabilityStream(posteriorProbabilityOfChangeString.c_str()); int fatherStateIndex,sonStateIndex; posteriorExpectationStream<<"#POS"<<"\t"; posteriorProbabilityStream<<"#POS"<<"\t"; for (fatherStateIndex = 0;fatherStateIndex < _alphabetSize;++fatherStateIndex){ for (sonStateIndex = 0;sonStateIndex < _alphabetSize;++sonStateIndex){ if(sonStateIndex == fatherStateIndex) continue; posteriorExpectationStream<<_sc.getAlphabet()->fromInt(fatherStateIndex)<<"->"<<_sc.getAlphabet()->fromInt(sonStateIndex)<<"\t"; posteriorProbabilityStream<<_sc.getAlphabet()->fromInt(fatherStateIndex)<<"->"<<_sc.getAlphabet()->fromInt(sonStateIndex)<<"\t"; } } posteriorExpectationStream<fromInt(fatherStateIndex)<<"->"<<_sc.getAlphabet()->fromInt(sonStateIndex)<<"\t"; } } countProbPerPosStream<id()][fatherStateIndex][sonStateIndex] > _probCutOffSum){//NIM out<<_sc.getAlphabet()->fromInt(fatherStateIndex)<<"->"<<_sc.getAlphabet()->fromInt(sonStateIndex)<<"\t"<name()<<"\t"<dis2father()<<"\t"<id()][fatherStateIndex][sonStateIndex]<id()][fatherStateIndex][sonStateIndex]; } } } } outCount<fromInt(fatherStateIndex)<<"->"<<_sc.getAlphabet()->fromInt(sonStateIndex)<<"\t"<< mynode->name()<<"\t"<dis2father()<<"\t"<id()][fatherStateIndex][sonStateIndex]<fromInt(fatherStateIndex)<<"->"<<_sc.getAlphabet()->fromInt(sonStateIndex)<<"\t"<< pos+1<<"\t"<name()<<"\t"<dis2father()<<"\t"<id()][fatherStateIndex][sonStateIndex]<<"\t"<id()][fatherStateIndex][sonStateIndex]<id()][fatherStateIndex][sonStateIndex]; expFather2Son[fatherStateIndex][sonStateIndex] += expChanges[mynode->id()][fatherStateIndex][sonStateIndex]; if (probChanges[mynode->id()][fatherStateIndex][sonStateIndex] > countCutOff) countFather2Son[fatherStateIndex][sonStateIndex] += 1; } } } for(fatherStateIndex = 0;fatherStateIndex < _alphabetSize;++fatherStateIndex){ for(sonStateIndex = 0;sonStateIndex < _alphabetSize;++sonStateIndex){ if(sonStateIndex == fatherStateIndex) continue; outSum<fromInt(fatherStateIndex)<<"->"<<_sc.getAlphabet()->fromInt(sonStateIndex)<<"\t"<< probFather2Son[fatherStateIndex][sonStateIndex]<<"\t"< fromCountTableComponentToDistance::fromCountTableComponentToDistance( const countTableComponentGam& ctc, const stochasticProcess &sp, const MDOUBLE toll, const MDOUBLE brLenIntialGuess, unObservableData* unObservableData_p) : _sp(sp), _ctc(ctc),_unObservableData_p(unObservableData_p) { _distance = brLenIntialGuess ;//0.03; _toll = toll; } void fromCountTableComponentToDistance::computeDistance() { MDOUBLE maxPairwiseDistance = 10.0; // The default is 5.0 MDOUBLE minPairwiseDistance = 0.0000001; // The default likeDist likeDist1(_sp,_toll,maxPairwiseDistance,minPairwiseDistance,_unObservableData_p); MDOUBLE initGuess = _distance; _distance = likeDist1.giveDistance(_ctc,_likeDistance,initGuess); assert(_distance>=0); } rate4site-3.0.0/src/phylogeny/computeCounts.cpp0000644011611301161130000001651012223673416016531 00000000000000// $Id: computeCounts.cpp 9899 2011-10-11 19:56:48Z rubi $ #include "computeCounts.h" void computeCounts::computeCountsNodeFatherNodeSonHomPos(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, const MDOUBLE weight, const doubleRep posProb, const tree::nodeP nodeSon, countTableComponentHom& _ctc, const MDOUBLE rateCategorProb ) { assert(posProb>0.0); if (weight == 0) return; int alph1,alph2; for (alph1 =0; alph1< pi.alphabetSize(); ++alph1) { for (alph2 =0; alph2< pi.alphabetSize(); ++alph2) { doubleRep tmp = cup.get(nodeSon->id(),alph1) * cdown.get(nodeSon->id(),alph2) * pi.getPij(nodeSon->id(),alph1,alph2)* sp.freq(alph1) * rateCategorProb / posProb; _ctc.addToCounts(alph1,alph2,convert(tmp)*weight); } } } //old void computeCounts::computeCountsNodeFatherNodeSonHomPosProportionalEB(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, const MDOUBLE weight, const doubleRep posProb, const tree::nodeP nodeSon, countTableComponentHom& _ctc, const MDOUBLE globalLocalRateCategorProb) { assert(posProb>0.0); if (weight == 0) return; int alph1,alph2; for (alph1 =0; alph1< pi.alphabetSize(); ++alph1) { for (alph2 =0; alph2< pi.alphabetSize(); ++alph2) { //here we multiply: P(a,b|globalRate_x,localRate_y,D)*P(globalRate_x,localRate_y|D) //which is: (up*down)*[(P(D|globalRate_x,localRate_y)*GlobalLocalRateCategoriesProb)/posProb] doubleRep tmp = (cup.get(nodeSon->id(),alph1) * cdown.get(nodeSon->id(),alph2)) * (pi.getPij(nodeSon->id(),alph1,alph2) * sp.freq(alph1) * globalLocalRateCategorProb / posProb); _ctc.addToCounts(alph1,alph2,convert(tmp)*weight); } } } //new void computeCounts::computeCountsNodeFatherNodeSonHomPosProportionalEB(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, const MDOUBLE weight, const VdoubleRep posProbVec, const tree::nodeP nodeSon, countTableComponentHom& _ctc) { if (weight == 0) return; int alph1,alph2; doubleRep posProb(0.0); for(int globalRateCat = 0;globalRateCat < posProbVec.size();++globalRateCat){ posProb += posProbVec[globalRateCat]; } for (alph1 =0; alph1< pi.alphabetSize(); ++alph1) { for (alph2 =0; alph2< pi.alphabetSize(); ++alph2) { //here we multiply: P(a,b|globalRate_x,localRate_y,D)*P(globalRate_x,localRate_y|D) //which is: (up*down)*[(P(D|globalRate_x,localRate_y)*GlobalLocalRateCategoriesProb)/posProb] doubleRep tmp = (cup.get(nodeSon->id(),alph1) * cdown.get(nodeSon->id(),alph2)) * (pi.getPij(nodeSon->id(),alph1,alph2) * sp.freq(alph1) / posProb); _ctc.addToCounts(alph1,alph2,convert(tmp)*weight); } } } void computeCounts::computeCountsNodeFatherNodeSonHomPos(const sequenceContainer& sc, const computePijHom& pi, const stochasticProcess& sp, const suffStatGlobalHomPos& cup, const suffStatGlobalHomPos& cdown, //_cdown[categor][letterAtRoot] const MDOUBLE weight, const doubleRep posProb, const tree::nodeP nodeSon, countTableComponentHom& _ctc, //_computeCountsV[mynode->id()][letterAtRoot][categor] const MDOUBLE rateCategorProb, const int letterInRoot ) { assert(posProb>0.0); if (weight == 0) return; int alph1,alph2; for (alph1 =0; alph1< pi.alphabetSize(); ++alph1) { for (alph2 =0; alph2< pi.alphabetSize(); ++alph2) { doubleRep tmp = cup.get(nodeSon->id(),alph1) * cdown.get(nodeSon->id(),alph2) * // down was already given with specific root pi.getPij(nodeSon->id(),alph1,alph2)* sp.freq(alph1) // fixed root? or already computed byt the downAlg? * rateCategorProb //* sp.freq(letterInRoot) // to account for the additional letterAtRoot loop - move it to after getCounts /posProb; _ctc.addToCounts(alph1,alph2,convert(tmp)*weight); } } } void computeCounts::fillCountTableComponentGam(countTableComponentGam& ctcGam, const stochasticProcess& sp, const sequenceContainer& sc, const computePijGam& pij0, const suffStatGlobalGam& cup, const suffStatGlobalGam& cdown, const Vdouble * weights, tree::nodeP nodeSon, const VdoubleRep& posProbVec) { ctcGam.countTableComponentAllocatePlace(sp.alphabetSize(),sp.categories()); for (int rateCat =0; rateCat< sp.categories(); ++ rateCat) { fillCountTableComponentGamSpecRateCategor(rateCat,ctcGam[rateCat],sp, sc,pij0[rateCat], cup,cdown,weights,posProbVec,nodeSon); } } void computeCounts::fillCountTableComponentGamSpecRateCategor(const int rateCategor, countTableComponentHom& ctcHom, const stochasticProcess& sp, const sequenceContainer& sc, const computePijHom& pi, const suffStatGlobalGam& cup, const suffStatGlobalGam& cdown, const Vdouble * weights, const VdoubleRep& posProbVec, //prob of the position with gamma tree::nodeP nodeSon) { computeCounts cc; for (int pos = 0; pos < sc.seqLen(); ++pos) { MDOUBLE weig = (weights ? (*weights)[pos] : 1.0); cc.computeCountsNodeFatherNodeSonHomPos(sc,pi,sp,cup[pos][rateCategor], cdown[pos][rateCategor], weig,posProbVec[pos],nodeSon, ctcHom,sp.ratesProb(rateCategor)); } } /* void computeCounts::computeCountsNodeXNodeYHomPos( const tree::nodeP nodeX, const tree::nodeP nodeY) { const tree::nodeP nodeFather = nodeSon->father(); _ctc.zero(); if (_weight!=NULL) { // this is one of the MAIN LOOPS. no "if"s deep inside it! for (int pos=0; pos< _pi.seqLen(); ++pos) { if ((*_weight)[pos] == 0) continue; for (int alph1 =0; alph1< _pi.alphabetSize(); ++alph1) { for (int alph2 =0; alph2< _pi.alphabetSize(); ++alph2) { for (int rate =0; rate< _pi.categories(); ++rate) { MDOUBLE tmp = _cup.get(nodeSon->id(),pos,rate,alph1) * _cdown.get(nodeSon->id(),pos,rate,alph2) * _pi.pij(pos)->getPij(nodeSon->id(),alph1,alph2,rate)* _pi.stocProcessFromPos(pos)->freq(alph1)/ _cprobAtEachPos.getProb(pos); _ctc.addToCounts(alph1,alph2,rate,tmp*(*_weight)[pos]); } } } } } else { for (int pos=0; pos< _pi.seqLen(); ++pos) { for (int alph1 =0; alph1< _pi.alphabetSize(); ++alph1) { for (int alph2 =0; alph2< _pi.alphabetSize(); ++alph2) { for (int rate =0; rate< _pi.categories(); ++rate) { MDOUBLE tmp = _cup.get(nodeSon->id(),pos,rate,alph1) * _cdown.get(nodeSon->id(),pos,rate,alph2) * _pi.pij(pos)->getPij(nodeSon->id(),alph1,alph2,rate)* _pi.stocProcessFromPos(pos)->freq(alph1)/ _cprobAtEachPos.getProb(pos); _ctc.addToCounts(alph1,alph2,rate,tmp); } } } } } */ rate4site-3.0.0/src/phylogeny/computeDownAlg.cpp0000644011611301161130000001716112223673415016613 00000000000000// $Id: computeDownAlg.cpp 4585 2008-08-05 15:02:58Z cohenofi $ #include "definitions.h" #include "computeDownAlg.h" #include "treeIt.h" void computeDownAlg::fillComputeDown(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalHomPos& ssc, const suffStatGlobalHomPos& cup){ ssc.allocatePlace(et.getNodesNum(), pi.alphabetSize()); treeIterTopDownConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter,letterInFather,bro,letterInSon; if (mynode->father()==NULL) {// if root for(letter=0; letterid(),letter,1.0); } mynode = tIt.next(); //continue } tree::nodeP fatherNode=mynode->father(); const int n_bro=fatherNode->getNumberOfSons(); for(letter=0; letterfather()!=NULL) { for(letterInFather=0; letterInFatherid(),letter,letterInFather)* ssc.get(fatherNode->id(),letterInFather); } else { fatherTerm=1.0; } doubleRep brotherTerm=1.0; for(bro = 0; bro < n_bro; bro++) { tree::nodeP brother = fatherNode->getSon(bro); if (brother != mynode) { doubleRep tmp_bro=0.0; for(letterInSon=0; letterInSongetSon(bro)->id(),letter,letterInSon)* cup.get(brother->id(),letterInSon); } brotherTerm *=tmp_bro; } } totalProb = fatherTerm * brotherTerm; ssc.set(mynode->id(),letter,totalProb); } } } //use Pij(t) from the stochastic process instead of precomputed probabilities (via the computePijHom class) void computeDownAlg::fillComputeDown(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const suffStatGlobalHomPos& cup){ ssc.allocatePlace(et.getNodesNum(), sp.alphabetSize()); treeIterTopDownConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter, letterInFather, bro, letterInSon; if (mynode->isRoot()) {// if root: set all values to 1.0 for(letter = 0; letter < sp.alphabetSize(); letter++) { ssc.set(mynode->id(), letter, 1.0); } mynode = tIt.next(); //continue } tree::nodeP fatherNode = mynode->father(); const int n_bro = fatherNode->getNumberOfSons(); for(letter = 0; letter < sp.alphabetSize(); letter++) { doubleRep totalProb=1.0; doubleRep fatherTerm=0; if (fatherNode->isRoot()) { fatherTerm = 1.0; } else { for(letterInFather = 0; letterInFather < sp.alphabetSize(); letterInFather++) { MDOUBLE dist = fatherNode->dis2father() * sp.getGlobalRate(); fatherTerm += sp.Pij_t(letter, letterInFather, dist) * ssc.get(fatherNode->id(), letterInFather); } } doubleRep brotherTerm = 1.0; for(bro = 0; bro < n_bro; bro++) { tree::nodeP brother = fatherNode->getSon(bro); if (brother != mynode) { doubleRep tmp_bro=0.0; for(letterInSon = 0; letterInSon < sp.alphabetSize(); letterInSon++) { MDOUBLE dist = brother->dis2father() * sp.getGlobalRate(); tmp_bro += sp.Pij_t(letter, letterInSon, dist) * cup.get(brother->id(), letterInSon); } brotherTerm *= tmp_bro; } } totalProb = fatherTerm * brotherTerm; ssc.set(mynode->id(), letter, totalProb); } } } //compute probabilities with a site-specific rate void computeDownAlg::fillComputeDownSpecificRate(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const suffStatGlobalHomPos& cup, const MDOUBLE gRate){ ssc.allocatePlace(et.getNodesNum(), sp.alphabetSize()); treeIterTopDownConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter, letterInFather, bro, letterInSon; if (mynode->isRoot()) {// if root: set all values to 1.0 for(letter = 0; letter < sp.alphabetSize(); letter++) { ssc.set(mynode->id(), letter, 1.0); } mynode = tIt.next(); //continue } tree::nodeP fatherNode = mynode->father(); const int n_bro = fatherNode->getNumberOfSons(); for(letter = 0; letter < sp.alphabetSize(); letter++) { doubleRep totalProb=1.0; doubleRep fatherTerm=0; if (fatherNode->isRoot()) { fatherTerm = 1.0; } else { for(letterInFather = 0; letterInFather < sp.alphabetSize(); letterInFather++) { MDOUBLE dist = fatherNode->dis2father() * gRate * sp.getGlobalRate(); fatherTerm += sp.Pij_t(letter, letterInFather, dist) * ssc.get(fatherNode->id(), letterInFather); } } doubleRep brotherTerm = 1.0; for(bro = 0; bro < n_bro; bro++) { tree::nodeP brother = fatherNode->getSon(bro); if (brother != mynode) { doubleRep tmp_bro=0.0; for(letterInSon = 0; letterInSon < sp.alphabetSize(); letterInSon++) { MDOUBLE dist = brother->dis2father() * gRate * sp.getGlobalRate(); tmp_bro += sp.Pij_t(letter, letterInSon, dist) * cup.get(brother->id(), letterInSon); } brotherTerm *= tmp_bro; } } totalProb = fatherTerm * brotherTerm; ssc.set(mynode->id(), letter, totalProb); } } } // The filled sscGivenRoot is using the "Gam" class (over all rate categories) for placing letter@root hidden state void computeDownAlg::fillComputeDownNonReversible(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalGamPos& sscGivenRoot, const suffStatGlobalHomPos& cup) { sscGivenRoot.allocatePlace(pi.alphabetSize(),et.getNodesNum(), pi.alphabetSize()); treeIterTopDownConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter,letterInFather,bro,letterInSon; if (mynode->father()==NULL) {//root for (int letterAtRoot=0; letterAtRootid(),letter,ind); } } mynode = tIt.next(); //continue } tree::nodeP fatherNode=mynode->father(); const int n_bro=fatherNode->getNumberOfSons(); for(int letterAtRoot=0; letterAtRootfather()!=NULL) { // not son of root for(letterInFather=0; letterInFatherid(),letterInFather,letter)* sscGivenRoot.get(letterAtRoot,fatherNode->id(),letterInFather); } else {//son of root fatherTerm=(letterAtRoot==letter?1.0:0.0); } doubleRep brotherTerm=1.0; for(bro = 0; bro < n_bro; bro++) { tree::nodeP brother = fatherNode->getSon(bro); if (brother != mynode) { doubleRep tmp_bro=0.0; for(letterInSon=0; letterInSongetSon(bro)->id(),letter,letterInSon)* cup.get(brother->id(),letterInSon); } brotherTerm *=tmp_bro; } } totalProb = fatherTerm * brotherTerm; sscGivenRoot.set(letterAtRoot,mynode->id(),letter,totalProb); } } } }rate4site-3.0.0/src/phylogeny/computeUpAlg.cpp0000644011611301161130000001235412223673415016267 00000000000000// $Id: computeUpAlg.cpp 5988 2009-03-18 18:20:05Z itaymay $ #include "definitions.h" #include "computeUpAlg.h" #include "treeIt.h" #include "seqContainerTreeMap.h" #include "logFile.h" #include #include using namespace std; void computeUpAlg::fillComputeUp(const tree& et, const sequenceContainer & sc, const computePijGam& pi, suffStatGlobalGam& ssc) { computeUpAlg cupAlg; ssc.allocatePlace(sc.seqLen(),pi.categories(),et.getNodesNum(),pi.alphabetSize()); for (int pos = 0; pos < sc.seqLen(); ++pos) { for (int categor = 0; categor < pi.categories(); ++categor) { cupAlg.fillComputeUp(et,sc,pos,pi[categor],ssc[pos][categor]); } } } void computeUpAlg::fillComputeUp(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalHomPos& ssc) { seqContainerTreeMap sctm(sc,et); ssc.allocatePlace(et.getNodesNum(),pi.alphabetSize()); treeIterDownTopConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter; if (mynode->isLeaf()) { for(letter=0; letterid()); doubleRep val = sc.getAlphabet()->relations(sc[seqID][pos],letter); ssc.set(mynode->id(),letter,val); } } else { for(letter=0; lettergetNumberOfSons();++i){ doubleRep prob=0.0; for(int letInSon=0; letInSongetSon(i)->id(), letInSon)* pi.getPij(mynode->getSon(i)->id(),letter,letInSon); } total_prob*=prob; } ssc.set(mynode->id(),letter,total_prob); } } } } /* void computeUpAlg::fillComputeUp(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc) { seqContainerTreeMap sctm(sc,et); ssc.allocatePlace(et.getNodesNum(),sp.alphabetSize()); treeIterDownTopConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter; if (mynode->isLeaf()) {// leaf for(letter=0; letterid()); MDOUBLE val = sc.getAlphabet()->relations(sc[seqID][pos],letter); ssc.set(mynode->id(),letter,val); } } else { for(letter=0; lettergetNumberOfSons();++i){ MDOUBLE prob=0.0; for(int letInSon=0; letInSongetSon(i)->id(),letInSon)* sp.Pij_t(letter,letInSon,mynode->getSon(i)->dis2father()*sp.getGlobalRate());// taking care of the glubal is new. } assert(prob>=0.0); total_prob*=prob; } ssc.set(mynode->id(),letter,total_prob); } } } } */ void computeUpAlg::fillComputeUpSpecificGlobalRate(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const MDOUBLE gRate) { if (sp.categories() >1) {// because we do not multiply all branch lengths by the rate[categories]) errorMsg::reportError("the function fillComputeUpSpecificGlobalRate should not be used with a gamma model"); } seqContainerTreeMap sctm(sc,et); ssc.allocatePlace(et.getNodesNum(),sp.alphabetSize()); treeIterDownTopConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { #ifdef VERBOS LOG(15,<name()<isLeaf()) { for(letter=0; letterid()); doubleRep val = sc.getAlphabet()->relations(sc[seqID][pos],letter); ssc.set(mynode->id(),letter,val); } } else { int letterWithTotalProbEqZero =0; for(letter=0; lettergetNumberOfSons();++i){ doubleRep prob=0.0; for(int letInSon=0; letInSongetSon(i)->id(),letInSon)>=0); assert(sp.Pij_t(letter,letInSon,mynode->getSon(i)->dis2father()*gRate)>=0); prob += ssc.get(mynode->getSon(i)->id(),letInSon)* sp.Pij_t(letter,letInSon,mynode->getSon(i)->dis2father()*gRate); } assert(prob>=0.0); total_prob*=prob; } if (total_prob==0.0) ++letterWithTotalProbEqZero; ssc.set(mynode->id(),letter,total_prob); } // end of else if (letterWithTotalProbEqZero == sp.alphabetSize() && (mynode->getNumberOfSons() > 0)) { LOG(5,<<" total prob =0"); for (int z=0; z getNumberOfSons(); ++z) { LOG(5,<<"son "<getSon(z)->name()<getSon(z)->dis2father()<getSon(z)->id(),letInSon) = "<getSon(z)->id(),letInSon))< #include #include #include using namespace std; void computeNodeFactorAndSetSsc(MDOUBLE & minFactor,suffStatGlobalHomPos& ssc, int nodeId, const int alphSize){ // given a number = probability (val), it is changed to a new number which is 10 to the power of factor + val. // for example if val = 0.001, it is changed to 0.1 and factor 2. minFactor=100000; for (int i=0; i < alphSize; ++i) { MDOUBLE tmpfactor=0; doubleRep val = ssc.get(nodeId,i); if (val >0) { while (val < 0.1) { val *=10; tmpfactor++; } } else tmpfactor=minFactor; if (tmpfactor(10.0),minFactor); ssc.set(nodeId,j,tmp); } } void computeUpAlg::fillComputeUpWithFactors(const tree& et, const sequenceContainer& sc, const int pos, const computePijHom& pi, suffStatGlobalHomPos& ssc, vector& factors) { factors.resize(et.getNodesNum(),0.0); seqContainerTreeMap sctm(sc,et); ssc.allocatePlace(et.getNodesNum(),pi.alphabetSize()); treeIterDownTopConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter; if (mynode->getNumberOfSons() == 0) {// leaf for(letter=0; letterid()); doubleRep val = sc.getAlphabet()->relations(sc[seqID][pos],letter); ssc.set(mynode->id(),letter,val); } computeNodeFactorAndSetSsc(factors[mynode->id()],ssc,mynode->id(),pi.alphabetSize()); } else { for(letter=0; lettergetNumberOfSons(); ++i){ doubleRep prob=0.0; for(int letInSon=0; letInSongetSon(i)->id(),letInSon)* pi.getPij(mynode->getSon(i)->id(),letter,letInSon); } total_prob*=prob; } ssc.set(mynode->id(),letter,total_prob); } computeNodeFactorAndSetSsc(factors[mynode->id()],ssc,mynode->id(),pi.alphabetSize()); for(int k=0; k < mynode->getNumberOfSons();++k) { factors[mynode->id()]+=factors[mynode->getSon(k)->id()]; } } } } void computeUpAlg::fillComputeUpWithFactors(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, vector& factors) { factors.resize(et.getNodesNum(),0.0); seqContainerTreeMap sctm(sc,et); ssc.allocatePlace(et.getNodesNum(),sp.alphabetSize()); treeIterDownTopConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { int letter; if (mynode->getNumberOfSons() == 0) {// leaf for(letter=0; letterid()); doubleRep val = sc.getAlphabet()->relations(sc[seqID][pos],letter); ssc.set(mynode->id(),letter,val); } computeNodeFactorAndSetSsc(factors[mynode->id()],ssc,mynode->id(),sp.alphabetSize()); } else { for(letter=0; lettergetNumberOfSons();++i){ doubleRep prob=0.0; for(int letInSon=0; letInSongetSon(i)->id(),letInSon)* sp.Pij_t(letter,letInSon,mynode->getSon(i)->dis2father()*sp.getGlobalRate());// taking care of the glubal is new. } assert(prob>=0); total_prob*=prob; } ssc.set(mynode->id(),letter,total_prob); } computeNodeFactorAndSetSsc(factors[mynode->id()],ssc,mynode->id(),sp.alphabetSize()); for(int k=0; k < mynode->getNumberOfSons();++k) { factors[mynode->id()]+=factors[mynode->getSon(k)->id()]; } } } } void computeUpAlg::fillComputeUpSpecificGlobalRateFactors(const tree& et, const sequenceContainer& sc, const int pos, const stochasticProcess& sp, suffStatGlobalHomPos& ssc, const MDOUBLE gRate, vector& factors) { factors.resize(et.getNodesNum(),0.0); seqContainerTreeMap sctm(sc,et); ssc.allocatePlace(et.getNodesNum(),sp.alphabetSize()); treeIterDownTopConst tIt(et); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { #ifdef VERBOS LOG(5,<name()<getNumberOfSons() == 0) {// leaf for(letter=0; letterid()); doubleRep val = sc.getAlphabet()->relations(sc[seqID][pos],letter); ssc.set(mynode->id(),letter,val); } computeNodeFactorAndSetSsc(factors[mynode->id()],ssc,mynode->id(),sp.alphabetSize()); } else { int letterWithTotalProbEqZero =0; for(letter=0; lettergetNumberOfSons();++i){ doubleRep prob=0.0; for(int letInSon=0; letInSongetSon(i)->id(),letInSon)>=0); assert(sp.Pij_t(letter,letInSon,mynode->getSon(i)->dis2father()*gRate)>=0); prob += ssc.get(mynode->getSon(i)->id(),letInSon)* sp.Pij_t(letter,letInSon,mynode->getSon(i)->dis2father()*gRate); } assert(prob>=0); total_prob*=prob; } if (total_prob ==0) ++letterWithTotalProbEqZero; ssc.set(mynode->id(),letter,total_prob); } // end of else computeNodeFactorAndSetSsc(factors[mynode->id()],ssc,mynode->id(),sp.alphabetSize()); for(int k=0; k < mynode->getNumberOfSons();++k) { factors[mynode->id()]+=factors[mynode->getSon(k)->id()]; } if (letterWithTotalProbEqZero == sp.alphabetSize() && (mynode->getNumberOfSons() > 0)) { LOG(5,<<" total prob =0"); for (int z=0; z getNumberOfSons(); ++z) { LOG(5,<<"son "<getSon(z)->name()<getSon(z)->dis2father()<sons[z]->id(),letInSon) = "<getSon(z)->id(),letInSon))<getSon(i)->dis2father()*gRate) = "<sons[i]->dis2father()*gRate)<getSon(i)->dis2father() = "<getSon(i)->dis2father()< //gser: returns the incomplete Gamma function evaluated by its series representation void gser(MDOUBLE *gamser, MDOUBLE a, MDOUBLE x, MDOUBLE *gln) { //MDOUBLE gammln(MDOUBLE xx); int n; MDOUBLE sum,del,ap; *gln=gammln(a); if (x <= 0.0) { if (x < 0.0) LOG(1,<<"x less than 0 in routine gser"); *gamser=0.0; return; } else { ap=a; del=sum=1.0/a; for (n=1;n<=ITMAX;n++) { ++ap; del *= x/ap; sum += del; if (fabs(del) < fabs(sum)*EPS) { *gamser=sum*exp(-x+a*log(x)-(*gln)); return; } } LOG(1,<<"Too many interations in routine gser"); return; } } //gcf: returns the complement of the incomplete Gamma function evaluated by its continued fraction representation void gcf(MDOUBLE *gammcf, MDOUBLE a, MDOUBLE x, MDOUBLE *gln) { //MDOUBLE gammln(MDOUBLE xx); int i; MDOUBLE an,b,c,d,del,h; *gln=gammln(a); b=x+1.0-a; c=1.0/FPMIN; d=1.0/b; h=d; for (i=1;i<=ITMAX;i++) { an = -i*(i-a); b += 2.0; d=an*d+b; if (fabs(d) < FPMIN) d=FPMIN; c=b+an/c; if (fabs(c) < FPMIN) c=FPMIN; d=1.0/d; del=d*c; h *= del; if (fabs(del-1.0) < EPS) break; } if (i > ITMAX) LOG(1,<<"a too large, ITMAX too small in gcf"); *gammcf=exp(-x+a*log(x)-(*gln))*h; } //gammp(a, x): computes the incomplete Gamma function which is: // 1/Gamma(a) * (the integral from 0 to x of (t^(a-1)*e^(-t)) dt) //gammp can be computed in two different ways: by a series representation (gser(..)) //or by a continued fraction representation (gcf(..)) //gammp chooses to function will be used, according to the values of a and x MDOUBLE gammp(MDOUBLE a, MDOUBLE x) { //void gcf(MDOUBLE *gammcf, MDOUBLE a, MDOUBLE x, MDOUBLE *gln); //void gser(MDOUBLE *gamser, MDOUBLE a, MDOUBLE x, MDOUBLE *gln); MDOUBLE gamser,gammcf,gln; if (x < 0.0 || a <= 0.0) LOG(1,<<"Invalid arguments in routine gammp"); if (x < (a+1.0)) { gser(&gamser,a,x,&gln); return gamser; } else { gcf(&gammcf,a,x,&gln); return 1.0-gammcf; } } //I add//////////// MDOUBLE gammq(MDOUBLE a, MDOUBLE x) { void gcf(MDOUBLE *gammcf, MDOUBLE a, MDOUBLE x, MDOUBLE *gln); void gser(MDOUBLE *gamser, MDOUBLE a, MDOUBLE x, MDOUBLE *gln); MDOUBLE gamser,gammcf,gln; if (x < 0.0 || a <= 0.0) LOG(1,<<"Invalid arguments in routine gammp"); if (x < (a+1.0)) { gser(&gamser,a,x,&gln); return 1.0 - gamser; } else { gcf(&gammcf,a,x,&gln); return gammcf; } } /************************************************************************* // this function computed the ln of the gamma function // The Gamma funnction: Gamma(xx) = integral from 0 to infinity of (t^(xx-1)*e^(-t)) dt. *************************************************************************/ MDOUBLE gammln(MDOUBLE xx) { MDOUBLE x,y,tmp,ser; static MDOUBLE cof[6]={ static_cast(76.18009172947146), static_cast(-86.50532032941677), static_cast(24.01409824083091), static_cast(-1.231739572450155), static_cast(0.1208650973866179e-2), static_cast(-0.5395239384953e-5) }; int j; y=x=xx; tmp=x+5.5; tmp -= (x+0.5)*log(tmp); ser=1.000000000190015f; for (j=0;j<6;j++) ser += cof[j]/++y; return -tmp+log(2.5066282746310005*ser/x); } // MDOUBLE search_for_z_in_dis_with_any_beta(MDOUBLE alpha,MDOUBLE beta, MDOUBLE ahoson) { return (search_for_z_in_dis_with_beta_1(alpha,ahoson)/beta); } MDOUBLE search_for_z_in_dis_with_beta_1(MDOUBLE alpha, MDOUBLE ahoson) { if ( ahoson>1 || ahoson<0 ) errorMsg::reportError("Error in function search_for_z_in_dis_with_beta_1"); MDOUBLE left=0; MDOUBLE right=99999.0; MDOUBLE tmp=5000.0; MDOUBLE results=0.0; for (int i=0;i<100000000 ; i++) { results=gammp(alpha,tmp); if (fabs(ahoson-results)ahoson) { right=tmp; } else left=tmp; tmp=(right+left)/2; } cout << "ERROR in search_for_z_in_dis_with_beta_1() Alpha is: "<< alpha <isInternal()) continue; } sequenceContainer::constTaxaIterator it=sc.constTaxaBegin(); for (;it != sc.constTaxaEnd(); ++it) { string scName = it->name(); string treeNodeName = mynode->name(); if (it->name() == mynode->name()) { bFound = true; break; } } if (bFound == false) { string errMsg = "The taxID:\t"; errMsg += mynode->name(); errMsg += "\twas found in the tree file but not found in the sequence file. Removed from tree."; LOGnOUT(4,<isInternal()) continue; } if (myseq->name() == mynode->name()) { bFound = true; break; } } if (bFound == false) { string errMsg = "The taxID name:\t"; errMsg += myseq->name(); errMsg += "\twas found in the sequence file but not found in the tree file. Removed."; LOGnOUT(4,<id()); } } for(int i=0; iisInternal()) continue; } sequenceContainer::constTaxaIterator it=sc.constTaxaBegin(); for (;it != sc.constTaxaEnd(); ++it) { string scName = it->name(); string treeNodeName = mynode->name(); if (it->name() == mynode->name()) { bFound = true; break; } } if (bFound == false) { string errMsg = "The sequence name: "; errMsg += mynode->name(); errMsg += " was found in the tree file but not found in the sequence file.\n"; errMsg += " Please, Re-run program with _intersectTreeAndSeq to produce new MSA and Tree.\n"; LOG(4,<isInternal()) continue; } if (it->name() == mynode->name()) { bFound = true; break; } } if (bFound == false) { string errMsg = "The sequence name: "; errMsg += it->name(); errMsg += " was found in the sequence file but not found in the tree file.\n"; errMsg += " Please, Re-run program with _intersectTreeAndSeq to produce new MSA and Tree.\n"; errorMsg::reportError(errMsg); } } } /******************************************************************************************** // input: a tree and a sequence-container containing all of the leaves sequences. // output: fills sc_leaves with the sequences of the leaves only. *********************************************************************************************/ void getLeavesSequences(const sequenceContainer& sc, const tree& tr, sequenceContainer& sc_leaves) { vector leavesNames = getSequencesNames(tr); vector::iterator itr_leaves; for (itr_leaves=leavesNames.begin();itr_leaves!=leavesNames.end();++itr_leaves) { sequenceContainer::constTaxaIterator it_sc=sc.constTaxaBegin(); for (;it_sc != sc.constTaxaEnd(); ++it_sc) { if (it_sc->name() == *(itr_leaves)) { sc_leaves.add(*it_sc); break; } } } if (tr.getLeavesNum() != sc_leaves.numberOfSeqs()) { string errMsg = "getLeavesSequencese: the number of leaves is not equal to the number of leaves' sequences"; errorMsg::reportError(errMsg); } } rate4site-3.0.0/src/phylogeny/treeUtil.cpp0000644011611301161130000003201012223673416015447 00000000000000// $Id: treeUtil.cpp 10477 2012-03-18 07:58:05Z itaymay $ #include "definitions.h" #include "treeUtil.h" #include "treeIt.h" #include "someUtil.h" #include #include #include #include using namespace std; vector getStartingTreeVecFromFile(string fileName) { vector vecT; ifstream in; istream* inPtr = &cin; // default if (fileName != "-"){ in.open(fileName.c_str()); if (! in.is_open()) errorMsg::reportError(string("Error - unable to open tree vector file ")+fileName,1); inPtr = ∈ } while (!inPtr->eof()) { //inputf.eatwhite();// do not remove. Tal: 1.1.2003 vector myTreeCharVec = PutTreeFileIntoVector(*inPtr); if (myTreeCharVec.size() >0) { tree t1(myTreeCharVec); //LOGDO(5,t1.output(myLog::LogFile())); vecT.push_back(t1); } } if (in.is_open()) in.close(); return vecT; } void getStartingTreeVecFromFile(string fileName, vector& vecT, vector& constraintsOfT0) { ifstream in; istream* inPtr = &cin; // default if (fileName != "-"){ in.open(fileName.c_str()); if (! in.is_open()) errorMsg::reportError(string("Error - unable to open tree vector file ")+fileName,1); inPtr = ∈ } //inputf.eatwhite(); for (int i=0; !inPtr->eof() ; ++i) { // while (!inPtr->eof()) { vector myTreeCharVec = PutTreeFileIntoVector(*inPtr); if (myTreeCharVec.size() >0) { if (i==0) { tree t1(myTreeCharVec,constraintsOfT0); vecT.push_back(t1); } else { tree t1(myTreeCharVec); vecT.push_back(t1); } } } if (in.is_open()) in.close(); } #include using namespace std; bool sameTreeTolopogy(tree t1, tree t2){ if (t1.getNodesNum() != t2.getNodesNum()) { errorMsg::reportError("error in function same tree topology (1)"); } tree::nodeP x = t2.getRoot(); while (x->getNumberOfSons() > 0) x= x->getSon(0); t1.rootAt(t1.findNodeByName(x->name())->father()); // now they have the same root t2.rootAt(t2.findNodeByName(x->name())->father()); // now they have the same root map names1; treeIterDownTopConst tit1(t1); for (tree::nodeP nodeM = tit1.first(); nodeM != tit1.end(); nodeM = tit1.next()) { vector nameOfChild; for (int i=0; i < nodeM->getNumberOfSons();++i) { nameOfChild.push_back(names1[nodeM->getSon(i)->id()]); } if (nodeM->getNumberOfSons()==0) nameOfChild.push_back(nodeM->name()); sort(nameOfChild.begin(),nameOfChild.end()); string res = "("; for (int k=0; k < nameOfChild.size(); ++k) { res += nameOfChild[k]; } res += ")"; names1[nodeM->id()] = res; } map names2; treeIterDownTopConst tit2(t2); for (tree::nodeP nodeM2 = tit2.first(); nodeM2 != tit2.end(); nodeM2 = tit2.next()) { vector nameOfChild; for (int i=0; i < nodeM2->getNumberOfSons();++i) { nameOfChild.push_back(names2[nodeM2->getSon(i)->id()]); } if (nodeM2->getNumberOfSons()==0) nameOfChild.push_back(nodeM2->name()); sort(nameOfChild.begin(),nameOfChild.end()); string res = "("; for (int k=0; k < nameOfChild.size(); ++k) { res += nameOfChild[k]; } res += ")"; names2[nodeM2->id()] = res; } return names1[t1.getRoot()->id()] == names2[t2.getRoot()->id()]; } // bigTree is passed by value and not by reference. Therefore, this method doens't change the original bigTree, // but allocates a new bigTree to be split. bool cutTreeToTwo(tree bigTree, const string& nameOfNodeToCut, tree &small1, tree &small2){// cutting above the NodeToCut. // we want to cut the tree in two. // first step: we make a new node between the two nodes that have to be splited, tree::nodeP node2splitOnNewTree = bigTree.findNodeByName(nameOfNodeToCut); string interNode = "interNode"; if (node2splitOnNewTree->father() == NULL) return(false); // assert(node2splitOnNewTree->father() != NULL); tree::nodeP tmp = makeNodeBetweenTwoNodes(bigTree,node2splitOnNewTree->father(),node2splitOnNewTree, interNode); bigTree.rootAt(tmp); // tmp is the interNode and it's now the root of the tree. Its sons are node2splitOnNewTree and its father. string allNodes = "Runs/testBifurcating/beforeCut.tree"; bigTree.output(allNodes, tree::PHYLIP, true); cutTreeToTwoSpecial(bigTree,tmp, small1,small2); if (small1.getNodesNum() < 5 || small2.getNodesNum() < 5) return (false); LOGDO(15,small1.output(myLog::LogFile(),tree::ANCESTORID)); LOGDO(15,small2.output(myLog::LogFile(),tree::ANCESTORID)); tree::nodeP toDel1 = small1.findNodeByName(interNode); small1.removeLeaf(toDel1); tree::nodeP toDel2 = small2.findNodeByName(interNode); small2.removeLeaf(toDel2); // this part fix the ids. treeIterTopDown tIt(small1); int newId =0; for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { mynode->setID(newId); newId++; } treeIterTopDown tIt2(small2); int newId2 =0; for (tree::nodeP mynode2 = tIt2.first(); mynode2 != tIt2.end(); mynode2 = tIt2.next()) { mynode2->setID(newId2); newId2++; } return (true); // successes! }; // pre-request: // the intermediateNode is the root. // and it has two sons. // resultT1PTR & resultT2PTR are empty trees (root=NULL); void cutTreeToTwoSpecial(const tree& source, tree::nodeP intermediateNode, tree &resultT1PTR, tree &resultT2PTR) { // make sure that you got two empty trees: if (resultT1PTR.getRoot() != NULL) errorMsg::reportError("got a non empty tree1 in function cutTreeToTwoSpecial"); else if (resultT2PTR.getRoot() != NULL) errorMsg::reportError("got a non empty tree2 in function cutTreeToTwoSpecial"); // make sure the the intermediateNode is really an intermediate Node; if ((intermediateNode->getNumberOfSons() !=2 ) || (source.getRoot() != intermediateNode)) { errorMsg::reportError("intermediateNode in function cutTreeToTwoSpecial, is not a real intermediate node "); } resultT1PTR.createRootNode(); resultT1PTR.getRoot()->setName(intermediateNode->name()); resultT2PTR.createRootNode(); resultT2PTR.getRoot()->setName(intermediateNode->name()); resultT1PTR.recursiveBuildTree(resultT1PTR.getRoot(),intermediateNode->getSon(0)); resultT2PTR.recursiveBuildTree(resultT2PTR.getRoot(),intermediateNode->getSon(1)); } //insert a new node between fatherNode and sonNode tree::nodeP makeNodeBetweenTwoNodes(tree& et, tree::nodeP fatherNode, tree::nodeP sonNode, const string &interName){ //make sure that fatherNode is indeed the father and sonNode is the son (and not the opposite). if (fatherNode->father() == sonNode) { tree::nodeP tmp = fatherNode; fatherNode = sonNode; sonNode = tmp; } else if (sonNode->father() != fatherNode) { errorMsg::reportError("Error in function 'cut_tree_in_two'. the two nodes are not neighbours "); } tree::nodeP theNewNodePTR = new tree::TreeNode(et.getNodesNum()); //fix the tree information for the new node. theNewNodePTR->setName(interName); MDOUBLE tmpLen = sonNode->dis2father() * 0.5; theNewNodePTR->setDisToFather(tmpLen); theNewNodePTR->setFather(fatherNode); theNewNodePTR->setSon(sonNode); //fix the tree information for the father node. fatherNode->removeSon(sonNode); fatherNode->setSon(theNewNodePTR); //fix the tree information for the sonNode. sonNode->setFather(theNewNodePTR); sonNode->setDisToFather(tmpLen); return theNewNodePTR; } vector getSequencesNames(const tree& t){ vector vleaves; t.getAllLeaves(vleaves,t.getRoot()); vector res; vector::const_iterator i = vleaves.begin(); for ( ; iname()); } return res; } tree starTree(const vector& names) { tree et; et.createRootNode(); for (int k=0 ; k < names.size(); ++k) { tree::nodeP tmpNode; tmpNode = et.createNode(et.getRoot(),et.getNodesNum()); tmpNode->setDisToFather(tree::FLAT_LENGTH_VALUE); tmpNode->setName(names[k]); } et.create_names_to_internal_nodes(); return et; } MDOUBLE getSumOfBranchLengths(const tree &t){ treeIterDownTopConst tIt(t); MDOUBLE sum = 0; for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { if (!mynode->isRoot()){ sum+=mynode->dis2father(); } } return sum; } MDOUBLE getDistanceFromNode2ROOT(const tree::nodeP &myNode){ if(myNode->isRoot()) return 0.0; else return ( myNode->dis2father() + getDistanceFromNode2ROOT(myNode->father()) ); } void fillAllNodesNames(Vstring& Vnames,const tree& tr){ vector vAllNodes; tr.getAllNodes(vAllNodes,tr.getRoot()); Vnames.resize(vAllNodes.size()); for (int i = 0; iid()] = vAllNodes[i]->name(); } void printTreeWithValuesAsBP(ostream &out, const tree &tr, Vstring values, VVVdouble *probs, int from, int to) { printTreeWithValuesAsBP(out,tr.getRoot(), values,probs,from,to); out<<"["<id()]<<"];"; } void printTreeWithValuesAsBP(ostream &out, const tree::nodeP &myNode, Vstring values, VVVdouble *probs, int from, int to) { int fatherNodeIndex,sonNodeIndex; if (myNode->isLeaf()) { out<< myNode->name(); if(probs){ for(fatherNodeIndex = 0;fatherNodeIndex < (*probs)[myNode->id()].size();++fatherNodeIndex){ for(sonNodeIndex = 0;sonNodeIndex < (*probs)[myNode->id()][fatherNodeIndex].size();++sonNodeIndex){ if((from == fatherNodeIndex)&&(to == sonNodeIndex)){ out<<"_P_"<<(*probs)[myNode->id()][fatherNodeIndex][sonNodeIndex]<< ":"<dis2father(); } } } } return; } else { out <<"("; for (int i=0;igetNumberOfSons();++i) { if (i>0) out <<","; printTreeWithValuesAsBP(out, myNode->getSon(i), values,probs,from,to); } out <<")"; if (myNode->isRoot()==false) { out<< myNode->name(); if(probs){ for(fatherNodeIndex = 0;fatherNodeIndex < (*probs)[myNode->id()].size();++fatherNodeIndex){ for(sonNodeIndex = 0;sonNodeIndex < (*probs)[myNode->id()][fatherNodeIndex].size();++sonNodeIndex){ if((from == fatherNodeIndex)&&(to == sonNodeIndex)){ out<<"_P_"<<(*probs)[myNode->id()][fatherNodeIndex][sonNodeIndex]<< ":"<dis2father(); //< "["<id()]<<"]"; } } } } } } } void printDataOnTreeAsBPValues(ostream &out, Vstring &data, tree &tr) { printDataOnTreeAsBPValues(out,data, tr.getRoot()); out<<";"; } void printDataOnTreeAsBPValues(ostream &out, Vstring &data, const tree::nodeP &myNode) { if (myNode->isLeaf()) { out << myNode->name()<< ":"<dis2father(); return; } else { out <<"("; for (int i=0;igetNumberOfSons();++i) { if (i>0) out <<","; printDataOnTreeAsBPValues(out,data,myNode->getSon(i)); } out <<")"; // out.precision(3); // out<id()]; // if (myNode->isRoot()==false) { out.precision(3); out<id()]; out<<":"<dis2father(); // } } } vector getNexusTreesFromFile (const string& nexusTreesFile) { ifstream treesFile(nexusTreesFile.c_str()); if (!treesFile) { errorMsg::reportError("could not open nexus tree file"); } vector treeVec; vector fileData; putFileIntoVectorStringArray(treesFile , fileData); treesFile.close(); vector::const_iterator it = fileData.begin(); // first line start with "#NEXUS" if (it->find("#NEXUS") == -1) errorMsg::reportError("NEXUS tree format must start with 'NEXUS' in the first line"); ++it; string::const_iterator itStrStart = it->begin(); string::const_iterator itStrEnd = it->end(); // second line start as [ID: 0759674699] //if (((*itStrStart++) != '[') || ((*itStrStart++) != 'I') // || ((*itStrStart++) != 'D') || ((*itStrStart++) != ':')) //{ // errorMsg::reportError("Cannot find proper ID format in first line of alphaFile"); //} //int idStart = it->find_first_of("1234567890"); //int idEnd = it->find_last_of("]"); //string treeFileID = it->substr(idStart, idEnd-idStart); //it += 2; //skipp also 3rd line while ( ( (*it).find("Translate") == -1) && ((*it).find("translate") == -1) &&(it != fileData.end())) ++it; //translate table [id name] vector nameTable(0); vector idTable(0); for(++it; (it->find(";") == -1) && (it->find("tree") == -1) ; ++it) { if (it->find(";") != -1) { break; } int idStartPos = it->find_first_of("0123456789"); int idEndPos = it->find_first_not_of("0123456789", idStartPos); string idStr = it->substr(0, idEndPos); int id = atoi(idStr.c_str()); int nameStartPos = it->find_first_not_of(" ", idEndPos); int nameEndPos = it->find_first_of(",;", idEndPos); string nameStr = it->substr(nameStartPos, nameEndPos - nameStartPos); nameTable.push_back(nameStr); idTable.push_back(id); } while (it->find("tree") == -1) ++it; for (; it->find("tree") != -1 ; ++it) { int pos = it->find_first_of("("); string treeStr = it->substr(pos); vector treeContents; for (string::iterator itStr = treeStr.begin(); itStr != treeStr.end(); ++itStr) { if (!isspace(*itStr)) treeContents.push_back((*itStr)); } tree tr(treeContents); for(int i=0 ; i < idTable.size(); ++i) { tree::nodeP node = tr.findNodeByName(int2string(idTable[i])); node->setName(nameTable[i]); } treeVec.push_back(tr); } return treeVec; } rate4site-3.0.0/src/phylogeny/matrixUtils.cpp0000644011611301161130000001775312223673416016220 00000000000000#include "matrixUtils.h" #include "errorMsg.h" #include #include #include #include #include Vdouble getDiagonalFromMatrix(VVdouble &mat){ Vdouble diagonal; for (int i=0; itempMax){ // TEST DEBUG!!! if '>' is used, the first Max is chosen, if '>' the last max tempMax=vec[i]; tempArgMax=i; } } maxValue=tempMax; argmax=tempArgMax; } void findMinInVector(const Vdouble &vec, MDOUBLE &minValue, int &argmin) { Vdouble minusCopy(vec.size()); for (int i=0; i big) big=temp; if (big == 0.0) errorMsg::reportError("Singular matrix in routine ludcmp"); vv[i]=1.0/big; } for (j=0;j= big) { big=dum; imax=i; } } if (j != imax) { for (k=0;k=0;i--) { sum=b[i]; for (j=i+1;j simulateCodonsJumps::simulateCodonsJumps(const tree& inTree, const stochasticProcess& sp, const int alphabetSize) : simulateJumpsAbstract(inTree,sp,alphabetSize) { } simulateCodonsJumps::~simulateCodonsJumps() { } void simulateCodonsJumps::init() { //init the vector of waiting times. _waitingTimeParams.clear(); _waitingTimeParams.resize(_alphabetSize); int i, j; for (i = 0; i < _alphabetSize; ++i) { _waitingTimeParams[i] = -_sp.dPij_dt(i, i, 0.0); } //init _jumpProbs. _jumpProbs.clear(); _jumpProbs.resize(_alphabetSize); for (i = 0; i < _alphabetSize; ++i) { MDOUBLE sum = 0.0; _jumpProbs[i].resize(_alphabetSize); for (j = 0; j < _alphabetSize; ++j) { if (i == j) _jumpProbs[i][j] = 0.0; else { _jumpProbs[i][j] = _sp.dPij_dt(i, j, 0.0) / _waitingTimeParams[i]; } sum += _jumpProbs[i][j]; } if (! DEQUAL(sum, 1.0,0.001)){ string err = "error in simulateCodonsJumps::init(): sum probabilities is not 1 and equal to "; err+=double2string(sum); errorMsg::reportError(err); } } //init _orderNodesVec: a vector in which the branch lengths are ordered in ascending order _tree.getAllNodes(_orderNodesVec, _tree.getRoot()); sort(_orderNodesVec.begin(), _orderNodesVec.end(), simulateJumpsAbstract::compareDist); _nodes2JumpsExp.clear(); _nodes2JumpsProb.clear(); // vector > zeroCombinedStates2jumps; for(i = 0;i < getCombinedAlphabetSize();++i){ pair syn_and_nonSyn_jumps(0.0,0.0); zeroCombinedStates2jumps.push_back(syn_and_nonSyn_jumps); } Vdouble zeroVector(getCombinedAlphabetSize(),0.0); for (i = 0; i < _orderNodesVec.size(); ++i) { string nodeName = _orderNodesVec[i]->name(); _nodes2JumpsExp[nodeName] = zeroCombinedStates2jumps; _nodes2JumpsProb[nodeName] = zeroCombinedStates2jumps; for (j=0; jdis2father(); MDOUBLE totalTimeTillJump = 0.0; int curState = startState; int smallestBranchNotUpdatedSofar = 0; vector > jumpsSoFar(0); while (totalTimeTillJump < maxTime) { MDOUBLE avgWaitingTime = 1 / _waitingTimeParams[curState]; MDOUBLE nextJumpTime = totalTimeTillJump + talRandom::rand_exp(avgWaitingTime); //go over all branches that "finished" their simulation (shorter than nextJumpTime) and update with their _nodes2JumpsExp //with the jumps that occured between the terminal Ids: startState-->curState for (int b = smallestBranchNotUpdatedSofar; b < _orderNodesVec.size(); ++b) { if (_orderNodesVec[b]->dis2father() > nextJumpTime) { smallestBranchNotUpdatedSofar = b; break; } string nodeName = _orderNodesVec[b]->name(); //update all the jumps that occured along the branch int terminalState = getCombinedState(startState, curState); _totalTerminals[nodeName][terminalState]++; //update all longer branches with all jumps that occurred till now /* vector jumpsSoFarBool(getCombinedAlphabetSize(),false);*/ // There's no need for the jumpsSoFarBool vector because we want to count // the number of syn subs and not just to note that there has been at least 1 // The final probability is calculated in computeExpectationsAndPosterior for (int j = 0; j < jumpsSoFar.size(); ++j) { substitutionType = codonUtility::codonReplacement(jumpsSoFar[j].first,jumpsSoFar[j].second); /* int combinedJumpState = getCombinedState(jumpsSoFar[j].first, jumpsSoFar[j].second); jumpsSoFarBool[combinedJumpState]=true;*/ if(substitutionType == codonUtility::synonymous) { _nodes2JumpsExp[nodeName][terminalState].first += 1; _nodes2JumpsProb[nodeName][terminalState].first += 1; } else if(substitutionType == codonUtility::non_synonymous) { _nodes2JumpsExp[nodeName][terminalState].second += 1; _nodes2JumpsProb[nodeName][terminalState].second += 1; } } /* for (int combined=0;combined(curState, nextState)); curState = nextState; } } void simulateCodonsJumps::computeExpectationsAndPosterior(){ //scale _nodes2JumpsExp so it will represent expectations map > >::iterator iterExp = _nodes2JumpsExp.begin(); for (; iterExp != _nodes2JumpsExp.end(); ++iterExp) {//each node string nodeName = iterExp->first; for (int termState = 0; termState < getCombinedAlphabetSize(); ++termState) { MDOUBLE totalJumps4currentNodeAndTermState = 0; map::iterator iterTerm = _totalTerminals.find(nodeName); map > >::iterator iterProb = _nodes2JumpsProb.find(nodeName); if ((iterTerm==_totalTerminals.end()) || (iterProb==_nodes2JumpsProb.end())) { errorMsg::reportError("error in simulateJumps::runSimulation, unknown reason: cannot find nodeName in map"); } if (iterTerm->second[termState]==0){ //never reached these terminal states if((iterExp->second[termState].first == 0)&&(iterExp->second[termState].second == 0)&& ((iterProb->second[termState].first == 0)&&(iterProb->second[termState].second == 0))) { int startID = getStartId(termState); int endID = getEndId(termState); if (startID != endID) // if the terminal states are different there was at least one startID->endID jump { codonUtility::replacementType substitutionType = codonUtility::codonReplacement(startID,endID); if(substitutionType == codonUtility::synonymous) { iterExp->second[termState].first = 1; iterProb->second[termState].first = 1; } else if(substitutionType == codonUtility::non_synonymous) { iterExp->second[termState].second = 1; iterProb->second[termState].second = 1; } totalJumps4currentNodeAndTermState = ((iterProb->second[termState].first) + (iterProb->second[termState].second)); if(totalJumps4currentNodeAndTermState) { (iterProb->second[termState].first) /= totalJumps4currentNodeAndTermState; (iterProb->second[termState].second) /= totalJumps4currentNodeAndTermState; } } continue; } else errorMsg::reportError("error in simulateCodonJumps::runSimulation, 0 times reached termState but non-zero for jumpCount"); } (iterExp->second[termState].first) /= iterTerm->second[termState]; (iterExp->second[termState].second) /= iterTerm->second[termState]; totalJumps4currentNodeAndTermState = ((iterProb->second[termState].first) + (iterProb->second[termState].second)); if(totalJumps4currentNodeAndTermState) { (iterProb->second[termState].first) /= totalJumps4currentNodeAndTermState; (iterProb->second[termState].second) /= totalJumps4currentNodeAndTermState; } } } } MDOUBLE simulateCodonsJumps::getExpectation(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId) { //map ::iterator pos;//Old map > >::iterator pos; if ((pos = _nodes2JumpsExp.find(nodeName)) == _nodes2JumpsExp.end()) { string err="error in simulateCodonJumps::getExpectation: cannot find node "+nodeName; errorMsg::reportError(err); } int combinedTerminalState = getCombinedState(terminalStart, terminalEnd); //Old //int combinedJumpState = getCombinedState(fromId, toId); //return (pos->second[combinedTerminalState][combinedJumpState]); MDOUBLE expectation=0.0; if(codonUtility::codonReplacement(fromId,toId) == 1) expectation = pos->second[combinedTerminalState].first; else if(codonUtility::codonReplacement(fromId,toId) == 2) expectation = pos->second[combinedTerminalState].second; return (expectation); } MDOUBLE simulateCodonsJumps::getExpectation( const string& nodeName, int terminalStart, int terminalEnd, codonUtility::replacementType substitutionType) { map > >::iterator pos; if ((pos = _nodes2JumpsExp.find(nodeName)) == _nodes2JumpsExp.end()) { string err="error in simulateCodonJumps::getExpectation: cannot find node "+nodeName; errorMsg::reportError(err); } int combinedTerminalState = getCombinedState(terminalStart, terminalEnd); MDOUBLE expectation=0.0; if(substitutionType == codonUtility::synonymous) expectation = pos->second[combinedTerminalState].first; else if(substitutionType == codonUtility::non_synonymous) expectation = pos->second[combinedTerminalState].second; return (expectation); } MDOUBLE simulateCodonsJumps::getProb(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId){ //map ::iterator pos; map > >::iterator pos; if ((pos = _nodes2JumpsProb.find(nodeName)) == _nodes2JumpsProb.end()) { string err="error in simulateCodonJumps::getProb: cannot find node "+nodeName; errorMsg::reportError(err); } int combinedTerminalState = getCombinedState(terminalStart, terminalEnd); //Old //int combinedJumpState = getCombinedState(fromId, toId); //return (pos->second[combinedTerminalState][combinedJumpState]); MDOUBLE prob=0.0; if(codonUtility::codonReplacement(fromId,toId) == 1) prob = pos->second[combinedTerminalState].first; else if(codonUtility::codonReplacement(fromId,toId) == 2) prob = pos->second[combinedTerminalState].second; return (prob); } MDOUBLE simulateCodonsJumps::getProb( const string& nodeName, int terminalStart, int terminalEnd, codonUtility::replacementType substitutionType) { map > >::iterator pos; if ((pos = _nodes2JumpsProb.find(nodeName)) == _nodes2JumpsProb.end()) { string err="error in simulateCodonJumps::getProb: cannot find node "+nodeName; errorMsg::reportError(err); } int combinedTerminalState = getCombinedState(terminalStart, terminalEnd); MDOUBLE prob=0.0; if(substitutionType == codonUtility::synonymous) prob = pos->second[combinedTerminalState].first; else if(substitutionType == codonUtility::non_synonymous) prob = pos->second[combinedTerminalState].second; return (prob); } rate4site-3.0.0/src/phylogeny/computePosteriorExpectationOfSubstitutions.cpp0000644011611301161130000002123512223673415024554 00000000000000#include "computePosteriorExpectationOfSubstitutions.h" #include "definitions.h" #include "computeDownAlg.h" #include "computeUpAlg.h" #include "matrixUtils.h" #include "treeIt.h" #include "likelihoodComputation.h" using namespace std; /******************************************************************************************** computePosteriorExpectationOfSubstitutions *********************************************************************************************/ computePosteriorExpectationOfSubstitutions::computePosteriorExpectationOfSubstitutions(const tree &tr, const sequenceContainer &sc, const stochasticProcess *sp): _tr(tr), _sc(sc){ if(!sp){ errorMsg::reportError("error in the constructor computePosteriorExpectationOfSubstitutions sp argument is NULL"); } else{ _sp = sp; } } /******************************************************************************************** Expectation of number of substitutions from character u to v --- = sum over all substitutions x,y: Posterior(Node=x,Father=y|D)*Exp(substitutions u to v|Node=x,Father=y) The second term is given to the function as input (can be obtained via simulations) *********************************************************************************************/ VVdouble computePosteriorExpectationOfSubstitutions::computeExpectationAcrossTree( simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbs, VVVdouble &expForBranch) { //int numNodes = _tr.getNodesNum(); int alphabetSize = _sp->alphabetSize(); VVdouble res; resizeMatrix(res,alphabetSize,alphabetSize); treeIterTopDownConst tIt(_tr); for (tree::nodeP mynode = tIt.first(); mynode != tIt.end(); mynode = tIt.next()) { for (int fromState=0;fromStateid()][fromState][toState] = computeExpectationOfChangePerBranch(sim,posteriorProbs,mynode,fromState,toState); res[fromState][toState] +=expForBranch[mynode->id()][fromState][toState]; } } } return res; } /******************************************************************************************** Posterior probabilities computed across entire tree, for all substitutions from character u to v *********************************************************************************************/ VVdouble computePosteriorExpectationOfSubstitutions::computePosteriorAcrossTree( simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbsGivenTerminals,VVVdouble &probsForBranch) { //int numNodes = _tr.getNodesNum(); int alphabetSize = _sp->alphabetSize(); // N: resized before //probsForBranch.resize(numNodes); //for (int n=0;nid()][fromState][toState]= computePosteriorOfChangePerBranch(sim,posteriorProbsGivenTerminals,mynode,fromState,toState); res[fromState][toState] +=probsForBranch[mynode->id()][fromState][toState]; } } } return res; } /******************************************************************************************** *********************************************************************************************/ MDOUBLE computePosteriorExpectationOfSubstitutions::computePosteriorOfChangePerBranch(simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbs, tree::nodeP node, int fromState, int toState) { int alphabetSize = _sp->alphabetSize(); MDOUBLE res = 0; for (int x=0;xname(),x,y,fromState,toState)*posteriorProbs[node->id()][x][y]; } } return res; } /******************************************************************************************** Posterior of observing a certain state substitution along a branch: P(Node=x,Father=y|D) = P(D,Node=x,Father=y)/P(D) usage: posteriorPerNodePer2States[mynode->id()][fatherState][sonState] *********************************************************************************************/ void computePosteriorExpectationOfSubstitutions::computePosteriorOfChangeGivenTerminals(VVVdouble &posteriorPerNodePer2States, int pos){ int numNodes = _tr.getNodesNum(); int alphabetSize = _sp->alphabetSize(); posteriorPerNodePer2States.resize(numNodes); for (int n=0;nid()][fatherState][sonState]= computePosterioGivenTerminalsPerBranch(mynode->id(),sonState,fatherState,sscUp,sscDown, pi,ll,mynode->name()); } } } } /******************************************************************************************** Posterior of observing a certain state substitution along a branch: P(Node=sonState,Father=fatherState|D) = P(D,Node=sonState,Father=fatherState)/P(D) usage: posteriorPerNodePer2States[mynode->id()][fatherState][sonState] *********************************************************************************************/ MDOUBLE computePosteriorExpectationOfSubstitutions::computePosterioGivenTerminalsPerBranch (int nodeId,int sonState, int fatherState,suffStatGlobalHomPos &sscUp, suffStatGlobalHomPos &sscDown,computePijHom &pi, MDOUBLE &LLData, const string nodeName) { MDOUBLE res, Down, Up, pij; Down = convert(sscDown.get(nodeId,fatherState)); Up = convert(sscUp.get(nodeId,sonState)); pij = pi.getPij(nodeId,fatherState,sonState); res=_sp->freq(fatherState)*Down*Up*pij; res/=LLData; // if(gainLossOptions::_printDEBUGinfo) // LOG(3,< 1 + 1e-4){ LOGnOUT(3,< 1 + 0.000001) || (res<-0.000001)){ string err = "Error in computePosteriorExpectationOfSubstitutions::computePosterioGivenTerminalsPerBranch, non probability value "; err+=double2string(res); err+=" at node "; err+=int2string(nodeId); err+= " sonState "; err+= int2string(sonState); err+= " fatherState "; err+= int2string(fatherState); errorMsg::reportError(err); } return res; } /******************************************************************************************** *********************************************************************************************/ MDOUBLE computePosteriorExpectationOfSubstitutions::computeExpectationOfChangePerBranch( simulateJumpsAbstract &sim, //input given from simulation studies const VVVdouble &posteriorProbsGivenTerminals, tree::nodeP node,int fromState, int toState) { int alphabetSize = _sp->alphabetSize(); MDOUBLE nodeExpectation = 0; for (int x = 0; xid()][x][y]* sim.getExpectation(node->name(),x,y,fromState,toState)); //DEBUG LOG(6,<<"node "<id()<id()][fatherState][sonState] *********************************************************************************************/ void computePosteriorExpectationOfSubstitutions_nonReversibleSp::computePosteriorOfChangeGivenTerminals(VVVdouble &posteriorPerNodePer2States, int pos){ int numNodes = _tr.getNodesNum(); int alphabetSize = _sp->alphabetSize(); posteriorPerNodePer2States.resize(numNodes); for (int n=0;nid()][fatherState][sonState]= computePosterioGivenTerminalsPerBranch(mynode->id(),sonState,fatherState,sscUp,sscDownNonRev, pi,ll,mynode->name()); } } } } /******************************************************************************************** Posterior of observing a certain state substitution along a branch: P(Node=sonState,Father=fatherState|D) = P(D,Node=sonState,Father=fatherState)/P(D) usage: posteriorPerNodePer2States[mynode->id()][fatherState][sonState] *********************************************************************************************/ MDOUBLE computePosteriorExpectationOfSubstitutions_nonReversibleSp::computePosterioGivenTerminalsPerBranch (int nodeId,int sonState, int fatherState,suffStatGlobalHomPos &sscUp, suffStatGlobalGamPos &sscDown,computePijHom &pi, MDOUBLE &LLData, const string nodeName) { MDOUBLE res=0.0; MDOUBLE resDXY, Down, Up, pij; for (int stateAtRoot = 0; stateAtRoot<_sp->alphabetSize(); ++stateAtRoot){ Down = convert(sscDown.get(stateAtRoot,nodeId,fatherState)); Up = convert(sscUp.get(nodeId,sonState)); pij = pi.getPij(nodeId,fatherState,sonState); res+=(_sp->freq(stateAtRoot)* Down* Up* pij); } resDXY = res; res/=LLData; // if(gainLossOptions::_printDEBUGinfo) // LOG(3,< 1 + 1e-4){ LOGnOUT(3,< 1 + 0.000001) || (res<-0.000001)){ string err = "Error in computePosteriorExpectationOfSubstitutions_nonReversibleSp::computePosterioGivenTerminalsPerBranch, non probability value "; err+=double2string(res); err+=" at node "; err+=int2string(nodeId); err+= " sonState "; err+= int2string(sonState); err+= " fatherState "; err+= int2string(fatherState); errorMsg::reportError(err); } return res; }rate4site-3.0.0/src/phylogeny/multipleStochasticProcess.cpp0000644011611301161130000000154512223673416021102 00000000000000#include "multipleStochasticProcess.h" #include "errorMsg.h" multipleStochasticProcess::multipleStochasticProcess() { } multipleStochasticProcess::~multipleStochasticProcess() { } void multipleStochasticProcess::copy(const multipleStochasticProcess *pOther) { _spVec = pOther->_spVec; _spProb = pOther->_spProb; } MDOUBLE multipleStochasticProcess::getProb(int spPlace) const { if (spPlace >= _spProb.size()) errorMsg::reportError("error in multipleStochasticProcess::getProb"); return _spProb[spPlace]; } stochasticProcess* multipleStochasticProcess::getSp(int spPlace) { if (spPlace >= _spVec.size()) errorMsg::reportError("error in multipleStochasticProcess::getSp"); return &_spVec[spPlace]; } void multipleStochasticProcess::setSpVec(vector& spVec) { _spVec.clear(); _spVec = spVec; } rate4site-3.0.0/src/phylogeny/simulateJumps.cpp0000644011611301161130000001617712223673416016534 00000000000000#include "simulateJumps.h" #include "talRandom.h" #include "someUtil.h" #include simulateJumps::simulateJumps(const tree& inTree, const stochasticProcess& sp, const int alphabetSize) : simulateJumpsAbstract(inTree,sp,alphabetSize) { } simulateJumps::~simulateJumps() { } void simulateJumps::init() { //init the vector of waiting times. _waitingTimeParams.clear(); _waitingTimeParams.resize(_alphabetSize); int i, j; for (i = 0; i < _alphabetSize; ++i) { _waitingTimeParams[i] = -_sp.dPij_dt(i, i, 0.0); } //init _jumpProbs. //_jumpProbs[i][j] = Q[i][j] / -Q[i][i] _jumpProbs.clear(); _jumpProbs.resize(_alphabetSize); for (i = 0; i < _alphabetSize; ++i) { MDOUBLE sum = 0.0; _jumpProbs[i].resize(_alphabetSize); for (j = 0; j < _alphabetSize; ++j) { if (i == j) _jumpProbs[i][j] = 0.0; else { _jumpProbs[i][j] = _sp.dPij_dt(i, j, 0.0) / _waitingTimeParams[i]; } sum += _jumpProbs[i][j]; } if (! DEQUAL(sum, 1.0)){ string err = "error in simulateJumps::init(): sum probabilities is not 1 and equal to "; err+=double2string(sum); errorMsg::reportError(err); } } //init _orderNodesVec: a vector in which the branch lengths are ordered in ascending order _tree.getAllNodes(_orderNodesVec, _tree.getRoot()); sort(_orderNodesVec.begin(), _orderNodesVec.end(), simulateJumpsAbstract::compareDist); _nodes2JumpsExp.clear(); _nodes2JumpsProb.clear(); VVdouble zeroMatrix(getCombinedAlphabetSize()); for (i = 0; i < getCombinedAlphabetSize(); ++i) zeroMatrix[i].resize(getCombinedAlphabetSize(), 0.0); Vdouble zeroVector(getCombinedAlphabetSize(),0.0); for (i = 0; i < _orderNodesVec.size(); ++i) { string nodeName = _orderNodesVec[i]->name(); _nodes2JumpsExp[nodeName] = zeroMatrix; _nodes2JumpsProb[nodeName] = zeroMatrix; for (j=0; jdis2father(); MDOUBLE totalTimeTillJump = 0.0; int jumpsNum = 0; int curState = startState; int smallestBranchNotUpdatedSofar = 0; vector > jumpsSoFar(0); while (totalTimeTillJump < maxTime) { MDOUBLE avgWaitingTime = 1 / _waitingTimeParams[curState]; MDOUBLE nextJumpTime = totalTimeTillJump + talRandom::rand_exp(avgWaitingTime); //go over all branches that "finished" their simulation (shorter than nextJumpTime) and update with their _nodes2JumpsExp //with the jumps that occurred between the terminal Ids: startState-->curState for (int b = smallestBranchNotUpdatedSofar; b < _orderNodesVec.size(); ++b) { if (_orderNodesVec[b]->dis2father() > nextJumpTime) { smallestBranchNotUpdatedSofar = b; break; } string nodeName = _orderNodesVec[b]->name(); //update all the jumps that occurred along the branch int terminalState = getCombinedState(startState, curState); _totalTerminals[nodeName][terminalState]++; //update all longer branches with all jumps that occurred till now vector jumpsSoFarBool(getCombinedAlphabetSize(),false); for (int j = 0; j < jumpsSoFar.size(); ++j) { int combinedJumpState = getCombinedState(jumpsSoFar[j].first, jumpsSoFar[j].second); jumpsSoFarBool[combinedJumpState]=true; _nodes2JumpsExp[nodeName][terminalState][combinedJumpState] += 1; } for (int combined=0;combined(curState, nextState)); curState = nextState; ++jumpsNum; } } void simulateJumps::computeExpectationsAndPosterior(){ //scale _nodes2JumpsExp so it will represent expectations map::iterator iterExp = _nodes2JumpsExp.begin(); for (; iterExp != _nodes2JumpsExp.end(); ++iterExp) { string nodeName = iterExp->first; for (int termState = 0; termState < getCombinedAlphabetSize(); ++termState) { for (int jumpState = 0; jumpState < getCombinedAlphabetSize(); ++jumpState) { //(iter->second[termState][jumpState]) /= static_cast(iterNum); map::iterator iterTerm = _totalTerminals.find(nodeName); map::iterator iterProb = _nodes2JumpsProb.find(nodeName); if ((iterTerm==_totalTerminals.end()) || (iterProb==_nodes2JumpsProb.end())) { errorMsg::reportError("error in simulateJumps::runSimulation, unknown reason: cannot find nodeName in map"); } if ((iterTerm->second[termState]==0)){ //never reached these terminal states if ((iterExp->second[termState][jumpState]==0) && (iterProb->second[termState][jumpState]==0)){ if( termState == jumpState && (getStartId(termState)!=getEndId(termState) ) ){ (iterExp->second[termState][jumpState]) = 1; // E.g - given start=0 end=1 there was at least one 0->1 jump (iterProb->second[termState][jumpState]) = 1; // E.g - given start=0 end=1 there was at least one 0->1 jump } continue;//leave the value of _nodes2JumpsExp and _nodes2JumpsProb as zero (or one) } else { errorMsg::reportError("error in simulateJumps::runSimulation, 0 times reached termState but non-zero for jumpCount"); } } (iterExp->second[termState][jumpState]) /= iterTerm->second[termState]; (iterProb->second[termState][jumpState]) /= iterTerm->second[termState]; } } } } MDOUBLE simulateJumps::getExpectation(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId) { map ::iterator pos; if ((pos = _nodes2JumpsExp.find(nodeName)) == _nodes2JumpsExp.end()) { string err="error in simulateJumps::getExpectation: cannot find node "+nodeName; errorMsg::reportError(err); } int combinedTerminalState = getCombinedState(terminalStart, terminalEnd); int combinedJumpState = getCombinedState(fromId, toId); return (pos->second[combinedTerminalState][combinedJumpState]); } MDOUBLE simulateJumps::getProb(const string& nodeName, int terminalStart, int terminalEnd, int fromId, int toId){ map ::iterator pos; if ((pos = _nodes2JumpsProb.find(nodeName)) == _nodes2JumpsProb.end()) { string err="error in simulateJumps::getProb: cannot find node "+nodeName; errorMsg::reportError(err); } int combinedTerminalState = getCombinedState(terminalStart, terminalEnd); int combinedJumpState = getCombinedState(fromId, toId); return (pos->second[combinedTerminalState][combinedJumpState]); }rate4site-3.0.0/src/phylogeny/simulateJumpsAbstract.cpp0000644011611301161130000000253412223673416020210 00000000000000#include "simulateJumpsAbstract.h" simulateJumpsAbstract::simulateJumpsAbstract(const tree& inTree, const stochasticProcess& sp, const int alphabetSize) : _tree(inTree), _sp(sp), _alphabetSize(alphabetSize) { } //runSimulation: do the actual simulation. iterNum specifies the number of iterations starting from each state void simulateJumpsAbstract::runSimulation(int iterNum) { init(); for (int state = 0; state < _alphabetSize; ++state) { for (int iter = 0; iter < iterNum; ++iter) { runOneIter(state); } } computeExpectationsAndPosterior(); } ////////////////////////////////////////////////////////// //combined two characters into a combined state. //For example. if the alphabet is {0,1,2} then the combined alphabet will be {0,1...8}. //The states (terminalStart, terminalEnd) = (0,2) then combinedId = 2. //The states (terminalStart, terminalEnd) = (1,2) then combinedId = 5. etc. int simulateJumpsAbstract::getCombinedState(int terminalStart, int terminalEnd) const { return (terminalStart * _alphabetSize + terminalEnd); } int simulateJumpsAbstract::getStartId(int combinedState) const { return combinedState / _alphabetSize; } int simulateJumpsAbstract::getEndId(int combinedState) const { return combinedState % _alphabetSize; } ////////////////////////////////////////////////////////// rate4site-3.0.0/src/phylogeny/treeIt.cpp0000644011611301161130000000014712223673415015113 00000000000000// $Id: treeIt.cpp 962 2006-11-07 15:13:34Z privmane $ #include "definitions.h" #include "treeIt.h" rate4site-3.0.0/src/phylogeny/likelihoodComputationGL.cpp0000644011611301161130000003375412223673415020462 00000000000000#include "likelihoodComputationGL.h" #include "definitions.h" #include "tree.h" #include "likelihoodComputation.h" #include #include using namespace likelihoodComputationGL; // account for RateCat, GainCat,LossCat // - For each RateCat an "external" multiplication is conducted - copy_et.multipleAllBranchesByFactor // - the GainCat*LossCat SPs are covered by the "internal" mechanism of PijGam /******************************************************************************************** *********************************************************************************************/ MDOUBLE likelihoodComputationGL::getTreeLikelihoodAllPosAlphTheSame(const tree& tr, const sequenceContainer& sc, const vector >& spVVec, const distribution * distGain, const distribution * distLoss, const Vdouble * const weights, unObservableData *unObservableData_p) { int numOfRateCategories = spVVec[0][0]->categories(); vector pi_vec(numOfRateCategories); vector ssc_vec(numOfRateCategories); vector cup_vec(numOfRateCategories); likelihoodComputationGL::fillPijAndUp(tr,sc,spVVec,distGain,distLoss,pi_vec,ssc_vec,cup_vec); MDOUBLE logLforMissingData; MDOUBLE LforMissingData = 0; if(unObservableData_p){ logLforMissingData = unObservableData_p->getlogLforMissingData(); LforMissingData = exp(logLforMissingData); } MDOUBLE res = 0.0; for (int k=0; k < sc.seqLen(); ++k) { MDOUBLE lnL = 0; MDOUBLE resGivenRate = 0.0; for(int rateIndex=0 ; rateIndexratesProb(rateIndex); } if(unObservableData_p){ // conditioning on observability for all rateCat. resGivenRate = resGivenRate / (1- LforMissingData); } LOG(20,<<"pos= "<=0.0); // tmp+=tmpLcat; // } //// cout<<"likelihoodComputation::getLofPos: tmp = "; tmp.outputn(cout); // DEBUG EP // if (!(tmp>0.0)){ // LOG(5,<<"likelihoodComputation::getLofPos: "<< tmp< #include #include #include #include #include using namespace std; const MDOUBLE tree::FLAT_LENGTH_VALUE = 0.3f; const int tree::TREE_NULL = -1; const MDOUBLE tree::SHORT_LENGTH_VALUE = 0.000001f; //removeSon: remove pSon from sons list. //does not delete pSon void tree::TreeNode::removeSon(TreeNode* pSon) { vector::iterator vec_iter = remove(_sons.begin(), _sons.end(), pSon); _sons.erase(vec_iter,_sons.end()); // pg 1170, primer. } void tree::TreeNode::claimSons(){ for(int i=0;isetFather(this); } } /******************************************************************************************** getDistance2ROOT() *********************************************************************************************/ MDOUBLE tree::TreeNode::getDistance2ROOT(){ if(this->isRoot()) return 0.0; else return ( this->dis2father() + this->father()->getDistance2ROOT() ); } /******************************************************************************************** getMinimalDistance2OTU() *********************************************************************************************/ MDOUBLE tree::TreeNode::getMinimalDistance2OTU(){ if(this->isLeaf()) return 0.0; else{ int numberOfSons = this->getNumberOfSons(); switch (numberOfSons) { case 0: LOGnOUT(3, <<"ERROR: number of sons for node is zero, but not return leaf\n"); return -1; break; case 1: return ( this->getSon(0)->dis2father() + this->getSon(0)->getMinimalDistance2OTU() ); break; case 2: return ( min( this->getSon(0)->dis2father() + this->getSon(0)->getMinimalDistance2OTU(), this->getSon(1)->dis2father() + this->getSon(1)->getMinimalDistance2OTU() ) ); break; case 3: return ( min(min( this->getSon(0)->dis2father() + this->getSon(0)->getMinimalDistance2OTU(), this->getSon(1)->dis2father() + this->getSon(1)->getMinimalDistance2OTU()), this->getSon(2)->dis2father() + this->getSon(2)->getMinimalDistance2OTU() ) ); break; case 4: return ( min(min(min( this->getSon(0)->dis2father() + this->getSon(0)->getMinimalDistance2OTU(), this->getSon(1)->dis2father() + this->getSon(1)->getMinimalDistance2OTU()), this->getSon(2)->dis2father() + this->getSon(2)->getMinimalDistance2OTU()), this->getSon(3)->dis2father() + this->getSon(3)->getMinimalDistance2OTU() ) ); break; default: LOGnOUT(3, <<"ERROR: number of sons for node "<< numberOfSons<<" is not implemented in getMinimalDistance2OTU\n"); return -1; } } } /******************************************************************************************** getMinimalDistance2OTU() This implementation is only for binary trees and tr-furcating. Can easily be generalized to arbitrary number of sons. *********************************************************************************************/ int tree::TreeNode::getMinimalNumOfNodes2OTU(){ //int minimalNumOfNodes2OTU = 1; if(this->isLeaf()) return 0; else{ int numberOfSons = this->getNumberOfSons(); switch (numberOfSons) { case 0: LOGnOUT(3, <<"ERROR: number of sons for node is zero, but not return leaf\n"); return -1; break; case 1: return ( 1 + this->getSon(0)->getMinimalNumOfNodes2OTU()); break; case 2: return ( min( 1 + this->getSon(0)->getMinimalNumOfNodes2OTU(), 1 + this->getSon(1)->getMinimalNumOfNodes2OTU() ) ); break; case 3: return ( min(min( 1 + this->getSon(0)->getMinimalNumOfNodes2OTU(), 1 + this->getSon(1)->getMinimalNumOfNodes2OTU() ), 1 + this->getSon(2)->getMinimalNumOfNodes2OTU() ) ); break; case 4: return ( min(min(min( 1 + this->getSon(0)->getMinimalNumOfNodes2OTU(), 1 + this->getSon(1)->getMinimalNumOfNodes2OTU()), 1 + this->getSon(2)->getMinimalNumOfNodes2OTU()), 1 + this->getSon(3)->getMinimalNumOfNodes2OTU() ) ); break; default: LOGnOUT(3, <<"ERROR: number of sons for node "<< numberOfSons<<" is not implemented in getMinimalNumOfNodes2OTU\n"); return -1; } } } //******************************************************************************* // Constructors Destructors //******************************************************************************* tree::tree() { _root=NULL; } // this function will accept "-" for cases where the input in from the standard input (cin) tree::tree(const string& treeFileName, vector& isFixed) { ifstream in; istream* inPtr = &cin; // default if (treeFileName != "-"){ in.open(treeFileName.c_str()); if (! in.is_open()) errorMsg::reportError(string("Error - unable to open tree file ")+treeFileName,1); inPtr = ∈ } if (readPhylipTreeTopology(*inPtr,isFixed)) { if (in.is_open()) in.close(); create_names_to_internal_nodes(); makeSureAllBranchesArePositive(); return; } if (in.is_open()) in.close(); errorMsg::reportError(string("Unable to read tree from the file ")+treeFileName,1); } // this function will accept "-" for cases where the input in from the standard input (cin) tree::tree(const string& treeFileName) { ifstream in; istream* inPtr = &cin; // default if (treeFileName != "-"){ in.open(treeFileName.c_str()); if (! in.is_open()) errorMsg::reportError(string("Error - unable to open tree file ")+treeFileName,1); inPtr = ∈ } if (readPhylipTreeTopology(*inPtr)) { if (in.is_open()) in.close(); create_names_to_internal_nodes(); makeSureAllBranchesArePositive(); return; } if (in.is_open()) in.close(); errorMsg::reportError(string("Unable to read tree from the file ")+treeFileName,1); } tree::tree(istream &in) { if (readPhylipTreeTopology(in)) { create_names_to_internal_nodes(); makeSureAllBranchesArePositive(); return; } errorMsg::reportError("Unable to read phylip tree file",1);// also quit the program } tree::tree(istream &in,vector& isFixed) { if (readPhylipTreeTopology(in,isFixed)) { create_names_to_internal_nodes(); makeSureAllBranchesArePositive(); return; } errorMsg::reportError("Unable to read phylip tree file",1);// also quit the program } tree::tree(const vector& tree_contents) { readPhylipTreeTopology(tree_contents); create_names_to_internal_nodes(); makeSureAllBranchesArePositive(); return; } tree::tree(const vector& tree_contents, vector& isFixed) { readPhylipTreeTopology(tree_contents,isFixed); create_names_to_internal_nodes(); makeSureAllBranchesArePositive(); return; } tree::tree(const tree &otherTree) { _root = NULL; if (otherTree._root == NULL) return; // if tree to copy is empty. createRootNode(); _root->setName(otherTree._root->name()); _root->setID(otherTree._root->id()); _root->setComment(otherTree._root->getComment()); for (int i=0; i getNumberOfSons(); ++i) { recursiveBuildTree( _root, otherTree.getRoot()->getSon(i)); } } tree& tree::operator=(const tree &otherTree) { if (this == &otherTree) return *this; if (otherTree._root == NULL) { clear(); return *this; // if tree to copy is empty. } createRootNode(); _root->setName(otherTree._root->name()); _root->setComment(otherTree._root->getComment()); for (int i=0; i getNumberOfSons(); ++i) { recursiveBuildTree( _root, otherTree.getRoot()->getSon(i)); } return *this; } void tree::clear() { vector vec; getAllNodes(vec, _root); for (int k=0; k < vec.size(); k++) { delete(vec[k]); } _nodes = 0; _leaves =0; _root = NULL; } //******************************************************************************* // questions on the tree topology //******************************************************************************* //stores the father and sons of node inNodeP in vNeighbourVector void tree::getNeigboursOfNode(vector &vNeighbourVector, const nodeP inNodeP) const { vNeighbourVector.clear(); for (int i=0; i < inNodeP->getNumberOfSons();++i) { vNeighbourVector.push_back(inNodeP->getSon(i)); } if (getRoot() != inNodeP) vNeighbourVector.push_back(inNodeP->father()); } // get nodePTR from name // "myNode" is a pointer to the root of the subtree in which we want to find the node "inName" tree::nodeP tree::findNodeByName(const string inName, nodeP myNode) const{ if (myNode==NULL) myNode=_root; if (myNode->name() == inName) return myNode; for (int i=0 ; i < myNode->getNumberOfSons(); i++ ) { nodeP answer = findNodeByName(inName, myNode->getSon(i)); if (answer!=NULL) return answer; } return NULL; } // get nodePTR from id // similar to tree::findNodeByName // "myNode" is a pointer to the root of the subtree in which we want to find the node "inId" tree::nodeP tree::findNodeById(const int inId, nodeP myNode) const{ if (myNode==NULL) myNode=_root; if (myNode->id() == inId) return myNode; for (int i=0 ; i < myNode->getNumberOfSons(); i++ ) { nodeP answer = findNodeById(inId, myNode->getSon(i)); if (answer!=NULL) return answer; } return NULL; } //getPathBetweenAnyTwoNodes: store all nodes on the path from node1 to node2 in path //the first node in path is node1. the last node is node2 //1. store all nodes from node1 to the root and node2 to the root //2. starting from the root - finds the first node (common_father) which is father to both node1 and node2 //3. store in all nodes in the path from node1 to common_father, from node2 to common_father and common_father itself void tree::getPathBetweenAnyTwoNodes(vector &path, const nodeP node1, const nodeP node2) const { path.clear(); vector pathMatrix1; vector pathMatrix2; nodeP nodeup = node1; while (nodeup != _root) { pathMatrix1.push_back(nodeup); nodeup = nodeup->father(); } pathMatrix1.push_back(_root); nodeup = node2; while (nodeup != _root) { pathMatrix2.push_back(nodeup); nodeup = nodeup->father(); } pathMatrix2.push_back(_root); int tmp1 = pathMatrix1.size()-1; int tmp2 = pathMatrix2.size()-1; while ((tmp1 >= 0) && (tmp2 >= 0)) { if (pathMatrix1[tmp1] != pathMatrix2[tmp2]) break; tmp1--; tmp2--; } for (int y=0; y <= tmp1; ++y) path.push_back(pathMatrix1[y]); path.push_back(pathMatrix1[tmp1+1]); // pushing once, the TreeNode that was common father to both. for (int j=tmp2; j >= 0; --j) { path.push_back(pathMatrix2[j]); } return; } void tree::getFromLeavesToRoot(vector &vNeighbourVector) const { getFromRootToLeaves(vNeighbourVector); reverse(vNeighbourVector.begin(),vNeighbourVector.end()); } void tree::getFromRootToLeaves(vector &vec) const { getFromNodeToLeaves(vec,_root); } void tree::getFromNodeToLeaves(vector &vec, const nodeP fromHereDown) const { vec.push_back(fromHereDown); for (int k=0; k < fromHereDown->getNumberOfSons(); k++) { getFromNodeToLeaves(vec, fromHereDown->getSon(k)); } return; } void tree::getAllHTUs(vector &vec, const nodeP fromHereDown ) const { vec.clear(); getAllHTUsPrivate(vec,fromHereDown); } void tree::getAllHTUsPrivate(vector &vec, const nodeP fromHereDown ) const { if (fromHereDown == NULL) return; if (fromHereDown->isInternal()) vec.push_back(fromHereDown); for (int k=0; k < fromHereDown->getNumberOfSons(); k++) { getAllHTUsPrivate(vec,fromHereDown->getSon(k)); } return; } void tree::getAllNodes(vector &vec, const nodeP fromHereDown ) const { vec.clear(); getAllNodesPrivate(vec,fromHereDown); } void tree::getAllNodesPrivate(vector &vec, const nodeP fromHereDown ) const { //DFS: depth first search if (fromHereDown == NULL) return; vec.push_back(fromHereDown); for (int k=0; k < fromHereDown->getNumberOfSons(); k++) { getAllNodesPrivate(vec,fromHereDown->getSon(k)); } return; } void tree::getAllLeaves(vector &vec, const nodeP fromHereDown ) const { vec.clear(); getAllLeavesPrivate(vec,fromHereDown); } void tree::getAllLeavesPrivate(vector &vec, const nodeP fromHereDown ) const { if (fromHereDown == NULL) return; if (fromHereDown->isLeaf()) vec.push_back(fromHereDown); for (int k=0; k < fromHereDown->getNumberOfSons(); k++) { getAllLeavesPrivate(vec,fromHereDown->getSon(k)); } return; } MDOUBLE tree::findLengthBetweenAnyTwoNodes(const nodeP node1, const nodeP node2) const { vector pathMatrix; MDOUBLE sumOfDistances =0; getPathBetweenAnyTwoNodes(pathMatrix, node1, node2); for (int i=0; i < pathMatrix.size() ; i++) { // two cases: first, the previous node is closer to the root // than the current one. NOTE: this can not be the case for the // first node in the path if (i>0 && pathMatrix[i]->father() == pathMatrix[i-1]) sumOfDistances += pathMatrix[i]->dis2father(); else // else: the next node is closer to the root than this node // again, it can not be the last node in the path if (ifather() == pathMatrix[i+1]) sumOfDistances += pathMatrix[i]->dis2father(); // if both cases are false, then the current node is the // closest to the root over the path, and therefor the // distance to its father is not in the path at all. } return sumOfDistances; } // simular to above, but for all nodes at once. O(n^3) or so, but this should not be an issue // in any reasonable scenario // only disTab[i][j] is filled. disTab[j][i] remains zero. void tree::getTreeDistanceTableAndNames(VVdouble& disTab, vector & vNames) const { vector nodepV; getAllLeaves(nodepV, _root); disTab.resize(nodepV.size()); vNames.resize(nodepV.size()); for (int i=0;iname(); for(int j=i+1;jfather() == j) return i->dis2father(); assert (j->father() == i); return j->dis2father(); } //******************************************************************************* // change tree topoplogy parameters - should be applied carefully //******************************************************************************* //set the new root at p_iNewRoot // The method doesn't convert an "unrooted tree" = "a tree in which the root has 3 sons" // to a rooted one = "a tree in which the root has <= 2 sons". // The new root will still have 3 sons. void tree::rootAt(const nodeP p_iNewRoot) { if (_root == p_iNewRoot) return; vector pathMatrix; getPathBetweenAnyTwoNodes(pathMatrix, _root, p_iNewRoot); //pathMatrix size is always bigger than 2. for (int i = 0; i < pathMatrix.size() - 1 ; i++) { pathMatrix[i]->_father = pathMatrix[i+1]; pathMatrix[i]->setDisToFather( pathMatrix[i+1]->dis2father() ); pathMatrix[i]->removeSon(pathMatrix[i+1]); pathMatrix[i+1]->_sons.push_back(pathMatrix[i+1]->father()); pathMatrix[i+1]->_father = NULL; } _root = p_iNewRoot; } void tree::makeSureAllBranchesArePositive() { if (!withBranchLength()) { LOGnOUT(3,<<"\n WARN: Tree with no branch length! Create Flat tree with all branches= "< _nodevec; getAllNodes(_nodevec,_root); for (int i=0; i < _nodevec.size(); ++i) { if (_nodevec[i]!=_root) { if (_nodevec[i]->dis2father()<=0) { _nodevec[i]->setDisToFather(tree::SHORT_LENGTH_VALUE); } } } } void tree::makeSureAllBranchesAreLargerThanEpsilon(MDOUBLE epsilon) { vector _nodevec; getAllNodes(_nodevec,_root); for (int i=0; i < _nodevec.size(); ++i) { if (_nodevec[i]!=_root) { if (_nodevec[i]->dis2father()name()<<", length: "<<_nodevec[i]->dis2father()<<" is changed to: "<setDisToFather(epsilon); } } } } MDOUBLE tree::getAllBranchesLengthSum() { MDOUBLE totalBranchLength = 0.0; vector _nodevec; getAllNodes(_nodevec,_root); for (int i=0; i < _nodevec.size(); ++i) { if (_nodevec[i]!=_root) { totalBranchLength += _nodevec[i]->dis2father(); } } return totalBranchLength; } //create new names to all internal nodes. //the new name will be NXX, where XX is htu number void tree::create_names_to_internal_nodes() { vector htuVec; getAllHTUs(htuVec,_root); for (int i=0; isetName((string)"N" + name); } } void tree::multipleAllBranchesByFactor(MDOUBLE InFactor) { vector vec; getAllNodes(vec,_root ); for (int i = 0; i < vec.size(); ++i) { if (vec[i]->father() != NULL) vec[i]->setDisToFather(vec[i]->dis2father() * InFactor); } _root->setDisToFather(TREE_NULL); } void tree::createFlatLengthMatrix(const MDOUBLE newFlatDistance) { vector vec; getAllNodes(vec,_root ); for (int i=0; i< vec.size(); ++i) { if (vec[i]->father() != NULL) vec[i]->setDisToFather(newFlatDistance); } } /* void tree::set_length_to_father(nodeP iSon, MDOUBLE dLength) { iSon->setDisToFather(dLength); } */ // helper function class eqNameVLOCAL { public: explicit eqNameVLOCAL(const string& x) : _x(x) {} const string& _x; bool operator() (const tree::nodeP y){ return _x == y->name(); } }; // removes sonNode from its father according to the name of sonNode // this function should ONLY be used when the node, sonNode, is to be recycled soon! // because this function does not change the number of leaves nor the number of nodes! // nor does it change the father of sonNode. void tree::removeNodeFromSonListOfItsFather(nodeP sonNode) { vector::iterator vec_iter; vec_iter = remove_if(sonNode->_father->_sons.begin(), sonNode->_father->_sons.end(), eqNameVLOCAL(sonNode->name())); sonNode->father()->_sons.erase(vec_iter,sonNode->father()->_sons.end()); // pg 1170, primer. } //******************************************************************************* // Input-Output //******************************************************************************* void tree::output(string treeOutFile, TREEformats fmt, bool withHTU ) const { ofstream os(treeOutFile.c_str()); output(os, fmt, withHTU); os.close(); } void tree::output(ostream& os, TREEformats fmt, bool withHTU) const { if (_root == NULL) { LOG(1,<<" empty tree "); return; } if (fmt == PHYLIP) outputInPhylipTreeFormat(os, withHTU); else if (fmt == PAML) outputInPamlTreeFormat(os, withHTU); else if (fmt == ANCESTOR) outputInAncestorTreeFormat(os,withHTU); else if (fmt == ANCESTORID) outputInAncestorIdTreeFormat(os,withHTU); os< vec; int maxNameLen = 0; getAllLeaves(vec,_root); for (int w=0; wname().size()) maxNameLen = vec[w]->name().size(); } maxNameLen++; // this is just the longest name of taxa plus one time( <ime ); treeOutStream<<"# created on "<< ctime( <ime ) ; treeOutStream<<"name"; spaces = maxNameLen-4; for (k=0;kname(); spaces = maxNameLen-vec[i]->name().size(); for (k=0;kfather()->name(); spaces = 7-vec[i]->father()->name().size(); for (k=0;kdis2father(); } for (int j=0; j < vec[i]->getNumberOfSons(); j++) { treeOutStream<<" "<_sons[j]->name(); } treeOutStream<name(); spaces = maxNameLen-vec[i]->name().size(); for (k=0;kfather()->name(); spaces = 7-vec[i]->father()->name().size(); for (k=0;kdis2father(); for (int j=0; j < vec[i]->getNumberOfSons(); j++) { treeOutStream<<" "<_sons[j]->name(); } treeOutStream<name()<<")"<getNumberOfSons()==1)) { // very special case of a root with one son. os<<"("<<_root->name()<<":0.0"; if (_root->getComment().length()) os << "[&&NHX" << _root->getComment() <<"]"; os<<","; os<<_root->getSon(0)->name()<<":" <getSon(0)->dis2father(); if (_root->getSon(0)->getComment().length()) os << "[&&NHX" << _root->getSon(0)->getComment() <<"]"; os <<")"<getNumberOfSons()-1; ++i) { print_from(_root->getSon(i),os, withHTU); os<<","; } print_from(_root->getSon(i),os, withHTU); os<<")"; if (withHTU==true) os<<_root->name(); if (_root->getComment().length()) os << "[&&NHX" << _root->getComment() <<"]"; char c=';';// 59 is dot-line os<name() + ")" + "\n"; return (treeString); } else if ((getLeavesNum() == 2) && (_root->getNumberOfSons()==1)) { // very special case of a root with one son. treeString += "(" + _root->name() + ":0.0"; if (_root->getComment().length()) treeString += "[&&NHX" + _root->getComment() + "]"; treeString += ","; treeString +=_root->getSon(0)->name() + ":" + double2string(_root->getSon(0)->dis2father()); if (_root->getSon(0)->getComment().length()) treeString += "[&&NHX" + _root->getSon(0)->getComment() + "]"; treeString += ")\n"; return (treeString); } // ======================================== treeString += "("; // going over all the son int i; for (i=0; i<_root->getNumberOfSons()-1; ++i) { string_print_from(_root->getSon(i),treeString, withHTU); treeString += ","; } string_print_from(_root->getSon(i),treeString, withHTU); treeString += ")"; if (withHTU==true) treeString += _root->name(); if (_root->getComment().length()) treeString += "[&&NHX" + _root->getComment() + "]"; treeString += ";"; return (treeString); } //this format is like phylip format except first line is the number of leaves in the tree and the number of trees (1) void tree::outputInPamlTreeFormat(ostream& os, bool withHTU ) const { // special case of a tree with 1 or 2 taxa. if (getLeavesNum() == 1) { os<<"("<<_root->name()<<")"<getNumberOfSons()==1)) { // very special case of a root with one son. os<<"("<<_root->name()<<":0.0"; if (_root->getComment().length()) os << "[&&NHX" << _root->getComment() <<"]"; os<<","; os<<_root->getSon(0)->name()<<":" <getSon(0)->dis2father(); if (_root->getSon(0)->getComment().length()) os << "[&&NHX" << _root->getSon(0)->getComment() <<"]"; os <<")"< vec; getAllLeaves(vec, _root); int num = vec.size(); os<getNumberOfSons()-1; ++i) { print_from(_root->getSon(i),os, withHTU); os<<","; } print_from(_root->getSon(i),os, withHTU); os<<")"; if (withHTU==true) os<<_root->name(); if (_root->getComment().length()) os << "[&&NHX" << _root->getComment() <<"]"; char c=';';// 59 is dot-line os<isLeaf()) os<name(); else { os<<"("; for (i=0; igetNumberOfSons()-1; ++i) { print_from(from_node->getSon(i),os,withHTU); os<<","; } print_from(from_node->getSon(i),os,withHTU); os<<")"; if (withHTU==true) os<name(); } os<<":"<dis2father(); if (from_node->getComment().length()) os << "[&&NHX" << from_node->getComment() <<"]"; return 0; } int tree::string_print_from(nodeP from_node, string& s, bool withHTU ) const { int i; if (from_node->isLeaf()) s += from_node->name(); else { s += "("; for (i=0; igetNumberOfSons()-1; ++i) { string_print_from(from_node->getSon(i),s,withHTU); s += ","; } string_print_from(from_node->getSon(i),s,withHTU); s += ")"; if (withHTU==true) s += from_node->name(); } s += ":" + double2string(from_node->dis2father()); if (from_node->getComment().length()) s += "[&&NHX" + from_node->getComment() + "]"; return 0; } bool tree::readPhylipTreeTopology(istream &in) { const vector tree_contents = PutTreeFileIntoVector(in); return readPhylipTreeTopology(tree_contents); } bool tree::readPhylipTreeTopology(istream &in,vector& isFixed) { const vector tree_contents = PutTreeFileIntoVector(in); return readPhylipTreeTopology(tree_contents,isFixed); } bool tree::readPhylipTreeTopology(const vector& tree_contents) { vector isFixed; return readPhylipTreeTopology(tree_contents,isFixed); } string getName(vector::const_iterator& p_itCurrent) { string tmpname; tmpname.erase(); while (((*p_itCurrent)!=')') && ((*p_itCurrent)!='(') && ((*p_itCurrent)!=':') && ((*p_itCurrent)!=',') && ((*p_itCurrent)!='}') && ((*p_itCurrent)!='{')) { tmpname +=(*p_itCurrent); ++p_itCurrent; } return tmpname; } bool tree::readPhylipTreeTopology(const vector& tree_contents,vector& isFixed) { int nextFreeID =0; // to give id's for nodes. _leaves = GetNumberOfLeaves(tree_contents); _root = new TreeNode(nextFreeID); if (_leaves == 1) {// very special case of a tree that is only 1 leaf... vector::const_iterator itCurrent = tree_contents.begin(); itCurrent++; _root->setName(getName(itCurrent)); return true; } ++nextFreeID; _nodes = GetNumberOfInternalNodes(tree_contents) + _leaves; isFixed.resize(_nodes,0); // 0 = not fixed, 1 = fixed. nodeP conection2part=NULL; vector::const_iterator itCurrent = tree_contents.begin(); if (verifyChar(itCurrent,OPENING_BRACE)||verifyChar(itCurrent,OPENING_BRACE2)){ do { itCurrent++; conection2part = readPart(itCurrent,nextFreeID,isFixed); // readPart returns a pointer to himself _root->_sons.push_back(conection2part); conection2part->_father = _root; } while (verifyChar(itCurrent, COMMA)); } if (!(verifyChar(itCurrent, CLOSING_BRACE)||verifyChar(itCurrent, CLOSING_BRACE2))) { errorMsg::reportError("Bad format in tree file.",1); // also quit } else itCurrent++; // skip closing brace _root->setComment(readPosibleComment(itCurrent)); if (verifyChar(itCurrent, SEMI_COLLON)) itCurrent++; // this part is for the cases where all the edges are fixed. In such case - this part changes // all the branches to not fixed. int z=0; bool allFixed = true; for (z=1; z< isFixed.size(); ++z) { if (isFixed[z] == 0) { allFixed = false; break; } } if (allFixed) { for (z=1; z< isFixed.size(); ++z) { isFixed[z] = 0; } } return true; } // isFixed is actually a bool vector. Sometimes we want to fix a subtree of the tree, for example // "human and chimp" so we won't try any topologies that interrupt with this constraint. // When isFixed[i] == 1, it means that the branch above node i is fixed. This happens for every leaf, // and for nodes indicated by CLOSING_BRACE2 which is '}'. tree::nodeP tree::readPart( vector::const_iterator& p_itCurrent, int& nextFreeID, vector & isFixed) { if ( IsAtomicPart(p_itCurrent) ) { // read the name, i.e. - the content from the file nodeP newLeaf = new TreeNode(nextFreeID); isFixed[nextFreeID] = 1; // all edges to the leaves are fixed... ++nextFreeID; string tmpname = getName(p_itCurrent); newLeaf->setName(tmpname); // if a number(==distance) exists on the right-hand, update the distance table if ( DistanceExists(p_itCurrent) ) newLeaf->setDisToFather(getDistance(p_itCurrent)); // clearPosibleComment(p_itCurrent); newLeaf->setComment(readPosibleComment(p_itCurrent)); return newLeaf; } else // this is a complex part { nodeP newHTU = new TreeNode(nextFreeID); ++nextFreeID; nodeP conection2part=NULL; do { ++p_itCurrent; conection2part = readPart(p_itCurrent,nextFreeID,isFixed); conection2part->_father = newHTU; newHTU->_sons.push_back(conection2part); } while (verifyChar(p_itCurrent, COMMA)); if (verifyChar(p_itCurrent, CLOSING_BRACE)) { isFixed[newHTU->id()] = 1; } else if (verifyChar(p_itCurrent, CLOSING_BRACE2)) { isFixed[newHTU->id()] = 0; } else { errorMsg::reportError("Bad format in tree file (2)"); } ++p_itCurrent; // if a number(==distance) exists on the right-hand, update the distance table if ( DistanceExists(p_itCurrent) ) newHTU->setDisToFather(getDistance(p_itCurrent)); // clearPosibleComment(p_itCurrent); newHTU->setComment(readPosibleComment(p_itCurrent)); return newHTU; } } //copy the information from other_nodePTR to a new node, and set the father to father_nodePTR //does not update the number of nodes and leaves tree::nodeP tree::recursiveBuildTree(tree::nodeP father_nodePTR, const tree::nodeP other_nodePTR) { tree::nodeP childPTR = createNode(father_nodePTR, other_nodePTR->id()); childPTR->setName(other_nodePTR->name()); childPTR->setComment(other_nodePTR->getComment()); childPTR->setDisToFather(other_nodePTR->dis2father()); for (int k = 0 ; k < other_nodePTR->getNumberOfSons() ; ++k) { recursiveBuildTree(childPTR, other_nodePTR->getSon(k)); } return childPTR; } void tree::updateNumberofNodesANDleaves() { vector vec; getAllLeaves(vec,getRoot()); _leaves = vec.size(); vec.clear(); getAllNodes(vec,getRoot()); _nodes = vec.size(); } //removeLeaf: removes nodePTR from tree. also deletes nodePTR void tree::removeLeaf(nodeP nodePTR) { if (!(nodePTR->isLeaf())) { errorMsg::reportError("Error in function deleteLeaf - Unable to remove a node, which is not a leaf "); } if (getNodesNum() == 1) { delete getRoot(); _root = NULL; } if (nodePTR->isRoot()) { assert (nodePTR->getNumberOfSons() == 1); nodeP sonOfRoot = nodePTR->getSon(0); rootAt(sonOfRoot); } // leaf is not the root: nodeP fatheOfLeafToRemove = nodePTR->father(); fatheOfLeafToRemove->removeSon(nodePTR); delete nodePTR; int tmpSons = fatheOfLeafToRemove->getNumberOfSons(); if ((_root == fatheOfLeafToRemove) && (tmpSons == 1)) { //in case the tree was rooted and the removed leaf was one of the root' sons: //we have to remove the root and reroot the tree at the second root son nodeP newRoot = _root->getSon(0); delete fatheOfLeafToRemove; _root = NULL; rootAt(newRoot); } else if (tmpSons == 1) shrinkNode(fatheOfLeafToRemove); else if ((_root == fatheOfLeafToRemove) && (tmpSons == 2)) { nodeP tmp = _root; rootAt(_root->getSon(0)); shrinkNode(tmp); } if (_root->isLeaf() && _root->getNumberOfSons() >0 ) rootAt(_root->getSon(0)); updateNumberofNodesANDleaves(); return; } //getAllBranches: returns two vectors such that nodesUp[i] is the father of nodesDown[i] void tree::getAllBranches(vector &nodesUp, vector & nodesDown){ vector localVec; getAllNodes(localVec, _root); for (int i=0 ; i < localVec.size() ; i++) { if (localVec[i]->father() != NULL) { nodesUp.push_back(localVec[i]->father()); nodesDown.push_back(localVec[i]); } } return; } // the idea is that if we have a node with only one son (a tree like: node1---node2---node3) // we can eliminate node2 (which is nodePTR) void tree::shrinkNode(nodeP nodePTR) { if (nodePTR->getNumberOfSons() != 1) { vector err; err.push_back("you requested to eliminate a node with more than 1 sons."); err.push_back(" error in function shrink node"); errorMsg::reportError(err); // also quit the program. } nodeP fatherNode = nodePTR->father(); nodeP sonNode = nodePTR->getSon(0); if( (nodePTR->isRoot())&&(nodePTR->getNumberOfSons() == 1) ) // refering the root to be sonNode. { MDOUBLE dis2root = sonNode->dis2father(); sonNode->setFather(NULL); delete(_root); _root = sonNode; for (int i=0; i < sonNode->getNumberOfSons(); ++i) { MDOUBLE oldDis2Father = sonNode->getSon(i)->dis2father(); sonNode->getSon(i)->setDisToFather(oldDis2Father + dis2root); } _root->setDisToFather(TREE_NULL); updateNumberofNodesANDleaves(); return; } // taking care of the son node: sonNode->_father = fatherNode; sonNode->setDisToFather(sonNode->dis2father() + nodePTR->dis2father());//if it is the root dont add the distance // takind car of father node fatherNode->removeSon(nodePTR); fatherNode->_sons.push_back(sonNode); // delete the nodePTR delete nodePTR; updateNumberofNodesANDleaves(); } //createRootNode: erase the current tree and create a tree with one node. void tree::createRootNode() { clear(); _root = new TreeNode(0); _leaves=1; _nodes=1; } tree::nodeP tree::createNode(nodeP fatherNode, const int id) { nodeP tmp = new TreeNode(id); _nodes++; if (!fatherNode->isLeaf()) { // if fatherNode is a leaf then we remove one leaf and add one leaf, so no change. ++_leaves; } // there is one case when your father IS a leaf and yet you have to increase the number of leaves // this is when you father is the root, and you add the first child if (fatherNode->isRoot() && fatherNode->getNumberOfSons()==0) { ++_leaves; } tmp->_father = fatherNode; fatherNode->setSon(tmp); return tmp; } // check whether the tree contains information about branch length bool tree::withBranchLength() const{ if (_root->_sons.empty()) return false; else if (_root->getSon(0)->dis2father() != TREE_NULL) return true; return false; } ostream &operator<<(ostream &out, const tree &tr){ tr.output(out,tree::ANCESTOR); return out; } /* void tree::fillNodesID() { vector vec; getAllNodes(vec,_root ); for (int i=0; i< vec.size(); ++i) { vec[i]->setID( i); } } */ /* void tree::cut_tree_in_two_leaving_interMediate_node(nodeP node2split,tree &small1,tree &small2) const { tree tmpCopyOfThisTree = (*this); nodeP node2splitOnNewTree = tmpCopyOfThisTree.getNodeByName(node2split->name()); string interNode = "interNode"; assert(node2split->father() != NULL); nodeP tmp = tmpCopyOfThisTree.makeNodeBetweenTwoNodes(node2splitOnNewTree->father(),node2splitOnNewTree, interNode); tmpCopyOfThisTree.rootAt(tmp); tmpCopyOfThisTree.cut_tree_in_two_special(tmp, small1,small2); nodeP toDel1 = small1.getNodeByName(interNode); }; */ void tree::outputInAncestorIdTreeFormat( ostream& treeOutStream, bool distances) const{ time_t ltime; int i,k,spaces; vector vec; int maxNameLen = 0; getAllLeaves(vec,_root); for (int w=0; wname().size()) maxNameLen = vec[w]->name().size(); } maxNameLen++; // this is just the longest name of taxa plus one maxNameLen+=5; // MN time( <ime ); treeOutStream<<"# created on "<< ctime( <ime ) ; treeOutStream<<"name"; spaces = maxNameLen-4; for (k=0;kname()<<"("<id()<<")"; int len=3; if (vec[i]->id()>=10) len++;if (vec[i]->id()>=100) len++; spaces = maxNameLen-vec[i]->name().size()-len; for (k=0;kfather()->name(); spaces = 7-vec[i]->father()->name().size(); for (k=0;kdis2father(); } //else treeOutStream<<" "; for (int j=0; j < vec[i]->getNumberOfSons(); j++) { treeOutStream<<" "<_sons[j]->name(); } treeOutStream<name()<<"("<id()<<")"; int len=3; if (vec[i]->id()>=10) len++;if (vec[i]->id()>=100) len++; spaces = maxNameLen-vec[i]->name().size()-len; for (k=0;kfather()->name(); spaces = 7-vec[i]->father()->name().size(); for (k=0;kdis2father(); for (int j=0; j < vec[i]->getNumberOfSons(); j++) { treeOutStream<<" "<_sons[j]->name(); } treeOutStream<getNumberOfSons() > 2) return; // tree is already unrooted! if (getLeavesNum() <= 2) return; // Cannot be unrooted if the tree has less than 3 leaves. if (getRoot()->getSon(0)->getNumberOfSons() == 0) { tree::nodeP toRemove = getRoot()->getSon(1); getRoot()->getSon(0)->setDisToFather(getRoot()->getSon(1)->dis2father() + getRoot()->getSon(0)->dis2father()); getRoot()->setSon(toRemove->getSon(0)); for (int k = 1; k < toRemove->getNumberOfSons(); ++k) { getRoot()->setSon(toRemove->getSon(k)); } delete toRemove; getRoot()->removeSon(getRoot()->getSon(1)); getRoot()->claimSons(); } else { tree::nodeP toRemove = getRoot()->getSon(0); getRoot()->getSon(1)->setDisToFather(getRoot()->getSon(0)->dis2father() + getRoot()->getSon(1)->dis2father()); getRoot()->setSon(toRemove->getSon(0)); for (int k = 1; k < toRemove->getNumberOfSons(); ++k) { getRoot()->setSon(toRemove->getSon(k)); } delete toRemove; getRoot()->removeSon(getRoot()->getSon(0)); getRoot()->claimSons(); } updateNumberofNodesANDleaves(); } //check if the distances from the root to all leaves are equal up to the given tollerance bool tree::isUltrametric(MDOUBLE tol, bool bErrorIfNot) const { vector nodes; getAllLeaves(nodes, _root); MDOUBLE dist0 = getDistanceFromNode2ROOT(nodes[0]); for (int t = 1; t < nodes.size(); ++t) { MDOUBLE dist = getDistanceFromNode2ROOT(nodes[t]); if (!DEQUAL(dist, dist0, tol)) { if (bErrorIfNot) { string error = "Error: tree is not ultrametric\n"; error += "the distance from " + nodes[0]->name() + " to the root is: " + double2string(dist0) +"\n"; error += "the distance from " + nodes[t]->name() + " to the root is: " + double2string(dist) +"\n"; errorMsg::reportError(error); } return false; } } return true; } rate4site-3.0.0/src/phylogeny/bblEMProportionalEB.cpp0000644011611301161130000002417012223673416017463 00000000000000// $Id: bblEMProprtional.cpp 962 2006-11-07 15:13:34Z privmane $ #include "bblEM.h" #include "bblEMProportionalEB.h" #include "likelihoodComputation.h" using namespace likelihoodComputation; #include "computeUpAlg.h" #include "computeDownAlg.h" #include "computeCounts.h" #include "treeIt.h" #include "fromCountTableComponentToDistance.h" #include //#define VERBOS #include "fromCountTableComponentToDistancePropEB.h" bblEMProportionalEB::bblEMProportionalEB(tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, const bool optimizeSelectedBranches, const vector * weights, const int maxIterations, const MDOUBLE epsilon, const MDOUBLE tollForPairwiseDist, const MDOUBLE* likelihoodLast): _et(et),_sc(sc),_msp(msp),_pProportionDist(pProportionDist),_weights (weights),_optimizeSelectedBranches(optimizeSelectedBranches) { _numberOfGenes = _sc.size(); assert(_msp->getSPVecSize() == _sc.size()); _treeLikelihoodVec = compute_bblEMPropEB(maxIterations,epsilon,tollForPairwiseDist,likelihoodLast); } Vdouble bblEMProportionalEB::compute_bblEMPropEB( const int maxIterations, const MDOUBLE epsilon, const MDOUBLE tollForPairwiseDist, const MDOUBLE* likelihoodLast){ LOGnOUT(5,<<"Allocating place"<getSp(geneN),_cup[geneN],_pProportionDist,_posLike[geneN],(_weights?(*_weights)[geneN]:NULL)); } LOGnOUT(5,<<"--- Iter="<id(),_msp,_pProportionDist,tollForPairwiseDist,mynode->dis2father()); from1.computeDistance(); mynode->setDisToFather(from1.getDistance()); } } } rate4site-3.0.0/src/phylogeny/fromCountTableComponentToDistancePropEB.cpp0000644011611301161130000000200012223673415023502 00000000000000// $Id: fromCountTableComponentToDistanceProp.cpp 962 2006-11-07 15:13:34Z privmane $ #include "fromCountTableComponentToDistancePropEB.h" #include "likeDistPropEB.h" fromCountTableComponentToDistancePropEB::fromCountTableComponentToDistancePropEB( const vector< vector >& ctc, const int nodeID, multipleStochasticProcess *msp, const gammaDistribution* pProportionDist, const MDOUBLE toll, const MDOUBLE brLenIntialGuess ) : _msp(msp), _ctc(ctc), _nodeID(nodeID), _pProportionDist(pProportionDist){ _distance =brLenIntialGuess; _toll = toll; } void fromCountTableComponentToDistancePropEB::computeDistance() { MDOUBLE maxPairwiseDistance = 10.0; // The default MDOUBLE minPairwiseDistance = 0.0000001; // The default likeDistPropEB likeDist1(_msp,_pProportionDist,_toll,maxPairwiseDistance,minPairwiseDistance); MDOUBLE initGuess = _distance; _distance = likeDist1.giveDistance(_ctc,_nodeID,_likeDistance,initGuess); assert(_distance>=0); } rate4site-3.0.0/src/phylogeny/likeDistPropEB.cpp0000644011611301161130000000140612223673415016476 00000000000000// $Id: likeDistProp.cpp 962 2006-11-07 15:13:34Z privmane $ #include "likeDistPropEB.h" #include "numRec.h" const MDOUBLE likeDistPropEB::giveDistance( const vector< vector >& ctc,const int nodeID, MDOUBLE& resL,const MDOUBLE initialGuess) const { const MDOUBLE ax = _minPairwiseDistance; const MDOUBLE bx = initialGuess; const MDOUBLE cx = _maxPairwiseDistance; const MDOUBLE tol = _toll; MDOUBLE dist=-1.0; resL = -dbrent(ax,bx,cx, C_evallikeDistPropEB(ctc,_msp,_pProportionDist,nodeID), C_evallikeDistPropEB_d(ctc,_msp,_pProportionDist,nodeID), tol,&dist); return dist; } // the minus resL = -dbrent because C_evalDist return - value, because it is computing the min not the max... rate4site-3.0.0/src/phylogeny/bblLSProportionalEB.cpp0000644011611301161130000000502012223673416017471 00000000000000#include "bblLSProportionalEB.h" #include "numRec.h" #include "logFile.h" #include "errorMsg.h" bblLSProportionalEB::bblLSProportionalEB(tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, Vdouble& treeLikelihoodVec, const bool optimizeSelectedBranches, int maxIter, MDOUBLE epsilon) { _treeLikelihoodVec = optimizeBranches(et,sc,msp,pProportionDist,treeLikelihoodVec,optimizeSelectedBranches,maxIter,epsilon); } Vdouble bblLSProportionalEB::optimizeBranches(tree& et, const vector& sc, multipleStochasticProcess* msp, const gammaDistribution* pProportionDist, Vdouble& inTreeLikelihoodVec, const bool optimizeSelectedBranches, int maxIter, MDOUBLE epsilon) { Vdouble treeLikelihoodVec; if (inTreeLikelihoodVec.empty()){ treeLikelihoodVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist); } else{ treeLikelihoodVec = inTreeLikelihoodVec; } MDOUBLE treeLikelihood = sumVdouble(treeLikelihoodVec); LOGnOUT(5,<<"ll before bblLSr4sp"<<" logL="< nodesV; et.getAllNodes(nodesV,et.getRoot()); MDOUBLE prevIterL = VERYSMALL; for (int iter = 0; iter < maxIter; ++iter) { if (treeLikelihood < prevIterL + epsilon){ treeLikelihoodVec = likelihoodComputation::getTreeLikelihoodProportionalAllPosAlphTheSame(et,sc,msp,pProportionDist); return treeLikelihoodVec; //likelihood converged } prevIterL = treeLikelihood; MDOUBLE paramFound; MDOUBLE oldBl; MDOUBLE newL; for (int i=0; iisRoot()) continue; if((optimizeSelectedBranches) && (nodesV[i]->getComment() != "1")) continue; //only selected branhes will be optimized oldBl = nodesV[i]->dis2father(); newL = -brent(0.0,oldBl,MAX_BRANCH_LENGTH,evalR4SPBranch(nodesV[i],et,sc,msp,pProportionDist),epsilon,¶mFound); LOGnOUT(4,<<"oldL="< seqFileData; putFileIntoVectorStringArray(infile,seqFileData); vector::const_iterator currentLinePosition = seqFileData.begin(); string::const_iterator itStr = seqFileData.begin()->begin(); string::const_iterator itStrEnd = seqFileData.begin()->end(); int f_numSeq; bool readSeqNum= fromStringIterToInt(itStr,itStrEnd,f_numSeq); if (readSeqNum == false) errorMsg::reportError("Error reading number of sequences while reading PHYLIP sequence format"); int f_seqLength; bool readSeqLen= fromStringIterToInt(itStr,itStrEnd,f_seqLength); if (readSeqLen == false) errorMsg::reportError("Error reading the sequences length while reading PHYLIP sequence format"); currentLinePosition++; // we read the first line. int localid=0; for (; currentLinePosition != seqFileData.end() ; ) { if (currentLinePosition->empty()) {++currentLinePosition;continue;} // empty line constinue string remark; string name; sequence seq(alph); if (mySeqData.numberOfSeqs() < f_numSeq ) {//get from the line a name and a sequence; string name1; string stringSeq1; string::const_iterator it2 = (currentLinePosition)->begin(); for (; it2 != (currentLinePosition)->end();++it2) { if ((*it2)==' ') break; else name1+=(*it2); } for (; it2 != (currentLinePosition)->end();++it2) { if ((*it2)==' ') continue; else stringSeq1+=(*it2); } mySeqData.add(sequence(stringSeq1,name1,remark,localid,alph)); currentLinePosition++; localid++; } else { // adding to the string stringSeq1; string::const_iterator it2 = (currentLinePosition)->begin(); int sequenceId=localid%f_numSeq; for (; it2 != (currentLinePosition)->end() && mySeqData[sequenceId].seqLen() name().size() > 10) break; } if (it5 != sd.constTaxaEnd()) { LOG(1,<<"you asked to print in phylip format\n"); LOG(1,<<"however, the names in phylip format\n"); LOG(1,<<"must be no more than 10 characters.\n"); LOG(1,<<"Names are hence trancated to ten \n"); LOG(1,<<"characters. Notice, that this might\n"); LOG(1,<<"result in a two or more sequences \n"); LOG(1,<<"having the same name \n"); } // vector vec; // sd.getSequenceDatumPtrVector(vec); out<::const_iterator it5= vec.begin(); it5!=vec.end(); ++ it5) { for (sequenceContainer::constTaxaIterator it5=sd.constTaxaBegin();it5!=sd.constTaxaEnd();++it5) { for (int iName = 0 ;iNamename().size()) { if (currentPositionname()[iName]; } else out<<" "; out.flush(); } else out<<" "; } out.flush(); out<<" "; if (it5->seqLen()toString()<=it5->seqLen()) break; out<toString(k); if (((k+1)%spaceEvery==0) && (((k+1)%numOfPositionInLine!=0))) out<<" "; } out< seqFileData; putFileIntoVectorStringArray(infile,seqFileData); vector::const_iterator it1; for (it1 = seqFileData.begin(); it1!= seqFileData.end(); ++it1) { if (it1->empty()) continue; // empty line continue if (it1->size()>1) { if ( ((*it1)[0] == ';') && ((*it1)[1] == ';')) {// general file remarks mySeqData.addGeneralRemark(*it1); } } } int localid=0; for (it1 = seqFileData.begin(); it1!= seqFileData.end(); ) { if (it1->empty()) {++it1;continue; }// empty line continue if (it1->size()>1) { if ( ((*it1)[0] == ';') && ((*it1)[1] == ';')) {// general file remarks ++it1;continue; } } string remark; string name; string seqStr; if ((*it1)[0] != ';') { LOG(5,<<"problem in line: "<<*it1<empty()) it1++; // empty line continue name = *it1; ++it1; while (it1!= seqFileData.end()) { if ((*it1)[0] == ';') break; // the following lines are taking care of a format which is like "10 aact" // in mase format string withoutNumberAndSpaces = takeCharOutOfString("0123456789 ",*it1); seqStr+=withoutNumberAndSpaces; ++it1; } mySeqData.add(sequence(seqStr,name,remark,localid,alph)); localid++; } return mySeqData; } void maseFormat::write(ostream &out, const sequenceContainer& sd) { vector gfr = sd.getGeneralRemarks(); if (gfr.empty()) out<<";;\n;;\n"; for (vector::const_iterator k=gfr.begin() ; k != gfr.end() ; ++k ) out<<(*k)< 0) out<<";"<<(*it5).remark()<name()<toString()< sequenceContainer clustalFormat::read(istream &infile, const alphabet* alph) { sequenceContainer mySeqData = readUnAligned(infile, alph); mySeqData.makeSureAllSeqAreSameLengthAndGetLen(); return mySeqData; } sequenceContainer clustalFormat::readUnAligned(istream &infile, const alphabet* alph) { sequenceContainer mySequenceData; vector seqFileData; map stringsToAdd; //map that holding for each name last //one or two nucleotides (when reading codon //alphabet) of the line in order to add it //to the next line. putFileIntoVectorStringArray(infile,seqFileData); if (seqFileData.empty()){ errorMsg::reportError("unable to open file, or file is empty in clustal format"); } vector::const_iterator it1= seqFileData.begin(); // make sure that the first 7 chars in the first line is clustal if (it1->size()<7) errorMsg::reportError("first word in clusltal sequence file format must be clustal",1); if ( (( (*it1)[0] != 'C') && ((*it1)[0] != 'c')) || (((*it1)[1] != 'L') && ((*it1)[1] != 'l')) || (((*it1)[2] != 'U') && ((*it1)[2] != 'u')) || (((*it1)[3] != 'S') && ((*it1)[3] != 's')) || (((*it1)[4] != 'T') && ((*it1)[4] != 't')) || (((*it1)[5] != 'A') && ((*it1)[5] != 'a')) || (((*it1)[6] != 'L') && ((*it1)[6] != 'l')) ) { errorMsg::reportError("first word in clusltal sequence file format must be clustal",1); } it1++; int localid=0; while (it1!= seqFileData.end()) { if (it1->empty()) {++it1;continue; }// empty line continue if ((it1->size() > 1) && ((*it1)[0]==' ')) {++it1;continue; }// remark line string remark; string name; // getFromLineAnameAndAsequence; string name1; string stringSeq1; string::const_iterator it2 = (it1)->begin(); for (; it2 != (it1)->end();++it2) { if ((*it2)==' ') break; else name1+=(*it2); } if (stringsToAdd.find(name1)!=stringsToAdd.end()) //not new sequence stringSeq1 = stringsToAdd[name1]; //init stringSeq1 with the nucleotide //from the previous line for (; it2 != (it1)->end();++it2) { if ((*it2)==' ') continue; else stringSeq1+=(*it2); } //when alphabet is codon stringSeq1 must be product of three. // 1. save 1 or 2 last nucleotide in stringToAdd // 2. substr the last or two last nucleotide for the next line. // 3. keep stringToAdd in map (according the name). string stringToAdd=""; // codon codonAlph; if (alph->size()>=60){ // codon? if ((stringSeq1.size()%3)==1){ //add the last nucleotide to the next line stringToAdd+=stringSeq1[stringSeq1.size()-1]; stringSeq1 = stringSeq1.substr(0,stringSeq1.size()-1); } if ((stringSeq1.size()%3)==2){ //add the 2 last nucleotide to the next line stringToAdd+=stringSeq1[stringSeq1.size()-2]; stringToAdd+=stringSeq1[stringSeq1.size()-1]; stringSeq1 = stringSeq1.substr(0,stringSeq1.size()-2); } } stringsToAdd[name1] = stringToAdd; //update the map with the new stringToAdd int id = mySequenceData.getId(name1,false); if (id==-1) { // new sequence. name = name1; mySequenceData.add(sequence(stringSeq1,name,remark,localid,alph)); localid++; } else {// the sequence is already there... sequence tmp(stringSeq1,name,remark,id,alph); mySequenceData[id].operator += (tmp); } it1++; } return mySequenceData; } void clustalFormat::write(ostream &out, const sequenceContainer& sd) { // setting some parameters const int numOfPositionInLine = 60; int maxLengthOfSeqName =0; for (sequenceContainer::constTaxaIterator p=sd.constTaxaBegin(); p != sd.constTaxaEnd(); ++p ) { int nameLen = (*p).name().size(); if (nameLen>maxLengthOfSeqName) maxLengthOfSeqName=nameLen; } if (maxLengthOfSeqName<15) maxLengthOfSeqName=16; else maxLengthOfSeqName=maxLengthOfSeqName+4; // all this maxLengthOfSeqName is the out<<"CLUSTAL V"<=60) charLen*=3; out<::const_iterator it5= vec.begin(); it5!=vec.end(); ++ it5) { for (sequenceContainer::constTaxaIterator it5=sd.constTaxaBegin();it5!=sd.constTaxaEnd();++it5) { for (int iName = 0 ;iNametoString()<=charLen) break; out<toString()[k]; //in case of codon alphabet each position is three characters if (sd.alphabetSize()>=60){ out<toString()[++k]; out<toString()[++k]; } } out< using namespace std; sequenceContainer fastaFormat::read(istream &infile, const alphabet* alph) { sequenceContainer mySeqData = readUnAligned(infile, alph); mySeqData.makeSureAllSeqAreSameLengthAndGetLen(); return mySeqData; } sequenceContainer fastaFormat::readUnAligned(istream &infile, const alphabet* alph) { sequenceContainer mySeqData; vector seqFileData; putFileIntoVectorStringArray(infile,seqFileData); if (seqFileData.empty()){ errorMsg::reportError("unable to open file, or file is empty in fasta format"); } vector::const_iterator it1; int localid=0; for (it1 = seqFileData.begin(); it1!= seqFileData.end(); ) { if (it1->empty()) {++it1;continue; }// empty line continue string remark; string name; if ((*it1)[0] == '>') { string::const_iterator itstrtmp = (*it1).begin(); itstrtmp++; while (itstrtmp != (*it1).end()) { name+= *itstrtmp; itstrtmp++; } //for (string::iterator i = name.begin(); i!=(name.end()-2);++i) { // *i=*(i+1); // removing the ">". should be done more elegant... //} ++it1; } else { LOG(0,<<"problem in line: "<<*it1<",1); } while (it1->empty()) it1++; // empty line continue string str; while (it1!= seqFileData.end()) { if ((*it1)[0] == '>') break; str+=*it1; ++it1; } // remove spaces form str; str = takeCharOutOfString(" \t", str); name = trim(name); mySeqData.add(sequence(str,name,remark,localid,alph)); localid++; } return mySeqData; } void fastaFormat::write(ostream &out, const sequenceContainer& sd) { for (sequenceContainer::constTaxaIterator it5=sd.constTaxaBegin();it5!=sd.constTaxaEnd();++it5) { out<<">"<<(it5)->name()<toString()< seqFileData; putFileIntoVectorStringArray(infile,seqFileData); vector::const_iterator currentLinePosition = seqFileData.begin(); string::const_iterator itStr = seqFileData.begin()->begin(); string::const_iterator itStrEnd = seqFileData.begin()->end(); int f_numSeq; bool readSeqNum= fromStringIterToInt(itStr,itStrEnd,f_numSeq); if (readSeqNum == false) errorMsg::reportError("Error reading number of sequences while reading PHYLIP sequence format"); int f_seqLength; bool readSeqLen= fromStringIterToInt(itStr,itStrEnd,f_seqLength); if (readSeqLen == false) errorMsg::reportError("Error reading the sequences length while reading PHYLIP sequence format"); currentLinePosition++; // we read the first line. int localid=0; for (; currentLinePosition != seqFileData.end() ; ) { if (currentLinePosition->empty()) {++currentLinePosition;continue;} // empty line continue string stringSeq1; string name1; while (stringSeq1.length() < f_seqLength ) { // adding a new seq string::const_iterator it2 = (currentLinePosition)->begin(); if ((*it2)==' ') { // line without seq. name, read seq. content only for (; it2 != (currentLinePosition)->end();++it2) { if ((*it2)==' ') continue; else stringSeq1+=(*it2); } } else { // first read sequence name, then read seq itself for (; it2 != (currentLinePosition)->end();++it2) { if ((*it2)==' ') break; else name1+=(*it2); } for (; it2 != (currentLinePosition)->end();++it2) { if ((*it2)==' ') continue; else stringSeq1+=(*it2); } } currentLinePosition++; } mySeqData.add(sequence(stringSeq1,name1,"",localid,alph)); localid++; } return mySeqData; } void phylipSequentialFormat::write(ostream &out, const sequenceContainer& sd, const int numOfPositionInLine, const int spaceEvery) { sequenceContainer::constTaxaIterator it5=sd.constTaxaBegin(); for (;it5!=sd.constTaxaEnd();++it5) { if (it5->name().size() > 10) break; } if (it5 != sd.constTaxaEnd()) { LOG(1,<<"you asked to print in phylip format\n"); LOG(1,<<"however, the names in phylip format\n"); LOG(1,<<"must be no more than 10 characters.\n"); LOG(1,<<"Names are hence trancated to ten \n"); LOG(1,<<"characters. Notice, that this might\n"); LOG(1,<<"result in a two or more sequences \n"); LOG(1,<<"having the same name \n"); } // vector vec; // sd.getSequenceDatumPtrVector(vec); out<name().size()) { if (currentPositionname()[iName]; } else out<<" "; out.flush(); } else out<<" "; } out.flush(); out<<" "; // next - print sequence itself while (currentPosition < sd.seqLen() ) { if (it5->seqLen()toString()<=it5->seqLen()) break; out<toString(k); if (((k+1)%spaceEvery==0) && (((k+1)%numOfPositionInLine!=0))) out<<" "; } out< seqFileData; putFileIntoVectorStringArray(infile,seqFileData); if (seqFileData.empty()){ errorMsg::reportError("unable to open file, or file is empty in molphy format"); } vector::iterator currentLinePosition = seqFileData.begin(); string::const_iterator itStr = seqFileData.begin()->begin(); string::const_iterator itStrEnd = seqFileData.begin()->end(); int f_numSeq; bool readSeqNum= fromStringIterToInt(itStr,itStrEnd,f_numSeq); if (readSeqNum == false) errorMsg::reportError("Error reading number of sequences while reading MOLPHY sequence format"); int f_seqLength; bool readSeqLen= fromStringIterToInt(itStr,itStrEnd,f_seqLength); if (readSeqLen == false) errorMsg::reportError("Error reading the sequences length while reading MOLPHY sequence format"); currentLinePosition++; // we read the first line. //--------------------------------------------------------------------- sequenceContainer mySeqData; //--------------------------------------------------------------------- // vector vec; // seqDataPtr->getSequenceDatumPtrVectorNonConst(vec); int localID=-1; vector::const_iterator it1 = seqFileData.begin(); ++it1; //skipping the first line that was read already. while (it1!= seqFileData.end()) { localID++; if (it1->empty()) { it1++; continue; // empty line continue } // read the name. string name(*it1); it1++; string tmpString; while (it1 != seqFileData.end()) { if (tmpString.size() < f_seqLength) { tmpString+=*it1; ++it1; } else break; } mySeqData.add(sequence(tmpString,name,"",localID,alph)); } return mySeqData; } void molphyFormat::write(ostream &out, const sequenceContainer& sd) { out<name()<toString(); int k=0; for (string::const_iterator cPos=seqString.begin() ; cPos != seqString.end() ; cPos ++,k++ ) { if (k>0 && ((k%60)==0)) out< sequenceContainer nexusFormat::read(istream &infile, const alphabet* pAlph) { sequenceContainer mySeqData = readUnAligned(infile, pAlph); mySeqData.makeSureAllSeqAreSameLengthAndGetLen(); return mySeqData; } sequenceContainer nexusFormat::readUnAligned(istream &infile, const alphabet* pAlph) { if (!infile) { errorMsg::reportError("unable to read mase format, could not open file"); } sequenceContainer mySeqData;; vector seqFileData; putFileIntoVectorStringArray(infile,seqFileData); vector::const_iterator it1 = seqFileData.begin(); // make sure that the first 6 chars in the first line is #NEXUS if (it1->size()<6) errorMsg::reportError("first word in a nexus sequence file format must be #NEXUS",1); if ( ((*it1)[0] != '#') || (((*it1)[1] != 'N') && ((*it1)[1] != 'n')) || (((*it1)[2] != 'E') && ((*it1)[2] != 'e')) || (((*it1)[3] != 'X') && ((*it1)[3] != 'x')) || (((*it1)[4] != 'U') && ((*it1)[4] != 'u')) || (((*it1)[5] != 'S') && ((*it1)[5] != 's')) ) { errorMsg::reportError("first word in a nexus sequence file format must be #NEXUS",1); } it1++; while ( ( (*it1).find("matrix") == -1) && ( (*it1).find("MATRIX") == -1) && (it1!= seqFileData.end())) { //check for the word matrix ++it1; } int localid=0; //int x1 = ((*it1).find("matrix") != -1); //int x2 = ((*it1).find("MATRIX") != -1); if (((*it1).find("matrix") != -1) || ((*it1).find("MATRIX") != -1)) { //taken from clustalFormat: //In case of codon alpahabet we cannot add a seqeunce that is not dividable by 3. //In this case the last nucleotides in each line (zero, one or two) //should be saved. The next time the same sequence name appears - //these saveed nucleotidea and are added to the begining of the line. map stringsToAdd; for (++it1; it1 != seqFileData.end() ; ++it1) { if (((*it1).find("end;") != -1) || ((*it1).find("END;") != -1)) break; if (it1->empty() || ((*it1).find(';') != -1)) { // empty line constinue continue; } sequence seq(pAlph); string taxonName; string remark; string stringSeq; bool beforeName = true; string::const_iterator stringIt = (it1)->begin(); for (; stringIt != (it1)->end(); ++stringIt) { //first loop finds the taxon name if ( ((*stringIt) == ' ') || ((*stringIt) == '\t')) if (beforeName == true) continue; //spaces before taxon name are legal else break; //A space marks the end of the taxon name else { taxonName += (*stringIt); beforeName = false; } } //check if a new sequence. //if the name already exists then init stringSeq with the nucleotide from the previous line of the same sequence if (stringsToAdd.find(taxonName)!=stringsToAdd.end()) stringSeq = stringsToAdd[taxonName]; for (; stringIt != (it1)->end(); ++stringIt) {//second loop finds the sequecne if ( ((*stringIt)==' ') || ((*stringIt) == '\t')) continue; else stringSeq += (*stringIt); } //when alphabet is codon stringSeq must be dividable by 3. // 1. save the reminder (0,1 or 2 last nucleotides) in stringToAdd // 2. substr the reminder from the sequence line. // 3. keep stringToAdd in map (according the name) to be added later. string stringToAdd=""; if (pAlph->size()>=60){ // codon? if ((stringSeq.size()%3)==1){ //add the last nucleotide to the next line stringToAdd += stringSeq[stringSeq.size()-1]; stringSeq = stringSeq.substr(0,stringSeq.size()-1); } if ((stringSeq.size() % 3) == 2){ //add the 2 last nucleotide to the next line stringToAdd+=stringSeq[stringSeq.size()-2]; stringToAdd+=stringSeq[stringSeq.size()-1]; stringSeq = stringSeq.substr(0, stringSeq.size() - 2); } } stringsToAdd[taxonName] = stringToAdd; //update the map with the new stringToAdd //add sequence to container int id = mySeqData.getId(taxonName, false); if (id==-1) { // new sequence. mySeqData.add(sequence(stringSeq, taxonName,remark,localid, pAlph)); localid++; } else {// the sequence is already there... sequence tmp(stringSeq,taxonName, remark, id, pAlph); mySeqData[id].operator += (tmp); } } } else { errorMsg::reportError("no sequence data in nexus file - no matrix keyword found"); } return mySeqData; } void nexusFormat::write(ostream &out, const sequenceContainer& sc) { //vector gfr = sd.getGeneralFileRemarks(); //if (gfr.empty()) out<<";;\n;;\n"; //for (vector::const_iterator k=gfr.begin() ; k != gfr.end() ; ++k ) // out<<(*k)<name()<<"\t"<toString()< "$@" AM_CXXFLAGS = -I$(top_srcdir)/src/phylogeny/ rate4site_CPPFLAGS = -DDOUBLEREP rate4site_LDADD = ../../src/phylogeny/libphylo.a rate4site_doublerep_LDADD = ../../src/phylogeny/libphylo.a rate4site_SOURCES = \ rate4site.h \ rate4siteOptions.h \ rate4siteOptions.cpp \ rate4site.cpp rate4site_doublerep_SOURCES = \ rate4site.h \ rate4siteOptions.h \ rate4siteOptions.cpp \ rate4site.cpp clean-local: rm -f $(man_MANS)rate4site-3.0.0/src/rate4site/Makefile.in0000644011611301161130000006005712223673476015123 00000000000000# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__make_dryrun = \ { \ am__dry=no; \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ *) \ for am__flg in $$MAKEFLAGS; do \ case $$am__flg in \ *=*|--*) ;; \ *n*) am__dry=yes; break;; \ esac; \ done;; \ esac; \ test $$am__dry = yes; \ } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : bin_PROGRAMS = $(am__EXEEXT_1) subdir = src/rate4site DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__EXEEXT_1 = rate4site$(EXEEXT) rate4site_doublerep$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" PROGRAMS = $(bin_PROGRAMS) am_rate4site_OBJECTS = rate4site-rate4siteOptions.$(OBJEXT) \ rate4site-rate4site.$(OBJEXT) rate4site_OBJECTS = $(am_rate4site_OBJECTS) rate4site_DEPENDENCIES = ../../src/phylogeny/libphylo.a am_rate4site_doublerep_OBJECTS = rate4siteOptions.$(OBJEXT) \ rate4site.$(OBJEXT) rate4site_doublerep_OBJECTS = $(am_rate4site_doublerep_OBJECTS) rate4site_doublerep_DEPENDENCIES = ../../src/phylogeny/libphylo.a DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(rate4site_SOURCES) $(rate4site_doublerep_SOURCES) DIST_SOURCES = $(rate4site_SOURCES) $(rate4site_doublerep_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 NROFF = nroff MANS = $(man_MANS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ PROGS = rate4site rate4site_doublerep man_MANS = rate4site.1 AM_CXXFLAGS = -I$(top_srcdir)/src/phylogeny/ rate4site_CPPFLAGS = -DDOUBLEREP rate4site_LDADD = ../../src/phylogeny/libphylo.a rate4site_doublerep_LDADD = ../../src/phylogeny/libphylo.a rate4site_SOURCES = \ rate4site.h \ rate4siteOptions.h \ rate4siteOptions.cpp \ rate4site.cpp rate4site_doublerep_SOURCES = \ rate4site.h \ rate4siteOptions.h \ rate4siteOptions.cpp \ rate4site.cpp all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/rate4site/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/rate4site/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) rate4site$(EXEEXT): $(rate4site_OBJECTS) $(rate4site_DEPENDENCIES) $(EXTRA_rate4site_DEPENDENCIES) @rm -f rate4site$(EXEEXT) $(CXXLINK) $(rate4site_OBJECTS) $(rate4site_LDADD) $(LIBS) rate4site_doublerep$(EXEEXT): $(rate4site_doublerep_OBJECTS) $(rate4site_doublerep_DEPENDENCIES) $(EXTRA_rate4site_doublerep_DEPENDENCIES) @rm -f rate4site_doublerep$(EXEEXT) $(CXXLINK) $(rate4site_doublerep_OBJECTS) $(rate4site_doublerep_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rate4site-rate4site.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rate4site-rate4siteOptions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rate4site.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rate4siteOptions.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` rate4site-rate4siteOptions.o: rate4siteOptions.cpp @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT rate4site-rate4siteOptions.o -MD -MP -MF $(DEPDIR)/rate4site-rate4siteOptions.Tpo -c -o rate4site-rate4siteOptions.o `test -f 'rate4siteOptions.cpp' || echo '$(srcdir)/'`rate4siteOptions.cpp @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/rate4site-rate4siteOptions.Tpo $(DEPDIR)/rate4site-rate4siteOptions.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rate4siteOptions.cpp' object='rate4site-rate4siteOptions.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o rate4site-rate4siteOptions.o `test -f 'rate4siteOptions.cpp' || echo '$(srcdir)/'`rate4siteOptions.cpp rate4site-rate4siteOptions.obj: rate4siteOptions.cpp @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT rate4site-rate4siteOptions.obj -MD -MP -MF $(DEPDIR)/rate4site-rate4siteOptions.Tpo -c -o rate4site-rate4siteOptions.obj `if test -f 'rate4siteOptions.cpp'; then $(CYGPATH_W) 'rate4siteOptions.cpp'; else $(CYGPATH_W) '$(srcdir)/rate4siteOptions.cpp'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/rate4site-rate4siteOptions.Tpo $(DEPDIR)/rate4site-rate4siteOptions.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rate4siteOptions.cpp' object='rate4site-rate4siteOptions.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o rate4site-rate4siteOptions.obj `if test -f 'rate4siteOptions.cpp'; then $(CYGPATH_W) 'rate4siteOptions.cpp'; else $(CYGPATH_W) '$(srcdir)/rate4siteOptions.cpp'; fi` rate4site-rate4site.o: rate4site.cpp @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT rate4site-rate4site.o -MD -MP -MF $(DEPDIR)/rate4site-rate4site.Tpo -c -o rate4site-rate4site.o `test -f 'rate4site.cpp' || echo '$(srcdir)/'`rate4site.cpp @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/rate4site-rate4site.Tpo $(DEPDIR)/rate4site-rate4site.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rate4site.cpp' object='rate4site-rate4site.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o rate4site-rate4site.o `test -f 'rate4site.cpp' || echo '$(srcdir)/'`rate4site.cpp rate4site-rate4site.obj: rate4site.cpp @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT rate4site-rate4site.obj -MD -MP -MF $(DEPDIR)/rate4site-rate4site.Tpo -c -o rate4site-rate4site.obj `if test -f 'rate4site.cpp'; then $(CYGPATH_W) 'rate4site.cpp'; else $(CYGPATH_W) '$(srcdir)/rate4site.cpp'; fi` @am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/rate4site-rate4site.Tpo $(DEPDIR)/rate4site-rate4site.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='rate4site.cpp' object='rate4site-rate4site.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rate4site_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o rate4site-rate4site.obj `if test -f 'rate4site.cpp'; then $(CYGPATH_W) 'rate4site.cpp'; else $(CYGPATH_W) '$(srcdir)/rate4site.cpp'; fi` install-man1: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(MANS) installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-local mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-man uninstall-man: uninstall-man1 .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-local ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-man1 \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-man uninstall-man1 $(man_MANS) : %.1 : %.cpp sed -e 's|__pkgdatadir__|$(pkgdatadir)|g;s|__examplesdir__|$(examplesdir)|g;s|__sysconfdir__|$(sysconfdir)|g;s|__bindir__|$(bindir)|g;s|__PACKAGE_VERSION__|$(PACKAGE_VERSION)|g' "$<" | \ pod2man --utf8 -c 'User Commands' -r "$(VERSION)" -name $(shell echo "$(basename $@)" | tr '[:lower:]' '[:upper:]') > "$@" clean-local: rm -f $(man_MANS) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: rate4site-3.0.0/src/rate4site/rate4site.h0000755011611301161130000000653612223673417015133 00000000000000/* rate4site - prediction of protein conservation weight based on a phylogenetic tree * Copyright (C) 2004: Mayrose, I., Graur, D. , Ben-Tal, N. , Pupko, T * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef ___RATE_4_SITE____H #define ___RATE_4_SITE____H #include "definitions.h" #include "rate4siteOptions.h" #include "alphabet.h" #include "sequenceContainer.h" #include "stochasticProcess.h" #include "tree.h" class rate4site { public: explicit rate4site(int argc, char* argv[]); virtual ~rate4site(); void testGTR(); private: void computeRate4site(); void compute_ML_Rate4site(); void compute_EB_EXP_Rate4site(); void getStartingStochasticProcess(); void getStartingEvolTreeTopology(bool bCalcDistanceTable); void getStartingBranchLengthsAndAlpha(); void printrate4siteInfo(ostream& out); void printProcessId(); void fillOptionsParameters(int argc, char* argv[]); const rate4siteOptions* _options; void printOptionParameters(); void getStartingSequenceData(); void getAttributesAndValidateThatEverythingFits(); void printOutputTree(); // TREE SEARCH PART void getStartingNJtreeNjJC(); void getStartingNJtreeNjJC_old(); // THIS IS THE OLD VERSION OF RATE4SITE. void getStartingTreeFromTreeFile(); void getStartingTreeNJ_fromDistances(const VVdouble& disTab,const vector& vNames); void getStartingNJtreeNjMLdis(); void getStartingMLtreeFromManyNJtrees(); void normalizeRates(); void print(ostream & out, const Vdouble & rate2print); void printRatesBayes(ostream& out, const Vdouble & rate2print); void printRatesML(ostream& out, const Vdouble & rate2print); void printAveAndStd(ostream& out); void computeAveAndStd(); // fills _ave, and _std void fillReferenceSequence(); void removeGapPositionAccordingToTheReferenceSequence(); sequenceContainer _sc; tree _et; stochasticProcess* _sp; alphabet* _alph; vector _spVec; vector _etVec; Vint _spAtributes; Vint _etAtributes; sequence* _refSeq; // the reference sequence MDOUBLE _likelihood; // the likelihood of the data after optimization Vdouble _rate;// the rates themselves Vdouble _Lrate;// the log likelihood of each position Vdouble _normalizedRates; // the rates when their ave = 0 and std = 1. MDOUBLE _ave; // the average over all rates. MDOUBLE _std; // the std over all rates. Vdouble _BayesianSTD;// the std of the Bayesian rates Vdouble _BayesianLowerBound;// lower bound of rate in Bayesian inference Vdouble _BayesianUpperBound;// upper bound of rate in Bayesian inference MDOUBLE _alphaConf; // the alpha confidence interval of Bayesian rates (set to 0.5). // the rate confidence interval will be the range of rates // that are in the 95% area under the curve. }; #endif rate4site-3.0.0/src/rate4site/rate4siteOptions.h0000644011611301161130000000664712223673417016507 00000000000000/* rate4site - prediction of protein conservation weight based on a phylogenetic tree * Copyright (C) 2004: Mayrose, I., Graur, D. , Ben-Tal, N. , Pupko, T * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ //We change the code, so that it takes into account secondary structures. //For this, we added the following members. //(1) string userSubstitutionMatrixFile; //This is used if the user want to input a single substitution file matrix. //For example, if wag was not implemented, the user could input the wag substitution file. //(2) string fileListingManySubstitutionMatrices; //This file is used if we want to have several matrices (for example, alpha, beta, and loop matrices). //Later, this file will be paired with the position file, so that position with attribute 1 will use //matrix 1, etc. //(3) string positionFile. This file gives the attributes of each position. For example //position with attributes 1 will use substitution matrix 1, etc. //(4) string manyTreeFileInput. If we want a different tree for each attribute. #if !defined ___RATEFPRSITE__OPTION__T__ #define ___RATEFPRSITE__OPTION__T__ // #ifdef SunOS // // #else // // #ifndef __STDC__ // // #define __STDC__ 1 // // #include "getopt.h" // // #undef __STDC__ // // #else // // #include // // #endif // #endif #include #include #include using namespace std; class rate4siteOptions{ public: enum modelNameType {rev,jtt,lg,day,aajc,nucjc,wag,cprev,hky,tamura92,nucgtr};//,customQ,manyQ enum optimizeBranchLengthsType {noBBL,mlBBLUniform,mlAndAlphaBBL,mlAndAlphaAndBetaBBL}; enum treeSearchAlgType {njJC,njML,njJCOLD}; enum rateEstimationMethodType {ebExp, mlRate}; public: explicit rate4siteOptions(int& argc, char *argv[]); ostream& out() const {return *outPtr;}; //ostream& outNotNormalize() const {return *outPtrNotNormalize;}; string treefile; string seqfile; string logFile; string referenceSeq; // the results are printed with this seq in each positions. int logValue; string outFile; string outFileNotNormalize; string treeOutFile; // different substitution matrices for different positions string fileListingManySubstitutionMatrices;//f string spPositionFile; //p // different trees for different positions string manyTreeFileInput;//c string treePositionFile; //u modelNameType modelName; treeSearchAlgType treeSearchAlg; int alphabet_size; optimizeBranchLengthsType optimizeBranchLengths; rateEstimationMethodType rateEstimationMethod; int numberOfDiscreteCategories; //optimization step int inferenceCatNum;//number of categories to be used only in the inference step double userInputAlpha; double userInputBeta; double userInputTrTv; private: ostream* outPtr; ofstream out_f; //ostream* outPtrNotNormalize; //ofstream out_fNotNormalize; }; #endif rate4site-3.0.0/src/rate4site/rate4siteOptions.cpp0000644011611301161130000002223512223673417017031 00000000000000/* rate4site - prediction of protein conservation weight based on a phylogenetic tree * Copyright (C) 2004: Mayrose, I., Graur, D. , Ben-Tal, N. , Pupko, T * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "rate4siteOptions.h" #include "errorMsg.h" #include #include #include //for exit() using namespace std; rate4siteOptions::rate4siteOptions(int& argc, char *argv[]): // DEFAULTS VALUES: treefile(""), seqfile(""), logFile(""), //log.txt referenceSeq("non"), logValue(3), outFile("r4s.res"), outFileNotNormalize("r4sOrig.res"), treeOutFile("TheTree.txt"), fileListingManySubstitutionMatrices(""), spPositionFile(""), manyTreeFileInput(""), treePositionFile(""), modelName(jtt), treeSearchAlg(njML), alphabet_size(20), // this is 20 outPtr(&cout), optimizeBranchLengths(mlAndAlphaBBL), rateEstimationMethod(ebExp), numberOfDiscreteCategories(16), inferenceCatNum(16), userInputAlpha(0), userInputBeta(0), userInputTrTv(0) { //static struct option long_options[] = {{0, 0, 0, 0}}; int option_index = 0; int c=0; bool algo_set=false; out_f.open(outFile.c_str()); // default output file outPtr=&out_f; // default output file while (c >= 0) { #ifdef WIN32 c = getopt_long(argc, argv,"A:a:b:B:c:C:d:D:e:E:f:F:g:G:Hh?i:I:j:J:k:K:l:L:m:M:n:N:O:o:p:P:r:R:s:S:T:t:u:U:v:V:x:X:y:Y:z:Z:",NULL,&option_index); #else c = getopt(argc, argv,"A:a:b:B:c:C:d:D:e:E:f:F:g:G:Hh?i:I:j:J:k:K:l:L:m:M:n:N:O:o:p:P:r:R:s:S:T:t:u:U:v:V:x:X:y:Y:z:Z:"); #endif switch (c) { // tree file, seqfile case 'a':case 'A': referenceSeq=optarg; break; case 'b':case 'B': { switch (optarg[0]) { case 'g': case 'G': optimizeBranchLengths=mlAndAlphaBBL; break; case 'h': case 'H': optimizeBranchLengths=mlBBLUniform; break; case 'n': case 'N': optimizeBranchLengths=noBBL; break; case 'r': case 'R': optimizeBranchLengths=mlAndAlphaAndBetaBBL; break; default: optimizeBranchLengths=mlAndAlphaBBL; break; } } break; case 'c':case 'C': manyTreeFileInput=optarg; break; case 'd':case 'D': userInputAlpha=atof(optarg); break; case 'e':case 'E': userInputBeta=atof(optarg); break; case 'j':case 'J': userInputTrTv=atof(optarg);break; case 'f':case 'F': fileListingManySubstitutionMatrices=optarg; break; case 'h':case 'H': case '?': cout <<"rate4site version 3.0.0."<>d;exit (0); case 'i':case 'I': { switch (optarg[0]) { case 'b': case 'B': rateEstimationMethod=ebExp; break; case 'm': case 'M': rateEstimationMethod=mlRate; break; default: rateEstimationMethod=ebExp; break; } break; } case 'k':case 'K': numberOfDiscreteCategories=atoi(optarg); break; case 'n':case 'N': inferenceCatNum = atoi(optarg); break; case 'l':case 'L': logFile=optarg; break; case 'm':case 'M': { switch (optarg[0]) { case 'd': case 'D': modelName=day;alphabet_size=20; break; case 'j': case 'J': modelName=jtt;alphabet_size=20; break; case 'r': case 'R': modelName=rev;alphabet_size=20; break; case 'w': case 'W': modelName=wag;alphabet_size=20; break; case 'l': case 'L': modelName=lg;alphabet_size=20; break; case 'c': case 'C': modelName=cprev;alphabet_size=20; break; case 'a': case 'A': modelName=aajc;alphabet_size=20; break; case 'n': case 'N': modelName=nucjc;alphabet_size=4; break; case 'g': case 'G': modelName=nucgtr;alphabet_size=4; break; case 'h': case 'H': modelName=hky;alphabet_size=4; break; case 't': case 'T': modelName=tamura92;alphabet_size=4; break; //case 'q': case 'Q': modelName=customQ;alphabet_size=20; break; //case 'm': case 'M': modelName=manyQ;alphabet_size=20; break; default:modelName=jtt;alphabet_size=20; break; } } break; case 'o':case 'O': { out_f.close(); // closing the default outFile=optarg; out_f.open(outFile.c_str()); if (out_f == NULL) errorMsg::reportError(" unable to open output file for writing. "); outPtr=&out_f; }; break; case 'p':case 'P': spPositionFile=optarg; break; case 's':case 'S': seqfile=optarg; break; case 't':case 'T': treefile=optarg; break; case 'u':case 'U': treePositionFile=optarg; break; case 'v':case 'V': logValue=atoi(optarg); break; case 'x':case 'X': treeOutFile=optarg; break; case 'y':case 'Y': outFileNotNormalize=optarg; break; case 'z':case 'Z': { switch (optarg[0]) { case 'J': case 'j': treeSearchAlg=njJC; break; case 'n': case 'N': treeSearchAlg=njML; break; case 'O': case 'o': treeSearchAlg=njJCOLD; break; default:treeSearchAlg=njJC; break; } } break; } } } rate4site-3.0.0/src/rate4site/rate4site.cpp0000755011611301161130000011630112223673417015456 00000000000000/* rate4site - prediction of protein conservation weight based on a phylogenetic tree * Copyright (C) 2004: Mayrose, I., Graur, D. , Ben-Tal, N. , Pupko, T * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "rate4site.h" #include "errorMsg.h" #include "nucleotide.h" #include "amino.h" #include "sequenceContainer.h" #include "evaluateCharacterFreq.h" #include "uniDistribution.h" #include "gammaDistribution.h" #include "readDatMatrix.h" #include "chebyshevAccelerator.h" #include "nucJC.h" #include "aaJC.h" #include "gtrModel.h" #include "trivialAccelerator.h" #include "jcDistance.h" #include "distanceTable.h" #include "nj.h" #include "numRec.h" #include "checkcovFanctors.h" #include "someUtil.h" #include "likeDist.h" #include "fastStartTree.h" #include "checkcovFanctorsWithFactors.h" #include "bestAlpha.h" #include "siteSpecificRate.h" #include "likelihoodComputation.h" #include "recognizeFormat.h" #include "bblEM.h" #include "hky.h" #include "bestGtrModelParams.h" #include "tamura92.h" #include "evaluateCharacterFreq.h" #include "bestHKYparam.h" #include "bestTamura92param.h" #include "bblEM.h" #include #include #include #include #include #include //#ifdef unix //for process id //#include //#else //#include //#endif using namespace std; using namespace likelihoodComputation; //ofstream timingsF; int main(int argc, char* argv[]) { rate4site r4s(argc,argv); return 0; } rate4site::rate4site(int argc, char* argv[]) { //timingsF.open("timing.dat"); fillOptionsParameters(argc,argv); myLog::setLog(_options->logFile, _options->logValue); printProcessId(); printrate4siteInfo(cout); printOptionParameters(); getStartingSequenceData(); getStartingStochasticProcess();// must be b4 the tree! getStartingEvolTreeTopology(true);// without optimizing branch lengths getStartingBranchLengthsAndAlpha(); printOutputTree(); fillReferenceSequence(); removeGapPositionAccordingToTheReferenceSequence(); getAttributesAndValidateThatEverythingFits(); computeRate4site(); ofstream nonNormalizedOutStream(_options->outFileNotNormalize.c_str()); computeAveAndStd(); // put them in _ave, and _std print(nonNormalizedOutStream,_rate); nonNormalizedOutStream.close(); normalizeRates(); // change also the _ave, the _std the quantiles, etc. print(_options->out(),_normalizedRates); //timingsF.close(); } void rate4site::removeGapPositionAccordingToTheReferenceSequence(){ // we remove unknown and not gaps because we changed all gaps to unknown... _sc.removeUnknownPositionsAccordingToAReferenceSeq(_refSeq->name()); } void rate4site::print(ostream & out, const Vdouble & rate2print) { switch (_options->rateEstimationMethod){ case (rate4siteOptions::ebExp): printRatesBayes(out,rate2print); break; case (rate4siteOptions::mlRate): printRatesML(out,rate2print); break; } printAveAndStd(out); } void rate4site::computeAveAndStd(){ MDOUBLE sum = 0; MDOUBLE sumSqr=0.0; for (int i=0; i < _sc.seqLen(); ++i) { sum+=_rate[i]; sumSqr+=(_rate[i]*_rate[i]); } _ave = sum/_sc.seqLen(); _std= sumSqr-(sum*sum/_sc.seqLen()); _std /= (_sc.seqLen()-1.0); _std = sqrt(_std); if (((_ave<1e-9)) && (_ave>(-(1e-9)))) _ave=0; if ((_std>(1-(1e-9))) && (_std< (1.0+(1e-9)))) _std=1.0; } void rate4site::fillReferenceSequence(){ if (strcmp(_options->referenceSeq.c_str(),"non")==0) { _refSeq = &(_sc[0]); } else { int id1 = _sc.getId(_options->referenceSeq,true); _refSeq = (&_sc[id1]); } } rate4site::~rate4site() { delete _alph; for (int i=0; i < _spVec.size(); ++i) delete _spVec[i]; delete _options; } void rate4site::printrate4siteInfo(ostream& out) { out<treefile.size()>0) cout<<"tree file is: "<<_options->treefile<seqfile.size()>0) cout<<"seq file is: "<<_options->seqfile<outFile.size()>0) cout<<"output file is: "<<_options->outFile<referenceSeq.c_str(),"non")!=0) cout<<"reference sequence is: "<<_options->referenceSeq<rateEstimationMethod){ case (rate4siteOptions::ebExp): { cout<< "rate inference method is: empirical Bayesian estimate"<numberOfDiscreteCategories<< " discrete categories"<modelName){ case (rate4siteOptions::day): cout<< "probablistic_model is: DAY" <optimizeBranchLengths){ case (rate4siteOptions::noBBL): cout<<"branch lengths are not optimized"<seqfile == "") { errorMsg::reportError("Please give a sequence file name in the command line"); } ifstream in(_options->seqfile.c_str()); int alphabetSize = _options->alphabet_size; if (alphabetSize==4) _alph = new nucleotide; else if (alphabetSize == 20) _alph = new amino; else errorMsg::reportError("no such alphabet in function rate4site::getStartingSequenceData"); sequenceContainer original = recognizeFormat::read(in,_alph);; original.changeGaps2MissingData(); _sc = original; } // void makeSureTreeIsBiFurcatingAndUnrooted(); void rate4site::getStartingStochasticProcess() { if (_options->numberOfDiscreteCategories<1 || _options->numberOfDiscreteCategories>50) { errorMsg::reportError("number of discrete rate categories should be between 1 and 50"); } distribution *dist = NULL; switch (_options->rateEstimationMethod){ case (rate4siteOptions::mlRate): dist = new uniDistribution; break; case (rate4siteOptions::ebExp): if(_options->optimizeBranchLengths == rate4siteOptions::mlAndAlphaAndBetaBBL) dist = new generalGammaDistribution(1,1,_options->numberOfDiscreteCategories); else dist = new gammaDistribution(1,_options->numberOfDiscreteCategories); break; default: dist = new gammaDistribution(1,_options->numberOfDiscreteCategories); break; } replacementModel *probMod=NULL; pijAccelerator *pijAcc=NULL; MDOUBLE initTrTv = 2.0; // for HKY and Tamura92 models if (_options->userInputTrTv!=0) initTrTv=_options->userInputTrTv; MDOUBLE initTamura92Theta = 0.5; switch (_options->modelName){ case (rate4siteOptions::day): probMod=new pupAll(datMatrixHolder::dayhoff);pijAcc = new chebyshevAccelerator(probMod); break; case (rate4siteOptions::jtt): probMod=new pupAll(datMatrixHolder::jones); pijAcc = new chebyshevAccelerator(probMod); break; case (rate4siteOptions::rev): probMod=new pupAll(datMatrixHolder::mtREV24); pijAcc = new chebyshevAccelerator(probMod); break; case (rate4siteOptions::wag): probMod=new pupAll(datMatrixHolder::wag); pijAcc = new chebyshevAccelerator(probMod); break; case (rate4siteOptions::lg): probMod=new pupAll(datMatrixHolder::lg); pijAcc = new chebyshevAccelerator(probMod); break; case (rate4siteOptions::cprev): probMod=new pupAll(datMatrixHolder::cpREV45); pijAcc = new chebyshevAccelerator(probMod); break; case (rate4siteOptions::nucjc): probMod=new nucJC; pijAcc = new trivialAccelerator(probMod); break; case (rate4siteOptions::nucgtr):{ probMod=new gtrModel(evaluateCharacterFreq(_sc)); pijAcc = new trivialAccelerator(probMod); break; } case (rate4siteOptions::aajc): probMod=new aaJC; pijAcc = new trivialAccelerator(probMod); break; case (rate4siteOptions::hky): probMod=new hky(evaluateCharacterFreq(_sc),initTrTv); pijAcc = new trivialAccelerator(probMod); break; case (rate4siteOptions::tamura92): probMod=new tamura92(initTamura92Theta,initTrTv); pijAcc = new trivialAccelerator(probMod); break; //case (rate4siteOptions::customQ): // probMod=new pupAll(_options->userSubstitutionMatrixFile);pijAcc = new chebyshevAccelerator(probMod); break; default: errorMsg::reportError("this probablistic model is not yet available"); } _sp = new stochasticProcess(dist, pijAcc); if (probMod) delete probMod; if (pijAcc) delete pijAcc; if (dist) delete dist; } //if bCalcDistanceTable==true then always calculate the distance table void rate4site::getStartingEvolTreeTopology(bool bCalcDistanceTable){ time_t ltime1; time( <ime1 ); LOG(4,<<"get Starting Tree Topology"< vNames; if ((_options->treefile=="") || bCalcDistanceTable) { distanceMethod* pDm; switch (_options->treeSearchAlg){ case (rate4siteOptions::njJC): pDm = new jcDistance(); giveDistanceTable(pDm, _sc, disTab, vNames); //getStartingNJtreeNjJC(); break; case (rate4siteOptions::njJCOLD): pDm = new jcDistanceOLD(_options->alphabet_size); giveDistanceTable(pDm, _sc,disTab, vNames); //getStartingNJtreeNjJC_old(); break; case (rate4siteOptions::njML): { uniDistribution lUni; const pijAccelerator* lpijAcc = _sp->getPijAccelerator();// note this is just a copy of the pointer. stochasticProcess lsp(&lUni,lpijAcc); pDm = new likeDist(lsp,0.01); giveDistanceTable(pDm,_sc,disTab,vNames); //getStartingNJtreeNjMLdis(); } break; default: errorMsg::reportError("this tree search mode is not yet available"); } delete pDm; //calc distqance table statistics MDOUBLE low_bound = VERYBIG; MDOUBLE upper_bound = VERYSMALL; MDOUBLE sum = 0.0; int count = 0; for (int i = 0; i < disTab.size(); ++i){ for (int j = i+1; j < disTab[i].size(); ++j){ sum += disTab[i][j]; ++count; if (disTab[i][j] < low_bound) low_bound = disTab[i][j]; if (disTab[i][j] > upper_bound) upper_bound = disTab[i][j]; } } MDOUBLE avg = sum / static_cast(count); LOG(4,<<"#MSA diversity matrix"<treefile=="") { //take ditance table from above getStartingTreeNJ_fromDistances(disTab, vNames); } else getStartingTreeFromTreeFile(); LOG(4,<<"After Tree Topology"<(ltime2 - ltime1); //timingsF<<"time for tree topology = "<rateEstimationMethod == rate4siteOptions::mlRate) { if (_options->optimizeBranchLengths == rate4siteOptions::noBBL) { if (_options->modelName == rate4siteOptions::hky) { bestHkyParamFixedTree bhky(_et,_sc,*_sp,NULL,upperBoundHkyParam, epsilonForHkyParam); _likelihood = bhky.getBestL(); } else if (_options->modelName == rate4siteOptions::tamura92) { bestTamura92ParamFixedTree bt92(_et,_sc,*_sp,NULL,maxBBLIterations, epsilonForLikelihoodImprovement,epsilonForTamura92TrTv,epsilonForTamura92Theta,upperBoundTamura92TrTv); _likelihood = bt92.getBestL(); } else if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,false,false); _likelihood = bestGTR.getBestL(); } else{ _likelihood = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,*_sp); } } else if (_options->optimizeBranchLengths == rate4siteOptions::mlBBLUniform) { //FIND TREE WITHOUT ALPHA with an homogenoues model. Update uniDistribution lUni; const pijAccelerator* lpijAcc = _sp->getPijAccelerator();// note this is just a copy of the pointer. stochasticProcess lsp(&lUni,lpijAcc); if (_options->modelName == rate4siteOptions::hky) { bestHkyParamAndBBL bbl4(_et,_sc,lsp,NULL, upperBoundHkyParam, epsilonForHkyParam,epsilonForLikelihoodImprovement,maxBBLIterations, maxTotalAlphaBBLIterations); _likelihood = bbl4.getBestL(); } else if (_options->modelName == rate4siteOptions::tamura92) { bestTamura92ParamAndBBL bbl5(_et,_sc,*_sp,NULL,maxTotalAlphaBBLIterations, epsilonForLikelihoodImprovement,epsilonForTamura92TrTv,epsilonForTamura92Theta,epsilonForAlpha,epsilonForBBL, maxBBLIterations); _likelihood = bbl5.getBestL(); } else if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,true,false); _likelihood = bestGTR.getBestL(); } else{//old implementation is with *_sp, itay's new implementation (below) is with lsp bblEM bblEM1(_et, _sc, lsp, NULL, maxBBLIterations , epsilonForBBL, epsilonForBBL); _likelihood = bblEM1.getTreeLikelihood(); } } else { // Here we want to optimize branch lengths with a gamma model, // but sp is with a homogenoues model. Hence, we have to create a local // copy of a gamma stochastic process. if (_options->userInputAlpha != 0) intitalAlpha = _options->userInputAlpha; gammaDistribution localDist(intitalAlpha,_options->numberOfDiscreteCategories); stochasticProcess localSP(&localDist,_sp->getPijAccelerator()); if (_options->userInputAlpha == 0) { // in this case we have to optimize both the alpha and the branch lengths if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,localSP,NULL); _likelihood = bestGTR.getBestL(); } else{ bestAlphaAndBBL bbl1(_et, _sc, localSP, NULL, intitalAlpha, upperBoundAlpha, epsilonForAlpha, epsilonForBBL, maxBBLIterations, maxTotalAlphaBBLIterations); _likelihood = bbl1.getBestL(); } } else { // in this case we know the alpa, and we want to just optimize branch lengths with this alpha if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,localSP,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,true,false); _likelihood = bestGTR.getBestL(); } else{ bblEM bbl(_et, _sc, localSP, NULL, maxBBLIterations, epsilonForBBL, epsilonForBBL); _likelihood = bbl.getTreeLikelihood(); } } } } else { // method for inference is Bayesian if (_options->optimizeBranchLengths == rate4siteOptions::noBBL) { //FIND BEST ALPHA, AND RETURN WITHOUT CHANING THE TREE if (_options->userInputAlpha == 0){ if (_options->modelName == rate4siteOptions::hky) { bestHkyParamFixedTree bhky(_et,_sc,*_sp,NULL,upperBoundHkyParam, epsilonForHkyParam); _likelihood = bhky.getBestL(); } else if (_options->modelName == rate4siteOptions::tamura92) { bestTamura92ParamFixedTree bt92(_et,_sc,*_sp,NULL,maxBBLIterations, epsilonForLikelihoodImprovement,epsilonForTamura92TrTv,epsilonForTamura92Theta,upperBoundTamura92TrTv); _likelihood = bt92.getBestL(); } else if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,false,true); _likelihood = bestGTR.getBestL(); } else{ bestAlphaFixedTree bbl2(_et, _sc, *_sp, NULL, upperBoundAlpha, epsilonForAlpha); _likelihood = bbl2.getBestL(); } } else {// in this case we just want to set the alpha to the right one static_cast(_sp->distr())->setAlpha(_options->userInputAlpha); if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,false,false); _likelihood = bestGTR.getBestL(); } else{ _likelihood = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,*_sp); } } } else if (_options->optimizeBranchLengths == rate4siteOptions::mlBBLUniform) { //FIND TREE WITHOUT ALPHA with an homogenoues model. Update uniDistribution lUni; const pijAccelerator* lpijAcc = _sp->getPijAccelerator();// note this is just a copy of the pointer. stochasticProcess lsp(&lUni,lpijAcc); if (_options->modelName == rate4siteOptions::hky) { bestHkyParamAndBBL bbl4(_et,_sc,lsp,NULL, upperBoundHkyParam, epsilonForHkyParam,epsilonForLikelihoodImprovement,maxBBLIterations, maxTotalAlphaBBLIterations); _likelihood = bbl4.getBestL(); } else if (_options->modelName == rate4siteOptions::tamura92) { bestTamura92ParamAndBBL bbl5(_et,_sc,*_sp,NULL,maxTotalAlphaBBLIterations, epsilonForLikelihoodImprovement,epsilonForTamura92TrTv,epsilonForTamura92Theta,epsilonForAlpha,epsilonForBBL, maxBBLIterations); _likelihood = bbl5.getBestL(); } else if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,lsp,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,true,false); _likelihood = bestGTR.getBestL(); } else //this is itay's code { bblEM bbl(_et, _sc, lsp, NULL, maxBBLIterations, epsilonForBBL, epsilonForAlpha); _likelihood = bbl.getTreeLikelihood(); } //THEN FIND ALPHA WITHOUT OPT TREE if (_options->userInputAlpha == 0){ if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,false,true); _likelihood = bestGTR.getBestL(); } else{ bestAlphaFixedTree bbl3(_et,_sc,*_sp, NULL, upperBoundAlpha, epsilonForAlpha); _likelihood = bbl3.getBestL(); } } else { static_cast(_sp->distr())->setAlpha(_options->userInputAlpha); if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL); _likelihood = bestGTR.getBestL(); } else{ _likelihood = likelihoodComputation::getTreeLikelihoodAllPosAlphTheSame(_et,_sc,*_sp); } } } else if(_options->optimizeBranchLengths == rate4siteOptions::mlAndAlphaBBL) { //ML OPT WITH GAMMA if (_options->userInputAlpha == 0){ if (_options->modelName == rate4siteOptions::hky) { bestHkyParamAlphaAndBBL bbl4(_et,_sc,*_sp,NULL,maxTotalAlphaBBLIterations, epsilonForLikelihoodImprovement,epsilonForHkyParam,epsilonForAlpha,epsilonForBBL, upperBoundHkyParam,maxBBLIterations,intitalAlpha,upperBoundAlpha); _likelihood = bbl4.getBestL(); } else if (_options->modelName == rate4siteOptions::tamura92) { bestTamura92ParamAlphaAndBBL bbl5(_et,_sc,*_sp,NULL,maxTotalAlphaBBLIterations, epsilonForLikelihoodImprovement,epsilonForTamura92TrTv,epsilonForTamura92Theta, epsilonForAlpha,epsilonForBBL,upperBoundTamura92TrTv, maxBBLIterations,intitalAlpha,upperBoundAlpha); _likelihood = bbl5.getBestL(); } else if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL); _likelihood = bestGTR.getBestL(); } else { bestAlphaAndBBL bbl1(_et, _sc, *_sp, NULL, intitalAlpha, upperBoundAlpha, epsilonForAlpha, epsilonForBBL, maxBBLIterations, maxTotalAlphaBBLIterations); _likelihood = bbl1.getBestL(); } } else {// alpha is known static_cast(_sp->distr())->setAlpha(_options->userInputAlpha); if(_options->modelName == rate4siteOptions::nucgtr){ bestGtrModel bestGTR(_et,_sc,*_sp,NULL,maxBBLIterations,epsilonForBBL,epsilonForBBL,upperBoundAlpha,true,false); _likelihood = bestGTR.getBestL(); } else{ bblEM bbl(_et, _sc, *_sp, NULL, maxBBLIterations, epsilonForBBL, epsilonForBBL); _likelihood = bbl.getTreeLikelihood(); } } } else if(_options->optimizeBranchLengths == rate4siteOptions::mlAndAlphaAndBetaBBL) { //ML OPT WITH GENERAL GAMMA (optimizing alpha and beta) if ((_options->userInputAlpha == 0)&&(_options->userInputBeta == 0)){ bestAlphaAndBetaAndBBL bbl1(_et,_sc,*_sp,NULL,intitalAlpha,intitalBeta,upperBoundAlpha,upperBoundBeta,epsilonForAlpha,epsilonForBeta,epsilonForBBL,maxBBLIterations,maxTotalAlphaBBLIterations); _likelihood = bbl1.getBestL(); } else if ((_options->userInputAlpha == 0)&&(_options->userInputBeta != 0)){ bestAlphaAndBBL bbl2(_et, _sc, *_sp, NULL, intitalAlpha, upperBoundAlpha, epsilonForAlpha, epsilonForBBL, maxBBLIterations, maxTotalAlphaBBLIterations); _likelihood = bbl2.getBestL(); } else if ((_options->userInputAlpha != 0)&&(_options->userInputBeta == 0)){ bestBetaAndBBL bbl3(_et, _sc, *_sp, NULL, intitalBeta, upperBoundBeta, epsilonForBeta, epsilonForBBL, maxBBLIterations, maxTotalAlphaBBLIterations); _likelihood = bbl3.getBestL(); } else{ static_cast(_sp->distr())->setAlpha(_options->userInputAlpha); static_cast(_sp->distr())->setBeta(_options->userInputBeta); bblEM bbl(_et, _sc, *_sp, NULL, maxBBLIterations, epsilonForBBL, epsilonForBBL); _likelihood = bbl.getTreeLikelihood(); } } } LOG(4,<<"After Branch Lengths And Alpha"<(ltime2 - ltime1); //timingsF<<"time for alpha and branch lengths optimization = "< vNames; giveDistanceTable(&pd1, _sc, disTab, vNames); getStartingTreeNJ_fromDistances(disTab,vNames); } void rate4site::getStartingNJtreeNjJC_old() { jcDistanceOLD pd1(_options->alphabet_size); VVdouble disTab; vector vNames; giveDistanceTable(&pd1, _sc, disTab, vNames); getStartingTreeNJ_fromDistances(disTab,vNames); } void rate4site::getStartingNJtreeNjMLdis() { // note that here ALWAYS, the ML distances are computed using // an homogenous rate distribution. uniDistribution lUni; const pijAccelerator* lpijAcc = _sp->getPijAccelerator();// note this is just a copy of the pointer. stochasticProcess lsp(&lUni,lpijAcc); likeDist pd1(lsp,0.01); VVdouble disTab; vector vNames; giveDistanceTable(&pd1, _sc, disTab, vNames); getStartingTreeNJ_fromDistances(disTab,vNames); } void rate4site::getStartingMLtreeFromManyNJtrees() { int numOfNJtrees = 30; if (_sc.numberOfSeqs() <4) numOfNJtrees = 1; else if (_sc.numberOfSeqs() <5) numOfNJtrees = 3; else if (_sc.numberOfSeqs() <6) numOfNJtrees = 15; else if (_sc.numberOfSeqs() <30) numOfNJtrees = 75; else if (_sc.numberOfSeqs() <50) numOfNJtrees = 15; else numOfNJtrees = 5; const MDOUBLE tmpForStartingTreeSearch = 1; const MDOUBLE epslionWeights = 0.05; _et = getBestMLTreeFromManyNJtrees(_sc, *_sp, numOfNJtrees, tmpForStartingTreeSearch, epslionWeights, cerr); cerr<<"number of tree evaluated: "<treeOutFile; f.open(fileName1.c_str()); _et.output(f); f.close(); cout<<"The tree was written to a file name called "<& vNames) { NJalg nj1; _et= nj1.computeTree(disTab,vNames); ofstream f; string fileName1=_options->treeOutFile; f.open(fileName1.c_str()); _et.output(f); f.close(); } void rate4site::getStartingTreeFromTreeFile(){ _et= tree(_options->treefile); if (!_et.withBranchLength()) _et.createFlatLengthMatrix(0.05); } void rate4site::computeRate4site(){ time_t ltime1; time( <ime1 ); LOG(4,<<"computing the rates"<rateEstimationMethod == rate4siteOptions::ebExp) { compute_EB_EXP_Rate4site(); } else if (_options->rateEstimationMethod == rate4siteOptions::mlRate) { compute_ML_Rate4site(); } else errorMsg::reportError("non such method for rate inference, in function void rate4site::computeRate4site()"); LOG(4,<<"After computing the rates"<(ltime2 - ltime1); //timingsF<<"time for rates calculations= "< 0) { // many trees if (_spVec.size()>0) { computeML_siteSpecificRate(_rate,_Lrate,_spAtributes,_etAtributes,_etVec,_spVec,_sc,maxRate,tol); } else { computeML_siteSpecificRate(_rate,_Lrate,_etAtributes,_etVec,*_sp,_sc,maxRate,tol); } } else {// one tree if (_spVec.size()>0) { computeML_siteSpecificRate(_rate,_Lrate,_spAtributes,_et,_spVec,_sc,maxRate,tol); } else { computeML_siteSpecificRate(_rate,_Lrate,_sc,*_sp,_et,maxRate,tol); } } } void rate4site::compute_EB_EXP_Rate4site(){ if (_etVec.size() > 0) { // many trees if (_spVec.size()>0) { computeEB_EXP_siteSpecificRate(_rate,_BayesianSTD,_BayesianLowerBound,_BayesianUpperBound,_spAtributes,_etAtributes,_sc,_etVec,_spVec,_alphaConf); } else {// MANY TREES, 1 SP computeEB_EXP_siteSpecificRate(_rate,_BayesianSTD,_BayesianLowerBound,_BayesianUpperBound,_etAtributes,_sc,_etVec,*_sp,_alphaConf); } } else {// one tree if (_spVec.size()>0) {// many sp computeEB_EXP_siteSpecificRate(_rate,_BayesianSTD,_BayesianLowerBound,_BayesianUpperBound,_spAtributes,_sc,_et,_spVec,_alphaConf); } else {//1 tree 1 sp int inferenceCatNum = _options->inferenceCatNum; _sp->distr()->change_number_of_categories(inferenceCatNum); computeEB_EXP_siteSpecificRate(_rate,_BayesianSTD,_BayesianLowerBound,_BayesianUpperBound,_sc,*_sp,_et,_alphaConf); } } } void rate4site::normalizeRates() { int i=0; if (_std==0) errorMsg::reportError(" std = 0 in function normalizeRates",1); _normalizedRates.resize(_sc.seqLen(),0.0); for (i=0;i<_normalizedRates.size();++i) { _normalizedRates[i]=(_rate[i]-_ave)/_std; } if (_options->rateEstimationMethod == rate4siteOptions::ebExp) { for (int k=0; k < _sc.seqLen(); ++k) { _BayesianUpperBound[k] = (_BayesianUpperBound[k] - _ave)/_std; _BayesianLowerBound[k] = (_BayesianLowerBound[k] - _ave)/_std; _BayesianSTD[k] = (_BayesianSTD[k])/_std; } } _ave = 0.0; _std = 1.0; } void rate4site::printRatesML(ostream& out, const Vdouble & rate2print) { out<<"#Rates were calculated using Maximim Likelihood"<getAlphabet()->fromInt((*_refSeq)[pos])<<" "; out<getAlphabet()->fromInt((*_refSeq)[pos]); out<numberOfDiscreteCategories<<" discrete categories"<(_sp->distr())->getAlpha()<getAlphabet()->fromInt((*_refSeq)[pos])<<" "; out<getAlphabet()->fromInt((*_refSeq)[pos]); out<treePositionFile=="")) return; // There are two types of attributes. One is a substitution matrix for each site // and the other one is a different tree for each site. // Here is what we do in case of different subs. matrices for each site. if (_options->spPositionFile!="") { // Creates the stochastic processes vector distribution *dist = _sp->distr(); pijAccelerator* pijAcc; vector vs; ifstream in(_options->fileListingManySubstitutionMatrices.c_str()); putFileIntoVectorStringArray(in,vs); in.close(); replacementModel *probMod=NULL; for (int i=0; i < vs.size(); ++i) { probMod=new pupAll(vs[i]); pijAcc = new chebyshevAccelerator(probMod); stochasticProcess* temp_sp = new stochasticProcess(dist, pijAcc); _spVec.push_back(temp_sp); if (probMod) delete probMod; if (pijAcc) delete pijAcc; } // Reads the stochastic process attributes ifstream in3; in3.open(_options->spPositionFile.c_str()); if (!in3) { errorMsg::reportError("can't open substitution matrices attributes file"); } int tmpI; int maxAttribute = 0; while (!in3.eof()) { in3>>tmpI; if (in3.fail()) break; _spAtributes.push_back(tmpI); if (tmpI > maxAttribute) maxAttribute = tmpI; } in3.close(); //check if the maximim sthochastic process attribute doesn't exceed the number of possible sthochastic processes if (_spVec.size()< maxAttribute) { errorMsg::reportError("There are more attributes than stochastic processes"); } //check if there is an attrute for every site if (_refSeq->seqLen() != _spAtributes.size()) { errorMsg::reportError("attributes size is different from the sequence length"); } }// end of updating vector of stochastic processes. // This part handles many trees if (_options->treePositionFile!="") { //read the trees ifstream in2; vector treeStrings; putFileIntoVectorStringArray(in2,treeStrings); in2.close(); for (int i=0; i < treeStrings.size();++i) { tree tmp(treeStrings[i]); if (!tmp.withBranchLength()) { tmp.createFlatLengthMatrix(0.05); } _etVec.push_back(tmp); } // Reads the trees attributes ifstream in4; in4.open(_options->treePositionFile.c_str()); if (!in4) { errorMsg::reportError("can't open trees attributes file"); } int tmpI; int maxAttribute = 0; while (!in4.eof()) { in4>>tmpI; if (in4.fail()) break; _etAtributes.push_back(tmpI); if (tmpI > maxAttribute) maxAttribute = tmpI; } in4.close(); //check if the maximim sthochastic process attribute doesn't exceed the number of possible sthochastic processes if (_etVec.size()< maxAttribute) { errorMsg::reportError("There are more attributes than trees"); } //check if there is a tree attrute for every site if (_refSeq->seqLen() != _etAtributes.size()) { errorMsg::reportError("tree attributes size is different from the sequence length"); } } } /* =pod =encoding utf8 =head1 NAME rate4site - detector of conserved amino-acid sites =head1 SYNOPSIS rate4site [OPTIONS] -s =head1 DESCRIPTION The rate of evolution is not constant among amino acid sites: some positions evolve slowly and are commonly referred to as "conserved", while others evolve rapidly and are referred to as "variable". The rate variations correspond to different levels of purifying selection acting on these sites. The purifying selection can be the result of geometrical constraints on the folding of the protein into its 3D structure, constraints at amino acid sites involved in enzymatic activity or in ligand binding or, alternatively, at amino acid sites that take part in protein-protein interactions. Rate4Site calculates the relative evolutionary rate at each site using a probabilistic-based evolutionary model. This allows taking into account the stochastic process underlying sequence evolution within protein families and the phylogenetic tree of the proteins in the family. The conservation score at a site corresponds to the site's evolutionary rate. =head1 METHODOLOGY The sole obligatory input to Rate4Site is an MSA file. The program then computes a phylogenetic tree that is consistent with the available MSA (the user can also input a pre-calculated tree). It then calculates the relative conservation score for each site in the MSA. This is carried out using either an empirical Bayesian method or a maximum likelihood method (Pupko et al., 2002). The differences between the two methods are explained in details in Mayrose et al (2004). =head1 REFERENCES =over =item Mayrose, I., Graur, D., Ben-Tal, N., and Pupko, T. 2004. Comparison of site-specific rate-inference methods: Bayesian methods are superior. Mol Biol Evol 21: 1781-1791. =back =head1 OPTIONS =over =item B<-s MSA_FILE> The input sequence file name. The following formats are supported: Mase, Molphy, Phylip, Clustal, Fasta =item -t The input tree file name (in Newick format) =item B<-o OUTPUT_FILE> The results output file =item -a Reference sequence name in the MSA. The conservation scores are printed based on the amino-acids in this sequence. =item -k The number of discrete Gamma categories =item -m Evolutionary model. The following amino-acids models are supported: DAY (-md), JTT (-mj), REV (-mr), aaJC (-ma), LG (-Ml), WAG (-Mw) . For nucleotides, the following models are supported: JC (-mn), HKY (-Mh), Tamura92 (-Mt), GTR (-Mg). =item -b Branch lengths optimization flag: -bn = no Branch lengths optimization -bh = optimization using a homogenous model (no among-site-rate-variation) -bg = optimization using a Gamma model =item -i Rate inference method flag: -Im = rates are inferred using the maximum likelihood method -Ib = rates are inferred using the empirical Bayes method =item -z Tree constructing method zj = Neighbor-joining tree with Jukes-Cantor distances zn = Neighbor-joining tree with maximum likelihood distances =item -h Short help message =back =head1 AUTHOR Nir Ben-Tal =head1 SEE ALSO =over =item Main website L =back =cut */