diff --git a/.gitignore b/.gitignore
index 810ab28..4fbb628 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,57 @@ src/scratch.c
src/RNAcode
stamp-h1
RNAcode*.tar.gz
+
+##### C
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/RNAcode.iml b/.idea/RNAcode.iml
new file mode 100644
index 0000000..bc2cd87
--- /dev/null
+++ b/.idea/RNAcode.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..0907017
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..38a4ad1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,829 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2017 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.
+
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/RNAcode
+pkgincludedir = $(includedir)/RNAcode
+pkglibdir = $(libdir)/RNAcode
+pkglibexecdir = $(libexecdir)/RNAcode
+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 = .
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+ $(am__configure_deps) $(am__DIST_COMMON)
+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 =
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-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 \
+ tags-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
+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)$(docudir)"
+DATA = $(docu_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ cscope distdir dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+ $(LISP)config.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
+ COPYING ChangeLog INSTALL NEWS README compile depcomp \
+ install-sh missing
+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__post_remove_distdir = $(am__remove_distdir)
+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
+DIST_TARGETS = dist-gzip
+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 = ${SHELL} /home/work/projects/RNAcode/missing aclocal-1.15
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AUTOCONF = ${SHELL} /home/work/projects/RNAcode/missing autoconf
+AUTOHEADER = ${SHELL} /home/work/projects/RNAcode/missing autoheader
+AUTOMAKE = ${SHELL} /home/work/projects/RNAcode/missing automake-1.15
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+CPP = gcc -E
+CPPFLAGS =
+CXX = g++
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /bin/grep -E
+EXEEXT =
+GREP = /bin/grep
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+ISODATE = 2020-08-24
+LDFLAGS =
+LIBOBJS =
+LIBS =
+LTLIBOBJS =
+MAKEINFO = ${SHELL} /home/work/projects/RNAcode/missing makeinfo
+MKDIR_P = /bin/mkdir -p
+OBJEXT = o
+PACKAGE = RNAcode
+PACKAGE_BUGREPORT = wash@mit.edu
+PACKAGE_NAME = RNAcode
+PACKAGE_STRING = RNAcode 0.3
+PACKAGE_TARNAME = RNAcode
+PACKAGE_URL =
+PACKAGE_VERSION = 0.3
+PATH_SEPARATOR = :
+RANLIB = ranlib
+SET_MAKE =
+SHELL = /bin/bash
+STRIP =
+VERSION = 0.3
+abs_builddir = /home/work/projects/RNAcode
+abs_srcdir = /home/work/projects/RNAcode
+abs_top_builddir = /home/work/projects/RNAcode
+abs_top_srcdir = /home/work/projects/RNAcode
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
+bindir = ${exec_prefix}/bin
+build_alias =
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host_alias =
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/work/projects/RNAcode/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+runstatedir = ${localstatedir}/run
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix =
+top_builddir = .
+top_srcdir = .
+SUBDIRS = phyml levmar seqgen librna src examples
+docu_DATA = INSTALL README AUTHORS COPYING
+EXTRA_DIST = INSTALL README AUTHORS COPYING manual.pdf color-legend.pdf
+docudir = $(pkgdatadir)
+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
+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
+ @test -f $@ || rm -f stamp-h1
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
+
+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
+install-docuDATA: $(docu_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(docu_DATA)'; test -n "$(docudir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(docudir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(docudir)" || 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_DATA) $$files '$(DESTDIR)$(docudir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(docudir)" || exit $$?; \
+ done
+
+uninstall-docuDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(docu_DATA)'; test -n "$(docudir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(docudir)'; $(am__uninstall_files_from_dir)
+
+# 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.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ 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"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ 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; \
+ $(am__define_uniq_tagged_files); \
+ 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-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscope: cscope.files
+ test ! -s cscope.files \
+ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+ -rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+ -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+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) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
+ $(am__post_remove_distdir)
+
+dist-bzip2: distdir
+ tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+ $(am__post_remove_distdir)
+
+dist-lzip: distdir
+ tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+ $(am__post_remove_distdir)
+
+dist-xz: distdir
+ tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+ $(am__post_remove_distdir)
+
+dist-tarZ: distdir
+ @echo WARNING: "Support for distribution archives compressed with" \
+ "legacy program 'compress' is deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ $(am__post_remove_distdir)
+
+dist-shar: distdir
+ @echo WARNING: "Support for shar distribution archives is" \
+ "deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
+ $(am__post_remove_distdir)
+
+dist-zip: distdir
+ -rm -f $(distdir).zip
+ zip -rq $(distdir).zip $(distdir)
+ $(am__post_remove_distdir)
+
+dist dist-all:
+ $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+ $(am__post_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*) \
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
+ *.tar.bz2*) \
+ bzip2 -dc $(distdir).tar.bz2 | $(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*) \
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
+ *.zip*) \
+ unzip $(distdir).zip ;;\
+ esac
+ chmod -R a-w $(distdir)
+ chmod u+w $(distdir)
+ mkdir $(distdir)/_build $(distdir)/_build/sub $(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/sub \
+ && ../../configure \
+ $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ --srcdir=../.. --prefix="$$dc_install_base" \
+ && $(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__post_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 $(DATA) config.h
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(docudir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+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-docuDATA
+
+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: uninstall-docuDATA
+
+.MAKE: $(am__recursive_targets) all install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+ am--refresh check check-am clean clean-cscope clean-generic \
+ cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
+ dist-gzip dist-lzip 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-docuDATA 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-am uninstall uninstall-am uninstall-docuDATA
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..7a91e9c
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,837 @@
+# Makefile.in generated by automake 1.16.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2020 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__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+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 = .
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+ $(am__configure_deps) $(am__DIST_COMMON)
+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 =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-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 \
+ tags-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
+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)$(docudir)"
+DATA = $(docu_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ cscope distdir distdir-am dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
+ config.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
+ COPYING ChangeLog INSTALL NEWS README compile config.guess \
+ config.sub depcomp install-sh missing
+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__post_remove_distdir = $(am__remove_distdir)
+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
+DIST_TARGETS = dist-gzip
+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@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+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@
+ISODATE = @ISODATE@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+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 = phyml/src levmar seqgen librna src examples
+docu_DATA = INSTALL README AUTHORS COPYING
+EXTRA_DIST = INSTALL README AUTHORS COPYING manual.pdf color-legend.pdf
+docudir = $(pkgdatadir)
+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
+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__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
+ 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
+ @test -f $@ || rm -f stamp-h1
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
+
+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
+install-docuDATA: $(docu_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(docu_DATA)'; test -n "$(docudir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(docudir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(docudir)" || 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_DATA) $$files '$(DESTDIR)$(docudir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(docudir)" || exit $$?; \
+ done
+
+uninstall-docuDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(docu_DATA)'; test -n "$(docudir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(docudir)'; $(am__uninstall_files_from_dir)
+
+# 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.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ 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"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ 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; \
+ $(am__define_uniq_tagged_files); \
+ 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-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscope: cscope.files
+ test ! -s cscope.files \
+ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+ -rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+ -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(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) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
+ $(am__post_remove_distdir)
+
+dist-bzip2: distdir
+ tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+ $(am__post_remove_distdir)
+
+dist-lzip: distdir
+ tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+ $(am__post_remove_distdir)
+
+dist-xz: distdir
+ tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+ $(am__post_remove_distdir)
+
+dist-zstd: distdir
+ tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
+ $(am__post_remove_distdir)
+
+dist-tarZ: distdir
+ @echo WARNING: "Support for distribution archives compressed with" \
+ "legacy program 'compress' is deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ $(am__post_remove_distdir)
+
+dist-shar: distdir
+ @echo WARNING: "Support for shar distribution archives is" \
+ "deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
+ $(am__post_remove_distdir)
+
+dist-zip: distdir
+ -rm -f $(distdir).zip
+ zip -rq $(distdir).zip $(distdir)
+ $(am__post_remove_distdir)
+
+dist dist-all:
+ $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+ $(am__post_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*) \
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
+ *.tar.bz2*) \
+ bzip2 -dc $(distdir).tar.bz2 | $(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*) \
+ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
+ *.zip*) \
+ unzip $(distdir).zip ;;\
+ *.tar.zst*) \
+ zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
+ esac
+ chmod -R a-w $(distdir)
+ chmod u+w $(distdir)
+ mkdir $(distdir)/_build $(distdir)/_build/sub $(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/sub \
+ && ../../configure \
+ $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ --srcdir=../.. --prefix="$$dc_install_base" \
+ && $(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__post_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 $(DATA) config.h
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(docudir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+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-docuDATA
+
+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: uninstall-docuDATA
+
+.MAKE: $(am__recursive_targets) all install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+ am--refresh check check-am clean clean-cscope clean-generic \
+ cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
+ dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
+ dist-zstd 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-docuDATA 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-am uninstall uninstall-am uninstall-docuDATA
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/README b/README
index 74ce4c8..5444bce 100644
--- a/README
+++ b/README
@@ -21,6 +21,7 @@ coding potential together with an associated p-value.
You can compile and install RNAcode like this:
+# ./autogen.sh
# ./configure
# make
# make install (as root)
@@ -211,3 +212,12 @@ RNA (2011), in revision
==========
Stefan Washietl
+
+
+5. Changes from phyml version 1 to version 3
+============================================
+
+As the default parameters of phyml changed, the results may differ between both versions.
+To change the options for phyml, take a look at parameter in Read_Command_Line() in phyml/cl.c.
+
+
diff --git a/compile b/compile
new file mode 120000
index 0000000..80e119e
--- /dev/null
+++ b/compile
@@ -0,0 +1 @@
+/usr/share/automake-1.15/compile
\ No newline at end of file
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 0000000..0e9aac7
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,402 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# examples/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2017 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.
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/RNAcode
+pkgincludedir = $(includedir)/RNAcode
+pkglibdir = $(libdir)/RNAcode
+pkglibexecdir = $(libexecdir)/RNAcode
+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 = examples
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/work/projects/RNAcode/missing aclocal-1.15
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AUTOCONF = ${SHELL} /home/work/projects/RNAcode/missing autoconf
+AUTOHEADER = ${SHELL} /home/work/projects/RNAcode/missing autoheader
+AUTOMAKE = ${SHELL} /home/work/projects/RNAcode/missing automake-1.15
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+CPP = gcc -E
+CPPFLAGS =
+CXX = g++
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /bin/grep -E
+EXEEXT =
+GREP = /bin/grep
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+ISODATE = 2020-08-24
+LDFLAGS =
+LIBOBJS =
+LIBS =
+LTLIBOBJS =
+MAKEINFO = ${SHELL} /home/work/projects/RNAcode/missing makeinfo
+MKDIR_P = /bin/mkdir -p
+OBJEXT = o
+PACKAGE = RNAcode
+PACKAGE_BUGREPORT = wash@mit.edu
+PACKAGE_NAME = RNAcode
+PACKAGE_STRING = RNAcode 0.3
+PACKAGE_TARNAME = RNAcode
+PACKAGE_URL =
+PACKAGE_VERSION = 0.3
+PATH_SEPARATOR = :
+RANLIB = ranlib
+SET_MAKE =
+SHELL = /bin/bash
+STRIP =
+VERSION = 0.3
+abs_builddir = /home/work/projects/RNAcode/examples
+abs_srcdir = /home/work/projects/RNAcode/examples
+abs_top_builddir = /home/work/projects/RNAcode
+abs_top_srcdir = /home/work/projects/RNAcode
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
+bindir = ${exec_prefix}/bin
+build_alias =
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host_alias =
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/work/projects/RNAcode/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+runstatedir = ${localstatedir}/run
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../
+top_builddir = ..
+top_srcdir = ..
+EXTRA_DIST = coding.aln coding.maf genomic.maf genomic-preprocessed.maf noncoding.aln noncoding.maf
+all: all-am
+
+.SUFFIXES:
+$(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 examples/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu examples/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):
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+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
+installdirs:
+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 mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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 -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic cscopelist-am \
+ ctags-am distclean distclean-generic 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-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+ pdf-am ps ps-am tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/examples/Makefile.in b/examples/Makefile.in
new file mode 100644
index 0000000..9bf1811
--- /dev/null
+++ b/examples/Makefile.in
@@ -0,0 +1,402 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2017 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__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+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 = examples
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__DIST_COMMON = $(srcdir)/Makefile.in
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+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@
+ISODATE = @ISODATE@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+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@
+runstatedir = @runstatedir@
+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@
+EXTRA_DIST = coding.aln coding.maf genomic.maf genomic-preprocessed.maf noncoding.aln noncoding.maf
+all: all-am
+
+.SUFFIXES:
+$(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 examples/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu examples/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):
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+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
+installdirs:
+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 mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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 -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic cscopelist-am \
+ ctags-am distclean distclean-generic 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-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+ pdf-am ps ps-am tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/examples/coding.aln b/examples/coding.aln
index 5226be9..0ee5c6a 100644
--- a/examples/coding.aln
+++ b/examples/coding.aln
@@ -1,4 +1,4 @@
-CLUSTAL W(1.81) multiple sequence alignment
+CLUSTAL W(1.81) multiple sequence 8 137
ec_K12.chr_fwd/3401506-3401703 TGCAGGCGTTACTTTTAGAACAGCAGGACGGCAAAACTCTCGCATCAGTACA--GACTCT
diff --git a/examples/coding.aln_phyml_stats.txt b/examples/coding.aln_phyml_stats.txt
new file mode 100644
index 0000000..e69de29
diff --git a/examples/coding.aln_phyml_tree.txt b/examples/coding.aln_phyml_tree.txt
new file mode 100644
index 0000000..e69de29
diff --git a/examples/coding.maf_mc_stats.txt b/examples/coding.maf_mc_stats.txt
new file mode 100644
index 0000000..e69de29
diff --git a/examples/coding.maf_mc_tree.txt b/examples/coding.maf_mc_tree.txt
new file mode 100644
index 0000000..e69de29
diff --git a/examples/example.maf b/examples/example.maf
new file mode 100644
index 0000000..1c7cb98
--- /dev/null
+++ b/examples/example.maf
@@ -0,0 +1,24 @@
+##maf version=1 scoring=tba.v8
+# tba.v8 (((human chimp) baboon) (mouse rat))
+
+a score=23262.0
+s hg18.chr7 27578828 38 + 158545518 AAA-GGGAATGTTAACCAAATGA---ATTGTCTCTTACGGTG
+s panTro1.chr6 28741140 38 + 161576975 AAA-GGGAATGTTAACCAAATGA---ATTGTCTCTTACGGTG
+s baboon 116834 38 + 4622798 AAA-GGGAATGTTAACCAAATGA---GTTGTCTCTTATGGTG
+s mm4.chr6 53215344 38 + 151104725 -AATGGGAATGTTAAGCAAACGA---ATTGTCTCTCAGTGTG
+s rn3.chr4 81344243 40 + 187371129 -AA-GGGGATGCTAAGCCAATGAGTTGTTGTCTCTCAATGTG
+
+a score=5062.0
+s hg18.chr7 27699739 6 + 158545518 TAAAGA
+s panTro1.chr6 28862317 6 + 161576975 TAAAGA
+s baboon 241163 6 + 4622798 TAAAGA
+s mm4.chr6 53303881 6 + 151104725 TAAAGA
+s rn3.chr4 81444246 6 + 187371129 taagga
+
+a score=6636.0
+s hg18.chr7 27707221 13 + 158545518 gcagctgaaaaca
+s panTro1.chr6 28869787 13 + 161576975 gcagctgaaaaca
+s baboon 249182 13 + 4622798 gcagctgaaaaca
+s mm4.chr6 53310102 13 + 151104725 ACAGCTGAAAATA
+
+
diff --git a/levmar/Makefile b/levmar/Makefile
new file mode 100644
index 0000000..cfc7d4a
--- /dev/null
+++ b/levmar/Makefile
@@ -0,0 +1,540 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# levmar/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2017 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.
+
+
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/RNAcode
+pkgincludedir = $(includedir)/RNAcode
+pkglibdir = $(libdir)/RNAcode
+pkglibexecdir = $(libexecdir)/RNAcode
+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 = levmar
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_$(V))
+am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
+liblevmar_a_AR = $(AR) $(ARFLAGS)
+liblevmar_a_LIBADD =
+am_liblevmar_a_OBJECTS = Axb.$(OBJEXT) lmbc.$(OBJEXT) lm.$(OBJEXT) \
+ lmlec.$(OBJEXT) misc.$(OBJEXT)
+liblevmar_a_OBJECTS = $(am_liblevmar_a_OBJECTS)
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(liblevmar_a_SOURCES)
+DIST_SOURCES = $(liblevmar_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 = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/work/projects/RNAcode/missing aclocal-1.15
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AUTOCONF = ${SHELL} /home/work/projects/RNAcode/missing autoconf
+AUTOHEADER = ${SHELL} /home/work/projects/RNAcode/missing autoheader
+AUTOMAKE = ${SHELL} /home/work/projects/RNAcode/missing automake-1.15
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+CPP = gcc -E
+CPPFLAGS =
+CXX = g++
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /bin/grep -E
+EXEEXT =
+GREP = /bin/grep
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+ISODATE = 2020-08-24
+LDFLAGS =
+LIBOBJS =
+LIBS =
+LTLIBOBJS =
+MAKEINFO = ${SHELL} /home/work/projects/RNAcode/missing makeinfo
+MKDIR_P = /bin/mkdir -p
+OBJEXT = o
+PACKAGE = RNAcode
+PACKAGE_BUGREPORT = wash@mit.edu
+PACKAGE_NAME = RNAcode
+PACKAGE_STRING = RNAcode 0.3
+PACKAGE_TARNAME = RNAcode
+PACKAGE_URL =
+PACKAGE_VERSION = 0.3
+PATH_SEPARATOR = :
+RANLIB = ranlib
+SET_MAKE =
+SHELL = /bin/bash
+STRIP =
+VERSION = 0.3
+abs_builddir = /home/work/projects/RNAcode/levmar
+abs_srcdir = /home/work/projects/RNAcode/levmar
+abs_top_builddir = /home/work/projects/RNAcode
+abs_top_srcdir = /home/work/projects/RNAcode
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
+bindir = ${exec_prefix}/bin
+build_alias =
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host_alias =
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/work/projects/RNAcode/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+runstatedir = ${localstatedir}/run
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../
+top_builddir = ..
+top_srcdir = ..
+noinst_LIBRARIES = liblevmar.a
+liblevmar_a_SOURCES = Axb.c lmbc.c lm.c lmlec.c misc.c lm.h misc.h
+noinst_HEADERS = lm.h misc.h Axb_core.c lmbc_core.c lmlec_core.c misc_core.c lm_core.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .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 levmar/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu levmar/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):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+liblevmar.a: $(liblevmar_a_OBJECTS) $(liblevmar_a_DEPENDENCIES) $(EXTRA_liblevmar_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f liblevmar.a
+ $(AM_V_AR)$(liblevmar_a_AR) liblevmar.a $(liblevmar_a_OBJECTS) $(liblevmar_a_LIBADD)
+ $(AM_V_at)$(RANLIB) liblevmar.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/Axb.Po
+include ./$(DEPDIR)/lm.Po
+include ./$(DEPDIR)/lmbc.Po
+include ./$(DEPDIR)/lmlec.Po
+include ./$(DEPDIR)/misc.Po
+
+.c.o:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ 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-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+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:
+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-noinstLIBRARIES 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-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-noinstLIBRARIES cscopelist-am ctags ctags-am 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-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 tags-am uninstall \
+ uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/levmar/Makefile.in b/levmar/Makefile.in
new file mode 100644
index 0000000..a744a5c
--- /dev/null
+++ b/levmar/Makefile.in
@@ -0,0 +1,540 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2017 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__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+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 = levmar
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_@AM_V@)
+am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
+liblevmar_a_AR = $(AR) $(ARFLAGS)
+liblevmar_a_LIBADD =
+am_liblevmar_a_OBJECTS = Axb.$(OBJEXT) lmbc.$(OBJEXT) lm.$(OBJEXT) \
+ lmlec.$(OBJEXT) misc.$(OBJEXT)
+liblevmar_a_OBJECTS = $(am_liblevmar_a_OBJECTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(liblevmar_a_SOURCES)
+DIST_SOURCES = $(liblevmar_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 = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+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@
+ISODATE = @ISODATE@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+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@
+runstatedir = @runstatedir@
+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@
+noinst_LIBRARIES = liblevmar.a
+liblevmar_a_SOURCES = Axb.c lmbc.c lm.c lmlec.c misc.c lm.h misc.h
+noinst_HEADERS = lm.h misc.h Axb_core.c lmbc_core.c lmlec_core.c misc_core.c lm_core.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .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 levmar/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu levmar/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):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+liblevmar.a: $(liblevmar_a_OBJECTS) $(liblevmar_a_DEPENDENCIES) $(EXTRA_liblevmar_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f liblevmar.a
+ $(AM_V_AR)$(liblevmar_a_AR) liblevmar.a $(liblevmar_a_OBJECTS) $(liblevmar_a_LIBADD)
+ $(AM_V_at)$(RANLIB) liblevmar.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Axb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lmbc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lmlec.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ 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-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+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:
+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-noinstLIBRARIES 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-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-noinstLIBRARIES cscopelist-am ctags ctags-am 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-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 tags-am uninstall \
+ uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/librna/Makefile b/librna/Makefile
new file mode 100644
index 0000000..adfa227
--- /dev/null
+++ b/librna/Makefile
@@ -0,0 +1,552 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# librna/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2017 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.
+
+
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/RNAcode
+pkgincludedir = $(includedir)/RNAcode
+pkglibdir = $(libdir)/RNAcode
+pkglibexecdir = $(libexecdir)/RNAcode
+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 = librna
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_$(V))
+am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
+libRNA_a_AR = $(AR) $(ARFLAGS)
+libRNA_a_LIBADD =
+am_libRNA_a_OBJECTS = fold_vars.$(OBJEXT) read_epars.$(OBJEXT) \
+ energy_par.$(OBJEXT) utils.$(OBJEXT) fold.$(OBJEXT) \
+ params.$(OBJEXT) alifold.$(OBJEXT) PS_dot.$(OBJEXT) \
+ aln_util.$(OBJEXT) naview.$(OBJEXT)
+libRNA_a_OBJECTS = $(am_libRNA_a_OBJECTS)
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libRNA_a_SOURCES)
+DIST_SOURCES = $(libRNA_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 = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/work/projects/RNAcode/missing aclocal-1.15
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AUTOCONF = ${SHELL} /home/work/projects/RNAcode/missing autoconf
+AUTOHEADER = ${SHELL} /home/work/projects/RNAcode/missing autoheader
+AUTOMAKE = ${SHELL} /home/work/projects/RNAcode/missing automake-1.15
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+CPP = gcc -E
+CPPFLAGS =
+CXX = g++
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /bin/grep -E
+EXEEXT =
+GREP = /bin/grep
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+ISODATE = 2020-08-24
+LDFLAGS =
+LIBOBJS =
+LIBS =
+LTLIBOBJS =
+MAKEINFO = ${SHELL} /home/work/projects/RNAcode/missing makeinfo
+MKDIR_P = /bin/mkdir -p
+OBJEXT = o
+PACKAGE = RNAcode
+PACKAGE_BUGREPORT = wash@mit.edu
+PACKAGE_NAME = RNAcode
+PACKAGE_STRING = RNAcode 0.3
+PACKAGE_TARNAME = RNAcode
+PACKAGE_URL =
+PACKAGE_VERSION = 0.3
+PATH_SEPARATOR = :
+RANLIB = ranlib
+SET_MAKE =
+SHELL = /bin/bash
+STRIP =
+VERSION = 0.3
+abs_builddir = /home/work/projects/RNAcode/librna
+abs_srcdir = /home/work/projects/RNAcode/librna
+abs_top_builddir = /home/work/projects/RNAcode
+abs_top_srcdir = /home/work/projects/RNAcode
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
+bindir = ${exec_prefix}/bin
+build_alias =
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host_alias =
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/work/projects/RNAcode/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+runstatedir = ${localstatedir}/run
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../
+top_builddir = ..
+top_srcdir = ..
+noinst_LIBRARIES = libRNA.a
+libRNA_a_SOURCES = fold_vars.c read_epars.c \
+ energy_par.c utils.c fold.c params.c alifold.c PS_dot.c aln_util.c naview.c
+
+noinst_HEADERS = alifold.h energy_const.h fold.h\
+ intloops.h params.h utils.h energy_par.h fold_vars.h\
+ pair_mat.h PS_dot.h aln_util.h circfold.inc alicircfold.inc
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .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 librna/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu librna/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):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+libRNA.a: $(libRNA_a_OBJECTS) $(libRNA_a_DEPENDENCIES) $(EXTRA_libRNA_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libRNA.a
+ $(AM_V_AR)$(libRNA_a_AR) libRNA.a $(libRNA_a_OBJECTS) $(libRNA_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libRNA.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/PS_dot.Po
+include ./$(DEPDIR)/alifold.Po
+include ./$(DEPDIR)/aln_util.Po
+include ./$(DEPDIR)/energy_par.Po
+include ./$(DEPDIR)/fold.Po
+include ./$(DEPDIR)/fold_vars.Po
+include ./$(DEPDIR)/naview.Po
+include ./$(DEPDIR)/params.Po
+include ./$(DEPDIR)/read_epars.Po
+include ./$(DEPDIR)/utils.Po
+
+.c.o:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ 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-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+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:
+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-noinstLIBRARIES 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-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-noinstLIBRARIES cscopelist-am ctags ctags-am 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-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 tags-am uninstall \
+ uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/librna/Makefile.am b/librna/Makefile.am
index c10b1cb..5718629 100644
--- a/librna/Makefile.am
+++ b/librna/Makefile.am
@@ -5,5 +5,7 @@ libRNA_a_SOURCES = fold_vars.c read_epars.c \
noinst_HEADERS =alifold.h energy_const.h fold.h\
intloops.h params.h utils.h energy_par.h fold_vars.h\
- pair_mat.h PS_dot.h aln_util.h circfold.inc alicircfold.inc
-
+ pair_mat.h PS_dot.h aln_util.h circfold.inc alicircfold.inc
+
+all-local:
+ objcopy --weaken libRNA.a libRNA.a
diff --git a/librna/Makefile.in b/librna/Makefile.in
new file mode 100644
index 0000000..d2f0f53
--- /dev/null
+++ b/librna/Makefile.in
@@ -0,0 +1,552 @@
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2017 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__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+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 = librna
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_@AM_V@)
+am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
+libRNA_a_AR = $(AR) $(ARFLAGS)
+libRNA_a_LIBADD =
+am_libRNA_a_OBJECTS = fold_vars.$(OBJEXT) read_epars.$(OBJEXT) \
+ energy_par.$(OBJEXT) utils.$(OBJEXT) fold.$(OBJEXT) \
+ params.$(OBJEXT) alifold.$(OBJEXT) PS_dot.$(OBJEXT) \
+ aln_util.$(OBJEXT) naview.$(OBJEXT)
+libRNA_a_OBJECTS = $(am_libRNA_a_OBJECTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libRNA_a_SOURCES)
+DIST_SOURCES = $(libRNA_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 = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+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@
+ISODATE = @ISODATE@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+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@
+runstatedir = @runstatedir@
+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@
+noinst_LIBRARIES = libRNA.a
+libRNA_a_SOURCES = fold_vars.c read_epars.c \
+ energy_par.c utils.c fold.c params.c alifold.c PS_dot.c aln_util.c naview.c
+
+noinst_HEADERS = alifold.h energy_const.h fold.h\
+ intloops.h params.h utils.h energy_par.h fold_vars.h\
+ pair_mat.h PS_dot.h aln_util.h circfold.inc alicircfold.inc
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .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 librna/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu librna/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):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+libRNA.a: $(libRNA_a_OBJECTS) $(libRNA_a_DEPENDENCIES) $(EXTRA_libRNA_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libRNA.a
+ $(AM_V_AR)$(libRNA_a_AR) libRNA.a $(libRNA_a_OBJECTS) $(libRNA_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libRNA.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PS_dot.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alifold.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aln_util.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/energy_par.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fold.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fold_vars.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/naview.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/params.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read_epars.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ 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-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+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:
+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-noinstLIBRARIES 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-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-noinstLIBRARIES cscopelist-am ctags ctags-am 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-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 tags-am uninstall \
+ uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/phyml/.gitignore b/phyml/.gitignore
new file mode 100755
index 0000000..4baf71f
--- /dev/null
+++ b/phyml/.gitignore
@@ -0,0 +1,48 @@
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+Makefile.in
+config.guess*
+config.sub*
+config.h.in
+aclocal.m4
+compile
+configure
+depcomp
+install-sh
+missing
+autom4te.cache
+*~
+doc/html
+doc/latex
+\#*#
+ltmain.sh
+m4/*.m4
+*.orig
\ No newline at end of file
diff --git a/phyml/.travis.yml b/phyml/.travis.yml
new file mode 100644
index 0000000..7ba9236
--- /dev/null
+++ b/phyml/.travis.yml
@@ -0,0 +1,34 @@
+sudo: required
+cache: apt
+language: c
+
+os:
+ - linux
+ - osx
+
+compiler:
+ - gcc
+
+script:
+# build and install software into $HOME/local
+ - ./autogen.sh
+ - ./configure
+ - make
+ - sudo make install
+ - ./configure --enable-phyrex
+ - make clean
+ - make
+ - ./configure --enable-phytime
+ - make clean
+ - make
+
+# put the installed binary into the $PATH
+ - export PATH=$HOME/local/bin:$PATH
+
+# install testiphy
+ - cd
+ - git clone https://gitlab.com/testiphy/testiphy.git
+
+# run testiphy
+ - cd testiphy
+ - ./testiphy phyml
\ No newline at end of file
diff --git a/phyml/Makefile b/phyml/Makefile
new file mode 100644
index 0000000..5d4e9e5
--- /dev/null
+++ b/phyml/Makefile
@@ -0,0 +1,673 @@
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# phyml/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2018 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.
+
+
+
+
+
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/RNAcode
+pkgincludedir = $(includedir)/RNAcode
+pkglibdir = $(libdir)/RNAcode
+pkglibexecdir = $(libexecdir)/RNAcode
+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 = phyml
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_$(V))
+am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
+libPHYML_a_AR = $(AR) $(ARFLAGS)
+libPHYML_a_LIBADD =
+am_libPHYML_a_OBJECTS = alrt.$(OBJEXT) avx.$(OBJEXT) bionj.$(OBJEXT) \
+ cl.$(OBJEXT) draw.$(OBJEXT) free.$(OBJEXT) help.$(OBJEXT) \
+ interface.$(OBJEXT) io.$(OBJEXT) make.$(OBJEXT) mg.$(OBJEXT) \
+ models.$(OBJEXT) nexus.$(OBJEXT) pars.$(OBJEXT) \
+ rates.$(OBJEXT) simu.$(OBJEXT) sse.$(OBJEXT) tbe.$(OBJEXT) \
+ tiporder.$(OBJEXT) xml.$(OBJEXT) ancestral.$(OBJEXT) \
+ checkpoint.$(OBJEXT) date.$(OBJEXT) eigen.$(OBJEXT) \
+ init.$(OBJEXT) lk.$(OBJEXT) main.$(OBJEXT) mcmc.$(OBJEXT) \
+ mixt.$(OBJEXT) optimiz.$(OBJEXT) phyrex.$(OBJEXT) \
+ rwrapper.$(OBJEXT) spr.$(OBJEXT) stats.$(OBJEXT) \
+ times.$(OBJEXT) utilities.$(OBJEXT)
+libPHYML_a_OBJECTS = $(am_libPHYML_a_OBJECTS)
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/alrt.Po ./$(DEPDIR)/ancestral.Po \
+ ./$(DEPDIR)/avx.Po ./$(DEPDIR)/bionj.Po \
+ ./$(DEPDIR)/checkpoint.Po ./$(DEPDIR)/cl.Po \
+ ./$(DEPDIR)/date.Po ./$(DEPDIR)/draw.Po ./$(DEPDIR)/eigen.Po \
+ ./$(DEPDIR)/free.Po ./$(DEPDIR)/help.Po ./$(DEPDIR)/init.Po \
+ ./$(DEPDIR)/interface.Po ./$(DEPDIR)/io.Po ./$(DEPDIR)/lk.Po \
+ ./$(DEPDIR)/main.Po ./$(DEPDIR)/make.Po ./$(DEPDIR)/mcmc.Po \
+ ./$(DEPDIR)/mg.Po ./$(DEPDIR)/mixt.Po ./$(DEPDIR)/models.Po \
+ ./$(DEPDIR)/nexus.Po ./$(DEPDIR)/optimiz.Po \
+ ./$(DEPDIR)/pars.Po ./$(DEPDIR)/phyrex.Po ./$(DEPDIR)/rates.Po \
+ ./$(DEPDIR)/rwrapper.Po ./$(DEPDIR)/simu.Po ./$(DEPDIR)/spr.Po \
+ ./$(DEPDIR)/sse.Po ./$(DEPDIR)/stats.Po ./$(DEPDIR)/tbe.Po \
+ ./$(DEPDIR)/times.Po ./$(DEPDIR)/tiporder.Po \
+ ./$(DEPDIR)/utilities.Po ./$(DEPDIR)/xml.Po
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libPHYML_a_SOURCES)
+DIST_SOURCES = $(libPHYML_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 = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/work/projects/RNAcode/missing aclocal-1.16
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AUTOCONF = ${SHELL} /home/work/projects/RNAcode/missing autoconf
+AUTOHEADER = ${SHELL} /home/work/projects/RNAcode/missing autoheader
+AUTOMAKE = ${SHELL} /home/work/projects/RNAcode/missing automake-1.16
+AWK = gawk
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+CPP = gcc -E
+CPPFLAGS =
+CXX = g++
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /bin/grep -E
+EXEEXT =
+GREP = /bin/grep
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+ISODATE = 2020-09-22
+LDFLAGS =
+LIBOBJS =
+LIBS =
+LTLIBOBJS =
+MAKEINFO = ${SHELL} /home/work/projects/RNAcode/missing makeinfo
+MKDIR_P = /bin/mkdir -p
+OBJEXT = o
+PACKAGE = RNAcode
+PACKAGE_BUGREPORT = wash@mit.edu
+PACKAGE_NAME = RNAcode
+PACKAGE_STRING = RNAcode 0.3
+PACKAGE_TARNAME = RNAcode
+PACKAGE_URL =
+PACKAGE_VERSION = 0.3
+PATH_SEPARATOR = :
+RANLIB = ranlib
+SET_MAKE =
+SHELL = /bin/bash
+STRIP =
+VERSION = 0.3
+abs_builddir = /home/work/projects/RNAcode/phyml
+abs_srcdir = /home/work/projects/RNAcode/phyml
+abs_top_builddir = /home/work/projects/RNAcode
+abs_top_srcdir = /home/work/projects/RNAcode
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
+bindir = ${exec_prefix}/bin
+build_alias =
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+host_alias =
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/work/projects/RNAcode/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+runstatedir = ${localstatedir}/run
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../
+top_builddir = ..
+top_srcdir = ..
+noinst_LIBRARIES = libPHYML.a
+libPHYML_a_SOURCES = alrt.c avx.c bionj.c cl.c draw.c free.c help.c interface.c io.c make.c mg.c models.c nexus.c pars.c rates.c simu.c sse.c tbe.c tiporder.c xml.c ancestral.c checkpoint.c date.c eigen.c init.c lk.c main.c mcmc.c mixt.c optimiz.c phyrex.c rwrapper.c spr.c stats.c times.c utilities.c
+noinst_HEADERS = alrt.h avx.h bionj.h cl.h draw.h free.h help.h interface.h io.h m4.h mcmc.h mixt.h mpi_boot.h nexus.h pars.h rates.h simu.h sse.h tbe.h tiporder.h xml.h ancestral.h beagle_utils.h checkpoint.h date.h eigen.h geo.h init.h invitee.h lk.h make.h mg.h models.h mxml.h optimiz.h phyrex.h rwrapper.h spr.h stats.h times.h utilities.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .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 phyml/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu phyml/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__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ 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):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+libPHYML.a: $(libPHYML_a_OBJECTS) $(libPHYML_a_DEPENDENCIES) $(EXTRA_libPHYML_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libPHYML.a
+ $(AM_V_AR)$(libPHYML_a_AR) libPHYML.a $(libPHYML_a_OBJECTS) $(libPHYML_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libPHYML.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/alrt.Po # am--include-marker
+include ./$(DEPDIR)/ancestral.Po # am--include-marker
+include ./$(DEPDIR)/avx.Po # am--include-marker
+include ./$(DEPDIR)/bionj.Po # am--include-marker
+include ./$(DEPDIR)/checkpoint.Po # am--include-marker
+include ./$(DEPDIR)/cl.Po # am--include-marker
+include ./$(DEPDIR)/date.Po # am--include-marker
+include ./$(DEPDIR)/draw.Po # am--include-marker
+include ./$(DEPDIR)/eigen.Po # am--include-marker
+include ./$(DEPDIR)/free.Po # am--include-marker
+include ./$(DEPDIR)/help.Po # am--include-marker
+include ./$(DEPDIR)/init.Po # am--include-marker
+include ./$(DEPDIR)/interface.Po # am--include-marker
+include ./$(DEPDIR)/io.Po # am--include-marker
+include ./$(DEPDIR)/lk.Po # am--include-marker
+include ./$(DEPDIR)/main.Po # am--include-marker
+include ./$(DEPDIR)/make.Po # am--include-marker
+include ./$(DEPDIR)/mcmc.Po # am--include-marker
+include ./$(DEPDIR)/mg.Po # am--include-marker
+include ./$(DEPDIR)/mixt.Po # am--include-marker
+include ./$(DEPDIR)/models.Po # am--include-marker
+include ./$(DEPDIR)/nexus.Po # am--include-marker
+include ./$(DEPDIR)/optimiz.Po # am--include-marker
+include ./$(DEPDIR)/pars.Po # am--include-marker
+include ./$(DEPDIR)/phyrex.Po # am--include-marker
+include ./$(DEPDIR)/rates.Po # am--include-marker
+include ./$(DEPDIR)/rwrapper.Po # am--include-marker
+include ./$(DEPDIR)/simu.Po # am--include-marker
+include ./$(DEPDIR)/spr.Po # am--include-marker
+include ./$(DEPDIR)/sse.Po # am--include-marker
+include ./$(DEPDIR)/stats.Po # am--include-marker
+include ./$(DEPDIR)/tbe.Po # am--include-marker
+include ./$(DEPDIR)/times.Po # am--include-marker
+include ./$(DEPDIR)/tiporder.Po # am--include-marker
+include ./$(DEPDIR)/utilities.Po # am--include-marker
+include ./$(DEPDIR)/xml.Po # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ 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-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(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:
+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-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/alrt.Po
+ -rm -f ./$(DEPDIR)/ancestral.Po
+ -rm -f ./$(DEPDIR)/avx.Po
+ -rm -f ./$(DEPDIR)/bionj.Po
+ -rm -f ./$(DEPDIR)/checkpoint.Po
+ -rm -f ./$(DEPDIR)/cl.Po
+ -rm -f ./$(DEPDIR)/date.Po
+ -rm -f ./$(DEPDIR)/draw.Po
+ -rm -f ./$(DEPDIR)/eigen.Po
+ -rm -f ./$(DEPDIR)/free.Po
+ -rm -f ./$(DEPDIR)/help.Po
+ -rm -f ./$(DEPDIR)/init.Po
+ -rm -f ./$(DEPDIR)/interface.Po
+ -rm -f ./$(DEPDIR)/io.Po
+ -rm -f ./$(DEPDIR)/lk.Po
+ -rm -f ./$(DEPDIR)/main.Po
+ -rm -f ./$(DEPDIR)/make.Po
+ -rm -f ./$(DEPDIR)/mcmc.Po
+ -rm -f ./$(DEPDIR)/mg.Po
+ -rm -f ./$(DEPDIR)/mixt.Po
+ -rm -f ./$(DEPDIR)/models.Po
+ -rm -f ./$(DEPDIR)/nexus.Po
+ -rm -f ./$(DEPDIR)/optimiz.Po
+ -rm -f ./$(DEPDIR)/pars.Po
+ -rm -f ./$(DEPDIR)/phyrex.Po
+ -rm -f ./$(DEPDIR)/rates.Po
+ -rm -f ./$(DEPDIR)/rwrapper.Po
+ -rm -f ./$(DEPDIR)/simu.Po
+ -rm -f ./$(DEPDIR)/spr.Po
+ -rm -f ./$(DEPDIR)/sse.Po
+ -rm -f ./$(DEPDIR)/stats.Po
+ -rm -f ./$(DEPDIR)/tbe.Po
+ -rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tiporder.Po
+ -rm -f ./$(DEPDIR)/utilities.Po
+ -rm -f ./$(DEPDIR)/xml.Po
+ -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-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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 -f ./$(DEPDIR)/alrt.Po
+ -rm -f ./$(DEPDIR)/ancestral.Po
+ -rm -f ./$(DEPDIR)/avx.Po
+ -rm -f ./$(DEPDIR)/bionj.Po
+ -rm -f ./$(DEPDIR)/checkpoint.Po
+ -rm -f ./$(DEPDIR)/cl.Po
+ -rm -f ./$(DEPDIR)/date.Po
+ -rm -f ./$(DEPDIR)/draw.Po
+ -rm -f ./$(DEPDIR)/eigen.Po
+ -rm -f ./$(DEPDIR)/free.Po
+ -rm -f ./$(DEPDIR)/help.Po
+ -rm -f ./$(DEPDIR)/init.Po
+ -rm -f ./$(DEPDIR)/interface.Po
+ -rm -f ./$(DEPDIR)/io.Po
+ -rm -f ./$(DEPDIR)/lk.Po
+ -rm -f ./$(DEPDIR)/main.Po
+ -rm -f ./$(DEPDIR)/make.Po
+ -rm -f ./$(DEPDIR)/mcmc.Po
+ -rm -f ./$(DEPDIR)/mg.Po
+ -rm -f ./$(DEPDIR)/mixt.Po
+ -rm -f ./$(DEPDIR)/models.Po
+ -rm -f ./$(DEPDIR)/nexus.Po
+ -rm -f ./$(DEPDIR)/optimiz.Po
+ -rm -f ./$(DEPDIR)/pars.Po
+ -rm -f ./$(DEPDIR)/phyrex.Po
+ -rm -f ./$(DEPDIR)/rates.Po
+ -rm -f ./$(DEPDIR)/rwrapper.Po
+ -rm -f ./$(DEPDIR)/simu.Po
+ -rm -f ./$(DEPDIR)/spr.Po
+ -rm -f ./$(DEPDIR)/sse.Po
+ -rm -f ./$(DEPDIR)/stats.Po
+ -rm -f ./$(DEPDIR)/tbe.Po
+ -rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tiporder.Po
+ -rm -f ./$(DEPDIR)/utilities.Po
+ -rm -f ./$(DEPDIR)/xml.Po
+ -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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+ clean-generic clean-noinstLIBRARIES cscopelist-am ctags \
+ ctags-am 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-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 tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/phyml/Makefile.am b/phyml/Makefile.am
index 56ec660..0c41732 100644
--- a/phyml/Makefile.am
+++ b/phyml/Makefile.am
@@ -1,5 +1,7 @@
noinst_LIBRARIES = libPHYML.a
+
+libPHYML_a_SOURCES = alrt.c avx.c bionj.c cl.c draw.c free.c help.c interface.c io.c make.c mg.c models.c nexus.c pars.c rates.c simu.c sse.c tbe.c tiporder.c xml.c ancestral.c checkpoint.c date.c eigen.c init.c lk.c main.c mcmc.c mixt.c optimiz.c phyrex.c rwrapper.c spr.c stats.c times.c utilities.c
-libPHYML_a_SOURCES = alrt.c bionj.c cl.c draw.c eigen.c free.c interface.c lk.c m4.c main.c mc.c models.c optimiz.c options.c pars.c rates.c simu.c spr.c utilities.c
-noinst_HEADERS = alrt.h bionj.h cl.h draw.h eigen.h free.h interface.h lk.h m4.h mc.h models.h optimiz.h options.h pars.h rates.h simu.h spr.h utilities.h mg.h
+noinst_HEADERS = alrt.h avx.h bionj.h cl.h draw.h free.h help.h interface.h io.h m4.h mcmc.h mixt.h mpi_boot.h nexus.h pars.h rates.h simu.h sse.h tbe.h tiporder.h xml.h ancestral.h beagle_utils.h checkpoint.h date.h eigen.h geo.h init.h invitee.h lk.h make.h mg.h models.h mxml.h optimiz.h phyrex.h rwrapper.h spr.h stats.h times.h utilities.h
+
diff --git a/phyml/Makefile.in b/phyml/Makefile.in
new file mode 100644
index 0000000..0c565f9
--- /dev/null
+++ b/phyml/Makefile.in
@@ -0,0 +1,673 @@
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2018 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__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+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 = phyml
+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)
+DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
+ $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+AM_V_AR = $(am__v_AR_@AM_V@)
+am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
+am__v_AR_0 = @echo " AR " $@;
+am__v_AR_1 =
+libPHYML_a_AR = $(AR) $(ARFLAGS)
+libPHYML_a_LIBADD =
+am_libPHYML_a_OBJECTS = alrt.$(OBJEXT) avx.$(OBJEXT) bionj.$(OBJEXT) \
+ cl.$(OBJEXT) draw.$(OBJEXT) free.$(OBJEXT) help.$(OBJEXT) \
+ interface.$(OBJEXT) io.$(OBJEXT) make.$(OBJEXT) mg.$(OBJEXT) \
+ models.$(OBJEXT) nexus.$(OBJEXT) pars.$(OBJEXT) \
+ rates.$(OBJEXT) simu.$(OBJEXT) sse.$(OBJEXT) tbe.$(OBJEXT) \
+ tiporder.$(OBJEXT) xml.$(OBJEXT) ancestral.$(OBJEXT) \
+ checkpoint.$(OBJEXT) date.$(OBJEXT) eigen.$(OBJEXT) \
+ init.$(OBJEXT) lk.$(OBJEXT) main.$(OBJEXT) mcmc.$(OBJEXT) \
+ mixt.$(OBJEXT) optimiz.$(OBJEXT) phyrex.$(OBJEXT) \
+ rwrapper.$(OBJEXT) spr.$(OBJEXT) stats.$(OBJEXT) \
+ times.$(OBJEXT) utilities.$(OBJEXT)
+libPHYML_a_OBJECTS = $(am_libPHYML_a_OBJECTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/alrt.Po ./$(DEPDIR)/ancestral.Po \
+ ./$(DEPDIR)/avx.Po ./$(DEPDIR)/bionj.Po \
+ ./$(DEPDIR)/checkpoint.Po ./$(DEPDIR)/cl.Po \
+ ./$(DEPDIR)/date.Po ./$(DEPDIR)/draw.Po ./$(DEPDIR)/eigen.Po \
+ ./$(DEPDIR)/free.Po ./$(DEPDIR)/help.Po ./$(DEPDIR)/init.Po \
+ ./$(DEPDIR)/interface.Po ./$(DEPDIR)/io.Po ./$(DEPDIR)/lk.Po \
+ ./$(DEPDIR)/main.Po ./$(DEPDIR)/make.Po ./$(DEPDIR)/mcmc.Po \
+ ./$(DEPDIR)/mg.Po ./$(DEPDIR)/mixt.Po ./$(DEPDIR)/models.Po \
+ ./$(DEPDIR)/nexus.Po ./$(DEPDIR)/optimiz.Po \
+ ./$(DEPDIR)/pars.Po ./$(DEPDIR)/phyrex.Po ./$(DEPDIR)/rates.Po \
+ ./$(DEPDIR)/rwrapper.Po ./$(DEPDIR)/simu.Po ./$(DEPDIR)/spr.Po \
+ ./$(DEPDIR)/sse.Po ./$(DEPDIR)/stats.Po ./$(DEPDIR)/tbe.Po \
+ ./$(DEPDIR)/times.Po ./$(DEPDIR)/tiporder.Po \
+ ./$(DEPDIR)/utilities.Po ./$(DEPDIR)/xml.Po
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libPHYML_a_SOURCES)
+DIST_SOURCES = $(libPHYML_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 = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+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@
+ISODATE = @ISODATE@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+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@
+runstatedir = @runstatedir@
+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@
+noinst_LIBRARIES = libPHYML.a
+libPHYML_a_SOURCES = alrt.c avx.c bionj.c cl.c draw.c free.c help.c interface.c io.c make.c mg.c models.c nexus.c pars.c rates.c simu.c sse.c tbe.c tiporder.c xml.c ancestral.c checkpoint.c date.c eigen.c init.c lk.c main.c mcmc.c mixt.c optimiz.c phyrex.c rwrapper.c spr.c stats.c times.c utilities.c
+noinst_HEADERS = alrt.h avx.h bionj.h cl.h draw.h free.h help.h interface.h io.h m4.h mcmc.h mixt.h mpi_boot.h nexus.h pars.h rates.h simu.h sse.h tbe.h tiporder.h xml.h ancestral.h beagle_utils.h checkpoint.h date.h eigen.h geo.h init.h invitee.h lk.h make.h mg.h models.h mxml.h optimiz.h phyrex.h rwrapper.h spr.h stats.h times.h utilities.h
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .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 phyml/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu phyml/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__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ 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):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+libPHYML.a: $(libPHYML_a_OBJECTS) $(libPHYML_a_DEPENDENCIES) $(EXTRA_libPHYML_a_DEPENDENCIES)
+ $(AM_V_at)-rm -f libPHYML.a
+ $(AM_V_AR)$(libPHYML_a_AR) libPHYML.a $(libPHYML_a_OBJECTS) $(libPHYML_a_LIBADD)
+ $(AM_V_at)$(RANLIB) libPHYML.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alrt.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ancestral.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avx.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bionj.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpoint.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cl.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/date.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/draw.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/free.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lk.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/make.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mcmc.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mg.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mixt.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/models.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nexus.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimiz.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pars.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/phyrex.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rates.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rwrapper.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simu.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spr.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sse.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stats.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tbe.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/times.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tiporder.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utilities.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ 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-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ 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"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(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:
+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-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/alrt.Po
+ -rm -f ./$(DEPDIR)/ancestral.Po
+ -rm -f ./$(DEPDIR)/avx.Po
+ -rm -f ./$(DEPDIR)/bionj.Po
+ -rm -f ./$(DEPDIR)/checkpoint.Po
+ -rm -f ./$(DEPDIR)/cl.Po
+ -rm -f ./$(DEPDIR)/date.Po
+ -rm -f ./$(DEPDIR)/draw.Po
+ -rm -f ./$(DEPDIR)/eigen.Po
+ -rm -f ./$(DEPDIR)/free.Po
+ -rm -f ./$(DEPDIR)/help.Po
+ -rm -f ./$(DEPDIR)/init.Po
+ -rm -f ./$(DEPDIR)/interface.Po
+ -rm -f ./$(DEPDIR)/io.Po
+ -rm -f ./$(DEPDIR)/lk.Po
+ -rm -f ./$(DEPDIR)/main.Po
+ -rm -f ./$(DEPDIR)/make.Po
+ -rm -f ./$(DEPDIR)/mcmc.Po
+ -rm -f ./$(DEPDIR)/mg.Po
+ -rm -f ./$(DEPDIR)/mixt.Po
+ -rm -f ./$(DEPDIR)/models.Po
+ -rm -f ./$(DEPDIR)/nexus.Po
+ -rm -f ./$(DEPDIR)/optimiz.Po
+ -rm -f ./$(DEPDIR)/pars.Po
+ -rm -f ./$(DEPDIR)/phyrex.Po
+ -rm -f ./$(DEPDIR)/rates.Po
+ -rm -f ./$(DEPDIR)/rwrapper.Po
+ -rm -f ./$(DEPDIR)/simu.Po
+ -rm -f ./$(DEPDIR)/spr.Po
+ -rm -f ./$(DEPDIR)/sse.Po
+ -rm -f ./$(DEPDIR)/stats.Po
+ -rm -f ./$(DEPDIR)/tbe.Po
+ -rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tiporder.Po
+ -rm -f ./$(DEPDIR)/utilities.Po
+ -rm -f ./$(DEPDIR)/xml.Po
+ -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-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+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 -f ./$(DEPDIR)/alrt.Po
+ -rm -f ./$(DEPDIR)/ancestral.Po
+ -rm -f ./$(DEPDIR)/avx.Po
+ -rm -f ./$(DEPDIR)/bionj.Po
+ -rm -f ./$(DEPDIR)/checkpoint.Po
+ -rm -f ./$(DEPDIR)/cl.Po
+ -rm -f ./$(DEPDIR)/date.Po
+ -rm -f ./$(DEPDIR)/draw.Po
+ -rm -f ./$(DEPDIR)/eigen.Po
+ -rm -f ./$(DEPDIR)/free.Po
+ -rm -f ./$(DEPDIR)/help.Po
+ -rm -f ./$(DEPDIR)/init.Po
+ -rm -f ./$(DEPDIR)/interface.Po
+ -rm -f ./$(DEPDIR)/io.Po
+ -rm -f ./$(DEPDIR)/lk.Po
+ -rm -f ./$(DEPDIR)/main.Po
+ -rm -f ./$(DEPDIR)/make.Po
+ -rm -f ./$(DEPDIR)/mcmc.Po
+ -rm -f ./$(DEPDIR)/mg.Po
+ -rm -f ./$(DEPDIR)/mixt.Po
+ -rm -f ./$(DEPDIR)/models.Po
+ -rm -f ./$(DEPDIR)/nexus.Po
+ -rm -f ./$(DEPDIR)/optimiz.Po
+ -rm -f ./$(DEPDIR)/pars.Po
+ -rm -f ./$(DEPDIR)/phyrex.Po
+ -rm -f ./$(DEPDIR)/rates.Po
+ -rm -f ./$(DEPDIR)/rwrapper.Po
+ -rm -f ./$(DEPDIR)/simu.Po
+ -rm -f ./$(DEPDIR)/spr.Po
+ -rm -f ./$(DEPDIR)/sse.Po
+ -rm -f ./$(DEPDIR)/stats.Po
+ -rm -f ./$(DEPDIR)/tbe.Po
+ -rm -f ./$(DEPDIR)/times.Po
+ -rm -f ./$(DEPDIR)/tiporder.Po
+ -rm -f ./$(DEPDIR)/utilities.Po
+ -rm -f ./$(DEPDIR)/xml.Po
+ -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:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+ clean-generic clean-noinstLIBRARIES cscopelist-am ctags \
+ ctags-am 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-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 tags-am uninstall uninstall-am
+
+.PRECIOUS: Makefile
+
+
+# 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:
diff --git a/phyml/alrt.c b/phyml/alrt.c
index d517aa6..f63b70c 100644
--- a/phyml/alrt.c
+++ b/phyml/alrt.c
@@ -18,16 +18,10 @@ Authors : Jean-Francois Dufayard & Stephane Guindon.
*/
-
-#include "utilities.h"
-#include "lk.h"
-#include "optimiz.h"
-#include "models.h"
-#include "free.h"
-#include "simu.h"
#include "alrt.h"
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
/*
* Check every testable branch of the tree,
@@ -35,7 +29,7 @@ Authors : Jean-Francois Dufayard & Stephane Guindon.
* param tree : the tree to check
*/
-int Check_NNI_Five_Branches(arbre *tree)
+int Check_NNI_Five_Branches(t_tree *tree)
{
int best_edge;
phydbl best_gain;
@@ -46,282 +40,339 @@ int Check_NNI_Five_Branches(arbre *tree)
phydbl init_lnL;
init_lnL = UNLIKELY;
- better_found = 1;
-
+ better_found = YES;
+
//While there is at least one NNI to do...
- while(better_found)
+ while(better_found == YES)
{
Update_Dirs(tree);
-
+
//Interface output
- if (tree->mod->s_opt->print) printf("\n\n. Checking for NNIs, optimizing five branches...\n");
-
+ if(tree->verbose > VL0 && tree->io->quiet == NO) PhyML_Printf("\n\n. Checking for NNIs, optimizing five branches...\n");
+
better_found = 0;
result = -1;
best_edge = -1;
- best_gain = -1.0;
+ best_gain = tree->mod->s_opt->min_diff_lk_local;
best_config = -1;
-
- tree->both_sides = 1;
- init_lnL = Return_Lk(tree);
-
+
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Set_Both_Sides(YES,tree);
+ init_lnL = Lk(NULL,tree);
+ MIXT_Set_Alias_Subpatt(NO,tree);
+
+
//For every branch
- For(i,2*tree->n_otu-3)
- {
- //if this branch is not terminal
- if((!tree->t_edges[i]->left->tax) && (!tree->t_edges[i]->rght->tax))
- {
- result = -1;
-
- //Try every NNIs for the tested branch
- result = NNI_Neigh_BL(tree->t_edges[i],tree);
-
- //Look for possible NNI to do, and check if it is the best one
- switch(result)
- {
- case 1 : /* lk1 > lk0 > lk2 */
- {
- better_found = 1;
- if(best_gain < (tree->t_edges[i]->nni->lk1 - tree->t_edges[i]->nni->lk0))
- {
- best_edge = i;
- best_gain = tree->t_edges[i]->nni->lk1-tree->t_edges[i]->nni->lk0;
- best_config = 1;
- }
- break;
- }
- case 2 : /* lk2 > lk0 > lk1 */
- {
- better_found = 1;
- if(best_gain < (tree->t_edges[i]->nni->lk2 - tree->t_edges[i]->nni->lk0))
- {
- best_edge = i;
- best_gain = tree->t_edges[i]->nni->lk2-tree->t_edges[i]->nni->lk0;
- best_config = 2;
- }
- break;
- }
- case 3 : /* lk1 > lk2 > lk0 */
- {
- better_found = 1;
- if(best_gain < (tree->t_edges[i]->nni->lk1 - tree->t_edges[i]->nni->lk2))
- {
- best_edge = i;
- best_gain = tree->t_edges[i]->nni->lk1-tree->t_edges[i]->nni->lk2;
- best_config = 1;
- }
- break;
- }
- case 4 : /* lk2 > lk1 > lk0 */
- {
- better_found = 1;
- if(best_gain < (tree->t_edges[i]->nni->lk2 - tree->t_edges[i]->nni->lk1))
- {
- best_edge = i;
- best_gain = tree->t_edges[i]->nni->lk2-tree->t_edges[i]->nni->lk1;
- best_config = 2;
- }
- break;
- }
- default : /* lk2 = lk1 = lk0 */
- {
- if(best_gain < .0) best_gain = .0;
- break;
- }
- }
- }
- }
-
+ for(i=0;i<2*tree->n_otu-3;++i)
+ {
+ //if this branch is not terminal
+ if((!tree->a_edges[i]->left->tax) && (!tree->a_edges[i]->rght->tax))
+ {
+ result = -1;
+
+ //Try every NNIs for the tested branch
+ result = NNI_Neigh_BL(tree->a_edges[i],tree);
+
+ //Look for possible NNI to do, and check if it is the best one
+ switch(result)
+ {
+ case 1 : /* lk1 > lk0 > lk2 */
+ {
+ if((tree->a_edges[i]->nni->lk0 - tree->a_edges[i]->nni->lk1) < best_gain)
+ {
+ better_found = YES;
+ best_edge = i;
+ best_gain = tree->a_edges[i]->nni->lk0-tree->a_edges[i]->nni->lk1;
+ best_config = 1;
+ }
+ break;
+ }
+ case 2 : /* lk2 > lk0 > lk1 */
+ {
+ if((tree->a_edges[i]->nni->lk0 - tree->a_edges[i]->nni->lk2) < best_gain)
+ {
+ better_found = YES;
+ best_edge = i;
+ best_gain = tree->a_edges[i]->nni->lk0-tree->a_edges[i]->nni->lk2;
+ best_config = 2;
+ }
+ break;
+ }
+ case 3 : /* lk1 > lk2 > lk0 */
+ {
+ if((tree->a_edges[i]->nni->lk2 - tree->a_edges[i]->nni->lk1) < best_gain)
+ {
+ better_found = YES;
+ best_edge = i;
+ best_gain = tree->a_edges[i]->nni->lk2-tree->a_edges[i]->nni->lk1;
+ best_config = 1;
+ }
+ break;
+ }
+ case 4 : /* lk2 > lk1 > lk0 */
+ {
+ if((tree->a_edges[i]->nni->lk1 - tree->a_edges[i]->nni->lk2) < best_gain)
+ {
+ better_found = YES;
+ best_edge = i;
+ best_gain = tree->a_edges[i]->nni->lk1-tree->a_edges[i]->nni->lk2;
+ best_config = 2;
+ }
+ break;
+ }
+ default : /* lk2 = lk1 = lk0 */
+ {
+ if(best_gain > .0) best_gain = .0;
+ break;
+ }
+ }
+ }
+ }
+
+
if((tree->c_lnL < init_lnL - tree->mod->s_opt->min_diff_lk_local) || (tree->c_lnL > init_lnL + tree->mod->s_opt->min_diff_lk_local))
- {
- printf("\n\n. tree->c_lnL = %f init_lnL = %f.",tree->c_lnL,init_lnL);
- printf("\n. Err in file %s at line %d.\n",__FILE__,__LINE__);
- Warn_And_Exit("\n");
- }
-
+ {
+ PhyML_Fprintf(stderr,"\n\n== tree->c_lnL = %f init_lnL = %f.",tree->c_lnL,init_lnL);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d\n\n.\n",__FILE__,__LINE__);
+ Warn_And_Exit("\n");
+ }
+
//Don't do any NNI if the user doesn't want to optimize topology
-
- if(!tree->mod->s_opt->opt_topo) better_found = 0;
+ if(!tree->mod->s_opt->opt_topo) better_found = NO;
+/* if(FABS(best_gain) <= tree->mod->s_opt->min_diff_lk_move) better_found = 0; */
//If there is one swap to do, make the best one.
if(better_found)
- {
- Make_Target_Swap(tree,tree->t_edges[best_edge],best_config);
- Lk(tree);
-
- if(tree->c_lnL < init_lnL)
- {
- printf("\n\n. tree->c_lnL = %f init_lnL = %f.",tree->c_lnL,init_lnL);
- printf("\n. Err in file %s at line %d.\n",__FILE__,__LINE__);
- Warn_And_Exit("\n");
- }
-
- if(tree->mod->s_opt->print)
- {
- Print_Lk(tree,"[Topology ]");
- printf("\n");
- }
- return 1;
- }
+ {
+ Make_Target_Swap(tree,tree->a_edges[best_edge],best_config);
+
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Lk(NULL,tree);
+ MIXT_Set_Alias_Subpatt(YES,tree);
+
+ if(tree->c_lnL < init_lnL)
+ {
+ PhyML_Fprintf(stderr,"\n\n== tree->c_lnL = %f init_lnL = %f.",tree->c_lnL,init_lnL);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d\n\n.\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ if(tree->verbose > VL0 && tree->io->quiet == NO) Print_Lk(tree,"[Topology ]");
+
+ if(FABS(tree->c_lnL - init_lnL) < tree->mod->s_opt->min_diff_lk_move) return 0;
+ return 1;
+ }
}
return 0;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
/* Compute aLRT supports */
-void aLRT(arbre *tree)
+void aLRT(t_tree *tree)
{
int i;
-
-
+ char *method;
+
+// Print_All_Edge_Likelihoods(tree);
+ Unscale_Br_Len_Multiplier_Tree(tree);
+ Br_Len_Not_Involving_Invar(tree);
+// Print_All_Edge_Likelihoods(tree);
/* aLRT support will label each internal branch */
- tree->print_alrt_val = 1;
+ tree->io->print_support_val = YES;
/* The topology will not be modified when assessing the branch support. We make sure that it will
- not be modified afterward bo locking the topology */
+ not be modified afterwards by locking the topology */
+
+ method = (char *)mCalloc(100,sizeof(char));
+
+ switch(tree->io->ratio_test)
+ {
+ case ALRTCHI2: { strcpy(method,"aLRT"); break; }
+ case MINALRTCHI2SH: { strcpy(method,"aLRT"); break; }
+ case ALRTSTAT: { strcpy(method,"aLRT"); break; }
+ case SH: { strcpy(method,"SH"); break; }
+ case ABAYES: { strcpy(method,"aBayes"); break; }
+ default : return;
+ }
+
+ if(tree->io->quiet == NO) PhyML_Printf("\n\n. Calculating fast branch supports (using '%s').",method);
+ Free(method);
+
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Set_Both_Sides(YES,tree);
+ // Print_All_Edge_Likelihoods(tree);
+ Lk(NULL,tree);
+ // Print_All_Edge_Likelihoods(tree);
+ MIXT_Set_Alias_Subpatt(NO,tree);
+ Update_Dirs(tree);
- tree->both_sides = 1;
- Lk(tree);
+ for(i=0;i<2*tree->n_otu-3;++i)
+ {
+ if((!tree->a_edges[i]->left->tax) && (!tree->a_edges[i]->rght->tax))
+ {
+ /* Compute likelihoods for each of the three configuration */
+ NNI_Neigh_BL(tree->a_edges[i],tree);
+ /* Compute the corresponding statistical support */
+ Compute_Likelihood_Ratio_Test(tree->a_edges[i],tree);
+ }
+ }
+
+ tree->lock_topo = YES;
- For(i,2*tree->n_otu-3)
- if((!tree->t_edges[i]->left->tax) && (!tree->t_edges[i]->rght->tax))
- {
- /* Compute likelihoods for each of the three configuration */
- NNI_Neigh_BL(tree->t_edges[i],tree);
- /* Compute the corresponding statistical support */
- Compute_Likelihood_Ratio_Test(tree->t_edges[i],tree);
- }
+ Br_Len_Involving_Invar(tree);
+ Rescale_Br_Len_Multiplier_Tree(tree);
- tree->lock_topo = 1;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
/*
* Launch one branch testing,
* analyse the result
* and convert supports as wished by the user.
* param tree : the tree to check
-* param tested_edge : the tested edge of the tree
+* param tested_t_edge : the tested t_edge of the tree
* param old_loglk : the initial likelihood, before any aLRT analysis
* param isBoot : 1 if used from the Bootstrap procedure, 0 if not
* return an integer, informative to analyse the results and potential NNIs to do
*/
-int Compute_Likelihood_Ratio_Test(edge *tested_edge, arbre *tree)
+int Compute_Likelihood_Ratio_Test(t_edge *tested_edge, t_tree *tree)
{
int result=0;
- tested_edge->ratio_test = 0.0;
+ tested_edge->ratio_test = 0.0;
tested_edge->alrt_statistic = -1.0;
-
+
if((tested_edge->nni->lk0 > tested_edge->nni->lk1) && (tested_edge->nni->lk0 > tested_edge->nni->lk2))
{
if(tested_edge->nni->lk1 < tested_edge->nni->lk2)
- {
- //lk0 > lk2 > lk1
- tested_edge->alrt_statistic = 2*(tested_edge->nni->lk0 - tested_edge->nni->lk2);
- }
+ {
+ //lk0 > lk2 > lk1
+ tested_edge->alrt_statistic = 2*(tested_edge->nni->lk0 - tested_edge->nni->lk2);
+ }
else
- {
- //lk0 > lk1 >= lk2
- tested_edge->alrt_statistic = 2*(tested_edge->nni->lk0 - tested_edge->nni->lk1);
- }
+ {
+ //lk0 > lk1 >= lk2
+ tested_edge->alrt_statistic = 2*(tested_edge->nni->lk0 - tested_edge->nni->lk1);
+ }
if (tested_edge->alrt_statistic < 0.0)
- {
- tested_edge->alrt_statistic = 0.0;
- tested_edge->ratio_test = 0.0;
- }
+ {
+ tested_edge->alrt_statistic = 0.0;
+ tested_edge->ratio_test = 0.0;
+ }
else
- {
- //aLRT statistic is valid, compute the wished support
- if (tree->io->ratio_test == 2)
- tested_edge->ratio_test = Statistics_To_Probabilities(tested_edge->alrt_statistic);
-
- else if(tree->io->ratio_test == 3)
- {
- phydbl sh_support;
- phydbl param_support;
-
- sh_support = Statistics_To_SH(tree);
- param_support = Statistics_To_Probabilities(tested_edge->alrt_statistic);
-
- if(sh_support < param_support) tested_edge->ratio_test = sh_support;
- else tested_edge->ratio_test = param_support;
- }
-
- else if(tree->io->ratio_test == 1)
- {
- tested_edge->ratio_test=tested_edge->alrt_statistic;
- }
- else
- {
- tested_edge->ratio_test = Statistics_To_SH(tree);
- }
- }
- }
+ {
+ //aLRT statistic is valid, compute the branch support
+ if (tree->io->ratio_test == ALRTCHI2)
+ {
+ tested_edge->ratio_test = Statistics_To_Probabilities(tested_edge->alrt_statistic);
+ }
+ else if(tree->io->ratio_test == MINALRTCHI2SH)
+ {
+ phydbl sh_support;
+ phydbl param_support;
+
+ sh_support = Statistics_To_SH(tree);
+ param_support = Statistics_To_Probabilities(tested_edge->alrt_statistic);
+
+ if(sh_support < param_support) tested_edge->ratio_test = sh_support;
+ else tested_edge->ratio_test = param_support;
+ }
+
+ else if(tree->io->ratio_test == ALRTSTAT)
+ {
+ tested_edge->ratio_test=tested_edge->alrt_statistic;
+ }
+ else if(tree->io->ratio_test == SH)
+ {
+ tested_edge->ratio_test = Statistics_To_SH(tree);
+ }
+ else if(tree->io->ratio_test == ABAYES)
+ {
+ phydbl Kp0,Kp1,Kp2,logK;
+
+ logK = 1. - MAX(MAX(tested_edge->nni->lk0,tested_edge->nni->lk1),tested_edge->nni->lk2);
+
+ Kp0 = exp(tested_edge->nni->lk0+logK);
+ Kp1 = exp(tested_edge->nni->lk1+logK);
+ Kp2 = exp(tested_edge->nni->lk2+logK);
+ tested_edge->ratio_test = Kp0/(Kp0+Kp1+Kp2);
+ }
+ }
+ }
//statistic is not valid, give the negative statistics if wished, or a zero support.
else if((tested_edge->nni->lk1 > tested_edge->nni->lk0) && (tested_edge->nni->lk1 > tested_edge->nni->lk2))
{
- tested_edge->alrt_statistic = 2*(tested_edge->nni->lk0-tested_edge->nni->lk1);
+ /* tested_edge->ratio_test = 2*(tested_edge->nni->lk0-tested_edge->nni->lk1); */
+ tested_edge->ratio_test = 0.0;
if(tree->io->ratio_test > 1) tested_edge->alrt_statistic = 0.0;
}
else if((tested_edge->nni->lk2 > tested_edge->nni->lk0) && (tested_edge->nni->lk2 > tested_edge->nni->lk1))
{
- tested_edge->alrt_statistic = 2*(tested_edge->nni->lk0-tested_edge->nni->lk2);
+ /* tested_edge->ratio_test = 2*(tested_edge->nni->lk0-tested_edge->nni->lk2); */
+ tested_edge->ratio_test = 0.0;
if(tree->io->ratio_test > 1) tested_edge->alrt_statistic = 0.0;
}
else // lk0 ~ lk1 ~ lk2
{
- tested_edge->alrt_statistic = 0.0;
+ tested_edge->ratio_test = 0.0;
if(tree->io->ratio_test > 1) tested_edge->ratio_test = 0.0;
}
-
return result;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
/*
* Test the 3 NNI positions for one branch.
* param tree : the tree to check
-* param tested_edge : the tested edge of the tree
+* param tested_t_edge : the tested t_edge of the tree
* param old_loglk : the initial likelihood, before any aLRT analysis
* param isBoot : 1 if used from the Bootstrap procedure, 0 if not
*/
-int NNI_Neigh_BL(edge *b_fcus, arbre *tree)
+int NNI_Neigh_BL(t_edge *b_fcus, t_tree *tree)
{
- int n_patterns;
- int l_r, r_l, l_v1, l_v2, r_v3, r_v4, site;
- node *v1,*v2,*v3,*v4;
- edge *e1,*e2,*e3,*e4;
- phydbl len_e1,len_e2,len_e3,len_e4;
+ /*!
+ syntax : (node) [edge]
+ (left_1) . .(right_1)
+ \ (left) (right) /
+ \._____________./
+ / [b_fcus] \
+ / \
+ (left_2) . .(right_2)
+
+ */
+
+ int site;
+ t_node *v1,*v2,*v3,*v4;
+ t_edge *e1,*e2,*e3,*e4;
+ scalar_dbl *len_e1,*len_e2,*len_e3,*len_e4;
+ scalar_dbl *var_e1,*var_e2,*var_e3,*var_e4;
phydbl lk0, lk1, lk2;
- phydbl bl_init;
- phydbl l1,l2,l3;
- phydbl l_infa, l_infb, l_max;
+ scalar_dbl *l_init,*v_init;
phydbl lk_init, lk_temp;
int i;
- int result,counter,wei;
+ int result;
+ void *buff;
result = 0;
- //Initialization
- bl_init = b_fcus->l;
- lk_init = tree->c_lnL;
- lk_temp = UNLIKELY;
- n_patterns = (int)floor(tree->n_pattern*tree->prop_of_sites_to_consider);
-
- b_fcus->nni->score = .0;
+ /*! Initialization */
+ l_init = Duplicate_Scalar_Dbl(b_fcus->l);
+ v_init = Duplicate_Scalar_Dbl(b_fcus->l_var);
+ lk_init = tree->c_lnL;
+ lk_temp = UNLIKELY;
lk0 = lk1 = lk2 = UNLIKELY;
v1 = v2 = v3 = v4 = NULL;
-
- l_r = r_l = l_v1 = l_v2 = r_v3 = r_v4 = -1;
-
- l_r = b_fcus->l_r;
- r_l = b_fcus->r_l;
-
- //vertices
+ Init_NNI_Score(0.0,b_fcus,tree);
+
+ /*! vertices */
v1 = b_fcus->left->v[b_fcus->l_v1];
v2 = b_fcus->left->v[b_fcus->l_v2];
v3 = b_fcus->rght->v[b_fcus->r_v1];
@@ -329,349 +380,340 @@ int NNI_Neigh_BL(edge *b_fcus, arbre *tree)
if(v1->num < v2->num)
{
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
- Warn_And_Exit("");
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n\n",__FILE__,__LINE__);
+ Exit("");
}
+
if(v3->num < v4->num)
{
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
- Warn_And_Exit("");
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n\n",__FILE__,__LINE__);
+ Exit("");
}
-
- l1 = l2 = l3 = -1.;
- l1 = b_fcus->l;
-
- //edges
+ /*! edges */
e1 = b_fcus->left->b[b_fcus->l_v1];
e2 = b_fcus->left->b[b_fcus->l_v2];
e3 = b_fcus->rght->b[b_fcus->r_v1];
e4 = b_fcus->rght->b[b_fcus->r_v2];
- //record initial branch lengths
- len_e1 = e1->l;
- len_e2 = e2->l;
- len_e3 = e3->l;
- len_e4 = e4->l;
-
- //Optimize branch lengths and update likelihoods for
- //the original configuration.
-
+ /*! record initial branch lengths */
+ len_e1 = Duplicate_Scalar_Dbl(e1->l);
+ len_e2 = Duplicate_Scalar_Dbl(e2->l);
+ len_e3 = Duplicate_Scalar_Dbl(e3->l);
+ len_e4 = Duplicate_Scalar_Dbl(e4->l);
+ var_e1 = Duplicate_Scalar_Dbl(e1->l_var);
+ var_e2 = Duplicate_Scalar_Dbl(e2->l_var);
+ var_e3 = Duplicate_Scalar_Dbl(e3->l_var);
+ var_e4 = Duplicate_Scalar_Dbl(e4->l_var);
+
+ /*! Optimize branch lengths and update likelihoods for
+ the original configuration.
+ */
do
{
lk0 = lk_temp;
- For(i,3)
- if(b_fcus->left->v[i] != b_fcus->rght)
- {
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
-
- l_infa = 10.*b_fcus->left->b[i]->l;
- l_max = b_fcus->left->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->left->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
-
- Update_P_Lk(tree,b_fcus,b_fcus->left);
-
- l_infa = 10.*b_fcus->l;
- l_max = b_fcus->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus,tree,
- tree->mod->s_opt->brent_it_max);
-
-
- For(i,3)
- if(b_fcus->rght->v[i] != b_fcus->left)
- {
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
-
- l_infa = 10.*b_fcus->rght->b[i]->l;
- l_max = b_fcus->rght->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->rght->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
-
- Update_P_Lk(tree,b_fcus,b_fcus->rght);
+ for(i=0;i<3;i++) //a branch has three nodes
+ if(b_fcus->left->v[i] != b_fcus->rght) //Only consider left_1 and left_2
+ {
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->left->b[i]->l->v),b_fcus->left->b[i],tree);
+ }
+
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->l->v),b_fcus,tree);
+
+ for(i=0;i<3;i++)
+ if(b_fcus->rght->v[i] != b_fcus->left) //Only consider right_1 and right_2
+ {
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+ lk_temp = Br_Len_Opt(&(b_fcus->rght->b[i]->l->v),b_fcus->rght->b[i],tree);
+ }
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
if(lk_temp < lk0 - tree->mod->s_opt->min_diff_lk_local)
- {
- printf("\n. lk_temp = %f lk0 = %f\n",lk_temp,lk0);
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
- Warn_And_Exit("");
- }
+ {
+ PhyML_Fprintf(stderr,"\n. lk_temp = %f lk0 = %f\n",lk_temp,lk0);
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
}
while(fabs(lk_temp-lk0) > tree->mod->s_opt->min_diff_lk_global);
-
-
+ //until no significative improvement is detected
+
lk0 = tree->c_lnL;
- counter=0;
- For(site,n_patterns)
+
+ buff = (t_tree *)tree;
+ do
{
- wei=0;
- For(wei,tree->data->wght[site])
- {
- tree->log_lks_aLRT[0][counter]= tree->c_lnL_sorted[site] / tree->data->wght[site];
- counter++;
- }
+ for(site=0;siten_pattern;site++) tree->log_lks_aLRT[0][site] = tree->c_lnL_sorted[site];
+ tree = tree->next_mixt;
}
+ while(tree);
+
+ tree = (t_tree *)buff;
+
+ /*! Go back to initial branch lengths */
+ Copy_Scalar_Dbl(len_e1,e1->l);
+ Copy_Scalar_Dbl(len_e2,e2->l);
+ Copy_Scalar_Dbl(len_e3,e3->l);
+ Copy_Scalar_Dbl(len_e4,e4->l);
+ Copy_Scalar_Dbl(l_init,b_fcus->l);
+ Copy_Scalar_Dbl(var_e1,e1->l_var);
+ Copy_Scalar_Dbl(var_e2,e2->l_var);
+ Copy_Scalar_Dbl(var_e3,e3->l_var);
+ Copy_Scalar_Dbl(var_e4,e4->l_var);
+ Copy_Scalar_Dbl(v_init,b_fcus->l_var);
- /* Go back to initial branch lengths */
- e1->l = len_e1;
- e2->l = len_e2;
- e3->l = len_e3;
- e4->l = len_e4;
- b_fcus->l = bl_init;
Update_PMat_At_Given_Edge(e1,tree);
Update_PMat_At_Given_Edge(e2,tree);
Update_PMat_At_Given_Edge(e3,tree);
Update_PMat_At_Given_Edge(e4,tree);
Update_PMat_At_Given_Edge(b_fcus,tree);
+ /* Sanity check */
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ lk_temp = Lk(b_fcus,tree);
+ MIXT_Set_Alias_Subpatt(NO,tree);
+ if((lk_temp > lk_init + tree->mod->s_opt->min_diff_lk_local) || (lk_temp < lk_init - tree->mod->s_opt->min_diff_lk_local))
+ {
+ PhyML_Fprintf(stderr,"\n. lk_temp = %f lk_init = %f",lk_temp,lk_init);
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
- //Do first possible swap
- Swap(v2,b_fcus->left,b_fcus->rght,v3,tree);
-
-
- tree->both_sides = 1;
- lk1 = Update_Lk_At_Given_Edge(b_fcus,tree);
- For(i,3)
+ /*! Do first possible swap */
+ Swap(v2,b_fcus->left,b_fcus->rght,v3,tree);
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Set_Both_Sides(YES,tree);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
+ lk1 = Lk(b_fcus,tree);
+ MIXT_Set_Alias_Subpatt(NO,tree);
+
+ for(i=0;i<3;i++)
if(b_fcus->left->v[i] != b_fcus->rght)
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
-
- For(i,3)
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+
+ for(i=0;i<3;i++)
if(b_fcus->rght->v[i] != b_fcus->left)
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
-
-
- //Optimize branch lengths and update likelihoods
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+
+
+ /*! Optimize branch lengths and update likelihoods */
lk_temp = UNLIKELY;
do
{
lk1 = lk_temp;
-
- For(i,3)
- if(b_fcus->left->v[i] != b_fcus->rght)
- {
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
-
- l_infa = 10.*b_fcus->left->b[i]->l;
- l_max = b_fcus->left->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->left->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
-
-
- Update_P_Lk(tree,b_fcus,b_fcus->left);
-
- l_infa = 10.*b_fcus->l;
- l_max = b_fcus->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus,tree,
- tree->mod->s_opt->brent_it_max);
-
-
-
- For(i,3)
- if(b_fcus->rght->v[i] != b_fcus->left)
- {
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
-
- l_infa = 10.*b_fcus->rght->b[i]->l;
- l_max = b_fcus->rght->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->rght->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
-
- Update_P_Lk(tree,b_fcus,b_fcus->rght);
-
-
+
+ for(i=0;i<3;i++)
+ if(b_fcus->left->v[i] != b_fcus->rght)
+ {
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->left->b[i]->l->v),b_fcus->left->b[i],tree);
+ }
+
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->l->v),b_fcus,tree);
+
+ for(i=0;i<3;i++)
+ if(b_fcus->rght->v[i] != b_fcus->left)
+ {
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+ lk_temp = Br_Len_Opt(&(b_fcus->rght->b[i]->l->v),b_fcus->rght->b[i],tree);
+ }
+
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
+
if(lk_temp < lk1 - tree->mod->s_opt->min_diff_lk_local)
- {
- printf("\n. lk_temp = %f lk1 = %f\n",lk_temp,lk1);
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
- Warn_And_Exit("");
- }
+ {
+ PhyML_Fprintf(stderr,"\n. lk_temp = %f lk1 = %f\n",lk_temp,lk1);
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n\n",__FILE__,__LINE__);
+ Exit("");
+ }
}
- while(fabs(lk_temp-lk1) > tree->mod->s_opt->min_diff_lk_global);
- //until no significative improvement is detected
+ while(FABS(lk_temp-lk1) > tree->mod->s_opt->min_diff_lk_global);
+ /*! until no significative improvement is detected */
lk1 = tree->c_lnL;
- //save likelihood of each sites, in order to compute branch supports
- counter=0;
- For(site,n_patterns)
+ /*! record likelihood of each site, in order to compute branch supports */
+
+ buff = (t_tree *)tree;
+ do
{
- wei=0;
- For(wei,tree->data->wght[site])
- {
- tree->log_lks_aLRT[1][counter]= tree->c_lnL_sorted[site] / tree->data->wght[site];
- counter++;
- }
+ for(site=0;siten_pattern;site++) tree->log_lks_aLRT[1][site]= tree->c_lnL_sorted[site];
+ tree = tree->next_mixt;
}
-
- //save current length
- l2 = b_fcus->l;
-
- //undo the swap
+ while(tree);
+ tree = (t_tree *)buff;
+
Swap(v3,b_fcus->left,b_fcus->rght,v2,tree);
- /* Go back to initial branch lengths */
- e1->l = len_e1;
- e2->l = len_e2;
- e3->l = len_e3;
- e4->l = len_e4;
- b_fcus->l = bl_init;
-
+ /*! Go back to initial branch lengths */
+ Copy_Scalar_Dbl(len_e1,e1->l);
+ Copy_Scalar_Dbl(len_e2,e2->l);
+ Copy_Scalar_Dbl(len_e3,e3->l);
+ Copy_Scalar_Dbl(len_e4,e4->l);
+ Copy_Scalar_Dbl(l_init,b_fcus->l);
+ Copy_Scalar_Dbl(var_e1,e1->l_var);
+ Copy_Scalar_Dbl(var_e2,e2->l_var);
+ Copy_Scalar_Dbl(var_e3,e3->l_var);
+ Copy_Scalar_Dbl(var_e4,e4->l_var);
+ Copy_Scalar_Dbl(v_init,b_fcus->l_var);
+
Update_PMat_At_Given_Edge(e1,tree);
Update_PMat_At_Given_Edge(e2,tree);
Update_PMat_At_Given_Edge(e3,tree);
Update_PMat_At_Given_Edge(e4,tree);
Update_PMat_At_Given_Edge(b_fcus,tree);
-
- /***********/
- //do the second possible swap
+
+
+ /* Sanity check */
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ lk_temp = Lk(b_fcus,tree);
+ MIXT_Set_Alias_Subpatt(NO,tree);
+ if((lk_temp > lk_init + tree->mod->s_opt->min_diff_lk_local) || (lk_temp < lk_init - tree->mod->s_opt->min_diff_lk_local))
+ {
+ PhyML_Fprintf(stderr,"\n== lk_temp = %f lk_init = %f",lk_temp,lk_init);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Warn_And_Exit("");
+ }
+
+ /*! do the second possible swap */
Swap(v2,b_fcus->left,b_fcus->rght,v4,tree);
- b_fcus->l = bl_init;
- tree->both_sides = 1;
-
- lk2 = Update_Lk_At_Given_Edge(b_fcus,tree);
-
- For(i,3)
+ Set_Both_Sides(YES,tree);
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
+ lk2 = Lk(b_fcus,tree);
+ MIXT_Set_Alias_Subpatt(NO,tree);
+
+ for(i=0;i<3;i++)
if(b_fcus->left->v[i] != b_fcus->rght)
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
-
- For(i,3)
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+
+ for(i=0;i<3;i++)
if(b_fcus->rght->v[i] != b_fcus->left)
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
-
-
- //Optimize branch lengths and update likelihoods
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+
+ /*! Optimize branch lengths and update likelihoods */
lk_temp = UNLIKELY;
do
{
lk2 = lk_temp;
-
- For(i,3)
- if(b_fcus->left->v[i] != b_fcus->rght)
- {
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
-
- l_infa = 10.*b_fcus->left->b[i]->l;
- l_max = b_fcus->left->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->left->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
-
-
- Update_P_Lk(tree,b_fcus,b_fcus->left);
-
- l_infa = 10.*b_fcus->l;
- l_max = b_fcus->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus,tree,
- tree->mod->s_opt->brent_it_max);
-
- For(i,3)
- if(b_fcus->rght->v[i] != b_fcus->left)
- {
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
-
- l_infa = 10.*b_fcus->rght->b[i]->l;
- l_max = b_fcus->rght->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->rght->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
-
- Update_P_Lk(tree,b_fcus,b_fcus->rght);
-
+
+ for(i=0;i<3;i++)
+ if(b_fcus->left->v[i] != b_fcus->rght)
+ {
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->left->b[i]->l->v),b_fcus->left->b[i],tree);
+
+ if(lk_temp < lk2 - tree->mod->s_opt->min_diff_lk_local)
+ {
+ PhyML_Fprintf(stderr,"\n== l: %f var:%f",b_fcus->left->b[i]->l->v,b_fcus->left->b[i]->l_var->v);
+ PhyML_Fprintf(stderr,"\n== lk_temp = %f lk2 = %f",lk_temp,lk2);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d",__FILE__,__LINE__);
+ Exit("\n");
+ }
+ }
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->l->v),b_fcus,tree);
+
if(lk_temp < lk2 - tree->mod->s_opt->min_diff_lk_local)
- {
- printf("\n. lk_temp = %f lk2 = %f\n",lk_temp,lk2);
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
- Warn_And_Exit("");
- }
+ {
+ PhyML_Fprintf(stderr,"\n== l: %f var:%f",b_fcus->l->v,b_fcus->l_var->v);
+ PhyML_Fprintf(stderr,"\n== lk_temp = %f lk2 = %f",lk_temp,lk2);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ for(i=0;i<3;i++)
+ if(b_fcus->rght->v[i] != b_fcus->left)
+ {
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+ lk_temp = Br_Len_Opt(&(b_fcus->rght->b[i]->l->v),b_fcus->rght->b[i],tree);
+
+ if(lk_temp < lk2 - tree->mod->s_opt->min_diff_lk_local)
+ {
+ Set_Both_Sides(YES,tree);
+ Lk(b_fcus,tree);
+ Check_Lk_At_Given_Edge(YES,tree);
+ PhyML_Fprintf(stderr,"\n== l: %f var:%f",b_fcus->rght->b[i]->l->v,b_fcus->rght->b[i]->l_var->v);
+ PhyML_Fprintf(stderr,"\n== lk_temp = %f lk2 = %f",lk_temp,lk2);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d",__FILE__,__LINE__);
+ Exit("\n");
+ }
+ }
+
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
+
}
- while(fabs(lk_temp-lk2) > tree->mod->s_opt->min_diff_lk_global);
+ while(FABS(lk_temp-lk2) > tree->mod->s_opt->min_diff_lk_global);
//until no significative improvement is detected
lk2 = tree->c_lnL;
-
- //save likelihood of each sites, in order to compute branch supports
- counter=0;
- For(site,n_patterns)
+
+ /*! save likelihood of each sites, in order to compute branch supports */
+ buff = (t_tree *)tree;
+ do
{
- wei=0;
- For(wei,tree->data->wght[site])
- {
- tree->log_lks_aLRT[2][counter]= tree->c_lnL_sorted[site] / tree->data->wght[site];
- counter++;
- }
+ for(site=0;siten_pattern;site++) tree->log_lks_aLRT[2][site]= tree->c_lnL_sorted[site];
+ tree = tree->next_mixt;
}
+ while(tree);
+ tree = (t_tree *)buff;
+
- //save current length
- l3 = b_fcus->l;
- //undo the swap
+ /*! undo the swap */
Swap(v4,b_fcus->left,b_fcus->rght,v2,tree);
/***********/
- //restore the initial branch length values
- e1->l = len_e1;
- e2->l = len_e2;
- e3->l = len_e3;
- e4->l = len_e4;
- b_fcus->l = bl_init;
+ /*! restore the initial branch length values */
+ Copy_Scalar_Dbl(len_e1,e1->l);
+ Copy_Scalar_Dbl(len_e2,e2->l);
+ Copy_Scalar_Dbl(len_e3,e3->l);
+ Copy_Scalar_Dbl(len_e4,e4->l);
+ Copy_Scalar_Dbl(l_init,b_fcus->l);
+ Copy_Scalar_Dbl(var_e1,e1->l_var);
+ Copy_Scalar_Dbl(var_e2,e2->l_var);
+ Copy_Scalar_Dbl(var_e3,e3->l_var);
+ Copy_Scalar_Dbl(var_e4,e4->l_var);
+ Copy_Scalar_Dbl(v_init,b_fcus->l_var);
- //recompute likelihoods
+
+ /*! recompute likelihoods */
Update_PMat_At_Given_Edge(e1,tree);
Update_PMat_At_Given_Edge(e2,tree);
Update_PMat_At_Given_Edge(e3,tree);
Update_PMat_At_Given_Edge(e4,tree);
Update_PMat_At_Given_Edge(b_fcus,tree);
- Update_P_Lk(tree,b_fcus,b_fcus->rght);
- Update_P_Lk(tree,b_fcus,b_fcus->left);
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
- For(i,3)
+ for(i=0;i<3;i++)
if(b_fcus->left->v[i] != b_fcus->rght)
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
- For(i,3)
+ for(i=0;i<3;i++)
if(b_fcus->rght->v[i] != b_fcus->left)
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
- lk_temp = Lk_At_Given_Edge(b_fcus,tree);
+ MIXT_Set_Alias_Subpatt(NO,tree);
+ lk_temp = Lk(b_fcus,tree);
if((lk_temp > lk_init + tree->mod->s_opt->min_diff_lk_local) || (lk_temp < lk_init - tree->mod->s_opt->min_diff_lk_local))
{
- printf("\n. lk_temp = %f lk_init = %f\n",lk_temp,lk_init);
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Fprintf(stderr,"\n== lk_temp = %f lk_init = %f",lk_temp,lk_init);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
Warn_And_Exit("");
}
@@ -696,51 +738,51 @@ int NNI_Neigh_BL(edge *b_fcus, arbre *tree)
if(b_fcus->nni->lk0 > b_fcus->nni->lk2) result = 1; //lk1 > lk0 > lk2
else result = 3; //lk1 > lk2 > lk0
}
- else if((b_fcus->nni->lk2 > b_fcus->nni->lk0) && (b_fcus->nni->lk2 > b_fcus->nni->lk1))
+ else if((b_fcus->nni->lk2 > b_fcus->nni->lk0) && (b_fcus->nni->lk2 > b_fcus->nni->lk1))
{
if(b_fcus->nni->lk0 > b_fcus->nni->lk1) result = 2; //lk2 > lk0 > lk1
else result = 4; //lk2 > lk1 > lk0
}
-
-/* int counter=0; */
-/* For(site,n_patterns) */
-/* { */
-/* printf("%3d %3d %15f ",b_fcus->num,tree->data->wght[site],b_fcus->nni->score); */
-/* printf("%15f %15f\n", */
-/* tree->log_lks_aLRT[0][counter], */
-/* (lk1 > lk2)?(tree->log_lks_aLRT[1][counter]):(tree->log_lks_aLRT[2][counter])); */
-/* counter+=tree->data->wght[site]; */
-/* } */
+
+
+ Free_Scalar_Dbl(len_e1);
+ Free_Scalar_Dbl(len_e2);
+ Free_Scalar_Dbl(len_e3);
+ Free_Scalar_Dbl(len_e4);
+ Free_Scalar_Dbl(l_init);
+ Free_Scalar_Dbl(var_e1);
+ Free_Scalar_Dbl(var_e2);
+ Free_Scalar_Dbl(var_e3);
+ Free_Scalar_Dbl(var_e4);
+ Free_Scalar_Dbl(v_init);
+
return result;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
/*
* Make one target swap, optimizing five branches.
* param tree : the tree to check
-* param tested_edge : the swaping edge of the tree
+* param tested_t_edge : the swaping t_edge of the tree
* param swapToDo : 1 or 2, to select the first or the second swap to do
*/
-void Make_Target_Swap(arbre *tree, edge *b_fcus, int swaptodo)
+void Make_Target_Swap(t_tree *tree, t_edge *b_fcus, int swaptodo)
{
- int l_r, r_l, l_v1, l_v2, r_v3, r_v4;
- node *v1,*v2,*v3,*v4;
- edge *e1,*e2,*e3,*e4;
+ t_node *v1,*v2,*v3,*v4;
phydbl lktodo;
- phydbl bl_init;
- phydbl l_infa, l_infb, l_max;
phydbl lk_init, lk_temp;
int i;
if(swaptodo < 0)
{
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Fprintf(stderr,"\n== Err in file %s at line %d\n\n",__FILE__,__LINE__);
Warn_And_Exit("");
}
//Initialization
- bl_init = b_fcus->l;
lk_init = tree->c_lnL;
b_fcus->nni->score = .0;
@@ -748,11 +790,6 @@ void Make_Target_Swap(arbre *tree, edge *b_fcus, int swaptodo)
lktodo = UNLIKELY;
v1 = v2 = v3 = v4 = NULL;
- l_r = r_l = l_v1 = l_v2 = r_v3 = r_v4 = -1;
-
- l_r = b_fcus->l_r;
- r_l = b_fcus->r_l;
-
v1 = b_fcus->left->v[b_fcus->l_v1];
v2 = b_fcus->left->v[b_fcus->l_v2];
v3 = b_fcus->rght->v[b_fcus->r_v1];
@@ -760,43 +797,42 @@ void Make_Target_Swap(arbre *tree, edge *b_fcus, int swaptodo)
if(v1->num < v2->num)
{
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Fprintf(stderr,"\n== Err in file %s at line %d\n\n",__FILE__,__LINE__);
Warn_And_Exit("");
}
if(v3->num < v4->num)
{
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Fprintf(stderr,"\n. Err in file %s at line %d\n\n",__FILE__,__LINE__);
Warn_And_Exit("");
}
- e1 = b_fcus->left->b[b_fcus->l_v1];
- e2 = b_fcus->left->b[b_fcus->l_v2];
- e3 = b_fcus->rght->b[b_fcus->r_v1];
- e4 = b_fcus->rght->b[b_fcus->r_v2];
-
/***********/
//make the selected swap
if(swaptodo==1)
{
Swap(v2,b_fcus->left,b_fcus->rght,v3,tree);
+ if(!Check_Topo_Constraints(tree,tree->io->cstr_tree)) Swap(v3,b_fcus->left,b_fcus->rght,v2,tree);
}
else
{
Swap(v2,b_fcus->left,b_fcus->rght,v4,tree);
+ if(!Check_Topo_Constraints(tree,tree->io->cstr_tree)) Swap(v4,b_fcus->left,b_fcus->rght,v2,tree);
}
- tree->both_sides = 1;
+ MIXT_Set_Alias_Subpatt(YES,tree);
+ Set_Both_Sides(YES,tree);
lktodo = Update_Lk_At_Given_Edge(b_fcus,tree);
-
- For(i,3)
+
+ for(i=0;i<3;i++)
if(b_fcus->left->v[i] != b_fcus->rght)
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
-
- For(i,3)
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+
+ for(i=0;i<3;i++)
if(b_fcus->rght->v[i] != b_fcus->left)
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+ MIXT_Set_Alias_Subpatt(NO,tree);
//Optimize branch lengths and update likelihoods
lk_temp = UNLIKELY;
@@ -804,84 +840,60 @@ void Make_Target_Swap(arbre *tree, edge *b_fcus, int swaptodo)
{
lktodo = lk_temp;
- For(i,3)
- if(b_fcus->left->v[i] != b_fcus->rght)
- {
- Update_P_Lk(tree,b_fcus->left->b[i],b_fcus->left);
-
- l_infa = 10.*b_fcus->left->b[i]->l;
- l_max = b_fcus->left->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->left->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
+ for(i=0;i<3;i++)
+ if(b_fcus->left->v[i] != b_fcus->rght)
+ {
+ Update_Partial_Lk(tree,b_fcus->left->b[i],b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->left->b[i]->l->v),b_fcus->left->b[i],tree);
+ }
- Update_P_Lk(tree,b_fcus,b_fcus->left);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
+ lk_temp = Br_Len_Opt(&(b_fcus->l->v),b_fcus,tree);
- l_infa = 10.*b_fcus->l;
- l_max = b_fcus->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus,tree,
- tree->mod->s_opt->brent_it_max);
-
-
-
- For(i,3)
- if(b_fcus->rght->v[i] != b_fcus->left)
- {
- Update_P_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
-
- l_infa = 10.*b_fcus->rght->b[i]->l;
- l_max = b_fcus->rght->b[i]->l;
- l_infb = BL_MIN;
- lk_temp = Br_Len_Brent(l_infa,l_max,l_infb,
- tree->mod->s_opt->min_diff_lk_local,
- b_fcus->rght->b[i],tree,
- tree->mod->s_opt->brent_it_max);
- }
-
- Update_P_Lk(tree,b_fcus,b_fcus->rght);
+ for(i=0;i<3;i++)
+ if(b_fcus->rght->v[i] != b_fcus->left)
+ {
+ Update_Partial_Lk(tree,b_fcus->rght->b[i],b_fcus->rght);
+ lk_temp = Br_Len_Opt(&(b_fcus->rght->b[i]->l->v),b_fcus->rght->b[i],tree);
+ }
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
if(lk_temp < lktodo - tree->mod->s_opt->min_diff_lk_local)
- {
- printf("\n. Edge %3d lk_temp = %f lktodo = %f\n",b_fcus->num,lk_temp,lktodo);
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
- Warn_And_Exit("");
- }
+ {
+ PhyML_Fprintf(stderr,"\n== Edge %3d lk_temp = %f lktodo = %f\n",b_fcus->num,lk_temp,lktodo);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d\n\n",__FILE__,__LINE__);
+ Warn_And_Exit("");
+ }
}
- while(fabs(lk_temp-lktodo) > tree->mod->s_opt->min_diff_lk_global);
+ while(FABS(lk_temp-lktodo) > tree->mod->s_opt->min_diff_lk_global);
//until no significative improvement is detected
-/* printf("\n.<< [%3d] l=%f lk_init=%f tree->c_lnL=%f score=%12f v1=%3d v2=%3d v3=%3d v4=%3d >>", */
+/* PhyML_Printf("\n.<< [%3d] l=%f lk_init=%f tree->c_lnL=%f score=%12f v1=%3d v2=%3d v3=%3d v4=%3d >>", */
/* b_fcus->num, */
-/* b_fcus->l, */
+/* b_fcus->l->v, */
/* lk_init, */
/* tree->c_lnL, */
/* lk_init-tree->c_lnL, */
/* v1->num,v2->num,v3->num,v4->num); */
- if(tree->c_lnL < lk_init)
+ if(tree->c_lnL < lk_init - tree->mod->s_opt->min_diff_lk_global)
{
- printf("\n. [%3d] v1=%d v2=%d v3=%d v4=%d",
- b_fcus->num,v1->num,v2->num,v3->num,v4->num);
- printf("\n. tree->c_lnL = %f lk_init = %f\n",tree->c_lnL,lk_init);
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Fprintf(stderr,"\n== [%3d] v1=%d v2=%d v3=%d v4=%d",b_fcus->num,v1->num,v2->num,v3->num,v4->num);
+ PhyML_Fprintf(stderr,"\n== tree->c_lnL = %f lk_init = %f\n",tree->c_lnL,lk_init);
+ PhyML_Fprintf(stderr,"\n== Err. in file %s at line %d\n\n",__FILE__,__LINE__);
Warn_And_Exit("");
}
-
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
/**
-* Convert an aLRT statistic to a none parametric support
+* Convert an aLRT statistic to a non-parametric support
* param in: the statistic
*/
@@ -1050,61 +1062,74 @@ phydbl Statistics_To_Probabilities(phydbl in)
return rough_value;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
/**
* deprecated
* Compute a RELL support, using the latest tested branch
* param tree: the tested tree
*/
-phydbl Statistics_to_RELL(arbre *tree)
+phydbl Statistics_to_RELL(t_tree *tree)
{
int i;
- int occurence=1000;
+ int occurence=10000;
phydbl nb=0.0;
- phydbl res;
+ phydbl res,*pi;
int site;
phydbl lk0=0.0;
phydbl lk1=0.0;
phydbl lk2=0.0;
- phydbl buff = -1.;
int position = -1;
+ t_tree *buff_tree;
+ int* samples;
- //1000 times
- For(i,occurence)
+ /*! 1000 times */
+ for(i=0;idata->init_len)
- {
- buff = rand();
- buff /= (RAND_MAX+1.);
-/* buff *= tree->data->crunch_len; */
- buff *= tree->data->init_len;
- position = (int)floor(buff);
-
- lk0+=tree->log_lks_aLRT[0][position];
- lk1+=tree->log_lks_aLRT[1][position];
- lk2+=tree->log_lks_aLRT[2][position];
- }
- if (lk0>=lk1 && lk0>=lk2) nb++;
+
+ /*! Shuffle the data and increment the support, if needed */
+ buff_tree = tree;
+ do
+ {
+ pi = (phydbl *)mCalloc(tree->data->crunch_len,sizeof(phydbl));
+ for(site=0;siten_pattern;site++) pi[site] = tree->data->wght[site] / (phydbl)tree->data->init_len;
+
+ samples = Sample_n_i_With_Proba_pi(pi,tree->n_pattern,tree->data->init_len);
+ For(site, tree->data->init_len)
+ {
+ position = samples[site];
+ lk0+=tree->log_lks_aLRT[0][position];
+ lk1+=tree->log_lks_aLRT[1][position];
+ lk2+=tree->log_lks_aLRT[2][position];
+ }
+ if (lk0>=lk1 && lk0>=lk2) nb++;
+ tree = tree->next_mixt;
+ Free(samples);
+ Free(pi);
+ }
+ while(tree);
+ tree = buff_tree;
}
res= nb/(phydbl)occurence;
return res;
}
-/*********************************************************/
-/**
-* deprecated
-* Compute a SH-like support, using the latest tested branch
-* param tree: the tested tree
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+/*!
+ Compute a SH-like support, using the latest tested branch
+ param tree: the tested tree
*/
-phydbl Statistics_To_SH(arbre *tree)
+phydbl Statistics_To_SH(t_tree *tree)
{
int i;
- int occurence=1000;
+ int occurence=10000;
phydbl nb=0.0;
phydbl res;
int site;
@@ -1114,125 +1139,148 @@ phydbl Statistics_To_SH(arbre *tree)
phydbl c0=0.0;
phydbl c1=0.0;
phydbl c2=0.0;
- phydbl buff=-1.;
int position=-1;
phydbl delta_local=-1.;
+ phydbl delta=0.0;
+ t_tree *buff_tree;
+ phydbl *pi;
+ int* samples;
+
+ /*! Compute the total log-lk of each NNI position */
+ buff_tree = tree;
+ do
+ {
+ For(site, tree->n_pattern)
+ {
+ c0+=tree->log_lks_aLRT[0][site] * tree->data->wght[site];
+ c1+=tree->log_lks_aLRT[1][site] * tree->data->wght[site];
+ c2+=tree->log_lks_aLRT[2][site] * tree->data->wght[site];
+ }
+ tree = tree->next_mixt;
+ }
+ while(tree);
+ tree = buff_tree;
- //Compute the total log-lk of each NNI position
- For(site, tree->data->init_len)
+
+ if (c0>=c1 && c0>=c2)
+ {
+ if (c1>=c2)
+ {
+ delta=c0-c1;
+ }
+ else
+ {
+ delta=c0-c2;
+ }
+ }
+ else if(c1>=c0 && c1>=c2)
{
- c0+=tree->log_lks_aLRT[0][site];
- c1+=tree->log_lks_aLRT[1][site];
- c2+=tree->log_lks_aLRT[2][site];
+ if (c0>=c2)
+ {
+ delta=c1-c0;
+ }
+ else
+ {
+ delta=c1-c2;
+ }
}
- phydbl delta=0.0;
- if (c0>=c1 && c0>=c2)
- {
- if (c1>=c2)
- {
- delta=c0-c1;
- }
- else
- {
- delta=c0-c2;
- }
- }
- else if(c1>=c0 && c1>=c2)
- {
- if (c0>=c2)
- {
- delta=c1-c0;
- }
- else
- {
- delta=c1-c2;
- }
- }
+ else
+ {
+ if (c1>=c0)
+ {
+ delta=c2-c1;
+ }
else
- {
- if (c1>=c0)
-
- {
- delta=c2-c1;
- }
- else
- {
- delta=c2-c0;
- }
- }
- //1000 times
- For(i,occurence)
+ {
+ delta=c2-c0;
+ }
+ }
+
+ /*! 1000 times */
+ for(i=0;idata->init_len)
- {
- buff = rand();
- buff /= (RAND_MAX+1.);
- buff *= tree->data->init_len;
- position = (int)floor(buff);
-
- lk0+=tree->log_lks_aLRT[0][position];
- lk1+=tree->log_lks_aLRT[1][position];
- lk2+=tree->log_lks_aLRT[2][position];
- }
-
- //return to null hypothesis
+ buff_tree = tree;
+ do
+ {
+ pi = (phydbl *)mCalloc(tree->data->crunch_len,sizeof(phydbl));
+ for(site=0;siten_pattern;site++) pi[site] = tree->data->wght[site] / (phydbl)tree->data->init_len;
+
+ samples = Sample_n_i_With_Proba_pi(pi,tree->n_pattern,tree->data->init_len);
+ /*! Shuffle the data */
+ For(site, tree->data->init_len)
+ {
+ position = samples[site];
+ lk0+=tree->log_lks_aLRT[0][position];
+ lk1+=tree->log_lks_aLRT[1][position];
+ lk2+=tree->log_lks_aLRT[2][position];
+ }
+
+ tree = tree->next_mixt;
+ Free(samples);
+ Free(pi);
+ }
+ while(tree);
+ tree = buff_tree;
+
+ /*! return to null hypothesis */
lk0=lk0-c0;
lk1=lk1-c1;
lk2=lk2-c2;
- //compute results and increment if needed
+ /*! compute results and increment if needed */
delta_local=0.0;
if (lk0>=lk1 && lk0>=lk2)
- {
- if (lk1>=lk2)
- {
- delta_local=lk0-lk1;
- }
- else
- {
- delta_local=lk0-lk2;
- }
- }
+ {
+ if (lk1>=lk2)
+ {
+ delta_local=lk0-lk1;
+ }
+ else
+ {
+ delta_local=lk0-lk2;
+ }
+ }
else if(lk1>=lk0 && lk1>=lk2)
- {
- if (lk0>=lk2)
- {
- delta_local=lk1-lk0;
- }
- else
- {
- delta_local=lk1-lk2;
- }
- }
+ {
+ if (lk0>=lk2)
+ {
+ delta_local=lk1-lk0;
+ }
+ else
+ {
+ delta_local=lk1-lk2;
+ }
+ }
else
- {
- if (lk1>=lk0)
-
- {
- delta_local=lk2-lk1;
- }
- else
- {
- delta_local=lk2-lk0;
- }
- }
-
- if (delta>(delta_local+0.1)) {
- nb++;
- }
- }
-
+ {
+ if (lk1>=lk0)
+ {
+ delta_local=lk2-lk1;
+ }
+ else
+ {
+ delta_local=lk2-lk0;
+ }
+ }
+
+ if (delta>(delta_local+0.1))
+ {
+ nb++;
+ }
+ }
+
res= nb/occurence;
-
+
return res;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
/**
* deprecated
* Compute one side likelihood
@@ -1240,22 +1288,34 @@ phydbl Statistics_To_SH(arbre *tree)
* param tree : b_fcus tree
* param exclude : side to exclude for computation
*/
-phydbl Update_Lk_At_Given_Edge_Excluding(edge *b_fcus, arbre *tree, node *exclude)
+phydbl Update_Lk_At_Given_Edge_Excluding(t_edge *b_fcus, t_tree *tree, t_node *exclude)
{
if((!b_fcus->left->tax) && (exclude == NULL || exclude != b_fcus->left))
- Update_P_Lk(tree,b_fcus,b_fcus->left);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->left);
if((!b_fcus->rght->tax) && (exclude == NULL || exclude != b_fcus->rght))
- Update_P_Lk(tree,b_fcus,b_fcus->rght);
+ Update_Partial_Lk(tree,b_fcus,b_fcus->rght);
- tree->c_lnL = Lk_At_Given_Edge(b_fcus,tree);
+ tree->c_lnL = Lk(b_fcus,tree);
return tree->c_lnL;
}
-/*********************************************************/
-/*********************************************************/
-/*********************************************************/
-/*********************************************************/
-/*********************************************************/
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
diff --git a/phyml/alrt.h b/phyml/alrt.h
index 8815d7b..2a211fe 100644
--- a/phyml/alrt.h
+++ b/phyml/alrt.h
@@ -10,17 +10,27 @@ the GNU public licence. See http://www.opensource.org for details.
*/
+#include
+
#ifndef ALRT_H
#define ALRT_H
-void aLRT(arbre *tree);
-int Check_NNI_Five_Branches(arbre *tree);
-int Compute_Likelihood_Ratio_Test(edge *tested_edge, arbre *tree);
-int NNI_Neigh_BL(edge *b_fcus, arbre *tree);
-void Make_Target_Swap(arbre *tree, edge *b_fcus, int swaptodo);
+#include "utilities.h"
+#include "lk.h"
+#include "optimiz.h"
+#include "models.h"
+#include "free.h"
+#include "simu.h"
+
+
+void aLRT(t_tree *tree);
+int Check_NNI_Five_Branches(t_tree *tree);
+int Compute_Likelihood_Ratio_Test(t_edge *tested_edge, t_tree *tree);
+int NNI_Neigh_BL(t_edge *b_fcus, t_tree *tree);
+void Make_Target_Swap(t_tree *tree, t_edge *b_fcus, int swaptodo);
phydbl Statistics_To_Probabilities(phydbl in);
-phydbl Statistics_To_RELL(arbre *tree);
-phydbl Statistics_To_SH(arbre *tree);
-phydbl Update_Lk_At_Given_Edge_Excluding(edge *b_fcus, arbre *tree, node *exclude);
+phydbl Statistics_To_RELL(t_tree *tree);
+phydbl Statistics_To_SH(t_tree *tree);
+phydbl Update_Lk_At_Given_Edge_Excluding(t_edge *b_fcus, t_tree *tree, t_node *exclude);
#endif
diff --git a/phyml/ancestral.c b/phyml/ancestral.c
new file mode 100644
index 0000000..65d87c7
--- /dev/null
+++ b/phyml/ancestral.c
@@ -0,0 +1,1071 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+#include "ancestral.h"
+
+void Sample_Ancestral_Seq(int fullmutmap, int fromprior, t_tree *tree)
+{
+ int rate_cat;
+ int i,j,k,l;
+ phydbl *probs;
+ phydbl sum;
+ int n_mut;
+ FILE *fp;
+ phydbl *muttime;
+ int *muttype,*muttax;
+ char *s,*mut_string;
+ int *ordering;
+
+
+ if(tree->is_mixt_tree == YES)
+ {
+ MIXT_Sample_Ancestral_Seq(fullmutmap,fromprior,tree);
+ return;
+ }
+
+ probs = (phydbl *)mCalloc(tree->mod->ras->n_catg,sizeof(phydbl));
+
+ muttime = (phydbl *)mCalloc((2*tree->n_otu-3)*5, // At most 5 mutations per branch on average
+ sizeof(phydbl));
+
+ muttype = (int *)mCalloc((2*tree->n_otu-3)*5, // At most 5 mutations per branch on average
+ sizeof(int));
+
+ muttax = (int *)mCalloc((2*tree->n_otu-3)*5, // At most 5 mutations per branch on average
+ sizeof(int));
+
+ ordering = (int *)mCalloc((2*tree->n_otu-3)*5, // At most 5 mutations per branch on average
+ sizeof(int));
+
+ s = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+
+ for(i=0;i<2*tree->n_otu-1;++i)
+ if(tree->a_nodes[i]->tax == NO)
+ {
+ tree->a_nodes[i]->c_seq_anc = (align *)mCalloc(1,sizeof(align));;
+ tree->a_nodes[i]->c_seq_anc->state = (char *)mCalloc(tree->n_pattern,sizeof(char));
+ }
+
+
+ /* Update P(D_x|X=i) for each state i and node X */
+ Set_Both_Sides(YES,tree);
+ Lk(NULL,tree);
+
+
+ for(i=0;in_pattern;++i)
+ {
+ /* Sample the rate class from its posterior density */
+ for(j=0;jmod->ras->n_catg;j++)
+ {
+ if(fromprior == NO)
+ probs[j] =
+ tree->unscaled_site_lk_cat[i*tree->mod->ras->n_catg+j]*
+ tree->mod->ras->gamma_r_proba->v[j];
+ else
+ probs[j] = tree->mod->ras->gamma_r_proba->v[j];
+ }
+
+ /* Scale probas. */
+ sum = .0;
+ for(j=0;jmod->ras->n_catg;j++) sum += probs[j];
+ for(j=0;jmod->ras->n_catg;j++) probs[j]/=sum;
+
+ rate_cat = Sample_i_With_Proba_pi(probs,tree->mod->ras->n_catg);
+
+ n_mut = 0;
+ if(tree->n_root != NULL)
+ {
+ Sample_Ancestral_Seq_Pre(tree->n_root,tree->n_root->v[1],tree->n_root->b[1],
+ i,rate_cat,
+ muttype,muttime,muttax,&n_mut,
+ fullmutmap,fromprior,tree);
+
+
+ Sample_Ancestral_Seq_Pre(tree->n_root,tree->n_root->v[2],tree->n_root->b[2],
+ i,rate_cat,
+ muttype,muttime,muttax,&n_mut,
+ fullmutmap,fromprior,tree);
+
+
+ }
+ else
+ {
+ Sample_Ancestral_Seq_Pre(tree->a_nodes[0],tree->a_nodes[0]->v[0],tree->a_nodes[0]->b[0],
+ i,rate_cat,
+ muttype,muttime,muttax,&n_mut,
+ fullmutmap,fromprior,tree);
+ }
+
+ for(j=0;j muttime[j]) ordering[k]++;
+ else ordering[j]++;
+ }
+ }
+
+ strcpy(s,"mutmap.");
+ sprintf(s+strlen(s),"%d.",tree->io->r_seed);
+ sprintf(s+strlen(s),"%d",i);
+ fp = fopen(s,"a");
+ PhyML_Fprintf(fp,"\n-1 -1 -1.0 -1 %d",tree->mixt_tree ? tree->mixt_tree->mcmc->run : tree->mcmc->run);
+
+ Reverse_Muttime(muttime,n_mut,tree);
+
+ for(j=0;jdata->init_len;l++) if(tree->data->sitepatt[l] == i) break;
+ mut_string = Mutation_Id(muttype[k],tree);
+ PhyML_Fprintf(fp,"\n%4d %s %g %4d %s",j,mut_string,muttime[k],l,tree->a_nodes[muttax[k]]->name);
+ Free(mut_string);
+ break;
+ }
+ }
+ }
+
+
+ for(j=0;j> a: %d d: %d b->left: %d b->rght: %d",a?a->num:-1,d?d->num:-1,b?b->left->num:-1,b?b->rght->num:-1); */
+
+ ns = tree->mod->ns;
+
+ probs = (phydbl *)mCalloc(ns,sizeof(phydbl));
+
+ if(a->tax == TRUE) // Sample state at tip if observed state is ambiguous
+ {
+ assert(b);
+ if(a == b->left) for(i=0;ip_lk_tip_l[site*ns+i];
+ else for(i=0;ip_lk_tip_r[site*ns+i];
+ for(i=0;imod->e_frq->pi->v[i];
+ sum = 0.0;
+ for(i=0;in_root)
+ {
+ sa = Sample_Ancestral_Seq_Core(NULL,tree->n_root,NULL,r_cat,site,tree);
+ }
+ else
+ {
+ sa = Assign_State(a->c_seq_anc->state + site,
+ tree->mod->io->datatype,
+ tree->mod->io->state_len);
+ }
+
+ sd = Sample_Ancestral_Seq_Core(a,d,b,r_cat,site,tree);
+
+ if(fullmutmap == YES) Map_Mutations(a,d,sa,sd,b,site,r_cat,muttype,muttime,muttax,n_mut,tree);
+
+ if(d->tax) return;
+ else
+ {
+ for(i=0;i<3;++i)
+ {
+ if(d->v[i] != a && d->b[i] != tree->e_root)
+ {
+ Sample_Ancestral_Seq_Pre(d,d->v[i],d->b[i],site,r_cat,muttype,muttime,muttax,n_mut,fullmutmap,fromprior,tree);
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int Sample_Ancestral_Seq_Core(t_node *a, t_node *d, t_edge *b, int r_cat, int site, t_tree *tree)
+{
+ int i,j;
+ int ns;
+
+ ns = tree->mod->ns;
+
+ int dim1 = tree->mod->ras->n_catg * ns;
+ int dim2 = ns;
+ int dim3 = ns * ns;
+
+ phydbl *probs,*Pij,sum;
+
+ int state;
+
+
+ probs = (phydbl *)mCalloc(ns,sizeof(phydbl));
+ state = -1;
+
+ if(d->tax == YES)
+ {
+ assert(b);
+ if(d == b->left) for(i=0;ip_lk_tip_l[site*ns+i];
+ else if(d == b->rght) for(i=0;ip_lk_tip_r[site*ns+i];
+ else assert(FALSE);
+ for(i=0;imod->e_frq->pi->v[i];
+ sum = 0.0;
+ for(i=0;in_root);
+
+ phydbl r,l;
+
+ Update_PMat_At_Given_Edge(tree->n_root->b[1],tree);
+ Update_PMat_At_Given_Edge(tree->n_root->b[2],tree);
+
+ for(i=0;ie_root->left == tree->n_root->v[1])
+ Pij = tree->n_root->b[1]->Pij_rr;
+ else
+ Pij = tree->n_root->b[2]->Pij_rr;
+
+ l = 0.0;
+ for(j=0;je_root->left->tax == NO)
+ l += tree->e_root->p_lk_left[site*dim1+r_cat*dim2+j] * Pij[r_cat*dim3+i*dim2+j];
+ else
+ l += tree->e_root->p_lk_tip_l[site*dim2+j] * Pij[r_cat*dim3+i*dim2+j];
+ }
+
+
+ if(tree->e_root->rght == tree->n_root->v[1])
+ Pij = tree->n_root->b[1]->Pij_rr;
+ else
+ Pij = tree->n_root->b[2]->Pij_rr;
+
+ r = 0.0;
+ for(j=0;je_root->rght->tax == NO)
+ r += tree->e_root->p_lk_rght[site*dim1+r_cat*dim2+j] * Pij[r_cat*dim3+i*dim2+j];
+ else
+ r += tree->e_root->p_lk_tip_r[site*dim2+j] * Pij[r_cat*dim3+i*dim2+j];
+ }
+
+ probs[i] = r*l*tree->mod->e_frq->pi->v[i];
+ }
+
+ sum = 0.0;
+ for(i=0;ic_seq_anc->state[site] = Reciproc_Assign_State(state,tree->io->datatype);
+ }
+ else
+ {
+ assert(b);
+
+ // State (already) sampled at node a
+ state = Assign_State(a->c_seq_anc->state + site,
+ tree->mod->io->datatype,
+ tree->mod->io->state_len);
+
+ Pij = b->Pij_rr;
+
+ for(i=0;ileft)
+ probs[i] = b->p_lk_left[site*dim1+r_cat*dim2+i] * Pij[r_cat*dim3+state*dim2+i];
+ else if(d == b->rght)
+ probs[i] = b->p_lk_rght[site*dim1+r_cat*dim2+i] * Pij[r_cat*dim3+state*dim2+i];
+ else assert(FALSE);
+ }
+
+ sum = 0.0;
+ for(i=0;ic_seq_anc->state[site] = Reciproc_Assign_State(state,tree->io->datatype);
+ }
+ }
+
+ Free(probs);
+ return state;
+
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Map_Mutations(t_node *a, t_node *d, int sa, int sd, t_edge *b, int site, int rcat, int *muttype, phydbl *muttime, int *muttax, int *n_mut, t_tree *tree)
+{
+ int i,j;
+ phydbl *probs,*all_probs;
+ int slast,snew; // Last state visited
+ phydbl tlast;
+ phydbl *Q;
+ phydbl u,sum;
+ int *mut; // Array of mutations
+ int thismut;
+ int n_mut_branch;
+ int n_iter;
+ int first_mut;
+ phydbl T;
+ int ns,tax_idx;
+ phydbl rr;
+
+ ns = tree->mod->ns;
+
+ all_probs = (phydbl *)mCalloc(ns*ns,sizeof(phydbl));
+ mut = (int *)mCalloc(ns*ns,sizeof(int));
+
+ // Site relative rate
+ rr = tree->mod->ras->gamma_rr->v[rcat];
+
+ // Rate matrix
+ Q = tree->mod->r_mat->qmat->v;
+
+ // Length of the 'time' interval considered.
+ T = 0.0;
+#ifdef PHYTIME
+ T = tree->rates->cur_l[d->num]*rr;
+#else
+ T = b->l->v*rr;
+#endif
+
+
+ /* PhyML_Printf("\n. Mutmap: a:%d d:%d ta:%G td:%G cr:%G rr:%G l:%G", */
+ /* a?a->num:-1,d?d->num:-1, */
+ /* tree->rates->nd_t[a->num], */
+ /* tree->rates->nd_t[d->num], */
+ /* cr,rr, */
+ /* fabs(tree->rates->nd_t[a->num]-tree->rates->nd_t[d->num])*cr*rr); */
+
+ // Matrix of change probabilities
+ for(i=0;ii)=0.0;
+ all_probs[i*ns+i] = 0.0;
+
+ // Normalise so that \sum_j p(i->j) = 1.0;
+ sum = 0;
+ for(j=0;j sample a new mutation event
+ if(tlast < T)
+ {
+ first_mut = NO;
+
+ n_mut_branch++;
+
+ if(n_mut_branch > 5 && n_mut_branch%10 == 0)
+ PhyML_Printf("\n. # of mutations on edge %d (length: %g) exceeds 5 (%d) ! The program will probably crash soon...:(",
+ b->num,
+ tree->rates ? tree->rates->cur_l[d->num] : b->l->v,
+ n_mut_branch);
+
+ snew = Sample_i_With_Proba_pi(probs,ns);
+
+ // Record mutation type
+ mut[slast*ns+snew]++;
+
+ // Record mutation type in the site mutation array
+ thismut = slast*ns+snew;
+
+ muttype[(*n_mut)+n_mut_branch-1] = thismut;
+
+ // Record time of mutation
+ muttime[(*n_mut)+n_mut_branch-1] = tlast;
+
+#ifdef PHYTIME
+ // Transform into time in calendar units
+ muttime[(*n_mut)+n_mut_branch-1] /= tree->rates->cur_l[d->num];
+ muttime[(*n_mut)+n_mut_branch-1] *= fabs(tree->rates->nd_t[a->num]-tree->rates->nd_t[d->num]);
+#endif
+
+ tax_idx = -1;
+ Random_Tax_Idx(a,d,&tax_idx,tree);
+ muttax[(*n_mut)+n_mut_branch-1] = tax_idx;
+
+ // Update the last state
+ slast = snew;
+ }
+ else
+ {
+ if(slast == sd) break;
+ else
+ {
+ // Restart from the beginning
+ for(i=0;i 0) */
+ /* { */
+ /* thismut = MIN(i,j) * ns + MAX(i,j) - (MIN(i,j)+1+(int)POW(MIN(i,j)+1,2))/2; */
+
+ /* if(tree->mixt_tree != NULL) */
+ /* tree->mixt_tree->mutmap[thismut*(tree->n_pattern)*(2*tree->n_otu-3) + b->num*(tree->n_pattern) + site]++; */
+ /* else */
+ /* tree->mutmap[thismut*(tree->n_pattern)*(2*tree->n_otu-3) + b->num*(tree->n_pattern) + site]++; */
+ /* } */
+ /* } */
+ /* } */
+
+ Free(all_probs);
+ Free(mut);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void Ancestral_Sequences(t_tree *tree, int print)
+{
+ int i;
+
+ if(print == YES)
+ {
+
+ PhyML_Printf("\n\n. Estimating ancestral sequences...");
+
+ strcpy(tree->io->out_ancestral_seq_file,tree->io->out_file);
+ strcat(tree->io->out_ancestral_seq_file,"_phyml_ancestral_");
+ if(tree->io->append_run_ID)
+ {
+ strcat(tree->io->out_ancestral_seq_file,tree->io->run_id_string);
+ strcat(tree->io->out_ancestral_seq_file,"_");
+ }
+ strcat(tree->io->out_ancestral_seq_file,"seq.txt");
+ tree->io->fp_out_ancestral_seq = Openfile(tree->io->out_ancestral_seq_file,1);
+
+
+ strcpy(tree->io->out_ancestral_tree_file,tree->io->out_file);
+ strcat(tree->io->out_ancestral_tree_file,"_phyml_ancestral_");
+ if(tree->io->append_run_ID)
+ {
+ strcat(tree->io->out_ancestral_tree_file,tree->io->run_id_string);
+ strcat(tree->io->out_ancestral_tree_file,"_");
+ }
+ strcat(tree->io->out_ancestral_tree_file,"tree.txt");
+ tree->io->fp_out_ancestral_tree = Openfile(tree->io->out_ancestral_tree_file,1);
+
+
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n\n\n");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. Printing marginal probabilities of ancestral sequences at each site");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. of the alignment and each node of the tree. The tree in Newick format");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. with internal nodes labels corresponding to those given below can be");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. found in the file '%s'.",tree->io->out_ancestral_tree_file);
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. Ancestral reconstruction is conducted based on the \"Minimum Posterior Expected");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. Error\" (MPEE) criterion, which accomodates for uncertainty in the selection of ");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. ancestral character states.");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. Recommended citation:");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. Oliva A., Pulicani S., Lefort V., Brehelin L., Gascuel O. and S. Guindon,");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. \"Accounting for ambiguity in ancestral sequence reconstruction\",");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n. Bioinformatics, Volume 35, Issue 21, 1 November 2019.");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n");
+
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n\n");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"Site\tNodeLabel\t");
+ for(i=0;imod->ns;i++) PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"%10c\t",Reciproc_Assign_State(i,tree->io->datatype));
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"MPEE\t");
+ PhyML_Fprintf(tree->io->fp_out_ancestral_seq,"\n");
+
+
+ short int bck_support = tree->io->print_support_val;
+
+ tree->io->print_node_num = YES;
+ tree->io->print_support_val = NO;
+ char *s = Write_Tree(tree);
+ PhyML_Fprintf(tree->io->fp_out_ancestral_tree,"%s",s);
+ tree->io->print_node_num = NO;
+ tree->io->print_support_val = bck_support;
+
+ Free(s);
+ fclose(tree->io->fp_out_ancestral_tree);
+ }
+
+ for(i=0;i<2*tree->n_otu-2;i++)
+ if(tree->a_nodes[i]->tax == NO)
+ Ancestral_Sequences_One_Node(tree->a_nodes[i],tree,print);
+
+ if(tree->n_root) Ancestral_Sequences_One_Node(tree->n_root,tree,print);
+
+
+ fclose(tree->io->fp_out_ancestral_seq);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Ancestral_Sequences_One_Node(t_node *d, t_tree *tree, int print)
+{
+ if(d->tax) return;
+ else
+ {
+ if(tree->is_mixt_tree)
+ {
+ MIXT_Ancestral_Sequences_One_Node(d,tree,print);
+ }
+ else
+ {
+ t_node *v0,*v1,*v2; // three neighbours of d
+ t_edge *b0,*b1,*b2;
+ int i,j;
+ int catg;
+ phydbl p0, p1, p2;
+ phydbl *p;
+ int site,csite;
+ phydbl *p_lk0, *p_lk1, *p_lk2;
+ int *sum_scale0, *sum_scale1, *sum_scale2;
+ phydbl sum_probas;
+ phydbl *Pij0, *Pij1, *Pij2;
+ phydbl inc,sum_scale;
+ FILE *fp;
+
+ unsigned const int ncatg = tree->mod->ras->n_catg;
+ unsigned const int ns = tree->mod->ns;
+ unsigned const int nsns = ns*ns;
+ unsigned const int ncatgns = ns*ncatg;
+
+
+ if(tree->scaling_method == SCALE_RATE_SPECIFIC)
+ {
+ PhyML_Fprintf(stderr,"\n. Likelihood rescaling method not compatible with the calculation of ancestral state probabilities.");
+ Exit("\n");
+ }
+
+
+ if(!d) return;
+
+ fp = tree->io->fp_out_ancestral_seq;
+ assert(fp != NULL);
+
+
+ p = (phydbl *)mCalloc(ns,sizeof(phydbl));
+
+ for(site=0;sitedata->init_len;site++) // For each site in the current partition element
+ {
+ csite = tree->data->sitepatt[site];
+
+ for(i=0;iv[0];
+ v1 = d->v[1];
+ v2 = d->v[2];
+
+ b0 = d->b[0];
+ b1 = d->b[1];
+ b2 = d->b[2];
+
+ Pij0 = b0->Pij_rr;
+ Pij1 = b1->Pij_rr;
+ Pij2 = b2->Pij_rr;
+
+ sum_scale = 0.0;
+
+ if(v0 == b0->left)
+ {
+ p_lk0 = b0->p_lk_left;
+ sum_scale0 = b0->sum_scale_left;
+ }
+ else
+ {
+ p_lk0 = b0->p_lk_rght;
+ sum_scale0 = b0->sum_scale_rght;
+ }
+
+ if(v1 == b1->left)
+ {
+ p_lk1 = b1->p_lk_left;
+ sum_scale1 = b1->sum_scale_left;
+ }
+ else
+ {
+ p_lk1 = b1->p_lk_rght;
+ sum_scale1 = b1->sum_scale_rght;
+ }
+
+ if(v2 == b2->left)
+ {
+ p_lk2 = b2->p_lk_left;
+ sum_scale2 = b2->sum_scale_left;
+ }
+ else
+ {
+ p_lk2 = b2->p_lk_rght;
+ sum_scale2 = b2->sum_scale_rght;
+ }
+
+
+ for(catg=0;catgtax)
+ {
+ for(j=0;jb[0]->p_lk_tip_r[csite*ns+j] * Pij0[catg*nsns+i*ns+j];
+
+ if(isinf(p0) || isnan(p0))
+ {
+ PhyML_Fprintf(stderr,"\n. p0: %G v0->b[0]->p_lk_tip_r[csite*ns+j]: %G Pij0[catg*nsns+i*ns+j]: %G\n",
+ p0,
+ v0->b[0]->p_lk_tip_r[csite*ns+j],
+ Pij0[catg*nsns+i*ns+j]);
+ Exit("\n");
+ }
+ }
+ }
+ else
+ {
+ for(j=0;jtax)
+ {
+ for(j=0;jb[0]->p_lk_tip_r[csite*ns+j] * Pij1[catg*nsns+i*ns+j];
+
+ if(isinf(p1) || isnan(p1))
+ {
+ PhyML_Fprintf(stderr,"\n. p1: %G v1->b[0]->p_lk_tip_r[csite*ns+j]: %G Pij1[catg*nsns+i*ns+j]: %G\n",
+ p1,
+ v1->b[0]->p_lk_tip_r[csite*ns+j],
+ Pij1[catg*nsns+i*ns+j]);
+ Exit("\n");
+ }
+ }
+ }
+ else
+ {
+ for(j=0;jtax)
+ {
+ for(j=0;jb[0]->p_lk_tip_r[csite*ns+j] * Pij2[catg*nsns+i*ns+j];
+ }
+ }
+ else
+ {
+ for(j=0;jmod->e_frq->pi->v[i] *
+ tree->mod->ras->gamma_r_proba->v[catg];
+
+ p[i] += inc;
+
+
+ if(isinf(p[i]) || isnan(p[i]))
+ {
+ PhyML_Fprintf(stderr,"\n. site: %4d p0: %G p1: %G p2: %G tree->mod->e_frq->pi->v[i]: %G tree->cur_site_lk[csite]: %G tree->mod->ras->gamma_r_proba->v[catg]: %G tree->c_lnL_sorted[csite]: %G",
+ csite,
+ p0,p1,p2,
+ tree->mod->e_frq->pi->v[i] ,
+ tree->cur_site_lk[csite] ,
+ tree->mod->ras->gamma_r_proba->v[catg],
+ tree->c_lnL_sorted[csite]);
+ Exit("\n");
+ }
+ }
+
+ /* printf("\n. site: %d || %d %d %d", */
+ /* csite, */
+ /* v0->tax ? -1 : sum_scale0[csite*ncatg+catg], */
+ /* v1->tax ? -1 : sum_scale1[csite*ncatg+catg], */
+ /* v2->tax ? -1 : sum_scale2[csite*ncatg+catg]); */
+
+ }
+
+ if(tree->mod->ras->invar == YES)
+ {
+ int num_prec_issue = NO;
+ phydbl inv_site_lk = Invariant_Lk(sum_scale,csite,&num_prec_issue,tree);
+
+
+ switch(num_prec_issue)
+ {
+ case YES :
+ {
+ assert(isinf(inv_site_lk));
+ inv_site_lk = Invariant_Lk(0,csite,&num_prec_issue,tree);
+ for(i=0;imod->ras->pinvar->v * tree->mod->e_frq->pi->v[i];
+ break;
+ }
+ case NO :
+ {
+ for(i=0;imod->ras->pinvar->v) + inv_site_lk * tree->mod->ras->pinvar->v * tree->mod->e_frq->pi->v[i];
+ break;
+ }
+ }
+
+ }
+
+
+ for(i=0;ic_lnL_sorted[csite];
+ for(i=0;inum);
+ for(i=0;i highest_count)
+ {
+ highest_count = count[i];
+ highest_count_idx = i;
+ }
+ }
+
+ most_frequent_state = best_state[highest_count_idx];
+
+ Free(alpha);
+ Free(best_state);
+ Free(idx);
+ Free(count);
+
+ return(most_frequent_state);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int MPEE_Score(const phydbl *alpha, int *idx, const phydbl *p, const int ns)
+{
+ unsigned int i;
+ phydbl *mpee_score,*cdf_sorted;
+ int min_idx,res;
+ phydbl a,b;
+ phydbl min;
+
+ mpee_score = (phydbl *)mCalloc(ns,sizeof(phydbl));
+ cdf_sorted = (phydbl *)mCalloc(ns,sizeof(phydbl));
+
+
+ cdf_sorted[0] = p[idx[0]];
+ for(i=1;i
+
+#ifndef ANCESTRAL_H
+#define ANCESTRAL_H
+
+#include "utilities.h"
+
+
+void Sample_Ancestral_Seq(int fullmutmap, int fromprior, t_tree *tree);
+void Sample_Ancestral_Seq_Pre(t_node *a, t_node *d, t_edge *b,
+ int site, int r_cat,
+ int *muttype, phydbl *muttime, int *muttax, int *n_mut,
+ int fullmutmap, int fromprior, t_tree *tree);
+int Sample_Ancestral_Seq_Core(t_node *a, t_node *d, t_edge *b, int r_cat, int site, t_tree *tree);
+void Map_Mutations(t_node *a, t_node *d, int sa, int sd, t_edge *b, int site, int rcat, int *muttype, phydbl *muttime, int *muttax, int *n_mut, t_tree *tree);
+void Ancestral_Sequences(t_tree *tree, int print);
+void Ancestral_Sequences_One_Node(t_node *d, t_tree *tree, int print);
+int MPEE_Score(const phydbl *alpha, int *idx, const phydbl *p, const int ns);
+int MPEE_Infer(const phydbl *p, const int ns);
+void Reverse_Muttime(phydbl *muttime, int n_mut, t_tree *tree);
+
+#endif
diff --git a/phyml/avx.c b/phyml/avx.c
new file mode 100644
index 0000000..69e404a
--- /dev/null
+++ b/phyml/avx.c
@@ -0,0 +1,669 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+#include "assert.h"
+#include "avx.h"
+
+#if defined(__AVX__)
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void AVX_Update_Eigen_Lr(t_edge *b, t_tree *tree)
+{
+ unsigned int site,catg;
+ unsigned int i,j;
+
+ unsigned const int npattern = tree->n_pattern;
+ unsigned const int ncatg = tree->mod->ras->n_catg;
+ unsigned const int ns = tree->mod->ns;
+ unsigned const int sz = (int)BYTE_ALIGN / 8;
+ unsigned const int nblocks = ns / sz;
+ unsigned const int ncatgns = ncatg*ns;
+
+ const phydbl *p_lk_left,*p_lk_rght,*pi;
+ phydbl *dot_prod,*p_lk_left_pi;
+ phydbl *l_ev,*r_ev;
+
+ __m256d *_l_ev,*_r_ev,*_prod_left,*_prod_rght;
+
+#ifndef WIN32
+ if(posix_memalign((void **)&p_lk_left_pi,BYTE_ALIGN,(size_t) ns * sizeof(phydbl))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&l_ev,BYTE_ALIGN,(size_t) ns * ns * sizeof(phydbl))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_l_ev,BYTE_ALIGN,(size_t) ns * ns / sz * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_r_ev,BYTE_ALIGN,(size_t) ns * ns / sz * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_prod_left,BYTE_ALIGN,(size_t) ns / sz * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_prod_rght,BYTE_ALIGN,(size_t) ns / sz * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+#else
+ p_lk_left_pi = _aligned_malloc(ns * sizeof(phydbl),BYTE_ALIGN);
+ l_ev = _aligned_malloc(ns * ns * sizeof(phydbl),BYTE_ALIGN);
+ _l_ev = _aligned_malloc(ns * ns / sz * sizeof(__m256d),BYTE_ALIGN);
+ _r_ev = _aligned_malloc(ns * ns / sz * sizeof(__m256d),BYTE_ALIGN);
+ _prod_left = _aligned_malloc(ns / sz * sizeof(__m256d),BYTE_ALIGN);
+ _prod_rght = _aligned_malloc(ns / sz * sizeof(__m256d),BYTE_ALIGN);
+#endif
+
+
+ assert(sz == 4);
+ assert(tree->update_eigen_lr == YES);
+
+ r_ev = tree->mod->eigen->r_e_vect;
+
+ /* Copy transpose of matrix of left eigen vectors */
+ for(i=0;imod->eigen->l_e_vect[j*ns+i];
+
+ /* Load into AVX registers */
+ for(i=0;ileft->tax ? b->p_lk_tip_l : b->p_lk_left;
+ p_lk_rght = b->rght->tax ? b->p_lk_tip_r : b->p_lk_rght;
+ pi = tree->mod->e_frq->pi->v;
+ dot_prod = tree->dot_prod;
+
+ for(site=0;sitedata->wght[site] > SMALL)
+ {
+ for(catg=0;catgleft->tax == NO) p_lk_left += ns;
+ if(b->rght->tax == NO) p_lk_rght += ns;
+ }
+
+ if(b->left->tax == YES) p_lk_left += ns;
+ if(b->rght->tax == YES) p_lk_rght += ns;
+ }
+ else
+ {
+ if(b->left->tax == YES) p_lk_left += ns;
+ else p_lk_left += ncatgns;
+
+ if(b->rght->tax == YES) p_lk_rght += ns;
+ else p_lk_rght += ncatgns;
+
+ dot_prod += ncatgns;
+ }
+ }
+
+ Free(l_ev);
+ Free(_l_ev);
+ Free(_r_ev);
+ Free(_prod_left);
+ Free(_prod_rght);
+ Free(p_lk_left_pi);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl AVX_Lk_Core_One_Class_No_Eigen_Lr(const phydbl *p_lk_left, const phydbl *p_lk_rght, const phydbl *Pij, const phydbl *tPij, const phydbl *pi, const int ns, const int ambiguity_check, const int observed_state)
+{
+ const unsigned int sz = (int)BYTE_ALIGN / 8;
+ const unsigned nblocks = ns/sz;
+
+ if(nblocks == 1)
+ {
+ __m256d _plk_r,_plk_l;
+
+ if(ambiguity_check == NO) // tip case.
+ {
+ Pij += observed_state*ns;
+ _plk_r = _mm256_mul_pd(_mm256_load_pd(Pij),_mm256_load_pd(p_lk_left));
+ return pi[observed_state] * AVX_Vect_Norm(_plk_r);
+ }
+ else
+ {
+ unsigned int i;
+ __m256d _pijplk,_pij;
+
+ _plk_r = _mm256_mul_pd(_mm256_load_pd(p_lk_rght),_mm256_load_pd(pi));
+ _pijplk = _mm256_setzero_pd();
+
+ for(i=0;in_pattern;
+ const unsigned int ns = tree->mod->ns;
+ const unsigned int ncatg = tree->mod->ras->n_catg;
+
+ const unsigned int ncatgns = ncatg * ns;
+ const unsigned int nsns = ns * ns;
+
+ const unsigned int sz = (int)BYTE_ALIGN / 8;
+ const unsigned nblocks = ns/sz;
+
+ __m256d *_tPij1,*_tPij2,*_pmat1plk1,*_pmat2plk2,*_plk0,*_init_tPij1,*_init_tPij2;
+
+
+#ifndef WIN32
+ if(posix_memalign((void **)&_tPij1,BYTE_ALIGN,(size_t)(ncatg * nsns / sz) * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_tPij2,BYTE_ALIGN,(size_t)(ncatg * nsns / sz) * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_pmat1plk1,BYTE_ALIGN,(size_t)ns / sz * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_pmat2plk2,BYTE_ALIGN,(size_t)ns / sz * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ if(posix_memalign((void **)&_plk0,BYTE_ALIGN,(size_t)(ns / sz) * sizeof(__m256d))) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+#else
+ _tPij1 = _aligned_malloc(ncatg * nsns / sz * sizeof(__m256d),BYTE_ALIGN);
+ _tPij2 = _aligned_malloc(ncatg * nsns / sz * sizeof(__m256d),BYTE_ALIGN);
+ tPij1 = _aligned_malloc(ncatg * nsns / sz * sizeof(__m256d),BYTE_ALIGN);
+ tPij2 = _aligned_malloc(ncatg * nsns / sz * sizeof(__m256d),BYTE_ALIGN);
+ _pmat1plk1 = _aligned_malloc(ns / sz * sizeof(__m256d),BYTE_ALIGN);
+ _pmat2plk2 = _aligned_malloc(ns / sz * sizeof(__m256d),BYTE_ALIGN);
+ _plk0 = _aligned_malloc(ns / sz * sizeof(__m256d),BYTE_ALIGN);
+#endif
+
+ _init_tPij1 = _tPij1;
+ _init_tPij2 = _tPij2;
+
+ sum_scale_v1_val = 0;
+ sum_scale_v2_val = 0;
+ n_v1 = n_v2 = NULL;
+ plk0 = plk1 = plk2 = NULL;
+ Pij1 = Pij2 = NULL;
+ tPij1 = tPij2 = NULL;
+ sum_scale_v1 = sum_scale_v2 = NULL;
+ p_lk_loc = NULL;
+ state_v1 = state_v2 = -1;
+
+
+ Set_All_Partial_Lk(&n_v1,&n_v2,
+ &plk0,&sum_scale,&p_lk_loc,
+ &Pij1,&tPij1,&plk1,&sum_scale_v1,
+ &Pij2,&tPij2,&plk2,&sum_scale_v2,
+ d,b,tree);
+
+ // Copy transpose of transition matrices into AVX registers
+ for(i=0;imod->augmented == YES)
+ {
+ PhyML_Printf("\n== AVX version of the Update_Partial_Lk function does not");
+ PhyML_Printf("\n== allow augmented data.");
+ assert(FALSE);
+ }
+
+ /* For every site in the alignment */
+ for(site=0;sitedata->wght[site] > SMALL)
+ {
+ state_v1 = state_v2 = -1;
+ ambiguity_check_v1 = ambiguity_check_v2 = YES;
+
+ if(n_v1 && n_v1->tax)
+ {
+ ambiguity_check_v1 = n_v1->c_seq->is_ambigu[site];
+ if(ambiguity_check_v1 == NO) state_v1 = n_v1->c_seq->d_state[site];
+ }
+
+ if(n_v2 && n_v2->tax)
+ {
+ ambiguity_check_v2 = n_v2->c_seq->is_ambigu[site];
+ if(ambiguity_check_v2 == NO) state_v2 = n_v2->c_seq->d_state[site];
+ }
+
+ _tPij1 = _init_tPij1;
+ _tPij2 = _init_tPij2;
+
+ for(catg=0;catgtax) ? 0 : ns;
+ plk2 += (n_v2->tax) ? 0 : ns;
+ }
+
+ plk1 += (n_v1->tax) ? ns : 0;
+ plk2 += (n_v2->tax) ? ns : 0;
+
+ if(tree->scaling_method == SCALE_FAST)
+ {
+ sum_scale_v1_val = (sum_scale_v1)?(sum_scale_v1[site]):(0);
+ sum_scale_v2_val = (sum_scale_v2)?(sum_scale_v2[site]):(0);
+ sum_scale[site] = sum_scale_v1_val + sum_scale_v2_val;
+
+ if(sum_scale[site] >= 1024)
+ {
+ /* plk0 -= ncatgns; */
+ /* plk1 -= (n_v1->tax) ? ns : ncatgns; */
+ /* plk2 -= (n_v2->tax) ? ns : ncatgns; */
+ /* PhyML_Fprintf(stderr,"\n. PARTIAL site: %d plk0: %p [%g %g %g %g] plk1: %p [%g %g %g %g] plk2: %p [%g %g %g %g]", */
+ /* site, */
+ /* plk0, */
+ /* plk0[0], */
+ /* plk0[1], */
+ /* plk0[2], */
+ /* plk0[3], */
+ /* plk1, */
+ /* plk1[0], */
+ /* plk1[1], */
+ /* plk1[2], */
+ /* plk1[3], */
+ /* plk2, */
+ /* plk2[0], */
+ /* plk2[1], */
+ /* plk2[2], */
+ /* plk2[3] */
+ /* ); */
+ /* PhyML_Fprintf(stderr,"\n. PARTIAL site: %d d: %d n_v1: %d n_v2: %d",site,d->num,n_v1->num,n_v2->num); */
+ /* PhyML_Fprintf(stderr,"\n. PARTIAL site: %d sum n: %d sum n_v1: %d sum n_v2: %d",site,sum_scale[site],sum_scale_v1_val,sum_scale_v2_val); */
+
+ /* plk0 += ncatgns; */
+ /* plk1 += (n_v1->tax) ? ns : ncatgns; */
+ /* plk2 += (n_v2->tax) ? ns : ncatgns; */
+ /* Exit("\n"); */
+ }
+
+ plk0 -= ncatgns;
+ largest_p_lk = -BIG;
+ for(i=0;i largest_p_lk)
+ largest_p_lk = plk0[i];
+
+ if(largest_p_lk < INV_TWO_TO_THE_LARGE &&
+ tree->mod->augmented == NO &&
+ tree->apply_lk_scaling == YES)
+ {
+ for(i=0;itax) ? ns : ncatgns;
+ plk2 += (n_v2->tax) ? ns : ncatgns;
+ }
+ }
+ Free(_init_tPij1);
+ Free(_init_tPij2);
+ Free(_pmat1plk1);
+ Free(_pmat2plk2);
+ Free(_plk0);
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void AVX_Partial_Lk_Exex(const __m256d *_tPij1, const int state1, const __m256d *_tPij2, const int state2, const int ns, __m256d *plk0)
+{
+ unsigned const int sz = (int)BYTE_ALIGN / 8;
+ unsigned const int nblocks = ns / sz;
+ unsigned int i;
+
+ _tPij1 = _tPij1 + state1 * nblocks;
+ _tPij2 = _tPij2 + state2 * nblocks;
+ for(i=0;i plk0: %f",x[i]); */
+
+ /* _mm256_store_pd(x,_tPij1[0]); */
+ /* for(int i=0;i<4;++i) PhyML_Printf("\n> Pij1: %f",x[i]); */
+
+ /* _mm256_store_pd(x,_tPij2[0]); */
+ /* for(int i=0;i<4;++i) PhyML_Printf("\n> Pij2: %f",x[i]); */
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void AVX_Partial_Lk_Exin(const __m256d *_tPij1, const int state1, const __m256d *_tPij2, const phydbl *_plk2, __m256d *_pmat2plk2, const int ns, __m256d *_plk0)
+{
+ unsigned const int sz = (int)BYTE_ALIGN / 8;
+ unsigned const int nblocks = ns / sz;
+ unsigned int i;
+
+ _tPij1 = _tPij1 + state1 * nblocks;
+ AVX_Matrix_Vect_Prod(_tPij2,_plk2,ns,_pmat2plk2);
+
+ for(i=0;i 1.0 || plk1[i] < 1.0 || plk2[i] > 1.0 || plk2[i] < 1.0) break;
+
+ if(i != ns)
+ {
+ AVX_Matrix_Vect_Prod(_tPij1,plk1,ns,_pmat1plk1);
+ AVX_Matrix_Vect_Prod(_tPij2,plk2,ns,_pmat2plk2);
+
+ for(i=0;i
+
+#ifndef AVX_H
+#define AVX_H
+
+#include "utilities.h"
+#include "optimiz.h"
+#include "models.h"
+#include "free.h"
+#include "times.h"
+#include "mixt.h"
+
+
+#if defined(__AVX__)
+
+void AVX_Update_Partial_Lk(t_tree *tree,t_edge *b_fcus,t_node *n);
+void AVX_Update_Eigen_Lr(t_edge *b, t_tree *tree);
+phydbl AVX_Lk_Core_One_Class_Eigen_Lr(const phydbl *dot_prod, const phydbl *expl, const unsigned int ns);
+void AVX_Lk_dLk_Core_One_Class_Eigen_Lr(const phydbl *dot_prod, const phydbl *expl, const unsigned int ns, phydbl *lk, phydbl *dlk);
+phydbl AVX_Lk_Core_One_Class_No_Eigen_Lr(const phydbl *p_lk_left, const phydbl *p_lk_rght, const phydbl *Pij, const phydbl *tPij, const phydbl *pi, const int ns, const int ambiguity_check, const int observed_state);
+phydbl AVX_Vect_Norm(__m256d _z);
+phydbl AVX_Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree);
+phydbl AVX_Lk_Core_Nucl(int state, int ambiguity_check, t_edge *b, t_tree *tree);
+phydbl AVX_Lk_Core_AA(int state, int ambiguity_check, t_edge *b, t_tree *tree);
+void AVX_Partial_Lk_Exex(const __m256d *_tPij1, const int state1, const __m256d *_tPij2, const int state2, const int ns, __m256d *plk0);
+void AVX_Partial_Lk_Exin(const __m256d *_tPij1, const int state1, const __m256d *_tPij2, const phydbl *_plk2, __m256d *_pmat2plk2, const int ns, __m256d *_plk0);
+void AVX_Partial_Lk_Inin(const __m256d *_tPij1, const phydbl *plk1, __m256d *_pmat1plk1, const __m256d *_tPij2, const phydbl *plk2, __m256d *_pmat2plk2, const int ns, __m256d *_plk0);
+void AVX_Matrix_Vect_Prod(const __m256d *_m_transpose, const phydbl *_v, const int ns, __m256d *res);
+__m256d AVX_Horizontal_Add(const __m256d x[4]);
+phydbl AVX_Lk_Core_One_Class_No_Eigen_Lr_Block(const phydbl *p_lk_left, const phydbl *p_lk_rght, const phydbl *Pij, const phydbl *tPij, const phydbl *pi, const int ns, const int ambiguity_check, const int observed_state);
+phydbl AVX_Lk_Core_One_Class_No_Eigen_Lr_No_Block(const phydbl *p_lk_left, const phydbl *p_lk_rght, const phydbl *Pij, const phydbl *tPij, const phydbl *pi, const int ns, const int ambiguity_check, const int observed_state);
+
+
+#endif
+#endif
diff --git a/phyml/beagle_utils.c b/phyml/beagle_utils.c
new file mode 100644
index 0000000..5fcf6df
--- /dev/null
+++ b/phyml/beagle_utils.c
@@ -0,0 +1,398 @@
+/*
+ * author: Imran Fanaswala
+ */
+
+#ifndef BEAGLE_UTILS_CPP
+#define BEAGLE_UTILS_CPP
+
+#include
+#include "beagle_utils.h"
+
+#define CLEAN_BEAGLE_API /* Attempting to remove unnecessary communication with BEAGLE device */
+
+double* int_to_double(const int* src, int num_elems)
+{
+ double* dest = (double*)malloc(num_elems*sizeof(double)); if (NULL==dest) Warn_And_Exit("\n. Couldn't allocate memory.\n");
+ int i;
+ for(i=0; ilength; i++) {
+ fprintf(stdout, "\t\tResource %i:\n\t\tName : %s\n", i, rList->list[i].name);
+ fprintf(stdout, "\t\t\tDesc : %s\n", rList->list[i].description);
+ fprintf(stdout, "\t\t\tFlags:");
+ print_beagle_flags(rList->list[i].supportFlags);
+ fprintf(stdout, "\n");
+ }
+ fflush(stdout);
+}
+
+void print_beagle_instance_details(BeagleInstanceDetails *inst)
+{
+ int rNumber = inst->resourceNumber;
+ fprintf(stdout, "\tUsing resource %i:\n", rNumber);
+ fprintf(stdout, "\t\tRsrc Name : %s\n", inst->resourceName);
+ fprintf(stdout, "\t\tImpl Name : %s\n", inst->implName);
+ fprintf(stdout, "\t\tImpl Desc : %s\n", inst->implDescription);
+ fprintf(stdout, "\t\tFlags:");
+ fflush(stdout);
+ print_beagle_flags(inst->flags);
+ fflush(stdout);
+}
+
+int create_beagle_instance(t_tree *tree, int quiet, option* io)
+{
+ if(UNINITIALIZED != tree->b_inst){
+// fprintf(stdout,"\n\tWARNING: Creating a BEAGLE instance on a tree with an existing BEAGLE instance:%d\n",tree->b_inst);
+ }
+ if(!quiet){
+// print_beagle_resource_list();
+ }
+ int i;
+ BeagleInstanceDetails inst_d;
+ int num_rate_catg = tree->mod->ras->n_catg;
+ int num_branches = 2*tree->n_otu-1; //rooted tree
+ //Recall that in PhyML, each edge has a "left" and "right" partial vectors. Therefore,
+ //in BEAGLE we have 2*num_branches number of partials.
+ //BEAGLE's partials buffer = [ tax1, tax2, ..., taxN, b1Left, b2Left, b3Left,...,bMLeft, b1Rght, b2Rght, b3Rght,...,bMRght] (N taxa, M branches)
+ int num_partials = 2*(tree->n_otu + num_branches); /* TODO: This does not seem correct; suspect poor indexing elsewhere */
+ /* In update_operations, indexes range from 0 to almost 2 (n_otu + num_branches), but not all integers are used */
+
+ int resourceList[1];
+ resourceList[0] = io->beagle_resource;
+
+// DUMP_I(tree->n_otu, num_rate_catg, num_partials, num_branches, tree->mod->ns, tree->n_pattern, tree->mod->whichmodel);
+ int beagle_inst = beagleCreateInstance(
+ tree->n_otu, /**< Number of tip data elements (input) */
+ num_partials, /**< Number of partial buffer (input) */
+ /* PhyML uses partials */ 0, /**< Number of compact state representation buffers to create (input) */
+ tree->mod->ns, /**< Number of states in the continuous-time Markov chain (input) */
+ tree->n_pattern, /**< Number of site patterns to be handled by the instance (input) */
+ 1, /**< Number of rate matrix eigen-decomposition,state freqs, and category weight buffers*/
+ num_branches, /**< Number of rate matrix buffers (input) */
+ num_rate_catg, /**< Number of rate categories (input) */
+ -1, /**< Number of scaling buffers. Unused because we use SCALING_ALWAYS */
+ resourceList, /**< List of potential resource on which this instance is allowed (input, NULL implies no restriction */
+ 1, /**< Length of resourceList list (input) */
+ BEAGLE_FLAG_FRAMEWORK_CPU | BEAGLE_FLAG_PROCESSOR_CPU | BEAGLE_FLAG_SCALING_ALWAYS | BEAGLE_FLAG_EIGEN_REAL | ((sizeof(float)==sizeof(phydbl)) ? BEAGLE_FLAG_PRECISION_SINGLE:BEAGLE_FLAG_PRECISION_DOUBLE),
+ 0, /**< Bit-flags indicating required implementation characteristics, see BeagleFlags (input) */
+ &inst_d);
+ if (beagle_inst < 0){
+ fprintf(stderr, "beagleCreateInstance() failed:%i\n\n",beagle_inst);
+ return beagle_inst;
+ }
+
+ if(!quiet){
+ fprintf(stdout, "\n\tUnique BEAGLE instance id:%i\n", beagle_inst);
+ print_beagle_instance_details(&inst_d);
+ }
+
+ //Set the tips
+ for(i=0; i<2*tree->n_otu-1; ++i) //taxa+internal nodes
+ {
+ // Print_Tip_Partials(tree, tree->a_nodes[i]);
+ if(tree->a_nodes[i]->tax)
+ {
+ assert(tree->a_nodes[i]->c_seq->len == tree->n_pattern); // number of compacts sites == number of distinct site patterns
+ double* tip = short_to_double(tree->a_nodes[i]->b[0]->p_lk_tip_r, tree->n_pattern*tree->mod->ns); //The tip states are stored on the branch leading to the tip
+ //Recall we store tip partials on the branch leading to the tip, rather than the tip itself.
+ int ret = beagleSetTipPartials(beagle_inst, tree->a_nodes[i]->b[0]->p_lk_tip_idx, tip);
+ if(ret<0){
+ fprintf(stderr, "beagleSetTipPartials() on instance %i failed:%i\n\n",beagle_inst,ret);
+ Free(tip);
+ return ret;
+ }
+ Free(tip);
+ }
+ }
+
+ //Set the pattern weights
+ double* pwts = int_to_double(tree->data->wght,tree->n_pattern); //BTW, These weights are absolute counts, and not freqs
+ int ret = beagleSetPatternWeights(beagle_inst, pwts);
+ if(ret<0){
+ fprintf(stderr, "beagleSetPatternWeights() on instance %i failed:%i\n\n",beagle_inst,ret);
+ Free(pwts);
+ return ret;
+ }
+ Free(pwts);
+
+ tree->mod->b_inst=beagle_inst;
+
+ update_beagle_ras(tree->mod);
+ update_beagle_efrqs(tree->mod);
+
+ return beagle_inst;
+}
+
+/* Update partial likelihood on edge b on the side of b where
+ node d lies.
+*/
+void update_beagle_partials(t_tree* tree, t_edge* b, t_node* d)
+{
+ /*
+ |
+ |<- b
+ |
+ d
+ / \
+ b1 / \ b2
+ / \
+ n_v1 n_v2
+ */
+
+ if(d->tax) //Partial likelihoods are only calculated on internal nodes
+ {
+ PhyML_Printf("\n== t_node %d is a leaf...",d->num);
+ PhyML_Printf("\n== Err. in file %s at line %d (function '%s')\n",__FILE__,__LINE__,__FUNCTION__);
+ Warn_And_Exit("\n");
+ }
+
+ //Determine d's "left" and "right" neighbors.
+ t_node *n_v1, *n_v2;//d's "left" and "right" neighbor nodes
+ phydbl *p_lk,*p_lk_v1,*p_lk_v2;
+ phydbl *Pij1,*Pij2;
+ int *sum_scale, *sum_scale_v1, *sum_scale_v2;
+ int *p_lk_loc;
+ int dest_p_idx, child1_p_idx, child2_p_idx, Pij1_idx, Pij2_idx;
+ n_v1 = n_v2 = NULL;
+ p_lk = p_lk_v1 = p_lk_v2 = NULL;
+ Pij1 = Pij2 = NULL;
+ sum_scale_v1 = sum_scale_v2 = NULL;
+ p_lk_loc = NULL;
+ dest_p_idx = child1_p_idx = child2_p_idx = Pij1_idx = Pij2_idx = UNINITIALIZED;
+ Set_All_P_Lk(&n_v1,&n_v2,
+ &p_lk,&sum_scale,&p_lk_loc,
+ &Pij1,&p_lk_v1,&sum_scale_v1,
+ &Pij2,&p_lk_v2,&sum_scale_v2,
+ d,b,tree,
+ &dest_p_idx, &child1_p_idx, &child2_p_idx, &Pij1_idx, &Pij2_idx);
+
+
+ // fprintf(stdout, "\nUpdating partials on Branch %d (on the side where Node %d lies)\n",b->num,d->num);fflush(stdout);
+ // double* p_lk_v1_b = (double*)malloc(tree->mod->ras->n_catg*tree->mod->ns*tree->n_pattern*sizeof(double));if(NULL==p_lk_v1_b) Warn_And_Exit("Couldnt allocate memory");
+ // beagleGetPartials(tree->b_inst, child1_p_idx, BEAGLE_OP_NONE, (double*)p_lk_v1_b);
+ // double* p_lk_v2_b = (double*)malloc(tree->mod->ras->n_catg*tree->mod->ns*tree->n_pattern*sizeof(double));if(NULL==p_lk_v2_b) Warn_And_Exit("Couldnt allocate memory");
+ // beagleGetPartials(tree->b_inst, child2_p_idx, BEAGLE_OP_NONE, (double*)p_lk_v2_b);
+
+ // fprintf(stdout, "Left partials :");fflush(stdout);
+ // Dump_Arr_D(p_lk_v1_b, tree->mod->ras->n_catg*tree->mod->ns*tree->n_pattern);
+ // fprintf(stdout, "Right partials:");fflush(stdout);
+ // Dump_Arr_D(p_lk_v2_b, tree->mod->ras->n_catg*tree->mod->ns*tree->n_pattern);
+ // Free(p_lk_v1_b);
+ // Free(p_lk_v2_b);
+
+
+ //Create the corresponding BEAGLE operation
+
+ // fprintf(stderr,"%d, %d, %d, ", dest_p_idx, child1_p_idx, child2_p_idx);
+
+ BeagleOperation operations[1] = {{dest_p_idx, BEAGLE_OP_NONE, BEAGLE_OP_NONE, child1_p_idx, Pij1_idx, child2_p_idx, Pij2_idx}};
+ //Compute the partials
+ int ret = beagleUpdatePartials(tree->b_inst, operations, 1, BEAGLE_OP_NONE);
+ if(ret<0){
+ fprintf(stderr, "beagleUpdatePartials() on instance %i failed:%i\n\n",tree->b_inst,ret);
+ Exit("");
+ }
+ //Load the computed/updated partial partials
+#ifndef CLEAN_BEAGLE_API
+ ret = beagleGetPartials(tree->b_inst, dest_p_idx, BEAGLE_OP_NONE, (double*)p_lk);
+ if(ret<0){
+ fprintf(stderr, "beagleGetPartials() on instance %i failed:%i\n\n",tree->b_inst,ret);
+ Exit("");
+ }
+#endif
+
+ // fprintf(stdout, "Updated partials:");fflush(stdout);
+ // Dump_Arr_D(p_lk, tree->mod->ras->n_catg*tree->mod->ns*tree->n_pattern);
+}
+
+int finalize_beagle_instance(t_tree *tree)
+{
+ if(tree->b_inst >= 0) {
+ int ret = beagleFinalizeInstance(tree->b_inst);
+ if(ret<0) fprintf(stderr, "\nFailed to finalize BEAGLE instance %i: %i\n\n", tree->b_inst, ret);
+ return ret;
+ }
+ return 0;
+}
+
+void update_beagle_ras(t_mod* mod)
+{
+ assert(UNINITIALIZED != mod->b_inst);
+
+ int ret=-1;
+ if((sizeof(float)==sizeof(phydbl))) //Do we need to convert?
+ {
+ double* catg_rates = float_to_double(mod->ras->gamma_rr->v, mod->ras->n_catg);
+ ret = beagleSetCategoryRates(mod->b_inst, catg_rates);
+ Free(catg_rates);
+ if(ret<0){
+ fprintf(stderr, "beagleSetCategoryRates() on instance %i failed:%i\n\n",mod->b_inst,ret);
+ Exit("");
+ }
+ double* catg_wts = float_to_double(mod->ras->gamma_r_proba->v, mod->ras->n_catg);
+ if(!mod->optimizing_topology) {
+ ret = beagleSetCategoryWeights(mod->b_inst, 0, catg_wts);
+ Free(catg_wts);
+ if(ret<0){
+ fprintf(stderr, "beagleSetCategoryWeights() on instance %i failed:%i\n\n",mod->b_inst,ret);
+ Exit("");
+ }
+ }
+ }
+ else
+ {
+ ret = beagleSetCategoryRates(mod->b_inst, mod->ras->gamma_rr->v);
+ if(ret<0){
+ fprintf(stderr, "beagleSetCategoryRates() on instance %i failed:%i\n\n",mod->b_inst,ret);
+ Exit("");
+ }
+ if(!mod->optimizing_topology) {
+ ret = beagleSetCategoryWeights(mod->b_inst, 0, mod->ras->gamma_r_proba->v);
+ if(ret<0){
+ fprintf(stderr, "beagleSetCategoryWeights() on instance %i failed:%i\n\n",mod->b_inst,ret);
+ Exit("");
+ }
+
+ }
+ }
+}
+
+void update_beagle_efrqs(t_mod* mod)
+{
+ assert(UNINITIALIZED != mod->b_inst);
+
+ int ret=-1;
+ if((sizeof(float)==sizeof(phydbl))) {
+ double* efrqs = float_to_double(mod->e_frq->pi->v, mod->ns);
+ ret = beagleSetStateFrequencies(mod->b_inst, 0, efrqs);
+ Free(efrqs);
+ } else {
+ ret = beagleSetStateFrequencies(mod->b_inst, 0, mod->e_frq->pi->v);
+ }
+ if(ret<0){
+ fprintf(stderr, "beagleSetStateFrequencies() on instance %i failed:%i\n\n",mod->b_inst,ret);
+ Exit("");
+ }
+}
+
+void calc_edgelks_beagle(t_edge *b, t_tree *tree)
+{
+ assert(UNINITIALIZED != tree->b_inst);
+
+ //Compute the edge likelihood
+ int parents[1] = {b->p_lk_left_idx};
+ int children[1] = {b->rght->tax?b->p_lk_tip_idx:b->p_lk_rght_idx};
+ int pmats[1] = {b->Pij_rr_idx};
+ int other[1] = {0};//Category Weights and State Frequencies both have a single buffer, hence they are both indexed at 0
+ double lnL[1] = {UNINITIALIZED};
+ // DUMP_I(parents[0], children[0], pmats[0], b->num, b->rght->tax);
+ int ret=beagleCalculateEdgeLogLikelihoods(tree->b_inst, parents, children, pmats, NULL, NULL, other, other, NULL, 1, lnL, NULL, NULL);
+ int i;
+
+if(ret<0){
+ fprintf(stderr, "beagleCalculateEdgeLogLikelihoods() on instance %i failed:%i\n\n",tree->b_inst,ret);
+ Exit("");
+ }
+
+ tree->c_lnL = sizeof(phydbl)==sizeof(float)?(float)lnL[0]:lnL[0];
+
+ //Retrieve the site likelihoods that were computed during the previous edge likelihood computation
+ ret = beagleGetSiteLogLikelihoods(tree->b_inst,tree->cur_site_lk);//TODO: Handle when cur_site_lk is float
+ if(ret<0){
+ fprintf(stderr, "beagleGetSiteLogLikelihoods() on instance %i failed:%i\n\n",tree->b_inst,ret);
+ Exit("");
+ }
+ //Transform
+ for(i=0;in_pattern;++i)
+ tree->cur_site_lk[i]=exp(tree->cur_site_lk[i]);
+}
+
+void update_beagle_eigen(t_mod* mod)
+{
+ assert(UNINITIALIZED != mod->b_inst);
+
+ int whichmodel = mod->whichmodel;
+ //We use Eigen Decomposition only for GTR models and AA datasets
+ if((mod->io->datatype == AA || whichmodel==GTR || whichmodel==CUSTOM) && mod->use_m4mod == NO)
+ {
+ //Beagle expects untransformed eigen-values (i.e. recall e_val is exp() scaled, so we undo that)
+ phydbl* evals = (phydbl*)malloc(mod->ns * sizeof(phydbl));
+ int i;
+ for(i=0;ins;++i) evals[i]=log(mod->eigen->e_val[i]);
+ int ret=-1;
+ if((sizeof(float)==sizeof(phydbl)))//Need to convert to doubles?
+ {
+ double* eigen_vects = float_to_double(mod->eigen->r_e_vect, mod->eigen->size*mod->eigen->size);
+ double* eigen_vects_inv = float_to_double(mod->eigen->l_e_vect, mod->eigen->size*mod->eigen->size);
+ double* eigen_vals = float_to_double(evals,mod->eigen->size);
+ ret = beagleSetEigenDecomposition(mod->b_inst,0,eigen_vects,eigen_vects_inv,eigen_vals);
+ Free(eigen_vects);Free(eigen_vects_inv);Free(eigen_vals);
+ } else {
+ ret = beagleSetEigenDecomposition(mod->b_inst,0,mod->eigen->r_e_vect,mod->eigen->l_e_vect,evals);
+ }
+ if(ret<0){
+ fprintf(stderr, "beagleSetEigenDecomposition() on instance %i failed:%i\n\n",mod->b_inst,ret);
+ Free(evals);
+ Exit("");
+ }
+ Free(evals);
+ }
+}
+
+#endif // BEAGLE_UTILS_CPP
+
diff --git a/phyml/beagle_utils.h b/phyml/beagle_utils.h
new file mode 100644
index 0000000..bcab8d9
--- /dev/null
+++ b/phyml/beagle_utils.h
@@ -0,0 +1,77 @@
+/*
+ * author: Imran Fanaswala
+ */
+
+#ifndef BEAGLE_UTILS_H
+#define BEAGLE_UTILS_H
+
+#include "assert.h"
+#include "libhmsbeagle/beagle.h"
+#include "utilities.h"
+#define UNINITIALIZED -42
+
+/*
+BEAGLE is a library that abstracts the core computations common to most
+phylogenetic packages. The following paragraphs serve as a "design document" for
+the implementation details of how BEAGLE has been integrated with PhyML. The
+reader is expected to be familiar with phylogenetics, skimmed the BEAGLE API,
+and seen a couple of its examples.
+
+PARTIAL LIKELIHOODS:
+- For each internal edge, PhyML maintains a vector of partials that lie to the
+"right" and "left", to faciliate both post-order and pre-order tree traversal.
+Therefore each t_edge has a `p_lk_right` and `p_lk_left` field
+- PhyML represents a tip as a vector of partials (where one bit is "1", and
+the rest are "0"). Therefore, a t_edge connected to a tip has `p_lk_tip` field.
+Also by convention, the tip always lies to the right of the edge its connected
+to. In other words, if b->right->tax is True, then b->p_lk_tip holds the tip
+partials.
+- Therefore for BEAGLE, we allocate N+(2*num_edges) partial buffers.
+- Recall that BEAGLE requires each partial buffer to be uniquely indexed. Thus
+each edge also has an additional `p_lk_rght_idx` and `p_lk_left_idx` field.
+These fields are used to create a BeagleOperation struct during the call to
+beagleUpdatePartials().
+- In PhyML, Update_P_Lk() updates the partials for a specific edge lieing along
+a specific "direction". The "direction" depends on which tree-traversal is being
+employed. In other words, the tree-traversal dictates whether we are computing
+"up"/"right" or "down"/"left" partials relative to the t_node*. Specifically,
+Set_All_P_Lk() handles the nitty gritty of determining whether we are computing
+"right" or "left" partials. Therefore this function has been modified to also
+set the appropriate BEAGLE indices.
+
+P-MATS and EDGELIKELIHOODS:
+- (1) Observe that PhyML does eigen decomposition for only GTR and AA models and
+thus the P-matrix is computed using Beagle. This implies the usage of
+SetEigenDecomposition() and UpdateTransitionMatricies() calls.
+- (2) On the other hand, in case of simpler models (JC69, F81, etc), the
+P-Matrix is explicitly set in BEAGLE thus implying the usage of
+SetTransitionMatrix().
+- The choice between (1) and (2) is made in Update_PMat_At_Given_Edge(). BTW,
+upon reading Update_PMat_At_Given_Edge(), it may appear that the P-Matrix is
+being computed in PhyML *and* in BEAGLE; afterall because PMat() function in all
+cases. However, when BEAGLE is enabled, observe that in PMat() essentially does
+nothing.
+- Lk_Core() computes the edgelikelihoods, and calc_edgelks_beagle() is the
+corresponding BEAGLE function that does the same.
+
+
+*/
+
+
+
+#define TODO_BEAGLE "TODO. This codepath has not been implemented in PhyML-X, please post your usecase on the PhyML discussion list"
+
+int create_beagle_instance(t_tree* tree, int quiet, option* io);
+int finalize_beagle_instance(t_tree* tree);
+void update_beagle_partials(t_tree* tree, t_edge* b, t_node* d);
+void update_beagle_ras(t_mod* mod);
+void update_beagle_efrqs(t_mod* mod);
+void update_beagle_eigen(t_mod* mod);
+void calc_edgelks_beagle(t_edge* b, t_tree* tree);
+double* int_to_double(const int* src, int num_elems);
+double* short_to_double(const short* src, int num_elems);
+double* float_to_double(const phydbl *src, int num_elems);
+
+
+
+#endif // BEAGLE_UTILS_H
diff --git a/phyml/bionj.c b/phyml/bionj.c
index 25b18f0..e1a3c3e 100644
--- a/phyml/bionj.c
+++ b/phyml/bionj.c
@@ -20,7 +20,7 @@ on a simple model of sequence data." (1997) O. Gascuel. Mol Biol Evol.
*/
#include "bionj.h"
-#include "free.h"
+
void Bionj(matrix *mat)
{
@@ -28,9 +28,10 @@ void Bionj(matrix *mat)
phydbl vxy,lx,ly,lamda,score;
Clean_Tree_Connections(mat->tree);
- For(i,mat->tree->n_otu) mat->tip_node[i] = mat->tree->noeud[i];
- mat->tree->num_curr_branch_available = 0;
+ for(i=0;itree->n_otu;i++) mat->tip_node[i] = mat->tree->a_nodes[i];
+ mat->tree->num_curr_branch_available = mat->tree->n_otu;
+
while(mat->r > 3)
{
x = y = 0;
@@ -38,29 +39,33 @@ void Bionj(matrix *mat)
score = .0;
Compute_Sx(mat);
Best_Pair(mat,&x,&y,&score);
- vxy=Variance(mat,x,y);
+ vxy=BioNJ_Variance(mat,x,y);
lx=Br_Length(mat,x,y);
ly=Br_Length(mat,y,x);
lamda=Lamda(mat,x,y,vxy);
Update_Mat(mat,x,y,lx,ly,vxy,lamda);
Update_Tree(mat,x,y,lx,ly,score);
}
+
Finish(mat);
+
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Finish(matrix *mat)
{
phydbl dxy,dxz,dyz;
int x,y,z;
- node *nx,*ny,*nz,*new;
+ t_node *nx,*ny,*nz,*new;
int i;
dxy = dxz = dyz = -1.;
x = y = z = -1;
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
if(mat->on_off[i])
{
@@ -78,7 +83,7 @@ void Finish(matrix *mat)
ny = mat->tip_node[y];
nz = mat->tip_node[z];
- new = mat->tree->noeud[mat->curr_int];
+ new = mat->tree->a_nodes[mat->curr_int];
new->num = mat->curr_int;
new->v[0] = nx;
new->v[1] = ny;
@@ -88,25 +93,34 @@ void Finish(matrix *mat)
ny->v[0] = new;
nz->v[0] = new;
-
- Connect_One_Edge_To_Two_Nodes(new,nx,mat->tree->t_edges[mat->tree->num_curr_branch_available],mat->tree);
- mat->tree->num_curr_branch_available++;
- Connect_One_Edge_To_Two_Nodes(new,ny,mat->tree->t_edges[mat->tree->num_curr_branch_available],mat->tree);
- mat->tree->num_curr_branch_available++;
- Connect_One_Edge_To_Two_Nodes(new,nz,mat->tree->t_edges[mat->tree->num_curr_branch_available],mat->tree);
- mat->tree->num_curr_branch_available++;
-
+ if(nx->tax)
+ Connect_One_Edge_To_Two_Nodes(new,nx,mat->tree->a_edges[nx->num],mat->tree);
+ else
+ Connect_One_Edge_To_Two_Nodes(new,nx,mat->tree->a_edges[mat->tree->num_curr_branch_available],mat->tree);
+
+ if(ny->tax)
+ Connect_One_Edge_To_Two_Nodes(new,ny,mat->tree->a_edges[ny->num],mat->tree);
+ else
+ Connect_One_Edge_To_Two_Nodes(new,ny,mat->tree->a_edges[mat->tree->num_curr_branch_available],mat->tree);
+
+ if(nz->tax)
+ Connect_One_Edge_To_Two_Nodes(new,nz,mat->tree->a_edges[nz->num],mat->tree);
+ else
+ Connect_One_Edge_To_Two_Nodes(new,nz,mat->tree->a_edges[mat->tree->num_curr_branch_available],mat->tree);
+
- nx->b[0]->l = .5*(dxy-dyz+dxz);
- ny->b[0]->l = .5*(dyz-dxz+dxy);
- nz->b[0]->l = .5*(dxz-dxy+dyz);
+ nx->b[0]->l->v = .5*(dxy-dyz+dxz);
+ ny->b[0]->l->v = .5*(dyz-dxz+dxy);
+ nz->b[0]->l->v = .5*(dxz-dxy+dyz);
- new->b[0]->l = nx->b[0]->l;
- new->b[1]->l = ny->b[0]->l;
- new->b[2]->l = nz->b[0]->l;
+ new->b[0]->l->v = nx->b[0]->l->v;
+ new->b[1]->l->v = ny->b[0]->l->v;
+ new->b[2]->l->v = nz->b[0]->l->v;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Update_Mat(matrix *mat, int x, int y, phydbl lx, phydbl ly, phydbl vxy, phydbl lamda)
{
@@ -114,7 +128,7 @@ void Update_Mat(matrix *mat, int x, int y, phydbl lx, phydbl ly, phydbl vxy, phy
int a,b;
a = b = -1;
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
if((mat->on_off[i]) && (i != x) && (i != y))
{
@@ -134,47 +148,53 @@ void Update_Mat(matrix *mat, int x, int y, phydbl lx, phydbl ly, phydbl vxy, phy
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
void Update_Tree(matrix *mat, int x, int y, phydbl lx, phydbl ly, phydbl score)
{
- node *new, *nx, *ny;
+ t_node *new, *nx, *ny;
nx = mat->tip_node[x];
ny = mat->tip_node[y];
- new = mat->tree->noeud[mat->curr_int];
+ new = mat->tree->a_nodes[mat->curr_int];
nx->v[0] = new;
ny->v[0] = new;
new->v[1] = nx;
new->v[2] = ny;
new->num = mat->curr_int;
+
+ if(nx->tax)
+ Connect_One_Edge_To_Two_Nodes(new,nx,mat->tree->a_edges[nx->num],mat->tree);
+ else
+ Connect_One_Edge_To_Two_Nodes(new,nx,mat->tree->a_edges[mat->tree->num_curr_branch_available],mat->tree);
- Connect_One_Edge_To_Two_Nodes(new,nx,mat->tree->t_edges[mat->tree->num_curr_branch_available],mat->tree);
- mat->tree->num_curr_branch_available++;
- Connect_One_Edge_To_Two_Nodes(new,ny,mat->tree->t_edges[mat->tree->num_curr_branch_available],mat->tree);
- mat->tree->num_curr_branch_available++;
+ if(ny->tax)
+ Connect_One_Edge_To_Two_Nodes(new,ny,mat->tree->a_edges[ny->num],mat->tree);
+ else
+ Connect_One_Edge_To_Two_Nodes(new,ny,mat->tree->a_edges[mat->tree->num_curr_branch_available],mat->tree);
- nx->b[0]->l = lx;
- ny->b[0]->l = ly;
- new->b[1]->l = lx;
- new->b[2]->l = ly;
+ nx->b[0]->l->v = lx;
+ ny->b[0]->l->v = ly;
+
+ new->b[1]->l->v = lx;
+ new->b[2]->l->v = ly;
new->score[0] = score;
- nx->l[0] = lx;
- ny->l[0] = ly;
-
- new->l[1] = lx;
- new->l[2] = ly;
-
+ nx->b[0]->l->v = lx;
+ ny->b[0]->l->v = ly;
+
mat->tip_node[x] = new;
mat->on_off[y] = 0;
mat->curr_int++;
mat->r--;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Best_Pair(matrix *mat, int *x, int *y,phydbl *score)
{
@@ -188,7 +208,7 @@ void Best_Pair(matrix *mat, int *x, int *y,phydbl *score)
Qmin = 1.e+10;
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
if(mat->on_off[i])
{
@@ -210,7 +230,7 @@ void Best_Pair(matrix *mat, int *x, int *y,phydbl *score)
}
/* n_ties = 0; */
-/* For(i,mat->n_otu) */
+/* for(i=0;in_otu;i++) */
/* { */
/* if(mat->on_off[i]) */
/* { */
@@ -230,7 +250,7 @@ void Best_Pair(matrix *mat, int *x, int *y,phydbl *score)
/* if(!n_ties) */
/* { */
-/* printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__); */
+/* PhyML_Printf("\n. Err in file %s at line %d\n\n",__FILE__,__LINE__); */
/* Warn_And_Exit(""); */
/* } */
@@ -240,7 +260,7 @@ void Best_Pair(matrix *mat, int *x, int *y,phydbl *score)
/* { */
/* int cand; */
/* *x = *y = -1; */
-/* cand = (int)rint(rand()/(phydbl)(RAND_MAX) * (n_ties-1)); */
+/* cand = (int)RINT(rand()/(phydbl)(RAND_MAX) * (n_ties-1)); */
/* *x = (int)(ties[cand] / mat->n_otu); */
/* *y = (int)(ties[cand] % mat->n_otu); */
/* } */
@@ -249,34 +269,36 @@ void Best_Pair(matrix *mat, int *x, int *y,phydbl *score)
Qmin2 = 1e+10;
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
if((i != *y) && (i != *x) && (t_Qij[mat->n_otu*(*x)+i] < Qmin2)) Qmin2 = t_Qij[mat->n_otu*(*x)+i];
}
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
if((i != *y) && (i != *x) && (t_Qij[mat->n_otu*i+(*y)] < Qmin2)) Qmin2 = t_Qij[mat->n_otu*i+(*y)];
}
- *score = fabs(Qmin2 - Qmin)/fabs(Qmin);
+ *score = FABS(Qmin2 - Qmin)/FABS(Qmin);
Free(t_Qij);
/* Free(ties); */
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Compute_Sx(matrix *mat)
{
int i,j;
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
mat->dist[i][i] = .0;
if(mat->on_off[i])
{
- For(j,mat->n_otu)
+ for(j=0;jn_otu;j++)
{
if((i != j) && (mat->on_off[j]))
{
@@ -287,14 +309,18 @@ void Compute_Sx(matrix *mat)
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
phydbl Sum_S(matrix *mat, int i)
{
return mat->dist[i][i];
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
phydbl Dist(matrix *mat, int x, int y)
{
@@ -304,9 +330,10 @@ phydbl Dist(matrix *mat, int x, int y)
return(mat->dist[y][x]);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-phydbl Variance(matrix *mat, int x, int y)
+phydbl BioNJ_Variance(matrix *mat, int x, int y)
{
if(x > y)
{
@@ -318,7 +345,9 @@ phydbl Variance(matrix *mat, int x, int y)
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
phydbl Br_Length(matrix *mat, int x, int y)
{
@@ -326,7 +355,9 @@ phydbl Br_Length(matrix *mat, int x, int y)
(Sum_S(mat,x)-Sum_S(mat,y))/(phydbl)(mat->r-2.));
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
phydbl Dist_Red(matrix *mat, int x, phydbl lx, int y, phydbl ly, int i, phydbl lamda)
{
@@ -336,18 +367,21 @@ phydbl Dist_Red(matrix *mat, int x, phydbl lx, int y, phydbl ly, int i, phydbl l
return(Dui);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
phydbl Var_Red(matrix *mat, int x, int y, int i, phydbl lamda, phydbl vxy)
{
phydbl Vui;
- Vui=lamda*(Variance(mat,x,i))
- +(1.-lamda)*(Variance(mat,y,i))
+ Vui=lamda*(BioNJ_Variance(mat,x,i))
+ +(1.-lamda)*(BioNJ_Variance(mat,y,i))
-lamda*(1.-lamda)*vxy;
return(Vui);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
phydbl Lamda(matrix *mat, int x, int y, phydbl vxy)
{
@@ -358,14 +392,14 @@ phydbl Lamda(matrix *mat, int x, int y, phydbl vxy)
lamda = 0.5;
else /* BioNJ (Gascuel, 1997) */
{
- if(vxy==0.0)
+ if(vxy < SMALL && vxy > -SMALL)
lamda=0.5;
else
{
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
if((x != i) && (y != i) && (mat->on_off[i]))
- lamda = lamda + Variance(mat,y,i) - Variance(mat,x,i);
+ lamda = lamda + BioNJ_Variance(mat,y,i) - BioNJ_Variance(mat,x,i);
}
lamda = 0.5 + lamda/(2.*(mat->r-2)*vxy);
}
@@ -379,7 +413,9 @@ phydbl Lamda(matrix *mat, int x, int y, phydbl vxy)
return(lamda);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
phydbl Q_Agglo(matrix *mat, int x, int y)
{
@@ -390,21 +426,25 @@ phydbl Q_Agglo(matrix *mat, int x, int y)
return(Qxy);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Bionj_Br_Length(matrix *mat)
{
int x;
- x = Bionj_Br_Length_Post(mat->tree->noeud[0],
- mat->tree->noeud[0]->v[0],
+ x = Bionj_Br_Length_Post(mat->tree->a_nodes[0],
+ mat->tree->a_nodes[0]->v[0],
mat);
- mat->tree->noeud[0]->b[0]->l = Dist(mat,0,x);
+ mat->tree->a_nodes[0]->b[0]->l->v = Dist(mat,0,x);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-int Bionj_Br_Length_Post(node *a, node *d, matrix *mat)
+
+int Bionj_Br_Length_Post(t_node *a, t_node *d, matrix *mat)
{
int i;
@@ -419,7 +459,7 @@ int Bionj_Br_Length_Post(node *a, node *d, matrix *mat)
int x,y;
d_v1 = d_v2 = -1;
- For(i,3)
+ for(i=0;i<3;i++)
if(d->v[i] != a) {(d_v1 < 0)?(d_v1 = i):(d_v2 = i);}
@@ -428,14 +468,14 @@ int Bionj_Br_Length_Post(node *a, node *d, matrix *mat)
vxy = .0;
Compute_Sx(mat);
- vxy=Variance(mat,(x),(y));
+ vxy=BioNJ_Variance(mat,(x),(y));
lx=Br_Length(mat,(x),(y));
ly=Br_Length(mat,(y),(x));
lamda=Lamda(mat,(x),(y),vxy);
Update_Mat(mat,(x),(y),lx,ly,vxy,lamda);
- d->b[d_v1]->l = lx;
- d->b[d_v2]->l = ly;
+ d->b[d_v1]->l->v = lx;
+ d->b[d_v2]->l->v = ly;
mat->on_off[y] = 0;
mat->r--;
@@ -444,7 +484,9 @@ int Bionj_Br_Length_Post(node *a, node *d, matrix *mat)
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
diff --git a/phyml/bionj.h b/phyml/bionj.h
index b73c4f9..8f0d6c7 100644
--- a/phyml/bionj.h
+++ b/phyml/bionj.h
@@ -10,12 +10,14 @@ the GNU public licence. See http://www.opensource.org for details.
*/
+#include
+
#ifndef NJ_H
#define NJ_H
#include "utilities.h"
#include "optimiz.h"
-/*#include "tools.h"*/
+#include "free.h"
void Bionj(matrix *mat);
void Finish(matrix *mat);
@@ -23,7 +25,7 @@ void Compute_Sx(matrix *mat);
phydbl Sum_S(matrix *mat, int i);
phydbl Dist(matrix *mat, int x, int y);
phydbl Q_Agglo(matrix *mat, int x, int y);
-phydbl Variance(matrix *mat, int x, int y);
+phydbl BioNJ_Variance(matrix *mat, int x, int y);
phydbl Br_Length(matrix *mat, int x, int y);
void Update_Dist(matrix *mat, int x, int y);
phydbl Lamda(matrix *mat, int x, int y, phydbl vxy);
@@ -34,7 +36,7 @@ void Update_Mat(matrix *mat, int x, int y,
phydbl lx, phydbl ly, phydbl vxy, phydbl lamda);
phydbl Dist_Red(matrix *mat, int x, phydbl lx, int y,
phydbl ly, int i, phydbl lamda);
-int Bionj_Br_Length_Post(node *a, node *d, matrix *mat);
+int Bionj_Br_Length_Post(t_node *a, t_node *d, matrix *mat);
void Bionj_Br_Length(matrix *mat);
#endif
diff --git a/phyml/checkpoint.c b/phyml/checkpoint.c
new file mode 100644
index 0000000..0827e3a
--- /dev/null
+++ b/phyml/checkpoint.c
@@ -0,0 +1,36 @@
+#include "checkpoint.h"
+
+
+void CHECK_Main(int argc,char **argv)
+{
+ // Up to you Salva...
+
+
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
diff --git a/phyml/checkpoint.h b/phyml/checkpoint.h
new file mode 100644
index 0000000..0f5aa7c
--- /dev/null
+++ b/phyml/checkpoint.h
@@ -0,0 +1,10 @@
+#include
+
+#ifndef CHECKPOINT_H
+#define CHECKPOINT_H
+
+#include "utilities.h"
+
+void CHECK_Main(int argc, char **argv);
+
+#endif
diff --git a/phyml/cl.c b/phyml/cl.c
index b813e55..8024a6d 100644
--- a/phyml/cl.c
+++ b/phyml/cl.c
@@ -10,27 +10,25 @@ the GNU public licence. See http://www.opensource.org for details.
*/
-#include
-#include
-#include "utilities.h"
-#include "options.h"
#include "cl.h"
-#include "models.h"
-#include "free.h"
-#include "interface.h"
-#include "mg.h"
-#include "m4.h"
/*********************************************************/
/**
* Fill the Option fields, with the argc array
*/
-void Read_Command_Line(option *io, int argc, char **argv)
+int Read_Command_Line(option *io, int argc, char **argv)
{
int c;
- int open_ps_file;
- int use_gamma;
+ int idx;
+ int i;
+ int writemode;
+
+ writemode = WRITE;
+
+ if(argc == 1) Exit("\n. No argument was passed to the program. Please check the documentation. \n");
+ PhyML_Printf("",writemode);
+
struct option longopts[] =
{
{"n_rgrft", required_argument,NULL,0},
@@ -65,6 +63,7 @@ void Read_Command_Line(option *io, int argc, char **argv)
{"random_boot", required_argument,NULL,29},
{"print_trace", no_argument,NULL,30},
{"print_site_lnl", no_argument,NULL,31},
+ {"print_site_lk", no_argument,NULL,31},
{"cov", no_argument,NULL,32},
{"cov_delta", required_argument,NULL,33},
{"cov_alpha", required_argument,NULL,34},
@@ -73,251 +72,725 @@ void Read_Command_Line(option *io, int argc, char **argv)
{"cov_free", no_argument,NULL,37},
{"no_gap", no_argument,NULL,38},
{"n_rr_branch", required_argument,NULL,39},
+ {"append", no_argument,NULL,40},
+ {"no_five_branch", no_argument,NULL,41},
+ {"pars_thresh", required_argument,NULL,42},
+ {"min_diff_lk_move", required_argument,NULL,43},
+ {"hybrid", no_argument,NULL,44},
+ {"use_median", no_argument,NULL,45},
+ {"run_id", required_argument,NULL,46},
+ {"pars", no_argument,NULL,47},
+ {"quiet", no_argument,NULL,48},
+ {"version", no_argument,NULL,49},
+ {"calibration_file", required_argument,NULL,50},
+ {"calibration", required_argument,NULL,50},
+ {"clade_file", required_argument,NULL,50},
+ {"boot_progress_every", required_argument,NULL,51},
+ {"aa_rate_file", required_argument,NULL,52},
+ {"chain_len", required_argument,NULL,53},
+ {"sample_freq", required_argument,NULL,54},
+ {"burnin", required_argument,NULL,55},
+ {"no_memory_check", no_argument,NULL,56},
+ {"no_colalias", no_argument,NULL,57},
+ {"alias_subpatt", no_argument,NULL,58},
+ {"no_sequences", no_argument,NULL,59},
+ {"prior", no_argument,NULL,59},
+ {"fastlk", no_argument,NULL,60},
+ {"free_rates", no_argument,NULL,61},
+ {"freerates", no_argument,NULL,61},
+ {"freerate", no_argument,NULL,61},
+ {"free_rate", no_argument,NULL,61},
+ {"is", no_argument,NULL,62},
+ // no 63 since it corresponds to character '?'
+ {"rate_model", required_argument,NULL,64},
+ {"ratemodel", required_argument,NULL,64},
+ {"log_l", no_argument,NULL,65},
+ {"gamma_lens", no_argument,NULL,66},
+ {"il", no_argument,NULL,66},
+ {"codpos", required_argument,NULL,67},
+ {"constraint_file", required_argument,NULL,68},
+ {"constraint_tree", required_argument,NULL,68},
+ {"help", no_argument,NULL,69},
+ {"mutmap", no_argument,NULL,70},
+ {"parvals", required_argument,NULL,71},
+ {"constrained_lens", no_argument,NULL,72},
+ {"xml", required_argument,NULL,73},
+ {"l_var", required_argument,NULL,74},
+#ifdef BEAGLE
+ {"beagle_resource", required_argument,NULL,75},
+#endif
+ {"ancestral", no_argument,NULL,76},
+ {"anc", no_argument,NULL,76},
+ {"coord_file", required_argument,NULL,77},
+ {"json_trace", no_argument,NULL,78},
+ {"weights", required_argument,NULL,79},
+ {"tbe", no_argument,NULL,80},
+ {"leave_duplicates", no_argument,NULL,81},
+ {"precision", required_argument,NULL,82},
+ {"l_min", required_argument,NULL,83},
{0,0,0,0}
};
- open_ps_file = 0;
- use_gamma = 0;
- while((c = getopt_long(argc,argv,"qi:d:m:b:n:t:f:zk:v:c:a:u:ho:s:x:g:l:e",longopts,NULL)) != -1)
- {
- switch(c)
- {
- case 39 :
- {
- io->mod->n_rr_branch = (int)atoi(optarg);
- if(io->mod->n_rr_branch < 1)
- {
- printf("\n. The number of classes must be an integer greater than 0.\n");
- printf("\n. Type any key to exit.\n");
- Exit("\n");
- }
- break;
- }
- case 38 :
- {
- io->rm_ambigu = 1;
- break;
- }
- case 37 :
- {
- io->mod->s_opt->opt_cov_free_rates = 1;
- break;
- }
- case 36 :
- {
- open_ps_file = 1;
- break;
- }
- case 35 :
- {
- io->m4_model = YES;
- if(!io->mod->m4mod) io->mod->m4mod = (m4 *)M4_Make_Light((io->mod->datatype == NT)?(4):(20));
- io->mod->m4mod->n_h = (int)atoi(optarg);
-
- if(io->mod->m4mod->n_h < 1)
- {
- char choix;
- printf("\n. The number of classes must be greater than 0.\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- break;
- }
- case 34 :
- {
- io->m4_model = YES;
- if(!io->mod->m4mod) io->mod->m4mod = (m4 *)M4_Make_Light((io->mod->datatype == NT)?(4):(20));
- io->mod->m4mod->use_cov_alpha = 1;
- io->mod->m4mod->use_cov_free = 0;
-
- if(!strcmp(optarg,"e") || !strcmp(optarg,"E") ||
- !strcmp(optarg,"estimated") || !strcmp(optarg,"ESTIMATED"))
- {
- io->mod->s_opt->opt_cov_alpha = 1;
- io->mod->m4mod->alpha = 1.0;
- }
- else
- {
- io->mod->m4mod->alpha = (phydbl)atof(optarg);
-
- if(io->mod->m4mod->alpha < 1.E-5)
- {
- char choix;
- printf("\n. The value of alpha must be greater than 1.E-5.\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- }
- break;
- }
-
- case 33 :
- {
- io->m4_model = YES;
- if(!io->mod->m4mod) io->mod->m4mod = (m4 *)M4_Make_Light((io->mod->datatype == NT)?(4):(20));
-
- if(!strcmp(optarg,"e") || !strcmp(optarg,"E") ||
- !strcmp(optarg,"estimated") || !strcmp(optarg,"ESTIMATED"))
- {
- io->mod->s_opt->opt_cov_delta = 1;
- io->mod->m4mod->delta = 1.0;
- }
- else
- {
- io->mod->m4mod->delta = (phydbl)atof(optarg);
-
- if(atof(optarg) < 1.E-10)
- {
- char choix;
- printf("\n. The value of delta must be larger than 1.E-10.\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- }
- break;
- }
- case 32 :
- {
- io->m4_model = YES;
- break;
- }
- case 31 :
- {
- io->print_site_lnl = 1;
- break;
- }
- case 30 :
- {
- io->print_trace = 1;
- break;
- }
- case 29 :
- {
- io->random_boot_seq_order = (int)atoi(optarg);
- break;
- }
- case 28 :
- {
- io->collapse_boot = (int)atoi(optarg);
- break;
- }
- case 27 :
- {
- io->r_seed = (int)atoi(optarg);
- break;
- }
- case 26 :
- {
- io->mod->s_opt->general_pars = 1;
- break;
- }
- case 25 :
- {
- io->mod->s_opt->fast_nni = 1;
- break;
- }
- case 24 :
- {
- io->mod->s_opt->p_moves_to_examine = (double)atof(optarg);
- break;
- }
- case 23 :
- {
- io->mod->s_opt->wim_inside_opt = 1;
- break;
- }
- case 0 :
- {
- io->mod->s_opt->wim_n_rgrft = atoi(optarg);
- break;
- }
- case 1 :
- {
- io->mod->s_opt->wim_n_globl = atoi(optarg);
- break;
- }
- case 2 :
- {
- io->mod->s_opt->wim_max_dist = atoi(optarg);
- break;
- }
- case 3 :
- {
- io->mod->s_opt->wim_n_optim = atoi(optarg);
- break;
- }
- case 4 :
- {
- io->mod->s_opt->wim_n_best = atoi(optarg);
- break;
- }
- case 16 :
- {
- io->mod->s_opt->min_diff_lk_local = atof(optarg);
- break;
- }
+ io->datatype = UNDEFINED;
+
+ #ifndef PHYML
+ int open_ps_file = 0;
+ #endif
+
+ idx=-1;
+
+ do
+ {
+ c = getopt_long(argc,argv,"qi:d:m:b:n:t:f:zk:v:c:a:u:ho:s:x:g:l:ep",longopts,&idx);
+
+ switch(c)
+ {
+ case 83 :
+ {
+ io->mod->l_min = String_To_Dbl(optarg);
+ break;
+ }
+ case 82 :
+ {
+ if ((!atoi(optarg)) || (atoi(optarg) < 1) || (atoi(optarg) > DECIMAL_DIG -3))
+ {
+ PhyML_Printf("\n. The number of digits must be [1 - %d]\n", DECIMAL_DIG -3);
+ Exit("\n");
+ }
+ else
+ {
+ io->precision = atoi(optarg);
+ }
+ break;
+ }
+ case 81 :
+ {
+ io->leave_duplicates = YES;
+ break;
+ }
+ case 80 :
+ {
+ io->do_tbe = YES;
+ io->do_boot = NO;
+ io->do_alrt = NO;
+ break;
+ }
+ case 79:
+ {
+ io->has_io_weights = YES;
+ strcpy(io->weight_file, optarg);
+ break;
+ }
+ case 78:
+ {
+ io->print_json_trace = YES;
+ break;
+ }
+
+ case 77:
+ {
+ char *tmp;
+ tmp = (char *)mCalloc(T_MAX_FILE, sizeof(char));
+
+ if(strlen(optarg) > T_MAX_FILE -11)
+ {
+ char choix;
+ strcpy (tmp, "\n. The file name'");
+ strcat (tmp, optarg);
+ strcat (tmp, "' is too long.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else if (!Filexists (optarg))
+ {
+ char choix;
+ strcpy (tmp, "\n. The file '");
+ strcat (tmp, optarg);
+ strcat (tmp, "' doesn't exist.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ strcpy(io->in_coord_file, optarg);
+ io->fp_in_coord = Openfile(io->in_coord_file,READ);
+ }
+ Free(tmp);
+ break;
+ }
+
+ case 76:
+ {
+ io->ancestral = YES;
+ break;
+ }
+#ifdef BEAGLE
+ case 75:
+ {
+ io->beagle_resource = (int)atoi(optarg);
+ break;
+ }
+#endif
+ case 74:
+ {
+ io->mod->l_var_sigma = String_To_Dbl(optarg);
+ break;
+ }
+ case 73:
+ {
+#ifdef INVITEE
+
+ Free_Optimiz(io->mod->s_opt);
+ Free_Model_Basic(io->mod);
+ Free_Input(io);
+ PhyTime_XML(optarg);
+ return 0;
+
+#elif defined(PHYML)
+
+ Free_Optimiz(io->mod->s_opt);
+ Free_Model_Basic(io->mod);
+ Free_Input(io);
+ io = PhyML_XML(optarg);
+ Free(io);
+ return 0;
+
+#elif defined(PHYTIME)
+
+ Free_Optimiz(io->mod->s_opt);
+ Free_Model_Basic(io->mod);
+ Free_Input(io);
+ DATE_XML(optarg);
+ return 0;
+
+#elif defined(PHYREX)
+
+ Free_Optimiz(io->mod->s_opt);
+ Free_Model_Basic(io->mod);
+ Free_Input(io);
+ PHYREX_XML(optarg);
+ return 0;
+
+#endif
+ break;
+ }
+ case 72:
+ {
+ io->mod->s_opt->constrained_br_len = YES;
+ break;
+ }
+ case 71:
+ {
+ io->mcmc->in_fp_par = fopen(optarg,"r");
+ io->mcmc->randomize = NO;
+ break;
+ }
+ case 70:
+ {
+ io->mutmap = YES;
+ break;
+ }
+ case 68:
+ {
+ char *tmp;
+ tmp = (char *)mCalloc(T_MAX_FILE, sizeof(char));
+
+ if(strlen(optarg) > T_MAX_FILE -11)
+ {
+ char choix;
+ strcpy (tmp, "\n. The file name'");
+ strcat (tmp, optarg);
+ strcat (tmp, "' is too long.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else if (!Filexists (optarg))
+ {
+ char choix;
+ strcpy (tmp, "\n. The file '");
+ strcat (tmp, optarg);
+ strcat (tmp, "' doesn't exist.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ strcpy(io->in_constraint_tree_file, optarg);
+ io->fp_in_constraint_tree = Openfile(io->in_constraint_tree_file,0);
+ }
+ Free(tmp);
+ break;
+ }
+ case 67:
+ {
+ phydbl pos;
+ pos = atof(optarg);
+ io->codpos = (int)pos;
+ if(io->codpos < 1 || io->codpos > 3)
+ {
+ char choix;
+ PhyML_Printf("\n. Coding position must be set to 1, 2 or 3.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ break;
- case 17 :
- {
- io->mod->s_opt->min_diff_lk_global = atof(optarg);
- break;
- }
- case 18 :
- {
- io->mod->s_opt->steph_spr = 0;
- io->mod->s_opt->greedy = 1;
- break;
- }
- case 19 :
- {
- io->mod->s_opt->brent_it_max = atoi(optarg);
- break;
- }
- case 20 :
- {
- io->mod->s_opt->random_input_tree = 1;
- break;
- }
- case 21 :
- {
- io->mod->s_opt->random_input_tree = 1;
- io->mod->s_opt->n_rand_starts = atoi(optarg);
- }
- case 's':case 6:
- {
- if((!strcmp(optarg,"spr")) || (!strcmp(optarg,"SPR")))
- {
- io->mod->s_opt->topo_search = SPR_MOVE;
- io->mod->s_opt->greedy = (io->mod->s_opt->steph_spr)?(0):(1);
- }
- else if((!strcmp(optarg,"nni")) || (!strcmp(optarg,"NNI")))
- {
- io->mod->s_opt->topo_search = NNI_MOVE;
- io->mod->s_opt->random_input_tree = 0;
- }
- else if((!strcmp(optarg,"nni+spr")) || (!strcmp(optarg,"NNI+SPR")))
- {
- io->mod->s_opt->topo_search = NNI_MOVE;
- io->mod->s_opt->random_input_tree = 0;
- io->mod->s_opt->spr_step_after_nnis = 1;
- io->mod->s_opt->greedy = (io->mod->s_opt->steph_spr)?(0):(1);
- }
- break;
- }
+ break;
+ }
+ case 66:
+ {
+ io->mod->gamma_mgf_bl = YES;
+ io->mod->s_opt->opt_gamma_br_len = YES;
+ break;
+ }
+ case 65:
+ {
+ io->mod->log_l = YES;
+ break;
+ }
+ case 64:
+ {
+ char *s;
+ int i;
+ s = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+ i = 0;
+ while(optarg[i++]) s[i]=tolower(optarg[i]);
+ if(!strcmp(optarg,"gbd")) io->rates->model = THORNE;
+ else if(!strcmp(optarg,"geom")) io->rates->model = GUINDON;
+ else if(!strcmp(optarg,"lognorm")) io->rates->model = LOGNORMAL;
+ else if(!strcmp(optarg,"clock")) io->rates->model = STRICTCLOCK;
+ else if(!strcmp(optarg,"strictclock")) io->rates->model = STRICTCLOCK;
+ else if(!strcmp(optarg,"strict_clock")) io->rates->model = STRICTCLOCK;
+ else
+ {
+ PhyML_Printf("\n. rate_model should be 'gbs', 'gbd', 'gamma' or 'clock'.");
+ Exit("\n");
+ }
+ Free(s);
+ break;
+ }
+
+
+ case 62:
+ {
+ io->mcmc->is = YES;
+ break;
+ }
+ case 61:
+ {
+ io->mod->ras->free_mixt_rates = YES;
+ io->mod->s_opt->opt_free_mixt_rates = YES;
+ break;
+ }
+ case 60:
+ {
+ io->lk_approx = NORMAL;
+ break;
+ }
+ case 59:
+ {
+ break;
+ }
+ case 58:
+ {
+ io->do_alias_subpatt = YES;
+ break;
+ }
+ case 57:
+ {
+ io->colalias = NO;
+ break;
+ }
+ case 56:
+ {
+ io->mem_question = NO;
+ break;
+ }
+ case 55:
+ {
+ phydbl len;
+ len = atof(optarg);
+ io->mcmc->chain_len_burnin = (int)len;
+ if(io->mcmc->chain_len_burnin < 1)
+ {
+ char choix;
+ PhyML_Printf("\n. chain_len_burnin must be an integer greater than 0.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ break;
+ }
+ case 54:
+ {
+ phydbl len;
+ len = atof(optarg);
+ io->mcmc->sample_interval = (int)len;
+ if(io->mcmc->sample_interval < 1)
+ {
+ char choix;
+ PhyML_Printf("\n. sample_interval must be an integer greater than 0.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ break;
+ }
+ case 53:
+ {
+ phydbl len;
+ len = atof(optarg);
+ io->mcmc->chain_len = (int)len;
+ if(io->mcmc->chain_len < 1)
+ {
+ char choix;
+ PhyML_Printf("\n. chain_len must be an integer greater than 0.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ break;
+ }
+ case 52:
+ {
+ char *s;
+ s = (char *)mCalloc(T_MAX_FILE, sizeof(char));
+ strcpy(s,optarg);
+ io->mod->fp_aa_rate_mat = Openfile(s,0);
+ strcpy(io->mod->aa_rate_mat_file->s,s);
+ Free(s);
+ break;
+ }
+ case 51:
+ {
+ io->boot_prog_every = atoi(optarg);
+ if(io->boot_prog_every < 1)
+ {
+ char choix;
+ PhyML_Printf("\n. boot_progress_every must be an integer greater than 0.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ break;
+ }
+ case 50:
+ {
+ strcpy(io->clade_list_file,optarg);
+ break;
+ }
+ case 49:
+ {
+ PhyML_Printf("\n. This is PhyML version %s.\n\n",VERSION);
+ Exit("");
+ break;
+ }
+ case 48 :
+ {
+ io->quiet = 1;
+ break;
+ }
+ case 'p' : case 47 :
+ {
+ io->in_tree = 1;
+ break;
+ }
+ case 46 :
+ {
+ if(strlen(optarg) > 0)
+ {
+ io->append_run_ID = YES;
+ strcpy(io->run_id_string,optarg);
+ }
+ break;
+ }
+ case 45 :
+ {
+ io->mod->ras->gamma_median = 1;
+ break;
+ }
+ case 44 :
+ {
+ io->mod->s_opt->hybrid_thresh = 0;
+ break;
+ }
+ case 43 :
+ {
+ io->mod->s_opt->min_diff_lk_move = atof(optarg);
+ if(io->mod->s_opt->min_diff_lk_move < 0)
+ {
+ char choix;
+ PhyML_Printf("\n. Min_diff_lk_move must be a double greater than 0.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ break;
+ }
+ case 42 :
+ {
+ io->mod->s_opt->pars_thresh = (int)atoi(optarg);
+ if(io->mod->s_opt->pars_thresh < 0)
+ {
+ PhyML_Printf("\n. The parsimony threshold must be an integer greater than 0.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ Exit("\n");
+ }
+ break;
+ }
+ case 41 :
+ {
+ io->mod->s_opt->opt_five_branch = 0;
+ break;
+ }
+ case 40 :
+ {
+ writemode = APPEND;
+ break;
+ }
+ case 39 :
+ {
+ break;
+ }
+ case 38 :
+ {
+ io->rm_ambigu = 1;
+ break;
+ }
+ case 37 :
+ {
+ io->mod->s_opt->opt_cov_free_rates = YES;
+#ifdef M4
+ io->mod->m4mod->use_cov_alpha = NO;
+ io->mod->m4mod->use_cov_free = YES;
+#endif
+ break;
+ }
+ case 36 :
+ {
+#ifndef PHYML
+ open_ps_file = 1;
+#endif
+ break;
+ }
+ case 35 :
+ {
+#ifdef M4
+ io->mod->m4mod->n_h = (int)atoi(optarg);
+
+ if(io->mod->m4mod->n_h < 1)
+ {
+ char choix;
+ PhyML_Printf("\n. The number of classes must be greater than 0.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+#endif
+ break;
+ }
+ case 34 :
+ {
+#ifdef M4
+ io->mod->m4mod->use_cov_alpha = YES;
+ io->mod->m4mod->use_cov_free = NO;
- case 'd':case 7:
- if(!strcmp(optarg,"nt"))
- /* if(atoi(optarg) == NT) */
+ if(!strcmp(optarg,"e") || !strcmp(optarg,"E") ||
+ !strcmp(optarg,"estimated") || !strcmp(optarg,"ESTIMATED"))
+ {
+ io->mod->s_opt->opt_cov_alpha = YES;
+ io->mod->m4mod->alpha = 1.0;
+ }
+ else
{
- io->mod->datatype = NT;
- io->mod->stepsize = 1;
- io->mod->ns = 4;
+ io->mod->m4mod->alpha = (phydbl)atof(optarg);
- if(
- (io->mod->whichmodel == LG) ||
+ if(io->mod->m4mod->alpha < 1.E-5)
+ {
+ char choix;
+ PhyML_Printf("\n. The value of alpha must be greater than 1.E-5.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ }
+#endif
+ break;
+ }
+ case 33 :
+ {
+#ifdef M4
+ if(!strcmp(optarg,"e") || !strcmp(optarg,"E") ||
+ !strcmp(optarg,"estimated") || !strcmp(optarg,"ESTIMATED"))
+ {
+ io->mod->s_opt->opt_cov_delta = YES;
+ io->mod->m4mod->delta = 1.0;
+ }
+ else
+ {
+ io->mod->m4mod->delta = (phydbl)atof(optarg);
+
+ if(atof(optarg) < 1.E-10)
+ {
+ char choix;
+ PhyML_Printf("\n. The value of delta must be larger than 1.E-10.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ }
+#endif
+ break;
+ }
+ case 32 :
+ {
+ io->mod->use_m4mod = YES;
+ break;
+ }
+ case 31 :
+ {
+ io->print_site_lnl = YES;
+ break;
+ }
+ case 30 :
+ {
+ io->print_trace = YES;
+ break;
+ }
+ case 29 :
+ {
+ io->random_boot_seq_order = (int)atoi(optarg);
+ break;
+ }
+ case 28 :
+ {
+ io->collapse_boot = (int)atoi(optarg);
+ break;
+ }
+ case 27 :
+ {
+ io->r_seed = (int)atoi(optarg);
+ break;
+ }
+ case 26 :
+ {
+ io->mod->s_opt->general_pars = YES;
+ break;
+ }
+ case 25 :
+ {
+ io->mod->s_opt->fast_nni = YES;
+ break;
+ }
+ case 24 :
+ {
+ io->mod->s_opt->p_moves_to_examine = (phydbl)atof(optarg);
+ break;
+ }
+ case 23 :
+ {
+ io->mod->s_opt->wim_inside_opt = 1;
+ break;
+ }
+ case 0 :
+ {
+ io->mod->s_opt->wim_n_rgrft = atoi(optarg);
+ break;
+ }
+ case 1 :
+ {
+ io->mod->s_opt->wim_n_globl = atoi(optarg);
+ break;
+ }
+ case 2 :
+ {
+ io->mod->s_opt->wim_max_dist = atoi(optarg);
+ break;
+ }
+ case 3 :
+ {
+ io->mod->s_opt->wim_n_optim = atoi(optarg);
+ break;
+ }
+ case 4 :
+ {
+ io->mod->s_opt->wim_n_best = atoi(optarg);
+ break;
+ }
+ case 16 :
+ {
+ io->mod->s_opt->min_diff_lk_local = atof(optarg);
+ break;
+ }
+ case 17 :
+ {
+ io->mod->s_opt->min_diff_lk_global = atof(optarg);
+ break;
+ }
+ case 18 :
+ {
+ io->mod->s_opt->steph_spr = NO;
+ io->mod->s_opt->greedy = YES;
+ break;
+ }
+ case 19 :
+ {
+ io->mod->s_opt->brent_it_max = atoi(optarg);
+ break;
+ }
+ case 20 :
+ {
+ io->mod->s_opt->random_input_tree = YES;
+ break;
+ }
+ case 21 :
+ {
+ io->mod->s_opt->random_input_tree = YES;
+ io->mod->s_opt->n_rand_starts = atoi(optarg);
+ if(io->mod->s_opt->n_rand_starts < 1) Exit("\n. Number of random starting trees must be > 0.\n\n");
+ }
+ case 's':case 6:
+ {
+ if((!strcmp(optarg,"spr")) || (!strcmp(optarg,"SPR")))
+ {
+ io->mod->s_opt->topo_search = SPR_MOVE;
+ io->mod->s_opt->greedy = (io->mod->s_opt->steph_spr)?(0):(1);
+ }
+ else if((!strcmp(optarg,"nni")) || (!strcmp(optarg,"NNI")))
+ {
+ PhyML_Printf("\n. The NNI option is deprecated. PhyML now uses a mix of SPRs and NNIs.");
+ io->mod->s_opt->topo_search = NNI_MOVE;
+ io->mod->s_opt->random_input_tree = 0;
+ }
+ else if((!strcmp(optarg,"best")) || (!strcmp(optarg,"BEST")))
+ {
+ PhyML_Printf("\n. The BEST option is deprecated. PhyML now uses a mix of SPRs and NNIs.");
+ io->mod->s_opt->topo_search = BEST_OF_NNI_AND_SPR;
+ io->mod->s_opt->greedy = (io->mod->s_opt->steph_spr)?(0):(1);
+ }
+ break;
+ }
+
+ case 'd':case 7:
+ {
+ if(!strcmp(optarg,"nt"))
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+#ifdef M4
+ io->mod->m4mod->n_o = 4;
+#endif
+
+ if((io->mod->whichmodel == LG) ||
(io->mod->whichmodel == WAG) ||
(io->mod->whichmodel == DAYHOFF) ||
(io->mod->whichmodel == JTT) ||
@@ -331,19 +804,23 @@ void Read_Command_Line(option *io, int argc, char **argv)
(io->mod->whichmodel == MTART) ||
(io->mod->whichmodel == HIVW) ||
(io->mod->whichmodel == HIVB) ||
+ (io->mod->whichmodel == AB) ||
(io->mod->whichmodel == CUSTOMAA)
)
{
io->mod->whichmodel = HKY85;
- strcpy(io->mod->modelname, "HKY85\0");
+ strcpy(io->mod->modelname->s, "HKY85\0");
}
}
else if (!strcmp(optarg,"aa"))
- /* else if (atoi(optarg) == AA) */
{
- io->mod->datatype = AA;
- io->mod->stepsize = 1;
- io->mod->ns = 20;
+ io->datatype = AA;
+ io->mod->s_opt->opt_kappa = NO;
+ io->mod->ns = 20;
+#ifdef M4
+ io->mod->m4mod->n_o = 20;
+#endif
+
if(
(io->mod->whichmodel == JC69) ||
(io->mod->whichmodel == K80) ||
@@ -356,310 +833,394 @@ void Read_Command_Line(option *io, int argc, char **argv)
)
{
io->mod->whichmodel = LG;
- strcpy(io->mod->modelname, "LG\0");
+ strcpy(io->mod->modelname->s, "LG\0");
}
}
+ else if ((!strcmp(optarg,"generic")) || (!strcmp(optarg,"gen")))
+ {
+ io->datatype = GENERIC;
+ }
else
{
char choix;
- printf("\n. Unknown argument to -d option: please use `nt' for DNA or `aa' for Amino-Acids\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Unknown argument to -d option: please use `nt' for DNA or `aa' for Amino-Acids\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
Exit("\n");
}
break;
+ }
+ case 'm': case 5 :
+ {
+ if (!isalpha(optarg[0]))
+ {
+ if(strchr(optarg,',') == NULL)
+ {
+ strcpy(io->mod->custom_mod_string->s,optarg);
+ if (strlen(io->mod->custom_mod_string->s) != 6)
+ {
+ Warn_And_Exit("\n. The custom model string should be of length 6.\n");
+ }
+
+ io->datatype = NT;
+ io->mod->whichmodel = CUSTOM;
+ strcpy(io->mod->modelname->s, "custom");
+ io->mod->s_opt->opt_kappa = NO;
+ io->mod->s_opt->opt_rr = YES;
+ }
+ else
+ {
+ phydbl v;
+ int n_rr;
+ const char *d = ",";
+ char *tok = strtok(optarg,d);
+
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = GTR;
+ io->mod->s_opt->opt_rr = NO;
+
+ io->mod->r_mat = (t_rmat *)Make_Rmat(io->mod->ns);
+ Init_Rmat(io->mod->r_mat);
+ Make_Custom_Model(io->mod);
+
+ n_rr = 0;
+ while(tok && n_rr < 6)
+ {
+ v = strtod(tok,NULL);
+ if (v != 0)
+ {
+ io->mod->r_mat->rr->v[n_rr] = v;
+ io->mod->r_mat->rr_val->v[n_rr] = log(v);
+ }
+ else
+ {
+ PhyML_Printf("\n. Invalid relative rate parameter value: '%s'.\n", tok);
+ Exit("\n");
+ }
+ tok = strtok (NULL,d);
+ n_rr++;
+ }
+ assert(n_rr <= 6);
+ }
+ }
+ else
+ {
+ char *s = To_Upper_String(optarg);
+
+ if (strcmp(s, "JC69") == 0)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = JC69;
+ }
+ else if(strcmp(s, "K80") == 0)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = K80;
+ }
+ else if(strcmp(s, "F81") == 0)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = F81;
+ }
+ else if (strcmp(s, "HKY85") == 0)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = HKY85;
+ }
+ else if(strcmp(s, "F84") == 0)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = F84;
+ }
+ else if (strcmp(s,"TN93") == 0)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = TN93;
+ }
+ else if(strncmp(s, "GTR", 3) == 0)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = GTR;
+ io->mod->s_opt->opt_rr = YES;
+ }
+ else if(strcmp(s, "DAYHOFF") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = DAYHOFF;
+ }
+ else if(strcmp(s, "JTT") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = JTT;
+ }
+ else if(strcmp(s, "MTREV") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = MTREV;
+ }
+ else if(strcmp(s, "LG") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = LG;
+ }
+ else if(strcmp(s, "WAG") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = WAG;
+ }
+ else if(strcmp(s, "DCMUT") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = DCMUT;
+ }
+ else if(strcmp(s, "RTREV") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = RTREV;
+ }
+ else if(strcmp(s, "CPREV") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = CPREV;
+ }
+ else if(strcmp(s, "VT") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = VT;
+ }
+ else if(strcmp(s, "BLOSUM62") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = BLOSUM62;
+ }
+ else if(strcmp(s, "MTMAM") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = MTMAM;
+ }
+ else if (strcmp(s,"MTART") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = MTART;
+ }
+ else if (strcmp(s,"HIVW") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = HIVW;
+ }
+ else if(strcmp(s, "HIVB") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = HIVB;
+ }
+ else if(strcmp(s, "AB") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = AB;
+ }
+ else if (strcmp(s, "CUSTOM") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = CUSTOMAA;
+ }
+ else if(strcmp(s, "FLU") == 0)
+ {
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->whichmodel = FLU;
+ }
+ else
+ {
+ PhyML_Printf("\n. The model name is incorrect. Please see the documentation.\n");
+ Exit("\n");
+ }
+ Free(s);
+ }
+
+
+ Set_Model_Name(io->mod);
- case 'm': case 5 :
- {
- if(!isalpha(optarg[0]))
- {
- strcpy(io->mod->custom_mod_string,optarg);
-
- if(strlen(io->mod->custom_mod_string) != 6)
- {
- Warn_And_Exit("\n. The string should be of length 6.\n");
- }
- else
- {
- Translate_Custom_Mod_String(io->mod);
- }
-
- io->mod->datatype = NT;
- io->mod->whichmodel = CUSTOM;
- strcpy(io->mod->modelname, "custom");
- io->mod->s_opt->opt_kappa = 0;
- io->mod->s_opt->opt_rr = 1;
- io->mod->s_opt->opt_num_param = 1;
- }
-
- if (strcmp(optarg, "JC69") == 0)
- {
- io->mod->datatype = NT;
- io->mod->whichmodel = JC69;
- strcpy(io->mod->modelname, "JC69");
- io->mod->s_opt->opt_kappa = 0;
- }
- else if(strcmp(optarg, "K80") == 0)
- {
- io->mod->datatype = NT;
- io->mod->whichmodel = K80;
- strcpy(io->mod->modelname, "K80");
- }
- else if(strcmp(optarg, "F81") == 0)
- {
- io->mod->datatype = NT;
- io->mod->whichmodel = F81;
- strcpy(io->mod->modelname, "F81");
- io->mod->s_opt->opt_kappa = 0;
- }
- else if (strcmp(optarg, "HKY85") == 0)
- {
- io->mod->datatype = NT;
- io->mod->whichmodel = HKY85;
- strcpy(io->mod->modelname, "HKY85");
- }
- else if(strcmp(optarg, "F84") == 0)
- {
- io->mod->datatype = NT;
- io->mod->whichmodel = F84;
- strcpy(io->mod->modelname, "F84");
- }
- else if (strcmp (optarg,"TN93") == 0)
- {
- io->mod->datatype = NT;
- io->mod->whichmodel = TN93;
- strcpy(io->mod->modelname, "TN93");
- if(io->mod->s_opt->opt_kappa)
- {
- io->mod->s_opt->opt_lambda = 1;
- }
- }
- else if(strcmp (optarg, "GTR") == 0)
- {
- io->mod->datatype = NT;
- io->mod->whichmodel = GTR;
- strcpy(io->mod->modelname, "GTR");
- io->mod->s_opt->opt_kappa = 0;
- }
- else if(strcmp(optarg, "Dayhoff") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = DAYHOFF;
- strcpy(io->mod->modelname, "Dayhoff");
- }
- else if(strcmp (optarg, "JTT") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = JTT;
- strcpy(io->mod->modelname, "JTT");
- }
- else if(strcmp(optarg, "MtREV") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = MTREV;
- strcpy(io->mod->modelname,"MtREV");
- }
- else if(strcmp (optarg, "LG") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = LG;
- strcpy(io->mod->modelname, "LG");
- }
- else if(strcmp (optarg, "WAG") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = WAG;
- strcpy(io->mod->modelname, "WAG");
- }
- else if(strcmp(optarg, "DCMut") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = DCMUT;
- strcpy(io->mod->modelname, "DCMut");
- }
- else if(strcmp (optarg, "RtREV") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = RTREV;
- strcpy(io->mod->modelname, "RtREV");
- }
- else if(strcmp(optarg, "CpREV") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = CPREV;
- strcpy(io->mod->modelname, "CpREV");
- }
- else if(strcmp(optarg, "VT") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = VT;
- strcpy(io->mod->modelname, "VT");
- }
- else if(strcmp(optarg, "Blosum62") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = BLOSUM62;
- strcpy(io->mod->modelname,"Blosum62");
- }
- else if(strcmp(optarg, "MtMam") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = MTMAM;
- strcpy(io->mod->modelname, "MtMam");
- }
- else if (strcmp(optarg,"MtArt") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = MTART;
- strcpy(io->mod->modelname, "MtArt");
- }
- else if (strcmp(optarg,"HIVw") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = HIVW;
- strcpy(io->mod->modelname, "HIVw");
- }
- else if(strcmp(optarg, "HIVb") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = HIVB;
- strcpy(io->mod->modelname, "HIVb");
- }
- else if (strcmp(optarg, "custom") == 0)
- {
- io->mod->datatype = AA;
- io->mod->whichmodel = CUSTOMAA;
- strcpy(io->mod->modelname, "Read from file");
- }
- break;
- }
-
- case 'a':case 14 :
- {
- use_gamma = 1;
- if ((strcmp (optarg, "e") == 0) ||
- (strcmp (optarg, "E") == 0) ||
- (strcmp (optarg, "estimated") == 0) ||
- (strcmp (optarg, "ESTIMATED") == 0))
- {
- io->mod->s_opt->opt_alpha = 1;
- io->mod->s_opt->opt_num_param = 1;
- }
- else if ((!atof(optarg)) || (atof(optarg) < .0))
- {
- char choix;
- printf("\n. Alpha must be a positive number\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else
- {
- io->mod->alpha = (phydbl)atof(optarg);
- io->mod->s_opt->opt_alpha = 0;
- }
- break;
- }
- case 'b':case 10:
- {
- if (atoi(optarg) < -4)
+ break;
+ }
+
+ case 'a':case 14 :
+ {
+ if ((strcmp (optarg, "e") == 0) ||
+ (strcmp (optarg, "E") == 0) ||
+ (strcmp (optarg, "estimated") == 0) ||
+ (strcmp (optarg, "ESTIMATED") == 0))
+ {
+ io->mod->s_opt->opt_alpha = YES;
+ }
+ else if (atof(optarg) < 1.E-10)
+ {
+ char choix;
+ PhyML_Printf("\n. Alpha must be > 1.E-10.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ io->mod->ras->alpha->v = (phydbl)atof(optarg);
+ io->mod->s_opt->opt_alpha = NO;
+ }
+ break;
+ }
+ case 'b':case 10:
+ {
+ if ((int)String_To_Dbl(optarg) < -5)
{
char choix;
- printf("\n. Branch test value must be a positive integer for bootstrap, or between -1 and -4 for aLRT branch test\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Branch test value must be a positive integer for bootstrap, or between -1 and -4 for aLRT branch test\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
Exit("\n");
}
else
{
- if((int)atoi(optarg) > 0)
+ if((int)String_To_Dbl(optarg) > 0)
{
- io->ratio_test = 0;
- io->mod->bootstrap = (int)atoi(optarg);
- io->print_boot_trees = 1;
-
+ io->do_alrt = NO;
+ io->ratio_test = 0;
+ io->n_boot_replicates = (int)atoi(optarg);
+ io->print_boot_trees = 1;
+
if(io->n_data_sets > 1)
{
char choix;
- printf("\n. Bootstrap option is not allowed with multiple data sets\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Bootstrap option is not allowed with multiple data sets\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
Exit("\n");
}
}
else if (atoi(optarg)==0)
{
- io->mod->bootstrap = 0;
- io->ratio_test = 0;
+ io->do_alrt = NO;
+ io->do_tbe = NO;
+ io->do_boot = NO;
+ io->ratio_test = 0;
}
else
{
- io->mod->bootstrap = 0;
- io->ratio_test = -(int)atoi(optarg);
+ io->do_alrt = YES;
+ io->do_tbe = NO;
+ io->do_boot = NO;
+ io->ratio_test = -(int)atoi(optarg);
+ }
+ }
+ break;
+ }
+ case 'c':case 12:
+ {
+ if ((!atoi(optarg)) || (atoi(optarg) < 0))
+ {
+ char choix;
+ PhyML_Printf("\n. Unknown argument to -c option: the number of rate categories must be a positive integer\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ io->mod->ras->n_catg = atoi(optarg);
+ if(io->mod->ras->n_catg < 1)
+ {
+ PhyML_Printf("\n. The number of rate categories must be a positive integer\n");
+ Exit("\n");
}
}
break;
}
- case 'c':case 12:
- {
- if ((!atoi(optarg)) || (atoi(optarg) < 0))
- {
- char choix;
- printf("\n. Unknown argument to -c option: the number of categories must be a positive integer\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else io->mod->n_catg = atoi(optarg);
- break;
- }
case 'f':
{
if(!strcmp(optarg,"e"))
{
- io->mod->s_opt->opt_state_freq = 1;
-
- if((io->mod->whichmodel == JC69) ||
- (io->mod->whichmodel == K80))
+ if(io->datatype == NT)
+ io->mod->s_opt->opt_state_freq = NO;
+ else if (io->datatype == AA)
+ io->mod->s_opt->opt_state_freq = YES;
+ else
{
- char choix;
- printf("\n. Invalid model settings (option '-f').\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Please define the data type (nt or aa) before setting the -f option\n");
Exit("\n");
}
}
- else if(!strcmp(optarg,"d"))
+ else if(!strcmp(optarg,"m"))
{
- io->mod->s_opt->opt_state_freq = 0;
+ if (io->datatype == NT)
+ io->mod->s_opt->opt_state_freq = YES;
+ else if (io->datatype == AA)
+ io->mod->s_opt->opt_state_freq = NO;
+ else
+ {
+ PhyML_Printf("\n. Please define the data type (nt or aa) before setting the -f option\n");
+ Exit("\n");
+ }
}
else if(!isalpha(optarg[0]))
{
phydbl sum;
+ double val1,val2,val3,val4;
+
+ io->mod->e_frq = (t_efrq *)Make_Efrq(4);
+ Init_Efrq(NULL,io->mod->e_frq);
- io->mod->s_opt->opt_state_freq = 0;
- io->mod->s_opt->user_state_freq = 1;
+ io->mod->s_opt->opt_state_freq = NO;
+ io->mod->e_frq->user_state_freq = YES;
+
+ sscanf(optarg,"%lf,%lf,%lf,%lf",&val1,&val2,&val3,&val4);
+ io->mod->e_frq->user_b_freq->v[0] = (phydbl)val1;
+ io->mod->e_frq->user_b_freq->v[1] = (phydbl)val2;
+ io->mod->e_frq->user_b_freq->v[2] = (phydbl)val3;
+ io->mod->e_frq->user_b_freq->v[3] = (phydbl)val4;
sum =
- (io->mod->user_b_freq[0] +
- io->mod->user_b_freq[1] +
- io->mod->user_b_freq[2] +
- io->mod->user_b_freq[3]);
-
- io->mod->user_b_freq[0] /= sum;
- io->mod->user_b_freq[1] /= sum;
- io->mod->user_b_freq[2] /= sum;
- io->mod->user_b_freq[3] /= sum;
-
- if(io->mod->user_b_freq[0] < .0 ||
- io->mod->user_b_freq[1] < .0 ||
- io->mod->user_b_freq[2] < .0 ||
- io->mod->user_b_freq[3] < .0 ||
- io->mod->user_b_freq[0] > 1. ||
- io->mod->user_b_freq[1] > 1. ||
- io->mod->user_b_freq[2] > 1. ||
- io->mod->user_b_freq[3] > 1.)
+ (io->mod->e_frq->user_b_freq->v[0] +
+ io->mod->e_frq->user_b_freq->v[1] +
+ io->mod->e_frq->user_b_freq->v[2] +
+ io->mod->e_frq->user_b_freq->v[3]);
+
+ io->mod->e_frq->user_b_freq->v[0] /= sum;
+ io->mod->e_frq->user_b_freq->v[1] /= sum;
+ io->mod->e_frq->user_b_freq->v[2] /= sum;
+ io->mod->e_frq->user_b_freq->v[3] /= sum;
+
+
+ if(io->mod->e_frq->user_b_freq->v[0] < .0 ||
+ io->mod->e_frq->user_b_freq->v[1] < .0 ||
+ io->mod->e_frq->user_b_freq->v[2] < .0 ||
+ io->mod->e_frq->user_b_freq->v[3] < .0 ||
+ io->mod->e_frq->user_b_freq->v[0] > 1. ||
+ io->mod->e_frq->user_b_freq->v[1] > 1. ||
+ io->mod->e_frq->user_b_freq->v[2] > 1. ||
+ io->mod->e_frq->user_b_freq->v[3] > 1.)
{
Warn_And_Exit("\n. Invalid base frequencies.\n");
}
@@ -667,194 +1228,236 @@ void Read_Command_Line(option *io, int argc, char **argv)
break;
}
- case 'h':
+ case 'h':case 69:
{
Usage();
break;
}
-
- case 'i':case 9:
- {
- char *tmp;
- tmp = (char *) mCalloc (T_MAX_FILE, sizeof(char));
- if (strlen (optarg) > T_MAX_FILE -16)
- {
- char choix;
- strcpy (tmp, "\n. The file name'");
- strcat (tmp, optarg);
- strcat (tmp, "' is too long.\n");
- printf("%s",tmp);
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else if (!Filexists (optarg))
- {
- char choix;
- strcpy (tmp, "\n. The file '");
- strcat (tmp, optarg);
- strcat (tmp, "' does not exist.\n");
- printf("%s",tmp);
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else
- {
- strcpy(io->in_seq_file, optarg);
- io->fp_in_seq = Openfile(io->in_seq_file,0);
- strcpy(io->out_tree_file,optarg);
+ case 'i':case 9:
+ {
+ char *tmp;
+ tmp = (char *) mCalloc (T_MAX_FILE, sizeof(char));
+ if (strlen (optarg) > T_MAX_FILE -16)
+ {
+ char choix;
+ strcpy (tmp, "\n. The file name'");
+ strcat (tmp, optarg);
+ strcat (tmp, "' is too long.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+
+ else if (!Filexists (optarg))
+ {
+ char choix;
+ strcpy (tmp, "\n. The file '");
+ strcat (tmp, optarg);
+ strcat (tmp, "' does not exist.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ strcpy(io->in_align_file, optarg);
+ io->fp_in_align = Openfile(io->in_align_file,0);
+
+ strcpy(io->out_file, optarg);
+ strcpy(io->out_tree_file,optarg);
#ifdef PHYML
- strcat(io->out_tree_file,"_phyml_tree.txt");
-#else
- strcat(io->out_tree_file,"_mc_tree.txt");
+ strcat(io->out_tree_file,"_phyml_tree");
+#elif M4
+ strcat(io->out_tree_file,"_m4_tree");
+#elif PHYREX
+ strcat(io->out_tree_file,"_phyrex_tree");
#endif
- io->fp_out_tree = Openfile(io->out_tree_file,1);
- strcpy(io->out_stats_file,optarg);
+
+ strcpy(io->out_stats_file,optarg);
#ifdef PHYML
- strcat(io->out_stats_file,"_phyml_stats.txt");
-#else
- strcat(io->out_stats_file,"_mc_stats.txt");
+ strcat(io->out_stats_file,"_phyml_stats");
+#elif M4
+ strcat(io->out_stats_file,"_m4_stats");
+#elif PHYREX
+ strcat(io->out_stats_file,"_phyrex_stats");
+#endif
+
+
+#ifdef PHYREX
+ strcpy(io->out_summary_file,optarg);
+ strcat(io->out_summary_file,"_phyrex_summary");
#endif
- io->fp_out_stats = Openfile(io->out_stats_file,1);
- }
- Free (tmp);
- break;
- }
+
+
+ }
+ Free (tmp);
+ break;
+ }
+
+ case 't':case 11:
+ {
+ if ((io->mod->whichmodel != JC69) && (io->mod->whichmodel != F81) && (io->mod->whichmodel != GTR))
+ {
+ if ((strcmp(optarg, "e") == 0) ||
+ (strcmp(optarg, "E") == 0) ||
+ (strcmp(optarg, "estimated") == 0) ||
+ (strcmp(optarg, "ESTIMATED") == 0))
+ {
+ io->mod->kappa->v = 4.0;
+ io->mod->s_opt->opt_kappa = YES;
+ if (io->mod->whichmodel == TN93)
+ io->mod->s_opt->opt_lambda = YES;
+ }
+ else
+ {
+ io->mod->s_opt->opt_kappa = NO;
+ io->mod->s_opt->opt_lambda = NO;
+
+
+ // Added the 2 TsTv ratios for TN93
+ // lambda is the ratio of both TsTv ratios
+ // kappa is the mean of both TsTv ratios
+ if (io->mod->whichmodel == TN93)
+ {
+ double TsTvPur, TsTvPyr;
+ TsTvPur = TsTvPyr = -1.;
+ if(!isalpha(optarg[0]))
+ {
+ sscanf(optarg,"%lf,%lf",&TsTvPur,&TsTvPyr);
+ }
+ else
+ {
+ PhyML_Fprintf(stderr,"\n. The TN93 model requires two Ts/Tv ratios.\n");
+ Exit("\n");
+ }
+ if ( (TsTvPur < .0) || (TsTvPyr < .0) )
+ {
+ PhyML_Fprintf(stderr,"\n. The Ts/Tv ratio must be a positive number.\n");
+ Exit("\n");
+ }
+ io->mod->lambda->v = (phydbl)(TsTvPur / TsTvPyr);
+ io->mod->kappa->v = (phydbl)((TsTvPur + TsTvPyr)/2.);
+ }
+ else
+ {
+ // -- End TN93 rates for purines & pyrimidines
+ if (atof(optarg) < .0)
+ {
+ char choix;
+ PhyML_Printf("\n. The Ts/Tv ratio must be a positive number\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ io->mod->kappa->v = (phydbl)atof(optarg);
+ }
+ }
+ }
+ }
+ break;
+ }
+ case 'n':case 8:
+ {
+ if ((!atoi(optarg)) || (atoi(optarg) < 0))
+ {
+ char choix;
+ PhyML_Printf("\n. The number of alignments must be a positive integer\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else io->n_data_sets = atoi (optarg);
+ break;
+ }
+ case 'q':case 22:
+ {
+ io->interleaved = NO;
+ break;
+ }
+ case 'u':case 15:
+ {
+ char *tmp;
+ tmp = (char *)mCalloc(T_MAX_FILE, sizeof(char));
+ if(strlen(optarg) > T_MAX_FILE -11)
+ {
+ char choix;
+ strcpy (tmp, "\n. The file name'");
+ strcat (tmp, optarg);
+ strcat (tmp, "' is too long.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else if (! Filexists (optarg))
+ {
+ char choix;
+ strcpy (tmp, "\n. The file '");
+ strcat (tmp, optarg);
+ strcat (tmp, "' doesn't exist.\n");
+ PhyML_Printf("%s",tmp);
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ strcpy(io->in_tree_file, optarg);
+ io->in_tree = 2;
+ io->fp_in_tree = Openfile(io->in_tree_file,READ);
+ }
+ Free(tmp);
+ break;
+ }
- case 't':case 11:
- {
- if ((io->mod->whichmodel != JC69) &&
- (io->mod->whichmodel != F81) &&
- (io->mod->whichmodel != GTR))
- {
- if ((strcmp(optarg, "e") == 0) ||
- (strcmp(optarg, "E") == 0) ||
- (strcmp(optarg, "estimated") == 0) ||
- (strcmp(optarg, "ESTIMATED") == 0))
- {
- io->mod->kappa = 4.0;
- io->mod->s_opt->opt_num_param = 1;
- io->mod->s_opt->opt_kappa = 1;
- if (io->mod->whichmodel == TN93)
- io->mod->s_opt->opt_lambda = 1;
- }
- else
- {
- if ((!atof(optarg)) || (atof(optarg) < .0))
- {
- char choix;
- printf("\n. The ts/tv ratio must be a positive number\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else
- {
- io->mod->kappa = (phydbl)atof(optarg);
- io->mod->s_opt->opt_kappa = 0;
- io->mod->s_opt->opt_lambda = 0;
- }
- }
- }
- break;
- }
- case 'n':case 8:
- {
- if ((!atoi(optarg)) || (atoi(optarg) < 0))
- {
- char choix;
- printf("\n. The number of alignments must be a positive integer\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else io->n_data_sets = atoi (optarg);
- break;
- }
- case 'q':case 22:
- {
- io->interleaved = 0;
- break;
- }
- case 'u':case 15:
- {
- char *tmp;
- tmp = (char *)mCalloc(T_MAX_FILE, sizeof(char));
- if (strlen (optarg) > T_MAX_FILE -11)
- {
- char choix;
- strcpy (tmp, "\n. The file name'");
- strcat (tmp, optarg);
- strcat (tmp, "' is too long.\n");
- printf("%s",tmp);
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else if (! Filexists (optarg))
- {
- char choix;
- strcpy (tmp, "\n. The file '");
- strcat (tmp, optarg);
- strcat (tmp, "' doesn't exist.\n");
- printf("%s",tmp);
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
- else
- {
- strcpy(io->in_tree_file, optarg);
- io->in_tree = 1;
- io->fp_in_tree = Openfile(io->in_tree_file,0);
- }
- Free(tmp);
- break;
- }
-
- case 'v':case 13:
- {
- if ((strcmp (optarg, "e") == 0) ||
- (strcmp (optarg, "E") == 0) ||
- (strcmp (optarg, "estimated") == 0) ||
- (strcmp (optarg, "ESTIMATED") == 0)) {
- io->mod->s_opt->opt_num_param = 1;
- io->mod->s_opt->opt_pinvar = 1;
- io->mod->pinvar = 0.2;
- io->mod->invar = 1;
- }
- else if ((atof(optarg) < 0.0) || (atof(optarg) > 1.0))
- {
- char choix;
- printf("\n. The proportion of invariable site must be a number between 0.0 and 1.0\n");
- printf("\n. Type any key to exit.");
- scanf("%c",&choix);
- Exit("\n");
- }
- else
- {
- io->mod->pinvar = (phydbl)atof(optarg);
- if (io->mod->pinvar > 0.0+MDBL_MIN)
- io->mod->invar = 1;
- else
- io->mod->invar = 0;
- io->mod->s_opt->opt_pinvar = 0;
- }
- break;
- }
+ case 'v':case 13:
+ {
+ if ((strcmp (optarg, "e") == 0) ||
+ (strcmp (optarg, "E") == 0) ||
+ (strcmp (optarg, "estimated") == 0) ||
+ (strcmp (optarg, "ESTIMATED") == 0))
+ {
+ io->mod->s_opt->opt_pinvar = YES;
+ io->mod->ras->invar = YES;
+ }
+
+ else if ((atof(optarg) < 0.0) || (atof(optarg) > 1.0))
+ {
+ char choix;
+ PhyML_Printf("\n. The proportion of invariable site must be a number between 0.0 and 1.0\n");
+ PhyML_Printf("\n. Type any key to exit.");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+ else
+ {
+ io->mod->ras->pinvar->v = (phydbl)atof(optarg);
+ if (io->mod->ras->pinvar->v > 0.0+SMALL)
+ io->mod->ras->invar = 1;
+ else
+ io->mod->ras->invar = 0;
+ io->mod->s_opt->opt_pinvar = 0;
+ }
+ break;
+ }
case 'o':
{
if(!strcmp(optarg,"tlr"))
{
- io->mod->s_opt->opt_topo = 1;
- io->mod->s_opt->opt_bl = 1;
+ io->mod->s_opt->opt_topo = YES;
+ io->mod->s_opt->opt_bl = YES;
+ io->mod->s_opt->opt_subst_param = YES;
}
else if(!strcmp(optarg,"tl"))
{
- io->mod->s_opt->opt_topo = 1;
- io->mod->s_opt->opt_bl = 1;
+ io->mod->s_opt->opt_topo = YES;
+ io->mod->s_opt->opt_bl = YES;
+ io->mod->s_opt->opt_subst_param = NO;
}
else if(!strcmp(optarg,"t"))
{
@@ -862,145 +1465,261 @@ void Read_Command_Line(option *io, int argc, char **argv)
}
else if(!strcmp(optarg,"lr"))
{
- io->mod->s_opt->opt_topo = 0;
- io->mod->s_opt->opt_bl = 1;
+ io->mod->s_opt->opt_topo = NO;
+ io->mod->s_opt->opt_bl = YES;
+ io->mod->s_opt->opt_subst_param = YES;
}
else if(!strcmp(optarg,"l"))
{
- io->mod->s_opt->opt_topo = 0;
- io->mod->s_opt->opt_bl = 1;
+ io->mod->s_opt->opt_topo = NO;
+ io->mod->s_opt->opt_bl = YES;
+ io->mod->s_opt->opt_subst_param = NO;
}
else if(!strcmp(optarg,"r"))
{
- io->mod->s_opt->opt_topo = 0;
- io->mod->s_opt->opt_bl = 0;
+ io->mod->s_opt->opt_topo = NO;
+ io->mod->s_opt->opt_bl = NO;
+ io->mod->s_opt->opt_subst_param = YES;
}
else if(!strcmp(optarg,"none") || !strcmp(optarg,"n"))
{
- io->mod->s_opt->opt_topo = 0;
- io->mod->s_opt->opt_bl = 0;
+ io->mod->s_opt->opt_topo = NO;
+ io->mod->s_opt->opt_bl = NO;
+ io->mod->s_opt->opt_subst_param = NO;
}
else
{
char choix;
- printf ("\n. The optimization parameter must be 'tlr' or 'tl' or 'lr' or 'l' or 'r' or ''.");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ PhyML_Printf ("\n. The optimization parameter must be 'tlr' or 'tl' or 'lr' or 'l' or 'r' or 'n'.");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
Exit("\n");
}
break;
}
+
case '?':
- {
- char choix;
- if (isprint (optopt))
- printf ("\n. Unknown option `-%c'.\n", optopt);
- else
- printf ("\n. Unknown option character `\\x%x'.\n", optopt);
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ {
+ Exit("\n");
break;
}
+ case -1:
+ {
+ break;
+ }
+
default:
- Usage();
- }
-}
-
-
- if(io->print_site_lnl)
- {
- strcpy(io->out_lk_file,io->in_seq_file);
- strcat(io->out_lk_file, "_phyml_lk.txt");
- io->fp_out_lk = Openfile(io->out_lk_file,1);
- }
-
- if(io->print_trace)
- {
- strcpy(io->out_trace_file,io->in_seq_file);
- strcat(io->out_trace_file,"_phyml_trace.txt");
- io->fp_out_trace = Openfile(io->out_trace_file,1);
- }
-
- if(io->mod->s_opt->random_input_tree)
- {
- strcpy(io->out_best_tree_file,io->in_seq_file);
- strcat(io->out_best_tree_file,"_phyml_best_tree.txt");
- }
-
- if((io->print_boot_trees) && (io->mod->bootstrap > 0))
- {
- strcpy(io->out_boot_tree_file,io->in_seq_file);
- strcat(io->out_boot_tree_file,"_phyml_boot_trees.txt");
- io->fp_out_boot_tree = Openfile(io->out_boot_tree_file,1);
-
- strcpy(io->out_boot_stats_file,io->in_seq_file);
- strcat(io->out_boot_stats_file,"_phyml_boot_stats.txt");
- io->fp_out_boot_stats = Openfile(io->out_boot_stats_file,1);
- }
+ {
+ Usage();
+ break;
+ }
+ }
+ }while(c != -1);
+
+ /* if((io->mod->whichmodel == K80) || (io->mod->whichmodel == JC69)) */
+ /* { */
+ /* if(io->mod->s_opt->opt_state_freq) */
+ /* { */
+ /* char c; */
+ /* PhyML_Printf("\n. WARNING: nucleotide frequencies must be set to 1/4 with this model.\n"); */
+ /* PhyML_Printf("\n. Type the enter key to resume the analysis.\n"); */
+ /* scanf("%c",&c); */
+ /* } */
+ /* io->mod->s_opt->opt_state_freq = 0; */
+ /* } */
+
+
+ if(io->mod->s_opt->constrained_br_len == YES)
+ {
+ io->mod->s_opt->opt_topo = NO;
+ /* io->mod->s_opt->opt_bl = NO; */
+ }
+
+
+ if(io->do_tbe == YES)
+ {
+ io->do_alrt = NO;
+ io->do_boot = NO;
+ }
+ else
+ {
+ if(io->do_alrt == NO && io->n_boot_replicates > 0) io->do_boot = YES;
+ }
+
#ifndef PHYML
- if((open_ps_file) || (io->m4_model == YES))
- {
- strcpy(io->out_ps_file,io->in_seq_file);
- strcat(io->out_ps_file, "_mc_tree.ps");
- io->fp_out_ps = Openfile(io->out_ps_file,1);
- }
+ if((open_ps_file) || (io->m4_model == YES))
+ {
+ strcpy(io->out_ps_file,io->in_align_file);
+ strcat(io->out_ps_file, "_mc_tree.ps");
+ io->fp_out_ps = Openfile(io->out_ps_file,WRITE);
+ }
#endif
+
+
+ if(io->datatype == UNDEFINED) io->datatype = NT;
+
+ if ((io->datatype == NT) && (io->mod->whichmodel > 10))
+ {
+ char choix;
+ PhyML_Printf("\n. Err.: model incompatible with the data type. Please use JC69, K80, F81, HKY, F84, TN93 or GTR\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Warn_And_Exit("\n");
+ }
+ else if ((io->datatype == AA) && (io->mod->whichmodel < 11))
+ {
+ char choix;
+ PhyML_Printf("\n. Err.: model incompatible with the data type. Please use LG, Dayhoff, JTT, MtREV, WAG, DCMut, RtREV, CpREV, VT, Blosum62, MtMam, MtArt, HIVw, HIVb or AB.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+
+ if(io->mod->use_m4mod == NO)
+ {
+ io->mod->s_opt->opt_cov_delta = 0;
+ io->mod->s_opt->opt_cov_alpha = 0;
+ io->mod->s_opt->opt_cov_free_rates = 0;
+ }
+
+ if((io->mod->s_opt->opt_cov_free_rates) && (io->mod->s_opt->opt_cov_alpha))
+ {
+ io->mod->s_opt->opt_cov_free_rates = 1;
+#ifdef M4
+ io->mod->m4mod->use_cov_alpha = 0;
+ io->mod->m4mod->use_cov_free = 1;
+#endif
+ }
+
+ if(io->print_site_lnl && io->fp_in_align != NULL)
+ {
+ strcpy(io->out_lk_file,io->in_align_file);
+ strcat(io->out_lk_file, "_phyml_lk");
+ if(io->append_run_ID) { strcat(io->out_lk_file,"_"); strcat(io->out_lk_file,io->run_id_string); }
+ strcat(io->out_lk_file, ".txt");
+ io->fp_out_lk = Openfile(io->out_lk_file,1);
+ }
+
+ if(io->print_trace && io->fp_in_align != NULL)
+ {
+ strcpy(io->out_trace_file,io->in_align_file);
+ strcat(io->out_trace_file,"_phyml_trace");
+ if(io->append_run_ID) { strcat(io->out_trace_file,"_"); strcat(io->out_trace_file,io->run_id_string); }
+ strcat(io->out_trace_file,".txt");
+ io->fp_out_trace = Openfile(io->out_trace_file,WRITE);
+ }
+
+ if(io->print_json_trace && io->fp_in_align != NULL)
+ {
+ strcpy(io->out_json_trace_file,io->in_align_file);
+ strcat(io->out_json_trace_file,"_phyml_trace");
+ if(io->append_run_ID) { strcat(io->out_json_trace_file,"_"); strcat(io->out_json_trace_file,io->run_id_string); }
+ strcat(io->out_json_trace_file,".json");
+ io->fp_out_json_trace = Openfile(io->out_json_trace_file,READWRITE);
+ }
+
+ if(io->mod->s_opt->random_input_tree && io->fp_in_align != NULL)
+ {
+ strcpy(io->out_trees_file,io->in_align_file);
+ strcat(io->out_trees_file,"_phyml_rand_trees");
+ if(io->append_run_ID) { strcat(io->out_trees_file,"_"); strcat(io->out_trees_file,io->run_id_string); }
+ strcat(io->out_trees_file,".txt");
+ io->fp_out_trees = Openfile(io->out_trees_file,1);
+ }
+
+ if((io->print_boot_trees) && (io->do_boot == YES) && (io->fp_in_align != NULL))
+ {
+ strcpy(io->out_boot_tree_file,io->in_align_file);
+ strcat(io->out_boot_tree_file,"_phyml_boot_trees");
+ if(io->append_run_ID) { strcat(io->out_boot_tree_file,"_"); strcat(io->out_boot_tree_file,io->run_id_string); }
+ strcat(io->out_boot_tree_file,".txt");
+ io->fp_out_boot_tree = Openfile(io->out_boot_tree_file,1);
+
+ strcpy(io->out_boot_stats_file,io->in_align_file);
+ strcat(io->out_boot_stats_file,"_phyml_boot_stats");
+ if(io->append_run_ID) { strcat(io->out_boot_stats_file,"_"); strcat(io->out_boot_stats_file,io->run_id_string); }
+ strcat(io->out_boot_stats_file,".txt");
+ io->fp_out_boot_stats = Openfile(io->out_boot_stats_file,1);
+ }
+
+ if(io->append_run_ID && io->fp_in_align != NULL)
+ {
+ strcat(io->out_tree_file,"_");
+ strcat(io->out_stats_file,"_");
+ strcat(io->out_tree_file,io->run_id_string);
+ strcat(io->out_stats_file,io->run_id_string);
+ }
+
+ if(io->fp_in_align != NULL)
+ {
+ strcat(io->out_tree_file,".txt");
+ strcat(io->out_stats_file,".txt");
+ }
+
+
+#ifdef PHYREX
+ strcat(io->out_summary_file,".txt");
+#endif
- if((use_gamma) && (io->mod->n_catg == 1))
- {
- io->mod->n_catg = 4;
- }
-
- if((io->mod->s_opt->n_rand_starts) &&
- (io->mod->s_opt->topo_search != SPR_MOVE) &&
- (io->mod->s_opt->random_input_tree))
- {
- Warn_And_Exit("\n. Random starting tree option is only compatible with a full-SPR search.\n");
- }
-
- if ((io->mod->datatype == NT) && (io->mod->whichmodel > 10))
- {
- char choix;
- printf("\n. Err: model incompatible with the data type. Please use JC69, K80, F81, HKY, F84, TN93 or GTR\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Warn_And_Exit("\n");
- }
- else if ((io->mod->datatype == AA) && (io->mod->whichmodel < 11))
- {
- char choix;
- printf("\n. Err: model incompatible with the data type. Please use LG, Dayhoff, JTT, MtREV, WAG, DCMut, RtREV, CpREV, VT, Blosum62, MtMam, MtArt, HIVw or HIVb.\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
- Exit("\n");
- }
-
- if(io->m4_model == YES)
- {
- io->mod->ns *= io->mod->m4mod->n_h;
- io->mod->use_m4mod = 1;
- M4_Make_Complete(io->mod->m4mod->n_h,
- io->mod->m4mod->n_o,
- io->mod->m4mod);
- }
- else
- {
- io->mod->s_opt->opt_cov_delta = 0;
- io->mod->s_opt->opt_cov_alpha = 0;
- io->mod->s_opt->opt_cov_free_rates = 0;
- }
-
- if((io->mod->s_opt->opt_cov_free_rates) && (io->mod->s_opt->opt_cov_alpha))
- {
- io->mod->s_opt->opt_cov_free_rates = 0;
- io->mod->m4mod->use_cov_alpha = 0;
- io->mod->m4mod->use_cov_free = 1;
- }
-
- return;
+
+ if(io->mod->ras->n_catg == 1) io->mod->s_opt->opt_alpha = 0;
+
+ if(io->mod->s_opt->opt_subst_param == NO)
+ {
+ io->mod->s_opt->opt_alpha = NO;
+ io->mod->s_opt->opt_kappa = NO;
+ io->mod->s_opt->opt_lambda = NO;
+ io->mod->s_opt->opt_pinvar = NO;
+ io->mod->s_opt->opt_rr = NO;
+ }
+
+ if(io->mod->whichmodel != K80 &&
+ io->mod->whichmodel != HKY85 &&
+ io->mod->whichmodel != F84 &&
+ io->mod->whichmodel != TN93)
+ {
+ io->mod->s_opt->opt_kappa = NO;
+ }
+
+ if(io->datatype == AA && io->mod->whichmodel == CUSTOMAA && !io->mod->fp_aa_rate_mat)
+ {
+ PhyML_Printf("\n. Custom model option with amino-acid requires you to specify a rate matrix file through the '--aa_rate_file' option.\n");
+ Exit("\n");
+ }
+
+#if !defined(PHYTIME)
+ // Make sure you don't erase the input file...
+ if(!strcmp(io->out_tree_file,io->in_align_file) ||
+ !strcmp(io->out_stats_file,io->in_align_file))
+ {
+ PhyML_Fprintf(stderr,"\n. The alignment file '%s' does not seem to exist...",io->in_align_file);
+ Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ }
+
+ if(io->fp_in_align != NULL)
+ {
+ io->fp_out_tree = Openfile(io->out_tree_file,writemode);
+ io->fp_out_stats = Openfile(io->out_stats_file,writemode);
+ }
+#endif
+
+#if defined(PHYREX)
+ if(io->fp_in_align != NULL) io->fp_out_summary = Openfile(io->out_summary_file,writemode);
+#endif
+
+
+ if(io->quiet == NO)
+ {
+ PhyML_Printf("\n\n. Command line: ");
+ for(i=0;i
#ifndef CL_H
#define CL_H
-void Read_Command_Line(option *input, int argc, char **argv);
+#include
+#include
+#include "utilities.h"
+#include "help.h"
+#include "models.h"
+#include "free.h"
+#include "interface.h"
+#include "invitee.h"
+#include "date.h"
+
+
+int Read_Command_Line(option *input, int argc, char **argv);
#endif
diff --git a/phyml/date.c b/phyml/date.c
new file mode 100644
index 0000000..e989dbc
--- /dev/null
+++ b/phyml/date.c
@@ -0,0 +1,1408 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+
+/* Routines for molecular dating */
+
+
+#include "date.h"
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int DATE_Main(int argc, char **argv)
+{
+ option *io;
+
+ io = Get_Input(argc,argv);
+ Free(io);
+ return(0);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void DATE_XML(char *xml_filename)
+{
+ FILE *fp_xml_in;
+ xml_node *xnd,*xroot;
+ t_tree *mixt_tree,*tree;
+ phydbl *res;
+ int seed;
+ char *dum_string;
+
+ mixt_tree = XML_Process_Base(xml_filename);
+ assert(mixt_tree);
+
+ mixt_tree->rates = RATES_Make_Rate_Struct(mixt_tree->n_otu);
+ RATES_Init_Rate_Struct(mixt_tree->rates,NULL,mixt_tree->n_otu);
+
+ tree = mixt_tree;
+ do
+ {
+ // All rate stuctures point to the same object
+ tree->rates = mixt_tree->rates;
+ tree = tree->next;
+ }
+ while(tree);
+
+
+ fp_xml_in = fopen(xml_filename,"r");
+ if(!fp_xml_in)
+ {
+ PhyML_Fprintf(stderr,"\n. Could not find the XML file '%s'.\n",xml_filename);
+ Exit("\n");
+ }
+
+ /* xroot = XML_Load_File(fp_xml_in); */
+ xroot = mixt_tree->xml_root;
+
+ if(xroot == NULL)
+ {
+ PhyML_Fprintf(stderr,"\n. Encountered an issue while loading the XML file.\n");
+ Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ }
+
+ xnd = XML_Search_Node_Name("phytime",NO,xroot);
+
+ if(xnd == NULL)
+ {
+ PhyML_Fprintf(stderr,"\n. Cound not find the \"root\" of the XML file (it should have \'phytime\' as tag name).\n");
+ Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ }
+
+ dum_string = XML_Get_Attribute_Value(xnd,"mcmc.chain.len");
+ if(dum_string != NULL) mixt_tree->io->mcmc->chain_len = (int)String_To_Dbl(dum_string);
+
+ dum_string = XML_Get_Attribute_Value(xnd,"mcmc.sample.every");
+ if(dum_string != NULL) mixt_tree->io->mcmc->sample_interval = (int)String_To_Dbl(dum_string);
+
+ dum_string = XML_Get_Attribute_Value(xnd,"mcmc.print.every");
+ if(dum_string != NULL) mixt_tree->io->mcmc->print_every = (int)String_To_Dbl(dum_string);
+
+ dum_string = XML_Get_Attribute_Value(xnd,"mcmc.burnin");
+ if(dum_string != NULL) mixt_tree->io->mcmc->chain_len_burnin = (int)String_To_Dbl(dum_string);
+
+
+ dum_string = XML_Get_Attribute_Value(xnd,"ignore.sequences");
+ if(dum_string != NULL) mixt_tree->eval_alnL = NO;
+
+ dum_string = XML_Get_Attribute_Value(xnd,"ignore.seq");
+ if(dum_string != NULL) mixt_tree->eval_alnL = NO;
+
+ dum_string = XML_Get_Attribute_Value(xnd,"ignore.data");
+ if(dum_string != NULL) mixt_tree->eval_alnL = NO;
+
+
+ dum_string = XML_Get_Attribute_Value(xnd,"mutmap");
+ if(dum_string != NULL)
+ {
+ int select = XML_Validate_Attr_Int(dum_string,6,
+ "true","yes","y",
+ "false","no","n");
+ if(select < 3) mixt_tree->io->mutmap = YES;
+ else mixt_tree->io->mutmap = NO;
+ }
+
+
+
+
+ // Looking for XML node with rate-across-lineage info
+ xnd = XML_Search_Node_Name("lineagerates",YES,xroot);
+
+
+ if(xnd == NULL)
+ {
+ PhyML_Fprintf(stdout,"\n. The model of rate variation across lineages is not specified.");
+ PhyML_Fprintf(stdout,"\n. Using the geometric Brownian model (see Guindon, 2012, Syst. Biol.).\n");
+ mixt_tree->rates->model = GUINDON;
+ mixt_tree->mod->gamma_mgf_bl = YES;
+ strcpy(mixt_tree->rates->model_name,"geometric Brownian");
+ }
+ else
+ {
+ char *model_name;
+ model_name = XML_Get_Attribute_Value(xnd,"model");
+
+ if(model_name == NULL)
+ {
+ PhyML_Fprintf(stderr,"\n. Please specify a model of rate variation across lineages,");
+ PhyML_Fprintf(stderr,"\n. e.g., .");
+ PhyML_Fprintf(stderr,"\n. See the manual for more options.");
+ assert(FALSE);
+ }
+ else
+ {
+ if(!strcmp(model_name,"geometricbrownian"))
+ {
+ mixt_tree->rates->model = GUINDON;
+ mixt_tree->mod->gamma_mgf_bl = YES;
+ strcpy(mixt_tree->rates->model_name,"geometric Brownian");
+ }
+ else if(!strcmp(model_name,"geometric"))
+ {
+ mixt_tree->rates->model = GUINDON;
+ mixt_tree->mod->gamma_mgf_bl = YES;
+ strcpy(mixt_tree->rates->model_name,"geometric Brownian");
+ }
+ else if(!strcmp(model_name,"brownian"))
+ {
+ mixt_tree->rates->model = GUINDON;
+ mixt_tree->mod->gamma_mgf_bl = YES;
+ strcpy(mixt_tree->rates->model_name,"geometric Brownian");
+ }
+ else if(!strcmp(model_name,"geo"))
+ {
+ mixt_tree->rates->model = GUINDON;
+ mixt_tree->mod->gamma_mgf_bl = YES;
+ strcpy(mixt_tree->rates->model_name,"geometric Brownian");
+ }
+ else if(!strcmp(model_name,"lognormal"))
+ {
+ mixt_tree->rates->model = LOGNORMAL;
+ mixt_tree->mod->gamma_mgf_bl = NO;
+ strcpy(mixt_tree->rates->model_name,"lognormal (uncorrelated)");
+ }
+ else if(!strcmp(model_name,"normal"))
+ {
+ mixt_tree->rates->model = LOGNORMAL;
+ mixt_tree->mod->gamma_mgf_bl = NO;
+ strcpy(mixt_tree->rates->model_name,"lognormal (uncorrelated)");
+ }
+ else if(!strcmp(model_name,"strictclock"))
+ {
+ mixt_tree->rates->model = STRICTCLOCK;
+ mixt_tree->mod->gamma_mgf_bl = NO;
+ strcpy(mixt_tree->rates->model_name,"strict clock");
+ }
+ else if(!strcmp(model_name,"clock"))
+ {
+ mixt_tree->rates->model = STRICTCLOCK;
+ mixt_tree->mod->gamma_mgf_bl = NO;
+ strcpy(mixt_tree->rates->model_name,"strict clock");
+ }
+ else
+ {
+ assert(FALSE);
+ }
+ }
+ }
+
+
+ // Looking for calibration info
+ xnd = XML_Search_Node_Name("calibration",YES,xroot);
+
+ if(xnd == NULL)
+ {
+ PhyML_Fprintf(stderr,"\n. No calibration information seems to be provided.");
+ PhyML_Fprintf(stderr,"\n. Please amend your XML file. \n");
+ assert(FALSE);
+ }
+ else
+ {
+ assert(xnd->child);
+ if(XML_Search_Node_Name("upper",NO,xnd->child) == NULL && XML_Search_Node_Name("lower",NO,xnd->child) == NULL)
+ {
+ PhyML_Fprintf(stderr,"\n. There is no calibration information provided. \n");
+ PhyML_Fprintf(stderr,"\n. Please check your data. \n");
+ assert(FALSE);
+ }
+ }
+
+
+
+ /* MIXT_Check_Model_Validity(mixt_tree); */
+ /* MIXT_Init_Model(mixt_tree); */
+ /* Print_Data_Structure(NO,stdout,mixt_tree); */
+ /* tree = MIXT_Starting_Tree(mixt_tree); */
+ /* Copy_Tree(tree,mixt_tree); */
+ /* Free_Tree(tree); */
+ /* MIXT_Connect_Cseqs_To_Nodes(mixt_tree); */
+ /* MIXT_Init_T_Beg(mixt_tree); */
+ /* MIXT_Chain_Edges(mixt_tree); */
+ /* MIXT_Chain_Nodes(mixt_tree); */
+ /* MIXT_Make_Tree_For_Pars(mixt_tree); */
+ /* MIXT_Make_Tree_For_Lk(mixt_tree); */
+ /* MIXT_Make_Spr(mixt_tree); */
+ /* MIXT_Chain_All(mixt_tree); */
+ /* Add_Root(mixt_tree->a_edges[0],mixt_tree); */
+ /* MIXT_Check_Edge_Lens_In_All_Elem(mixt_tree); */
+ /* MIXT_Turn_Branches_OnOff_In_All_Elem(ON,mixt_tree); */
+ /* MIXT_Check_Invar_Struct_In_Each_Partition_Elem(mixt_tree); */
+ /* MIXT_Check_RAS_Struct_In_Each_Partition_Elem(mixt_tree); */
+
+ /* XML_Read_Calibration(xroot,mixt_tree); */
+
+ /* MIXT_Chain_Cal(mixt_tree); */
+
+ seed = (mixt_tree->io->r_seed < 0)?(time(NULL)):(mixt_tree->io->r_seed);
+ srand(seed);
+ mixt_tree->io->r_seed = seed;
+
+
+ MIXT_Check_Model_Validity(mixt_tree);
+ MIXT_Init_Model(mixt_tree);
+ Print_Data_Structure(NO,stdout,mixt_tree);
+ tree = MIXT_Starting_Tree(mixt_tree);
+ Add_Root(tree->a_edges[0],tree);
+ Copy_Tree(tree,mixt_tree);
+ Free_Tree(tree);
+ MIXT_Connect_Cseqs_To_Nodes(mixt_tree);
+ MIXT_Init_T_Beg(mixt_tree);
+ MIXT_Make_Tree_For_Lk(mixt_tree);
+ MIXT_Make_Tree_For_Pars(mixt_tree);
+ MIXT_Make_Spr(mixt_tree);
+ MIXT_Chain_All(mixt_tree);
+ MIXT_Check_Edge_Lens_In_All_Elem(mixt_tree);
+ MIXT_Turn_Branches_OnOff_In_All_Elem(ON,mixt_tree);
+ MIXT_Check_Invar_Struct_In_Each_Partition_Elem(mixt_tree);
+ MIXT_Check_RAS_Struct_In_Each_Partition_Elem(mixt_tree);
+
+ XML_Read_Calibration(xroot,mixt_tree);
+ MIXT_Chain_Cal(mixt_tree);
+
+ res = DATE_MCMC(mixt_tree);
+
+
+ // Cleaning up...
+ RATES_Free_Rates(mixt_tree->rates);
+ RATES_Free_Rates(mixt_tree->extra_tree->rates);
+ MCMC_Free_MCMC(mixt_tree->mcmc);
+ MCMC_Free_MCMC(mixt_tree->extra_tree->mcmc);
+ Free_Mmod(mixt_tree->mmod);
+ Free_Spr_List_One_Edge(mixt_tree);
+ Free_Tree_Pars(mixt_tree);
+ Free_Tree_Lk(mixt_tree);
+
+ if(mixt_tree->io->fp_out_trees) fclose(mixt_tree->io->fp_out_trees);
+ if(mixt_tree->io->fp_out_tree) fclose(mixt_tree->io->fp_out_tree);
+ if(mixt_tree->io->fp_out_stats) fclose(mixt_tree->io->fp_out_stats);
+ if(mixt_tree->io->fp_out_json_trace) fclose(mixt_tree->io->fp_out_json_trace);
+ Free_Input(mixt_tree->io);
+
+
+ tree = mixt_tree;
+ do
+ {
+ Free_Calign(tree->data);
+ tree = tree->next_mixt;
+ }
+ while(tree);
+
+ tree = mixt_tree;
+ do
+ {
+ Free_Optimiz(tree->mod->s_opt);
+ tree = tree->next;
+ }
+ while(tree);
+
+
+ Free_Model_Complete(mixt_tree->mod);
+ Free_Model_Basic(mixt_tree->mod);
+ Free_Tree(mixt_tree->extra_tree);
+ Free_Tree(mixt_tree);
+ Free(res);
+ XML_Free_XML_Tree(xroot);
+ fclose(fp_xml_in);
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// Update t_prior_min and t_prior_max on a given ranked tree
+// given (primary and secondary) calibration information.
+// Make sure secondary and primary calibration are up-to-date
+void DATE_Update_T_Prior_MinMax(t_tree *tree)
+{
+ int i,j;
+
+
+ for(i=0;i<2*tree->n_otu-1;++i) // All nodes
+ {
+ tree->rates->t_prior_max[i] = +INFINITY;
+ tree->rates->t_prior_min[i] = -INFINITY;
+
+ if(tree->a_nodes[i]->n_cal > 0) // Primary calibration found on that node
+ {
+ for(j=0;ja_nodes[i]->n_cal;++j)
+ {
+ tree->rates->t_prior_max[i] = MIN(tree->rates->t_prior_max[i],tree->a_nodes[i]->cal[j]->upper);
+ tree->rates->t_prior_min[i] = MAX(tree->rates->t_prior_min[i],tree->a_nodes[i]->cal[j]->lower);
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void DATE_Assign_Primary_Calibration(t_tree *tree)
+{
+ int i,j,idx,node_num;
+ t_clad *clade;
+ t_cal *cal;
+
+ clade = NULL;
+ cal = NULL;
+
+ for(i=0;irates->n_cal;++i)
+ {
+ cal = tree->rates->a_cal[i];
+ if(cal->clade_list != NULL)
+ {
+ clade = cal->clade_list[cal->current_clade_idx];
+ clade->target_nd = NULL;
+ }
+ }
+
+ for(i=0;i<2*tree->n_otu-1;++i)
+ for(j=0;ja_nodes[i]->cal[j] = NULL;
+ tree->a_nodes[i]->n_cal = 0;
+ }
+
+ for(i=0;irates->n_cal;++i)
+ {
+ cal = tree->rates->a_cal[i];
+
+ if(cal->clade_list != NULL)
+ {
+ clade = cal->clade_list[cal->current_clade_idx];
+
+ node_num = Find_Clade(clade->tax_list,
+ clade->n_tax,
+ tree);
+
+ clade->target_nd = tree->a_nodes[node_num];
+
+ idx = tree->a_nodes[node_num]->n_cal;
+ tree->a_nodes[node_num]->cal[idx] = tree->rates->a_cal[i];
+ tree->a_nodes[node_num]->n_cal++;
+
+
+ if(tree->a_nodes[node_num]->n_cal == MAX_N_CAL)
+ {
+ PhyML_Fprintf(stderr,"\n. A node cannot have more than %d calibration",MAX_N_CAL);
+ PhyML_Fprintf(stderr,"\n. constraints attached to it. Feel free to increase the");
+ PhyML_Fprintf(stderr,"\n. value of the variable MAX_N_CAL in utilities.h if");
+ PhyML_Fprintf(stderr,"\n. necessary.");
+ Exit("\n");
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// Return splitted calibration intervals. Make sure all primary
+// and secondary calibration intervals are up-to-date.
+phydbl *DATE_Splitted_Calibration(t_tree *tree)
+{
+ phydbl *minmax,*splitted_cal,buff;
+ int i,len,done;
+
+ // One t_prior_min and one t_prior_max per internal nodes except root, so
+ // 2 x # of internal nodes boundaries in total at most.
+ minmax = (phydbl *)mCalloc(2*(tree->n_otu-2),sizeof(phydbl));
+ For(i,2*(tree->n_otu-2)) minmax[i] = +INFINITY;
+ splitted_cal = (phydbl *)mCalloc((int)(4*tree->n_otu-10),sizeof(phydbl));
+
+
+ len = 0;
+ for(i = tree->n_otu; i < 2*tree->n_otu-1; i++)
+ {
+ if(tree->a_nodes[i] != tree->n_root)
+ {
+ minmax[len] = MAX(tree->rates->t_prior_min[i],tree->rates->nd_t[tree->n_root->num]);
+ minmax[len+1] = tree->rates->t_prior_max[i];
+ len+=2;
+ }
+ }
+
+
+ // Bubble sort of all these times in increasing order
+ do
+ {
+ done = YES;
+ for(i=0;i minmax[i+1])
+ {
+ buff = minmax[i];
+ minmax[i] = minmax[i+1];
+ minmax[i+1] = buff;
+ done = NO;
+ }
+ }
+ }
+ while(done == NO);
+
+ for(i=0;i minmax[i+1]));
+
+ // Remove ties
+ for(i=0;i minmax[i+1])
+ {
+ buff = minmax[i];
+ minmax[i] = minmax[i+1];
+ minmax[i+1] = buff;
+ done = NO;
+ }
+ }
+ }
+ while(done == NO);
+
+ splitted_cal[0] = minmax[0];
+ len = 1;
+ for(i = 1; i < 2*(tree->n_otu-2); i++)
+ {
+ splitted_cal[len] = minmax[i];
+ if(len+1 < 4*tree->n_otu-10) splitted_cal[len+1] = minmax[i];
+ len+=2;
+ }
+
+ /* For(i,4*tree->n_otu-10) PhyML_Printf("\n. split -- %3d %12f",i,splitted_cal[i]); */
+
+ Free(minmax);
+
+ return splitted_cal;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl DATE_J_Sum_Product(t_tree *tree)
+{
+ phydbl prod, total,*splitted_cal;
+ int fact,idx,ans,rk;
+
+ DATE_Assign_Primary_Calibration(tree);
+ DATE_Update_T_Prior_MinMax(tree);
+
+ splitted_cal = DATE_Splitted_Calibration(tree);
+
+ ans = 0;
+ total = 0.0;
+ idx = 0;
+ rk = 1;
+ do
+ {
+ prod = 1.0;
+ fact = 1;
+ ans = DATE_J_Sum_Product_Pre(tree->a_nodes[tree->rates->t_rank[rk]], // Oldest node after root (as rk=1)
+ idx,
+ -1,
+ prod,fact,&total,splitted_cal,rk,tree);
+ idx+=2;
+ }
+ while(ans != 1);
+
+ Free(splitted_cal);
+
+ return(total);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int DATE_J_Sum_Product_Pre(t_node *d, int split_idx_d, int split_idx_a, phydbl prod, int fact, phydbl *total, phydbl *splitted_cal, int rk, t_tree *tree)
+{
+ int ans,idx;
+
+ ans = DATE_Is_Split_Accessible(d,split_idx_d,splitted_cal,tree);
+
+ switch(ans)
+ {
+ case 1 : // split interval is younger than t_prior_max. No need to go further.
+ {
+ return ans;
+ break;
+ }
+ case 0 : // split interval is within [t_prior_min,t_prior_max]
+ {
+ int local_ans;
+
+ // Calculate J for this time interval
+ prod *= DATE_J(tree->rates->birth_rate,
+ tree->rates->death_rate,
+ FABS(splitted_cal[split_idx_d+1]),
+ FABS(splitted_cal[split_idx_d]));
+
+ // Remove factorial term from current product
+ prod *= fact;
+
+ if(split_idx_d == split_idx_a) fact++;
+ else fact = 1;
+
+ prod /= fact;
+
+ if(tree->rates->t_rank[tree->n_otu-2] == d->num) // Youngest internal node
+ {
+ (*total) += prod;
+ return 0;
+ }
+
+ idx = split_idx_d;
+ do
+ {
+ local_ans = DATE_J_Sum_Product_Pre(tree->a_nodes[tree->rates->t_rank[rk+1]],
+ idx,
+ split_idx_d,
+ prod,fact,total,splitted_cal,rk+1,tree);
+ idx+=2;
+ }
+ while(local_ans == 0);
+
+ break;
+ }
+ case -1 : // split interval is older than t_prior_min. Move forward.
+ {
+ int local_ans;
+ // Advance to younger split intervals and stop once you're in
+ idx = split_idx_d+2;
+ do
+ {
+ local_ans = DATE_J_Sum_Product_Pre(d,
+ idx,
+ idx+1,
+ prod,fact,total,splitted_cal,rk,tree);
+ idx+=2;
+ }
+ while(local_ans == -1);
+ break;
+ }
+ }
+
+ return ans;
+}
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int DATE_Is_Split_Accessible(t_node *d, int which, phydbl *splitted_cal, t_tree *tree)
+{
+ phydbl eps;
+
+ assert(d->tax == NO);
+
+ eps = FABS(tree->rates->t_prior_min[d->num]) / 1.E+6;
+
+ assert(eps > MDBL_MIN);
+
+ // Upper and lower bound of splitted calibration interval are equal to zero
+ if(Are_Equal(splitted_cal[which],0.0,eps) && Are_Equal(splitted_cal[which+1],0.0,eps)) return +1;
+
+
+ if(Are_Equal(tree->rates->t_prior_min[d->num],splitted_cal[which],eps) ||
+ Are_Equal(tree->rates->t_prior_max[d->num],splitted_cal[which+1],eps) ||
+ (tree->rates->t_prior_min[d->num] < splitted_cal[which] &&
+ tree->rates->t_prior_max[d->num] > splitted_cal[which+1])) return 0; // splitted interval is within [t_prior_min,t_prior_max]
+ else if(Are_Equal(tree->rates->t_prior_max[d->num],splitted_cal[which],eps) ||
+ splitted_cal[which] > tree->rates->t_prior_max[d->num]) return +1; // splitted interval is younger than [t_prior_min,t_prior_max]
+ else if(Are_Equal(tree->rates->t_prior_min[d->num],splitted_cal[which+1],eps) ||
+ splitted_cal[which+1] < tree->rates->t_prior_min[d->num]) return -1; // splitted interval is older than [t_prior_min,t_prior_max]
+ else
+ {
+ PhyML_Printf("\n. d->num: %d d->tax: %d",d->num,d->tax);
+ PhyML_Printf("\n. t_prior_min: %f t_prior_max: %f",
+ tree->rates->t_prior_min[d->num],
+ tree->rates->t_prior_max[d->num]);
+ PhyML_Printf("\n. splitted_cal_min: %f splitted_cal_max: %f",
+ splitted_cal[which],
+ splitted_cal[which+1]);
+ PhyML_Printf("\n");
+ assert(FALSE); // splitted interval cannot be partially overlapping [t_prior_min,t_prior_max]
+ }
+ return(0);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl DATE_J(phydbl birth_r, phydbl death_r, phydbl t_min, phydbl t_pls)
+{
+ phydbl d,b,J;
+ assert(t_pls > t_min);
+ d = death_r;
+ b = birth_r;
+ J = (b-d)*(exp(t_min*d+t_pls*b) - exp(t_min*b+t_pls*d));
+ J /= ((b*exp(t_min*b)-d*exp(t_min*d)) * (b*exp(t_pls*b)-d*exp(t_pls*d)));
+ /* printf(" J : %f",J); */
+ return(J);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int DATE_Check_Calibration_Constraints(t_tree *tree)
+{
+ int i,j;
+ phydbl lower,upper;
+
+ lower = upper = -1.;
+
+ For(i,2*tree->n_otu-1)
+ {
+ if(tree->a_nodes[i]->n_cal > 1)
+ {
+ lower = tree->a_nodes[i]->cal[0]->lower;
+ upper = tree->a_nodes[i]->cal[0]->upper;
+ for(j=1; j < tree->a_nodes[i]->n_cal; j++)
+ {
+ lower = MAX(lower,tree->a_nodes[i]->cal[j]->lower);
+ upper = MIN(upper,tree->a_nodes[i]->cal[j]->upper);
+ if(upper < lower)
+ {
+ /* PhyML_Printf("\n. Inconsistency detected on node %d",i); */
+ return 0;
+ }
+ }
+ }
+ }
+ return 1;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// Check that time constraints are satisfied. Note: it is a
+// requirement to verify that the age of the root node is also
+// within correct boundaries
+int DATE_Check_Time_Constraints(t_tree *tree)
+{
+ for(int i=0;i<2*tree->n_otu-1;++i)
+ {
+ if(tree->a_nodes[i]->tax == NO)
+ {
+ if(tree->rates->nd_t[i] > tree->rates->t_prior_max[i] ||
+ tree->rates->nd_t[i] < tree->rates->t_prior_min[i])
+ {
+ /* PhyML_Printf("\n!!! Node %d t: %f min:%f max:%f", */
+ /* i, */
+ /* tree->rates->nd_t[i], */
+ /* tree->rates->t_prior_min[i], */
+ /* tree->rates->t_prior_max[i]); */
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl *DATE_MCMC(t_tree *tree)
+{
+ t_mcmc *mcmc;
+ char *s_tree;
+ int move, n_vars, i, j, adjust_len;
+ phydbl u;
+ phydbl *res;
+ FILE *fp_stats,*fp_tree;
+ int t_beg;
+
+ t_beg = (int)time(NULL);
+
+ fp_stats = tree->io->fp_out_stats;
+ fp_tree = tree->io->fp_out_tree;
+
+ if(tree->io->mutmap == YES) Make_MutMap(tree);
+
+ TIMES_Randomize_Tree_With_Time_Constraints(tree->rates->a_cal[0],tree);
+ MIXT_Propagate_Tree_Update(tree);
+
+
+ mcmc = MCMC_Make_MCMC_Struct();
+ tree->mcmc = mcmc;
+ MCMC_Init_MCMC_Struct(NULL,NULL,mcmc);
+ MCMC_Complete_MCMC(mcmc,tree);
+
+ MCMC_Randomize_Birth(tree);
+ MCMC_Randomize_Death(tree);
+ MCMC_Randomize_Clock_Rate(tree);
+ MCMC_Randomize_Rate_Across_Sites(tree);
+ MCMC_Randomize_Rates(tree);
+
+
+ n_vars = 10;
+ adjust_len = tree->io->mcmc->chain_len_burnin;
+ mcmc->sample_interval = tree->io->mcmc->sample_interval;
+ mcmc->print_every = tree->io->mcmc->print_every;
+ mcmc->chain_len = tree->io->mcmc->chain_len;
+ mcmc->chain_len_burnin = tree->io->mcmc->chain_len_burnin;
+ tree->rates->bl_from_rt = YES;
+
+ res = (phydbl *)mCalloc(tree->mcmc->chain_len / tree->mcmc->sample_interval * n_vars,sizeof(phydbl));
+
+ Set_Both_Sides(YES,tree);
+ Set_Update_Eigen(YES,tree->mod);
+ Lk(NULL,tree);
+ Set_Update_Eigen(NO,tree->mod);
+
+
+ RATES_Lk_Rates(tree);
+ DATE_Assign_Primary_Calibration(tree);
+ TIMES_Lk_Times(NO,tree);
+
+ /* Time_To_Branch(tree); */
+ /* tree->bl_ndigits = 1; */
+ /* printf("\n. Random init tree: %s",Write_Tree(tree)); */
+ /* tree->bl_ndigits = 7; */
+ RATES_Update_Cur_Bl(tree);
+
+
+ PhyML_Printf("\n. AVX enabled: %s",
+#if defined(__AVX__)
+ "yes"
+#else
+ "no"
+#endif
+ );
+ PhyML_Printf("\n. SSE enabled: %s",
+#if defined(__SSE3__)
+ "yes"
+#else
+ "no"
+#endif
+ );
+
+ PhyML_Printf("\n\n. Seed: %d",tree->io->r_seed);
+ PhyML_Printf("\n. Ignore sequences: %s",tree->eval_alnL == YES ? "no" : "yes");
+ PhyML_Printf("\n. Model of variation of rates across lineages: %s",tree->rates->model_name);
+ PhyML_Printf("\n. log(Pr(Seq|Tree)) = %f",tree->c_lnL);
+ PhyML_Printf("\n. log(Pr(Tree)) = %f",tree->rates->c_lnL_times);
+
+
+ tree->extra_tree = Make_Tree_From_Scratch(tree->n_otu,tree->data);
+ tree->extra_tree->mod = tree->mod;
+ Copy_Tree(tree,tree->extra_tree);
+ tree->extra_tree->rates = RATES_Make_Rate_Struct(tree->n_otu);
+ RATES_Init_Rate_Struct(tree->extra_tree->rates,NULL,tree->n_otu);
+ RATES_Copy_Rate_Struct(tree->rates,tree->extra_tree->rates,tree->n_otu);
+ tree->extra_tree->rates->model = LOGNORMAL;
+ RATES_Duplicate_Calib_Struct(tree,tree->extra_tree);
+ MIXT_Chain_Cal(tree->extra_tree);
+ DATE_Assign_Primary_Calibration(tree->extra_tree);
+ TIMES_Randomize_Tree_With_Time_Constraints(tree->extra_tree->rates->a_cal[0],tree->extra_tree);
+
+
+ TIMES_Lk_Times(NO,tree->extra_tree);
+ PhyML_Printf("\n. log(Pr(extra tree)) = %f",tree->extra_tree->rates->c_lnL_times);
+ mcmc = MCMC_Make_MCMC_Struct();
+ tree->extra_tree->mcmc = mcmc;
+ MCMC_Init_MCMC_Struct(NULL,NULL,mcmc);
+ MCMC_Complete_MCMC(mcmc,tree->extra_tree);
+
+ PhyML_Fprintf(fp_stats,"\n%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t",
+ "sample",
+ "lnL(posterior)",
+ "lnL(seq)",
+ "lnL(times)",
+ "lnL(rates)",
+ "birth",
+ "death",
+ "clock",
+ "root",
+ "tstv",
+ "nu");
+ for(i=0;imod->ras->n_catg;i++) PhyML_Fprintf(fp_stats,"rr%d\t",i);
+ for(i=0;imod->ras->n_catg;i++) PhyML_Fprintf(fp_stats,"pr%d\t",i);
+
+
+ for(i=0;irates->n_cal;++i)
+ {
+ t_cal *cal = tree->rates->a_cal[i];
+ for(j=0;jclade_list_size;++j)
+ {
+ t_clad *clade = cal->clade_list[j];
+ PhyML_Fprintf(fp_stats,"t(calib:%s_clade:%s)\t",cal->id,clade->id);
+ }
+ }
+
+ for(i=0;irates->n_cal;++i)
+ {
+ t_cal *cal = tree->rates->a_cal[i];
+ PhyML_Fprintf(fp_stats,"clade(calib:%s)\t",cal->id);
+ }
+
+
+ if(tree->rates->model == THORNE ||
+ tree->rates->model == LOGNORMAL ||
+ tree->rates->model == STRICTCLOCK)
+ for(i=0;i<2*tree->n_otu-2;++i) PhyML_Fprintf(fp_stats,"br%d\t",i);
+ else
+ for(i=0;i<2*tree->n_otu-1;++i) PhyML_Fprintf(fp_stats,"nr%d\t",i);
+
+ for(i=0;i<2*tree->n_otu-1;++i) if(tree->a_nodes[i]->tax == NO) PhyML_Fprintf(fp_stats,"t%d\t",i);
+
+ PhyML_Fprintf(fp_stats,"accRT\t");
+ PhyML_Fprintf(fp_stats,"tuneRT\t");
+
+ PhyML_Fprintf(fp_stats,"accT\t");
+ PhyML_Fprintf(fp_stats,"tuneT\t");
+
+ PhyML_Fprintf(fp_stats,"accClock\t");
+ PhyML_Fprintf(fp_stats,"tuneClock\t");
+
+ PhyML_Fprintf(fp_stats,"accTCr\t");
+ PhyML_Fprintf(fp_stats,"tuneTCr\t");
+
+ PhyML_Fprintf(fp_stats,"accTreeRates\t");
+ PhyML_Fprintf(fp_stats,"tuneTreeRates\t");
+
+ PhyML_Fprintf(fp_stats,"accSprW\t");
+ PhyML_Fprintf(fp_stats,"tuneSprW\t");
+
+ PhyML_Fprintf(fp_stats,"accSpr\t");
+ PhyML_Fprintf(fp_stats,"tuneSpr\t");
+
+ PhyML_Fprintf(fp_stats,"accSprLoc\t");
+ PhyML_Fprintf(fp_stats,"tuneSprLoc\t");
+
+ fflush(NULL);
+
+ PhyML_Printf("\n\n");
+ PhyML_Printf("\n. MCMC settings. Chain length: %g steps.",(phydbl)tree->mcmc->chain_len);
+ PhyML_Printf("\n. MCMC settings. Burnin: %g steps.",(phydbl)tree->mcmc->chain_len_burnin);
+ PhyML_Printf("\n. MCMC settings. Sample every %g steps.",(phydbl)tree->mcmc->sample_interval);
+ PhyML_Printf("\n. MCMC settings. Print out every %g steps.",(phydbl)tree->mcmc->print_every);
+ PhyML_Printf("\n\n");
+
+
+ for(i=0;imcmc->n_moves;i++) tree->mcmc->start_ess[i] = YES;
+ Set_Both_Sides(NO,tree);
+ tree->mcmc->always_yes = NO;
+ move = -1;
+
+ // Get in the range of sensible values for clock_r
+ i = 0;
+ do { MCMC_Clock_R(tree); } while(i++ < 100);
+
+ do
+ {
+ if(tree->mcmc->run > adjust_len) for(i=0;imcmc->n_moves;i++) tree->mcmc->adjust_tuning[i] = NO;
+
+ if(tree->c_lnL < UNLIKELY + 0.1 && tree->eval_alnL == YES)
+ {
+ PhyML_Printf("\n. Move '%s' failed\n",tree->mcmc->move_name[move]);
+ assert(FALSE);
+ }
+
+ u = Uni();
+ for(move=0;movemcmc->n_moves;move++) if(tree->mcmc->move_weight[move] > u-1.E-10) break;
+
+ assert(!(move == tree->mcmc->n_moves));
+
+ if(!strcmp(tree->mcmc->move_name[move],"clock")) MCMC_Clock_R(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"birth_rate")) MCMC_Birth_Rate(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"death_rate")) MCMC_Death_Rate(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"birth_death_updown")) MCMC_Birth_Death_Updown(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"tree_height")) MCMC_Tree_Height(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"times")) MCMC_Times_All(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"times_and_rates")) MCMC_Times_And_Rates_All(tree);
+
+ else if(!strcmp(tree->mcmc->move_name[move],"spr")) MCMC_Prune_Regraft(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"spr_local")) MCMC_Prune_Regraft_Local(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"spr_weighted")) MCMC_Prune_Regraft_Weighted(tree);
+
+ else if(!strcmp(tree->mcmc->move_name[move],"updown_t_cr")) MCMC_Updown_T_Cr(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"kappa")) MCMC_Kappa(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"ras")) MCMC_Rate_Across_Sites(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"nu")) MCMC_Nu(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"subtree_height")) MCMC_Subtree_Height(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"time_slice")) MCMC_Time_Slice(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"br_rate")) MCMC_Rates_All(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"tree_rates")) MCMC_Tree_Rates(tree);
+ else if(!strcmp(tree->mcmc->move_name[move],"clade_change")) MCMC_Clade_Change(tree);
+ else continue;
+
+
+ phydbl cur_lk = tree->c_lnL;
+ phydbl new_lk = Lk(NULL,tree);
+ if(Are_Equal(cur_lk,new_lk,1.E-5) == NO)
+ {
+ PhyML_Printf("\n. move: %s",tree->mcmc->move_name[move]);
+ PhyML_Printf("\n. new: %f cur: %f",new_lk,cur_lk);
+ assert(FALSE);
+ }
+
+
+ if(!RATES_Check_Edge_Length_Consistency(tree))
+ {
+ PhyML_Fprintf(stderr,"\n. Issue detected by RATES_Check_Edge_Length_Consistency(tree).");
+ PhyML_Fprintf(stderr,"\n. Move: %s",tree->mcmc->move_name[move]);
+ if(tree->eval_alnL == YES) assert(FALSE);
+ }
+
+ if(!TIMES_Check_Node_Height_Ordering(tree))
+ {
+ PhyML_Fprintf(stderr,"\n. Issue detected by TIMES_Check_Node_Height_Ordering(tree).");
+ PhyML_Fprintf(stderr,"\n. Move: %s",tree->mcmc->move_name[move]);
+ assert(FALSE);
+ }
+
+
+ if(!(tree->rates->c_lnL_times > UNLIKELY))
+ {
+ PhyML_Fprintf(stderr,"\n. move: %s",tree->mcmc->move_name[move]);
+ PhyML_Fprintf(stderr,"\n. glnL=%f",tree->rates->c_lnL_times);
+ assert(FALSE);
+ }
+
+ (void)signal(SIGINT,MCMC_Terminate);
+
+ if(!(tree->mcmc->run%tree->mcmc->print_every))
+ {
+ phydbl mean_r,post;
+
+ mean_r = RATES_Average_Substitution_Rate(tree);
+ post = Get_Lk(tree) + tree->rates->c_lnL_times + tree->rates->c_lnL_rates;
+
+ if(tree->mcmc->run < adjust_len) PhyML_Printf("\nx");
+ else PhyML_Printf("\n.");
+ PhyML_Printf(" %10d lnL: [%12.2f -- %12.2f -- %12.2f -- %12.2f] root age: %12f [time: %7d sec] clock: %15f %20s",
+ tree->mcmc->run,
+ post,
+ Get_Lk(tree),
+ tree->rates->c_lnL_times,
+ tree->rates->c_lnL_rates,
+ fabs(tree->rates->nd_t[tree->n_root->num]),
+ (int)time(NULL) - t_beg,
+ mean_r,
+ tree->mcmc->move_name[move]);
+ }
+
+ if(!(tree->mcmc->run%tree->mcmc->sample_interval))
+ {
+ phydbl mean_r,post;
+
+ mean_r = RATES_Average_Substitution_Rate(tree);
+ post = Get_Lk(tree) + tree->rates->c_lnL_times + tree->rates->c_lnL_rates;
+
+ PhyML_Fprintf(fp_stats,"\n%6d\t%9.1f\t%9.1f\t%9.1f\t%9.1f\t%12G\t%12G\t%12G\t%12G\t%12G\t%12G\t",
+ tree->mcmc->run,
+ post,
+ Get_Lk(tree),
+ tree->rates->c_lnL_times,
+ tree->rates->c_lnL_rates,
+ tree->rates->birth_rate,
+ tree->rates->death_rate,
+ mean_r,
+ fabs(tree->rates->nd_t[tree->n_root->num]),
+ tree->next->mod->kappa->v,
+ tree->rates->nu);
+
+ for(i=0;imod->ras->n_catg;i++) PhyML_Fprintf(fp_stats,"%G\t",tree->mod->ras->gamma_rr->v[i]);
+ for(i=0;imod->ras->n_catg;i++) PhyML_Fprintf(fp_stats,"%G\t",tree->mod->ras->gamma_r_proba->v[i]);
+
+
+ for(i=0;irates->n_cal;i++)
+ {
+ t_cal *cal = tree->rates->a_cal[i];
+ for(j=0;jclade_list_size;++j)
+ {
+ t_clad *clade = cal->clade_list[j];
+ PhyML_Fprintf(fp_stats,"%G\t",fabs(tree->rates->nd_t[clade->target_nd->num]));
+ }
+ }
+
+ for(i=0;irates->n_cal;++i)
+ {
+ t_cal *cal = tree->rates->a_cal[i];
+ PhyML_Fprintf(fp_stats,"%d\t",cal->current_clade_idx);
+ /* PhyML_Fprintf(fp_stats,"%s\t",cal->clade_list[cal->current_clade_idx]->id); */
+ }
+
+ if(tree->rates->model == THORNE ||
+ tree->rates->model == LOGNORMAL ||
+ tree->rates->model == STRICTCLOCK)
+ for(i=0;i<2*tree->n_otu-2;++i) PhyML_Fprintf(fp_stats,"%G\t",tree->rates->br_r[i]);
+ else
+ for(i=0;i<2*tree->n_otu-1;++i) PhyML_Fprintf(fp_stats,"%G\t",tree->rates->nd_r[i]);
+
+ for(i=0;i<2*tree->n_otu-1;++i) if(tree->a_nodes[i]->tax == NO) PhyML_Fprintf(fp_stats,"%G\t",fabs(tree->rates->nd_t[i]));
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_times_and_rates_root]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_times_and_rates_root]);
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_root_time]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_root_time]);
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_clock_r]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_clock_r]);
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_updown_t_cr]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_updown_t_cr]);
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_tree_rates]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_tree_rates]);
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_spr_weighted]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_spr_weighted]);
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_spr]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_spr]);
+
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->acc_rate[tree->mcmc->num_move_spr_local]);
+ PhyML_Fprintf(fp_stats,"%G\t",tree->mcmc->tune_move[tree->mcmc->num_move_spr_local]);
+
+ if(tree->mcmc->sample_num == 0)
+ {
+ PhyML_Fprintf(fp_tree,"\n#NEXUS");
+ PhyML_Fprintf(fp_tree,"\nBEGIN TREES;");
+ }
+ else
+ {
+ fseek(fp_tree,-5,SEEK_CUR);
+ }
+
+
+ TIMES_Time_To_Bl(tree);
+ tree->bl_ndigits = 3;
+ /* RATES_Update_Cur_Bl(tree); */
+ s_tree = Write_Tree(tree);
+ tree->bl_ndigits = 7;
+ PhyML_Fprintf(fp_tree,"\ntree %d [&lnP=%f] = [&R] %s",tree->mcmc->sample_num,tree->c_lnL,s_tree);
+ Free(s_tree);
+ PhyML_Fprintf(fp_tree,"\nEND;");
+ fflush(NULL);
+ RATES_Update_Cur_Bl(tree);
+
+
+ if(tree->mcmc->run > tree->mcmc->chain_len_burnin &&
+ tree->io->mutmap == YES) Sample_Ancestral_Seq(YES,NO,tree);
+
+ tree->mcmc->sample_num++;
+ }
+
+ tree->mcmc->run++;
+ MCMC_Get_Acc_Rates(tree->mcmc);
+ }
+ while(tree->mcmc->run < tree->mcmc->chain_len);
+
+
+ return(res);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// Update the list of nodes that are younger than lim
+void DATE_List_Of_Nodes_Younger_Than(t_node *a, t_node *d, phydbl lim, t_ll **list, t_tree *tree)
+{
+ if(tree->rates->nd_t[d->num] > lim) Push_Bottom_Linked_List(d,list,YES);
+
+ if(d->tax == YES) return;
+ else
+ {
+ int i;
+
+ if(d == tree->n_root)
+ {
+ DATE_List_Of_Nodes_Younger_Than(d,d->v[1],lim,list,tree);
+ DATE_List_Of_Nodes_Younger_Than(d,d->v[2],lim,list,tree);
+ }
+ else
+ {
+ for(i=0;i<3;i++)
+ if(d->v[i] != a && d->b[i] != tree->e_root)
+ DATE_List_Of_Nodes_Younger_Than(d,d->v[i],lim,list,tree);
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// Update the list of nodes that are younger than lim with direct ancestors
+// not younger than lim
+void DATE_List_Of_Nodes_And_Ancestors_Younger_Than(t_node *a, t_node *d, phydbl lim, t_ll **list, t_tree *tree)
+{
+ if(tree->rates->nd_t[d->num] > lim && a != NULL && tree->rates->nd_t[a->num] > lim) Push_Bottom_Linked_List(d,list,YES);
+
+ if(d->tax == YES) return;
+ else
+ {
+ int i;
+
+ if(d == tree->n_root)
+ {
+ DATE_List_Of_Nodes_And_Ancestors_Younger_Than(d,d->v[1],lim,list,tree);
+ DATE_List_Of_Nodes_And_Ancestors_Younger_Than(d,d->v[2],lim,list,tree);
+ }
+ else
+ {
+ for(i=0;i<3;i++)
+ if(d->v[i] != a && d->b[i] != tree->e_root)
+ DATE_List_Of_Nodes_And_Ancestors_Younger_Than(d,d->v[i],lim,list,tree);
+ }
+ }
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// List of valid regraft nodes, taking into account calibration
+// constraints. The subtree (defined by prune and prune_daughter
+// will be re-attached *on top of* one of the nodes in this list
+// (as opposed to *on one of the sister edges below*).
+t_ll *DATE_List_Of_Regraft_Nodes(t_node *prune, t_node *prune_daughter, phydbl *t_min, phydbl *t_max, int verbose, t_tree *tree)
+{
+ t_node *n,*m;
+ int i,j;
+ t_ll *out,*in,*ll;
+ int is_clade_affected;
+ t_clad *clade;
+ t_cal *cal;
+
+ cal = NULL;
+ clade = NULL;
+ n = NULL;
+ m = NULL;
+ *t_min = -INFINITY;
+ in = NULL;
+ out = NULL;
+ is_clade_affected = NO;
+
+
+ // Find the oldest LCA of calibrated sets among the nodes between
+ // prune and root. These clades might see the position of their
+ // LCA change.
+
+ if(prune != tree->n_root)
+ {
+ n = prune;
+ while(n)
+ {
+ for(i=0;irates->n_cal;++i)
+ {
+ // That node is the LCA of calibration a_cal[i]
+ cal = tree->rates->a_cal[i];
+ clade = cal->clade_list[cal->current_clade_idx];
+
+ if(n == clade->target_nd)
+ {
+ is_clade_affected = NO;
+
+ for(j=0;jn_tax;++j)
+ {
+ m = clade->tip_list[j];
+ do
+ {
+ if(m == prune_daughter)
+ {
+ is_clade_affected = YES;
+ break;
+ }
+ m = m->anc;
+ }
+ while(m);
+
+ if(is_clade_affected == YES) break;
+ }
+
+
+ // Maximum of the lower bounds for calibration intervals
+ /* if(is_clade_affected == YES) *t_min = MAX(*t_min,tree->rates->a_cal[i]->lower); */
+ if(is_clade_affected == YES) *t_min = MAX(*t_min,tree->rates->t_prior_min[n->num]);
+ }
+ }
+ n = n->anc;
+ }
+ }
+
+ // Find the oldest internal node within intervals defined by
+ // calibrations affected by the pruning.
+ n = prune_daughter;
+ while(n->anc && !(tree->rates->nd_t[n->anc->num] < *t_min))
+ {
+ n = n->anc;
+ assert(n);
+ }
+
+
+ if(verbose)
+ {
+ PhyML_Printf("\n. Apical: %d @ time %f min: %f",n->num,tree->rates->nd_t[n->num],*t_min);
+ fflush(NULL);
+ }
+
+ // List all nodes younger than this apical node
+ DATE_List_Of_Nodes_Younger_Than(n->anc,n,-INFINITY,&in,tree);
+
+ assert(in != NULL);
+
+ if(verbose)
+ {
+ ll = in->head;
+ t_node *x;
+ do
+ {
+ x = (t_node *)ll->v;
+ PhyML_Printf("\nx Inlist %d @ %f",x->num,tree->rates->nd_t[x->num]);
+ ll = ll->next;
+ }
+ while(ll != NULL);
+ }
+
+ // Remove from that list the nodes that are too young to be suitable regraft points.
+
+
+ n = prune_daughter;
+ out = NULL;
+ while(n)
+ {
+ for(i=0;irates->n_cal;i++)
+ {
+ cal = tree->rates->a_cal[i];
+ clade = cal->clade_list[cal->current_clade_idx];
+
+ if(n->anc && n->anc == clade->target_nd)
+ {
+ for(j=0;jn_tax;++j)
+ {
+ m = clade->tip_list[j];
+ do
+ {
+ if(m == prune_daughter) break;
+ if(m == prune) break;
+ m = m->anc;
+ }
+ while(m);
+ if(m == prune) break; // Prune-regraft anywhere below calibrated node will not change that node.
+ }
+
+ if(m != prune)
+ {
+ for(j=0;j<3;++j)
+ {
+ if(n->anc->v[j] != n->anc->anc && n->anc->b[j] != tree->e_root && n->anc->v[j] != n)
+ {
+ DATE_List_Of_Nodes_And_Ancestors_Younger_Than(n->anc,
+ n->anc->v[j],
+ tree->rates->a_cal[i]->upper,
+ &out,
+ tree);
+ break;
+ }
+ }
+ }
+ }
+ }
+ n = n->anc;
+ }
+
+ // Remove nodes that are `strictly' younger than prune_daughter
+ DATE_List_Of_Nodes_And_Ancestors_Younger_Than(tree->n_root,tree->n_root->v[1],tree->rates->nd_t[prune_daughter->num],&out,tree);
+ DATE_List_Of_Nodes_And_Ancestors_Younger_Than(tree->n_root,tree->n_root->v[2],tree->rates->nd_t[prune_daughter->num],&out,tree);
+
+ // Remove nodes that are below prune_daughter (prune_daughter included)
+ DATE_List_Of_Nodes_Younger_Than(prune,prune_daughter,-INFINITY,&out,tree);
+
+ // Add prune node to the list of node that can't be targeted for regraft
+ Push_Bottom_Linked_List(prune,&out,YES);
+
+ // Add root node as one cannot regraft above it
+ /* Push_Bottom_Linked_List(tree->n_root,&out); */
+
+ if(verbose)
+ {
+ printf("\nx outlist: %p",(void *)out); fflush(NULL);
+ ll = out->head;
+ do
+ {
+ t_node *x = (t_node *)ll->v;
+ PhyML_Printf("\nx Outlist %d @ %f",x->num,tree->rates->nd_t[x->num]);
+ ll = ll->next;
+ }
+ while(ll != NULL);
+ }
+
+
+ /* Print_List(in); */
+ ll = out->head;
+ do
+ {
+ if(verbose)
+ {
+ t_node *x = (t_node *)ll->v;
+ printf("\nx Remove %d",x->num);
+ }
+
+ Remove_From_Linked_List(NULL,ll->v,&in);
+
+ if(verbose) PhyML_Printf("\n. List in (in->head:%p in->tail:%p):",in?in->head:NULL,in?in->tail:NULL);
+
+ /* Print_List(in); */
+ ll = ll->next;
+ }
+ while(ll != NULL);
+
+ Free_Linked_List(out);
+
+ if(verbose)
+ {
+ ll = in->head;
+ do
+ {
+ t_node *x;
+ x = (t_node *)ll->v;
+ printf("\n. In1: %d",x->num); fflush(NULL);
+ ll = ll->next;
+ }
+ while(ll != NULL);
+ }
+
+ return(in);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl DATE_Lk_Calib(t_tree *tree)
+{
+ phydbl lnL;
+ int i;
+ t_cal *cal;
+
+ lnL = 0.0;
+ for(i=0;irates->n_cal;++i)
+ {
+ cal = tree->rates->a_cal[i];
+ lnL += LOG(cal->alpha_proba_list[cal->current_clade_idx]);
+ }
+
+ return lnL;
+}
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
diff --git a/phyml/date.h b/phyml/date.h
new file mode 100644
index 0000000..09a1592
--- /dev/null
+++ b/phyml/date.h
@@ -0,0 +1,45 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+#include
+
+#ifndef DATE_H
+#define DATE_H
+
+#include "utilities.h"
+
+int DATE_Main(int argc, char **argv);
+void DATE_XML(char *xml_filename);
+void DATE_Update_Secondary_Cal(t_tree *tree);
+void DATE_Update_Secondary_Cal_Post(t_node *a, t_node *d, t_tree *tree);
+void DATE_Update_Secondary_Cal_Pre(t_node *a, t_node *d, t_tree *tree);
+phydbl *DATE_Splitted_Calibration(t_tree *tree);
+void DATE_Assign_Primary_Calibration(t_tree *tree);
+void DATE_Update_T_Prior_MinMax(t_tree *tree);
+phydbl DATE_J(phydbl birth_r, phydbl death_r, phydbl t_min, phydbl t_pls);
+int DATE_Is_Split_Accessible(t_node *d, int which, phydbl *splitted_cal, t_tree *tree);
+phydbl *DATE_Splitted_Calibration(t_tree *tree);
+phydbl DATE_J_Sum_Product(t_tree *tree);
+int DATE_J_Sum_Product_Pre(t_node *d, int split_idx_d, int split_idx_a, phydbl prod, int fact, phydbl *total, phydbl *splitted_cal, int rk, t_tree *tree);
+void DATE_Chain_Cal(t_tree *mixt_tree);
+int DATE_Check_Calibration_Constraints(t_tree *tree);
+int DATE_Check_Time_Constraints(t_tree *tree);
+phydbl *DATE_MCMC(t_tree *tree);
+void DATE_List_Of_Nodes_Younger_Than(t_node *a, t_node *d, phydbl lim, t_ll **list, t_tree *tree);
+void DATE_List_Of_Nodes_And_Ancestors_Younger_Than(t_node *a, t_node *d, phydbl lim, t_ll **list, t_tree *tree);
+t_ll *DATE_List_Of_Regraft_Nodes(t_node *prune, t_node *prune_daughter, phydbl *t_min, phydbl *t_max, int verbose, t_tree *tree);
+phydbl DATE_Lk_Calib(t_tree *tree);
+
+
+
+
+#endif
diff --git a/phyml/draw.c b/phyml/draw.c
index 0e4cbf1..ea0bbf4 100644
--- a/phyml/draw.c
+++ b/phyml/draw.c
@@ -10,293 +10,419 @@ the GNU public licence. See http://www.opensource.org for details.
*/
-#include "utilities.h"
#include "draw.h"
-/*********************************************************/
+void DR_Draw_Tree(char *file_name, t_tree *tree)
+{
+ FILE *ps_tree;
+
+ ps_tree = (FILE *)fopen(file_name,"w");
+ DR_Print_Postscript_Header(1,ps_tree);
+ tree->ps_tree = DR_Make_Tdraw_Struct(tree);
+ DR_Init_Tdraw_Struct(tree->ps_tree);
+ DR_Get_Tree_Box_Width(tree->ps_tree,tree);
+ Dist_To_Root(tree);
+ tree->ps_tree->max_dist_to_root = DR_Get_Max_Dist_To_Root(tree);
+ DR_Get_X_Coord(NO,tree->ps_tree,tree);
+ DR_Get_Y_Coord(NO,tree->ps_tree,tree);
+ DR_Print_Tree_Postscript(1,NO,ps_tree,tree);
+ DR_Print_Postscript_EOF(ps_tree);
+ fclose(ps_tree);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void DR_Get_Tree_Coord(arbre *tree)
+
+void DR_Get_Tree_Coord(t_tree *tree)
{
DR_Init_Tdraw_Struct(tree->ps_tree);
DR_Get_Tree_Box_Width(tree->ps_tree,tree);
if(!tree->n_root)
{
- printf("\n. Adding root before rendering the tree.");
- Add_Root(tree->t_edges[0],tree);
+ PhyML_Printf("\n. Adding root before rendering the tree.");
+ Add_Root(tree->a_edges[0],tree);
}
- else Update_Root_Pos(tree);
- DR_Dist_To_Root(tree->n_root,tree);
+ Dist_To_Root(tree);
tree->ps_tree->max_dist_to_root = DR_Get_Max_Dist_To_Root(tree);
- DR_Get_X_Coord(tree->ps_tree,tree);
- DR_Get_Y_Coord(tree->ps_tree,tree);
+ DR_Get_X_Coord(NO,tree->ps_tree,tree);
+ DR_Get_Y_Coord(NO,tree->ps_tree,tree);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void DR_Print_Postscript_Header(int n_pages, FILE *fp)
{
if(!fp)
{
- printf("\n. Failed to open the postscript file.");
- printf("\n. Did you forget the '--ps' option ?.");
- Warn_And_Exit("\n");
+ PhyML_Printf("\n== Failed to open the postscript file.");
+ PhyML_Printf("\n== Did you forget the '--ps' option ?.");
+ Exit("\n");
}
- fprintf(fp,"%%!PS-Adobe-3.0\n");
- fprintf(fp,"%%%%DocumentFonts: Times-Roman Times-Roman\n");
- fprintf(fp,"%%%%Creator: Stephane Guindon\n");
- fprintf(fp,"%%%%Title: tree\n");
- fprintf(fp,"%%%%BeginFeature: *PageSize\n");
- fprintf(fp,"a4\n");
- fprintf(fp,"%%%%EndFeature\n");
- fprintf(fp,"%%%%EndComments\n");
- fprintf(fp,"%%%%Pages: %d\n",n_pages);
-
- fprintf(fp,"/lt {lineto} bind def\n");
- fprintf(fp,"/mt {moveto} bind def\n");
- fprintf(fp,"/sc {setrgbcolor} bind def\n");
-
- fprintf(fp,"/clipbox\n");
- fprintf(fp,"{\n");
- fprintf(fp,"newpath\n");
- fprintf(fp,"40 40 moveto\n");
- fprintf(fp,"560 40 lineto\n");
- fprintf(fp,"560 820 lineto\n");
- fprintf(fp,"40 820 lineto\n");
- fprintf(fp,"40 40 lineto\n");
- fprintf(fp,"closepath\n");
- fprintf(fp,"clip\n");
- fprintf(fp,"} bind def\n");
+ PhyML_Fprintf(fp,"%%!PS-Adobe-3.0\n");
+ PhyML_Fprintf(fp,"%%%%BoundingBox: 0 0 595.28 841.89\n");
+ PhyML_Fprintf(fp,"%%%%DocumentFonts: Times-Roman Times-Roman\n");
+ PhyML_Fprintf(fp,"%%%%Creator: Stephane Guindon\n");
+ PhyML_Fprintf(fp,"%%%%Title: tree\n");
+ PhyML_Fprintf(fp,"%%%%EndComments\n");
+ PhyML_Fprintf(fp,"%%%%Pages: %d\n",n_pages);
+
+ PhyML_Fprintf(fp,"/lt {lineto} bind def\n");
+ PhyML_Fprintf(fp,"/mt {moveto} bind def\n");
+ PhyML_Fprintf(fp,"/sc {setrgbcolor} bind def\n");
+ PhyML_Fprintf(fp,"/ct {curveto} bind def\n");
+ PhyML_Fprintf(fp,"/np {newpath} bind def\n");
+ PhyML_Fprintf(fp,"/cp {closepath} bind def\n");
+ PhyML_Fprintf(fp,"/gs {gsave} bind def\n");
+ PhyML_Fprintf(fp,"/gr {grestore} bind def\n");
- fprintf(fp,"/Times-Roman findfont\n");
- fprintf(fp,"12 scalefont\n");
- fprintf(fp,"setfont\n");
+ PhyML_Fprintf(fp,"/Times-Roman findfont\n");
+ PhyML_Fprintf(fp,"12 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
+
+ PhyML_Fprintf(fp,"/clipbox\n");
+ PhyML_Fprintf(fp,"{\n");
+ PhyML_Fprintf(fp,"newpath\n");
+ PhyML_Fprintf(fp,"20 20 mt\n");
+ PhyML_Fprintf(fp,"580 20 lt\n");
+ PhyML_Fprintf(fp,"580 820 lt\n");
+ PhyML_Fprintf(fp,"20 820 lt\n");
+ PhyML_Fprintf(fp,"20 20 lt\n");
+ PhyML_Fprintf(fp,"closepath\n");
+ PhyML_Fprintf(fp,"clip\n");
+ PhyML_Fprintf(fp,"} bind def\n");
+
+
+ /* PhyML_Fprintf(fp,"gs\n"); */
+ /* PhyML_Fprintf(fp,"newpath\n"); */
+ /* PhyML_Fprintf(fp,"20 20 mt\n"); */
+ /* PhyML_Fprintf(fp,"580 20 lt\n"); */
+ /* PhyML_Fprintf(fp,"580 820 lt\n"); */
+ /* PhyML_Fprintf(fp,"20 820 lt\n"); */
+ /* PhyML_Fprintf(fp,"20 20 lt\n"); */
+ /* PhyML_Fprintf(fp,"closepath\n"); */
+ /* PhyML_Fprintf(fp,"stroke\n"); */
+ /* PhyML_Fprintf(fp,"gr\n"); */
+ /* PhyML_Fprintf(fp,"0 0 0 sc\n"); */
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void DR_Print_Postscript_EOF(FILE *fp)
{
- fprintf(fp,"%%%%Trailer\n");
- fprintf(fp,"%%%%EOF\n");
+ PhyML_Fprintf(fp,"%%%%Trailer\n");
+ PhyML_Fprintf(fp,"%%%%EOF\n");
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void DR_Print_Tree_Postscript(int page_num, FILE *fp, arbre *tree)
+
+void DR_Print_Tree_Postscript(int page_num, int render_name, FILE *fp, t_tree *tree)
{
- int i;
tdraw *draw;
- node *n_root;
+ t_node *n_root;
draw = tree->ps_tree;
- DR_Get_Tree_Coord(tree);
+/* DR_Get_Tree_Coord(tree); */
n_root = tree->n_root;
- fprintf(fp,"%%%%Page: %d %d\n",page_num,page_num);
- fprintf(fp,"clipbox\n");
- fprintf(fp,"stroke\n");
- fprintf(fp,"50 50 translate\n");
- fprintf(fp,"newpath\n");
-
-/* if(b_root->prob_sel_regime <= 0.1) */
-/* fprintf(fp,".0 .0 1. sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.1 && b_root->prob_sel_regime <= 0.2) */
-/* fprintf(fp,".0 .5 1. sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.2 && b_root->prob_sel_regime <= 0.3) */
-/* fprintf(fp,".0 1. 1. sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.3 && b_root->prob_sel_regime <= 0.4) */
-/* fprintf(fp,".0 1. .5 sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.4 && b_root->prob_sel_regime <= 0.5) */
-/* fprintf(fp,".0 1. .0 sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.5 && b_root->prob_sel_regime <= 0.6) */
-/* fprintf(fp,".5 1. .0 sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.6 && b_root->prob_sel_regime <= 0.7) */
-/* fprintf(fp,"1. 1. 0. sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.7 && b_root->prob_sel_regime <= 0.8) */
-/* fprintf(fp,"1. .5 0. sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.8 && b_root->prob_sel_regime <= 0.9) */
-/* fprintf(fp,"1. 0. 0. sc\n"); */
-/* else if(b_root->prob_sel_regime > 0.9) */
-/* fprintf(fp,"1. .0 .0 sc\n"); */
-
- fprintf(fp,"%d %d mt\n",draw->xcoord[n_root->v[0]->num],draw->ycoord[n_root->v[0]->num]);
- fprintf(fp,"%d %d lt\n",0,draw->ycoord[n_root->v[0]->num]);
- fprintf(fp,"%d %d lt\n",0,draw->ycoord[n_root->v[1]->num]);
- fprintf(fp,"%d %d lt\n",draw->xcoord[n_root->v[1]->num],draw->ycoord[n_root->v[1]->num]);
- fprintf(fp,"stroke\n");
-
-
- fprintf(fp,"%d %d mt\n",draw->xcoord[n_root->v[0]->num],draw->ycoord[n_root->v[0]->num]);
- if(n_root->v[0]->tax) fprintf(fp,"(%s) show\n",n_root->v[0]->name);
- else
- {
- For(i,3)
- if((n_root->v[0]->v[i]) && (n_root->v[0]->v[i] != n_root->v[1]))
- DR_Print_Tree_Postscript_Pre(n_root->v[0],n_root->v[0]->v[i],fp,draw,tree);
- }
+/* PhyML_Fprintf(fp,"%%%%Page: %d %d\n",page_num,page_num); */
+ /* PhyML_Fprintf(fp,"0.001 setlinewidth\n"); */
+/* PhyML_Fprintf(fp,"0.5 0.5 0.4 sc\n"); */
+ /* PhyML_Fprintf(fp,"0 0 0 sc\n"); */
+/* PhyML_Fprintf(fp,"clipbox\n"); */
+/* PhyML_Fprintf(fp,"stroke\n"); */
+ PhyML_Fprintf(fp,"20 20 translate\n");
+ PhyML_Fprintf(fp,"newpath\n");
- fprintf(fp,"%d %d mt\n",draw->xcoord[n_root->v[1]->num],draw->ycoord[n_root->v[1]->num]);
- if(n_root->v[1]->tax) fprintf(fp,"(%s) show\n",n_root->v[1]->name);
- else
- {
- For(i,3)
- if((n_root->v[1]->v[i]) && (n_root->v[1]->v[i] != n_root->v[0]))
- DR_Print_Tree_Postscript_Pre(n_root->v[1],n_root->v[1]->v[i],fp,draw,tree);
- }
+ draw->ycoord[n_root->num] = (draw->ycoord[n_root->v[2]->num] + draw->ycoord[n_root->v[1]->num])/2. + 20;
+ draw->xcoord[n_root->num] = 0.0;
+ DR_Print_Tree_Postscript_Pre(n_root,n_root->v[2],n_root->b[2],render_name,fp,draw,tree);
+ DR_Print_Tree_Postscript_Pre(n_root,n_root->v[1],n_root->b[1],render_name,fp,draw,tree);
+
- fprintf(fp,"closepath\n");
- fprintf(fp,"stroke\n");
- fprintf(fp,"showpage\n");
+ PhyML_Fprintf(fp,"closepath\n");
+ PhyML_Fprintf(fp,"0 0 translate\n");
+ PhyML_Fprintf(fp,"stroke\n");
+ PhyML_Fprintf(fp,"showpage\n");
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void DR_Print_Tree_Postscript_Pre(node *a, node *d, FILE *fp, tdraw *w, arbre *tree)
+
+void DR_Print_Tree_Postscript_Pre(t_node *a, t_node *d, t_edge *b, int render_name, FILE *fp, tdraw *w, t_tree *tree)
{
int i;
+ phydbl R, G, B;
+
+ R = G = B = 0.0;
+
+ PhyML_Fprintf(fp,"gs\n");
+
+ PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[a->num],w->ycoord[a->num]);
+
+/* PhyML_Fprintf(fp,"%.1f %.1f lt\n",w->xcoord[a->num],w->ycoord[d->num]); */
+/* PhyML_Fprintf(fp,"%.1f %.1f lt\n",w->xcoord[d->num],w->ycoord[d->num]); */
- fprintf(fp,"gsave\n");
+ phydbl min,max,step,val;
+
+ min = 0.0;
+ max = 5.;
- For(i,3)
- if(a->v[i] == d)
- {
-/* if(a->b[i]->prob_sel_regime <= 0.1) */
-/* fprintf(fp,".0 .0 1. sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.1 && a->b[i]->prob_sel_regime <= 0.2) */
-/* fprintf(fp,".0 .5 1. sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.2 && a->b[i]->prob_sel_regime <= 0.3) */
-/* fprintf(fp,".0 1. 1. sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.3 && a->b[i]->prob_sel_regime <= 0.4) */
-/* fprintf(fp,".0 1. .5 sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.4 && a->b[i]->prob_sel_regime <= 0.5) */
-/* fprintf(fp,".0 1. .0 sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.5 && a->b[i]->prob_sel_regime <= 0.6) */
-/* fprintf(fp,".5 1. .0 sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.6 && a->b[i]->prob_sel_regime <= 0.7) */
-/* fprintf(fp,"1. 1. 0. sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.7 && a->b[i]->prob_sel_regime <= 0.8) */
-/* fprintf(fp,"1. .5 0. sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.8 && a->b[i]->prob_sel_regime <= 0.9) */
-/* fprintf(fp,"1. 0. 0. sc\n"); */
-/* else if(a->b[i]->prob_sel_regime > 0.9) */
-/* fprintf(fp,"1. .0 .0 sc\n"); */
- break;
- }
-
- fprintf(fp,"%d %d mt\n",w->xcoord[a->num],w->ycoord[a->num]);
- fprintf(fp,"%d %d lt\n",w->xcoord[a->num],w->ycoord[d->num]);
- fprintf(fp,"%d %d lt\n",w->xcoord[d->num],w->ycoord[d->num]);
+ step = (max-min)/13.;
+
+ /* val = tree->rates->mean_r[d->num] / (phydbl)(tree->mcmc->run/tree->mcmc->sample_interval+1.); */
+ /* val = tree->rates->mean_r[d->num]; */
+ /* val = tree->rates->has_survived[d->num]; */
+ /* if(val > 0.5) {R=1.; G=.0; B=0.;} */
+ /* val = tree->geo->ldscape[tree->geo->idx_loc[d->num]*tree->geo->n_dim+0] + 2.5; */
+ val = tree->geo->coord_loc[tree->geo->idx_loc[d->num]]->lonlat[0] + 2.5;
+ /* val = 0.; */
+
+ if(val <= min+1.*step)
+ {R=.0; G=1.; B=1.;}
+ else if(val > min+1.*step && val <= min+2.*step)
+ {R=.0; G=1.; B=.8;}
+ else if(val > min+2.*step && val <= min+3.*step)
+ {R=.0; G=1.; B=.5;}
+ else if(val > min+3.*step && val <= min+4.*step)
+ {R=.0; G=1.; B=.3;}
+ else if(val > min+4.*step && val <= min+5.*step)
+ {R=.0; G=1.; B=.0;}
+ else if(val > min+5.*step && val <= min+6.*step)
+ {R=.25; G=1.; B=0.;}
+ else if(val > min+6.*step && val <= min+7.*step)
+ {R=.5; G=1.; B=0.;}
+ else if(val > min+7.*step && val <= min+8.*step)
+ {R=.75; G=1.; B=.0;}
+ else if(val > min+8.*step && val <= min+9.*step)
+ {R=1.; G=1.; B=.0;}
+ else if(val > min+9.*step && val <= min+10.*step)
+ {R=1.; G=.75; B=.0;}
+ else if(val > min+10.*step && val <= min+11.*step)
+ {R=1.; G=.5; B=.0;}
+ else if(val > min+11.*step && val <= min+12.*step)
+ {R=1.; G=.25; B=.0;}
+ else if(val > min+12.*step)
+ {R=1.; G=.0; B=0.;}
+
+
+ /* R = 0.; G = 0.; B = 0.; */
+
+ PhyML_Fprintf(fp,"2 setlinewidth\n");
+ /* PhyML_Fprintf(fp,"%.1f %.1f lt\n",w->xcoord[a->num],w->ycoord[d->num]); */
+ /* PhyML_Fprintf(fp,"%.1f %.1f lt\n",w->xcoord[d->num],w->ycoord[d->num]); */
+
+ phydbl xa = w->xcoord[a->num];
+ phydbl xd = MIN(w->xcoord[a->num] + 5,w->xcoord[d->num]);
+ phydbl ya = w->ycoord[a->num];
+ phydbl yd = w->ycoord[d->num];
+
+ PhyML_Fprintf(fp,"%.1f %.1f %.1f %.1f %.1f %.1f ct\n",
+ xa + (xd-xa)/2.,(ya+yd)/2.,
+ xd - (xd-xa)/5.,yd,
+ xd,yd);
+
+ PhyML_Fprintf(fp,"%.1f %.1f lt\n",w->xcoord[d->num],w->ycoord[d->num]);
+
+ /* PhyML_Fprintf(fp,"%.1f %.1f %.1f %.1f %.1f %.1f ct\n", */
+ /* w->xcoord[a->num], */
+ /* w->ycoord[d->num], */
+ /* w->xcoord[d->num], */
+ /* w->ycoord[d->num], */
+ /* w->xcoord[d->num], */
+ /* w->ycoord[d->num]); */
+
+
+ if(tree->rates && tree->rates->has_survived[d->num] == YES)
+ {
+ PhyML_Fprintf(fp," /Helvetica findfont 16 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
+ PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[d->num]-5,w->ycoord[d->num]);
+ PhyML_Fprintf(fp,"0 0 0 sc\n");
+ PhyML_Fprintf(fp,"(*) show \n");
+ }
+
+ PhyML_Fprintf(fp,"%f %f %f sc\n",R,G,B);
if(d->tax)
{
- fprintf(fp,"(%s) show \n",d->name);
- fprintf(fp,"stroke\n");
- fprintf(fp,"grestore\n");
+ PhyML_Fprintf(fp,"stroke\n");
+ PhyML_Fprintf(fp,"0 setgray\n");
+ PhyML_Fprintf(fp,"2 setlinewidth\n");
+ PhyML_Fprintf(fp,"np %.1f %.1f 1 0 360 arc cp\n",w->xcoord[d->num],w->ycoord[d->num]);
+ PhyML_Fprintf(fp,"%.1f %.1f %.1f sc fill\n",R,G,B);
+/* PhyML_Fprintf(fp,"%f setgray fill\n",greylevel); */
+ PhyML_Fprintf(fp,"0 0 0 sc\n");
+
+
+ PhyML_Fprintf(fp," /Helvetica findfont 10 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
+ PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[d->num]+2,w->ycoord[d->num]-6);
+ /* PhyML_Fprintf(fp,"(%d) show \n",d->num); */
+ /* PhyML_Fprintf(fp,"(%s) show \n",d->name); */
+ PhyML_Fprintf(fp," /Helvetica findfont 14 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
+
+
+ PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[d->num] - (w->xcoord[d->num] - w->xcoord[a->num])/2.,w->ycoord[d->num]);
+ PhyML_Fprintf(fp," /Helvetica findfont 10 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
+
+#if (defined GEO)
+ /* PhyML_Fprintf(fp,"([%4.4f,%4.4f]) show \n", */
+ /* tree->geo->ldscape[tree->geo->loc[d->num]*tree->geo->n_dim+0], */
+ /* tree->geo->ldscape[tree->geo->loc[d->num]*tree->geo->n_dim+1]); */
+#endif
+
+
+ /* PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[d->num]+5,w->ycoord[d->num]); */
+ /* PhyML_Fprintf(fp,"(%.10s) show \n",d->name); */
+
+
+/* if(render_name) */
+/* { */
+/* if(tree->io->long_tax_names) */
+/* PhyML_Fprintf(fp,"(%s) show \n",tree->io->long_tax_names[d->num]); */
+/* else */
+/* PhyML_Fprintf(fp,"(%s) show \n",d->name); */
+/* } */
+
+ PhyML_Fprintf(fp,"stroke\n");
+ PhyML_Fprintf(fp,"gr\n");
+ PhyML_Fprintf(fp,"0 0 0 sc\n");
return;
}
else
{
- fprintf(fp,"stroke\n");
- fprintf(fp,"grestore\n");
- For(i,3)
- if(d->v[i] != a) DR_Print_Tree_Postscript_Pre(d,d->v[i],fp,w,tree);
- }
+ PhyML_Fprintf(fp,"stroke\n");
+ PhyML_Fprintf(fp,"0 setgray\n");
+ PhyML_Fprintf(fp,"2 setlinewidth\n");
+ PhyML_Fprintf(fp,"np %.1f %.1f 1 0 360 arc cp\n",w->xcoord[d->num],w->ycoord[d->num]);
+ PhyML_Fprintf(fp,"%.1f %.1f %.1f sc fill\n",R,G,B);
+/* PhyML_Fprintf(fp,"%f setgray fill\n",greylevel); */
+ PhyML_Fprintf(fp,"0 0 0 sc\n");
+ PhyML_Fprintf(fp," /Helvetica findfont 10 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
+ PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[d->num]+2,w->ycoord[d->num]);
- return;
-}
+ /* PhyML_Fprintf(fp,"(%d) show \n",b->num); */
-/*********************************************************/
+ PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[d->num],w->ycoord[d->num]);
+ PhyML_Fprintf(fp," /Helvetica findfont 14 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
-void DR_Dist_To_Root_Pre(node *a, node *d, edge *b, arbre *tree)
-{
- int i;
- if(b) d->dist_to_root = a->dist_to_root + b->l;
+ PhyML_Fprintf(fp,"%.1f %.1f mt\n",w->xcoord[d->num] - (w->xcoord[d->num] - w->xcoord[a->num])/2.,w->ycoord[d->num]);
+ PhyML_Fprintf(fp," /Helvetica findfont 10 scalefont\n");
+ PhyML_Fprintf(fp,"setfont\n");
- if(d->tax) return;
- else
- {
- For(i,3)
- if((d->v[i] != a) && (d->b[i] != tree->e_root))
- DR_Dist_To_Root_Pre(d,d->v[i],d->b[i],tree);
+#if (defined GEO)
+ /* PhyML_Fprintf(fp,"([%4.4f,%4.4f]) show \n", */
+ /* tree->geo->ldscape[tree->geo->loc[d->num]*tree->geo->n_dim+0], */
+ /* tree->geo->ldscape[tree->geo->loc[d->num]*tree->geo->n_dim+1]); */
+#endif
+
+
+ PhyML_Fprintf(fp,"stroke\n");
+ PhyML_Fprintf(fp,"gr\n");
+ PhyML_Fprintf(fp,"0 0 0 sc\n");
+ for(i=0;i<3;i++)
+ if(d->v[i] != a && d->b[i] != tree->e_root) DR_Print_Tree_Postscript_Pre(d,d->v[i],d->b[i],render_name,fp,w,tree);
}
-}
-/*********************************************************/
-void DR_Dist_To_Root(node *n_root, arbre *tree)
-{
- n_root->v[0]->dist_to_root = tree->e_root->l * tree->n_root_pos;
- n_root->v[1]->dist_to_root = tree->e_root->l * (1.-tree->n_root_pos);
- DR_Dist_To_Root_Pre(n_root,n_root->v[0],NULL,tree);
- DR_Dist_To_Root_Pre(n_root,n_root->v[1],NULL,tree);
+
+
+ return;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void DR_Get_X_Coord_Pre(node *a, node *d, edge *b, tdraw *w, arbre *tree)
+
+void DR_Get_X_Coord_Pre(t_node *a, t_node *d, t_edge *b, tdraw *w, int fixed_tips, t_tree *tree)
{
int i;
- if(b) w->xcoord[d->num] = d->dist_to_root * (double)w->tree_box_width/w->max_dist_to_root;
+ if(!(d->tax && fixed_tips == YES)) w->xcoord[d->num] = d->dist_to_root * (phydbl)w->tree_box_width/w->max_dist_to_root;
if(d->tax) return;
else
{
- For(i,3)
+ for(i=0;i<3;i++)
if((d->v[i] != a) && (d->b[i] != tree->e_root))
- DR_Get_X_Coord_Pre(d,d->v[i],d->b[i],w,tree);
+ DR_Get_X_Coord_Pre(d,d->v[i],d->b[i],w,fixed_tips,tree);
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
-void DR_Get_X_Coord(tdraw *w, arbre *tree)
+void DR_Get_X_Coord(int fixed_tips, tdraw *w, t_tree *tree)
{
- w->xcoord[tree->n_root->v[0]->num] = tree->n_root->v[0]->dist_to_root * (double)w->tree_box_width/w->max_dist_to_root;
- w->xcoord[tree->n_root->v[1]->num] = tree->n_root->v[1]->dist_to_root * (double)w->tree_box_width/w->max_dist_to_root;
- DR_Get_X_Coord_Pre(tree->n_root,tree->n_root->v[0],NULL,w,tree);
- DR_Get_X_Coord_Pre(tree->n_root,tree->n_root->v[1],NULL,w,tree);
+ if(!(tree->n_root->v[2]->tax && fixed_tips == YES)) w->xcoord[tree->n_root->v[2]->num] = tree->n_root->v[2]->dist_to_root * (phydbl)w->tree_box_width/w->max_dist_to_root;
+ if(!(tree->n_root->v[1]->tax && fixed_tips == YES)) w->xcoord[tree->n_root->v[1]->num] = tree->n_root->v[1]->dist_to_root * (phydbl)w->tree_box_width/w->max_dist_to_root;
+ DR_Get_X_Coord_Pre(tree->n_root,tree->n_root->v[2],NULL,w,fixed_tips,tree);
+ DR_Get_X_Coord_Pre(tree->n_root,tree->n_root->v[1],NULL,w,fixed_tips,tree);
+ w->xcoord[tree->n_root->num] = 0;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void DR_Get_Y_Coord(tdraw *w, arbre *tree)
+
+void DR_Get_Y_Coord(int fixed_tips, tdraw *w, t_tree *tree)
{
int next_y_slot;
next_y_slot = 0;
- DR_Get_Y_Coord_Post(tree->e_root->left,tree->e_root->rght,tree->e_root,&next_y_slot,w,tree);
- DR_Get_Y_Coord_Post(tree->e_root->rght,tree->e_root->left,tree->e_root,&next_y_slot,w,tree);
+ DR_Get_Y_Coord_Post(tree->n_root,tree->n_root->v[2],NULL,&next_y_slot,fixed_tips,w,tree);
+ DR_Get_Y_Coord_Post(tree->n_root,tree->n_root->v[1],NULL,&next_y_slot,fixed_tips,w,tree);
+ w->ycoord[tree->n_root->num] = (int)((w->ycoord[tree->n_root->v[2]->num] + w->ycoord[tree->n_root->v[2]->num]) / 2.) + 20;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
-void DR_Get_Y_Coord_Post(node *a, node *d, edge *b, int *next_y_slot, tdraw *w, arbre *tree)
+void DR_Get_Y_Coord_Post(t_node *a, t_node *d, t_edge *b, int *next_y_slot, int fixed_tips, tdraw *w, t_tree *tree)
{
int i;
if(d->tax)
{
- w->ycoord[d->num] = *next_y_slot + (int)(w->page_height / (2.*tree->n_otu));
- (*next_y_slot) += (int)(w->page_height / (tree->n_otu));
+ if(!fixed_tips)
+ {
+/* w->ycoord[d->num] = *next_y_slot + (int)(w->page_height / (2.*tree->n_otu)); */
+ w->ycoord[d->num] = *next_y_slot + 20;
+ (*next_y_slot) += (int)(w->page_height / (tree->n_otu-1));
+ printf("\n. %s %f",d->name,w->ycoord[d->num]);
+ }
}
else
{
int d1, d2;
d1 = d2 = -1;
- For(i,3)
+ for(i=0;i<3;i++)
{
- if(d->v[i] != a)
+ if(d->v[i] != a && d->b[i] != tree->e_root)
{
- DR_Get_Y_Coord_Post(d,d->v[i],d->b[i],next_y_slot,w,tree);
+ DR_Get_Y_Coord_Post(d,d->v[i],d->b[i],next_y_slot,fixed_tips,w,tree);
if(d1<0) d1 = i;
else d2 = i;
}
@@ -305,61 +431,190 @@ void DR_Get_Y_Coord_Post(node *a, node *d, edge *b, int *next_y_slot, tdraw *w,
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
-tdraw *DR_Make_Tdraw_Struct(arbre *tree)
+tdraw *DR_Make_Tdraw_Struct(t_tree *tree)
{
tdraw *w;
w = (tdraw *)mCalloc(1,sizeof(tdraw));
- w->xcoord = (int *)mCalloc(2*tree->n_otu-2,sizeof(int));
- w->ycoord = (int *)mCalloc(2*tree->n_otu-2,sizeof(int));
+ w->xcoord = (phydbl *)mCalloc(2*tree->n_otu-1,sizeof(phydbl));
+ w->ycoord = (phydbl *)mCalloc(2*tree->n_otu-1,sizeof(phydbl));
+ w->xcoord_s = (phydbl *)mCalloc(2*tree->n_otu-1,sizeof(phydbl));
+ w->ycoord_s = (phydbl *)mCalloc(2*tree->n_otu-1,sizeof(phydbl));
+ w->cdf_mat = (int *)mCalloc((2*tree->n_otu-2)*(2*tree->n_otu-2),sizeof(int));
+ w->cdf_mat_x = (phydbl *)mCalloc(2*tree->n_otu-1,sizeof(phydbl));
+ w->cdf_mat_y = (phydbl *)mCalloc(2*tree->n_otu-1,sizeof(phydbl));
return w;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void DR_Init_Tdraw_Struct(tdraw *w)
{
- w->page_width = 510;
- w->page_height = 770;
+ w->page_width = 580-20;
+ w->page_height = 820-20;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
-void DR_Get_Tree_Box_Width(tdraw *w, arbre *tree)
+void DR_Get_Tree_Box_Width(tdraw *w, t_tree *tree)
{
int i;
int max_name_len, curr_len;
max_name_len = curr_len = 0;
- For(i,tree->n_otu)
+ for(i=0;in_otu;i++)
{
- curr_len = (int)strlen(tree->noeud[i]->name);
+ curr_len = (int)strlen(tree->a_nodes[i]->name);
if(curr_len > max_name_len) max_name_len = curr_len;
}
w->tree_box_width = w->page_width - max_name_len * 8.66667;
+ /* w->tree_box_width = w->page_width - max_name_len * 10.; */
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
-double DR_Get_Max_Dist_To_Root(arbre *tree)
+phydbl DR_Get_Max_Dist_To_Root(t_tree *tree)
{
- double mx;
+ phydbl mx;
int i;
mx = .0;
- For(i,tree->n_otu)
+ for(i=0;in_otu;i++)
{
- if(tree->noeud[i]->dist_to_root > mx)
+ if(tree->a_nodes[i]->dist_to_root > mx)
{
- mx = tree->noeud[i]->dist_to_root;
+ mx = tree->a_nodes[i]->dist_to_root;
}
}
return mx;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void DR_Get_Tree_Coord_Scaled(tdraw *w, t_tree *tree)
+{
+ int i;
+ int max_x,min_x;
+ int max_y,min_y;
+
+ max_x = -INT_MAX;
+ min_x = INT_MAX;
+
+ For(i,2*tree->n_otu-1)
+ {
+ if(w->xcoord[i] > max_x) max_x = w->xcoord[i];
+ if(w->xcoord[i] < min_x) min_x = w->xcoord[i];
+ }
+
+ max_y = -INT_MAX;
+ min_y = INT_MAX;
+
+ For(i,2*tree->n_otu-1)
+ {
+ if(w->ycoord[i] > max_y) max_y = w->ycoord[i];
+ if(w->ycoord[i] < min_y) min_y = w->ycoord[i];
+ }
+
+
+ For(i,2*tree->n_otu-1)
+ {
+ w->xcoord_s[i] = (phydbl)(w->xcoord[i] - min_x) / (max_x - min_x);
+ w->ycoord_s[i] = (phydbl)(w->ycoord[i] - min_y) / (max_y - min_y);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void DR_Get_Cdf_Mat(t_tree *tree)
+{
+ int i,j,k;
+ phydbl min_x,max_x,y;
+ phydbl x_mat,y_mat;
+ t_node *d, *a;
+ phydbl eps;
+
+ eps = 1.E-6;
+
+ For(i,2*tree->n_otu-1) tree->ps_tree->cdf_mat_x[i] = tree->ps_tree->xcoord_s[i];
+ For(i,2*tree->n_otu-1) tree->ps_tree->cdf_mat_y[i] = tree->ps_tree->ycoord_s[i];
+
+ Qksort(tree->ps_tree->cdf_mat_x,NULL,0,2*tree->n_otu-2);
+ Qksort(tree->ps_tree->cdf_mat_y,NULL,0,2*tree->n_otu-2);
+
+ For(i,2*tree->n_otu-2) /* x coordinates */
+ {
+ For(j,2*tree->n_otu-2) /* y coordinates */
+ {
+ For(k,2*tree->n_otu-2) /* all nodes in the tree */
+ {
+ d = tree->a_nodes[k];
+ a = tree->a_nodes[k]->anc;
+
+ min_x = tree->ps_tree->xcoord_s[a->num];
+ max_x = tree->ps_tree->xcoord_s[d->num];
+
+ y = tree->ps_tree->ycoord_s[d->num];
+
+ x_mat = tree->ps_tree->cdf_mat_x[i];
+ y_mat = tree->ps_tree->cdf_mat_y[j];
+
+/* printf("\n. x_mat=%.1f ymat=%.1f min=%.1f max=%.1f y=%.1f", */
+/* x_mat,y_mat,min_x,max_x,y); */
+
+ if((min_x < x_mat + eps) && (max_x > x_mat) && (y > y_mat))
+ {
+ tree->ps_tree->cdf_mat[j*(2*tree->n_otu-2)+i] += 1;
+/* PhyML_Printf("\n. Add 1 to [%.1f,%.1f]", */
+/* tree->ps_tree->cdf_mat_x[i], */
+/* tree->ps_tree->cdf_mat_y[j]); */
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
diff --git a/phyml/draw.h b/phyml/draw.h
index 40d8cff..471bd80 100644
--- a/phyml/draw.h
+++ b/phyml/draw.h
@@ -1,21 +1,29 @@
+#include
+
#ifndef DRAW_H
#define DRAW_H
-void DR_Dist_To_Root_Pre(node *a, node *d, edge *b, arbre *tree);
-void DR_Dist_To_Root(node *n_root, arbre *tree);
-void DR_Get_X_Coord_Pre(node *a, node *d, edge *b, tdraw *w, arbre *tree);
-void DR_Get_X_Coord(tdraw *w, arbre *tree);
-tdraw *DR_Make_Tdraw_Struct(arbre *tree);
+#include "utilities.h"
+
+void DR_Dist_To_Root_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree);
+void DR_Dist_To_Root(t_node *n_root, t_tree *tree);
+void DR_Get_X_Coord_Pre(t_node *a, t_node *d, t_edge *b, tdraw *w, int fixed_tips, t_tree *tree);
+void DR_Get_X_Coord(int fixed_tips, tdraw *w, t_tree *tree);
+tdraw *DR_Make_Tdraw_Struct(t_tree *tree);
void DR_Init_Tdraw_Struct(tdraw *d);
-void DR_Get_Tree_Box_Width(tdraw *w, arbre *tree);
-void DR_Get_Y_Coord_Post(node *a, node *d, edge *b, int *next_y_slot, tdraw *w, arbre *tree);
-void DR_Get_Y_Coord(tdraw *w, arbre *tree);
-void DR_Get_Tree_Coord(arbre *tree);
-double DR_Get_Max_Dist_To_Root(arbre *tree);
-void DR_Print_Tree_Postscript(int tree_num, FILE *fp, arbre *tree);
-void DR_Print_Tree_Postscript_Pre(node *a, node *d, FILE *fp, tdraw *w, arbre *tree);
+void DR_Get_Tree_Box_Width(tdraw *w, t_tree *tree);
+void DR_Get_Y_Coord_Post(t_node *a, t_node *d, t_edge *b, int *next_y_slot, int fixed_tips, tdraw *w, t_tree *tree);
+void DR_Get_Y_Coord(int fixed_tips, tdraw *w, t_tree *tree);
+void DR_Get_Tree_Coord(t_tree *tree);
+phydbl DR_Get_Max_Dist_To_Root(t_tree *tree);
+void DR_Print_Tree_Postscript(int tree_num, int render_name,FILE *fp, t_tree *tree);
+void DR_Print_Tree_Postscript_Pre(t_node *a, t_node *d, t_edge *b, int render_name, FILE *fp, tdraw *w, t_tree *tree);
void DR_Print_Postscript_EOF(FILE *fp);
void DR_Print_Postscript_Header(int n_pages, FILE *fp);
+void DR_Get_Tree_Coord_Scaled(tdraw *w, t_tree *tree);
+void DR_Get_Cdf_Mat(t_tree *tree);
+void DR_Draw_Tree(char *file_name, t_tree *tree);
+
#endif
diff --git a/phyml/eigen.c b/phyml/eigen.c
index 44ce785..44dc30d 100644
--- a/phyml/eigen.c
+++ b/phyml/eigen.c
@@ -1,14 +1,11 @@
-
-/* wash. outcommented most of the funciton since redefined in seq-gen eigen.c */
-
/***********************************************************
* This eigen() routine works for eigenvalue/vector analysis
* for real general square matrix A
* A will be destroyed
* rr,ri are vectors containing eigenvalues
-* vr,vi are matrices containing (right) eigenvectors
+* vr,vi are matrices containing (right) real and imaginary eigenvectors
*
-* A*[vr+vi*i] = [vr+vi*i] * diag{rr+ri*i}
+* A * [vr+vi*i] = [vr+vi*i] * diag{rr+ri*i}
*
* Algorithm: Handbook for Automatic Computation, vol 2
* by Wilkinson and Reinsch, 1971
@@ -23,16 +20,18 @@
* Thu May 6 15:22:31 CDT 1993
***************************************************************/
-#include "utilities.h"
#include "eigen.h"
-#include "free.h"
+
#define BASE 2 /* base of floating point arithmetic */
-#define DIGITS 40 /* no. of digits to the base BASE in the fraction */
-/*
-#define DIGITS 53
+
+/* no. of digits to the base BASE in the fraction */
+#define DIGITS 40
+/*
+#define DIGITS 53
*/
-#define MAXITER 30 /* max2. no. of iterations to converge */
+
+#define MAXITER 10000 /* max2. no. of iterations to converge */
#define pos(i,j,n) ((i)*(n)+(j))
@@ -41,108 +40,119 @@
/* ri/vi : imaginary part s of eigen values/vectors */
-int Eigen(int job, double *A, int n, double *rr, double *ri,
- double *vr, double *vi, double *work)
+int Eigen(int job, phydbl *A, int n, phydbl *rr, phydbl *ri,
+ phydbl *vr, phydbl *vi, phydbl *work)
{
/* job=0: eigen values only
1: both eigen values and eigen vectors
- double w[n*2]: work space
+ phydbl w[n*2]: work space
*/
int low,hi,i,j,k, it, istate=0;
- double tiny=sqrt(pow((double)BASE,(double)(1-DIGITS))), t;
-
-/* printf("EIGEN\n"); */
-
- bbalance(A,n,&low,&hi,work);
- elemhess(job,A,n,low,hi,vr,vi, (int*)(work+n));
+ phydbl tiny, t;
+
+ tiny=SQRT(POW((phydbl)BASE,(phydbl)(1-(int)DIGITS)));
+ /* tiny=FLT_MIN; */
+ /* tiny = SMALL; */
+
+ balance(A,n,&low,&hi,work);
+ elemhess(job,A,n,low,hi,vr,vi,(int*)(work+n));
if (-1 == realeig(job,A,n,low,hi,rr,ri,vr,vi)) return (-1);
if (job) unbalance(n,vr,vi,low,hi,work);
-
-/* sort, added by Z. Yang */
- for (i=0; itiny) istate=1;
- }
-
- return (istate) ;
+
+ /* sort, added by Z. Yang */
+ for (i=0; itiny) istate=1;
+ }
+
+ return (istate) ;
}
-/* complex funcctions
-*/
+/* complex functions
+ */
-/*
-complex compl (double re,double im)
+complex compl (phydbl re,phydbl im)
{
- complex r;
-
- r.re = re;
- r.im = im;
- return(r);
+ complex r;
+
+ r.re = re;
+ r.im = im;
+ return(r);
}
-*/
+
complex _conj (complex a)
{
- a.im = -a.im;
- return(a);
+ a.im = -a.im;
+ return(a);
}
-#define csize(a) (fabs(a.re)+fabs(a.im))
-
-/*
complex cplus (complex a, complex b)
{
- complex c;
- c.re = a.re+b.re;
- c.im = a.im+b.im;
- return (c);
+ complex c;
+ c.re = a.re+b.re;
+ c.im = a.im+b.im;
+ return (c);
}
complex cminus (complex a, complex b)
{
- complex c;
- c.re = a.re-b.re;
- c.im = a.im-b.im;
- return (c);
+ complex c;
+ c.re = a.re-b.re;
+ c.im = a.im-b.im;
+ return (c);
}
complex cby (complex a, complex b)
{
- complex c;
- c.re = a.re*b.re-a.im*b.im ;
- c.im = a.re*b.im+a.im*b.re ;
- return (c);
+ complex c;
+ c.re = a.re*b.re-a.im*b.im ;
+ c.im = a.re*b.im+a.im*b.re ;
+ return (c);
}
complex cdiv (complex a,complex b)
{
- double ratio, den;
- complex c;
-
- if (fabs(b.re) <= fabs(b.im)) {
- ratio = b.re / b.im;
- den = b.im * (1 + ratio * ratio);
- c.re = (a.re * ratio + a.im) / den;
- c.im = (a.im * ratio - a.re) / den;
- }
- else {
- ratio = b.im / b.re;
- den = b.re * (1 + ratio * ratio);
- c.re = (a.re + a.im * ratio) / den;
- c.im = (a.im - a.re * ratio) / den;
- }
- return(c);
+ phydbl ratio, den;
+ complex c;
+
+ if (fabs(b.re) <= fabs(b.im)) {
+ ratio = b.re / b.im;
+ den = b.im * (1 + ratio * ratio);
+ c.re = (a.re * ratio + a.im) / den;
+ c.im = (a.im * ratio - a.re) / den;
+ }
+ else {
+ ratio = b.im / b.re;
+ den = b.re * (1 + ratio * ratio);
+ c.re = (a.re + a.im * ratio) / den;
+ c.im = (a.im - a.re * ratio) / den;
+ }
+ return(c);
}
-*/
-
/* complex local_cexp (complex a) */
/* { */
/* complex c; */
@@ -152,208 +162,206 @@ complex cdiv (complex a,complex b)
/* return (c); */
/* } */
-/*
-
-complex cfactor (complex x, double a)
+complex cfactor (complex x, phydbl a)
{
- complex c;
- c.re = a*x.re;
- c.im = a*x.im;
- return (c);
+ complex c;
+ c.re = a*x.re;
+ c.im = a*x.im;
+ return (c);
}
int cxtoy (complex *x, complex *y, int n)
{
- int i;
- For (i,n) y[i]=x[i];
- return (0);
+ int i;
+ For (i,n) y[i]=x[i];
+ return (0);
}
-*/
-
-
-/* int cmatby (complex *a, complex *b, complex *c, int n,int m,int k) */
-/* /\* a[n*m], b[m*k], c[n*k] ...... c = a*b */
-/* *\/ */
-/* { */
-/* int i,j,i1; */
-/* complex t; */
-
-/* For (i,n) For(j,k) { */
-/* for (i1=0,t=compl(0,0); i1=n
- int i,j,k, *irow=(int*) space;
- double xmaxsize, ee=1e-20;
- complex xmax, t,t1;
-
- For(i,n) {
- xmaxsize = 0.;
- for (j=i; j=0; i--) {
- if (irow[i] == i) continue;
- For(j,n) {
- t = x[j*m+i];
- x[j*m+i] = x[j*m+irow[i]];
- x[ j*m+irow[i]] = t;
- }
+ int i,j,i1;
+ complex t;
+
+ For (i,n) for(j=0;j= 0; k--) {
- for (j = k; j >= 0; j--) {
- for (i = 0; i <= k; i++) {
- if (i != j && fabs(mat[pos(j,i,n)]) != 0) break;
- }
-
- if (i > k) {
- scale[k] = j;
-
- if (j != k) {
- for (i = 0; i <= k; i++) {
- c = mat[pos(i,j,n)];
- mat[pos(i,j,n)] = mat[pos(i,k,n)];
- mat[pos(i,k,n)] = c;
- }
-
- for (i = 0; i < n; i++) {
- c = mat[pos(j,i,n)];
- mat[pos(j,i,n)] = mat[pos(k,i,n)];
- mat[pos(k,i,n)] = c;
- }
- }
- break;
- }
- }
- if (j < 0) break;
+ /* x[n*m] ... m>=n
+ */
+ int i,j,k, *irow=(int*) space;
+ phydbl xmaxsize, ee=1e-20;
+ complex t,t1;
+
+ for(i=0;i=0; i--) {
+ if (irow[i] == i) continue;
+ for(j=0;j= 0; k--)
+ {
+ for (j = k; j >= 0; j--)
+ {
+ for (i = 0; i <= k; i++)
+ {
+ if (i != j && fabs(mat[pos(j,i,n)]) > SMALL) break;
}
- if (i > k) {
- scale[l] = j;
- if (j != l) {
- for (i = 0; i <= k; i++) {
- c = mat[pos(i,j,n)];
- mat[pos(i,j,n)] = mat[pos(i,l,n)];
- mat[pos(i,l,n)] = c;
- }
-
- for (i = l; i < n; i++) {
- c = mat[pos(j,i,n)];
- mat[pos(j,i,n)] = mat[pos(l,i,n)];
- mat[pos(l,i,n)] = c;
- }
- }
-
- break;
+
+ if (i > k) {
+ scale[k] = j;
+
+ if (j != k) {
+ for (i = 0; i <= k; i++) {
+ c = mat[pos(i,j,n)];
+ mat[pos(i,j,n)] = mat[pos(i,k,n)];
+ mat[pos(i,k,n)] = c;
+ }
+
+ for (i = 0; i < n; i++) {
+ c = mat[pos(j,i,n)];
+ mat[pos(j,i,n)] = mat[pos(k,i,n)];
+ mat[pos(k,i,n)] = c;
+ }
}
+ break;
+ }
}
-
- if (j > k) break;
+ if (j < 0) break;
}
-
- *hi = k;
- *low = l;
-
- /* balance the submatrix in rows l through k */
-
- for (i = l; i <= k; i++) {
- scale[i] = 1;
+
+ /* search for columns isolating an eigenvalue and push them left */
+
+ for (l = 0; l <= k; l++) {
+ for (j = l; j <= k; j++) {
+ for (i = l; i <= k; i++) {
+ if (i != j && fabs(mat[pos(i,j,n)]) > SMALL) break;
+ }
+ if (i > k) {
+ scale[l] = j;
+ if (j != l) {
+ for (i = 0; i <= k; i++) {
+ c = mat[pos(i,j,n)];
+ mat[pos(i,j,n)] = mat[pos(i,l,n)];
+ mat[pos(i,l,n)] = c;
+ }
+
+ for (i = l; i < n; i++) {
+ c = mat[pos(j,i,n)];
+ mat[pos(j,i,n)] = mat[pos(l,i,n)];
+ mat[pos(l,i,n)] = c;
+ }
+ }
+
+ break;
+ }
}
-
- do {
- for (done = 1,i = l; i <= k; i++) {
- for (c = 0,r = 0,j = l; j <= k; j++) {
- if (j != i) {
- c += fabs(mat[pos(j,i,n)]);
- r += fabs(mat[pos(i,j,n)]);
- }
+
+ if (j > k) break;
+ }
+
+ *hi = k;
+ *low = l;
+
+ /* balance the submatrix in rows l through k */
+
+ for (i = l; i <= k; i++) {
+ scale[i] = 1;
+ }
+
+ do {
+ for (done = 1,i = l; i <= k; i++) {
+ for (c = 0,r = 0,j = l; j <= k; j++) {
+ if (j != i) {
+ c += fabs(mat[pos(j,i,n)]);
+ r += fabs(mat[pos(i,j,n)]);
+ }
+ }
+
+ /* if (c != 0 && r != 0) { */
+ if ((fabs(c) > SMALL || fabs(c) < -SMALL) && (fabs(r) > SMALL || fabs(r) < -SMALL))
+ {
+ g = r / BASE;
+ f = 1;
+ s = c + r;
+
+ while (c < g) {
+ f *= BASE;
+ c *= BASE * BASE;
+ }
+
+ g = r * BASE;
+
+ while (c >= g) {
+ f /= BASE;
+ c /= BASE * BASE;
+ }
+
+ if ((c + r) / f < 0.95 * s) {
+ done = 0;
+ g = 1 / f;
+ scale[i] *= f;
+
+ for (j = l; j < n; j++) {
+ mat[pos(i,j,n)] *= g;
}
-
- if (c != 0 && r != 0) {
- g = r / BASE;
- f = 1;
- s = c + r;
-
- while (c < g) {
- f *= BASE;
- c *= BASE * BASE;
- }
-
- g = r * BASE;
-
- while (c >= g) {
- f /= BASE;
- c /= BASE * BASE;
- }
-
- if ((c + r) / f < 0.95 * s) {
- done = 0;
- g = 1 / f;
- scale[i] *= f;
-
- for (j = l; j < n; j++) {
- mat[pos(i,j,n)] *= g;
- }
-
- for (j = 0; j <= k; j++) {
- mat[pos(j,i,n)] *= f;
- }
- }
+
+ for (j = 0; j <= k; j++) {
+ mat[pos(j,i,n)] *= f;
}
+ }
}
- } while (!done);
+ }
+ } while (!done);
}
@@ -361,487 +369,508 @@ void bbalance(double *mat, int n,int *low, int *hi, double *scale)
* Transform back eigenvectors of a balanced matrix
* into the eigenvectors of the original matrix
*/
-
-/*
-void unbalance(int n,double *vr,double *vi, int low, int hi, double *scale)
+void unbalance(int n,phydbl *vr,phydbl *vi, int low, int hi, phydbl *scale)
{
- int i,j,k;
- double tmp;
-
- for (i = low; i <= hi; i++) {
- for (j = 0; j < n; j++) {
- vr[pos(i,j,n)] *= scale[i];
- vi[pos(i,j,n)] *= scale[i];
- }
+ int i,j,k;
+ phydbl tmp;
+
+ for (i = low; i <= hi; i++) {
+ for (j = 0; j < n; j++) {
+ vr[pos(i,j,n)] *= scale[i];
+ vi[pos(i,j,n)] *= scale[i];
}
-
- for (i = low - 1; i >= 0; i--) {
- if ((k = (int)scale[i]) != i) {
- for (j = 0; j < n; j++) {
- tmp = vr[pos(i,j,n)];
- vr[pos(i,j,n)] = vr[pos(k,j,n)];
- vr[pos(k,j,n)] = tmp;
-
- tmp = vi[pos(i,j,n)];
- vi[pos(i,j,n)] = vi[pos(k,j,n)];
- vi[pos(k,j,n)] = tmp;
- }
- }
+ }
+
+ for (i = low - 1; i >= 0; i--) {
+ if ((k = (int)scale[i]) != i) {
+ for (j = 0; j < n; j++) {
+ tmp = vr[pos(i,j,n)];
+ vr[pos(i,j,n)] = vr[pos(k,j,n)];
+ vr[pos(k,j,n)] = tmp;
+
+ tmp = vi[pos(i,j,n)];
+ vi[pos(i,j,n)] = vi[pos(k,j,n)];
+ vi[pos(k,j,n)] = tmp;
+ }
}
-
- for (i = hi + 1; i < n; i++) {
- if ((k = (int)scale[i]) != i) {
- for (j = 0; j < n; j++) {
- tmp = vr[pos(i,j,n)];
- vr[pos(i,j,n)] = vr[pos(k,j,n)];
- vr[pos(k,j,n)] = tmp;
-
- tmp = vi[pos(i,j,n)];
- vi[pos(i,j,n)] = vi[pos(k,j,n)];
- vi[pos(k,j,n)] = tmp;
- }
- }
+ }
+
+ for (i = hi + 1; i < n; i++) {
+ if ((k = (int)scale[i]) != i) {
+ for (j = 0; j < n; j++) {
+ tmp = vr[pos(i,j,n)];
+ vr[pos(i,j,n)] = vr[pos(k,j,n)];
+ vr[pos(k,j,n)] = tmp;
+
+ tmp = vi[pos(i,j,n)];
+ vi[pos(i,j,n)] = vi[pos(k,j,n)];
+ vi[pos(k,j,n)] = tmp;
+ }
}
+ }
}
-*/
-
/*
* Reduce the submatrix in rows and columns low through hi of real matrix mat to
* Hessenberg form by elementary similarity transformations
*/
-
- /*
-void elemhess(int job,double *mat,int n,int low,int hi, double *vr,
- double *vi, int *work)
+void elemhess(int job,phydbl *mat,int n,int low,int hi, phydbl *vr,
+ phydbl *vi, int *work)
{
-// work[n]
- int i,j,m;
- double x,y;
-
- for (m = low + 1; m < hi; m++) {
- for (x = 0,i = m,j = m; j <= hi; j++) {
- if (fabs(mat[pos(j,m-1,n)]) > fabs(x)) {
- x = mat[pos(j,m-1,n)];
- i = j;
+ /* work[n] */
+ unsigned int i,j,m;
+ phydbl x,y;
+
+ for (m = low + 1; m < hi; m++)
+ {
+ for (x = 0,i = m,j = m; j <= hi; j++)
+ {
+ if(fabs(mat[pos(j,m-1,n)]) > fabs(x))
+ {
+ x = mat[pos(j,m-1,n)];
+ i = j;
}
}
-
- if ((work[m] = i) != m) {
- for (j = m - 1; j < n; j++) {
- y = mat[pos(i,j,n)];
- mat[pos(i,j,n)] = mat[pos(m,j,n)];
- mat[pos(m,j,n)] = y;
+
+ if ((work[m] = i) != m)
+ {
+ for (j = m - 1; j < n; j++)
+ {
+ y = mat[pos(i,j,n)];
+ mat[pos(i,j,n)] = mat[pos(m,j,n)];
+ mat[pos(m,j,n)] = y;
}
-
- for (j = 0; j <= hi; j++) {
- y = mat[pos(j,i,n)];
- mat[pos(j,i,n)] = mat[pos(j,m,n)];
- mat[pos(j,m,n)] = y;
+
+ for (j = 0; j <= hi; j++)
+ {
+ y = mat[pos(j,i,n)];
+ mat[pos(j,i,n)] = mat[pos(j,m,n)];
+ mat[pos(j,m,n)] = y;
+ }
+ }
+
+ if (fabs(x) > SMALL)
+ {
+ for (i = m + 1; i <= hi; i++)
+ {
+ if (fabs(y = mat[pos(i,m-1,n)]) > SMALL)
+ {
+ y = mat[pos(i,m-1,n)] = y / x;
+
+ for (j = m; j < n; j++) {
+ mat[pos(i,j,n)] -= y * mat[pos(m,j,n)];
+ }
+
+ for (j = 0; j <= hi; j++) {
+ mat[pos(j,m,n)] += y * mat[pos(j,i,n)];
+ }
+ }
}
}
+ }
+
+ if (job)
+ {
+ for (i=0; i low; m--)
+ {
+ for (i = m + 1; i <= hi; i++)
+ {
+ vr[pos(i,m,n)] = mat[pos(i,m-1,n)];
+ }
+
+ if ((i = work[m]) != m)
+ {
+ for (j = m; j <= hi; j++)
+ {
+ vr[pos(m,j,n)] = vr[pos(i,j,n)];
+ vr[pos(i,j,n)] = 0.0;
+ }
+ vr[pos(i,m,n)] = 1.0;
+ }
+ }
+ }
+}
- if (x != 0) {
- for (i = m + 1; i <= hi; i++) {
- if ((y = mat[pos(i,m-1,n)]) != 0) {
- y = mat[pos(i,m-1,n)] = y / x;
+/*
+ * Calculate eigenvalues and eigenvectors of a real upper Hessenberg matrix
+ * Return 1 if converges successfully and 0 otherwise
+ */
- for (j = m; j < n; j++) {
- mat[pos(i,j,n)] -= y * mat[pos(m,j,n)];
+int realeig(int job,phydbl *mat,int n,int low, int hi, phydbl *valr,
+ phydbl *vali, phydbl *vr,phydbl *vi)
+{
+ complex v;
+ phydbl p=.0,q=.0,r=.0,s=.0,t,w,x,y,z=0,ra,sa,norm,eps;
+ int niter,en,i,j,k,l,m;
+ phydbl precision = POW((phydbl)BASE,(phydbl)(1-(int)DIGITS)); // Won't pass testiphy...
+ /* phydbl precision = SMALL; */
+
+
+ eps = precision;
+ for (i=0; i hi) valr[i] = mat[pos(i,i,n)];
+ }
+ t = 0;
+ en = hi;
+
+ while (en >= low)
+ {
+ niter = 0;
+ for (;;) {
+
+ /* look for single small subdiagonal element */
+
+ for (l = en; l > low; l--)
+ {
+ s = fabs(mat[pos(l-1,l-1,n)]) + fabs(mat[pos(l,l,n)]);
+ if (fabs(s) < SMALL) s = norm;
+ if (fabs(mat[pos(l,l-1,n)]) <= eps * s) break;
+ }
+
+ /* form shift */
+
+ x = mat[pos(en,en,n)];
+
+ if (l == en)
+ { /* one root found */
+ valr[en] = x + t;
+ if (job) mat[pos(en,en,n)] = x + t;
+ en--;
+ break;
+ }
+
+ y = mat[pos(en-1,en-1,n)];
+ w = mat[pos(en,en-1,n)] * mat[pos(en-1,en,n)];
+
+ if (l == en - 1)
+ { /* two roots found */
+ p = (y - x) / 2;
+ q = p * p + w;
+ z = SQRT(fabs(q));
+ x += t;
+ if (job)
+ {
+ mat[pos(en,en,n)] = x;
+ mat[pos(en-1,en-1,n)] = y + t;
+ }
+ if (q < 0)
+ { /* complex pair */
+ valr[en-1] = x+p;
+ vali[en-1] = z;
+ valr[en] = x+p;
+ vali[en] = -z;
+ }
+ else
+ { /* real pair */
+ z = (p < 0) ? p - z : p + z;
+ valr[en-1] = x + z;
+ valr[en] = (fabs(z) < SMALL) ? x + z : x - w / z;
+ if (job) {
+ x = mat[pos(en,en-1,n)];
+ s = fabs(x) + fabs(z);
+ p = x / s;
+ q = z / s;
+ r = SQRT(p*p+q*q);
+ p /= r;
+ q /= r;
+ for (j = en - 1; j < n; j++)
+ {
+ z = mat[pos(en-1,j,n)];
+ mat[pos(en-1,j,n)] = q * z + p *
+ mat[pos(en,j,n)];
+ mat[pos(en,j,n)] = q * mat[pos(en,j,n)] - p*z;
}
-
- for (j = 0; j <= hi; j++) {
- mat[pos(j,m,n)] += y * mat[pos(j,i,n)];
+ for (i = 0; i <= en; i++)
+ {
+ z = mat[pos(i,en-1,n)];
+ mat[pos(i,en-1,n)] = q * z + p * mat[pos(i,en,n)];
+ mat[pos(i,en,n)] = q * mat[pos(i,en,n)] - p*z;
+ }
+ for (i = low; i <= hi; i++)
+ {
+ z = vr[pos(i,en-1,n)];
+ vr[pos(i,en-1,n)] = q*z + p*vr[pos(i,en,n)];
+ vr[pos(i,en,n)] = q*vr[pos(i,en,n)] - p*z;
}
}
+ }
+ en -= 2;
+ break;
+ }
+ if (niter == MAXITER) return(-1);
+ if (niter != 0 && niter % 10 == 0) {
+ t += x;
+ for (i = low; i <= en; i++) mat[pos(i,i,n)] -= x;
+ s = fabs(mat[pos(en,en-1,n)]) + fabs(mat[pos(en-1,en-2,n)]);
+ x = y = 0.75 * s;
+ w = -0.4375 * s * s;
+ }
+ niter++;
+ /* look for two consecutive small subdiagonal elements */
+ for (m = en - 2; m >= l; m--) {
+ z = mat[pos(m,m,n)];
+ r = x - z;
+ s = y - z;
+ p = (r * s - w) / mat[pos(m+1,m,n)] + mat[pos(m,m+1,n)];
+ q = mat[pos(m+1,m+1,n)] - z - r - s;
+ r = mat[pos(m+2,m+1,n)];
+ s = fabs(p) + fabs(q) + fabs(r);
+ p /= s;
+ q /= s;
+ r /= s;
+ if (m == l || fabs(mat[pos(m,m-1,n)]) * (fabs(q)+fabs(r)) <=
+ eps * (fabs(mat[pos(m-1,m-1,n)]) + fabs(z) +
+ fabs(mat[pos(m+1,m+1,n)])) * fabs(p)) break;
+ }
+ for (i = m + 2; i <= en; i++) mat[pos(i,i-2,n)] = 0;
+ for (i = m + 3; i <= en; i++) mat[pos(i,i-3,n)] = 0;
+ /* phydbl QR step involving rows l to en and columns m to en */
+ for (k = m; k < en; k++) {
+ if (k != m) {
+ p = mat[pos(k,k-1,n)];
+ q = mat[pos(k+1,k-1,n)];
+ r = (k == en - 1) ? 0 : mat[pos(k+2,k-1,n)];
+ if (fabs(x = fabs(p) + fabs(q) + fabs(r)) < SMALL) continue;
+ p /= x;
+ q /= x;
+ r /= x;
+ }
+ s = SQRT(p*p+q*q+r*r);
+ if (p < 0) s = -s;
+ if (k != m) {
+ mat[pos(k,k-1,n)] = -s * x;
+ }
+ else if (l != m) {
+ mat[pos(k,k-1,n)] = -mat[pos(k,k-1,n)];
+ }
+ p += s;
+ x = p / s;
+ y = q / s;
+ z = r / s;
+ q /= p;
+ r /= p;
+ /* row modification */
+ for (j = k; j <= (!job ? en : n-1); j++){
+ p = mat[pos(k,j,n)] + q * mat[pos(k+1,j,n)];
+ if (k != en - 1) {
+ p += r * mat[pos(k+2,j,n)];
+ mat[pos(k+2,j,n)] -= p * z;
+ }
+ mat[pos(k+1,j,n)] -= p * y;
+ mat[pos(k,j,n)] -= p * x;
+ }
+ j = MIN(en,k+3);
+ /* column modification */
+ for (i = (!job ? l : 0); i <= j; i++) {
+ p = x * mat[pos(i,k,n)] + y * mat[pos(i,k+1,n)];
+ if (k != en - 1) {
+ p += z * mat[pos(i,k+2,n)];
+ mat[pos(i,k+2,n)] -= p*r;
+ }
+ mat[pos(i,k+1,n)] -= p*q;
+ mat[pos(i,k,n)] -= p;
+ }
+ if (job) { /* accumulate transformations */
+ for (i = low; i <= hi; i++) {
+ p = x * vr[pos(i,k,n)] + y * vr[pos(i,k+1,n)];
+ if (k != en - 1) {
+ p += z * vr[pos(i,k+2,n)];
+ vr[pos(i,k+2,n)] -= p*r;
}
+ vr[pos(i,k+1,n)] -= p*q;
+ vr[pos(i,k,n)] -= p;
+ }
}
+ }
}
- if (job) {
- for (i=0; i SMALL) {
+ /* back substitute to find vectors of upper triangular form */
+ for (en = n-1; en >= 0; en--) {
+ p = valr[en];
+ if ((q = vali[en]) < 0) { /* complex vector */
+ m = en - 1;
+ if (fabs(mat[pos(en,en-1,n)]) > fabs(mat[pos(en-1,en,n)])) {
+ mat[pos(en-1,en-1,n)] = q / mat[pos(en,en-1,n)];
+ mat[pos(en-1,en,n)] = (p - mat[pos(en,en,n)]) /
+ mat[pos(en,en-1,n)];
+ }
+ else {
+ v = cdiv(compl(0.0,-mat[pos(en-1,en,n)]),
+ compl(mat[pos(en-1,en-1,n)]-p,q));
+ mat[pos(en-1,en-1,n)] = v.re;
+ mat[pos(en-1,en,n)] = v.im;
+ }
+ mat[pos(en,en-1,n)] = 0;
+ mat[pos(en,en,n)] = 1;
+ for (i = en - 2; i >= 0; i--) {
+ w = mat[pos(i,i,n)] - p;
+ ra = 0;
+ sa = mat[pos(i,en,n)];
+ for (j = m; j < en; j++) {
+ ra += mat[pos(i,j,n)] * mat[pos(j,en-1,n)];
+ sa += mat[pos(i,j,n)] * mat[pos(j,en,n)];
}
- vr[pos(i,i,n)] = 1.0;
- }
-
- for (m = hi - 1; m > low; m--) {
- for (i = m + 1; i <= hi; i++) {
- vr[pos(i,m,n)] = mat[pos(i,m-1,n)];
+ if (vali[i] < 0) {
+ z = w;
+ r = ra;
+ s = sa;
}
-
- if ((i = work[m]) != m) {
- for (j = m; j <= hi; j++) {
- vr[pos(m,j,n)] = vr[pos(i,j,n)];
- vr[pos(i,j,n)] = 0.0;
+ else {
+ m = i;
+ if (fabs(vali[i]) < SMALL) {
+ v = cdiv(compl(-ra,-sa),compl(w,q));
+ mat[pos(i,en-1,n)] = v.re;
+ mat[pos(i,en,n)] = v.im;
+ }
+ else { /* solve complex equations */
+ x = mat[pos(i,i+1,n)];
+ y = mat[pos(i+1,i,n)];
+ v.re = (valr[i]- p)*(valr[i]-p) + vali[i]*vali[i] - q*q;
+ v.im = (valr[i] - p)*2*q;
+ if (fabs(v.re) + fabs(v.im) < SMALL) {
+ v.re = eps * norm * (fabs(w) +
+ fabs(q) + fabs(x) + fabs(y) + fabs(z));
+ }
+ v = cdiv(compl(x*r-z*ra+q*sa,x*s-z*sa-q*ra),v);
+ mat[pos(i,en-1,n)] = v.re;
+ mat[pos(i,en,n)] = v.im;
+ if (fabs(x) > fabs(z) + fabs(q)) {
+ mat[pos(i+1,en-1,n)] =
+ (-ra - w * mat[pos(i,en-1,n)] +
+ q * mat[pos(i,en,n)]) / x;
+ mat[pos(i+1,en,n)] = (-sa - w * mat[pos(i,en,n)] -
+ q * mat[pos(i,en-1,n)]) / x;
+ }
+ else {
+ v = cdiv(compl(-r-y*mat[pos(i,en-1,n)],
+ -s-y*mat[pos(i,en,n)]),compl(z,q));
+ mat[pos(i+1,en-1,n)] = v.re;
+ mat[pos(i+1,en,n)] = v.im;
+ }
+ }
+ }
+ }
+ }
+ else if (fabs(q) < SMALL) { /* real vector */
+ m = en;
+ mat[pos(en,en,n)] = 1;
+ for (i = en - 1; i >= 0; i--) {
+ w = mat[pos(i,i,n)] - p;
+ r = mat[pos(i,en,n)];
+ for (j = m; j < en; j++) {
+ r += mat[pos(i,j,n)] * mat[pos(j,en,n)];
+ }
+ if (vali[i] < 0) {
+ z = w;
+ s = r;
+ }
+ else {
+ m = i;
+ if (fabs(vali[i]) < SMALL) {
+ if (fabs(t = w) < SMALL) t = eps * norm;
+ mat[pos(i,en,n)] = -r / t;
}
- vr[pos(i,m,n)] = 1.0;
- }
+ else { /* solve real equations */
+ x = mat[pos(i,i+1,n)];
+ y = mat[pos(i+1,i,n)];
+ q = (valr[i] - p) * (valr[i] - p) + vali[i]*vali[i];
+ t = (x * s - z * r) / q;
+ mat[pos(i,en,n)] = t;
+ if (fabs(x) <= fabs(z)) {
+ mat[pos(i+1,en,n)] = (-s - y * t) / z;
+ }
+ else {
+ mat[pos(i+1,en,n)] = (-r - w * t) / x;
+ }
+ }
+ }
+ }
}
- }
+ }
+ /* vectors of isolated roots */
+ for (i = 0; i < n; i++) {
+ if (i < low || i > hi) {
+ for (j = i; j < n; j++) {
+ vr[pos(i,j,n)] = mat[pos(i,j,n)];
+ }
+ }
+ }
+ /* multiply by transformation matrix */
+
+ for (j = n-1; j >= low; j--) {
+ m = MIN(j,hi);
+ for (i = low; i <= hi; i++) {
+ for (z = 0,k = low; k <= m; k++) {
+ z += vr[pos(i,k,n)] * mat[pos(k,j,n)];
+ }
+ vr[pos(i,j,n)] = z;
+ }
+ }
+ }
+ /* rearrange complex eigenvectors */
+ for (j = 0; j < n; j++) {
+ if (fabs(vali[j]) > SMALL) {
+ for (i = 0; i < n; i++) {
+ vi[pos(i,j,n)] = vr[pos(i,j+1,n)];
+ vr[pos(i,j+1,n)] = vr[pos(i,j,n)];
+ vi[pos(i,j+1,n)] = -vi[pos(i,j,n)];
+ }
+ j++;
+ }
+ }
+ return(0);
}
- */
-
-
-/*
- * Calculate eigenvalues and eigenvectors of a real upper Hessenberg matrix
- * Return 1 if converges successfully and 0 otherwise
- */
-
-/* int realeig(int job,double *mat,int n,int low, int hi, double *valr, */
-/* double *vali, double *vr,double *vi) */
-/* { */
-/* complex v; */
-/* double p=0,q=0,r=0,s=0,t,w,x,y,z=0,ra,sa,norm,eps; */
-/* int niter,en,i,j,k,l,m; */
-/* double precision = pow((double)BASE,(double)(1-DIGITS)); */
-
-/* eps = precision; */
-/* for (i=0; i hi) valr[i] = mat[pos(i,i,n)]; */
-/* } */
-/* t = 0; */
-/* en = hi; */
-
-/* while (en >= low) { */
-/* niter = 0; */
-/* for (;;) { */
-
-/* /\* look for single small subdiagonal element *\/ */
-
-/* for (l = en; l > low; l--) { */
-/* s = fabs(mat[pos(l-1,l-1,n)]) + fabs(mat[pos(l,l,n)]); */
-/* if (s == 0) s = norm; */
-/* if (fabs(mat[pos(l,l-1,n)]) <= eps * s) break; */
-/* } */
-
-/* /\* form shift *\/ */
-
-/* x = mat[pos(en,en,n)]; */
-
-/* if (l == en) { /\* one root found *\/ */
-/* valr[en] = x + t; */
-/* if (job) mat[pos(en,en,n)] = x + t; */
-/* en--; */
-/* break; */
-/* } */
-
-/* y = mat[pos(en-1,en-1,n)]; */
-/* w = mat[pos(en,en-1,n)] * mat[pos(en-1,en,n)]; */
-
-/* if (l == en - 1) { /\* two roots found *\/ */
-/* p = (y - x) / 2; */
-/* q = p * p + w; */
-/* z = sqrt(fabs(q)); */
-/* x += t; */
-/* if (job) { */
-/* mat[pos(en,en,n)] = x; */
-/* mat[pos(en-1,en-1,n)] = y + t; */
-/* } */
-/* if (q < 0) { /\* complex pair *\/ */
-/* valr[en-1] = x+p; */
-/* vali[en-1] = z; */
-/* valr[en] = x+p; */
-/* vali[en] = -z; */
-/* } */
-/* else { /\* real pair *\/ */
-/* z = (p < 0) ? p - z : p + z; */
-/* valr[en-1] = x + z; */
-/* valr[en] = (z == 0) ? x + z : x - w / z; */
-/* if (job) { */
-/* x = mat[pos(en,en-1,n)]; */
-/* s = fabs(x) + fabs(z); */
-/* p = x / s; */
-/* q = z / s; */
-/* r = sqrt(p*p+q*q); */
-/* p /= r; */
-/* q /= r; */
-/* for (j = en - 1; j < n; j++) { */
-/* z = mat[pos(en-1,j,n)]; */
-/* mat[pos(en-1,j,n)] = q * z + p * */
-/* mat[pos(en,j,n)]; */
-/* mat[pos(en,j,n)] = q * mat[pos(en,j,n)] - p*z; */
-/* } */
-/* for (i = 0; i <= en; i++) { */
-/* z = mat[pos(i,en-1,n)]; */
-/* mat[pos(i,en-1,n)] = q * z + p * mat[pos(i,en,n)]; */
-/* mat[pos(i,en,n)] = q * mat[pos(i,en,n)] - p*z; */
-/* } */
-/* for (i = low; i <= hi; i++) { */
-/* z = vr[pos(i,en-1,n)]; */
-/* vr[pos(i,en-1,n)] = q*z + p*vr[pos(i,en,n)]; */
-/* vr[pos(i,en,n)] = q*vr[pos(i,en,n)] - p*z; */
-/* } */
-/* } */
-/* } */
-/* en -= 2; */
-/* break; */
-/* } */
-/* if (niter == MAXITER) return(-1); */
-/* if (niter != 0 && niter % 10 == 0) { */
-/* t += x; */
-/* for (i = low; i <= en; i++) mat[pos(i,i,n)] -= x; */
-/* s = fabs(mat[pos(en,en-1,n)]) + fabs(mat[pos(en-1,en-2,n)]); */
-/* x = y = 0.75 * s; */
-/* w = -0.4375 * s * s; */
-/* } */
-/* niter++; */
-/* /\* look for two consecutive small subdiagonal elements *\/ */
-/* for (m = en - 2; m >= l; m--) { */
-/* z = mat[pos(m,m,n)]; */
-/* r = x - z; */
-/* s = y - z; */
-/* p = (r * s - w) / mat[pos(m+1,m,n)] + mat[pos(m,m+1,n)]; */
-/* q = mat[pos(m+1,m+1,n)] - z - r - s; */
-/* r = mat[pos(m+2,m+1,n)]; */
-/* s = fabs(p) + fabs(q) + fabs(r); */
-/* p /= s; */
-/* q /= s; */
-/* r /= s; */
-/* if (m == l || fabs(mat[pos(m,m-1,n)]) * (fabs(q)+fabs(r)) <= */
-/* eps * (fabs(mat[pos(m-1,m-1,n)]) + fabs(z) + */
-/* fabs(mat[pos(m+1,m+1,n)])) * fabs(p)) break; */
-/* } */
-/* for (i = m + 2; i <= en; i++) mat[pos(i,i-2,n)] = 0; */
-/* for (i = m + 3; i <= en; i++) mat[pos(i,i-3,n)] = 0; */
-/* /\* double QR step involving rows l to en and columns m to en *\/ */
-/* for (k = m; k < en; k++) { */
-/* if (k != m) { */
-/* p = mat[pos(k,k-1,n)]; */
-/* q = mat[pos(k+1,k-1,n)]; */
-/* r = (k == en - 1) ? 0 : mat[pos(k+2,k-1,n)]; */
-/* if ((x = fabs(p) + fabs(q) + fabs(r)) == 0) continue; */
-/* p /= x; */
-/* q /= x; */
-/* r /= x; */
-/* } */
-/* s = sqrt(p*p+q*q+r*r); */
-/* if (p < 0) s = -s; */
-/* if (k != m) { */
-/* mat[pos(k,k-1,n)] = -s * x; */
-/* } */
-/* else if (l != m) { */
-/* mat[pos(k,k-1,n)] = -mat[pos(k,k-1,n)]; */
-/* } */
-/* p += s; */
-/* x = p / s; */
-/* y = q / s; */
-/* z = r / s; */
-/* q /= p; */
-/* r /= p; */
-/* /\* row modification *\/ */
-/* for (j = k; j <= (!job ? en : n-1); j++){ */
-/* p = mat[pos(k,j,n)] + q * mat[pos(k+1,j,n)]; */
-/* if (k != en - 1) { */
-/* p += r * mat[pos(k+2,j,n)]; */
-/* mat[pos(k+2,j,n)] -= p * z; */
-/* } */
-/* mat[pos(k+1,j,n)] -= p * y; */
-/* mat[pos(k,j,n)] -= p * x; */
-/* } */
-/* j = MIN(en,k+3); */
-/* /\* column modification *\/ */
-/* for (i = (!job ? l : 0); i <= j; i++) { */
-/* p = x * mat[pos(i,k,n)] + y * mat[pos(i,k+1,n)]; */
-/* if (k != en - 1) { */
-/* p += z * mat[pos(i,k+2,n)]; */
-/* mat[pos(i,k+2,n)] -= p*r; */
-/* } */
-/* mat[pos(i,k+1,n)] -= p*q; */
-/* mat[pos(i,k,n)] -= p; */
-/* } */
-/* if (job) { /\* accumulate transformations *\/ */
-/* for (i = low; i <= hi; i++) { */
-/* p = x * vr[pos(i,k,n)] + y * vr[pos(i,k+1,n)]; */
-/* if (k != en - 1) { */
-/* p += z * vr[pos(i,k+2,n)]; */
-/* vr[pos(i,k+2,n)] -= p*r; */
-/* } */
-/* vr[pos(i,k+1,n)] -= p*q; */
-/* vr[pos(i,k,n)] -= p; */
-/* } */
-/* } */
-/* } */
-/* } */
-/* } */
-
-/* if (!job) return(0); */
-/* if (norm != 0) { */
-/* /\* back substitute to find vectors of upper triangular form *\/ */
-/* for (en = n-1; en >= 0; en--) { */
-/* p = valr[en]; */
-/* if ((q = vali[en]) < 0) { /\* complex vector *\/ */
-/* m = en - 1; */
-/* if (fabs(mat[pos(en,en-1,n)]) > fabs(mat[pos(en-1,en,n)])) { */
-/* mat[pos(en-1,en-1,n)] = q / mat[pos(en,en-1,n)]; */
-/* mat[pos(en-1,en,n)] = (p - mat[pos(en,en,n)]) / */
-/* mat[pos(en,en-1,n)]; */
-/* } */
-/* else { */
-/* v = cdiv(compl(0.0,-mat[pos(en-1,en,n)]), */
-/* compl(mat[pos(en-1,en-1,n)]-p,q)); */
-/* mat[pos(en-1,en-1,n)] = v.re; */
-/* mat[pos(en-1,en,n)] = v.im; */
-/* } */
-/* mat[pos(en,en-1,n)] = 0; */
-/* mat[pos(en,en,n)] = 1; */
-/* for (i = en - 2; i >= 0; i--) { */
-/* w = mat[pos(i,i,n)] - p; */
-/* ra = 0; */
-/* sa = mat[pos(i,en,n)]; */
-/* for (j = m; j < en; j++) { */
-/* ra += mat[pos(i,j,n)] * mat[pos(j,en-1,n)]; */
-/* sa += mat[pos(i,j,n)] * mat[pos(j,en,n)]; */
-/* } */
-/* if (vali[i] < 0) { */
-/* z = w; */
-/* r = ra; */
-/* s = sa; */
-/* } */
-/* else { */
-/* m = i; */
-/* if (vali[i] == 0) { */
-/* v = cdiv(compl(-ra,-sa),compl(w,q)); */
-/* mat[pos(i,en-1,n)] = v.re; */
-/* mat[pos(i,en,n)] = v.im; */
-/* } */
-/* else { /\* solve complex equations *\/ */
-/* x = mat[pos(i,i+1,n)]; */
-/* y = mat[pos(i+1,i,n)]; */
-/* v.re = (valr[i]- p)*(valr[i]-p) + vali[i]*vali[i] - q*q; */
-/* v.im = (valr[i] - p)*2*q; */
-/* if ((fabs(v.re) + fabs(v.im)) == 0) { */
-/* v.re = eps * norm * (fabs(w) + */
-/* fabs(q) + fabs(x) + fabs(y) + fabs(z)); */
-/* } */
-/* v = cdiv(compl(x*r-z*ra+q*sa,x*s-z*sa-q*ra),v); */
-/* mat[pos(i,en-1,n)] = v.re; */
-/* mat[pos(i,en,n)] = v.im; */
-/* if (fabs(x) > fabs(z) + fabs(q)) { */
-/* mat[pos(i+1,en-1,n)] = */
-/* (-ra - w * mat[pos(i,en-1,n)] + */
-/* q * mat[pos(i,en,n)]) / x; */
-/* mat[pos(i+1,en,n)] = (-sa - w * mat[pos(i,en,n)] - */
-/* q * mat[pos(i,en-1,n)]) / x; */
-/* } */
-/* else { */
-/* v = cdiv(compl(-r-y*mat[pos(i,en-1,n)], */
-/* -s-y*mat[pos(i,en,n)]),compl(z,q)); */
-/* mat[pos(i+1,en-1,n)] = v.re; */
-/* mat[pos(i+1,en,n)] = v.im; */
-/* } */
-/* } */
-/* } */
-/* } */
-/* } */
-/* else if (q == 0) { /\* real vector *\/ */
-/* m = en; */
-/* mat[pos(en,en,n)] = 1; */
-/* for (i = en - 1; i >= 0; i--) { */
-/* w = mat[pos(i,i,n)] - p; */
-/* r = mat[pos(i,en,n)]; */
-/* for (j = m; j < en; j++) { */
-/* r += mat[pos(i,j,n)] * mat[pos(j,en,n)]; */
-/* } */
-/* if (vali[i] < 0) { */
-/* z = w; */
-/* s = r; */
-/* } */
-/* else { */
-/* m = i; */
-/* if (vali[i] == 0) { */
-/* if ((t = w) == 0) t = eps * norm; */
-/* mat[pos(i,en,n)] = -r / t; */
-/* } */
-/* else { /\* solve real equations *\/ */
-/* x = mat[pos(i,i+1,n)]; */
-/* y = mat[pos(i+1,i,n)]; */
-/* q = (valr[i] - p) * (valr[i] - p) + vali[i]*vali[i]; */
-/* t = (x * s - z * r) / q; */
-/* mat[pos(i,en,n)] = t; */
-/* if (fabs(x) <= fabs(z)) { */
-/* mat[pos(i+1,en,n)] = (-s - y * t) / z; */
-/* } */
-/* else { */
-/* mat[pos(i+1,en,n)] = (-r - w * t) / x; */
-/* } */
-/* } */
-/* } */
-/* } */
-/* } */
-/* } */
-/* /\* vectors of isolated roots *\/ */
-/* for (i = 0; i < n; i++) { */
-/* if (i < low || i > hi) { */
-/* for (j = i; j < n; j++) { */
-/* vr[pos(i,j,n)] = mat[pos(i,j,n)]; */
-/* } */
-/* } */
-/* } */
-/* /\* multiply by transformation matrix *\/ */
-
-/* for (j = n-1; j >= low; j--) { */
-/* m = MIN(j,hi); */
-/* for (i = low; i <= hi; i++) { */
-/* for (z = 0,k = low; k <= m; k++) { */
-/* z += vr[pos(i,k,n)] * mat[pos(k,j,n)]; */
-/* } */
-/* vr[pos(i,j,n)] = z; */
-/* } */
-/* } */
-/* } */
-/* /\* rearrange complex eigenvectors *\/ */
-/* for (j = 0; j < n; j++) { */
-/* if (vali[j] != 0) { */
-/* for (i = 0; i < n; i++) { */
-/* vi[pos(i,j,n)] = vr[pos(i,j+1,n)]; */
-/* vr[pos(i,j+1,n)] = vr[pos(i,j,n)]; */
-/* vi[pos(i,j+1,n)] = -vi[pos(i,j,n)]; */
-/* } */
-/* j++; */
-/* } */
-/* } */
-/* return(0); */
-/* } */
-
#define LUDCMP_TINY 1.0e-20;
-int ludcmp(double **a, int n, double *d)
+int ludcmp(phydbl **a, int n, phydbl *d)
{
- int i,imax,j,k;
- double big,dum,sum,temp;
- double *vv;
-
- imax = 0;
- vv = (double *)mCalloc(n,sizeof(double));
-
- *d=1.0;
- for (i=0;i big) big=temp;
- if (big == 0.0) Exit("\n. Singular matrix in routine LUDCMP");
- vv[i]=1.0/big;
- }
- for (j=0;j big) big=temp;
+ if (fabs(big) < SMALL) Exit("\n. Singular matrix in routine LUDCMP");
+ vv[i]=1.0/big;
+ }
+ for (j=0;j big) big=temp;
+ if (fabs(big) < SMALL) Exit("\n. 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
+
#ifndef EIGEN_H
#define EIGEN_H
-int Eigen(int job, double *A, int n, double *rr, double *ri,
- double *vr, double *vi, double *w);
+#include "utilities.h"
+#include "free.h"
+
+#ifdef RWRAPPER
+#include
+#endif
+
+int ludcmp_1D(phydbl *a, int n, phydbl *d);
+void det_1D(phydbl *a, int n, phydbl *d);
-/* wash. renamed balance to bbalance due to name clash with SISSI */
-void bbalance(double *mat, int n, int *low, int *hi, double *scale);
-void unbalance(int n, double *vr, double *vi, int low, int hi,
- double *scale);
-int realeig(int job, double *mat, int n,int low, int hi, double *valr,
- double *vali, double *vr, double *vi);
-void elemhess(int job, double *mat, int n, int low, int hi,
- double *vr, double *vi, int *work);
+int Eigen(int job, phydbl *A, int n, phydbl *rr, phydbl *ri,
+ phydbl *vr, phydbl *vi, phydbl *w);
+void balance(phydbl *mat, int n, int *low, int *hi, phydbl *scale);
+void unbalance(int n, phydbl *vr, phydbl *vi, int low, int hi,
+ phydbl *scale);
+int realeig(int job, phydbl *mat, int n,int low, int hi, phydbl *valr,
+ phydbl *vali, phydbl *vr, phydbl *vi);
+void elemhess(int job, phydbl *mat, int n, int low, int hi,
+ phydbl *vr, phydbl *vi, int *work);
-int ludcmp(double **a, int n, double *d);
-void det(double **a, int n, double *d);
+int ludcmp(phydbl **a, int n, phydbl *d);
+void det(phydbl **a, int n, phydbl *d);
/* complex functions */
-typedef struct { double re, im; } complex;
-#define csize(a) (fabs(a.re)+fabs(a.im))
+typedef struct { phydbl re, im; } complex;
+#define csize(a) (FABS(a.re)+FABS(a.im))
-complex compl (double re,double im);
+complex compl (phydbl re,phydbl im);
complex _conj (complex a);
complex cplus (complex a, complex b);
complex cminus (complex a, complex b);
complex cby (complex a, complex b);
complex cdiv (complex a,complex b);
/* complex local_cexp (complex a); */
-complex cfactor (complex x, double a);
+complex cfactor (complex x, phydbl a);
int cxtoy (complex *x, complex *y, int n);
int cmatby (complex *a, complex *b, complex *c, int n,int m,int k);
int cmatout (FILE * fout, complex *x, int n, int m);
-int cmatinv( complex *x, int n, int m, double *space);
+int cmatinv( complex *x, int n, int m, phydbl *space);
+phydbl *Cholesky_Decomp(phydbl *A, int dim);
#endif
diff --git a/phyml/free.c b/phyml/free.c
index 01661b5..df24179 100644
--- a/phyml/free.c
+++ b/phyml/free.c
@@ -1,7 +1,7 @@
/*
PHYML : a program that computes maximum likelihood phylogenies from
-DNA or AA homologous sequences
+DNA or AA homologous sequences
Copyright (C) Stephane Guindon. Oct 2003 onward
@@ -10,37 +10,132 @@ the GNU public licence. See http://www.opensource.org for details.
*/
-#include "utilities.h"
#include "free.h"
-#include "m4.h"
-/*********************************************************/
-void Free_All_Nodes_Light(arbre *tree)
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Clade(t_clad *this)
+{
+ Free(this);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_All_Nodes_Light(t_tree *mixt_tree)
{
int i;
- For(i,2*tree->n_otu-2)
- Free_Node(tree->noeud[i]);
+ t_tree *tree;
+
+ tree = mixt_tree;
+ do
+ {
+ for(i=0;i<2*tree->n_otu-1;++i) if(tree->a_nodes[i] != NULL) Free_Node(tree->a_nodes[i]);
+ Free(tree->a_nodes);
+ tree = tree->next;
+ }
+ while(tree);
+
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_All_Edges_Light(arbre *tree)
+void Free_All_Edges_Light(t_tree *mixt_tree)
{
int i;
- For(i,2*tree->n_otu-3)
- if(tree->t_edges[i])
- Free_Edge(tree->t_edges[i]);
+ t_tree *tree;
+
+ tree = mixt_tree;
+
+ for(i=0;i<2*tree->n_otu-1;++i)
+ {
+ if(tree->a_edges[i] != NULL)
+ {
+ Free_Scalar_Dbl(tree->a_edges[i]->l);
+ Free_Scalar_Dbl(tree->a_edges[i]->l_old);
+ Free_Scalar_Dbl(tree->a_edges[i]->l_var);
+ Free_Scalar_Dbl(tree->a_edges[i]->l_var_old);
+ }
+ }
+
+ do
+ {
+ for(i=0;i<2*tree->n_otu-1;++i)
+ if(tree->a_edges[i] != NULL)
+ Free_Edge(tree->a_edges[i]);
+ Free(tree->a_edges);
+ tree = tree->next;
+ }
+ while(tree);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Edge_Length(t_edge *b)
+{
+ if(b->l) Free_Scalar_Dbl(b->l);
+ if(b->l_old) Free_Scalar_Dbl(b->l_old);
+ if(b->l_var) Free_Scalar_Dbl(b->l_var);
+ if(b->l_var_old) Free_Scalar_Dbl(b->l_var_old);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Edge(t_edge *b)
+{
+ Free_Label(b->label);
+ Free_Edge_Core(b);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Edge_Core(t_edge *b)
+{
+ Free(b);
}
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Node(t_node *n)
+{
+ Free(n->b);
+ Free(n->v);
+ Free(n->score);
+ Free(n->s_ingrp);
+ Free(n->s_outgrp);
+ Free(n->cal);
+ Free_Label(n->label);
+
+ if(n->c_seq_anc != NULL)
+ {
+ Free(n->c_seq_anc->state);
+ Free(n->c_seq_anc);
+ }
+
+ if(n->ori_name) { Free(n->ori_name); n->ori_name = NULL; }
+
+ /* if(n->name) { Free(n->name); n->name = NULL; } */
+ /* Don't do that: see Copy_Tax_Names_To_Tip_Labels
+ tree->a_nodes[i]->ori_name = tree->a_nodes[i]->name; */
-/*********************************************************/
+ Free(n);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
void Free_Mat(matrix *mat)
{
int i;
- For(i,mat->n_otu)
+ for(i=0;in_otu;i++)
{
Free(mat->P[i]);
Free(mat->Q[i]);
@@ -53,158 +148,141 @@ void Free_Mat(matrix *mat)
Free(mat->dist);
Free(mat->name);
Free(mat->tip_node);
-
+
Free(mat->on_off);
Free(mat);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Partial_Lk(phydbl ****p_lk, int len, int n_catg)
-{
- int i,j;
- For(i,len)
- {
- For(j,n_catg) Free((*p_lk)[i][j]);
- Free((*p_lk)[i]);
- }
- Free((*p_lk));
- (*p_lk) = NULL;
+void Free_Partial_Lk(phydbl *p_lk, int len, int n_catg)
+{
+ Free(p_lk);
+
+/* int i,j; */
+/* for(i=0;in_otu-2) Free(tree->t_dir[i]);
- Free(tree->t_dir);
-
- if(tree->has_bip)
+ tree = mixt_tree;
+ do
{
- For(i,2*tree->n_otu-2)
- {
- Free(tree->noeud[i]->bip_size);
- For(j,3)
- {
- Free(tree->noeud[i]->bip_node[j]);
- For(k,tree->n_otu) Free(tree->noeud[i]->bip_name[j][k]);
- Free(tree->noeud[i]->bip_name[j]);
- }
- Free(tree->noeud[i]->bip_node);
- Free(tree->noeud[i]->bip_name);
- }
+ if(tree->mat) Free_Mat(tree->mat);
+ Free(tree->t_dir);
+ if(tree->short_l) Free(tree->short_l);
+ if(tree->mutmap) Free(tree->mutmap);
+ Free_Bip(tree);
+ Free(tree->curr_path);
+ tree = tree->next;
}
-
- Free(tree->curr_path);
-
- For(i,2*tree->n_otu-3)
- {
- b = tree->t_edges[i];
- Free_Edge(b);
- }
- Free(tree->t_edges);
+ while(tree);
+ Free_All_Edges_Light(mixt_tree);
+ Free_All_Nodes_Light(mixt_tree);
- For(i,2*tree->n_otu-2)
+ tree = mixt_tree;
+ next = mixt_tree->next;
+ do
{
- n = tree->noeud[i];
- Free_Node(n);
+ Free(tree);
+ tree = next;
+ if(!tree) break;
+ next = next->next;
}
- Free(tree->noeud);
+ while(tree);
-
- For(i,tree->n_dead_edges)
- Free_Edge(tree->t_dead_edges[i]);
-
- For(i,tree->n_dead_nodes)
- Free_Node(tree->t_dead_nodes[i]);
-
- Free(tree->t_dead_edges);
- Free(tree->t_dead_nodes);
-
-
- Free(tree);
-}
-
-/*********************************************************/
-
-void Free_Edge_Labels(edge *b)
-{
- int i;
- For(i,b->n_labels+b->n_labels%BLOCK_LABELS) Free(b->labels[i]);
- Free(b->labels);
- b->labels = NULL;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Edge(edge *b)
-{
- Free_Edge_Labels(b);
- Free(b);
-}
-/*********************************************************/
-
-void Free_Node(node *n)
+void Free_Bip(t_tree *tree)
{
- int i;
-
- Free(n->b);
- Free(n->v);
- Free(n->l);
- Free(n->score);
- Free(n->name);
+ int i,j;
- if(n->list_of_reachable_tips)
+ if(tree->has_bip)
{
- For(i,3) Free(n->list_of_reachable_tips[i]);
- Free(n->list_of_reachable_tips);
- Free(n->n_of_reachable_tips);
+ For(i,2*tree->n_otu-2)
+ {
+ Free(tree->a_nodes[i]->bip_size);
+ for(j=0;j<3;j++) Free(tree->a_nodes[i]->bip_node[j]);
+ Free(tree->a_nodes[i]->bip_node);
}
-
- Free(n);
+ }
+ tree->has_bip = NO;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Cseq(allseq *data)
+void Free_Calign(calign *data)
{
int i;
-
+
+ if(data->io_wght) Free_Scalar_Dbl(data->io_wght);
Free(data->invar);
Free(data->wght);
Free(data->ambigu);
- Free(data->b_frq);
+ Free(data->obs_state_frq);
Free(data->sitepatt);
- For(i,data->n_otu)
+ for(i=0;in_otu;i++)
{
Free(data->c_seq[i]->name);
- if(data->c_seq[i]->state)
- {
- Free(data->c_seq[i]->state);
- if(data->c_seq[i]->is_ambigu) Free(data->c_seq[i]->is_ambigu);
- }
+ if(data->c_seq[i]->state)
+ {
+ Free(data->c_seq[i]->state);
+ Free(data->c_seq[i]->d_state);
+ if(data->c_seq[i]->is_ambigu) Free(data->c_seq[i]->is_ambigu);
+ }
Free(data->c_seq[i]);
}
- Free(data->c_seq);
+
+
+ for(i=0;in_rm;i++)
+ {
+ Free(data->c_seq_rm[i]->name);
+ if(data->c_seq_rm[i]->state)
+ {
+ Free(data->c_seq_rm[i]->state);
+ Free(data->c_seq_rm[i]->d_state);
+ if(data->c_seq_rm[i]->is_ambigu) Free(data->c_seq_rm[i]->is_ambigu);
+ }
+ Free(data->c_seq_rm[i]);
+ }
+
+ if(data->c_seq_rm != NULL) Free(data->c_seq_rm);
+ if(data->c_seq != NULL) Free(data->c_seq);
+
Free(data);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Seq(seq **d, int n_otu)
+void Free_Seq(align **d, int n_otu)
{
int i;
- For(i,n_otu)
+ for(i=0;iname);
Free(d[i]->state);
+ Free(d[i]->d_state);
if(d[i]->is_ambigu) Free(d[i]->is_ambigu);
Free(d[i]);
}
@@ -212,267 +290,717 @@ void Free_Seq(seq **d, int n_otu)
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
-void Free_All(seq **d, allseq *alldata, arbre *tree)
+void Free_All(align **d, calign *cdata, t_tree *tree)
{
- Free_Cseq(alldata);
+ Free_Calign(cdata);
Free_Seq(d,tree->n_otu);
Free_Tree(tree);
-}
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-/*********************************************************/
-void Free_SubTree(edge *b_fcus, node *a, node *d, arbre *tree)
+void Free_SubTree(t_edge *b_fcus, t_node *a, t_node *d, t_tree *tree)
{
int i;
if(d->tax) return;
else
{
- For(i,3)
- {
- if(d->v[i] != a)
- {
- Free_SubTree(d->b[i],d,d->v[i],tree);
- Free_Edge(d->b[i]);
- Free_Node(d->v[i]);
- }
- }
+ for(i=0;i<3;i++)
+ {
+ if(d->v[i] != a)
+ {
+ Free_SubTree(d->b[i],d,d->v[i],tree);
+ Free_Edge(d->b[i]);
+ Free_Node(d->v[i]);
+ }
+ }
}
}
-/*********************************************************/
-void Free_Tree_Ins_Tar(arbre *tree)
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Tree_Ins_Tar(t_tree *tree)
{
return;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Tree_Pars(arbre *tree)
+void Free_Tree_Pars(t_tree *mixt_tree)
{
int i;
-
- Free(tree->step_mat);
- Free(tree->site_pars);
- For(i,2*tree->n_otu-3)
- Free_Edge_Pars(tree->t_edges[i],tree);
+ t_tree *tree;
+
+ tree = mixt_tree;
+ do
+ {
+ Free(tree->step_mat);
+ Free(tree->site_pars);
+
+ for(i=0;i<2*tree->n_otu-3;++i)
+ {
+ Free_Edge_Pars(tree->a_edges[i]);
+ }
+
+ if(tree->n_root)
+ {
+ Free_Edge_Pars_Left(tree->n_root->b[1]);
+ Free_Edge_Pars_Left(tree->n_root->b[2]);
+ }
+ else
+ {
+ Free_Edge_Pars(tree->a_edges[2*tree->n_otu-3]);
+ Free_Edge_Pars(tree->a_edges[2*tree->n_otu-2]);
+ }
+
+ tree = tree->next;
+ }
+ while(tree);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Edge_Pars(edge *b, arbre *tree)
+void Free_Edge_Pars_Left(t_edge *b)
+{
+ if(b->pars_l) Free(b->pars_l);
+ if(b->ui_l) Free(b->ui_l);
+ if(b->p_pars_l) Free(b->p_pars_l);
+ if(b->n_diff_states_l) Free(b->n_diff_states_l);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Edge_Pars_Rght(t_edge *b)
+{
+ if(b->pars_r) Free(b->pars_r);
+ if(b->ui_r) Free(b->ui_r);
+ if(b->p_pars_r) Free(b->p_pars_r);
+ if(b->n_diff_states_r) Free(b->n_diff_states_r);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Edge_Pars(t_edge *b)
+{
+ Free_Edge_Pars_Left(b);
+ Free_Edge_Pars_Rght(b);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Tree_Lk(t_tree *mixt_tree)
{
int i;
+ t_tree *tree;
- Free(b->pars_l);
- Free(b->pars_r);
-
- For(i,tree->data->crunch_len)
+ tree = mixt_tree;
+ do
{
- Free(b->p_pars_l[i]);
- Free(b->p_pars_r[i]);
+ Free(tree->c_lnL_sorted);
+ Free(tree->cur_site_lk);
+ Free(tree->old_site_lk);
+ Free(tree->site_lk_cat);
+ Free(tree->fact_sum_scale);
+ Free(tree->unscaled_site_lk_cat);
+ Free(tree->expl);
+
+ if(tree->is_mixt_tree == NO)
+ {
+ Free(tree->eigen_lr_left);
+ Free(tree->eigen_lr_rght);
+ Free(tree->dot_prod);
+
+ for(i=0;i<3;i++) Free(tree->log_lks_aLRT[i]);
+ Free(tree->log_lks_aLRT);
+
+ Free(tree->div_post_pred_extra_0);
+ Free(tree->sum_scale_cat_extra_0);
+ Free(tree->sum_scale_extra_0);
+ Free(tree->patt_id_extra_0);
+ Free(tree->p_lk_extra_0);
+ Free(tree->p_lk_tip_extra_0);
+
+ Free(tree->div_post_pred_extra_1);
+ Free(tree->sum_scale_cat_extra_1);
+ Free(tree->sum_scale_extra_1);
+ Free(tree->patt_id_extra_1);
+ Free(tree->p_lk_extra_1);
+ Free(tree->p_lk_tip_extra_1);
+
+ for(i=0;i<2*tree->n_otu-1;++i) Free_NNI(tree->a_edges[i]->nni);
+ for(i=0;i<2*tree->n_otu-3;++i) Free_Edge_Lk(tree->a_edges[i]);
+ for(i=0;i<2*tree->n_otu-3;++i) Free_Edge_Loc(tree->a_edges[i]);
+
+ if(tree->n_root != NULL)
+ {
+ Free(tree->n_root->b[1]->Pij_rr);
+ Free(tree->n_root->b[2]->Pij_rr);
+ Free(tree->n_root->b[1]->tPij_rr);
+ Free(tree->n_root->b[2]->tPij_rr);
+ Free_Edge_Lk_Left(tree->n_root->b[1]);
+ Free_Edge_Lk_Left(tree->n_root->b[2]);
+ Free_Edge_Loc_Left(tree->n_root->b[1]);
+ Free_Edge_Loc_Left(tree->n_root->b[2]);
+ }
+ else
+ {
+ Free_Edge_Lk(tree->a_edges[2*tree->n_otu-3]);
+ Free_Edge_Lk(tree->a_edges[2*tree->n_otu-2]);
+ Free_Edge_Loc(tree->a_edges[2*tree->n_otu-3]);
+ Free_Edge_Loc(tree->a_edges[2*tree->n_otu-2]);
+ }
+ }
+
+ tree = tree->next;
+
}
+ while(tree);
- Free(b->ui_l);
- Free(b->ui_r);
- Free(b->p_pars_l);
- Free(b->p_pars_r);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Tree_Lk(arbre *tree)
+
+void Free_Node_Lk(t_node *n)
{
- int i;
- edge *b;
- node *n;
+/* Free(n->n_ex_nodes); */
+}
- b = NULL;
- n = NULL;
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
- For(i,3) Free(tree->log_lks_aLRT[i]);
- Free(tree->log_lks_aLRT);
+void Free_Extra_Edge_Lk(t_tree *tree)
+{
+ if(tree->div_post_pred_extra_0) Free(tree->div_post_pred_extra_0);
+ if(tree->sum_scale_cat_extra_0) Free(tree->sum_scale_cat_extra_0);
+ if(tree->sum_scale_extra_0) Free(tree->sum_scale_extra_0);
+ if(tree->p_lk_extra_0) Free(tree->p_lk_extra_0);
+ if(tree->p_lk_tip_extra_0) Free(tree->p_lk_tip_extra_0);
+ if(tree->patt_id_extra_0) Free(tree->patt_id_extra_0);
+
+ if(tree->div_post_pred_extra_1) Free(tree->div_post_pred_extra_1);
+ if(tree->sum_scale_cat_extra_1) Free(tree->sum_scale_cat_extra_1);
+ if(tree->sum_scale_extra_1) Free(tree->sum_scale_extra_1);
+ if(tree->p_lk_extra_1) Free(tree->p_lk_extra_1);
+ if(tree->p_lk_tip_extra_1) Free(tree->p_lk_tip_extra_1);
+ if(tree->patt_id_extra_1) Free(tree->patt_id_extra_1);
+}
- Free(tree->c_lnL_sorted);
- Free(tree->site_lk);
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
- For(i,tree->mod->n_catg) Free(tree->log_site_lk_cat[i]);
- Free(tree->log_site_lk_cat);
-
- For(i,2*tree->n_otu-3)
+void Free_Edge_Lk_Rght(t_edge *b)
+{
+ assert(b);
+
+ Free(b->div_post_pred_rght);
+
+ if(b->p_lk_rght)
{
- b = tree->t_edges[i];
- Free_Edge_Lk(tree,b);
+ Free(b->p_lk_rght);
+ if(b->sum_scale_rght) Free(b->sum_scale_rght);
}
+
+ if(b->p_lk_tip_r) Free(b->p_lk_tip_r);
+ if(b->sum_scale_rght_cat) Free(b->sum_scale_rght_cat);
+ if(b->patt_id_rght) Free(b->patt_id_rght);
}
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-/*********************************************************/
+void Free_Edge_Lk_Left(t_edge *b)
+{
+
+ Free(b->div_post_pred_left);
+ if(b->p_lk_left)
+ {
+ Free(b->p_lk_left);
+ if(b->sum_scale_left) Free(b->sum_scale_left);
+ }
-void Free_Node_Lk(node *n)
+ if(b->p_lk_tip_l) Free(b->p_lk_tip_l);
+ if(b->sum_scale_left_cat) Free(b->sum_scale_left_cat);
+ if(b->patt_id_left) Free(b->patt_id_left);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Edge_Lk(t_edge *b)
{
-/* Free(n->n_ex_nodes); */
+ Free(b->tPij_rr);
+ Free(b->Pij_rr);
+
+ Free_Edge_Lk_Left(b);
+ Free_Edge_Lk_Rght(b);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Edge_Lk(arbre *tree, edge *b)
+void Free_Edge_Loc_Rght(t_edge *b)
{
- int i,j;
+ if(b->p_lk_loc_rght) Free(b->p_lk_loc_rght);
+}
- Free(b->nni);
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
- Free(b->div_post_pred_left);
- Free(b->div_post_pred_rght);
+void Free_Edge_Loc_Left(t_edge *b)
+{
+ if(b->p_lk_loc_left) Free(b->p_lk_loc_left);
+}
- if(b->p_lk_left)
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Edge_Loc(t_edge *b)
+{
+ Free_Edge_Loc_Left(b);
+ Free_Edge_Loc_Rght(b);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Model_Complete(t_mod *mixt_mod)
+{
+ Free_Eigen(mixt_mod->eigen);
+ Free_Rmat(mixt_mod->r_mat);
+ Free_Efrq(mixt_mod->e_frq);
+ Free_Vect_Dbl(mixt_mod->Pij_rr);
+ mixt_mod->r_mat = NULL;
+ mixt_mod->e_frq = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Rmat_Weights(t_mod *mixt_mod)
+{
+ t_mod *mod;
+
+ mod = mixt_mod;
+
+ do
{
- For(i,tree->data->crunch_len)
- {
- For(j,tree->mod->n_catg)
- {
- Free(b->p_lk_left[i][j]);
- }
- Free(b->p_lk_left[i]);
- }
- Free(b->p_lk_left);
- if(b->sum_scale_f_left) Free(b->sum_scale_f_left);
+ Free(mod->r_mat_weight);
+ mod = mod->next_mixt;
}
+ while(mod);
+
+ if(mixt_mod->next) Free_Scalar_Dbl(mixt_mod->next->r_mat_weight);
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Efrq_Weights(t_mod *mixt_mod)
+{
+ t_mod *mod;
+
+ mod = mixt_mod;
- if(b->p_lk_tip_l)
+ do
{
- For(i,tree->data->crunch_len)
- {
- Free(b->p_lk_tip_l[i]);
- }
- Free(b->p_lk_tip_l);
+ Free(mod->e_frq_weight);
+ mod = mod->next_mixt;
}
+ while(mod);
+ if(mixt_mod->next) Free_Scalar_Dbl(mixt_mod->next->e_frq_weight);
- if(b->p_lk_rght)
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Model_Basic(t_mod *mixt_mod)
+{
+ t_mod *mod;
+
+ Free_RAS(mixt_mod->ras);
+ Free_Scalar_Dbl(mixt_mod->mr);
+ Free_Scalar_Dbl(mixt_mod->kappa);
+ Free_Scalar_Dbl(mixt_mod->lambda);
+ Free_Scalar_Dbl(mixt_mod->br_len_mult);
+ Free_Scalar_Dbl(mixt_mod->br_len_mult_unscaled);
+
+ Free_Rmat_Weights(mixt_mod);
+ Free_Efrq_Weights(mixt_mod);
+
+ Free_String(mixt_mod->modelname);
+ Free_String(mixt_mod->custom_mod_string);
+ Free_String(mixt_mod->aa_rate_mat_file);
+
+ mod = mixt_mod;
+ do
{
- For(i,tree->data->crunch_len)
- {
- For(j,tree->mod->n_catg)
- {
- Free(b->p_lk_rght[i][j]);
- }
- Free(b->p_lk_rght[i]);
- }
- Free(b->p_lk_rght);
- if(b->sum_scale_f_rght) Free(b->sum_scale_f_rght);
+ if(mod->next)
+ {
+ mod = mod->next;
+ Free(mod->prev);
+ }
+ else
+ {
+ Free(mod);
+ break;
+ }
}
+ while(mod);
- if(b->p_lk_tip_r)
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Vect_Dbl(vect_dbl *v)
+{
+ vect_dbl *next;
+
+ assert(v);
+
+ next = v->next;
+ do
{
- For(i,tree->data->crunch_len)
- {
- Free(b->p_lk_tip_r[i]);
- }
- Free(b->p_lk_tip_r);
+ Free(v->v);
+ Free(v);
+
+ v = next;
+ if(v) next = v->next;
}
+ while(v);
+}
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
- For(i,tree->mod->n_catg)
+void Free_Vect_Int(vect_int *v)
+{
+ vect_int *next;
+
+ assert(v);
+
+ next = v->next;
+ do
{
- For(j,tree->mod->ns)
- {
- Free(b->Pij_rr[i][j]);
- }
- Free(b->Pij_rr[i]);
+ Free(v->v);
+ Free(v);
+
+ v = next;
+ if(v) next = v->next;
}
- Free(b->Pij_rr);
+ while(v);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Model(model *mod)
+void Free_Scalar_Dbl(scalar_dbl *v)
{
- int i,j;
+ scalar_dbl *next;
+
+ assert(v);
+
+ next = v->next;
+ do
+ {
+ Free(v);
+ v = next;
+ if(v) next = v->next;
+ }
+ while(v);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Scalar_Int(scalar_int *v)
+{
+ scalar_int *next;
+
+ assert(v);
+
+ next = v->next;
+ do
+ {
+ Free(v);
+ v = next;
+ if(v) next = v->next;
+ }
+ while(v);
+}
+
- Free(mod->modelname);
- Free(mod->custom_mod_string);
- Free(mod->user_b_freq);
- Free(mod->rr_num);
- Free(mod->rr);
- Free(mod->rr_val);
- Free(mod->n_rr_per_cat);
- Free(mod->s_opt);
- Free(mod->pi);
- Free(mod->pi_unscaled);
- Free(mod->gamma_r_proba);
- Free(mod->gamma_rr);
- Free(mod->qmat);
- Free(mod->qmat_buff);
- Free_Eigen(mod->eigen);
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Linked_List(t_ll *t)
+{
+ t_ll *next,*ll;
- For(i,mod->n_catg)
+ if(t == NULL) return;
+
+ ll = t->head;
+ next = ll->next;
+ do
{
- For(j,mod->ns) Free(mod->Pij_rr[i][j]);
- Free(mod->Pij_rr[i]);
+ /* t_node *n = ll->v; */
+ /* printf("\n. free node %d",n?n->num:-1); */
+ /* printf(" ll: %p",ll); */
+ /* printf(" hd: %p",ll?ll->head:NULL); fflush(NULL); */
+ Free(ll);
+ ll = next;
+ if(ll) next = ll->next;
+ }
+ while(ll);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_String(t_string *ts)
+{
+ t_string *next;
+
+ next = ts->next;
+ do
+ {
+ Free(ts->s);
+ Free(ts);
+
+ ts = next;
+ if(ts) next = ts->next;
}
- Free(mod->Pij_rr);
+ while(ts);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Custom_Model(t_mod *mod)
+{
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Efrq(t_efrq *e_frq)
+{
+ Free(e_frq->pi->v);
+ Free(e_frq->pi);
+
+ Free(e_frq->pi_unscaled->v);
+ Free(e_frq->pi_unscaled);
+
+ Free(e_frq->user_b_freq->v);
+ Free(e_frq->user_b_freq);
+
+ if(e_frq->next) Free_Efrq(e_frq->next);
+
+ Free(e_frq);
+}
- if(mod->n_rr_branch)
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Rmat(t_rmat *r_mat)
+{
+
+ Free(r_mat->rr->v);
+ Free(r_mat->rr);
+
+ Free(r_mat->rr_num->v);
+
+ Free(r_mat->rr_val->v);
+ Free(r_mat->rr_val);
+
+ Free(r_mat->n_rr_per_cat->v);
+ Free(r_mat->n_rr_per_cat);
+
+ Free(r_mat->rr_num);
+
+ Free(r_mat->qmat->v);
+ Free(r_mat->qmat);
+
+ Free(r_mat->qmat_buff->v);
+ Free(r_mat->qmat_buff);
+
+ if(r_mat->next) Free_Rmat(r_mat->next);
+
+ Free(r_mat);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_RAS(t_ras *ras)
+{
+ if(ras->gamma_r_proba->v)
{
- Free(mod->rr_branch);
- Free(mod->p_rr_branch);
+ Free(ras->gamma_r_proba->v);
+ Free(ras->gamma_r_proba_unscaled->v);
+ Free(ras->gamma_rr->v);
+ Free(ras->gamma_rr_unscaled->v);
}
- #ifndef PHYML
- /* Commented out by wash, we don't use M4 mode, setting PHYML does
- not help */
- /* M4_Free_M4_Model(mod->m4mod); */
- #endif
- Free(mod);
+ Free(ras->gamma_r_proba);
+ Free(ras->skip_rate_cat);
+
+ Free(ras->gamma_r_proba_unscaled);
+ Free(ras->gamma_rr);
+ Free(ras->gamma_rr_unscaled);
+ Free_Scalar_Dbl(ras->pinvar);
+ Free_Scalar_Dbl(ras->alpha);
+ Free_Scalar_Dbl(ras->free_rate_mr);
+
+ if(ras->next) Free_RAS(ras->next);
+
+ Free(ras);
}
-/*********************************************************/
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Model(t_mod *mod)
+{
+ Free_Custom_Model(mod);
+ Free_Model_Complete(mod);
+ Free_Model_Basic(mod);
+ /* Free(mod); */
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
void Free(void *p)
{
+#if (defined(__AVX__) || defined(__SSE3__))
+#ifndef WIN32
free(p);
+#else
+ _aligned_free(p);
+#endif
+#else
+ free(p);
+#endif
+
+ p = NULL;
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Free_Input(option *io)
{
- Free(io->in_seq_file);
- Free(io->in_tree_file);
- Free(io->out_tree_file);
- Free(io->out_best_tree_file);
- Free(io->out_boot_tree_file);
- Free(io->out_boot_stats_file);
- Free(io->out_stats_file);
- Free(io->out_lk_file);
- Free(io->out_ps_file);
- Free(io->out_trace_file);
- Free(io->nt_or_cd);
- Free(io);
+ int i;
+
+ do
+ {
+ RATES_Free_Rates(io->rates);
+ MCMC_Free_MCMC(io->mcmc);
+ Free(io->in_align_file);
+ Free(io->in_tree_file);
+ Free(io->in_constraint_tree_file);
+ Free(io->in_coord_file);
+ Free(io->out_file);
+ Free(io->out_tree_file);
+ Free(io->out_trees_file);
+ Free(io->out_boot_tree_file);
+ Free(io->out_boot_stats_file);
+ Free(io->out_stats_file);
+ Free(io->weight_file);
+ Free(io->out_lk_file);
+ Free(io->out_summary_file);
+ Free(io->out_ps_file);
+ Free(io->out_trace_file);
+ Free(io->out_json_trace_file);
+ Free(io->out_ancestral_seq_file);
+ Free(io->out_ancestral_tree_file);
+ Free(io->nt_or_cd);
+ Free(io->run_id_string);
+ Free(io->clade_list_file);
+ for(i=0;ialphabet[i]);
+ Free(io->alphabet);
+ if(io->short_tax_names)
+ {
+ for(i=0;isize_tax_names;i++)
+ {
+ Free(io->short_tax_names[i]);
+ Free(io->long_tax_names[i]);
+ }
+ Free(io->long_tax_names);
+ Free(io->short_tax_names);
+ }
+ Free_Tree_List(io->treelist);
+
+ if(io->lon) Free(io->lon);
+ if(io->lat) Free(io->lat);
+
+ if(io->next)
+ {
+ io = io->next;
+ Free(io->prev);
+ }
+ else
+ {
+ Free(io);
+ break;
+ }
+
+ }while(1);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_St(superarbre *st)
+void Free_Tree_List(t_treelist *list)
+{
+ Free(list->tree);
+ Free(list);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+void Free_St(supert_tree *st)
{
int i;
- For(i,2*st->tree->n_otu-3)
- Free(st->tree->t_edges[i]->nni);
+ For(i,2*st->tree->n_otu-1)
+ Free_NNI(st->tree->a_edges[i]->nni);
- For(i,st->n_gt) Free(st->match_st_node_in_gt[i]);
+ for(i=0;in_part;i++) Free(st->match_st_node_in_gt[i]);
Free(st->match_st_node_in_gt);
Free_Tree(st->tree);
-
+
Free(st);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Free_Eigen(eigen *eigen_struct)
{
@@ -480,108 +1008,110 @@ void Free_Eigen(eigen *eigen_struct)
Free(eigen_struct->space);
Free(eigen_struct->e_val);
Free(eigen_struct->e_val_im);
- Free(eigen_struct->r_e_vect);
Free(eigen_struct->r_e_vect_im);
Free(eigen_struct->l_e_vect);
+ Free(eigen_struct->r_e_vect);
+ Free(eigen_struct->dum);
Free(eigen_struct->q);
+
+ if(eigen_struct->next) Free_Eigen(eigen_struct->next);
+
Free(eigen_struct);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_One_Spr(spr *this_spr)
+
+void Free_One_Spr(t_spr *this_spr)
{
Free(this_spr->path);
- Free(this_spr);
+ if(this_spr->l0) Free_Scalar_Dbl(this_spr->l0);
+ if(this_spr->l1) Free_Scalar_Dbl(this_spr->l1);
+ if(this_spr->l2) Free_Scalar_Dbl(this_spr->l2);
+ if(this_spr->v0) Free_Scalar_Dbl(this_spr->v0);
+ if(this_spr->v1) Free_Scalar_Dbl(this_spr->v1);
+ if(this_spr->v2) Free_Scalar_Dbl(this_spr->v2);
+
+ if(this_spr->init_target_l) Free_Scalar_Dbl(this_spr->init_target_l);
+ if(this_spr->init_target_v) Free_Scalar_Dbl(this_spr->init_target_v);
+
+ Free(this_spr);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Spr_List(arbre *tree)
+void Free_Spr_List_One_Edge(t_tree *mixt_tree)
{
int i;
+ t_tree *tree;
- For(i,tree->size_spr_list+1)
+ tree = mixt_tree;
+ do
{
- Free_One_Spr(tree->spr_list[i]);
+ for(i=0;isize_spr_list_one_edge+1;++i) Free_One_Spr(tree->spr_list_one_edge[i]);
+ Free(tree->spr_list_one_edge);
+ tree = tree->next;
}
- Free(tree->spr_list);
+ while(tree);
}
-/*********************************************************/
-
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Triplet(ttriplet *t)
+void Free_Spr_List_All_Edge(t_tree *mixt_tree)
{
- int i,j,k;
-
- Free(t->F_bc);
- Free(t->F_cd);
- Free(t->F_bd);
- Free(t->pi_bc);
- Free(t->pi_cd);
- Free(t->pi_bd);
-
- For(k,t->mod->n_catg)
- {
- For(i,t->size)
- {
- For(j,t->size) Free(t->core[k][i][j]);
- Free(t->core[k][i]);
- }
- Free(t->core[k]);
- }
- Free(t->core);
-
- For(i,t->size)
- {
- For(j,t->size) Free(t->p_one_site[i][j]);
- Free(t->p_one_site[i]);
- }
- Free(t->p_one_site);
+ int i;
+ t_tree *tree;
- For(i,t->size)
+ tree = mixt_tree;
+ do
{
- For(j,t->size) Free(t->sum_p_one_site[i][j]);
- Free(t->sum_p_one_site[i]);
+ for(i=0;isize_spr_list_all_edge+1;++i) Free_One_Spr(tree->spr_list_all_edge[i]);
+ Free(tree->spr_list_all_edge);
+ tree = tree->next;
}
- Free(t->sum_p_one_site);
+ while(tree);
- Free_Eigen(t->eigen_struct);
-
- Free(t);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Actual_CSeq(allseq *data)
+void Free_Actual_CSeq(calign *data)
{
int i;
- For(i,data->n_otu)
+ for(i=0;in_otu;i++)
{
Free(data->c_seq[i]->state);
+ Free(data->c_seq[i]->d_state);
data->c_seq[i]->state = NULL;
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Free_Prefix_Tree(pnode *n, int size)
{
int i;
-
- For(i,size)
+
+ for(i=0;inext[i])
- {
- Free_Prefix_Tree(n->next[i],size);
- }
+ {
+ Free_Prefix_Tree(n->next[i],size);
+ }
}
Free_Pnode(n);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Free_Pnode(pnode *n)
{
@@ -589,21 +1119,400 @@ void Free_Pnode(pnode *n)
Free(n);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Optimiz(t_opt *s_opt)
+{
+ Free(s_opt);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
-void Free_Rates(int n_otu, trate *r)
+void Free_Nexus(option *io)
+{
+ int i,j;
+
+ for(i=0;inex_com_list[i]->nparm) Free_Nexus_Parm(io->nex_com_list[i]->parm[j]);
+ Free(io->nex_com_list[i]->parm);
+ Free(io->nex_com_list[i]->name);
+ Free(io->nex_com_list[i]);
+ }
+ Free(io->nex_com_list);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+void Free_Nexus_Com(nexcom **com)
{
int i;
- Free(r->br_r);
- Free(r->lexp);
+ for(i=0;iparm);
+ Free(com[i]->name);
+ Free(com[i]);
+ }
+ Free(com);
+}
- For(i,n_otu) Free(r->mc_mr[i]);
- Free(r->mc_mr);
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
- Free(r);
+void Free_Nexus_Parm(nexparm *parm)
+{
+ Free(parm->value);
+ Free(parm->name);
+ Free(parm);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void XML_Free_XML_Tree(xml_node *node)
+{
+ if(!node) return;
+ if(node->child) XML_Free_XML_Tree(node->child);
+ if(node->next) XML_Free_XML_Tree(node->next);
+ XML_Free_XML_Node(node);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void XML_Free_XML_Node(xml_node *node)
+{
+ Free(node->id);
+ Free(node->name);
+ Free(node->value);
+ XML_Free_XML_Ds(node->ds);
+ XML_Free_XML_Attr(node->attr);
+ Free(node);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void XML_Free_XML_Attr(xml_attr *attr)
+{
+ if(attr)
+ {
+ Free(attr->name);
+ Free(attr->value);
+ if(attr->next) XML_Free_XML_Attr(attr->next);
+ Free(attr);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void XML_Free_XML_Ds(t_ds *ds)
+{
+ if(ds->next) XML_Free_XML_Ds(ds->next);
+ Free(ds);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void MCMC_Free_MCMC(t_mcmc *mcmc)
+{
+ int i;
+
+ Free(mcmc->move_type);
+ Free(mcmc->adjust_tuning);
+ Free(mcmc->out_filename);
+ Free(mcmc->move_weight);
+ Free(mcmc->acc_move);
+ Free(mcmc->run_move);
+ Free(mcmc->prev_acc_move);
+ Free(mcmc->prev_run_move);
+ Free(mcmc->acc_rate);
+ Free(mcmc->tune_move);
+ for(i=0;in_moves;i++) Free(mcmc->move_name[i]);
+ Free(mcmc->move_name);
+ Free(mcmc->ess_run);
+ Free(mcmc->start_ess);
+ Free(mcmc->ess);
+ Free(mcmc->sampled_val);
+ Free(mcmc->mode);
+ Free(mcmc);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void RATES_Free_Rates(t_rate *rates)
+{
+ if(rates->is_allocated == YES)
+ {
+ int i;
+ Free(rates->nd_r);
+ Free(rates->br_r);
+ Free(rates->buff_nd_r);
+ Free(rates->buff_br_r);
+ Free(rates->true_r);
+ Free(rates->buff_t);
+ Free(rates->nd_t);
+ Free(rates->true_t);
+ Free(rates->t_prior);
+ Free(rates->t_mean);
+ Free(rates->t_prior_min);
+ Free(rates->t_prior_max);
+ Free(rates->t_floor);
+ Free(rates->t_has_prior);
+ Free(rates->t_rank);
+ Free(rates->dens);
+ Free(rates->triplet);
+ Free(rates->n_jps);
+ Free(rates->t_jps);
+ Free(rates->cond_var);
+ Free(rates->invcov);
+ Free(rates->ml_l);
+ Free(rates->cur_l);
+ Free(rates->u_ml_l);
+ Free(rates->u_cur_l);
+ Free(rates->cov_r);
+ Free(rates->lca);
+ Free(rates->trip_cond_cov);
+ Free(rates->trip_reg_coeff);
+ Free(rates->_2n_vect1);
+ Free(rates->_2n_vect2);
+ Free(rates->_2n_vect3);
+ Free(rates->_2n_vect4);
+ Free(rates->_2n_vect5);
+ Free(rates->_2n2n_vect1);
+ Free(rates->_2n2n_vect2);
+ Free(rates->cov_l);
+ Free(rates->mean_l);
+ Free(rates->mean_r);
+ Free(rates->mean_t);
+ Free(rates->grad_l);
+ Free(rates->reg_coeff);
+ Free(rates->br_do_updt);
+ Free(rates->cur_gamma_prior_mean);
+ Free(rates->cur_gamma_prior_var);
+ Free(rates->n_tips_below);
+ Free(rates->time_slice_lims);
+ Free(rates->n_time_slice_spans);
+ Free(rates->curr_slice);
+ Free(rates->has_survived);
+ Free(rates->survival_rank);
+ Free(rates->survival_dur);
+ Free(rates->calib_prob);
+ Free(rates->t_prior_min_ori);
+ Free(rates->t_prior_max_ori);
+ Free(rates->times_partial_proba);
+ Free(rates->numb_calib_chosen);
+ for(i=0;in_cal;i++) Free_Calib(rates->a_cal[i]);
+ Free(rates->a_cal);
+ Free(rates->model_name);
+ }
+ Free(rates);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Calib(t_cal *cal)
+{
+ if(!cal) return;
+ else
+ {
+ int i;
+ for(i=0;iclade_list_size;i++) Free(cal->clade_list[i]);
+ Free(cal->clade_list);
+ Free(cal->id);
+ Free(cal->alpha_proba_list);
+ Free(cal);
+ }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void Free_Geo(t_geo *t)
+{
+ int i;
+ Free(t->f_mat);
+ Free(t->r_mat);
+ Free(t->occup);
+ Free(t->idx_loc);
+ Free(t->sorted_nd);
+ Free(t->cov);
+ Free(t->idx_loc_beneath);
+ for(i=0;ildscape_sz;i++) Free_Geo_Coord(t->coord_loc[i]);
+ Free(t->coord_loc);
+ Free(t);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void Free_Geo_Coord(t_geo_coord *t)
+{
+ Free(t->cpy->lonlat);
+ Free(t->cpy->id);
+ Free(t->cpy);
+
+ Free(t->lonlat);
+ Free(t->id);
+ Free(t);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void Free_Disk(t_dsk *t)
+{
+ Free_Geo_Coord(t->centr);
+ Free(t->ldsk_a);
+ Free(t->id);
+ Free(t);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void Free_Ldisk(t_ldsk *t)
+{
+ if(t == NULL) return;
+ else
+ {
+ Free(t->next);
+ Free_Geo_Coord(t->coord);
+ if(t->cpy_coord) Free_Geo_Coord(t->cpy_coord);
+ Free(t);
+ }
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Poly(t_poly *p)
+{
+ int i;
+ for(i=0;in_poly_vert;i++) Free_Geo_Coord(p->poly_vert[i]);
+ Free(p->poly_vert);
+ Free(p);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_Mmod(t_phyrex_mod *mmod)
+{
+ if(mmod == NULL) return;
+ Free_Geo_Coord(mmod->lim_up);
+ Free_Geo_Coord(mmod->lim_do);
+ Free(mmod);
}
-/*********************************************************/
-/*********************************************************/
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void JSON_Free_Array(json_a *a)
+{
+ if(a->object) JSON_Free_Object(a->object);
+ Free(a);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void JSON_Free_Object(json_o *o)
+{
+ if(o->kv) JSON_Free_KeyVal(o->kv);
+ if(o->next) JSON_Free_Object(o->next);
+ Free(o);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void JSON_Free_KeyVal(json_kv *kv)
+{
+ if(kv->key) Free(kv->key);
+ if(kv->value) Free(kv->value);
+ if(kv->object) JSON_Free_Object(kv->object);
+ if(kv->array) JSON_Free_Array(kv->array);
+ if(kv->next) JSON_Free_KeyVal(kv->next);
+ Free(kv);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Free_NNI(t_nni *t)
+{
+ if(t->init_l) Free_Scalar_Dbl(t->init_l);
+ if(t->init_v) Free_Scalar_Dbl(t->init_v);
+
+ if(t->best_l) Free_Scalar_Dbl(t->best_l);
+ if(t->best_v) Free_Scalar_Dbl(t->best_v);
+
+ if(t->l0) Free_Scalar_Dbl(t->l0);
+ if(t->v0) Free_Scalar_Dbl(t->v0);
+
+ if(t->l1) Free_Scalar_Dbl(t->l1);
+ if(t->v1) Free_Scalar_Dbl(t->v1);
+
+ if(t->l2) Free_Scalar_Dbl(t->l2);
+ if(t->v2) Free_Scalar_Dbl(t->v2);
+
+ Free(t);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+/* Matrices used in transfer bootstrap computation (tbe.c) */
+void Free_TBE_Matrices(int n_otu, short unsigned*** i_matrix, short unsigned*** c_matrix,
+ short unsigned*** hamming, short unsigned** min_dist,
+ short unsigned** min_dist_edge, int** cluster_sizes){
+ int i;
+ int nb_edges = 2*n_otu-3;
+ for (i=0; ikey);
+ Free(lab->val);
+ if(lab->next != NULL) Free_Label(lab->next);
+ Free(lab);
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
diff --git a/phyml/free.h b/phyml/free.h
index c36a523..a0096e1 100644
--- a/phyml/free.h
+++ b/phyml/free.h
@@ -10,41 +10,90 @@ the GNU public licence. See http://www.opensource.org for details.
*/
+#include
+
#ifndef FREE_H
#define FREE_H
-void Free_All_Nodes_Light(arbre *tree);
-void Free_All_Edges_Light(arbre *tree);
+#include "utilities.h"
+
+void Free_All_Nodes_Light(t_tree *tree);
+void Free_All_Edges_Light(t_tree *tree);
void Free_Mat(matrix *mat);
-void Free_Partial_Lk(phydbl ****p_lk, int len, int n_catg);
-void Free_Tree(arbre *tree);
-void Free_Edge(edge *b);
-void Free_Node(node *n);
-void Free_Cseq(allseq *alldata);
-void Free_Seq(seq **d, int n_otu);
-void Free_All(seq **d, allseq *alldata, arbre *tree);
-void Free_SubTree(edge *b_fcus, node *a, node *d, arbre *tree);
-void Free_Tree_Ins_Tar(arbre *tree);
-void Free_Tree_Lk(arbre *tree);
-void Free_NNI(arbre *tree);
-void Free_Edge_P_Lk_Struct(edge *b, arbre *tree);
-void Free_Node_Lk(node *n);
-void Free_Edge_Lk(arbre *tree, edge *b);
-void Free_Model(model *mod);
+void Free_Partial_Lk(phydbl *p_lk,int len,int n_catg);
+void Free_Tree(t_tree *tree);
+void Free_Bip(t_tree *tree);
+void Free_Edge(t_edge *b);
+void Free_Node(t_node *n);
+void Free_Calign(calign *data);
+void Free_Seq(align **d,int n_otu);
+void Free_All(align **d,calign *cdata,t_tree *tree);
+void Free_SubTree(t_edge *b_fcus,t_node *a,t_node *d,t_tree *tree);
+void Free_Tree_Ins_Tar(t_tree *tree);
+void Free_Tree_Pars(t_tree *tree);
+void Free_Edge_Pars(t_edge *b);
+void Free_Edge_Pars_Left(t_edge *b);
+void Free_Edge_Pars_Rght(t_edge *b);
+void Free_Tree_Lk(t_tree *tree);
+void Free_Node_Lk(t_node *n);
+void Free_Edge_Lk(t_edge *b);
+void Free_Model_Complete(t_mod *mod);
+void Free_Model_Basic(t_mod *mod);
+void Free_Custom_Model(t_mod *mod);
+void Free_Efrq(t_efrq *e_frq);
+void Free_Rmat(t_rmat *r_mat);
+void Free_Model(t_mod *mod);
void Free(void *p);
-void Free_Input(option *input);
-void Free_Reachable(arbre *tree);
-void Free_St(superarbre *st);
+void Free_Input(option *io);
+void Free_Tree_List(t_treelist *list);
+void Free_St(supert_tree *st);
void Free_Eigen(eigen *eigen_struct);
-void Free_Triplet(ttriplet *t);
-void Free_Tree_Pars(arbre *tree);
-void Free_Edge_Pars(edge *b, arbre *tree);
-void Free_One_Spr(spr *this_spr);
-void Free_Spr_List(arbre *tree);
-void Free_Actual_CSeq(allseq *data);
-void Free_Prefix_Tree(pnode *n, int size);
+void Free_One_Spr(t_spr *this_spr);
+void Free_Spr_List_One_Edge(t_tree *tree);
+void Free_Spr_List_All_Edge(t_tree *mixt_tree);
+void Free_Actual_CSeq(calign *data);
+void Free_Prefix_Tree(pnode *n,int size);
void Free_Pnode(pnode *n);
-void Free_Edge_Labels(edge *b);
-void Free_Rates(int n_otu, trate *r);
-
+void Free_Optimiz(t_opt *s_opt);
+void Free_Nexus(option *io);
+void Free_Nexus_Com(nexcom **com);
+void Free_Nexus_Parm(nexparm *parm);
+void Free_RAS(t_ras *ras);
+void XML_Free_XML_Tree(xml_node *node);
+void XML_Free_XML_Node(xml_node *node);
+void XML_Free_XML_Attr(xml_attr *attr);
+void XML_Free_XML_Ds(t_ds *ds);
+void Free_String(t_string *ts);
+void Free_Vect_Dbl(vect_dbl *v);
+void Free_Vect_Int(vect_int *v);
+void Free_Scalar_Dbl(scalar_dbl *v);
+void Free_Scalar_Int(scalar_int *v);
+void Free_Edge_Core(t_edge *b);
+void RATES_Free_Rates(t_rate *rates);
+void Free_Calib(t_cal *cal);
+void Free_Edge_Lk_Left(t_edge *b);
+void Free_Edge_Lk_Rght(t_edge *b);
+void Free_Geo(t_geo *t);
+void Free_Geo_Coord(t_geo_coord *t);
+void Free_Disk(t_dsk *t);
+void Free_Ldisk(t_ldsk *t);
+void Free_Poly(t_poly *p);
+void Free_Mmod(t_phyrex_mod *mmod);
+void Free_Efrq_Weights(t_mod *mixt_mod);
+void Free_Rmat_Weights(t_mod *mixt_mod);
+void JSON_Free_KeyVal(json_kv *kv);
+void JSON_Free_Object(json_o *o);
+void JSON_Free_Array(json_a *a);
+void Free_Edge_Loc_Rght(t_edge *b);
+void Free_Edge_Loc_Left(t_edge *b);
+void Free_Edge_Loc(t_edge *b);
+void Free_NNI(t_nni *t);
+void Free_Linked_List(t_ll *t);
+void Free_TBE_Matrices(int n_otu, short unsigned*** i_matrix, short unsigned*** c_matrix,
+ short unsigned*** hamming, short unsigned** min_dist,
+ short unsigned** min_dist_edge, int** cluster_sizes);
+void Free_Extra_Edge_Lk(t_tree *tree);
+void Free_Edge_Length(t_edge *b);
+void Free_Clade(t_clad *this);
+void Free_Label(t_label *lab);
#endif
diff --git a/phyml/geo.c b/phyml/geo.c
new file mode 100644
index 0000000..f8fcbf2
--- /dev/null
+++ b/phyml/geo.c
@@ -0,0 +1,1822 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+
+#include "geo.h"
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int GEO_Main(int argc, char **argv)
+{
+ /* GEO_Simulate_Estimate(argc,argv); */
+ GEO_Estimate(argc,argv);
+ return(1);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int GEO_Estimate(int argc, char **argv)
+{
+ t_geo *t;
+ int seed;
+ FILE *fp;
+ t_tree *tree;
+ phydbl *ldscp;
+ int *loc_hash;
+ int i,j;
+ phydbl *probs;
+ phydbl sum;
+
+ // geo ./ban
+
+
+ seed = getpid();
+ /* seed = 28224; */
+ /* seed = 21249; */
+ /* seed = 21596; */
+
+ printf("\n. Seed = %d",seed);
+ srand(seed);
+
+ t = GEO_Make_Geo_Basic();
+ GEO_Init_Geo_Struct(t);
+
+ fp = Openfile(argv[1],0); /* Open tree file */
+
+ tree = Read_Tree_File_Phylip(fp); /* Read it */
+
+ Update_Ancestors(tree->n_root,tree->n_root->v[2],tree);
+ Update_Ancestors(tree->n_root,tree->n_root->v[1],tree);
+ tree->rates = RATES_Make_Rate_Struct(tree->n_otu);
+ RATES_Init_Rate_Struct(tree->rates,NULL,tree->n_otu);
+ Branch_To_Time(tree);
+
+ tree->geo = t;
+
+ GEO_Read_In_Landscape(argv[2],t,&ldscp,&loc_hash,tree);
+
+ GEO_Make_Geo_Complete(t->ldscape_sz,t->n_dim,tree->n_otu,t);
+
+
+ j = 0;
+ for(i=0;ildscape_sz;i++)
+ {
+ t->coord_loc[i]->lonlat[0] = ldscp[j];
+ t->coord_loc[i]->lonlat[1] = ldscp[j+1];
+ PhyML_Printf("\n. Location %d: %13f %13f",i+1,t->coord_loc[i]->lonlat[0],t->coord_loc[i]->lonlat[1]);
+ j+=2;
+ }
+
+ for(i=0;in_otu;i++) t->idx_loc[i] = loc_hash[i];
+
+ t->cov[0*t->n_dim+0] = t->sigma;
+ t->cov[1*t->n_dim+1] = t->sigma;
+ t->cov[0*t->n_dim+1] = 0.0;
+ t->cov[1*t->n_dim+0] = 0.0;
+
+ GEO_Get_Sigma_Max(t);
+
+ t->max_sigma = t->sigma_thresh * 2.;
+
+ PhyML_Printf("\n. Sigma max: %f",t->sigma_thresh);
+
+ GEO_Get_Locations_Beneath(t,tree);
+
+ probs = (phydbl *)mCalloc(tree->geo->ldscape_sz,sizeof(phydbl));
+
+ sum = 0.0;
+ for(i=0;igeo->ldscape_sz;i++) sum += tree->geo->idx_loc_beneath[tree->n_root->num * tree->geo->ldscape_sz + i];
+ for(i=0;igeo->ldscape_sz;i++) probs[i] = tree->geo->idx_loc_beneath[tree->n_root->num * tree->geo->ldscape_sz + i]/sum;
+ tree->geo->idx_loc[tree->n_root->num] = Sample_i_With_Proba_pi(probs,tree->geo->ldscape_sz);
+ Free(probs);
+
+ GEO_Randomize_Locations(tree->n_root,t,tree);
+
+
+ GEO_Update_Occup(t,tree);
+ GEO_Lk(t,tree);
+
+ PhyML_Printf("\n. Init loglk: %f",tree->geo->c_lnL);
+
+ /* DR_Draw_Tree("essai.ps",tree); */
+
+ GEO_MCMC(tree);
+
+ fclose(fp);
+ Free(ldscp);
+ Free(loc_hash);
+
+ return(1);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int GEO_Simulate_Estimate(int argc, char **argv)
+{
+ t_geo *t;
+ int n_tax;
+ t_tree *tree,*ori_tree;
+ int seed;
+ phydbl *res;
+ FILE *fp;
+ int pid;
+ char *s;
+ int rand_loc;
+ phydbl *probs,sum;
+ int i;
+ phydbl mantel_p_val;
+ phydbl rf;
+
+ s = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+
+ strcpy(s,"geo.out");
+ pid = getpid();
+ sprintf(s+strlen(s),".%d",pid);
+
+ fp = fopen(s,"w");
+
+ seed = getpid();
+ /* seed = 15520; */
+ /* seed = 5023; */
+ printf("\n. Seed = %d",seed);
+ srand(seed);
+
+ t = GEO_Make_Geo_Basic();
+ GEO_Init_Geo_Struct(t);
+
+ /* t->tau = 3.0; */
+ /* t->lbda = 0.02; */
+ /* t->sigma = 10.; */
+
+
+ t->ldscape_sz = (int)atoi(argv[1]);
+ t->n_dim = 2;
+ n_tax = (int)atoi(argv[2]);
+
+ GEO_Make_Geo_Complete(t->ldscape_sz,t->n_dim,n_tax,t);
+
+ t->cov[0*t->n_dim+0] = t->sigma;
+ t->cov[1*t->n_dim+1] = t->sigma;
+ t->cov[0*t->n_dim+1] = 0.0;
+ t->cov[1*t->n_dim+0] = 0.0;
+
+ GEO_Simulate_Coordinates(t->ldscape_sz,t);
+
+ GEO_Get_Sigma_Max(t);
+
+ t->max_sigma = t->sigma_thresh * 2.;
+
+ PhyML_Printf("\n. sigma max: %f threshold: %f",t->max_sigma,t->sigma_thresh);
+
+ /* t->tau = Uni()*(t->max_tau/100.-t->min_tau*10.) + t->min_tau*10.; */
+ /* t->lbda = exp(Uni()*(log(t->max_lbda/100.)-log(t->min_lbda*10.)) + log(t->min_lbda*10.)); */
+ /* t->sigma = Uni()*(t->max_sigma-t->min_sigma) + t->min_sigma; */
+
+ t->lbda = 1.;
+ t->sigma = 0.3;
+ t->tau = 1.;
+
+ PhyML_Fprintf(fp,"\n# SigmaTrue\t SigmaThresh\t LbdaTrue\t TauTrue\txTrue\t yTrue\t xRand\t yRand\t RF\t Sigma5\t Sigma50\t Sigma95\t ProbSigmaInfThresh\t Lbda5\t Lbda50\t Lbda95\t ProbLbdaInf1\t Tau5\t Tau50\t Tau95\t X5\t X50\t X95\t Y5\t Y50\t Y95\t RandX5\t RandX50\t RandX95\t RandY5\t RandY50\t RandY95\t Mantel\t");
+ PhyML_Fprintf(fp,"\n");
+
+ tree = GEO_Simulate(t,n_tax);
+
+ ori_tree = Make_Tree_From_Scratch(tree->n_otu,NULL);
+ Copy_Tree(tree,ori_tree);
+
+ Random_SPRs_On_Rooted_Tree(tree);
+
+ Free_Bip(ori_tree);
+ Alloc_Bip(ori_tree);
+ Get_Bip(ori_tree->a_nodes[0],ori_tree->a_nodes[0]->v[0],ori_tree);
+
+ Free_Bip(tree);
+ Alloc_Bip(tree);
+ Get_Bip(tree->a_nodes[0],tree->a_nodes[0]->v[0],tree);
+ Match_Tip_Numbers(tree,ori_tree);
+
+ rf = (phydbl)Compare_Bip(ori_tree,tree,NO)/(tree->n_otu-3);
+ PhyML_Printf("\n. rf: %f",rf);
+
+ phydbl scale;
+ scale = exp(Rnorm(0,0.2));
+ PhyML_Printf("\n. Scale: %f",scale);
+ For(i,2*tree->n_otu-1) tree->rates->nd_t[i] *= scale;
+
+
+ phydbl *tree_dist,*geo_dist;
+ int j;
+
+ Time_To_Branch(tree);
+ tree_dist = Dist_Btw_Tips(tree);
+
+ geo_dist = (phydbl *)mCalloc(tree->n_otu*tree->n_otu,sizeof(phydbl));
+
+ for(i=0;in_otu;i++)
+ {
+ for(j=0;jn_otu;j++)
+ {
+ /* geo_dist[i*tree->n_otu+j] = */
+ /* FABS(t->ldscape[t->idx_loc[i]*t->n_dim+0] - */
+ /* t->ldscape[t->idx_loc[j]*t->n_dim+0])+ */
+ /* FABS(t->ldscape[t->idx_loc[i]*t->n_dim+1] - */
+ /* t->ldscape[t->idx_loc[j]*t->n_dim+1]); */
+ geo_dist[i*tree->n_otu+j] =
+ FABS(t->coord_loc[t->idx_loc[i]]->lonlat[0] -
+ t->coord_loc[t->idx_loc[j]]->lonlat[0])+
+ FABS(t->coord_loc[t->idx_loc[i]]->lonlat[1] -
+ t->coord_loc[t->idx_loc[j]]->lonlat[1]);
+
+ }
+ }
+
+ printf("\n. tau: %f lbda: %f sigma: %f",t->tau,t->lbda,t->sigma);
+ mantel_p_val = Mantel(tree_dist,geo_dist,tree->n_otu,tree->n_otu);
+ printf("\n. Mantel test p-value: %f",mantel_p_val);
+
+ Free(tree_dist);
+ Free(geo_dist);
+
+ rand_loc = Rand_Int(0,t->ldscape_sz-1);
+
+ PhyML_Printf("\n. sigma: %f\t lbda: %f\t tau:%f\t x:%f\t y:%f rand.x:%f\t rand.y:%f\t",
+ t->sigma,
+ t->lbda,
+ t->tau,
+ /* t->ldscape[t->idx_loc[tree->n_root->num]*t->n_dim+0], */
+ /* t->ldscape[t->idx_loc[tree->n_root->num]*t->n_dim+1], */
+ /* t->ldscape[rand_loc*t->n_dim+0], */
+ /* t->ldscape[rand_loc*t->n_dim+1]); */
+ t->coord_loc[t->idx_loc[tree->n_root->num]]->lonlat[0],
+ t->coord_loc[t->idx_loc[tree->n_root->num]]->lonlat[1],
+ t->coord_loc[rand_loc]->lonlat[0],
+ t->coord_loc[rand_loc]->lonlat[1]);
+
+ PhyML_Fprintf(fp,"%f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t",
+ t->sigma,
+ t->sigma_thresh,
+ t->lbda,
+ t->tau,
+ t->coord_loc[t->idx_loc[tree->n_root->num]]->lonlat[0],
+ t->coord_loc[t->idx_loc[tree->n_root->num]]->lonlat[1],
+ t->coord_loc[rand_loc]->lonlat[0],
+ t->coord_loc[rand_loc]->lonlat[1],
+ rf);
+
+ GEO_Get_Locations_Beneath(t,tree);
+
+ probs = (phydbl *)mCalloc(tree->geo->ldscape_sz,sizeof(phydbl));
+
+ sum = 0.0;
+ for(i=0;igeo->ldscape_sz;i++) sum += tree->geo->idx_loc_beneath[tree->n_root->num * tree->geo->ldscape_sz + i];
+ for(i=0;igeo->ldscape_sz;i++) probs[i] = tree->geo->idx_loc_beneath[tree->n_root->num * tree->geo->ldscape_sz + i]/sum;
+ tree->geo->idx_loc[tree->n_root->num] = Sample_i_With_Proba_pi(probs,tree->geo->ldscape_sz);
+ Free(probs);
+ GEO_Randomize_Locations(tree->n_root,tree->geo,tree);
+
+ GEO_Update_Occup(t,tree);
+ GEO_Lk(t,tree);
+ PhyML_Printf("\n. Init loglk: %f",tree->geo->c_lnL);
+
+
+ res = GEO_MCMC(tree);
+
+ PhyML_Fprintf(fp,"%f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f \n",
+
+ /* Sigma5 */ Quantile(res+0*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.025),
+ /* Sigma50*/ Quantile(res+0*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.50),
+ /* Sigma95*/ Quantile(res+0*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.975),
+
+ /* ProbInfThesh */ Prob(res+0*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval,t->sigma_thresh),
+
+ /* Lbda5 */ Quantile(res+1*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.025),
+ /* Lbda50 */ Quantile(res+1*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.50),
+ /* Lbda95 */ Quantile(res+1*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.975),
+
+ /* ProbInf1 */ Prob(res+1*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval,1.0),
+
+ /* Tau5 */ Quantile(res+2*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.025),
+ /* Tau50 */ Quantile(res+2*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.50),
+ /* Tau 95 */ Quantile(res+2*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.975),
+
+ /* X5 */ Quantile(res+4*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.025),
+ /* X50 */ Quantile(res+4*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.50),
+ /* X95 */ Quantile(res+4*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.975),
+
+ /* Y5 */ Quantile(res+5*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.025),
+ /* Y50 */ Quantile(res+5*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.50),
+ /* Y95 */ Quantile(res+5*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.975),
+
+ /* RandX5 */ Quantile(res+6*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.025),
+ /* RandX50*/ Quantile(res+6*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.50),
+ /* RandX95*/ Quantile(res+6*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.975),
+
+ /* RandY5 */ Quantile(res+7*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.025),
+ /* RandY50*/ Quantile(res+7*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.50),
+ /* RandY95*/ Quantile(res+7*tree->mcmc->chain_len / tree->mcmc->sample_interval,tree->mcmc->run / tree->mcmc->sample_interval+1,0.975),
+
+ mantel_p_val
+ );
+ fflush(NULL);
+
+ Free(s);
+ Free(res);
+
+ fclose(fp);
+
+ return 1;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl *GEO_MCMC(t_tree *tree)
+{
+ phydbl *res;
+ int n_vars;
+ int rand_loc;
+ t_geo *t;
+
+ t = tree->geo;
+
+ tree->mcmc = MCMC_Make_MCMC_Struct();
+ MCMC_Complete_MCMC(tree->mcmc,tree);
+
+ tree->mcmc->io = NULL;
+ tree->mcmc->is = NO;
+ tree->mcmc->run = 0;
+ tree->mcmc->sample_interval = 1E+3;
+ tree->mcmc->chain_len = 1E+6;
+ tree->mcmc->chain_len_burnin = 1E+5;
+ tree->mcmc->randomize = YES;
+ tree->mcmc->norm_freq = 1E+3;
+ tree->mcmc->max_tune = 1.E+20;
+ tree->mcmc->min_tune = 1.E-10;
+ tree->mcmc->print_every = 2;
+ tree->mcmc->is_burnin = NO;
+ tree->mcmc->nd_t_digits = 1;
+
+ t->tau = 1.0;
+ t->lbda = 1.0;
+ t->sigma = 1.0;
+ t->dum = 1.0;
+
+ tree->mcmc->chain_len = 1.E+8;
+ tree->mcmc->sample_interval = 50;
+
+ MCMC_Complete_MCMC(tree->mcmc,tree);
+
+ GEO_Update_Occup(t,tree);
+ GEO_Lk(t,tree);
+
+ tree->mcmc->start_ess[tree->mcmc->num_move_geo_sigma] = YES;
+ tree->mcmc->start_ess[tree->mcmc->num_move_geo_lambda] = YES;
+ tree->mcmc->start_ess[tree->mcmc->num_move_geo_tau] = YES;
+ tree->mcmc->start_ess[tree->mcmc->num_move_geo_dum] = YES;
+
+ n_vars = 10;
+ res = (phydbl *)mCalloc(tree->mcmc->chain_len / tree->mcmc->sample_interval * n_vars,sizeof(phydbl));
+
+ PhyML_Printf("\n. Run Sigma [ESS] Lambda [ESS] Tau [ESS] Dummy [ESS] LogLk");
+
+ tree->mcmc->run = 0;
+ do
+ {
+ MCMC_GEO_Lbda(tree);
+ MCMC_GEO_Tau(tree);
+ /* MCMC_Geo_Dum(tree); */
+ MCMC_GEO_Loc(tree);
+
+ t->update_fmat = YES;
+ MCMC_GEO_Sigma(tree);
+ t->update_fmat = NO;
+
+
+ /* t->update_fmat = YES; */
+ /* MCMC_Geo_Updown_Lbda_Sigma(tree); */
+ /* t->update_fmat = NO; */
+
+
+ /* MCMC_Geo_Updown_Tau_Lbda(tree); */
+ /* MCMC_Geo_Updown_Tau_Lbda(tree); */
+ /* MCMC_Geo_Updown_Tau_Lbda(tree); */
+
+
+ /* printf("\n"); */
+ /* int i; */
+ /* For(i,2*tree->n_otu-1) */
+ /* { */
+ /* if(tree->a_nodes[i]->tax == NO) */
+ /* { */
+ /* printf("%2d ",tree->geo->idx_loc[i]); */
+ /* } */
+ /* } */
+
+
+ if(tree->mcmc->run%tree->mcmc->sample_interval == 0)
+ {
+ MCMC_Copy_To_New_Param_Val(tree->mcmc,tree);
+
+ MCMC_Update_Effective_Sample_Size(tree->mcmc->num_move_geo_lambda,tree->mcmc,tree);
+ MCMC_Update_Effective_Sample_Size(tree->mcmc->num_move_geo_sigma,tree->mcmc,tree);
+ MCMC_Update_Effective_Sample_Size(tree->mcmc->num_move_geo_tau,tree->mcmc,tree);
+
+ /* printf("\n. lbda:%f,%f tau:%f,%f sigma:%f,%f", */
+ /* tree->mcmc->acc_rate[tree->mcmc->num_move_geo_lambda], */
+ /* tree->mcmc->tune_move[tree->mcmc->num_move_geo_lambda], */
+ /* tree->mcmc->acc_rate[tree->mcmc->num_move_geo_tau], */
+ /* tree->mcmc->tune_move[tree->mcmc->num_move_geo_tau], */
+ /* tree->mcmc->acc_rate[tree->mcmc->num_move_geo_sigma], */
+ /* tree->mcmc->tune_move[tree->mcmc->num_move_geo_sigma]); */
+
+ PhyML_Printf("\n. %6d %12f %4.0f %12f %4.0f %12f %4.0f %12f %4.0f %12f",
+ tree->mcmc->run,
+
+ t->sigma,
+ tree->mcmc->ess[tree->mcmc->num_move_geo_sigma],
+
+ t->lbda,
+ tree->mcmc->ess[tree->mcmc->num_move_geo_lambda],
+
+ t->tau,
+ tree->mcmc->ess[tree->mcmc->num_move_geo_tau],
+
+ t->dum,
+ tree->mcmc->ess[tree->mcmc->num_move_geo_dum],
+
+ t->c_lnL);
+
+
+ /* PhyML_Printf("\n%12f %12f %12f %12f", */
+ /* t->sigma, */
+ /* t->lbda, */
+ /* t->tau, */
+ /* t->dum); */
+
+
+ rand_loc = Rand_Int(0,t->ldscape_sz-1);
+
+ res[0 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->sigma;
+ res[1 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->lbda;
+ res[2 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->tau;
+ res[3 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->c_lnL;
+
+ /* res[4 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->ldscape[t->idx_loc[tree->n_root->num]*t->n_dim+0]; */
+ /* res[5 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->ldscape[t->idx_loc[tree->n_root->num]*t->n_dim+1]; */
+ res[4 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->coord_loc[t->idx_loc[tree->n_root->num]]->lonlat[0];
+ res[5 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->coord_loc[t->idx_loc[tree->n_root->num]]->lonlat[1];
+
+ /* res[6 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->ldscape[rand_loc*t->n_dim+0]; */
+ /* res[7 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->ldscape[rand_loc*t->n_dim+1]; */
+ res[6 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->coord_loc[rand_loc]->lonlat[0];
+ res[7 * tree->mcmc->chain_len / tree->mcmc->sample_interval + tree->mcmc->run / tree->mcmc->sample_interval] = t->coord_loc[rand_loc]->lonlat[1];
+ }
+
+ tree->mcmc->run++;
+
+ if(tree->mcmc->ess[tree->mcmc->num_move_geo_sigma] > 200.) tree->mcmc->adjust_tuning[tree->mcmc->num_move_geo_sigma] = NO;
+ if(tree->mcmc->ess[tree->mcmc->num_move_geo_tau] > 200.) tree->mcmc->adjust_tuning[tree->mcmc->num_move_geo_tau] = NO;
+ if(tree->mcmc->ess[tree->mcmc->num_move_geo_lambda]> 200.) tree->mcmc->adjust_tuning[tree->mcmc->num_move_geo_lambda] = NO;
+
+ MCMC_Get_Acc_Rates(tree->mcmc);
+
+ if(tree->mcmc->ess[tree->mcmc->num_move_geo_sigma] > 1000. &&
+ tree->mcmc->ess[tree->mcmc->num_move_geo_tau] > 1000. &&
+ tree->mcmc->ess[tree->mcmc->num_move_geo_lambda]> 1000.) break;
+ }
+ while(tree->mcmc->run < tree->mcmc->chain_len);
+
+ return(res);
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+// Update F matrix. Assume a diagonal covariance matrix.
+void GEO_Update_Fmat(t_geo *t)
+{
+ phydbl *loc1, *loc2;
+ int i,j,k;
+ int err;
+ phydbl lognloc;
+
+ for(i=0;in_dim;i++) t->cov[i*t->n_dim+i] = t->sigma; // Diagonal covariance matrix. Same variance in every direction
+
+ lognloc = log(t->ldscape_sz);
+
+ // Fill in F matrix;
+ for(i=0;ildscape_sz;i++)
+ {
+ loc1 = t->coord_loc[i]->lonlat;
+
+ for(j=i;jldscape_sz;j++)
+ {
+ loc2 = t->coord_loc[j]->lonlat;
+
+ t->f_mat[i*t->ldscape_sz+j] = .0;
+
+ // Calculate log(f(l_i,l_j)) - log(f(l_i,l_i) - log(m)
+ for(k=0;kn_dim;k++) t->f_mat[i*t->ldscape_sz+j] += Log_Dnorm(loc2[k],loc1[k],t->cov[k*t->n_dim+k],&err);
+ t->f_mat[i*t->ldscape_sz+j] -= lognloc;
+ for(k=0;kn_dim;k++) t->f_mat[i*t->ldscape_sz+j] -= Log_Dnorm(loc1[k],loc1[k],t->cov[k*t->n_dim+k],&err);
+
+ // Take the exponential
+ t->f_mat[i*t->ldscape_sz+j] = exp(t->f_mat[i*t->ldscape_sz+j]);
+
+ // Matrix is symmetric
+ t->f_mat[j*t->ldscape_sz+i] = t->f_mat[i*t->ldscape_sz+j];
+
+ /* printf("\n. f[%d,%d] = %f (1:[%f;%f] 2:[%f;%f]) sigma=%f",i,j,t->f_mat[i*t->ldscape_sz+j],loc1[0],loc1[1],loc2[0],loc2[1],SQRT(t->cov[0*t->n_dim+0])); */
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+// Sort node heights from oldest to youngest age.
+void GEO_Update_Sorted_Nd(t_geo *t, t_tree *tree)
+{
+ int i;
+ int swap;
+ t_node *buff;
+
+ buff = NULL;
+
+ For(i,2*tree->n_otu-1) t->sorted_nd[i] = tree->a_nodes[i];
+
+ // Bubble sort of the node heights
+ do
+ {
+ swap = NO;
+ For(i,2*tree->n_otu-2)
+ {
+ if(tree->rates->nd_t[t->sorted_nd[i+1]->num] < tree->rates->nd_t[t->sorted_nd[i]->num])
+ {
+ buff = t->sorted_nd[i];
+ t->sorted_nd[i] = t->sorted_nd[i+1];
+ t->sorted_nd[i+1] = buff;
+
+ swap = YES;
+ }
+ }
+ }
+ while(swap == YES);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+// Update the set of vectors of occupation along the tree
+void GEO_Update_Occup(t_geo *t, t_tree *tree)
+{
+ int i,j;
+ t_node *v1, *v2;
+
+ GEO_Update_Sorted_Nd(t,tree);
+
+ For(i,t->ldscape_sz*(2*tree->n_otu-1)) t->occup[i] = 0;
+
+ t->occup[tree->n_root->num*t->ldscape_sz + t->idx_loc[tree->n_root->num]] = 1;
+
+ for(i=1;i<2*tree->n_otu-1;i++)
+ {
+ for(j=0;jldscape_sz;j++)
+ {
+ t->occup[t->sorted_nd[i]->num*t->ldscape_sz + j] =
+ t->occup[t->sorted_nd[i-1]->num*t->ldscape_sz + j];
+ }
+
+
+ if(t->sorted_nd[i-1]->tax == NO)
+ {
+ v1 = v2 = NULL;
+ if(t->sorted_nd[i-1] == tree->n_root)
+ {
+ v1 = tree->n_root->v[1];
+ v2 = tree->n_root->v[2];
+ }
+ else
+ {
+ for(j=0;j<3;j++)
+ {
+ if(t->sorted_nd[i-1]->v[j] != t->sorted_nd[i-1]->anc &&
+ t->sorted_nd[i-1]->b[j] != tree->e_root)
+ {
+ if(!v1) v1 = t->sorted_nd[i-1]->v[j];
+ else v2 = t->sorted_nd[i-1]->v[j];
+ }
+ }
+ }
+
+
+ if(t->idx_loc[v1->num] != t->idx_loc[t->sorted_nd[i-1]->num])
+ {
+ t->occup[t->sorted_nd[i]->num * t->ldscape_sz + t->idx_loc[v1->num]]++;
+ }
+ else
+ {
+ t->occup[t->sorted_nd[i]->num * t->ldscape_sz + t->idx_loc[v2->num]]++;
+ }
+ }
+ }
+
+ /* printf("\n"); */
+ /* For(i,2*tree->n_otu-1) */
+ /* { */
+ /* printf("\n. Node %3d: ",t->sorted_nd[i]->num); */
+ /* for(j=0;jldscape_sz;j++) */
+ /* { */
+ /* /\* printf("%3d [%12f;%12f] ", *\/ */
+ /* /\* t->occup[t->sorted_nd[i]->num*t->ldscape_sz + j], *\/ */
+ /* /\* t->ldscape[j*t->n_dim+0],t->ldscape[j*t->n_dim+1]); *\/ */
+ /* /\* printf("%3d ", *\/ */
+ /* /\* t->occup[t->sorted_nd[i]->num*t->ldscape_sz + j]); *\/ */
+ /* } */
+ /* } */
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+// Calculate R mat at node n
+void GEO_Update_Rmat(t_node *n, t_geo *t, t_tree *tree)
+{
+ int i,j;
+ phydbl lbda_j;
+
+ for(i=0;ildscape_sz;i++)
+ {
+ for(j=0;jldscape_sz;j++)
+ {
+ lbda_j = ((t->occup[n->num*t->ldscape_sz + j]==0) ? (1.0) : (t->lbda));
+ t->r_mat[i*t->ldscape_sz+j] = t->f_mat[i*t->ldscape_sz+j] * lbda_j * t->tau * t->dum;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl GEO_Lk(t_geo *t, t_tree *tree)
+{
+ int i,j;
+ phydbl loglk;
+ phydbl R;
+ int dep,arr; // departure and arrival location indices;
+ t_node *curr_n,*prev_n,*v1,*v2;
+ phydbl sum;
+
+ GEO_Update_Occup(t,tree); // Same here.
+
+ if(t->update_fmat == YES) GEO_Update_Fmat(t);
+
+ prev_n = NULL;
+ curr_n = NULL;
+ loglk = .0;
+ for(i=1;in_otu-1;i++) // Consider all the time slices, from oldest to youngest.
+ // Start at first node below root
+ {
+ prev_n = t->sorted_nd[i-1]; // node just above
+ curr_n = t->sorted_nd[i]; // current node
+
+ GEO_Update_Rmat(curr_n,t,tree); // NOTE: don't need to do that every time. Add check later.
+
+ R = GEO_Total_Migration_Rate(curr_n,t); // Total migration rate calculated at node n
+
+ /* if(i < 2) */
+ /* { */
+ /* printf("\n. t0: %f t1: %f R: %f tau: %f sigma: %f lbda: %f x1: %f y1: %f x2: %f y2: %f log0: %d loc1: %d rij: %G fij: %G", */
+ /* tree->rates->nd_t[t->sorted_nd[i-1]->num], */
+ /* tree->rates->nd_t[t->sorted_nd[i]->num], */
+ /* R, */
+ /* t->tau, */
+ /* t->lbda, */
+ /* t->sigma, */
+ /* t->ldscape[t->idx_loc[tree->geo->sorted_nd[i-1]->num]*t->n_dim+0], */
+ /* t->ldscape[t->idx_loc[tree->geo->sorted_nd[i-1]->num]*t->n_dim+1], */
+ /* t->ldscape[t->idx_loc[tree->geo->sorted_nd[i]->num]*t->n_dim+0], */
+ /* t->ldscape[t->idx_loc[tree->geo->sorted_nd[i]->num]*t->n_dim+1], */
+ /* t->idx_loc[tree->geo->sorted_nd[i-1]->num], */
+ /* t->idx_loc[tree->geo->sorted_nd[i]->num], */
+ /* t->r_mat[t->idx_loc[tree->geo->sorted_nd[i-1]->num] * t->ldscape_sz + t->idx_loc[tree->geo->sorted_nd[i]->num]], */
+ /* t->f_mat[t->idx_loc[tree->geo->sorted_nd[i-1]->num] * t->ldscape_sz + t->idx_loc[tree->geo->sorted_nd[i]->num]] */
+ /* ); */
+
+ /* printf("\n >> "); */
+ /* int j; */
+ /* for(j=0;jldscape_sz;j++) */
+ /* if(t->occup[t->sorted_nd[i]->num * t->ldscape_sz + j] > 0) */
+ /* printf("%f %f -- ", */
+ /* t->ldscape[j*t->n_dim+0], */
+ /* t->ldscape[j*t->n_dim+1]); */
+ /* } */
+
+
+ /* printf("\n. %d %d (%d) %f %p %p \n",i,curr_n->num,curr_n->tax,tree->rates->nd_t[curr_n->num],curr_n->v[1],curr_n->v[2]); */
+
+ v1 = v2 = NULL;
+ for(j=0;j<3;j++)
+ if(curr_n->v[j] != curr_n->anc && curr_n->b[j] != tree->e_root)
+ {
+ if(!v1) v1 = curr_n->v[j];
+ else v2 = curr_n->v[j];
+ }
+
+ dep = t->idx_loc[curr_n->num]; // departure location
+ arr = // arrival location
+ (t->idx_loc[v1->num] == t->idx_loc[curr_n->num] ?
+ t->idx_loc[v2->num] :
+ t->idx_loc[v1->num]);
+
+ /* printf("\n%f\t%f", */
+ /* t->ldscape[arr*t->n_dim+0]-t->ldscape[dep*t->n_dim+0], */
+ /* t->ldscape[arr*t->n_dim+1]-t->ldscape[dep*t->n_dim+1]); */
+
+ loglk -= R * FABS(tree->rates->nd_t[curr_n->num] - tree->rates->nd_t[prev_n->num]);
+ loglk += log(t->r_mat[dep * t->ldscape_sz + arr]);
+
+ /* printf("\n <> %d %f %f %d %d v1:%d v2:%d anc:%d %d %d %d", */
+ /* curr_n->num, */
+ /* R * FABS(tree->rates->nd_t[curr_n->num] - tree->rates->nd_t[prev_n->num]), */
+ /* log(t->r_mat[dep * t->ldscape_sz + arr]), */
+ /* dep,arr,v1->num,v2->num,curr_n->anc->num,curr_n->v[0]->num,curr_n->v[1]->num,curr_n->v[2]->num); */
+
+ /* if(i<2) */
+ /* { */
+ /* printf("\n. R = %f r_mat = %f f_mat = %f dt = %f loglk = %f", */
+ /* R, */
+ /* t->r_mat[dep * t->ldscape_sz + arr], */
+ /* t->f_mat[dep * t->ldscape_sz + arr], */
+ /* FABS(t->sorted_nd[i] - t->sorted_nd[i-1]),loglk); */
+ /* Exit("\n"); */
+ /* } */
+
+ }
+
+
+ // Likelihood for the first 'slice' (i.e., the part just below the root down to
+ // the next node)
+ GEO_Update_Rmat(tree->n_root,t,tree);
+
+ loglk -= log(t->ldscape_sz);
+ dep = t->idx_loc[tree->n_root->num];
+ arr =
+ (t->idx_loc[tree->n_root->num] != t->idx_loc[tree->n_root->v[1]->num] ?
+ t->idx_loc[tree->n_root->v[1]->num] :
+ t->idx_loc[tree->n_root->v[2]->num]);
+
+ /* printf("\n %f %f",t->ldscape[dep],t->ldscape[arr]); */
+
+ loglk += log(t->r_mat[dep * t->ldscape_sz + arr]);
+
+ sum = .0;
+ for(i=0;ildscape_sz;i++) sum += t->r_mat[dep * t->ldscape_sz + i];
+
+ loglk -= log(sum);
+
+ tree->geo->c_lnL = loglk;
+
+ return loglk;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Init_Tloc_Tips(t_geo *t, t_tree *tree)
+{
+ int i;
+
+ // TO DO
+ for(i=0;in_otu;i++)
+ {
+ t->idx_loc[i] = i;
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+// Do not forget to call GEO_Update_Rmat (with node n) before calling this function
+phydbl GEO_Total_Migration_Rate(t_node *n, t_geo *t)
+{
+ phydbl R;
+ int i,j;
+
+ R = .0;
+
+ for(i=0;ildscape_sz;i++)
+ {
+ for(j=0;jldscape_sz;j++)
+ {
+ R +=
+ t->r_mat[i * t->ldscape_sz + j] *
+ t->occup[n->num * t->ldscape_sz + i];
+ }
+ }
+
+ return R;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+// Find the arrival location for the migration leaving from n
+int GEO_Get_Arrival_Location(t_node *n, t_geo *t, t_tree *tree)
+{
+ int i;
+ t_node *v1, *v2; // the two daughters of n
+
+ v1 = v2 = NULL;
+
+ for(i=0;i<3;i++)
+ {
+ if(n->v[i] && n->v[i] != n->anc)
+ {
+ if(!v1) v1 = n->v[i];
+ else v2 = n->v[i];
+ }
+ }
+
+ if(t->idx_loc[v1->num] == t->idx_loc[v2->num]) // Migrated to the same location as that of n
+ {
+ if(t->idx_loc[n->num] != t->idx_loc[v1->num])
+ {
+ PhyML_Printf("\n== Error detected in location labeling.");
+ PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+ else
+ return t->idx_loc[n->num];
+ }
+ else // Migrated to a different spot
+ {
+ if((t->idx_loc[v1->num] != t->idx_loc[n->num]) && (t->idx_loc[v2->num] != t->idx_loc[n->num]))
+ {
+ PhyML_Printf("\n== Error detected in location labeling.");
+ PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+ else
+ {
+ if(t->idx_loc[v1->num] == t->idx_loc[n->num]) return t->idx_loc[v2->num]; // v2 gets the new location, v1 inheritates from n
+ else return t->idx_loc[v1->num]; // v1 gets the new location, v2 inheritates from n
+ }
+ }
+ return -1;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+t_tree *GEO_Simulate(t_geo *t, int n_otu)
+{
+ t_tree *tree;
+ int n_branching_nodes;
+ t_node **branching_nodes; // vector of nodes available for branching out
+ phydbl *p_branch; // p_branch[i]: proba that the i-th node in branching_nodes branches out (p_x vector in the article)
+ phydbl *p_mig; // p_branch[i]: proba of migrating to location i from the location of the edge branching out (q_i vector in the article)
+ int hit;
+ phydbl time;
+ int dep, arr;
+ int i,j;
+ phydbl sum;
+ phydbl R;
+ int *occup; // occupation vector. Updated as we move down the tree
+ int nd_idx;
+ t_node *buff_nd;
+ phydbl buff_t;
+ int buff_l;
+ int swap;
+
+ tree = Make_Tree_From_Scratch(n_otu,NULL);
+ tree->rates = RATES_Make_Rate_Struct(tree->n_otu);
+ RATES_Init_Rate_Struct(tree->rates,NULL,tree->n_otu);
+ tree->n_root = tree->a_nodes[2*tree->n_otu-2]; // Set the root node to the last element in the list of nodes
+ tree->geo = t;
+
+
+ For(i,2*tree->n_otu-2) tree->rates->nd_t[i] = -1.;
+
+ occup = (int *)mCalloc(t->ldscape_sz,sizeof(int));
+
+ GEO_Update_Fmat(t);
+
+ branching_nodes = (t_node **)mCalloc(tree->n_otu,sizeof(t_node *));
+ branching_nodes[0] = tree->n_root;
+ n_branching_nodes = 1;
+ nd_idx = 0;
+
+
+ p_branch = (phydbl *)mCalloc(tree->n_otu,sizeof(phydbl ));
+ p_branch[0] = 1.0;
+
+ p_mig = (phydbl *)mCalloc(t->ldscape_sz,sizeof(phydbl ));
+
+ time = 0.0; // Time at the root node (this will be changed afterward)
+
+ // Sample a location uniformly for the root
+ t->idx_loc[tree->n_root->num] = Rand_Int(0,t->ldscape_sz-1);
+
+ // Update the occupancy vector
+ occup[t->idx_loc[tree->n_root->num]] = 1;
+
+ dep = arr = -1;
+
+
+ // total migration rate
+ R = 0.0;
+ for(i=0;ildscape_sz;i++)
+ {
+ R +=
+ t->f_mat[t->idx_loc[tree->n_root->num]*t->ldscape_sz+i] *
+ ((occup[i] == 0) ? (1.0) : (t->lbda)) *
+ t->tau * t->dum;
+ }
+
+ do
+ {
+ // Select the node that branches out
+ hit = Sample_i_With_Proba_pi(p_branch,n_branching_nodes);
+
+ /* printf("\n. [%d] Select node %d (location %d)",n_branching_nodes,branching_nodes[hit]->num,t->idx_loc[branching_nodes[hit]->num]); */
+
+ // Set the time for the branching node
+ tree->rates->nd_t[branching_nodes[hit]->num] = time;
+
+
+ /* printf("\n. Set its time to %f",time); */
+
+ // Select the destination location
+ dep = t->idx_loc[branching_nodes[hit]->num]; // Departure point
+
+ sum = .0;
+ for(i=0;ildscape_sz;i++) // Total rate of migration out of departure point
+ {
+ p_mig[i] =
+ t->f_mat[dep*t->ldscape_sz+i] *
+ ((occup[i] == 0) ? (1.0) : (t->lbda)) *
+ t->tau * t->dum;
+
+ sum += p_mig[i];
+ }
+ for(i=0;ildscape_sz;i++) p_mig[i] /= sum;
+
+ arr = Sample_i_With_Proba_pi(p_mig,t->ldscape_sz);
+
+ /* printf("\n. Migrate from %d [%5.2f,%5.2f] to %d [%5.2f,%5.2f]", */
+ /* dep, */
+ /* t->ldscape[dep*t->n_dim+0], */
+ /* t->ldscape[dep*t->n_dim+1], */
+ /* arr, */
+ /* t->ldscape[arr*t->n_dim+0], */
+ /* t->ldscape[arr*t->n_dim+1]); */
+
+ /* printf("\n%f\t%f", */
+ /* t->ldscape[arr*t->n_dim+0]-t->ldscape[dep*t->n_dim+0], */
+ /* t->ldscape[arr*t->n_dim+1]-t->ldscape[dep*t->n_dim+1]); */
+
+
+ // Update vector of occupation
+ occup[arr]++;
+
+ /* printf("\n. Remove %d. Add %d and %d",branching_nodes[hit]->num,tree->a_nodes[nd_idx]->num,tree->a_nodes[nd_idx+1]->num); */
+ // Connect two new nodes to the node undergoing a branching event
+ tree->a_nodes[nd_idx]->v[0] = branching_nodes[hit];
+ tree->a_nodes[nd_idx+1]->v[0] = branching_nodes[hit];
+ branching_nodes[hit]->v[1] = tree->a_nodes[nd_idx];
+ branching_nodes[hit]->v[2] = tree->a_nodes[nd_idx+1];
+
+ // update branching_nodes vector. Element 'hit' is being replaced so that the corresponding node can no longer branch out
+ branching_nodes[hit] = tree->a_nodes[nd_idx];
+ branching_nodes[n_branching_nodes] = tree->a_nodes[nd_idx+1];
+
+ // Update t_loc vector.
+ t->idx_loc[tree->a_nodes[nd_idx]->num] = dep;
+ t->idx_loc[tree->a_nodes[nd_idx+1]->num] = arr;
+
+ // Update total migration rate
+ R = .0;
+ for(i=0;ildscape_sz;i++)
+ {
+ if(occup[i] > 0)
+ {
+ for(j=0;jldscape_sz;j++)
+ {
+ R +=
+ occup[i] *
+ t->f_mat[i*t->ldscape_sz+j] *
+ ((occup[j] == 0) ? (1.0) : (t->lbda)) *
+ t->tau * t->dum;
+ }
+ }
+ }
+
+ // Set the time until next branching event
+ time = time + Rexp(R);
+
+ // Update p_branch vector
+ For(i,n_branching_nodes+1)
+ {
+ dep = t->idx_loc[branching_nodes[i]->num];
+ p_branch[i] = 0.0;
+ for(j=0;jldscape_sz;j++)
+ {
+ p_branch[i] +=
+ t->f_mat[dep*t->ldscape_sz+j] *
+ ((occup[j] == 0) ? (1.0) : (t->lbda)) *
+ t->tau * t->dum / R;
+
+ /* printf("\n. %f %f %f %f", */
+ /* R, */
+ /* t->f_mat[dep*t->ldscape_sz+j], */
+ /* ((occup[j]>0) ? (t->lbda) : (1.0)), */
+ /* t->tau); */
+ }
+ /* printf("\n. %f ",p_branch[i]); */
+ }
+
+
+ // Increase the number of branching nodes by one (you just added 2 new and removed 1 old)
+ n_branching_nodes++;
+ nd_idx += 2;
+
+ }
+ while(n_branching_nodes < n_otu);
+
+
+ // Set the times at the tips
+ For(i,2*tree->n_otu-1) if(tree->rates->nd_t[i] < 0.0) tree->rates->nd_t[i] = time;
+
+ // Reverse time scale
+ For(i,2*tree->n_otu-1) tree->rates->nd_t[i] -= time;
+ /* For(i,2*tree->n_otu-1) tree->rates->nd_t[i] = FABS(tree->rates->nd_t[i]); */
+
+ // Bubble sort to put all the tips at the top of the tree->a_nodes array
+ do
+ {
+ swap = NO;
+ For(i,2*tree->n_otu-2)
+ {
+ if(!tree->a_nodes[i+1]->v[1] && tree->a_nodes[i]->v[1])
+ {
+ buff_nd = tree->a_nodes[i+1];
+ tree->a_nodes[i+1] = tree->a_nodes[i];
+ tree->a_nodes[i] = buff_nd;
+
+ buff_t = tree->rates->nd_t[i+1];
+ tree->rates->nd_t[i+1] = tree->rates->nd_t[i];
+ tree->rates->nd_t[i] = buff_t;
+
+ buff_l = t->idx_loc[i+1];
+ t->idx_loc[i+1] = t->idx_loc[i];
+ t->idx_loc[i] = buff_l;
+
+ swap = YES;
+ }
+ }
+ }
+ while(swap == YES);
+
+
+ // The rest below is just bookeeping...
+
+
+ For(i,2*tree->n_otu-1) tree->a_nodes[i]->num = i;
+ For(i,2*tree->n_otu-1)
+ {
+ if(i < tree->n_otu) tree->a_nodes[i]->tax = YES;
+ else tree->a_nodes[i]->tax = NO;
+ }
+
+ /* printf("\n++++++++++++++++++\n"); */
+ /* For(i,2*tree->n_otu-1) */
+ /* { */
+ /* printf("\n. Node %3d [%p] anc:%3d v1:%3d v2:%3d time: %f", */
+ /* tree->a_nodes[i]->num, */
+ /* (void *)tree->a_nodes[i], */
+ /* tree->a_nodes[i]->v[0] ? tree->a_nodes[i]->v[0]->num : -1, */
+ /* tree->a_nodes[i]->v[1] ? tree->a_nodes[i]->v[1]->num : -1, */
+ /* tree->a_nodes[i]->v[2] ? tree->a_nodes[i]->v[2]->num : -1, */
+ /* tree->rates->nd_t[i]); */
+ /* } */
+
+
+ for(i=0;in_otu;i++)
+ {
+ if(!tree->a_nodes[i]->name) tree->a_nodes[i]->name = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+ strcpy(tree->a_nodes[i]->name,"x");
+ sprintf(tree->a_nodes[i]->name+1,"%d",i);
+ }
+
+ tree->n_root->v[1]->v[0] = tree->n_root->v[2];
+ tree->n_root->v[2]->v[0] = tree->n_root->v[1];
+
+ tree->num_curr_branch_available = 0;
+ Connect_Edges_To_Nodes_Recur(tree->a_nodes[0],tree->a_nodes[0]->v[0],tree);
+
+ tree->e_root = tree->n_root->v[1]->b[0];
+
+ For(i,2*tree->n_otu-3)
+ {
+ tree->a_edges[i]->l->v = FABS(tree->rates->nd_t[tree->a_edges[i]->left->num] -
+ tree->rates->nd_t[tree->a_edges[i]->rght->num]);
+ }
+
+ tree->e_root->l->v =
+ FABS(tree->rates->nd_t[tree->n_root->v[1]->num] -
+ tree->rates->nd_t[tree->n_root->num]) +
+ FABS(tree->rates->nd_t[tree->n_root->v[2]->num] -
+ tree->rates->nd_t[tree->n_root->num]);
+
+ tree->n_root->l[1] = FABS(tree->rates->nd_t[tree->n_root->v[1]->num] -
+ tree->rates->nd_t[tree->n_root->num]);
+
+ tree->n_root->l[2] = FABS(tree->rates->nd_t[tree->n_root->v[2]->num] -
+ tree->rates->nd_t[tree->n_root->num]);
+
+ tree->n_root_pos =
+ FABS(tree->rates->nd_t[tree->n_root->v[2]->num] -
+ tree->rates->nd_t[tree->n_root->num]) / tree->e_root->l->v;
+
+ /* printf("\n. %s ",Write_Tree(tree)); */
+
+ DR_Draw_Tree("essai.ps",tree);
+
+ /* for(i=0;in_otu;i++) */
+ /* printf("\n. %4s %4d [%5.2f %5.2f]",tree->a_nodes[i]->name, */
+ /* t->idx_loc[i], */
+ /* t->ldscape[t->idx_loc[i]*t->n_dim+0], */
+ /* t->ldscape[t->idx_loc[i]*t->n_dim+1]); */
+
+
+ Update_Ancestors(tree->n_root,tree->n_root->v[2],tree);
+ Update_Ancestors(tree->n_root,tree->n_root->v[1],tree);
+
+ Free(branching_nodes);
+ Free(p_branch);
+ Free(p_mig);
+
+ return(tree);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+// Simualte n coordinates (in 2D)
+void GEO_Simulate_Coordinates(int n, t_geo *t)
+{
+ int i;
+ phydbl width;
+
+ width = 5.;
+
+ for(i=0;ildscape[i*t->n_dim+0] = -width/2. + Uni()*width; */
+ /* t->ldscape[i*t->n_dim+1] = width/2.; */
+ t->coord_loc[i]->lonlat[0] = -width/2. + Uni()*width;
+ t->coord_loc[i]->lonlat[1] = width/2.;
+ }
+
+ /* t->ldscape[0*t->n_dim+0] = 0.0; */
+ /* t->ldscape[0*t->n_dim+1] = 0.0; */
+
+ /* t->ldscape[1*t->n_dim+0] = 0.1; */
+ /* t->ldscape[1*t->n_dim+1] = 0.1; */
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Optimize_Sigma(t_geo *t, t_tree *tree)
+{
+ Generic_Brent_Lk(&(t->sigma),
+ t->min_sigma,
+ t->max_sigma,
+ 1.E-5,
+ 1000,
+ NO,
+ GEO_Wrap_Lk,NULL,tree,NULL,NO);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Optimize_Lambda(t_geo *t, t_tree *tree)
+{
+ Generic_Brent_Lk(&(t->lbda),
+ t->min_lbda,
+ t->max_lbda,
+ 1.E-5,
+ 1000,
+ NO,
+ GEO_Wrap_Lk,NULL,tree,NULL,NO);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Optimize_Tau(t_geo *t, t_tree *tree)
+{
+ Generic_Brent_Lk(&(t->tau),
+ t->min_tau,
+ t->max_tau,
+ 1.E-5,
+ 1000,
+ NO,
+ GEO_Wrap_Lk,NULL,tree,NULL,NO);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl GEO_Wrap_Lk(t_edge *b, t_tree *tree, supert_tree *stree)
+{
+ return GEO_Lk(tree->geo,tree);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Init_Geo_Struct(t_geo *t)
+{
+ t->c_lnL = UNLIKELY;
+
+ t->sigma = 1.0;
+ t->min_sigma = 1.E-3;
+ t->max_sigma = 1.E+3;
+ t->sigma_thresh = t->max_sigma;
+
+ t->lbda = 1.0;
+ t->min_lbda = 1.E-3;
+ t->max_lbda = 1.E+3;
+
+ t->tau = 1.0;
+ t->min_tau = 1.E-3;
+ t->max_tau = 1.E+3;
+
+ t->dum = 1.0;
+ t->min_dum = 1.E-3;
+ t->max_dum = 1.E+3;
+
+ t->n_dim = 2;
+ t->ldscape_sz = 1;
+
+ t->update_fmat = YES;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Randomize_Locations(t_node *n, t_geo *t, t_tree *tree)
+{
+ if(n->tax == YES) return;
+ else
+ {
+ t_node *v1, *v2;
+ int i;
+ phydbl *probs; // vector of probability of picking each location
+ phydbl sum;
+ phydbl u;
+
+
+ probs = (phydbl *)mCalloc(t->ldscape_sz,sizeof(phydbl));
+
+ v1 = v2 = NULL;
+ for(i=0;i<3;i++)
+ {
+ if(n->v[i] != n->anc && n->b[i] != tree->e_root)
+ {
+ if(!v1) v1 = n->v[i];
+ else v2 = n->v[i];
+ }
+ }
+
+ if(v1->tax && v2->tax)
+ {
+ Free(probs);
+ return;
+ }
+ else if(v1->tax && !v2->tax && t->idx_loc[v1->num] != t->idx_loc[n->num])
+ {
+ t->idx_loc[v2->num] = t->idx_loc[n->num];
+ }
+ else if(v2->tax && !v1->tax && t->idx_loc[v2->num] != t->idx_loc[n->num])
+ {
+ t->idx_loc[v1->num] = t->idx_loc[n->num];
+ }
+ else if(v1->tax && !v2->tax && t->idx_loc[v1->num] == t->idx_loc[n->num])
+ {
+ sum = 0.0;
+ for(i=0;ildscape_sz;i++) sum += t->idx_loc_beneath[v2->num * t->ldscape_sz + i];
+ for(i=0;ildscape_sz;i++) probs[i] = t->idx_loc_beneath[v2->num * t->ldscape_sz + i]/sum;
+
+ t->idx_loc[v2->num] = Sample_i_With_Proba_pi(probs,t->ldscape_sz);
+ }
+ else if(v2->tax && !v1->tax && t->idx_loc[v2->num] == t->idx_loc[n->num])
+ {
+ sum = 0.0;
+ for(i=0;ildscape_sz;i++) sum += t->idx_loc_beneath[v1->num * t->ldscape_sz + i];
+ for(i=0;ildscape_sz;i++) probs[i] = t->idx_loc_beneath[v1->num * t->ldscape_sz + i]/sum;
+
+ t->idx_loc[v1->num] = Sample_i_With_Proba_pi(probs,t->ldscape_sz);
+ }
+ else
+ {
+ int n_v1, n_v2;
+ phydbl p;
+
+ n_v1 = t->idx_loc_beneath[v1->num * t->ldscape_sz + t->idx_loc[n->num]];
+ n_v2 = t->idx_loc_beneath[v2->num * t->ldscape_sz + t->idx_loc[n->num]];
+
+ if(n_v1 + n_v2 < 1)
+ {
+ PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+
+ p = n_v1 / (n_v1 + n_v2);
+
+ u = Uni();
+
+ if(u < p)
+ {
+ sum = 0.0;
+ for(i=0;ildscape_sz;i++) sum += t->idx_loc_beneath[v2->num * t->ldscape_sz + i];
+ for(i=0;ildscape_sz;i++) probs[i] = t->idx_loc_beneath[v2->num * t->ldscape_sz + i]/sum;
+
+ t->idx_loc[v2->num] = Sample_i_With_Proba_pi(probs,t->ldscape_sz);
+ t->idx_loc[v1->num] = t->idx_loc[n->num];
+ }
+ else
+ {
+ if(t->idx_loc_beneath[v2->num * t->ldscape_sz + t->idx_loc[n->num]] > 0)
+ {
+ sum = 0.0;
+ for(i=0;ildscape_sz;i++) sum += t->idx_loc_beneath[v1->num * t->ldscape_sz + i];
+ for(i=0;ildscape_sz;i++) probs[i] = t->idx_loc_beneath[v1->num * t->ldscape_sz + i]/sum;
+
+ t->idx_loc[v1->num] = Sample_i_With_Proba_pi(probs,t->ldscape_sz);
+ t->idx_loc[v2->num] = t->idx_loc[n->num];
+ }
+ else
+ {
+ sum = 0.0;
+ for(i=0;ildscape_sz;i++) sum += t->idx_loc_beneath[v2->num * t->ldscape_sz + i];
+ for(i=0;ildscape_sz;i++) probs[i] = t->idx_loc_beneath[v2->num * t->ldscape_sz + i]/sum;
+
+ t->idx_loc[v2->num] = Sample_i_With_Proba_pi(probs,t->ldscape_sz);
+ t->idx_loc[v1->num] = t->idx_loc[n->num];
+ }
+ }
+
+ if(t->idx_loc[v1->num] != t->idx_loc[n->num] && t->idx_loc[v2->num] != t->idx_loc[n->num])
+ {
+ PhyML_Printf("\n. %d %d %d",t->idx_loc[v1->num],t->idx_loc[v2->num],t->idx_loc[n->num]);
+ PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ if(t->idx_loc_beneath[v1->num * t->ldscape_sz + t->idx_loc[v1->num]] < 1)
+ {
+ PhyML_Printf("\n. %d %d %d",t->idx_loc[v1->num],t->idx_loc[v2->num],t->idx_loc[n->num]);
+ PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ if(t->idx_loc_beneath[v2->num * t->ldscape_sz + t->idx_loc[v2->num]] < 1)
+ {
+ PhyML_Printf("\n. %d %d %d",t->idx_loc[v1->num],t->idx_loc[v2->num],t->idx_loc[n->num]);
+ PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ }
+
+ Free(probs);
+
+ for(i=0;i<3;i++)
+ if(n->v[i] != n->anc && n->b[i] != tree->e_root)
+ GEO_Randomize_Locations(n->v[i],t,tree);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Get_Locations_Beneath(t_geo *t, t_tree *tree)
+{
+ int i;
+ GEO_Get_Locations_Beneath_Post(tree->n_root,tree->n_root->v[1],t,tree);
+ GEO_Get_Locations_Beneath_Post(tree->n_root,tree->n_root->v[2],t,tree);
+
+ for(i=0;ildscape_sz;i++)
+ {
+ t->idx_loc_beneath[tree->n_root->num*t->ldscape_sz+i] =
+ t->idx_loc_beneath[tree->n_root->v[1]->num*t->ldscape_sz+i] +
+ t->idx_loc_beneath[tree->n_root->v[2]->num*t->ldscape_sz+i];
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Get_Locations_Beneath_Post(t_node *a, t_node *d, t_geo *t, t_tree *tree)
+{
+
+ if(d->tax)
+ {
+ t->idx_loc_beneath[d->num*t->ldscape_sz+t->idx_loc[d->num]] = 1;
+ return;
+ }
+ else
+ {
+ int i;
+ t_node *v1, *v2;
+
+ for(i=0;i<3;i++)
+ {
+ if(d->v[i] != a && d->b[i] != tree->e_root)
+ {
+ GEO_Get_Locations_Beneath_Post(d,d->v[i],t,tree);
+ }
+ }
+
+
+ v1 = v2 = NULL;
+ for(i=0;i<3;i++)
+ {
+ if(d->v[i] != a && d->b[i] != tree->e_root)
+ {
+ if(!v1) v1 = d->v[i];
+ else v2 = d->v[i];
+ }
+ }
+
+
+ for(i=0;ildscape_sz;i++)
+ {
+ t->idx_loc_beneath[ d->num*t->ldscape_sz+i] =
+ t->idx_loc_beneath[v1->num*t->ldscape_sz+i] +
+ t->idx_loc_beneath[v2->num*t->ldscape_sz+i] ;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Get_Sigma_Max(t_geo *t)
+{
+ int i,j;
+ phydbl mean_dist,inv_mean_dist;
+ phydbl sigma_a, sigma_b, sigma_c;
+ phydbl overlap_a, overlap_b, overlap_c;
+ phydbl d_intersect;
+ phydbl overlap_target;
+ phydbl eps;
+ int n_iter,n_iter_max;
+
+ eps = 1.E-6;
+ overlap_target = 0.95;
+ n_iter_max = 100;
+
+ mean_dist = -1.;
+ inv_mean_dist = -1.;
+ for(i=0;ildscape_sz-1;i++)
+ {
+ for(j=i+1;jldscape_sz;j++)
+ {
+ /* dist = POW(t->ldscape[i*t->n_dim+0] - t->ldscape[j*t->n_dim+0],1); */
+ /* if(dist > mean_dist) mean_dist = dist; */
+ /* dist = POW(t->ldscape[i*t->n_dim+1] - t->ldscape[j*t->n_dim+1],1); */
+ /* if(dist > mean_dist) mean_dist = dist; */
+ /* mean_dist += FABS(t->ldscape[i*t->n_dim+0] - t->ldscape[j*t->n_dim+0]); */
+ /* mean_dist += FABS(t->ldscape[i*t->n_dim+1] - t->ldscape[j*t->n_dim+1]); */
+ mean_dist += FABS(t->coord_loc[i]->lonlat[0] - t->coord_loc[j]->lonlat[0]);
+ mean_dist += FABS(t->coord_loc[i]->lonlat[1] - t->coord_loc[j]->lonlat[1]);
+ }
+ }
+
+ mean_dist /= t->ldscape_sz*(t->ldscape_sz-1)/2.;
+ inv_mean_dist = 1./mean_dist;
+
+ PhyML_Printf("\n. Mean distance between locations: %f",mean_dist);
+
+ sigma_a = t->min_sigma; sigma_b = 1.0; sigma_c = t->max_sigma;
+ /* sigma_a = t->min_sigma; sigma_b = 1.0; sigma_c = 10.; */
+ n_iter = 0;
+ do
+ {
+ d_intersect = Inverse_Truncated_Normal(inv_mean_dist,0.0,sigma_a,0.0,mean_dist);
+ overlap_a =
+ (Pnorm(mean_dist,0.0,sigma_a) - Pnorm(d_intersect,0.0,sigma_a))/
+ (Pnorm(mean_dist,0.0,sigma_a) - Pnorm(0.0,0.0,sigma_a)) +
+ d_intersect / mean_dist;
+ /* printf("\n. inter: %f %f [%f]",d_intersect,mean_dist,d_intersect / mean_dist); */
+
+ d_intersect = Inverse_Truncated_Normal(inv_mean_dist,0.0,sigma_b,0.0,mean_dist);
+ overlap_b =
+ (Pnorm(mean_dist,0.0,sigma_b) - Pnorm(d_intersect,0.0,sigma_b))/
+ (Pnorm(mean_dist,0.0,sigma_b) - Pnorm(0.0,0.0,sigma_b)) +
+ d_intersect / mean_dist;
+ /* printf("\n. inter: %f %f [%f]",d_intersect,mean_dist,d_intersect / mean_dist); */
+
+ d_intersect = Inverse_Truncated_Normal(inv_mean_dist,0.0,sigma_c,0.0,mean_dist);
+ overlap_c =
+ (Pnorm(mean_dist,0.0,sigma_c) - Pnorm(d_intersect,0.0,sigma_c))/
+ (Pnorm(mean_dist,0.0,sigma_c) - Pnorm(0.0,0.0,sigma_c)) +
+ d_intersect / mean_dist;
+
+ /* printf("\n. inter: %f %f [%f]",d_intersect,mean_dist,d_intersect / mean_dist); */
+
+ /* printf("\n. sigma_a:%f overlap_a:%f sigma_b:%f overlap_b:%f sigma_c:%f overlap_c:%f", */
+ /* sigma_a,overlap_a, */
+ /* sigma_b,overlap_b, */
+ /* sigma_c,overlap_c); */
+
+ if(overlap_target > overlap_a && overlap_target < overlap_b)
+ {
+ sigma_c = sigma_b;
+ sigma_b = sigma_a + (sigma_c - sigma_a)/2.;
+ }
+ else if(overlap_target > overlap_b && overlap_target < overlap_c)
+ {
+ sigma_a = sigma_b;
+ sigma_b = sigma_a + (sigma_c - sigma_a)/2.;
+ }
+ else if(overlap_target < overlap_a)
+ {
+ sigma_a /= 2.;
+ }
+ else if(overlap_target > overlap_c)
+ {
+ sigma_c *= 2.;
+ }
+
+ n_iter++;
+
+ }
+ while(sigma_c - sigma_a > eps && n_iter < n_iter_max);
+
+ /* if(sigma_c - sigma_a > eps) */
+ /* { */
+ /* PhyML_Printf("\n== Error detected in getting maximum value of sigma."); */
+ /* PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__); */
+ /* Exit("\n"); */
+ /* } */
+ /* else */
+ /* { */
+ /* PhyML_Printf("\n== Threshold for sigma: %f",sigma_b); */
+ /* } */
+
+ t->sigma_thresh = sigma_b;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void MCMC_Geo_Updown_Tau_Lbda(t_tree *tree)
+{
+ phydbl K,mult,u,alpha,ratio;
+ phydbl cur_lnL,new_lnL;
+ phydbl cur_tau,new_tau;
+ phydbl cur_lbda,new_lbda;
+
+ K = tree->mcmc->tune_move[tree->mcmc->num_move_geo_updown_tau_lbda];
+ cur_lnL = tree->geo->c_lnL;
+ new_lnL = tree->geo->c_lnL;
+ cur_tau = tree->geo->tau;
+ new_tau = tree->geo->tau;
+ cur_lbda = tree->geo->lbda;
+ new_lbda = tree->geo->lbda;
+
+ u = Uni();
+ mult = exp(K*(u-0.5));
+
+ /* Multiply tau by K */
+ new_tau = cur_tau * K;
+
+ /* Divide lbda by same amount */
+ new_lbda = cur_lbda / K;
+
+
+ if(
+ new_lbda < tree->geo->min_lbda || new_lbda > tree->geo->max_lbda ||
+ new_tau < tree->geo->min_tau || new_tau > tree->geo->max_tau
+ )
+ {
+ tree->mcmc->run_move[tree->mcmc->num_move_geo_updown_tau_lbda]++;
+ return;
+ }
+
+ tree->geo->tau = new_tau;
+ tree->geo->lbda = new_lbda;
+
+ if(tree->eval_alnL) new_lnL = GEO_Lk(tree->geo,tree);
+
+ ratio = 0.0;
+ /* Proposal ratio: 2n-2=> number of multiplications, 1=>number of divisions */
+ ratio += 0.0*log(mult); /* (1-1)*log(mult); */
+ /* Likelihood density ratio */
+ ratio += (new_lnL - cur_lnL);
+
+ /* printf("\n. new_tau: %f new_lbda:%f cur_lnL:%f new_lnL:%f",new_tau,new_lbda,cur_lnL,new_lnL); */
+
+
+ ratio = exp(ratio);
+ alpha = MIN(1.,ratio);
+ u = Uni();
+
+ if(u > alpha) /* Reject */
+ {
+ tree->geo->tau = cur_tau;
+ tree->geo->lbda = cur_lbda;
+ tree->geo->c_lnL = cur_lnL;
+ }
+ else
+ {
+ tree->mcmc->acc_move[tree->mcmc->num_move_geo_updown_tau_lbda]++;
+ }
+
+ tree->mcmc->run_move[tree->mcmc->num_move_geo_updown_tau_lbda]++;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+void MCMC_Geo_Updown_Lbda_Sigma(t_tree *tree)
+{
+ phydbl K,mult,u,alpha,ratio;
+ phydbl cur_lnL,new_lnL;
+ phydbl cur_lbda,new_lbda;
+ phydbl cur_sigma,new_sigma;
+
+ K = tree->mcmc->tune_move[tree->mcmc->num_move_geo_updown_lbda_sigma];
+ cur_lnL = tree->geo->c_lnL;
+ new_lnL = tree->geo->c_lnL;
+ cur_lbda = tree->geo->lbda;
+ new_lbda = tree->geo->lbda;
+ cur_sigma = tree->geo->sigma;
+ new_sigma = tree->geo->sigma;
+
+ u = Uni();
+ mult = exp(K*(u-0.5));
+
+ /* Multiply lbda by K */
+ new_lbda = cur_lbda * K;
+
+ /* Divide sigma by same amount */
+ new_sigma = cur_sigma / K;
+
+
+ if(
+ new_sigma < tree->geo->min_sigma || new_sigma > tree->geo->max_sigma ||
+ new_lbda < tree->geo->min_lbda || new_lbda > tree->geo->max_lbda
+ )
+ {
+ tree->mcmc->run_move[tree->mcmc->num_move_geo_updown_lbda_sigma]++;
+ return;
+ }
+
+ tree->geo->lbda = new_lbda;
+ tree->geo->sigma = new_sigma;
+
+ if(tree->eval_alnL) new_lnL = GEO_Lk(tree->geo,tree);
+
+ ratio = 0.0;
+ /* Proposal ratio: 2n-2=> number of multiplications, 1=>number of divisions */
+ ratio += 0.0*log(mult); /* (1-1)*log(mult); */
+ /* Likelihood density ratio */
+ ratio += (new_lnL - cur_lnL);
+
+ /* printf("\n. new_lbda: %f new_sigma:%f cur_lnL:%f new_lnL:%f",new_lbda,new_sigma,cur_lnL,new_lnL); */
+
+
+ ratio = exp(ratio);
+ alpha = MIN(1.,ratio);
+ u = Uni();
+
+ if(u > alpha) /* Reject */
+ {
+ tree->geo->lbda = cur_lbda;
+ tree->geo->sigma = cur_sigma;
+ tree->geo->c_lnL = cur_lnL;
+ }
+ else
+ {
+ tree->mcmc->acc_move[tree->mcmc->num_move_geo_updown_lbda_sigma]++;
+ }
+
+ tree->mcmc->run_move[tree->mcmc->num_move_geo_updown_lbda_sigma]++;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void GEO_Read_In_Landscape(char *file_name, t_geo *t, phydbl **ldscape, int **loc_hash, t_tree *tree)
+{
+ FILE *fp;
+ char *s;
+ phydbl longitude, lattitude;
+ int tax,loc;
+
+ PhyML_Printf("\n");
+ PhyML_Printf("\n. Reading landscape file '%s'.\n",file_name);
+
+ s = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+ (*ldscape) = (phydbl *)mCalloc(10*t->n_dim,sizeof(phydbl));
+ (*loc_hash) = (int *)mCalloc(tree->n_otu,sizeof(int));
+
+ fp = Openfile(file_name,0);
+
+ tax = loc = -1;
+
+ t->ldscape_sz = 0;
+
+ do
+ {
+ if(fscanf(fp,"%s",s) == EOF) break;
+
+ if(strlen(s) > 0) for(tax=0;taxn_otu;tax++) if(!strcmp(tree->a_nodes[tax]->name,s)) break;
+
+ if(tax == tree->n_otu)
+ {
+ PhyML_Printf("\n== Could not find a taxon with name '%s' in the tree provided.",s);
+ /* PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__); */
+ /* Exit("\n"); */
+ continue;
+ }
+
+ /* sscanf(line+pos,"%lf %lf",&longitude,&lattitude); */
+ if(fscanf(fp,"%lf",&longitude) == EOF) break;
+ if(fscanf(fp,"%lf",&lattitude) == EOF) break;
+
+ /* printf("\n. s: %s %f %f",s,longitude,lattitude); */
+
+ for(loc=0;locldscape_sz;loc++)
+ {
+ if(FABS(longitude-(*ldscape)[loc*t->n_dim+0]) < 1.E-10 &&
+ FABS(lattitude-(*ldscape)[loc*t->n_dim+1]) < 1.E-10)
+ {
+ break;
+ }
+ }
+
+ if(loc == t->ldscape_sz)
+ {
+ t->ldscape_sz++;
+ (*ldscape)[(t->ldscape_sz-1)*t->n_dim+0] = longitude;
+ (*ldscape)[(t->ldscape_sz-1)*t->n_dim+1] = lattitude;
+
+ if(!(t->ldscape_sz%10))
+ {
+ (*ldscape) = (phydbl *)mRealloc((*ldscape),(t->ldscape_sz+10)*t->n_dim,sizeof(phydbl));
+ }
+ }
+
+ (*loc_hash)[tax] = loc;
+
+ }
+ while(1);
+
+ for(tax=0;taxn_otu;tax++)
+ PhyML_Printf("\n. Taxon %30s, longitude: %12f, lattitude: %12f [%4d]",
+ tree->a_nodes[tax]->name,
+ (*ldscape)[(*loc_hash)[tax]*t->n_dim+0],
+ (*ldscape)[(*loc_hash)[tax]*t->n_dim+1],
+ (*loc_hash)[tax]);
+
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
diff --git a/phyml/geo.h b/phyml/geo.h
new file mode 100644
index 0000000..7493490
--- /dev/null
+++ b/phyml/geo.h
@@ -0,0 +1,49 @@
+/*
+
+PHYML : a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences
+
+Copyright (C) Stephane Guindon. Oct 2003 onward
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+#include
+
+#ifndef GEO_H
+#define GEO_H
+
+#include "utilities.h"
+
+int GEO_Main(int argc, char **argv);
+void Free_Geo(t_geo *t);
+void GEO_Update_Fmat(t_geo *t);
+void GEO_Update_Sorted_Nd(t_geo *t,t_tree *tree);
+void GEO_Update_Occup(t_geo *t,t_tree *tree);
+void GEO_Update_Rmat(t_node *n,t_geo *t,t_tree *tree);
+phydbl GEO_Lk(t_geo *t,t_tree *tree);
+void GEO_Init_Tloc_Tips(t_geo *t,t_tree *tree);
+phydbl GEO_Total_Migration_Rate(t_node *n,t_geo *t);
+int GEO_Get_Arrival_Location(t_node *n,t_geo *t,t_tree *tree);
+void GEO_Simulate_Coordinates(int n, t_geo *t);
+t_tree *GEO_Simulate(t_geo *t, int n_otu);
+void GEO_Optimize_Sigma(t_geo *t, t_tree *tree);
+phydbl GEO_Wrap_Lk(t_edge *b, t_tree *tree, supert_tree *stree);
+void GEO_Optimize_Lambda(t_geo *t, t_tree *tree);
+void GEO_Init_Geo_Struct(t_geo *t);
+void GEO_Optimize_Tau(t_geo *t, t_tree *tree);
+void GEO_Get_Locations_Beneath(t_geo *t, t_tree *tree);
+void GEO_Get_Locations_Beneath_Post(t_node *a, t_node *d, t_geo *t, t_tree *tree);
+void GEO_Randomize_Locations_Pre(t_node *n, t_geo *t, t_tree *tree);
+void GEO_Randomize_Locations(t_node *n, t_geo *t, t_tree *tree);
+void GEO_Get_Sigma_Max(t_geo *t);
+void MCMC_Geo_Updown_Tau_Lbda(t_tree *tree);
+void MCMC_Geo_Updown_Lbda_Sigma(t_tree *tree);
+int GEO_Simulate_Estimate(int argc, char **argv);
+void GEO_Read_In_Landscape(char *file_name, t_geo *t, phydbl **ldscape, int **loc_hash, t_tree *tree);
+int GEO_Estimate(int argc, char **argv);
+phydbl *GEO_MCMC(t_tree *tree);
+
+#endif
diff --git a/phyml/help.c b/phyml/help.c
new file mode 100644
index 0000000..1fb29b2
--- /dev/null
+++ b/phyml/help.c
@@ -0,0 +1,375 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+
+#include "help.h"
+
+
+/* int T_MAX_FILE; */
+/* phydbl SMALL; */
+/* phydbl UNLIKELY; */
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+void Usage()
+{
+
+ char *BOLD=(char *)mCalloc(10,sizeof(char));
+ char *FLAT=(char *)mCalloc(10,sizeof(char));
+ char *LINE=(char *)mCalloc(10,sizeof(char));
+ char *cha;
+
+
+ cha = getenv("OS");
+
+ if(cha!=NULL)
+ {
+ strcpy(BOLD, "");
+ strcpy(FLAT, "");
+ strcpy(LINE, "");
+ }
+ else
+ {
+ strcpy(BOLD, "\033[00;01m");
+ strcpy(FLAT, "\033[00;00m");
+ strcpy(LINE, "\033[00;04m");
+ }
+
+ #ifdef PHYML
+ PhyML_Printf("%sNAME\n"
+ "%s\t- PhyML %s - \n\n"
+ "%s\t\''A simple, fast, and accurate algorithm to estimate\n"
+ "%s\tlarge phylogenies by maximum likelihood\''\n\n"
+ "%s\tStephane Guindon and Olivier Gascuel,\n"
+ "%s\tSystematic Biology 52(5):696-704, 2003.\n\n"
+ "%s\tPlease cite this paper if you use this software in your publications.\n",BOLD,FLAT,VERSION,FLAT,FLAT,FLAT,FLAT,FLAT);
+ #endif
+
+ #ifdef PHYTIME
+ PhyML_Printf("%sNAME\n"
+ "%s\t- PhyTime %s - \n\n"
+ "%s\t'Bayesian estimation of divergence times from large sequence alignments.'\n"
+ "%s\tStephane Guindon,\n"
+ "%s\tMolecular Biology and Evolution 27(8):1768-81, 2010.\n\n"
+ "%s\tPlease cite this paper if you use this software in your publications.\n",BOLD,FLAT,VERSION,FLAT,FLAT,FLAT,FLAT,FLAT);
+ #endif
+
+
+
+ #ifdef PHYML
+ PhyML_Printf("%s\nSYNOPSIS:\n\n"
+ "%s\tphyml %s[command args]\n",BOLD,BOLD,BOLD);
+ #endif
+ #ifdef PHYTIME
+ PhyML_Printf("%s\nSYNOPSIS:\n\n"
+ "%s\tphytime %s[command args]\n",BOLD,BOLD,BOLD);
+ #endif
+
+ #ifdef PHYML
+ PhyML_Printf("%s\n\tAll the options below are optional (except '%s-i%s' if you want to use the command-line interface).\n\n",FLAT,BOLD,FLAT);
+ #endif
+
+ #ifdef PHYTIME
+ PhyML_Printf("%s\n\tAll the options below are optional except '%s-i%s','%s-u%s' and '%s--calibration%s'.\n\n",FLAT,BOLD,FLAT,BOLD,FLAT,BOLD,FLAT);
+ #endif
+
+ PhyML_Printf("%s\nCommand options:\n%s",BOLD,FLAT);
+
+ PhyML_Printf("\n\t%s-i (or --input) %sseq_file_name%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%sseq_file_name%s is the name of the nucleotide or amino-acid sequence file in PHYLIP format.\n",LINE,FLAT);
+ PhyML_Printf("\n");
+
+ PhyML_Printf("%s\n\t-d (or --datatype) ""%sdata_type%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%sdata_type%s is 'nt' for nucleotide (default), 'aa' for amino-acid sequences, or 'generic',\n",LINE,FLAT);
+ PhyML_Printf("\t\t(use NEXUS file format and the 'symbols' parameter here).\n");
+ PhyML_Printf("\n");
+
+
+ PhyML_Printf("%s\n\t-q (or --sequential)\n",BOLD);
+ PhyML_Printf("%s\t\tChanges interleaved format (default) to sequential format.\n",FLAT);
+ PhyML_Printf("\n");
+
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t-n (or --multiple) ""%snb_data_sets%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%snb_data_sets%s is an integer corresponding to the number of data sets to analyse.\n",LINE,FLAT);
+ PhyML_Printf("\n");
+ #endif
+
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t-p (or --pars)%s\n",BOLD,FLAT);
+ PhyML_Printf("%s\t\tUse a minimum parsimony starting tree. This option is taken into account when the '-u' option\n",FLAT);
+ PhyML_Printf("%s\t\tis absent and when tree topology modifications are to be done.\n",FLAT);
+ PhyML_Printf("\n");
+ #endif
+
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t-b (or --bootstrap) %sint%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%sint%s > 0: %sint%s is the number of bootstrap replicates.\n",LINE,FLAT,LINE,FLAT);
+ PhyML_Printf("\t\t%sint%s = 0: neither approximate likelihood ratio test nor bootstrap values are computed.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sint%s = -1: approximate likelihood ratio test returning aLRT statistics.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sint%s = -2: approximate likelihood ratio test returning Chi2-based parametric branch supports.\n",LINE,FLAT);
+/* PhyML_Printf("\t\t%sint%s = -3 : minimum of Chi2-based parametric and SH-like branch supports.\n",LINE,FLAT); */
+ PhyML_Printf("\t\t%sint%s = -4: SH-like branch supports alone.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sint%s = -5: (default) approximate Bayes branch supports.\n",LINE,FLAT);
+ PhyML_Printf("\n");
+
+ PhyML_Printf("%s\n\t--tbe%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\tComputes TBE instead of FBP (standard) bootstrap support\n");
+ PhyML_Printf("\t\tHas no effect with -b <= 0\n");
+
+ #endif
+
+ PhyML_Printf("%s\n\t-m (or --model) %smodel%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tmodel%s : substitution model name.\n",FLAT);
+ PhyML_Printf("\t\t%s- %sNucleotide%s-based models : %sHKY85%s (default) | %sJC69%s | %sK80%s | %sF81%s | %sF84%s | %sTN93%s | %sGTR%s | %scustom (*)%s\n",
+ FLAT,LINE,FLAT,LINE,FLAT,LINE,FLAT,LINE,FLAT,LINE,FLAT,LINE,FLAT,LINE,FLAT,LINE,FLAT,LINE,FLAT);
+ PhyML_Printf("\t\t(*) : for the custom option, a string of six digits identifies the model. For instance, 000000\n");
+ PhyML_Printf("\t\t corresponds to F81 (or JC69 provided the distribution of nucleotide frequencies is uniform).\n");
+ PhyML_Printf("\t\t 012345 corresponds to GTR. This option can be used for encoding any model that is a nested within GTR.\n");
+ PhyML_Printf("\n");
+ PhyML_Printf("\t\t%s- %sAmino-acid%s based models : %sLG%s (default) | %sWAG%s | %sJTT%s | %sMtREV%s | %sDayhoff%s | %sDCMut%s | %sRtREV%s | %sCpREV%s | %sVT%s | %sAB%s\n",FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT);
+ PhyML_Printf("\t\t %sBlosum62%s | %sMtMam%s | %sMtArt%s | %sHIVw%s | %sHIVb%s | %scustom%s\n",
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT,
+ LINE,FLAT);
+
+ PhyML_Printf("\n");
+
+ PhyML_Printf("%s\n\t--aa_rate_file %sfilename%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%sfilename%s is the name of the file that provides the amino acid substitution rate matrix in PAML format.\n",LINE,FLAT);
+ PhyML_Printf("\t\tIt is compulsory to use this option when analysing amino acid sequences with the `custom' model.\n");
+ PhyML_Printf("\n");
+
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t-f %se%s, %sm%s, or %sfA,fC,fG,fT%s\n",BOLD,LINE,BOLD,LINE,BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%se%s : the character frequencies are determined as follows : \n",LINE,FLAT);
+ PhyML_Printf("%s\t\t- %sNucleotide%s sequences: (Empirical) the equilibrium base frequencies are estimated by counting\n"
+ "\t\t the occurence of the different bases in the alignment.\n",FLAT,LINE,FLAT);
+ PhyML_Printf("%s\t\t- %sAmino-acid%s sequences: (Empirical) the equilibrium amino-acid frequencies are estimated by counting\n"
+"\t\t the occurence of the different amino-acids in the alignment.\n",FLAT,LINE,FLAT);
+ PhyML_Printf("\n");
+ PhyML_Printf("\t\t%sm%s : the character frequencies are determined as follows : \n",LINE,FLAT);
+ PhyML_Printf("%s\t\t- %sNucleotide%s sequences: (ML) the equilibrium base frequencies are estimated using maximum likelihood \n",FLAT,LINE,FLAT);
+ PhyML_Printf("%s\t\t- %sAmino-acid%s sequences: (Model) the equilibrium amino-acid frequencies are estimated using\n"
+"\t\t the frequencies defined by the substitution model.\n",FLAT,LINE,FLAT);
+ PhyML_Printf("\n");
+ PhyML_Printf("\t\t%sfA,fC,fG,fT%s : only valid for nucleotide-based models. fA, fC, fG and fT are floating numbers that \n",LINE,FLAT);
+ PhyML_Printf("\t\t correspond to the frequencies of A, C, G and T respectively (WARNING: do not use any blank space between\n");
+ PhyML_Printf("\t\t your values of nucleotide frequencies, only commas!)\n");
+ PhyML_Printf("\n");
+ #endif
+
+ #ifdef PHYTIME
+ PhyML_Printf("%s\n\t--calibration %sfilename%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%sfilename%s is the name of the calibration file that provides a priori defined boundaries for node ages.\n",LINE,FLAT);
+ PhyML_Printf("\t\tPlease read the manual for more information about the format of this file.\n");
+ PhyML_Printf("\n");
+ #endif
+
+
+ PhyML_Printf("%s\n\t-t (or --ts/tv) %sts/tv_ratio%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tts/tv_ratio%s : transition/transversion ratio. DNA sequences only.\n",FLAT);
+ PhyML_Printf("\t\tCan be a fixed positive value (ex:4.0) or %se%s to get the maximum likelihood estimate.\n",LINE,FLAT);
+ PhyML_Printf("\n");
+
+ PhyML_Printf("%s\n\t-v (or --pinv) %sprop_invar%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tprop_invar%s : proportion of invariable sites.\n",FLAT);
+ PhyML_Printf("\t\tCan be a fixed value in the [0,1] range or %se%s to get the maximum likelihood estimate.\n",LINE,FLAT);
+ PhyML_Printf("\n");
+
+ PhyML_Printf("%s\n\t-c (or --nclasses) %snb_subst_cat%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tnb_subst_cat%s : number of relative substitution rate categories. Default : %snb_subst_cat%s=4.\n",
+ FLAT,LINE,FLAT);
+ PhyML_Printf("\t\tMust be a positive integer.\n");
+ PhyML_Printf("\n");
+
+ PhyML_Printf("%s\n\t--freerates (or --free_rates or --freerate or --free_rate)\n",BOLD);
+ PhyML_Printf("\t\t%s FreeRate model of substitution rate variation across sites.\n",FLAT);
+ PhyML_Printf("\n");
+
+
+
+ PhyML_Printf("%s\n\t-a (or --alpha) %sgamma%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tgamma%s : distribution of the gamma distribution shape parameter.\n",FLAT);
+ PhyML_Printf("\t\tCan be a fixed positive value or %se%s to get the maximum likelihood estimate.\n",LINE,FLAT);
+ PhyML_Printf("\n");
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t-s (or --search) %smove%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tTree topology search operation option.\n");
+ PhyML_Printf("\t\tCan be either %sNNI%s (default, fast) or %sSPR%s (a bit slower than NNI) or %sBEST%s (best of NNI and SPR search).\n",LINE,FLAT,LINE,FLAT,LINE,FLAT);
+ PhyML_Printf("\n");
+ #endif
+
+
+ PhyML_Printf("%s\n\t-u (or --inputtree) %suser_tree_file%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tuser_tree_file%s : starting tree filename. The tree must be in Newick format.\n",FLAT);
+ PhyML_Printf("\n");
+
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t-o %sparams%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tThis option focuses on specific parameter optimisation.\n");
+ PhyML_Printf("\t\t%sparams%s=tlr : tree topology (t), branch length (l) and rate parameters (r) are optimised.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sparams%s=tl : tree topology and branch length are optimised.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sparams%s=lr : branch length and rate parameters are optimised.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sparams%s=l : branch length are optimised.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sparams%s=r : rate parameters are optimised.\n",LINE,FLAT);
+ PhyML_Printf("\t\t%sparams%s=n : no parameter is optimised.\n",LINE,FLAT);
+ PhyML_Printf("\n");
+ #endif
+
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t--rand_start%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\tThis option sets the initial tree to random.\n");
+ PhyML_Printf("\t\tIt is only valid if SPR searches are to be performed.\n");
+ PhyML_Printf("\n");
+ #endif
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t--n_rand_starts %snum%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tnum%s is the number of initial random trees to be used.\n",FLAT);
+ PhyML_Printf("\t\tIt is only valid if SPR searches are to be performed.\n");
+ PhyML_Printf("\n");
+ #endif
+
+ PhyML_Printf("%s\n\t--r_seed %snum%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tnum%s is the seed used to initiate the random number generator.\n",FLAT);
+ PhyML_Printf("\t\tMust be an integer.\n");
+ PhyML_Printf("\n");
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t--print_site_lnl%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\t%sPrint the likelihood for each site in file *_phyml_lk.txt.\n",FLAT);
+ PhyML_Printf("\n");
+ #endif
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t--print_trace%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\t%sPrint each phylogeny explored during the tree search process\n",FLAT);
+ PhyML_Printf("\t\t%sin file *_phyml_trace.txt.\n",FLAT);
+ PhyML_Printf("\n");
+ #endif
+
+
+ PhyML_Printf("%s\n\t--run_id %sID_string%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%sAppend the string %sID_string%s at the end of each PhyML output file.\n",FLAT,LINE,FLAT);
+ PhyML_Printf("\t\t%sThis option may be useful when running simulations involving PhyML.\n",FLAT);
+ PhyML_Printf("\n");
+
+ PhyML_Printf("%s\n\t--quiet%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\t%sNo interactive question (for running in batch mode) and quiet output.\n",FLAT);
+ PhyML_Printf("\n");
+
+
+ PhyML_Printf("%s\n\t--no_memory_check%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\t%sNo interactive question for memory usage (for running in batch mode). Normal output otherwise.\n",FLAT);
+ PhyML_Printf("\n");
+
+#ifndef PHYTIME
+ PhyML_Printf("%s\n\t--leave_duplicates%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\t%sPhyML removes duplicate sequences by default. Use this option to leave them in.\n",FLAT);
+ PhyML_Printf("\n");
+#endif
+
+#ifndef PHYTIME
+ PhyML_Printf("%s\n\t--alias_subpatt%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\t%sSite aliasing is generalized at the subtree level. Sometimes lead to faster calculations.\n",FLAT);
+ PhyML_Printf("\t\t%sSee Kosakovsky Pond SL, Muse SV, Sytematic Biology (2004) for an example.\n",FLAT);
+ PhyML_Printf("\n");
+ #endif
+
+ #ifndef PHYTIME
+ PhyML_Printf("%s\n\t--boot_progress_display %snum%s (default=20)\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%snum%s is the frequency at which the bootstrap progress bar will be updated.\n",LINE,FLAT);
+ PhyML_Printf("\t\tMust be an integer.\n");
+ PhyML_Printf("\n");
+ #endif
+
+
+ #ifdef PHYTIME
+ PhyML_Printf("%s\n\t--chain_len %snum%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\t%snum%s is the number of generations or runs of the Markov Chain Monte Carlo. Set to 1E+6 by default. \n",LINE,FLAT);
+ PhyML_Printf("\t\tMust be an integer.\n");
+ PhyML_Printf("\n");
+ #endif
+
+/* #ifdef PHYTIME */
+/* PhyML_Printf("%s\n\t--burnin %snum%s\n",BOLD,LINE,FLAT); */
+/* PhyML_Printf("\t\t%snum%s is the number of generations of runs of the Markov Chain Monte Carlo during the 'burnin' period.\n",LINE,FLAT); */
+/* PhyML_Printf("\t\t%sSet to 1E+5 by default. Must be an integer. \n",FLAT); */
+/* PhyML_Printf("\n"); */
+/* #endif */
+
+ #ifdef PHYTIME
+ PhyML_Printf("%s\n\t--sample_freq %snum%s\n",BOLD,LINE,FLAT);
+ PhyML_Printf("\t\tThe chain is sampled every %snum%s generations. Set to 1E+3 by default. \n",LINE,FLAT);
+ PhyML_Printf("\t\tMust be an integer.\n");
+ PhyML_Printf("\n");
+ #endif
+
+
+ #ifdef PHYTIME
+ PhyML_Printf("%s\n\t--no_sequences%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\tUse this option to run the sampler without sequence data.\n");
+ PhyML_Printf("\n");
+ #endif
+
+
+ #ifdef PHYTIME
+ PhyML_Printf("%s\n\t--fastlk%s\n",BOLD,FLAT);
+ PhyML_Printf("\t\tUse the multivariate normal approximation to the likelihood and speed up calculations\n");
+ PhyML_Printf("\n");
+ #endif
+
+
+ #ifdef PHYML
+ PhyML_Printf("%sPHYLIP-LIKE INTERFACE\n""%s\n\tYou can also use PhyML with no argument, in this case change the value of\n",BOLD,FLAT);
+ PhyML_Printf("%s\ta parameter by typing its corresponding character as shown on screen.\n\n",FLAT);
+ #endif
+
+ #ifdef PHYML
+ PhyML_Printf("%sEXAMPLES\n\n"
+ "%s\tDNA interleaved sequence file, default parameters : ""%s ./phyml -i seqs1"
+ "%s\n\tAA interleaved sequence file, default parameters : ""%s ./phyml -i seqs2 -d aa"
+ "%s\n\tAA sequential sequence file, with customization : ""%s ./phyml -i seqs3 -q -d aa -m JTT -c 4 -a e%s\n",BOLD,FLAT,BOLD,FLAT,BOLD,FLAT,BOLD,FLAT);
+ #endif
+
+ Exit("");
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+
diff --git a/phyml/options.h b/phyml/help.h
similarity index 69%
rename from phyml/options.h
rename to phyml/help.h
index 6dfc238..55ba51b 100644
--- a/phyml/options.h
+++ b/phyml/help.h
@@ -10,12 +10,16 @@ the GNU public licence. See http://www.opensource.org for details.
*/
+#include
+
#ifndef OPTIONS_H
#define OPTIONS_H
+#include "utilities.h"
+#include "cl.h"
+#include "models.h"
+#include "free.h"
+#include "interface.h"
+
void Usage();
-option *Get_Input(int argc, char **argv);
-void Init_Optimiz(optimiz *s_opt);
-void Get_Input_Interactive(option *input);
-void Set_Defaults(option* input);
#endif
diff --git a/phyml/init.c b/phyml/init.c
new file mode 100644
index 0000000..bba1959
--- /dev/null
+++ b/phyml/init.c
@@ -0,0 +1,3727 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+#include "init.h"
+#ifdef BEAGLE
+#include "beagle_utils.h"
+#endif
+
+void Init_Eigen_Struct(eigen *this)
+{
+ this->next = NULL;
+ this->prev = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Scalar_Dbl(scalar_dbl *p)
+{
+ p->v = -1.;
+ p->onoff = ON;
+ p->next = NULL;
+ p->prev = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Scalar_Int(scalar_int *p)
+{
+ p->v = -1.;
+ p->next = NULL;
+ p->prev = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Vect_Dbl(int len, vect_dbl *p)
+{
+ p->len = len;
+ p->next = NULL;
+ p->prev = NULL;
+ p->v = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Vect_Int(int len, vect_int *p)
+{
+ p->len = len;
+ p->next = NULL;
+ p->prev = NULL;
+ p->v = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_String(t_string *ts)
+{
+ ts->len = -1.;
+ ts->next = NULL;
+ ts->prev = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Efrq(phydbl *b_frq, t_efrq *f)
+{
+ f->user_state_freq = NO;
+ f->empirical_state_freq = NO;
+ f->next = NULL;
+ f->prev = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Tree(t_tree *tree, int n_otu)
+{
+ tree->n_otu = n_otu;
+ tree->mat = NULL;
+ tree->n_root = NULL;
+ tree->e_root = NULL;
+ tree->ps_tree = NULL;
+ tree->short_l = NULL;
+ tree->mutmap = NULL;
+ tree->next = NULL;
+ tree->prev = NULL;
+ tree->next = NULL;
+ tree->prev = NULL;
+ tree->mixt_tree = NULL;
+ tree->geo = NULL;
+ tree->xml_root = NULL;
+ tree->extra_tree = NULL;
+ tree->verbose = VL3;
+ tree->edge_list = NULL;
+ tree->node_list = NULL;
+
+ tree->is_mixt_tree = NO;
+ tree->tree_num = 0;
+ tree->depth_curr_path = 0;
+ tree->has_bip = NO;
+ tree->n_moves = 0;
+ tree->bl_from_node_stamps = 0;
+ tree->lock_topo = NO;
+ tree->ps_page_number = 0;
+ tree->init_lnL = UNLIKELY;
+ tree->best_lnL = UNLIKELY;
+ tree->old_lnL = UNLIKELY;
+ tree->c_lnL = UNLIKELY;
+ tree->sum_min_sum_scale = .0;
+ tree->n_swap = 0;
+ tree->best_pars = 1E+5;
+ tree->n_pattern = -1;
+ tree->n_root_pos = -1.;
+ tree->write_labels = YES;
+ tree->write_br_lens = YES;
+ tree->num_curr_branch_available = 0;
+ tree->tip_order_score = .0;
+ tree->write_tax_names = YES;
+ tree->update_alias_subpatt = NO;
+ tree->bl_ndigits = 8;
+ tree->n_short_l = 100;
+ tree->norm_scale = 0.0;
+ tree->br_len_recorded = NO;
+ tree->apply_lk_scaling = YES;
+ tree->dp = 0;
+ tree->ignore_root = YES;
+ tree->ignore_mixt_info = NO;
+ tree->annealing_temp = 0.;
+ tree->both_sides = NO;
+ tree->json_num = 0;
+ tree->update_eigen_lr = NO;
+ tree->use_eigen_lr = NO;
+ tree->eval_alnL = YES;
+ tree->eval_rlnL = YES;
+ tree->eval_glnL = YES;
+ tree->scaling_method = SCALE_FAST;
+ tree->perform_spr_right_away = YES;
+ tree->tip_root = 0;
+ tree->n_edges_traversed = 0;
+ tree->fully_nni_opt = NO;
+ tree->n_tot_bl_opt = 0;
+ tree->numerical_warning = NO;
+
+#ifdef BEAGLE
+ tree->b_inst = UNINITIALIZED;
+#endif
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Edge_Light(t_edge *b, int num)
+{
+ b->num = num;
+ b->bip_score = 0;
+ b->tdist_score = .0;
+ b->dist_btw_edges = .0;
+ b->topo_dist_btw_edges = 0;
+ b->has_zero_br_len = NO;
+ b->n_jumps = 0;
+ b->l_var->v = -1.;
+ b->does_exist = YES;
+ b->l->v = -1.;
+ b->bin_cod_num = -1.;
+ b->l->onoff = ON;
+
+ b->next = NULL;
+ b->prev = NULL;
+ b->next_mixt = NULL;
+ b->prev_mixt = NULL;
+
+ b->p_lk_left = NULL;
+ b->p_lk_rght = NULL;
+ b->p_lk_loc_left = NULL;
+ b->p_lk_loc_rght = NULL;
+ b->Pij_rr = NULL;
+ b->label = NULL;
+
+ b->pars_l = NULL;
+ b->pars_r = NULL;
+ b->ui_l = NULL;
+ b->ui_r = NULL;
+ b->p_pars_l = NULL;
+ b->p_pars_r = NULL;
+ b->n_diff_states_l = NULL;
+ b->n_diff_states_r = NULL;
+
+ b->update_partial_lk_left = YES;
+ b->update_partial_lk_rght = YES;
+
+#ifdef BEAGLE
+ b->p_lk_left_idx = num;
+ b->p_lk_rght_idx = UNINITIALIZED; //Will be initialized later when the total number of branches is known (i.e. in Make_Tree_From_Scratch())
+ b->Pij_rr_idx = num;
+ b->p_lk_tip_idx = UNINITIALIZED; //Will be initialized later only if this branch is connected to a tip
+#endif
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Node_Light(t_node *n, int num)
+{
+ n->num = num;
+ n->tax = -1;
+ n->dist_to_root = .0;
+ n->common = 1;
+ n->ext_node = NULL;
+ n->name = NULL;
+ n->ori_name = NULL;
+ n->c_seq = NULL;
+ n->c_seq_anc = NULL;
+ n->y_rank = 0.;
+ n->y_rank_ori = 0.;
+ n->y_rank_max = 0.;
+ n->y_rank_min = 0.;
+ n->anc = NULL;
+ n->rank = 0;
+ n->match_node = NULL;
+ n->id_rank = 0;
+ n->next = NULL;
+ n->prev = NULL;
+ n->n_cal = 0;
+ n->ldsk = NULL;
+ n->rk_next = NULL;
+ n->rk_prev = NULL;
+ n->label = NULL;
+ /* n->next = NULL; */
+ /* n->prev = NULL; */
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_NNI(t_nni *a_nni)
+{
+ a_nni->left = NULL;
+ a_nni->rght = NULL;
+ a_nni->b = NULL;
+ a_nni->init_l = NULL;
+ a_nni->init_v = NULL;
+ a_nni->init_lk = .0;
+ a_nni->score = +1.0;
+ a_nni->best_l = NULL;
+ a_nni->best_v = NULL;
+ a_nni->swap_node_v1 = NULL;
+ a_nni->swap_node_v2 = NULL;
+ a_nni->swap_node_v3 = NULL;
+ a_nni->swap_node_v4 = NULL;
+ a_nni->lk0 = UNLIKELY;
+ a_nni->lk1 = UNLIKELY;
+ a_nni->lk2 = UNLIKELY;
+ a_nni->l0 = NULL;
+ a_nni->l1 = NULL;
+ a_nni->l2 = NULL;
+ a_nni->v0 = NULL;
+ a_nni->v1 = NULL;
+ a_nni->v2 = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Nexus_Format(nexcom **com)
+{
+
+ /*****************************/
+
+ strcpy(com[0]->name,"dimensions");
+ com[0]->nparm = 2;
+ com[0]->nxt_token_t = NEXUS_PARM;
+ com[0]->cur_token_t = NEXUS_COM;
+
+ com[0]->parm[0] = Make_Nexus_Parm();
+ strcpy(com[0]->parm[0]->name,"ntax");
+ com[0]->parm[0]->fp = Read_Nexus_Dimensions;
+ com[0]->parm[0]->com = com[0];
+ com[0]->parm[0]->nxt_token_t = NEXUS_EQUAL;
+ com[0]->parm[0]->cur_token_t = NEXUS_PARM;
+
+ com[0]->parm[1] = Make_Nexus_Parm();
+ strcpy(com[0]->parm[1]->name,"nchar");
+ com[0]->parm[1]->fp = Read_Nexus_Dimensions;
+ com[0]->parm[1]->com = com[0];
+ com[0]->parm[1]->nxt_token_t = NEXUS_EQUAL;
+ com[0]->parm[1]->cur_token_t = NEXUS_PARM;
+
+ /*****************************/
+
+ strcpy(com[1]->name,"format");
+ com[1]->nparm = 11;
+ com[1]->nxt_token_t = NEXUS_PARM;
+ com[1]->cur_token_t = NEXUS_COM;
+
+ com[1]->parm[0] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[0]->name,"datatype");
+ com[1]->parm[0]->fp = Read_Nexus_Format;
+ com[1]->parm[0]->com = com[1];
+ com[1]->parm[0]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[0]->cur_token_t = NEXUS_PARM;
+
+ com[1]->parm[1] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[1]->name,"respectcase");
+ com[1]->parm[1]->fp = Read_Nexus_Format;
+ com[1]->parm[1]->com = com[1];
+ com[1]->parm[1]->nxt_token_t = NEXUS_PARM;
+ com[1]->parm[1]->cur_token_t = NEXUS_VALUE;
+
+ com[1]->parm[2] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[2]->name,"missing");
+ com[1]->parm[2]->fp = Read_Nexus_Format;
+ com[1]->parm[2]->com = com[1];
+ com[1]->parm[2]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[2]->cur_token_t = NEXUS_PARM;
+
+ com[1]->parm[3] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[3]->name,"gap");
+ com[1]->parm[3]->fp = Read_Nexus_Format;
+ com[1]->parm[3]->com = com[1];
+ com[1]->parm[3]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[3]->cur_token_t = NEXUS_PARM;
+
+ com[1]->parm[4] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[4]->name,"symbols");
+ com[1]->parm[4]->fp = Read_Nexus_Format;
+ com[1]->parm[4]->com = com[1];
+ com[1]->parm[4]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[4]->cur_token_t = NEXUS_PARM;
+
+ com[1]->parm[5] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[5]->name,"equate");
+ com[1]->parm[5]->fp = Read_Nexus_Format;
+ com[1]->parm[5]->com = com[1];
+ com[1]->parm[5]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[5]->cur_token_t = NEXUS_PARM;
+
+ com[1]->parm[6] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[6]->name,"matchchar");
+ com[1]->parm[6]->fp = Read_Nexus_Format;
+ com[1]->parm[6]->com = com[1];
+ com[1]->parm[6]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[6]->cur_token_t = NEXUS_PARM;
+
+ com[1]->parm[7] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[7]->name,"transpose");
+ com[1]->parm[7]->fp = Read_Nexus_Format;
+ com[1]->parm[7]->com = com[1];
+ com[1]->parm[7]->nxt_token_t = NEXUS_PARM;
+ com[1]->parm[7]->cur_token_t = NEXUS_VALUE;
+
+ com[1]->parm[8] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[8]->name,"interleave");
+ com[1]->parm[8]->fp = Read_Nexus_Format;
+ com[1]->parm[8]->com = com[1];
+ com[1]->parm[8]->nxt_token_t = NEXUS_PARM;
+ com[1]->parm[8]->cur_token_t = NEXUS_VALUE;
+
+ com[1]->parm[9] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[9]->name,"items");
+ com[1]->parm[9]->fp = Read_Nexus_Format;
+ com[1]->parm[9]->com = com[1];
+ com[1]->parm[9]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[9]->cur_token_t = NEXUS_PARM;
+
+ com[1]->parm[10] = Make_Nexus_Parm();
+ strcpy(com[1]->parm[10]->name,"statesformat");
+ com[1]->parm[10]->fp = Read_Nexus_Format;
+ com[1]->parm[10]->com = com[1];
+ com[1]->parm[10]->nxt_token_t = NEXUS_EQUAL;
+ com[1]->parm[10]->cur_token_t = NEXUS_PARM;
+
+ /*****************************/
+
+ strcpy(com[2]->name,"eliminate");
+ com[2]->nparm = 0;
+ com[2]->nxt_token_t = NEXUS_VALUE;
+ com[2]->cur_token_t = NEXUS_COM;
+
+ /*****************************/
+
+ strcpy(com[3]->name,"taxlabels");
+ com[3]->nparm = 0;
+ com[3]->nxt_token_t = -1;
+ com[3]->cur_token_t = -1;
+
+ /*****************************/
+
+ strcpy(com[4]->name,"charstatelabels");
+ com[4]->nparm = 0;
+ com[4]->nxt_token_t = -1;
+ com[4]->cur_token_t = -1;
+
+ /*****************************/
+
+ strcpy(com[5]->name,"charlabels");
+ com[5]->nparm = 0;
+ com[5]->nxt_token_t = -1;
+ com[5]->cur_token_t = -1;
+
+ /*****************************/
+
+ strcpy(com[6]->name,"statelabels");
+ com[6]->nparm = 0;
+ com[6]->nxt_token_t = -1;
+ com[6]->cur_token_t = -1;
+
+ /*****************************/
+
+ strcpy(com[7]->name,"matrix");
+ com[7]->nparm = 1;
+ com[7]->nxt_token_t = NEXUS_COM;
+ com[7]->cur_token_t = NEXUS_VALUE; /* This will allow us to skip directly
+ to the matrix reading function */
+
+ com[7]->parm[0] = Make_Nexus_Parm();
+ strcpy(com[7]->parm[0]->name,"matrix");
+ com[7]->parm[0]->fp = Read_Nexus_Matrix;
+ com[7]->parm[0]->com = com[7];
+ com[7]->parm[0]->nxt_token_t = NEXUS_COM;
+ com[7]->parm[0]->cur_token_t = -1;
+
+ /*****************************/
+
+ strcpy(com[8]->name,"begin");
+ com[8]->nparm = 3;
+
+ com[8]->nxt_token_t = NEXUS_PARM;
+ com[8]->cur_token_t = NEXUS_COM;
+
+ com[8]->parm[0] = Make_Nexus_Parm();
+ strcpy(com[8]->parm[0]->name,"data");
+ com[8]->parm[0]->fp = Read_Nexus_Begin;
+ com[8]->parm[0]->com = com[8];
+ com[8]->parm[0]->nxt_token_t = NEXUS_COM;
+ com[8]->parm[0]->cur_token_t = NEXUS_PARM;
+
+
+ com[8]->parm[1] = Make_Nexus_Parm();
+ strcpy(com[8]->parm[1]->name,"trees");
+ com[8]->parm[1]->fp = Read_Nexus_Begin;
+ com[8]->parm[1]->com = com[8];
+ com[8]->parm[1]->nxt_token_t = NEXUS_COM;
+ com[8]->parm[1]->cur_token_t = NEXUS_PARM;
+
+
+ com[8]->parm[2] = Make_Nexus_Parm();
+ strcpy(com[8]->parm[2]->name,"taxa");
+ com[8]->parm[2]->fp = Read_Nexus_Taxa;
+ com[8]->parm[2]->com = com[8];
+ com[8]->parm[2]->nxt_token_t = NEXUS_COM;
+ com[8]->parm[2]->cur_token_t = NEXUS_VALUE;
+
+
+ /*****************************/
+
+ strcpy(com[9]->name,"end");
+ com[9]->nparm = 0;
+ com[9]->nxt_token_t = -1;
+ com[9]->cur_token_t = -1;
+
+ /*****************************/
+
+ strcpy(com[10]->name,"translate");
+ com[10]->nparm = 1;
+ com[10]->nxt_token_t = NEXUS_COM;
+ com[10]->cur_token_t = NEXUS_VALUE;
+
+ com[10]->parm[0] = Make_Nexus_Parm();
+ strcpy(com[10]->parm[0]->name,"translate");
+ com[10]->parm[0]->fp = Read_Nexus_Translate;
+ com[10]->parm[0]->com = com[10];
+ com[10]->parm[0]->nxt_token_t = NEXUS_COM;
+ com[10]->parm[0]->cur_token_t = -1;
+
+ /*****************************/
+
+ strcpy(com[11]->name,"tree");
+ com[11]->nparm = 1;
+ com[11]->nxt_token_t = NEXUS_COM;
+ com[11]->cur_token_t = NEXUS_VALUE;
+
+ com[11]->parm[0] = Make_Nexus_Parm();
+ strcpy(com[11]->parm[0]->name,"tree");
+ com[11]->parm[0]->fp = Read_Nexus_Tree;
+ com[11]->parm[0]->com = com[11];
+ com[11]->parm[0]->nxt_token_t = -1;
+ com[11]->parm[0]->cur_token_t = -1;
+
+
+ /*****************************/
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Mat(matrix *mat, calign *data)
+{
+ int i;
+
+ mat->n_otu = data->n_otu;
+ mat->r = mat->n_otu;
+ mat->curr_int = mat->n_otu;
+ mat->method = 1;
+
+ for(i=0;in_otu;i++)
+ {
+ strcpy(mat->name[i],data->c_seq[i]->name);
+ mat->on_off[i] = 1;
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Set_Defaults_Input(option* io)
+{
+ io->fp_in_align = NULL;
+ io->fp_in_tree = NULL;
+ io->fp_in_constraint_tree = NULL;
+ io->fp_out_tree = NULL;
+ io->fp_out_trees = NULL;
+ io->fp_out_boot_tree = NULL;
+ io->fp_out_boot_stats = NULL;
+ io->fp_out_stats = NULL;
+ io->fp_out_ancestral_seq = NULL;
+ io->fp_out_ancestral_tree = NULL;
+ io->fp_in_coord = NULL;
+ io->fp_out_trace = NULL;
+ io->fp_weight_file = NULL;
+ io->fp_out_json_trace = NULL;
+ io->fp_out_lk = NULL;
+ io->fp_out_trace = NULL;
+ io->long_tax_names = NULL;
+ io->short_tax_names = NULL;
+ io->lon = NULL;
+ io->lat = NULL;
+ io->z_scores = NULL;
+ io->cstr_tree = NULL;
+ io->next = NULL;
+ io->prev = NULL;
+ io->tree = NULL;
+ io->mod = NULL;
+ strcpy(io->nt_or_cd,"nucleotides");
+ io->tbe_bootstrap = NO;
+ io->n_data_sets = 1;
+ io->interleaved = 1;
+ io->in_tree = 0;
+ io->out_tree_file_open_mode = 1;
+ io->out_stats_file_open_mode = 1;
+ io->init_len = -1;
+ io->n_otu = -1;
+ io->n_data_set_asked = -1;
+ io->print_boot_trees = 1;
+ io->n_part = 1;
+ io->ratio_test = ABAYES;
+ io->multigene = 0;
+ io->config_multigene = 0;
+ io->curr_interface = 0;
+ io->r_seed = -1;
+ io->collapse_boot = 0;
+ io->random_boot_seq_order = YES;
+ io->print_trace = NO;
+ io->print_json_trace = NO;
+ io->print_site_lnl = NO;
+ io->m4_model = NO;
+ io->rm_ambigu = NO;
+ io->append_run_ID = NO;
+ io->quiet = NO;
+ io->datatype = NT;
+ io->colalias = YES;
+ io->data_file_format = PHYLIP;
+ io->tree_file_format = PHYLIP;
+ io->boot_prog_every = 20;
+ io->mem_question = YES;
+ io->do_alias_subpatt = NO;
+ io->lk_approx = EXACT;
+ io->codpos = -1;
+ io->mutmap = NO;
+ io->state_len = 1;
+ io->ancestral = NO;
+ io->use_xml = NO;
+ io->has_io_weights = NO;
+ io->do_boot = NO;
+ io->do_alrt = YES;
+ io->do_tbe = NO;
+ io->print_node_num = NO;
+ io->print_support_val = NO;
+ io->n_boot_replicates = 0;
+
+#ifdef BEAGLE
+ io->beagle_resource = 0;
+#endif
+ io->precision = 0;
+
+ MCMC_Init_MCMC_Struct(NULL,io,io->mcmc);
+ RATES_Init_Rate_Struct(io->rates,NULL,-1);
+ io->rates->model = LOGNORMAL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Rmat(t_rmat *rmat)
+{
+ rmat->n_diff_rr = 1;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Set_Defaults_Model(t_mod *mod)
+{
+ Set_Defaults_Ras(mod->ras);
+
+ strcpy(mod->modelname->s,"HKY85");
+ strcpy(mod->custom_mod_string->s,"000000");
+ mod->next = NULL;
+ mod->prev = NULL;
+ mod->next_mixt = NULL;
+ mod->prev_mixt = NULL;
+ mod->r_mat = NULL;
+ mod->e_frq = NULL;
+ mod->whichmodel = HKY85;
+ mod->n_mixt_classes = 0;
+ mod->mod_num = 0;
+ mod->update_eigen = NO;
+ mod->is_mixt_mod = NO;
+
+ mod->kappa->v = 4.0;
+ mod->lambda->v = 1.0;
+ mod->l_var_sigma = 1.E-2;
+ mod->e_frq_weight->v = 1.0;
+ mod->r_mat_weight->v = 1.0;
+
+ mod->ns = 4;
+ mod->use_m4mod = NO;
+ mod->ras->gamma_median = NO;
+ mod->m4mod = NULL;
+
+ /* mod->r_mat->n_diff_rr = 0; */
+ /* mod->r_mat->rr = NULL; */
+ /* mod->r_mat->rr_val = NULL; */
+ /* mod->r_mat->n_rr_per_cat = NULL; */
+
+ mod->io = NULL;
+ mod->log_l = NO;
+ mod->gamma_mgf_bl = NO;
+ mod->br_len_mult->v = 1.0;
+
+
+#if !(defined PHYTIME || defined PHYREX)
+ mod->l_min = 1.E-8;
+ mod->l_max = 100.0;
+#else
+ mod->l_min = 1.E-8;
+ mod->l_max = 1.E+3;
+#endif
+
+ mod->l_var_min = mod->l_min;
+ mod->l_var_max = mod->l_max;
+
+ mod->br_len_mult->v = 1.0;
+ mod->br_len_mult_unscaled->v = 1.0;
+ mod->augmented = NO;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Set_Defaults_Ras(t_ras *ras)
+{
+ ras->n_catg = 4;
+ ras->normalise_rr = YES;
+ ras->pinvar->v = 0.0;
+ ras->alpha->v = 1.0;
+ ras->invar = NO;
+ ras->free_mixt_rates = NO;
+ ras->parent_class_number = 0;
+ ras->init_r_proba = YES;
+ ras->init_rr = YES;
+ ras->sort_rate_classes = NO;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Set_Defaults_Optimiz(t_opt *s_opt)
+{
+ s_opt->last_opt = YES;
+ s_opt->opt_subst_param = YES;
+ s_opt->opt_alpha = YES;
+ s_opt->opt_kappa = YES;
+ s_opt->opt_bl = YES;
+ s_opt->opt_lambda = NO;
+ s_opt->opt_pinvar = NO;
+ s_opt->opt_cov_delta = NO;
+ s_opt->opt_cov_alpha = NO;
+ s_opt->opt_cov_free_rates = NO;
+ s_opt->opt_rr = NO;
+ s_opt->init_lk = UNLIKELY;
+ s_opt->n_it_max = 1000;
+ s_opt->opt_topo = YES;
+ s_opt->topo_search = NNI_MOVE;
+ s_opt->random_input_tree = 0;
+ s_opt->n_rand_starts = 5;
+ s_opt->brent_it_max = BRENT_IT_MAX;
+ s_opt->steph_spr = YES;
+ s_opt->opt_br_len_mult = NO;
+ s_opt->min_n_triple_moves = 20;
+ s_opt->max_rank_triple_move = 0;
+ s_opt->n_improvements = 0;
+ s_opt->max_spr_depth = 0;
+ s_opt->opt_clock_r = YES;
+
+ s_opt->min_diff_lk_local = 1.E-03;
+ s_opt->min_diff_lk_global = 1.E-03;
+ s_opt->min_diff_lk_move = 1.E-03;
+
+ s_opt->p_moves_to_examine = 0.15;
+ s_opt->fast_nni = NO;
+ s_opt->greedy = NO;
+ s_opt->general_pars = NO;
+ s_opt->tree_size_mult = 1;
+ s_opt->opt_five_branch = YES;
+ s_opt->nni_br_len_opt = YES;
+
+ s_opt->pars_thresh = 5;
+
+ s_opt->hybrid_thresh = NO;
+ s_opt->quickdirty = NO;
+ s_opt->spr_pars = YES;
+ s_opt->spr_lnL = NO;
+ s_opt->min_depth_path = 0;
+ s_opt->eval_list_regraft = NO;
+
+ s_opt->max_depth_path = 2000;
+ s_opt->deepest_path = 2000;
+ s_opt->max_delta_lnL_spr = 2000000.;
+ s_opt->max_delta_lnL_spr_current = 0.0;
+ s_opt->worst_lnL_spr = BIG;
+
+ s_opt->br_len_in_spr = 10;
+ s_opt->opt_free_mixt_rates = YES;
+ s_opt->constrained_br_len = NO;
+ s_opt->opt_gamma_br_len = NO;
+ s_opt->first_opt_free_mixt_rates = YES;
+
+ s_opt->wim_n_rgrft = -1;
+ s_opt->wim_n_globl = -1;
+ s_opt->wim_max_dist = -1;
+ s_opt->wim_n_optim = -1;
+ s_opt->wim_n_best = -1;
+ s_opt->wim_inside_opt = 0;
+
+ s_opt->opt_rmat_weight = NO;
+ s_opt->opt_efrq_weight = NO;
+
+ s_opt->skip_tree_traversal = NO;
+ s_opt->serial_free_rates = YES;
+
+ s_opt->curr_opt_free_rates = NO;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void XML_Init_Attribute(xml_attr *attr)
+{
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void XML_Init_Node(xml_node *parent, xml_node *new_node, char *name)
+{
+ if(name) strcpy(new_node->name,name);
+
+ new_node->parent = parent ? parent : NULL;
+ new_node->next = NULL;
+ new_node->prev = NULL;
+ new_node->child = NULL;
+ new_node->ds->obj = NULL;
+ new_node->ds->next = NULL;
+
+ if(parent)
+ {
+ if(!parent->child)
+ {
+ parent->child = new_node;
+ }
+ else
+ {
+ xml_node *node = parent->child;
+ while(node->next) node = node->next;
+ node->next = new_node;
+ new_node->prev = node;
+ }
+ }
+
+ new_node->attr = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void RATES_Init_Rate_Struct(t_rate *rates, t_rate *existing_rates, int n_otu)
+{
+ int i;
+
+ if(existing_rates && existing_rates->model != -1)
+ {
+ rates->model = existing_rates->model;
+ }
+ else
+ {
+ rates->model = NONE;
+ }
+
+ rates->met_within_gibbs = NO;
+ rates->c_lnL_rates = UNLIKELY;
+ rates->c_lnL_times = UNLIKELY;
+ rates->c_lnL_jps = UNLIKELY;
+ rates->adjust_rates = 0;
+ rates->use_rates = 1;
+ rates->lexp = 1.E-3;
+ rates->norm_fact = 1.0;
+ rates->inflate_var = 1.0;
+ rates->nd_t_recorded = NO;
+ rates->br_r_recorded = NO;
+
+ rates->birth_rate = 1.E-1;
+ rates->birth_rate_min = 1.E-6;
+ rates->birth_rate_max = 1.E+0;
+ rates->birth_rate_pivot = 1.E-1;
+
+ rates->death_rate = 1.E-1;
+ rates->death_rate_min = 1.E-6;
+ rates->death_rate_max = 1.E+0;
+ rates->death_rate_pivot = 1.E-1;
+
+ rates->max_rate = 100.0;
+ rates->min_rate = 0.001;
+
+ rates->clock_r = 1.E-4;
+ rates->min_clock = 1.E-10;
+ rates->max_clock = 1.E+0;
+
+ /* rates->clock_r = 3.E-4; */
+ /* rates->max_clock = 1.E-3; */
+ /* rates->min_clock = 1.E-5; */
+
+ rates->nu = 1.0E-1;
+ rates->min_nu = 0.0;
+ rates->max_nu = 2.0;
+
+ /* rates->max_nu = 2.0; */
+
+ /* rates->nu = 1.E-4; */
+ /* rates->max_nu = 1.E-1; */
+ /* rates->min_nu = 1.E-5; */
+
+ rates->min_dt = 0.0;
+
+ rates->step_rate = 1.E-4;
+ rates->approx = 1;
+ rates->bl_from_rt = NO;
+
+ rates->update_mean_l = NO;
+ rates->update_cov_l = NO;
+ rates->n_cal = 0;
+
+ rates->p_max = 0.01;
+
+ rates->true_tree_size = 0.0;
+
+ if(n_otu > 0)
+ {
+ for(i=0;i<(2*n_otu-2)*(2*n_otu-2);++i) rates->cov_l[i] = 0.0;
+
+ for(i=0;i<2*n_otu-2;++i)
+ {
+ rates->n_jps[i] = -1;
+ rates->t_jps[i] = -1;
+ rates->mean_r[i] = 1.0;
+ rates->mean_l[i] = 0.0;
+ rates->cur_l[i] = 0.01;
+ }
+
+ for(i=0;i<2*n_otu-1;++i)
+ {
+ rates->nd_r[i] = 1.0;
+ rates->br_r[i] = 1.0;
+
+ rates->mean_t[i] = 0.0;
+ rates->nd_t[i] = 0.0;
+ rates->true_t[i] = 0.0;
+ if(i < n_otu)
+ {
+ rates->t_has_prior[i] = YES;
+ rates->t_prior_max[i] = 0.0;
+ rates->t_prior_min[i] = 0.0;
+ }
+ else
+ {
+ rates->t_has_prior[i] = NO;
+ rates->t_prior_max[i] = 0.0;
+ rates->t_prior_min[i] = -BIG;
+ }
+
+ rates->br_do_updt[i] = YES;
+ rates->has_survived[i] = NO;
+
+ rates->t_rank[i] = i;
+ }
+ }
+
+ rates->update_time_norm_const = NO;
+ rates->is_asynchronous = NO;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_One_Spr(t_spr *a_spr)
+{
+ a_spr->lnL = UNLIKELY;
+ a_spr->pars = 1E+5;
+ a_spr->depth_path = 0;
+ a_spr->dist = 0;
+ a_spr->init_target_l = NULL;
+ a_spr->init_target_v = NULL;
+ a_spr->l0 = NULL;
+ a_spr->l1 = NULL;
+ a_spr->l2 = NULL;
+ a_spr->v0 = NULL;
+ a_spr->v1 = NULL;
+ a_spr->v2 = NULL;
+ a_spr->n_link = NULL;
+ a_spr->n_opp_to_link = NULL;
+ a_spr->b_opp_to_link = NULL;
+ a_spr->b_target = NULL;
+ a_spr->b_init_target = NULL;
+ a_spr->next = NULL;
+ a_spr->prev = NULL;
+ a_spr->next = NULL;
+ a_spr->prev = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Target_Tip(t_clad *clade, t_tree *tree)
+{
+ int i,j;
+
+ for(i=0;in_tax;++i)
+ {
+ for(j=0;jn_otu;++j)
+ {
+ if(!strcmp(tree->a_nodes[j]->name,clade->tax_list[i]))
+ {
+ clade->tip_list[i] = tree->a_nodes[j];
+ break;
+ }
+ }
+ assert(j != tree->n_otu);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Model(calign *data, t_mod *mod, option *io)
+{
+ int i,j;
+ phydbl sum,aux;
+ int result;
+ phydbl *dr, *di, *space;
+
+ assert(data);
+ assert(mod);
+ assert(io);
+
+#ifdef BEAGLE
+ mod->b_inst = UNINITIALIZED; //prevents calling an uninitialized BEAGLE instance (for ex: prevents Update_Eigen(), Update_RAS(), from calling BEAGLE)
+ mod->optimizing_topology = false;
+#endif
+
+ mod->ns = io->mod->ns;
+
+ if(io->datatype == GENERIC) mod->whichmodel = JC69;
+
+ dr = (phydbl *)mCalloc( mod->ns,sizeof(phydbl));
+ di = (phydbl *)mCalloc( mod->ns,sizeof(phydbl));
+ space = (phydbl *)mCalloc(2*mod->ns,sizeof(phydbl));
+
+ if(mod->log_l == YES)
+ {
+ mod->l_min = log(mod->l_min);
+ mod->l_max = log(mod->l_max);
+ }
+
+ // Init unscaled relative rate frequencies
+ if(mod->ras->init_r_proba == YES)
+ {
+ for(i=0;iras->n_catg;i++) mod->ras->gamma_r_proba->v[i] = (phydbl)1./mod->ras->n_catg;
+ for(i=0;iras->n_catg;i++) mod->ras->gamma_r_proba_unscaled->v[i] = (phydbl)(i+1);
+ }
+ else
+ {
+ mod->ras->gamma_r_proba_unscaled->v[mod->ras->n_catg-1] = 1.0;
+ for(i=0;iras->n_catg;i++)
+ {
+ sum = 0.0;
+ For(j,i+1) sum += mod->ras->gamma_r_proba->v[j];
+ mod->ras->gamma_r_proba_unscaled->v[i] = sum * mod->ras->gamma_r_proba_unscaled->v[mod->ras->n_catg-1];
+ }
+ }
+
+ // Init unscaled relative rates
+ if(mod->ras->init_rr == YES)
+ {
+ if(mod->ras->n_catg > 1)
+ {
+ for(i=0;iras->n_catg;i++) mod->ras->gamma_rr->v[i] = (phydbl)i;
+ for(i=0;iras->n_catg;i++) mod->ras->gamma_rr_unscaled->v[i] = (phydbl)i;
+ }
+ else
+ {
+ mod->ras->gamma_rr->v[0] = 1.0;
+ mod->ras->gamma_rr_unscaled->v[0] = 1.0;
+ }
+ }
+ else
+ {
+ for(i=0;iras->n_catg;i++) mod->ras->gamma_rr_unscaled->v[i] = mod->ras->gamma_rr->v[i];
+ }
+
+ if(io->datatype == NT)
+ {
+ /* Set the substitution parameters to their default values
+ if they are not fixed by the user */
+
+ if(mod->s_opt->opt_kappa == YES)
+ {
+ mod->kappa->v = 4.0;
+ mod->lambda->v = 1.0;
+ }
+
+
+ if(mod->whichmodel == CUSTOM)
+ {
+ for(i=0;i<6;i++)
+ {
+ mod->r_mat->rr_val->v[i] = 0.0;
+ mod->r_mat->rr->v[i] = 1.0;
+ }
+
+ /* Condition below is true if custom model corresponds to TN93 or K80 */
+ if(mod->r_mat->rr_num->v[AC] == mod->r_mat->rr_num->v[AT] &&
+ mod->r_mat->rr_num->v[AT] == mod->r_mat->rr_num->v[CG] &&
+ mod->r_mat->rr_num->v[CG] == mod->r_mat->rr_num->v[GT] &&
+ mod->r_mat->rr_num->v[AG] != mod->r_mat->rr_num->v[AC] &&
+ mod->r_mat->rr_num->v[CT] != mod->r_mat->rr_num->v[AC])
+ {
+ for(i=1;ir_mat->n_diff_rr;i++)
+ {
+ mod->r_mat->rr_val->v[i] = log(2.0);
+ mod->r_mat->rr->v[i] = 2.0;
+ }
+ }
+ else if(mod->r_mat->n_diff_rr == 6) /* Custom <-> GTR model */
+ {
+ mod->r_mat->rr_val->v[AG] = log(2.0);
+ mod->r_mat->rr_val->v[CT] = log(2.0);
+
+ mod->r_mat->rr->v[AG] = 2.0;
+ mod->r_mat->rr->v[CT] = 2.0;
+ }
+ }
+ else if(mod->whichmodel == GTR)
+ {
+ if(mod->s_opt->opt_rr == YES)
+ {
+ for(i=0;i<6;i++) mod->r_mat->rr_val->v[i] = 0.0;
+ for(i=0;i<6;i++) mod->r_mat->rr->v[i] = 1.0;
+
+ mod->r_mat->rr_val->v[AG] = log(2.0);
+ mod->r_mat->rr_val->v[CT] = log(2.0);
+
+ mod->r_mat->rr->v[AG] = 2.0;
+ mod->r_mat->rr->v[CT] = 2.0;
+ }
+ }
+ }
+
+ if(mod->s_opt->opt_alpha) mod->ras->alpha->v = 1.0;
+ if(mod->s_opt->opt_pinvar) mod->ras->pinvar->v = 0.2;
+
+ if(io->datatype == NT) /* Nucleotides */
+ {
+ /* init for nucleotides */
+
+ if(mod->whichmodel == JC69)
+ {
+ mod->e_frq->pi->v[0] = mod->e_frq->pi->v[1] = mod->e_frq->pi->v[2] = mod->e_frq->pi->v[3] = .25;
+ mod->kappa->v = 1.;
+ mod->s_opt->opt_state_freq = NO;
+ mod->s_opt->opt_kappa = NO;
+ mod->s_opt->opt_lambda = NO;
+ mod->update_eigen = NO;
+ }
+
+ if(mod->whichmodel == K80)
+ {
+ mod->e_frq->pi->v[0] = mod->e_frq->pi->v[1] = mod->e_frq->pi->v[2] = mod->e_frq->pi->v[3] = .25;
+ mod->s_opt->opt_state_freq = NO;
+ mod->s_opt->opt_lambda = NO;
+ mod->update_eigen = NO;
+ }
+
+ if(mod->whichmodel == F81)
+ {
+ if(mod->e_frq->user_state_freq == NO) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ else for(i=0;i<4;i++) mod->e_frq->pi->v[i] = mod->e_frq->user_b_freq->v[i];
+ for(i=0;ins;i++) mod->e_frq->pi_unscaled->v[i] = log(mod->e_frq->pi->v[i]);
+ mod->kappa->v = 1.;
+ mod->update_eigen = NO;
+ }
+
+ if(mod->whichmodel == F84)
+ {
+ if(mod->e_frq->user_state_freq == NO) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ else for(i=0;i<4;i++) mod->e_frq->pi->v[i] = mod->e_frq->user_b_freq->v[i];
+ for(i=0;ins;i++) mod->e_frq->pi_unscaled->v[i] = log(mod->e_frq->pi->v[i]);
+ aux = ((mod->e_frq->pi->v[0]+mod->e_frq->pi->v[2])-(mod->e_frq->pi->v[1]+mod->e_frq->pi->v[3]))/(2.*mod->kappa->v);
+ mod->lambda->v = ((mod->e_frq->pi->v[1]+mod->e_frq->pi->v[3]) + aux)/((mod->e_frq->pi->v[0]+mod->e_frq->pi->v[2]) - aux);
+ mod->update_eigen = NO;
+ }
+
+ if(mod->whichmodel == TN93)
+ {
+ if(mod->e_frq->user_state_freq == NO)
+ Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ else
+ for(i=0;i<4;i++)
+ mod->e_frq->pi->v[i] = mod->e_frq->user_b_freq->v[i];
+ for(i=0;ins;i++)
+ mod->e_frq->pi_unscaled->v[i] = log(mod->e_frq->pi->v[i]);
+ mod->update_eigen = NO;
+ if(io->mod->s_opt->opt_kappa) io->mod->s_opt->opt_lambda = YES;
+
+ }
+
+ if(mod->whichmodel == HKY85)
+ {
+ if(mod->e_frq->user_state_freq == NO)
+ Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ else
+ for(i=0;i<4;i++)
+ mod->e_frq->pi->v[i] = mod->e_frq->user_b_freq->v[i];
+ for(i=0;ins;i++)
+ mod->e_frq->pi_unscaled->v[i] = log(mod->e_frq->pi->v[i]);
+ mod->update_eigen = NO;
+ }
+
+ if(mod->whichmodel == GTR)
+ {
+ if (mod->e_frq->user_state_freq == NO)
+ Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ else
+ for(i=0;i<4;i++)
+ mod->e_frq->pi->v[i] = mod->e_frq->user_b_freq->v[i];
+ for(i=0;ins;i++)
+ mod->e_frq->pi_unscaled->v[i] = log(mod->e_frq->pi->v[i]);
+ mod->kappa->v = 1.;
+ mod->update_eigen = NO;
+ }
+
+ if(mod->whichmodel == CUSTOM)
+ {
+ if(mod->e_frq->user_state_freq == NO) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ else for(i=0;i<4;i++) mod->e_frq->pi->v[i] = mod->e_frq->user_b_freq->v[i];
+ for(i=0;ins;i++) mod->e_frq->pi_unscaled->v[i] = log(mod->e_frq->pi->v[i]);
+ mod->kappa->v = 1.;
+ mod->update_eigen = NO;
+ }
+
+ if(mod->whichmodel == GTR)
+ {
+ mod->custom_mod_string->s[0] = '0';
+ mod->custom_mod_string->s[1] = '1';
+ mod->custom_mod_string->s[2] = '2';
+ mod->custom_mod_string->s[3] = '3';
+ mod->custom_mod_string->s[4] = '4';
+ mod->custom_mod_string->s[5] = '5';
+ Translate_Custom_Mod_String(mod);
+ }
+ }
+ else if(mod->io->datatype == AA)
+ {
+
+ /* init for amino-acids */
+ /* see comments of PMat_Empirical for details */
+ /* read pi and Q from file */
+
+ /* These initialisations are needed when analysing multiple
+ * data sets
+ */
+ For(i,mod->ns*mod->ns) mod->r_mat->qmat->v[i] = .0;
+ For(i,mod->ns ) mod->e_frq->pi->v[i] = .0;
+
+ switch(mod->whichmodel)
+ {
+ case DAYHOFF :
+ {
+ Init_Qmat_Dayhoff(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case JTT :
+ {
+ Init_Qmat_JTT(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case MTREV :
+ {
+ Init_Qmat_MtREV(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case LG :
+ {
+ Init_Qmat_LG(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case WAG :
+ {
+ Init_Qmat_WAG(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case DCMUT :
+ {
+ Init_Qmat_DCMut(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case RTREV :
+ {
+ Init_Qmat_RtREV(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case CPREV :
+ {
+ Init_Qmat_CpREV(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case VT :
+ {
+ Init_Qmat_VT(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case BLOSUM62 :
+ {
+ Init_Qmat_Blosum62(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case MTMAM :
+ {
+ Init_Qmat_MtMam(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case MTART :
+ {
+ Init_Qmat_MtArt(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case HIVW :
+ {
+ Init_Qmat_HIVw(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case HIVB :
+ {
+ Init_Qmat_HIVb(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case AB :
+ {
+ Init_Qmat_AB(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case CUSTOMAA :
+ {
+ mod->fp_aa_rate_mat = Openfile(mod->aa_rate_mat_file->s,READ);
+ Read_Qmat(mod->r_mat->qmat->v,mod->e_frq->pi->v,mod->fp_aa_rate_mat);
+ fclose(mod->fp_aa_rate_mat);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ case FLU :
+ {
+ Init_Qmat_FLU(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ default :
+ {
+ Init_Qmat_LG(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+ if(mod->e_frq->empirical_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+ break;
+ }
+ }
+
+ if(mod->s_opt->opt_state_freq == YES) Init_Efrqs_Using_Observed_Freqs(mod->e_frq,data->obs_state_frq,mod->ns);
+
+
+ // Adjust equilibrium state frequencies if some of them are too close to zero
+ // in order to avoid numerical precision issues.
+ int iter = 0;
+ do
+ {
+ for(i=0;ins;i++) if(mod->e_frq->pi->v[i] < E_FRQ_MIN) mod->e_frq->pi->v[i] = E_FRQ_MIN;
+ sum = 0.0;
+ for(i=0;ins;i++) sum += fabs(mod->e_frq->pi->v[i]);
+ for(i=0;ins;i++) mod->e_frq->pi->v[i] /= sum;
+ iter++;
+ }
+ while(iter < 10);
+
+ /* multiply the nth col of Q by the nth term of pi/100 just as in PAML */
+ for(i=0;ins;i++) for(j=0;jns;j++) mod->r_mat->qmat->v[i*mod->ns+j] *= mod->e_frq->pi->v[j] / 100.0;
+
+ /* compute diagonal terms of Q and mean rate mr = l/t */
+ mod->mr->v= .0;
+ For (i,mod->ns)
+ {
+ sum=.0;
+ For(j, mod->ns) sum += mod->r_mat->qmat->v[i*mod->ns+j];
+ mod->r_mat->qmat->v[i*mod->ns+i] = -sum;
+ mod->mr->v += mod->e_frq->pi->v[i] * sum;
+ }
+
+ /* scale instantaneous rate matrix so that mu=1 */
+ For (i,mod->ns*mod->ns) mod->r_mat->qmat->v[i] /= mod->mr->v;
+
+ /* compute eigenvectors/values */
+ result = 0;
+
+ For(i,mod->ns*mod->ns) mod->r_mat->qmat_buff->v[i] = mod->r_mat->qmat->v[i];
+
+ if(!Eigen(1,mod->r_mat->qmat_buff->v,mod->eigen->size,mod->eigen->e_val,
+ mod->eigen->e_val_im,mod->eigen->r_e_vect,
+ mod->eigen->r_e_vect_im,mod->eigen->space))
+ {
+ /* compute inverse(Vr) into Vi */
+ For (i,mod->ns*mod->ns) mod->eigen->l_e_vect[i] = mod->eigen->r_e_vect[i];
+ if(!Matinv(mod->eigen->l_e_vect,mod->eigen->size,mod->eigen->size,YES))
+ {
+ PhyML_Fprintf(stderr,"\n. Err in file %s at line %d.",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ /* compute the diagonal terms of exp(D) */
+ for(i=0;ins;i++) mod->eigen->e_val[i] = (phydbl)exp(mod->eigen->e_val[i]);
+ }
+ else
+ {
+ if (result==-1) PhyML_Printf("\n. Eigenvalues/vectors computation does not converge : computation cancelled");
+ else if (result==1) PhyML_Printf("\n. Complex eigenvalues/vectors : computation cancelled");
+ }
+ }
+ else if(mod->io->datatype == GENERIC)
+ {
+ /* Uniform state frequencies */
+ for(i=0;ins;i++) mod->e_frq->pi->v[i] = 1./(phydbl)mod->ns;
+ mod->kappa->v = 1;
+ mod->s_opt->opt_state_freq = NO;
+ mod->s_opt->opt_kappa = NO;
+ mod->s_opt->opt_lambda = NO;
+ mod->update_eigen = NO;
+ for(i=0;ins*(mod->ns-1)/2;i++) mod->r_mat->rr_val->v[i] = 0.0;
+ for(i=0;ins*(mod->ns-1)/2;i++) mod->r_mat->rr->v[i] = 1.0;
+ }
+ else
+ {
+ PhyML_Fprintf(stderr,"\n. Datatype not recognized.\n");
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Warn_And_Exit("");
+ }
+
+ Init_Eigen_Struct(mod->eigen);
+
+ Set_Model_Parameters(mod);
+
+ free(dr);
+ free(di);
+ free(space);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Efrqs_Using_Observed_Freqs(t_efrq *f, phydbl *o, int ns)
+{
+ int i;
+ phydbl eps,sum;
+
+ assert(f);
+ assert(o);
+
+ // To avoid numerical prevision issues
+ eps = 1.E-50;
+
+ for(i=0;ipi->v[i] = MAX(o[i],eps);
+
+ sum = 0.0;
+ for(i=0;ipi->v[i];
+
+ for(i=0;ipi->v[i] /= sum;;
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int Init_Qmat_Dayhoff(phydbl *daa, phydbl *pi)
+{
+ /* Dayhoff's model data
+ * Dayhoff, M.O., Schwartz, R.M., Orcutt, B.C. (1978)
+ * "A model of evolutionary change in proteins."
+ * Dayhoff, M.O.(ed.) Atlas of Protein Sequence Structur., Vol5, Suppl3.
+ * National Biomedical Research Foundation, Washington DC, pp.345-352.
+ */
+ int i,j,naa;
+
+ naa = 20;
+
+/* PhyML_Printf("\n\n. REMINDER : THIS IS NOT DAYHOFF !!!\n\n"); */
+
+/* daa[1*20 + 0] = 0.538903; */
+/* daa[2*20 + 0] = 0.412504; */
+/* daa[2*20 + 1] = 0.736081; */
+/* daa[3*20 + 0] = 0.586915; */
+/* daa[3*20 + 1] = 0.108051; */
+/* daa[3*20 + 2] = 5.446642; */
+/* daa[4*20 + 0] = 2.189718; */
+/* daa[4*20 + 1] = 0.830604; */
+/* daa[4*20 + 2] = 0.573426; */
+/* daa[4*20 + 3] = 0.077565; */
+/* daa[5*20 + 0] = 1.08213; */
+/* daa[5*20 + 1] = 2.950693; */
+/* daa[5*20 + 2] = 1.739514; */
+/* daa[5*20 + 3] = 0.559035; */
+/* daa[5*20 + 4] = 0.111314; */
+/* daa[6*20 + 0] = 1.386865; */
+/* daa[6*20 + 1] = 0.358434; */
+/* daa[6*20 + 2] = 0.541447; */
+/* daa[6*20 + 3] = 5.406871; */
+/* daa[6*20 + 4] = 0.003738; */
+/* daa[6*20 + 5] = 4.124043; */
+/* daa[7*20 + 0] = 2.085747; */
+/* daa[7*20 + 1] = 0.453132; */
+/* daa[7*20 + 2] = 1.815844; */
+/* daa[7*20 + 3] = 1.08647; */
+/* daa[7*20 + 4] = 0.526418; */
+/* daa[7*20 + 5] = 0.347693; */
+/* daa[7*20 + 6] = 0.438476; */
+/* daa[8*20 + 0] = 0.407898; */
+/* daa[8*20 + 1] = 2.689322; */
+/* daa[8*20 + 2] = 5.386808; */
+/* daa[8*20 + 3] = 0.884563; */
+/* daa[8*20 + 4] = 0.658583; */
+/* daa[8*20 + 5] = 4.588358; */
+/* daa[8*20 + 6] = 0.386218; */
+/* daa[8*20 + 7] = 0.368668; */
+/* daa[9*20 + 0] = 0.10177; */
+/* daa[9*20 + 1] = 0.104875; */
+/* daa[9*20 + 2] = 0.16239; */
+/* daa[9*20 + 3] = 0.011698; */
+/* daa[9*20 + 4] = 0.253282; */
+/* daa[9*20 + 5] = 0.083872; */
+/* daa[9*20 + 6] = 0.041767; */
+/* daa[9*20 + 7] = 0.009778; */
+/* daa[9*20 + 8] = 0.1042; */
+/* daa[10*20 + 0] = 0.248202; */
+/* daa[10*20 + 1] = 0.375742; */
+/* daa[10*20 + 2] = 0.093863; */
+/* daa[10*20 + 3] = 0.019241; */
+/* daa[10*20 + 4] = 0.572688; */
+/* daa[10*20 + 5] = 0.703538; */
+/* daa[10*20 + 6] = 0.071961; */
+/* daa[10*20 + 7] = 0.03006; */
+/* daa[10*20 + 8] = 0.418222; */
+/* daa[10*20 + 9] = 3.702051; */
+/* daa[11*20 + 0] = 0.652019; */
+/* daa[11*20 + 1] = 5.940478; */
+/* daa[11*20 + 2] = 2.352253; */
+/* daa[11*20 + 3] = 0.231001; */
+/* daa[11*20 + 4] = 0.027995; */
+/* daa[11*20 + 5] = 3.646743; */
+/* daa[11*20 + 6] = 1.507981; */
+/* daa[11*20 + 7] = 0.331175; */
+/* daa[11*20 + 8] = 0.698362; */
+/* daa[11*20 + 9] = 0.140326; */
+/* daa[11*20 + 10] = 0.171396; */
+/* daa[12*20 + 0] = 0.694226; */
+/* daa[12*20 + 1] = 0.419899; */
+/* daa[12*20 + 2] = 0.326927; */
+/* daa[12*20 + 3] = 0.039488; */
+/* daa[12*20 + 4] = 0.844827; */
+/* daa[12*20 + 5] = 1.394214; */
+/* daa[12*20 + 6] = 0.133235; */
+/* daa[12*20 + 7] = 0.085075; */
+/* daa[12*20 + 8] = 0.347092; */
+/* daa[12*20 + 9] = 4.051255; */
+/* daa[12*20 + 10] = 6.650794; */
+/* daa[12*20 + 11] = 0.617549; */
+/* daa[13*20 + 0] = 0.155206; */
+/* daa[13*20 + 1] = 0.057971; */
+/* daa[13*20 + 2] = 0.09816; */
+/* daa[13*20 + 3] = 0.020441; */
+/* daa[13*20 + 4] = 0.904305; */
+/* daa[13*20 + 5] = 0.052719; */
+/* daa[13*20 + 6] = 0.0219; */
+/* daa[13*20 + 7] = 0.046668; */
+/* daa[13*20 + 8] = 0.890005; */
+/* daa[13*20 + 9] = 0.844963; */
+/* daa[13*20 + 10] = 2.348881; */
+/* daa[13*20 + 11] = 0.028372; */
+/* daa[13*20 + 12] = 1.671635; */
+/* daa[14*20 + 0] = 1.433475; */
+/* daa[14*20 + 1] = 0.328393; */
+/* daa[14*20 + 2] = 0.173181; */
+/* daa[14*20 + 3] = 0.431874; */
+/* daa[14*20 + 4] = 0.09902; */
+/* daa[14*20 + 5] = 0.592324; */
+/* daa[14*20 + 6] = 0.488352; */
+/* daa[14*20 + 7] = 0.23865; */
+/* daa[14*20 + 8] = 0.462856; */
+/* daa[14*20 + 9] = 0.057048; */
+/* daa[14*20 + 10] = 0.233532; */
+/* daa[14*20 + 11] = 0.387808; */
+/* daa[14*20 + 12] = 0.096377; */
+/* daa[14*20 + 13] = 0.079912; */
+/* daa[15*20 + 0] = 4.887126; */
+/* daa[15*20 + 1] = 0.883923; */
+/* daa[15*20 + 2] = 4.627163; */
+/* daa[15*20 + 3] = 1.122164; */
+/* daa[15*20 + 4] = 3.186667; */
+/* daa[15*20 + 5] = 1.085947; */
+/* daa[15*20 + 6] = 0.569339; */
+/* daa[15*20 + 7] = 1.993432; */
+/* daa[15*20 + 8] = 0.867972; */
+/* daa[15*20 + 9] = 0.070512; */
+/* daa[15*20 + 10] = 0.163009; */
+/* daa[15*20 + 11] = 0.718913; */
+/* daa[15*20 + 12] = 0.301103; */
+/* daa[15*20 + 13] = 0.32579; */
+/* daa[15*20 + 14] = 1.449582; */
+/* daa[16*20 + 0] = 2.030538; */
+/* daa[16*20 + 1] = 0.639463; */
+/* daa[16*20 + 2] = 2.076294; */
+/* daa[16*20 + 3] = 0.377239; */
+/* daa[16*20 + 4] = 1.42848; */
+/* daa[16*20 + 5] = 0.979403; */
+/* daa[16*20 + 6] = 0.647562; */
+/* daa[16*20 + 7] = 0.145556; */
+/* daa[16*20 + 8] = 0.493329; */
+/* daa[16*20 + 9] = 0.973405; */
+/* daa[16*20 + 10] = 0.271824; */
+/* daa[16*20 + 11] = 1.20033; */
+/* daa[16*20 + 12] = 1.659187; */
+/* daa[16*20 + 13] = 0.1217; */
+/* daa[16*20 + 14] = 0.571399; */
+/* daa[16*20 + 15] = 6.641034; */
+/* daa[17*20 + 0] = 0.131405; */
+/* daa[17*20 + 1] = 0.552911; */
+/* daa[17*20 + 2] = 0.079985; */
+/* daa[17*20 + 3] = 0.060514; */
+/* daa[17*20 + 4] = 0.633662; */
+/* daa[17*20 + 5] = 0.21823; */
+/* daa[17*20 + 6] = 0.074988; */
+/* daa[17*20 + 7] = 0.169114; */
+/* daa[17*20 + 8] = 0.847725; */
+/* daa[17*20 + 9] = 0.10627; */
+/* daa[17*20 + 10] = 0.622044; */
+/* daa[17*20 + 11] = 0.060755; */
+/* daa[17*20 + 12] = 0.719575; */
+/* daa[17*20 + 13] = 3.14824; */
+/* daa[17*20 + 14] = 0.077123; */
+/* daa[17*20 + 15] = 0.276716; */
+/* daa[17*20 + 16] = 0.148883; */
+/* daa[18*20 + 0] = 0.165179; */
+/* daa[18*20 + 1] = 0.224883; */
+/* daa[18*20 + 2] = 0.528334; */
+/* daa[18*20 + 3] = 0.121252; */
+/* daa[18*20 + 4] = 1.174118; */
+/* daa[18*20 + 5] = 0.177062; */
+/* daa[18*20 + 6] = 0.074715; */
+/* daa[18*20 + 7] = 0.042356; */
+/* daa[18*20 + 8] = 5.911187; */
+/* daa[18*20 + 9] = 0.192481; */
+/* daa[18*20 + 10] = 0.321454; */
+/* daa[18*20 + 11] = 0.090556; */
+/* daa[18*20 + 12] = 0.406415; */
+/* daa[18*20 + 13] = 10.908861; */
+/* daa[18*20 + 14] = 0.070752; */
+/* daa[18*20 + 15] = 0.328483; */
+/* daa[18*20 + 16] = 0.181539; */
+/* daa[18*20 + 17] = 3.823886; */
+/* daa[19*20 + 0] = 1.78517; */
+/* daa[19*20 + 1] = 0.166975; */
+/* daa[19*20 + 2] = 0.106482; */
+/* daa[19*20 + 3] = 0.041707; */
+/* daa[19*20 + 4] = 1.876812; */
+/* daa[19*20 + 5] = 0.22421; */
+/* daa[19*20 + 6] = 0.247356; */
+/* daa[19*20 + 7] = 0.06688; */
+/* daa[19*20 + 8] = 0.1436; */
+/* daa[19*20 + 9] = 9.60184; */
+/* daa[19*20 + 10] = 1.599119; */
+/* daa[19*20 + 11] = 0.17319; */
+/* daa[19*20 + 12] = 1.645134; */
+/* daa[19*20 + 13] = 0.438571; */
+/* daa[19*20 + 14] = 0.252486; */
+/* daa[19*20 + 15] = 0.105536; */
+/* daa[19*20 + 16] = 1.789097; */
+/* daa[19*20 + 17] = 0.147951; */
+/* daa[19*20 + 18] = 0.200571; */
+
+
+
+/* for (i=0; i 2664 (67% of the original 3933 positions)
+
+ The species included in the analysis were:
+ Harpiosquilla harpax [NCBI_TaxID 287944]
+ Ixodes uriae [NCBI_TaxID 59655]
+ Heptathela hangzhouensis [NCBI_TaxID 216259]
+ Triops longicaudatus [NCBI_TaxID 58777]
+ Gryllotalpa orientalis [NCBI_TaxID 213494]
+ lepidopsocid RS-2001 [NCBI_TaxID 159971]
+ Locusta migratoria [NCBI_TaxID 7004]
+ Drosophila yakuba [NCBI_TaxID 7245]
+ Ostrinia furnacalis [NCBI_TaxID 93504]
+ Megabalanus volcano [NCBI_TaxID 266495]
+ Periplaneta fuliginosa [NCBI_TaxID 36977]
+ Thermobia domestica [NCBI_TaxID 89055]
+ Aleurochiton aceris [NCBI_TaxID 266942]
+ Schizaphis graminum [NCBI_TaxID 13262]
+ Pteronarcys princeps [NCBI_TaxID 285953]
+ Aleurodicus dugesii [NCBI_TaxID 30099]
+ Pollicipes polymerus [NCBI_TaxID 36137]
+ Gomphiocephalus hodgsoni [NCBI_TaxID 221270]
+ Habronattus oregonensis [NCBI_TaxID 130930]
+ Speleonectes tulumensis [NCBI_TaxID 84346]
+ Hutchinsoniella macracantha [NCBI_TaxID 84335]
+ Haemaphysalis flava [NCBI_TaxID 181088]
+ Scutigera coleoptrata [NCBI_TaxID 29022]
+ Vargula hilgendorfii [NCBI_TaxID 6674]
+ Tricholepidion gertschi [NCBI_TaxID 89825]
+ Varroa destructor [NCBI_TaxID 109461]
+ Bombyx mandarina [NCBI_TaxID 7092]
+ Thyropygus sp. [NCBI_TaxID 174155]
+ Tribolium castaneum [NCBI_TaxID 7070]
+ Pagurus longicarpus [NCBI_TaxID 111067]
+ Limulus polyphemus [NCBI_TaxID 6850]
+ Tetrodontophora bielanensis [NCBI_TaxID 48717]
+ Penaeus monodon [NCBI_TaxID 6687]
+ Daphnia pulex [NCBI_TaxID 6669]
+ Apis mellifera [NCBI_TaxID 7469]
+ Anopheles gambiae [NCBI_TaxID 7165]
+
+ The topology used for inferring the model was:
+ (((Daph_pulex,Trio_longi),((((((Aleu_aceri,Aleu_duges),Schi_grami),lepi_RS_20),
+ ((((Ostr_furna,Bomb_manda),(Dros_yakub,Anop_gambi)),Apis_melli),Trib_casta)),
+ ((Gryl_orien,Locu_migra),(Pter_princ,Peri_fulig))),(Tric_gerts,Ther_domes)),
+ (Scut_coleo,Thyr_sp),Varg_hilge,Hutc_macra,((((Ixod_uriae,Haem_flava),Varr_destr),
+ (Habr_orego,Hept_hangz)),Limu_polyp),(Poll_polym,Mega_volca),(Gomp_hodgs,Tetr_biela),
+ ((Pagu_longi,Pena_monod),Harp_harpa),Spel_tulum));
+
+ Note this is not the ML topology but the consensus one (based on morphological data,
+ phylogenetic reconstruction using nuclear genes, etc). Where relationships are
+ not clear, a polytomy was introduced (it contains quite a lot of polytomies!).
+
+ The model was estimated using (the great and helpful) Ziheng Yang's Paml software package.
+ A four-categorized gamma distribution was used to account for heterogeneity (alpha
+ was estimated to be 0.47821). Sites with ambiguity data were taken into account.
+
+ If you would like the data related to this matrix, please contact fabascal@uvigo.es.
+ Federico Abascal (c)2005.
+ */
+
+ int i,j,naa;
+ naa = 20;
+ daa[1*20+ 0] = 0.2; daa[2*20+ 0] = 0.2; daa[2*20+ 1] = 0.2; daa[3*20+ 0] = 0.6;
+ daa[3*20+ 1] = 4.3; daa[3*20+ 2] = 500.2; daa[4*20+ 0] = 253.5; daa[4*20+ 1] = 35.5;
+ daa[4*20+ 2] = 98.2; daa[4*20+ 3] = 10.6; daa[5*20+ 0] = 0.2; daa[5*20+ 1] = 154.0;
+ daa[5*20+ 2] = 261.8; daa[5*20+ 3] = 0.2; daa[5*20+ 4] = 0.2; daa[6*20+ 0] = 0.2;
+ daa[6*20+ 1] = 0.2; daa[6*20+ 2] = 183.0; daa[6*20+ 3] = 861.8; daa[6*20+ 4] = 0.2;
+ daa[6*20+ 5] = 261.6; daa[7*20+ 0] = 199.8; daa[7*20+ 1] = 0.2; daa[7*20+ 2] = 120.5;
+ daa[7*20+ 3] = 12.5; daa[7*20+ 4] = 80.5; daa[7*20+ 5] = 2.6; daa[7*20+ 6] = 43.9;
+ daa[8*20+ 0] = 0.2; daa[8*20+ 1] = 41.3; daa[8*20+ 2] = 179.5; daa[8*20+ 3] = 0.2;
+ daa[8*20+ 4] = 12.4; daa[8*20+ 5] = 313.5; daa[8*20+ 6] = 15.2; daa[8*20+ 7] = 0.2;
+ daa[9*20+ 0] = 25.7; daa[9*20+ 1] = 1.8; daa[9*20+ 2] = 21.3; daa[9*20+ 3] = 6.6;
+ daa[9*20+ 4] = 63.0; daa[9*20+ 5] = 10.5; daa[9*20+ 6] = 6.8; daa[9*20+ 7] = 2.7;
+ daa[9*20+ 8] = 0.2; daa[10*20+ 0] = 3.7; daa[10*20+ 1] = 1.8; daa[10*20+ 2] = 12.6;
+ daa[10*20+ 3] = 1.2; daa[10*20+ 4] = 78.7; daa[10*20+ 5] = 16.3; daa[10*20+ 6] = 1.7;
+ daa[10*20+ 7] = 1.4; daa[10*20+ 8] = 5.5; daa[10*20+ 9] = 514.5; daa[11*20+ 0] = 0.2;
+ daa[11*20+ 1] = 208.6; daa[11*20+ 2] = 467.3; daa[11*20+ 3] = 1.7; daa[11*20+ 4] = 0.2;
+ daa[11*20+ 5] = 349.3; daa[11*20+ 6] = 106.3; daa[11*20+ 7] = 0.2; daa[11*20+ 8] = 0.2;
+ daa[11*20+ 9] = 3.5; daa[11*20+ 10] = 3.8; daa[12*20+ 0] = 120.6; daa[12*20+ 1] = 5.2;
+ daa[12*20+ 2] = 78.8; daa[12*20+ 3] = 0.2; daa[12*20+ 4] = 312.3; daa[12*20+ 5] = 67.3;
+ daa[12*20+ 6] = 0.2; daa[12*20+ 7] = 55.7; daa[12*20+ 8] = 0.2; daa[12*20+ 9] = 514.8;
+ daa[12*20+ 10] = 885.5; daa[12*20+ 11] = 105.6; daa[13*20+ 0] = 13.1; daa[13*20+ 1] = 4.7;
+ daa[13*20+ 2] = 19.7; daa[13*20+ 3] = 0.2; daa[13*20+ 4] = 184.1; daa[13*20+ 5] = 0.2;
+ daa[13*20+ 6] = 0.2; daa[13*20+ 7] = 0.8; daa[13*20+ 8] = 13.8; daa[13*20+ 9] = 117.9;
+ daa[13*20+ 10] = 262.6; daa[13*20+ 11] = 10.7; daa[13*20+ 12] = 321.6; daa[14*20+ 0] = 49.3;
+ daa[14*20+ 1] = 0.2; daa[14*20+ 2] = 16.5; daa[14*20+ 3] = 0.2; daa[14*20+ 4] = 0.2;
+ daa[14*20+ 5] = 39.3; daa[14*20+ 6] = 7.9; daa[14*20+ 7] = 0.2; daa[14*20+ 8] = 0.8;
+ daa[14*20+ 9] = 0.2; daa[14*20+ 10] = 12.2; daa[14*20+ 11] = 16.8; daa[14*20+ 12] = 5.3;
+ daa[14*20+ 13] = 14.6; daa[15*20+ 0] = 673.0; daa[15*20+ 1] = 2.7; daa[15*20+ 2] = 398.4;
+ daa[15*20+ 3] = 44.4; daa[15*20+ 4] = 664.2; daa[15*20+ 5] = 52.4; daa[15*20+ 6] = 31.5;
+ daa[15*20+ 7] = 226.0; daa[15*20+ 8] = 10.6; daa[15*20+ 9] = 7.2; daa[15*20+ 10] = 8.2;
+ daa[15*20+ 11] = 144.2; daa[15*20+ 12] = 111.7; daa[15*20+ 13] = 36.1; daa[15*20+ 14] = 86.5;
+ daa[16*20+ 0] = 243.9; daa[16*20+ 1] = 0.2; daa[16*20+ 2] = 165.9; daa[16*20+ 3] = 0.2;
+ daa[16*20+ 4] = 182.8; daa[16*20+ 5] = 43.7; daa[16*20+ 6] = 43.4; daa[16*20+ 7] = 0.2;
+ daa[16*20+ 8] = 18.6; daa[16*20+ 9] = 203.7; daa[16*20+ 10] = 47.8; daa[16*20+ 11] = 69.5;
+ daa[16*20+ 12] = 288.6; daa[16*20+ 13] = 13.5; daa[16*20+ 14] = 46.8; daa[16*20+ 15] = 660.4;
+ daa[17*20+ 0] = 0.2; daa[17*20+ 1] = 0.2; daa[17*20+ 2] = 7.7; daa[17*20+ 3] = 0.2;
+ daa[17*20+ 4] = 21.6; daa[17*20+ 5] = 6.7; daa[17*20+ 6] = 11.0; daa[17*20+ 7] = 1.9;
+ daa[17*20+ 8] = 0.2; daa[17*20+ 9] = 0.2; daa[17*20+ 10] = 21.1; daa[17*20+ 11] = 16.0;
+ daa[17*20+ 12] = 70.7; daa[17*20+ 13] = 53.7; daa[17*20+ 14] = 0.2; daa[17*20+ 15] = 2.4;
+ daa[17*20+ 16] = 0.2; daa[18*20+ 0] = 1.2; daa[18*20+ 1] = 3.9; daa[18*20+ 2] = 251.2;
+ daa[18*20+ 3] = 0.2; daa[18*20+ 4] = 72.0; daa[18*20+ 5] = 86.7; daa[18*20+ 6] = 7.7;
+ daa[18*20+ 7] = 8.6; daa[18*20+ 8] = 191.4; daa[18*20+ 9] = 12.3; daa[18*20+ 10] = 19.8;
+ daa[18*20+ 11] = 117.1; daa[18*20+ 12] = 70.9; daa[18*20+ 13] = 791.6; daa[18*20+ 14] = 18.4;
+ daa[18*20+ 15] = 30.5; daa[18*20+ 16] = 46.0; daa[18*20+ 17] = 37.7; daa[19*20+ 0] = 339.9;
+ daa[19*20+ 1] = 0.2; daa[19*20+ 2] = 22.6; daa[19*20+ 3] = 0.2; daa[19*20+ 4] = 350.4;
+ daa[19*20+ 5] = 0.2; daa[19*20+ 6] = 13.6; daa[19*20+ 7] = 2.6; daa[19*20+ 8] = 0.2;
+ daa[19*20+ 9] = 1854.5; daa[19*20+ 10] = 84.7; daa[19*20+ 11] = 26.1; daa[19*20+ 12] = 281.3;
+ daa[19*20+ 13] = 51.9; daa[19*20+ 14] = 31.7; daa[19*20+ 15] = 60.6; daa[19*20+ 16] = 544.1;
+ daa[19*20+ 17] = 0.2; daa[19*20+ 18] = 1.6;
+
+/* MtArt.old: esta es la MtArt que hice con 26 secuencias (2 outgroups) con una topologia incorrecta
+ daa[1*20+ 0] = 0.2; daa[2*20+ 0] = 0.2; daa[2*20+ 1] = 8.0; daa[3*20+ 0] = 0.2;
+ daa[3*20+ 1] = 0.2; daa[3*20+ 2] = 441.7; daa[4*20+ 0] = 287.9; daa[4*20+ 1] = 48.4;
+ daa[4*20+ 2] = 82.4; daa[4*20+ 3] = 0.2; daa[5*20+ 0] = 0.2; daa[5*20+ 1] = 149.9;
+ daa[5*20+ 2] = 278.6; daa[5*20+ 3] = 0.2; daa[5*20+ 4] = 21.7; daa[6*20+ 0] = 6.6;
+ daa[6*20+ 1] = 0.2; daa[6*20+ 2] = 213.9; daa[6*20+ 3] = 760.8; daa[6*20+ 4] = 0.2;
+ daa[6*20+ 5] = 292.9; daa[7*20+ 0] = 228.2; daa[7*20+ 1] = 0.2; daa[7*20+ 2] = 97.1;
+ daa[7*20+ 3] = 10.4; daa[7*20+ 4] = 98.4; daa[7*20+ 5] = 4.0; daa[7*20+ 6] = 48.7;
+ daa[8*20+ 0] = 0.2; daa[8*20+ 1] = 56.7; daa[8*20+ 2] = 156.4; daa[8*20+ 3] = 24.5;
+ daa[8*20+ 4] = 15.5; daa[8*20+ 5] = 328.6; daa[8*20+ 6] = 7.0; daa[8*20+ 7] = 8.4;
+ daa[9*20+ 0] = 26.4; daa[9*20+ 1] = 1.6; daa[9*20+ 2] = 40.1; daa[9*20+ 3] = 0.2;
+ daa[9*20+ 4] = 22.1; daa[9*20+ 5] = 13.8; daa[9*20+ 6] = 0.2; daa[9*20+ 7] = 3.6;
+ daa[9*20+ 8] = 0.2; daa[10*20+ 0] = 3.4; daa[10*20+ 1] = 0.6; daa[10*20+ 2] = 13.8;
+ daa[10*20+ 3] = 0.7; daa[10*20+ 4] = 76.9; daa[10*20+ 5] = 12.1; daa[10*20+ 6] = 5.4;
+ daa[10*20+ 7] = 2.5; daa[10*20+ 8] = 2.9; daa[10*20+ 9] = 542.6; daa[11*20+ 0] = 0.2;
+ daa[11*20+ 1] = 240.2; daa[11*20+ 2] = 602.8; daa[11*20+ 3] = 35.5; daa[11*20+ 4] = 0.2;
+ daa[11*20+ 5] = 357.6; daa[11*20+ 6] = 62.6; daa[11*20+ 7] = 0.2; daa[11*20+ 8] = 3.3;
+ daa[11*20+ 9] = 0.2; daa[11*20+ 10] = 17.5; daa[12*20+ 0] = 119.0; daa[12*20+ 1] = 0.2;
+ daa[12*20+ 2] = 91.4; daa[12*20+ 3] = 6.4; daa[12*20+ 4] = 332.3; daa[12*20+ 5] = 65.4;
+ daa[12*20+ 6] = 0.2; daa[12*20+ 7] = 60.4; daa[12*20+ 8] = 2.4; daa[12*20+ 9] = 492.5;
+ daa[12*20+ 10] = 815.8; daa[12*20+ 11] = 67.3; daa[13*20+ 0] = 8.2; daa[13*20+ 1] = 6.4;
+ daa[13*20+ 2] = 31.5; daa[13*20+ 3] = 3.4; daa[13*20+ 4] = 174.4; daa[13*20+ 5] = 5.7;
+ daa[13*20+ 6] = 5.7; daa[13*20+ 7] = 2.1; daa[13*20+ 8] = 11.0; daa[13*20+ 9] = 94.4;
+ daa[13*20+ 10] = 243.3; daa[13*20+ 11] = 12.3; daa[13*20+ 12] = 357.8; daa[14*20+ 0] = 62.5;
+ daa[14*20+ 1] = 0.4; daa[14*20+ 2] = 17.5; daa[14*20+ 3] = 0.2; daa[14*20+ 4] = 0.2;
+ daa[14*20+ 5] = 48.6; daa[14*20+ 6] = 17.7; daa[14*20+ 7] = 2.7; daa[14*20+ 8] = 0.2;
+ daa[14*20+ 9] = 0.2; daa[14*20+ 10] = 11.2; daa[14*20+ 11] = 21.7; daa[14*20+ 12] = 5.2;
+ daa[14*20+ 13] = 12.6; daa[15*20+ 0] = 659.0; daa[15*20+ 1] = 5.2; daa[15*20+ 2] = 469.8;
+ daa[15*20+ 3] = 52.3; daa[15*20+ 4] = 570.7; daa[15*20+ 5] = 47.8; daa[15*20+ 6] = 37.3;
+ daa[15*20+ 7] = 227.8; daa[15*20+ 8] = 12.7; daa[15*20+ 9] = 12.3; daa[15*20+ 10] = 7.4;
+ daa[15*20+ 11] = 189.0; daa[15*20+ 12] = 155.3; daa[15*20+ 13] = 43.8; daa[15*20+ 14] = 103.4;
+ daa[16*20+ 0] = 276.4; daa[16*20+ 1] = 1.6; daa[16*20+ 2] = 175.6; daa[16*20+ 3] = 0.2;
+ daa[16*20+ 4] = 96.2; daa[16*20+ 5] = 71.4; daa[16*20+ 6] = 37.4; daa[16*20+ 7] = 0.2;
+ daa[16*20+ 8] = 14.2; daa[16*20+ 9] = 212.5; daa[16*20+ 10] = 38.5; daa[16*20+ 11] = 97.4;
+ daa[16*20+ 12] = 254.7; daa[16*20+ 13] = 2.1; daa[16*20+ 14] = 41.6; daa[16*20+ 15] = 670.6;
+ daa[17*20+ 0] = 6.2; daa[17*20+ 1] = 0.2; daa[17*20+ 2] = 0.2; daa[17*20+ 3] = 5.6;
+ daa[17*20+ 4] = 0.2; daa[17*20+ 5] = 0.2; daa[17*20+ 6] = 3.1; daa[17*20+ 7] = 0.4;
+ daa[17*20+ 8] = 0.2; daa[17*20+ 9] = 15.2; daa[17*20+ 10] = 11.5; daa[17*20+ 11] = 32.6;
+ daa[17*20+ 12] = 82.4; daa[17*20+ 13] = 81.9; daa[17*20+ 14] = 0.2; daa[17*20+ 15] = 9.7;
+ daa[17*20+ 16] = 0.2; daa[18*20+ 0] = 1.6; daa[18*20+ 1] = 7.7; daa[18*20+ 2] = 242.5;
+ daa[18*20+ 3] = 0.2; daa[18*20+ 4] = 88.0; daa[18*20+ 5] = 93.1; daa[18*20+ 6] = 0.2;
+ daa[18*20+ 7] = 6.0; daa[18*20+ 8] = 113.7; daa[18*20+ 9] = 22.1; daa[18*20+ 10] = 17.2;
+ daa[18*20+ 11] = 138.5; daa[18*20+ 12] = 37.6; daa[18*20+ 13] = 770.2; daa[18*20+ 14] = 5.3;
+ daa[18*20+ 15] = 25.0; daa[18*20+ 16] = 55.5; daa[18*20+ 17] = 69.3; daa[19*20+ 0] = 307.8;
+ daa[19*20+ 1] = 2.2; daa[19*20+ 2] = 6.9; daa[19*20+ 3] = 0.2; daa[19*20+ 4] = 405.7;
+ daa[19*20+ 5] = 0.8; daa[19*20+ 6] = 20.2; daa[19*20+ 7] = 5.7; daa[19*20+ 8] = 0.2;
+ daa[19*20+ 9] = 1687.9; daa[19*20+ 10] = 49.4; daa[19*20+ 11] = 23.4; daa[19*20+ 12] = 329.9;
+ daa[19*20+ 13] = 86.3; daa[19*20+ 14] = 27.3; daa[19*20+ 15] = 95.0; daa[19*20+ 16] = 443.0;
+ daa[19*20+ 17] = 2.4; daa[19*20+ 18] = 0.2;
+3*/
+ for (i=0; idim = n_dim;
+ Random_String(t->id,3);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void PHYREX_Init_Disk_Event(t_dsk *t, int n_dim, t_phyrex_mod *mmod)
+{
+ t->prev = NULL;
+ t->next = NULL;
+ t->mmod = NULL;
+ t->age_fixed = NO;
+
+ Random_String(t->id,3);
+ GEO_Init_Coord(t->centr,n_dim);
+
+ if(mmod != NULL) t->mmod = mmod;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void PHYREX_Init_Migrep_Mod(t_phyrex_mod *t, int n_dim, phydbl min_lat, phydbl min_lon, phydbl max_lat, phydbl max_lon)
+{
+ assert(n_dim == 2);
+
+ t->name = PHYREX_NORMAL;
+ t->n_dim = n_dim;
+ t->safe_phyrex = NO;
+
+ t->lim_up->lonlat[0] = max_lat;
+ t->lim_up->lonlat[1] = max_lon;
+
+ t->lim_do->lonlat[0] = min_lat;
+ t->lim_do->lonlat[1] = min_lon;
+
+ t->lbda = 1.E-2;
+ t->min_lbda = 1.E-6;
+ t->max_lbda = 1.E+4;
+ t->prior_param_lbda = 1.0;
+
+ t->mu = 0.400;
+ t->min_mu = 0.000;
+ t->max_mu = 1.000;
+ t->prior_param_mu = 1.000;
+
+ t->min_rad = 0.0;
+ t->max_rad = 1.0*((max_lat-min_lat)+(max_lon-min_lon));
+ /* t->max_rad = 10.0*((max_lat-min_lat)+(max_lon-min_lon)); */
+ t->rad = 0.01*((max_lat-min_lat)+(max_lon-min_lon));
+ /* t->prior_param_rad = 1./(0.01*((max_lat-min_lat)+(max_lon-min_lon))); */
+ t->prior_param_rad = 1./(0.1*((max_lat-min_lat)+(max_lon-min_lon)));
+ t->update_rad = NO;
+
+ t->min_sigsq = 0.0;
+ t->max_sigsq = 1.E+2;
+ t->sigsq = 1.0;
+ t->prior_param_sigsq = 10.0;
+
+
+ t->c_lnL = UNLIKELY;
+ t->c_ln_prior_rad = UNLIKELY;
+ t->c_ln_prior_lbda = UNLIKELY;
+ t->c_ln_prior_mu = UNLIKELY;
+
+ t->soft_bound_area = 0.1;
+
+ t->samp_area = NULL;
+
+ t->max_num_of_intervals = 1000000;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void PHYREX_Init_Lindisk_Node(t_ldsk *t, t_dsk *disk, int n_dim)
+{
+ t->disk = disk;
+ /* disk->ldsk = t; */
+ t->prev = NULL;
+ t->next = NULL;
+ t->nd = NULL;
+ t->is_hit = NO;
+ t->n_next = 0;
+ GEO_Init_Coord(t->coord, n_dim);
+ GEO_Init_Coord(t->cpy_coord,n_dim);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void MCMC_Init_MCMC_Struct(char *filename, option *io, t_mcmc *mcmc)
+{
+ int pid;
+
+ assert(mcmc);
+
+ mcmc->io = io;
+ mcmc->is = NO;
+ mcmc->run = 0;
+ mcmc->sample_interval = 1E+3;
+ mcmc->chain_len = 1E+7;
+ mcmc->chain_len_burnin = 1E+4;
+ mcmc->randomize = YES;
+ mcmc->norm_freq = 1E+3;
+ mcmc->max_tune = 1.E+20;
+ mcmc->min_tune = 1.E-10;
+ mcmc->print_every = 2;
+ mcmc->is_burnin = NO;
+ mcmc->nd_t_digits = 4;
+ mcmc->always_yes = NO;
+ mcmc->max_lag = 1000;
+ mcmc->sample_num = 0;
+
+ if(filename)
+ {
+ char *s;
+
+ s = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+
+ strcpy(mcmc->out_filename,filename);
+ pid = getpid();
+ sprintf(mcmc->out_filename+strlen(mcmc->out_filename),".%d",pid);
+
+ strcpy(s,mcmc->io->in_align_file);
+ strcat(s,"_");
+ strcat(s,mcmc->out_filename);
+ strcat(s,".stats");
+ mcmc->out_fp_stats = fopen(s,"w");
+
+ strcpy(s,mcmc->io->in_align_file);
+ strcat(s,"_");
+ strcat(s,mcmc->out_filename);
+ strcat(s,".trees");
+ mcmc->out_fp_trees = fopen(s,"w");
+
+ strcpy(s,mcmc->io->in_align_file);
+ strcat(s,"_");
+ strcat(s,mcmc->out_filename);
+ strcat(s,".constree");
+ mcmc->out_fp_constree = fopen(s,"w");
+
+/* strcpy(s,tree->mcmc->out_filename); */
+/* strcat(s,".means"); */
+/* tree->mcmc->out_fp_means = fopen(s,"w"); */
+
+/* strcpy(s,tree->mcmc->out_filename); */
+/* strcat(s,".lasts"); */
+/* tree->mcmc->out_fp_last = fopen(s,"w"); */
+
+ Free(s);
+ }
+ else
+ {
+ mcmc->out_fp_stats = stderr;
+ mcmc->out_fp_trees = stderr;
+ /* tree->mcmc->out_fp_means = stderr; */
+ /* tree->mcmc->out_fp_last = stderr; */
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Calibration(t_cal *cal)
+{
+ cal->next = NULL;
+ cal->prev = NULL;
+ cal->lower = -1.;
+ cal->upper = -1.;
+ cal->is_primary = FALSE;
+ cal->alpha_proba_list = NULL;
+ cal->clade_list = NULL;
+ cal->clade_list_size = 0;
+ cal->id = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_All_Calibration(t_tree *tree)
+{
+ int i;
+ assert(tree->rates && tree->rates->a_cal);
+ For(i,2*tree->n_otu-1) Init_Calibration(tree->rates->a_cal[i]);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Sarea(t_sarea *s)
+{
+ assert(s);
+ s->n_poly = 0;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Calign(int n_otu, int crunch_len, int init_len, calign *this)
+{
+ this->obs_pinvar = .0;
+ this->n_otu = n_otu;
+ this->clean_len = -1;
+ this->crunch_len = crunch_len;
+ this->init_len = init_len;
+ this->format = 0;
+ this->io_wght = NULL;
+
+ for(int i=0; ic_seq[i]);
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Cseq(align *this)
+{
+ this->is_duplicate = NO;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_Linked_List(t_ll *list)
+{
+ list->head = list;
+ list->tail = list;
+ list->next = NULL;
+ list->prev = NULL;
+ list->v = NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Init_NNI_Score(phydbl val, t_edge *b, t_tree *tree)
+{
+ b->nni->score = val;
+ if(tree->is_mixt_tree == YES) MIXT_Init_NNI_Score(val,b,tree);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+#ifdef M4
+void M4_Init_Model(m4 *m4mod, calign *data, t_mod *mod)
+{
+ int i,j,ct;
+ phydbl fq;
+
+ if(mod->io->datatype == NT) m4mod->n_o = 4;
+ else if(mod->io->datatype == AA) m4mod->n_o = 20;
+ else
+ {
+ PhyML_Fprintf(stderr,"\n. Not implemented yet.");
+ PhyML_Fprintf(stderr,"\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ Warn_And_Exit("");
+ }
+
+ mod->ns = m4mod->n_o * m4mod->n_h;
+
+ for(i=0;in_o;i++) m4mod->o_fq[i] = mod->e_frq->pi->v[i]; /*! At that stage, the mod->pi vector as been initialized
+ under a standard non covarion type of model. Use these
+ frequencies as they have been set according to the
+ nucleotide substitution model chosen (e.g., 1/4 for JC69). !*/
+ For(i,(int)(m4mod->n_h)) m4mod->multipl[i] = 1.;
+
+ ct = 0;
+ for(i=0;in_o-1;i++)
+ {
+ for(j=i+1;jn_o;j++)
+ {
+ m4mod->o_rr[ct] = MAX(mod->r_mat->qmat->v[i*m4mod->n_o+j],1.E-5);
+ ct++;
+ }
+ }
+
+ For(i,(int)(m4mod->n_h*(m4mod->n_h-1)/2)) m4mod->h_rr[i] = 1.;
+ fq = (phydbl)(1./m4mod->n_h);
+
+ if(mod->s_opt->opt_cov_delta) m4mod->delta = 1.0;
+ if(mod->s_opt->opt_cov_alpha) m4mod->alpha = 1.0;
+ for(i=0;in_h;i++) m4mod->h_fq[i] = fq;
+ for(i=0;in_h;i++) m4mod->h_fq_unscaled[i] = 1.0;
+ for(i=0;in_h;i++) m4mod->multipl[i] = (phydbl)i;
+ for(i=0;in_h;i++) m4mod->multipl_unscaled[i] = (phydbl)i;
+
+ Set_Update_Eigen(YES,mod);
+ M4_Update_Qmat(m4mod,mod);
+}
+#endif
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
diff --git a/phyml/init.h b/phyml/init.h
new file mode 100644
index 0000000..6a8109c
--- /dev/null
+++ b/phyml/init.h
@@ -0,0 +1,76 @@
+/*
+
+PHYML : a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences
+
+Copyright (C) Stephane Guindon. Oct 2003 onward
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+#include
+
+#ifndef INIT_H
+#define INIT_H
+
+#include "utilities.h"
+
+void Init_Cseq(align *this);
+void Init_Eigen_Struct(eigen *this);
+void Init_Scalar_Dbl(scalar_dbl *p);
+void Init_Scalar_Int(scalar_int *p);
+void Init_Vect_Dbl(int len,vect_dbl *p);
+void Init_Vect_Int(int len,vect_int *p);
+void Init_Tree(t_tree *tree,int n_otu);
+void Init_Edge_Light(t_edge *b,int num);
+void Init_Node_Light(t_node *n,int num);
+void Init_NNI(t_nni *a_nni);
+void Init_Nexus_Format(nexcom **com);
+void Init_Mat(matrix *mat,calign *data);
+void Set_Defaults_Input(option *io);
+void Set_Defaults_Model(t_mod *mod);
+void Set_Defaults_Optimiz(t_opt *s_opt);
+void XML_Init_Node(xml_node *prev,xml_node *new_node,char *name);
+void Init_One_Spr(t_spr *a_spr);
+void Init_Model(calign *data,t_mod *mod,option *io);
+int Init_Qmat_Dayhoff(phydbl *daa,phydbl *pi);
+int Init_Qmat_DCMut(phydbl *daa,phydbl *pi);
+int Init_Qmat_MtArt(phydbl *daa,phydbl *pi);
+int Init_Qmat_HIVb(phydbl *daa,phydbl *pi);
+int Init_Qmat_HIVw(phydbl *daa,phydbl *pi);
+int Init_Qmat_JTT(phydbl *daa,phydbl *pi);
+int Init_Qmat_MtREV(phydbl *daa,phydbl *pi);
+int Init_Qmat_LG(phydbl *daa,phydbl *pi);
+int Init_Qmat_WAG(phydbl *daa,phydbl *pi);
+int Init_Qmat_RtREV(phydbl *daa,phydbl *pi);
+int Init_Qmat_CpREV(phydbl *daa,phydbl *pi);
+int Init_Qmat_VT(phydbl *daa,phydbl *pi);
+int Init_Qmat_Blosum62(phydbl *daa,phydbl *pi);
+int Init_Qmat_MtMam(phydbl *daa,phydbl *pi);
+int Init_Qmat_AB(phydbl *daa, phydbl *pi);
+void XML_Init_Attribute(xml_attr *attr);
+void Init_String(t_string *ts);
+void Init_Efrq(phydbl *b_frq, t_efrq *f);
+void RATES_Init_Rate_Struct(t_rate *rates, t_rate *existing_rates, int n_otu);
+void Init_Rmat(t_rmat *rmat);
+void Init_MGF_Bl(t_tree *tree);
+int Init_Qmat_FLU(phydbl *daa, phydbl *pi);
+void Set_Defaults_Ras(t_ras *ras);
+void GEO_Init_Coord(t_geo_coord *t, int n_dim);
+void PHYREX_Init_Disk_Event(t_dsk *t, int n_dim, t_phyrex_mod *mod);
+void PHYREX_Init_Lindisk_Node(t_ldsk *t, t_dsk *devt, int n_dim);
+void PHYREX_Init_Migrep_Mod(t_phyrex_mod *t, int n_dim, phydbl min_lat, phydbl min_lon, phydbl max_lat, phydbl max_lon);
+void MCMC_Init_MCMC_Struct(char *filename, option *io, t_mcmc *mcmc);
+void Init_Calibration(t_cal *cal);
+void Init_All_Calibration(t_tree *tree);
+void Init_Sarea(t_sarea *s);
+void Init_Efrqs_Using_Observed_Freqs(t_efrq *f, phydbl *o, int ns);
+void Init_Calign(int n_otu, int crunch_len, int init_len, calign *this);
+void Init_Linked_List(t_ll *list);
+void Init_Target_Tip(t_clad *clade, t_tree *tree);
+void Init_NNI_Score(phydbl val, t_edge *b, t_tree *tree);
+void M4_Init_Model(m4 *m4mod, calign *data, t_mod *mod);
+
+#endif
diff --git a/phyml/interface.c b/phyml/interface.c
index e1ad094..5191fdf 100644
--- a/phyml/interface.c
+++ b/phyml/interface.c
@@ -10,21 +10,14 @@ the GNU public licence. See http://www.opensource.org for details.
*/
-#include "utilities.h"
-#include "options.h"
-#include "models.h"
-#include "free.h"
-#include "options.h"
#include "interface.h"
-#ifdef MG
-#include "multigene.h"
-#endif
+#include "mg.h"
void Launch_Interface(option *io)
{
Launch_Interface_Input(io);
- io->ready_to_go = 0;
+ io->ready_to_go = 0;
do
{
switch(io->curr_interface)
@@ -56,27 +49,175 @@ void Launch_Interface(option *io)
}
default :
{
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Printf("\n== Err in file %s at line %d\n\n",__FILE__,__LINE__);
Exit("");
break;
}
}
-
}while(!io->ready_to_go);
+
+
+ if(io->in_tree == 2)
+ {
+ PhyML_Printf("\n. Enter the name of the input tree file > ");
+ Getstring_Stdin(io->in_tree_file);
+ io->fp_in_tree = Openfile(io->in_tree_file,0);
+ }
+
+ if((io->mod->whichmodel == CUSTOMAA) && (io->datatype == AA))
+ {
+ char *filename;
+
+ filename = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+
+ fflush(NULL);
+ PhyML_Printf("\n");
+ PhyML_Printf("\n. Enter the rate matrix file name > "); fflush(NULL);
+ Getstring_Stdin(filename);
+ io->mod->fp_aa_rate_mat = Openfile(filename,0);
+ strcpy(io->mod->aa_rate_mat_file->s,filename);
+ PhyML_Printf("\n");
+ Free(filename);
+ fflush(NULL);
+ }
+
+ if((io->mod->s_opt->n_rand_starts) &&
+ (io->mod->s_opt->topo_search == NNI_MOVE) &&
+ (io->mod->s_opt->random_input_tree))
+ {
+ Warn_And_Exit("\n. The random starting tree option is only compatible with SPR based search options.\n");
+ }
+
+ if ((io->datatype == NT) && (io->mod->whichmodel > 10))
+ {
+ char choix;
+ PhyML_Printf("\n== Err: model incompatible with the data type. Please use JC69, K80, F81, HKY, F84, TN93 or GTR\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Warn_And_Exit("\n");
+ }
+ else if ((io->datatype == AA) && (io->mod->whichmodel < 11))
+ {
+ char choix;
+ PhyML_Printf("\n== Err: model incompatible with the data type. Please use LG, Dayhoff, JTT, MtREV, WAG, DCMut, RtREV, CpREV, VT, Blosum62, MtMam, MtArt, HIVw, HIVb or AB.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
+ Exit("\n");
+ }
+
+ if(io->m4_model == YES)
+ {
+#ifdef M4
+ io->mod->ns *= io->mod->m4mod->n_h;
+ io->mod->use_m4mod = 1;
+ M4_Make_Complete(io->mod->m4mod->n_h,
+ io->mod->m4mod->n_o,
+ io->mod->m4mod);
+#endif
+ }
+ else
+ {
+ io->mod->s_opt->opt_cov_delta = 0;
+ io->mod->s_opt->opt_cov_alpha = 0;
+ io->mod->s_opt->opt_cov_free_rates = 0;
+ }
+
+ if((io->mod->s_opt->opt_cov_free_rates) && (io->mod->s_opt->opt_cov_alpha))
+ {
+ io->mod->s_opt->opt_cov_free_rates = 0;
+ io->mod->m4mod->use_cov_alpha = 0;
+ io->mod->m4mod->use_cov_free = 1;
+ }
+
+
+ if(io->print_site_lnl)
+ {
+ strcpy(io->out_lk_file,io->in_align_file);
+ strcat(io->out_lk_file, "_phyml_lk.txt");
+
+ if(io->append_run_ID) { strcat(io->out_lk_file,"_"); strcat(io->out_lk_file,io->run_id_string); }
+ io->fp_out_lk = Openfile(io->out_lk_file,1);
+ }
+
+ if(io->print_trace)
+ {
+ strcpy(io->out_trace_file,io->in_align_file);
+ strcat(io->out_trace_file,"_phyml_trace.txt");
+
+ if(io->append_run_ID) { strcat(io->out_trace_file,"_"); strcat(io->out_trace_file,io->run_id_string); }
+ io->fp_out_trace = Openfile(io->out_trace_file,1);
+ }
+
+ if(io->mod->s_opt->random_input_tree)
+ {
+ strcpy(io->out_trees_file,io->in_align_file);
+ strcat(io->out_trees_file,"_phyml_trees.txt");
+
+ if(io->append_run_ID) { strcat(io->out_trees_file,"_"); strcat(io->out_trees_file,io->run_id_string); }
+ io->fp_out_trees = Openfile(io->out_trees_file,1);
+ }
+
+ if((io->print_boot_trees) && (io->n_boot_replicates > 0))
+ {
+ strcpy(io->out_boot_tree_file,io->in_align_file);
+ strcat(io->out_boot_tree_file,"_phyml_boot_trees.txt");
+
+ if(io->append_run_ID) { strcat(io->out_boot_tree_file,"_"); strcat(io->out_boot_tree_file,io->run_id_string); }
+ io->fp_out_boot_tree = Openfile(io->out_boot_tree_file,1);
+
+ strcpy(io->out_boot_stats_file,io->in_align_file);
+ strcat(io->out_boot_stats_file,"_phyml_boot_stats.txt");
+
+ if(io->append_run_ID) { strcat(io->out_boot_stats_file,"_"); strcat(io->out_boot_stats_file,io->run_id_string); }
+ io->fp_out_boot_stats = Openfile(io->out_boot_stats_file,1);
+ }
+
+ if(io->append_run_ID)
+ {
+ strcat(io->out_tree_file,"_");
+ strcat(io->out_stats_file,"_");
+ strcat(io->out_tree_file,io->run_id_string);
+ strcat(io->out_stats_file,io->run_id_string);
+ }
+
+ if(io->mod->ras->n_catg == 1) io->mod->s_opt->opt_alpha = 0;
+
+ if(io->mod->whichmodel != K80 &&
+ io->mod->whichmodel != HKY85 &&
+ io->mod->whichmodel != F84 &&
+ io->mod->whichmodel != TN93)
+ {
+ io->mod->s_opt->opt_kappa = 0;
+ }
+
+ io->fp_out_tree = Openfile(io->out_tree_file,1);
+ io->fp_out_stats = Openfile(io->out_stats_file,1);
+
+// VINCENT: do not necessarily optimize relative rate parameters, they could be set by user
+ if(io->mod->whichmodel == GTR)
+ {
+ if (io->mod->s_opt->opt_subst_param)
+ io->mod->s_opt->opt_rr = YES;
+ else
+ io->mod->s_opt->opt_rr = NO;
+ }
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Clear()
{
#ifdef WIN32
system("cls");
#elif UNIX
- printf("\033[2J\033[H");
+ PhyML_Printf("\033[2J\033[H");
#endif
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
void Launch_Interface_Input(option *io)
{
@@ -91,26 +232,26 @@ void Launch_Interface_Input(option *io)
char *n_data_sets;
- printf("\n\n");
- printf("\n. Enter the tree file name > "); fflush(NULL);
+ PhyML_Printf("\n\n");
+ PhyML_Printf("\n. Enter the tree file name > "); fflush(NULL);
Getstring_Stdin(io->in_tree_file);
io->fp_in_tree = Openfile(io->in_tree_file,0);
- printf("\n");
+ PhyML_Printf("\n");
- printf("\n. Enter the reference sequence file name > "); fflush(NULL);
- Getstring_Stdin(io->in_seq_file);
- io->fp_in_seq = Openfile(io->in_seq_file,0);
- printf("\n");
+ PhyML_Printf("\n. Enter the reference sequence file name > "); fflush(NULL);
+ Getstring_Stdin(io->in_align_file);
+ io->fp_in_align = Openfile(io->in_align_file,0);
+ PhyML_Printf("\n");
- printf("\n. Number of data sets > ");
+ PhyML_Printf("\n. Number of data sets > ");
n_data_sets = (char *)mCalloc(10000,sizeof(char));
Getstring_Stdin(n_data_sets);
n_trial = 0;
while((!atoi(n_data_sets)) || (atoi(n_data_sets) < 0))
{
- if(++n_trial > 10) Exit("\n. Err : the number of sets must be a positive integer");
- printf("\n. The number of sets must be a positive integer");
- printf("\n. Enter a new value > ");
+ if(++n_trial > 10) Exit("\n== Err : the number of sets must be a positive integer");
+ PhyML_Printf("\n. The number of sets must be a positive integer");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(n_data_sets);
}
io->n_data_set_asked = atoi(n_data_sets);
@@ -118,72 +259,60 @@ void Launch_Interface_Input(option *io)
#elif OPTIMIZ
- printf("\n. Enter the tree file name > "); fflush(NULL);
+ PhyML_Printf("\n. Enter the tree file name > "); fflush(NULL);
Getstring_Stdin(io->in_tree_file);
io->fp_in_tree = Openfile(io->in_tree_file,0);
- printf("\n");
+ PhyML_Printf("\n");
- printf("\n. Enter the reference sequence file name > "); fflush(NULL);
- Getstring_Stdin(io->in_seq_file);
- io->fp_in_seq = Openfile(io->in_seq_file,0);
- printf("\n");
+ PhyML_Printf("\n. Enter the reference sequence file name > "); fflush(NULL);
+ Getstring_Stdin(io->in_align_file);
+ io->fp_in_align = Openfile(io->in_align_file,0);
+ PhyML_Printf("\n");
-#elif defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
+#elif defined(PHYML) || defined(PART) || defined(PHYML_INSERT)
- printf("\n. Enter the sequence file name > "); fflush(NULL);
- Getstring_Stdin(io->in_seq_file);
- io->fp_in_seq = Openfile(io->in_seq_file,0);
+ PhyML_Printf("\n. Enter the sequence file name > "); fflush(NULL);
+ Getstring_Stdin(io->in_align_file);
+ io->fp_in_align = Openfile(io->in_align_file,0);
#endif
-#if defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
+#if defined(PHYML) || defined(PART) || defined(PHYML_INSERT)
- strcpy(io->out_stats_file,io->in_seq_file);
- strcat(io->out_stats_file,"_phyml_stats.txt");
+ strcpy(io->out_stats_file,io->in_align_file);
- strcpy(io->out_tree_file,io->in_seq_file);
+ strcat(io->out_stats_file,"_phyml_stats.txt");
+ strcpy(io->out_tree_file,io->in_align_file);
+
strcat(io->out_tree_file,"_phyml_tree.txt");
+ strcpy(io->out_lk_file,io->in_align_file);
- strcpy(io->out_lk_file,io->in_seq_file);
strcat(io->out_lk_file,"_phyml_lk.txt");
-
-
#endif
-
-#ifdef WIN32
#ifdef EVOLVE
if(Filexists("evolve_out.txt"));
#elif OPTIMIZ
if(Filexists("optimiz_out.txt"))
-#elif defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
- if(Filexists(io->out_stat_file))
-#endif
-#elif UNIX
-#ifdef EVOLVE
- if(Filexists("evolve_out"));
-#elif OPTIMIZ
- if(Filexists("optimiz_out"))
-#elif defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
- if(Filexists(io->out_stats_file))
-#endif
+#elif defined(PHYML) || defined(PART) || defined(PHYML_INSERT)
+ if(Filexists(io->out_stats_file))
#endif
{
- printf("\n");
+ PhyML_Printf("\n");
#ifdef EVOLVE
- printf("\n. A file 'evolve_out' already exists");
+ PhyML_Printf("\n. A file 'evolve_out' already exists");
#elif OPTIMIZ
- printf("\n. A file 'optimiz_out' already exists");
-#elif defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
- printf("\n. A file '%s' already exists",io->out_stats_file);
+ PhyML_Printf("\n. A file 'optimiz_out' already exists");
+#elif defined(PHYML) || defined(PART) || defined(PHYML_INSERT)
+ PhyML_Printf("\n. A file '%s' already exists",io->out_stats_file);
#endif
- printf("\n. Do you want to Replace it or Append to it ? ");
+ PhyML_Printf("\n. Do you want to Replace it or Append to it ? ");
n_trial = 0;
do
{
- printf("\n. Please type R or A > ");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Please type R or A > ");
+ if(!scanf("%c",&choix)) Exit("\n");
if(choix == '\n') choix = 'r';
else getchar();
if(++n_trial>10) Exit("\n");
@@ -194,40 +323,30 @@ void Launch_Interface_Input(option *io)
else io->out_stats_file_open_mode = 2;
}
- io->fp_out_stats = Openfile(io->out_stats_file,io->out_stats_file_open_mode);
+ /* io->fp_out_stats = Openfile(io->out_stats_file,io->out_stats_file_open_mode); */
-#ifdef WIN32
#ifdef EVOLVE
if(Filexists("evolve_seq.txt"))
#elif OPTIMIZ
if(Filexists("optimiz_tree.txt"))
-#elif defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
+#elif defined(PHYML) || defined(PART) || defined(PHYML_INSERT)
if(Filexists(io->out_tree_file))
-#endif
-#elif UNIX
-#ifdef EVOLVE
- if(Filexists("evolve_seq"))
-#elif OPTIMIZ
- if(Filexists("optimiz_tree"))
-#elif defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
- if(Filexists(io->out_tree_file))
-#endif
#endif
{
- printf("\n");
+ PhyML_Printf("\n");
#ifdef EVOLVE
- printf("\n. A file 'evolve_seq' already exists");
+ PhyML_Printf("\n. A file 'evolve_seq' already exists");
#elif OPTIMIZ
- printf("\n. A file 'optimiz_tree' already exists");
-#elif defined(PHYML) || defined(MG) || defined(PHYML_INSERT)
- printf("\n. A file '%s' already exists",io->out_tree_file);
+ PhyML_Printf("\n. A file 'optimiz_tree' already exists");
+#elif defined(PHYML) || defined(PART) || defined(PHYML_INSERT)
+ PhyML_Printf("\n. A file '%s' already exists",io->out_tree_file);
#endif
- printf("\n. Do you want to Replace it or Append to it ? ");
+ PhyML_Printf("\n. Do you want to Replace it or Append to it ? ");
n_trial = 0;
do
{
- printf("\n. Please type R or A > ");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Please type R or A > ");
+ if(!scanf("%c",&choix)) Exit("\n");
if(choix == '\n') choix = 'r';
else getchar();
Uppercase(&choix);
@@ -237,10 +356,13 @@ void Launch_Interface_Input(option *io)
if(choix == 'R') io->out_tree_file_open_mode = 1;
else io->out_tree_file_open_mode = 2;
}
- io->fp_out_tree = Openfile(io->out_tree_file,io->out_tree_file_open_mode);
+
+ /* io->fp_out_tree = Openfile(io->out_tree_file,io->out_tree_file_open_mode); */
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Launch_Interface_Data_Type(option *io)
{
@@ -256,31 +378,34 @@ void Launch_Interface_Data_Type(option *io)
buff = (char *)mCalloc(100,sizeof(char));
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" ................... \n");
- printf(" Menu : Input Data \n");
- printf(" ......................... \n");
+ PhyML_Printf(" ................... \n");
+ PhyML_Printf(" Menu : Input Data \n");
+ PhyML_Printf(" ......................... \n");
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" [+] "
+ PhyML_Printf(" [+] "
".................................... Next sub-menu\n");
- printf(" [-] "
+ PhyML_Printf(" [-] "
"................................ Previous sub-menu\n");
- printf(" [Y] "
+ PhyML_Printf(" [Y] "
".............................. Launch the analysis\n");
- printf("\n");
+ PhyML_Printf("\n");
- printf(" [D] "
- "............................... Data type (DNA/AA) "
- " %-15s \n",
- (io->mod->datatype)?("AA"):("DNA"));
+ if(io->datatype == NT) strcpy(s,"DNA");
+ else if(io->datatype == AA) strcpy(s,"AA");
+ else strcpy(s,"Generic");
+
+ PhyML_Printf(" [D] "
+ "....................... Data type (DNA/AA/Generic) "
+ " %-15s \n",s);
- printf(" [I] "
+ PhyML_Printf(" [I] "
"...... Input sequences interleaved (or sequential) "
" %-15s \n",
(io->interleaved)?("interleaved"):("sequential"));
@@ -289,16 +414,22 @@ void Launch_Interface_Data_Type(option *io)
sprintf(s," (%d sets)",io->n_data_sets);
strcpy(buff,(io->n_data_sets > 1)?("yes"):("no"));
buff=strcat(buff,(io->n_data_sets > 1)?(s):("\0"));
- printf(" [M] "
+ PhyML_Printf(" [M] "
"....................... Analyze multiple data sets "
" %-15s \n",buff);
+ if(!io->append_run_ID) strcpy(s,"none");
+ else strcpy(s,io->run_id_string);
+ PhyML_Printf(" [R] "
+ "........................................... Run ID "
+ " %-15s \n",s);
+
- printf("\n\n. Are these settings correct ? "
+ PhyML_Printf("\n\n. Are these settings correct ? "
"(type '+', '-', 'Y' or other letter for one to change) ");
- scanf("%c",&choix);
+ if(!scanf("%c",&choix)) Exit("\n");
if(choix != '\n') getchar(); /* \n */
fflush(NULL);
@@ -311,36 +442,45 @@ void Launch_Interface_Data_Type(option *io)
/* io->curr_interface++; */
/* break; */
/* } */
+ case 'R' :
+ {
+ io->append_run_ID = (io->append_run_ID)?(0):(1);
+ PhyML_Printf("\n. Enter a run ID (any string of characters) > ");
+ Getstring_Stdin(io->run_id_string);
+ break;
+ }
+
+
case 'M' :
{
char *c;
int n_trial;
- printf("\n. How many data sets > ");
+ PhyML_Printf("\n. How many data sets > ");
c = (char *)mCalloc(100,sizeof(char));
Getstring_Stdin(c);
n_trial = 0;
while((!atoi(c)) || (atoi(c) < 0))
{
- if(++n_trial > 10) Exit("\n. Err : The number of data sets must be a positive integer");
- printf("\n. The number of data sets must be a positive integer");
- printf("\n. Enter a new value > ");
+ if(++n_trial > 10) Exit("\n== Err : The number of data sets must be a positive integer");
+ PhyML_Printf("\n. The number of data sets must be a positive integer");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(c);
}
io->n_data_sets = atoi(c);
- #ifdef MG
+ #ifdef PART
if(io->n_data_sets > 1)
{
io->multigene = 1;
}
#endif
- if((io->mod->bootstrap > 1) && (io->n_data_sets > 1))
+ if((io->do_boot || io->do_tbe) && (io->n_data_sets > 1))
{
- printf("\n. Bootstrap option is not allowed with multiple data sets !\n");
- printf("\n. Type any key to exit.");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Bootstrap option is not allowed with multiple data sets !\n");
+ PhyML_Printf("\n. Type any key to exit.");
+ if(!scanf("%c",&choix)) Exit("\n");
Exit("\n");
}
@@ -356,21 +496,27 @@ void Launch_Interface_Data_Type(option *io)
}
case 'D' :
{
- if(io->mod->datatype == NT)
+ if(io->datatype == NT)
{
- io->mod->datatype = 1;
- io->mod->stepsize = 1;
- io->mod->ns = 20;
- io->mod->whichmodel = LG;
- strcpy(io->mod->modelname,"LG");
+ io->datatype = AA;
+ io->mod->ns = 20;
+ io->mod->s_opt->opt_kappa = 0;
+ io->mod->whichmodel = LG;
+ strcpy(io->mod->modelname->s,"LG");
}
- else
+ else if(io->datatype == AA)
{
- io->mod->datatype = 0;
- io->mod->stepsize = 1;
- io->mod->ns = 4;
- io->mod->whichmodel = HKY85;
- strcpy(io->mod->modelname,"HKY85");
+ io->datatype = GENERIC;
+ io->mod->whichmodel = JC69;
+ strcpy(io->mod->modelname->s,"JC69");
+ strcpy(io->nt_or_cd,"natural numbers");
+ }
+ else if(io->datatype == GENERIC)
+ {
+ io->datatype = NT;
+ io->mod->ns = 4;
+ io->mod->whichmodel = HKY85;
+ strcpy(io->mod->modelname->s,"HKY85");
strcpy(io->nt_or_cd,"nucleotides");
}
break;
@@ -399,7 +545,9 @@ void Launch_Interface_Data_Type(option *io)
Free(s);
Free(buff);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Launch_Interface_Model(option *io)
{
@@ -413,32 +561,32 @@ void Launch_Interface_Model(option *io)
if(io->config_multigene) Print_Data_Set_Number(io,stdout);
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" ........................... \n");
- printf(" Menu : Substitution Model \n");
- printf(" ................................. \n");
+ PhyML_Printf(" ........................... \n");
+ PhyML_Printf(" Menu : Substitution Model \n");
+ PhyML_Printf(" ................................. \n");
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" [+] "
+ PhyML_Printf(" [+] "
".................................... Next sub-menu\n");
- printf(" [-] "
+ PhyML_Printf(" [-] "
"................................ Previous sub-menu\n");
- printf(" [Y] "
+ PhyML_Printf(" [Y] "
".............................. Launch the analysis\n");
- printf("\n");
+ PhyML_Printf("\n");
- if (io->mod->datatype == NT)
+ if (io->datatype == NT)
{
if(!strcmp(io->nt_or_cd,"nucleotides"))
{
- printf(" [M] "
+ PhyML_Printf(" [M] "
"................. Model of nucleotide substitution "
- " %-15s \n", io->mod->modelname);
+ " %-15s \n", io->mod->modelname->s);
if((io->mod->whichmodel == F81) ||
(io->mod->whichmodel == HKY85) ||
@@ -447,14 +595,14 @@ void Launch_Interface_Model(option *io)
(io->mod->whichmodel == GTR) ||
(io->mod->whichmodel == CUSTOM))
{
-/* printf(" [F] " */
+/* PhyML_Printf(" [F] " */
/* ".......... Base frequency estimates (empirical/ML) " */
/* " %-15s \n", */
/* (io->mod->s_opt->opt_state_freq)?("ML"):("empirical")); */
/* } */
/* else if(io->mod->whichmodel == CUSTOM) */
/* { */
- printf(" [F] "
+ PhyML_Printf(" [F] "
"................. Optimise equilibrium frequencies "
" %-15s \n",
(io->mod->s_opt->opt_state_freq)?("yes"):("no"));
@@ -465,60 +613,67 @@ void Launch_Interface_Model(option *io)
{
if(!io->mod->s_opt->opt_state_freq)
{
- printf(" [E] "
+ PhyML_Printf(" [E] "
"......... Equilibrium frequencies (empirical/user) "
" %-15s \n",
- (io->mod->s_opt->user_state_freq)?("user defined"):("empirical"));
+ (io->mod->e_frq->user_state_freq)?("user defined"):("empirical"));
}
- printf(" [K] "
+ PhyML_Printf(" [K] "
"............................. Current custom model "
- " %-15s \n", io->mod->custom_mod_string);
+ " %-15s \n", io->mod->custom_mod_string->s);
- printf(" [O] "
+ PhyML_Printf(" [O] "
"................ Optimise relative rate parameters "
" %-15s \n",(io->mod->s_opt->opt_rr)?("yes"):("no"));
}
}
}
- else
+ else if(io->datatype == AA)
{
- printf(" [M] "
+ PhyML_Printf(" [M] "
"................ Model of amino-acids substitution "
- " %-15s \n", io->mod->modelname);
+ " %-15s \n", io->mod->modelname->s);
- printf(" [F] "
+ PhyML_Printf(" [F] "
". Amino acid frequencies (empirical/model defined) "
" %-15s \n",
(io->mod->s_opt->opt_state_freq)?("empirical"):("model"));
}
+ else if(io->datatype == GENERIC)
+ {
+ PhyML_Printf(" [M] "
+ "................. Model of nucleotide substitution "
+ " %-15s \n", io->mod->modelname->s);
+ }
-
- if ((io->mod->datatype == NT) &&
+ if ((io->datatype == NT) &&
((io->mod->whichmodel == K80) ||
(io->mod->whichmodel == HKY85)||
(io->mod->whichmodel == F84) ||
(io->mod->whichmodel == TN93)))
{
strcpy(s,(io->mod->s_opt->opt_kappa)?("estimated"):("fixed"));
- (io->mod->s_opt->opt_kappa)?((char *)strcat(s,"")):((char *)strcat(s," (ts/tv = "));
-/* (io->mod->s_opt->opt_kappa)?((char *)strcat(s,"")):((char *)sprintf(s+(int)strlen((char *)s),"%3.2f)",io->mod->kappa)); */
+ if(io->mod->s_opt->opt_kappa) strcat(s,"");
+ else strcat(s," (ts/tv = ");
+
+/* (io->mod->s_opt->opt_kappa)?((char *)strcat(s,"")):((char *)sprintf(s+(int)strlen((char *)s),"%3.2f)",io->mod->kappa->v)); */
if(io->mod->s_opt->opt_kappa)
{
strcat((char *)s,"");
}
else
{
- sprintf((char *)(s+(int)strlen(s)),"%3.2f)",io->mod->kappa);
+ sprintf((char *)(s+(int)strlen(s)),"%3.2f)",io->mod->kappa->v);
}
- printf(" [T] "
+ PhyML_Printf(" [T] "
".................... Ts/tv ratio (fixed/estimated) "
" %-15s \n",s);
}
-
- (io->mod->s_opt->opt_pinvar)?(strcpy(s,"estimated")):(strcpy(s,"fixed"));
- (io->mod->s_opt->opt_pinvar)?((char *)strcat(s,"")):((char *)strcat(s," (p-invar = "));
+
+ strcpy(s,io->mod->s_opt->opt_pinvar?"estimated":"fixed");
+ strcat(s,io->mod->s_opt->opt_pinvar?"":" (p-invar = ");
if(io->mod->s_opt->opt_pinvar)
{
@@ -526,31 +681,39 @@ void Launch_Interface_Model(option *io)
}
else
{
- sprintf((char *)(s+strlen((char *)s)),"%3.2f)",io->mod->pinvar);
+ sprintf((char *)(s+strlen((char *)s)),"%3.2f)",io->mod->ras->pinvar->v);
}
- printf(" [V] "
+ PhyML_Printf(" [V] "
". Proportion of invariable sites (fixed/estimated)"
" %-15s \n",s);
- printf(" [R] "
+ PhyML_Printf(" [R] "
"....... One category of substitution rate (yes/no) "
" %-15s \n",
- (io->mod->n_catg > 1)?("no"):("yes"));
+ (io->mod->ras->n_catg > 1)?("no"):("yes"));
- if(io->mod->n_catg > 1)
+ if(io->mod->ras->n_catg > 1)
{
- printf(" [C] "
+ PhyML_Printf(" [C] "
"........... Number of substitution rate categories "
" %-15d \n",
- io->mod->n_catg);
+ io->mod->ras->n_catg);
+ }
+
+
+ if(io->mod->ras->n_catg > 1)
+ {
+ PhyML_Printf(" [G] "
+ "............. Gamma distributed rates across sites "
+ " %-15s \n",(io->mod->ras->free_mixt_rates)?("no"):("yes"));
}
- if(io->mod->n_catg > 1)
+ if((io->mod->ras->n_catg > 1) && (io->mod->ras->free_mixt_rates == NO))
{
strcpy(s,(io->mod->s_opt->opt_alpha)?("estimated"):("fixed"));
- (io->mod->s_opt->opt_alpha)?(strcat(s, "")):(strcat(s," (alpha = "));
+ strcat(s,io->mod->s_opt->opt_alpha?"":" (alpha = ");
if(io->mod->s_opt->opt_alpha)
{
@@ -558,19 +721,28 @@ void Launch_Interface_Model(option *io)
}
else
{
- sprintf(s+strlen(s),"%3.2f)",io->mod->alpha);
+ sprintf(s+strlen(s),"%3.2f)",io->mod->ras->alpha->v);
}
- printf(" [A] "
+ PhyML_Printf(" [A] "
"... Gamma distribution parameter (fixed/estimated) "
" %-15s \n",s);
+
+
+/* strcpy(s,(io->mod->ras->gamma_median)?("median"):("mean")); */
+
+/* PhyML_Printf(" [G] " */
+/* ".........'Middle' of each rate class (mean/median) " */
+/* " %-15s \n",s); */
+
+
}
- printf("\n\n. Are these settings correct ? "
+ PhyML_Printf("\n\n. Are these settings correct ? "
"(type '+', '-', 'Y' or other letter for one to change) ");
- scanf("%c",&choix);
+ if(!scanf("%c",&choix)) Exit("\n");
if(choix != '\n') getchar(); /* \n */
Uppercase(&choix);
@@ -583,6 +755,12 @@ void Launch_Interface_Model(option *io)
/* break; */
/* } */
+ case 'G' :
+ {
+ io->mod->ras->free_mixt_rates = (io->mod->ras->free_mixt_rates)?(NO):(YES);
+ break;
+ }
+
case 'O' :
{
io->mod->s_opt->opt_rr = (io->mod->s_opt->opt_rr)?(0):(1);
@@ -593,46 +771,52 @@ void Launch_Interface_Model(option *io)
{
int i,j;
char **rr_param,*rr;
- model *mod;
- int curr_param;
+ t_mod *mod;
int n_trial;
if(io->mod->whichmodel == CUSTOM)
{
rr_param = (char **)mCalloc(6,sizeof(char *));
- For(i,6) rr_param[i] = (char *)mCalloc(10,sizeof(char));
+ for(i=0;i<6;i++) rr_param[i] = (char *)mCalloc(10,sizeof(char));
rr = (char *)mCalloc(50,sizeof(char));
mod = io->mod;
+ mod->s_opt->opt_rr = 1;
n_trial = 0;
do
{
- printf("\n. Enter a new custom model > ");
- Getstring_Stdin(io->mod->custom_mod_string);
- if(strlen(io->mod->custom_mod_string) == 6)
+ PhyML_Printf("\n. Enter a new custom model > ");
+ Getstring_Stdin(io->mod->custom_mod_string->s);
+ if(strlen(io->mod->custom_mod_string->s) == 6)
{
- For(i,6)
+ for(i=0;i<6;i++)
{
- while(!isdigit((int)io->mod->custom_mod_string[i]))
+ while(!isdigit((int)io->mod->custom_mod_string->s[i]))
{
- if(++n_trial > 10) Exit("\n. Err : this string is not valid !\n");
- printf("\n. This string is not valid\n");
- printf("\n. Enter a new model > ");
- Getstring_Stdin(io->mod->custom_mod_string);
+ if(++n_trial > 10) Exit("\n== Err : this string is not valid !\n");
+ PhyML_Printf("\n. This string is not valid\n");
+ PhyML_Printf("\n. Enter a new model > ");
+ Getstring_Stdin(io->mod->custom_mod_string->s);
}
}
if(i == 6) break;
}
else
{
- printf("\n. The string should be of length 6\n");
+ PhyML_Printf("\n. The string should be of length 6\n");
n_trial++;
}
}while(n_trial < 10);
if(n_trial == 10) Exit("");
- Translate_Custom_Mod_String(io->mod);
+ if(!mod->r_mat)
+ {
+ mod->r_mat = (t_rmat *)Make_Rmat(mod->ns);
+ Init_Rmat(mod->r_mat);
+ Make_Custom_Model(mod);
+ Translate_Custom_Mod_String(io->mod);
+ }
strcpy(rr_param[0],"A<->C");
strcpy(rr_param[1],"A<->G");
@@ -641,22 +825,21 @@ void Launch_Interface_Model(option *io)
strcpy(rr_param[4],"C<->T");
strcpy(rr_param[5],"G<->T");
- printf("\n. Set the relative rate values\n");
- curr_param = 0;
- For(i,mod->n_diff_rr)
+ PhyML_Printf("\n. Set the relative rate values\n");
+ for(i=0;ir_mat->n_diff_rr;i++)
{
sprintf(rr,"\n. [");
- For(j,6)
+ for(j=0;j<6;j++)
{
- if(mod->rr_num[j] == i)
+ if(mod->r_mat->rr_num->v[j] == i)
{
sprintf(rr+strlen(rr),"%s = ",rr_param[j]);
}
}
sprintf(rr+strlen(rr)-3,"]");
- printf("%s",rr);
+ PhyML_Printf("%s",rr);
- printf(" (current=%.2f) > ",mod->rr_val[i]);
+ PhyML_Printf(" (current=%.2f) > ",mod->r_mat->rr_val->v[i]);
Getstring_Stdin(rr);
@@ -666,16 +849,16 @@ void Launch_Interface_Model(option *io)
while((atof(rr) < .0))
{
if(++n_trial > 10)
- Exit("\n. Err : the value of this parameter must be a positive number\n");
- printf("\n. The value of this parameter must be a positive number\n");
- printf("\n. Enter a new value > ");
+ Exit("\n== Err : the value of this parameter must be a positive number\n");
+ PhyML_Printf("\n. The value of this parameter must be a positive number\n");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(rr);
}
- io->mod->rr_val[i] = (phydbl)atof(rr);
+ io->mod->r_mat->rr_val->v[i] = (phydbl)atof(rr);
}
}
- For(i,5) Free(rr_param[i]);
+ for(i=0;i<6;i++) Free(rr_param[i]);
Free(rr_param);
Free(rr);
}
@@ -687,9 +870,9 @@ void Launch_Interface_Model(option *io)
if(io->mod->whichmodel == CUSTOM)
{
- io->mod->s_opt->user_state_freq = (io->mod->s_opt->user_state_freq)?(0):(1);
+ io->mod->e_frq->user_state_freq = (io->mod->e_frq->user_state_freq)?(0):(1);
- if(io->mod->s_opt->user_state_freq)
+ if(io->mod->e_frq->user_state_freq)
{
if(!io->mod->s_opt->opt_state_freq)
{
@@ -699,7 +882,7 @@ void Launch_Interface_Model(option *io)
int n_trial;
bases = (char **)mCalloc(4,sizeof(char *));
- For(i,4) bases[i] = (char *)mCalloc(50,sizeof(char));
+ for(i=0;i<4;i++) bases[i] = (char *)mCalloc(50,sizeof(char));
bs = (char *)mCalloc(100,sizeof(char));
strcpy(bases[0],". f(A)> ");
@@ -707,41 +890,41 @@ void Launch_Interface_Model(option *io)
strcpy(bases[2],". f(G)> ");
strcpy(bases[3],". f(T)> ");
- printf("\n. Set nucleotide frequencies \n");
+ PhyML_Printf("\n. Set nucleotide frequencies \n");
sum = .0;
- For(i,4)
+ for(i=0;i<4;i++)
{
- printf("%s",bases[i]);
+ PhyML_Printf("%s",bases[i]);
Getstring_Stdin(bs);
n_trial = 0;
while((atof(bs) < .0001) || (bs[0] == '\0'))
{
if(++n_trial > 10)
- Exit("\n. Err : the value of this parameter must be a positive number\n");
- printf("\n. The value of this parameter must be a positive number\n");
- printf("\n. Enter a new value > ");
+ Exit("\n== Err : the value of this parameter must be a positive number\n");
+ PhyML_Printf("\n. The value of this parameter must be a positive number\n");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(bs);
}
- io->mod->user_b_freq[i] = (phydbl)atof(bs);
- sum += io->mod->user_b_freq[i];
+ io->mod->e_frq->user_b_freq->v[i] = (phydbl)atof(bs);
+ sum += io->mod->e_frq->user_b_freq->v[i];
}
- For(i,4) io->mod->user_b_freq[i] /= sum;
+ for(i=0;i<4;i++) io->mod->e_frq->user_b_freq->v[i] /= sum;
if(sum > 1.0 || sum < 1.0)
{
- printf("\n. The nucleotide frequencies have to be normalised in order to sum to 1.0.\n");
- printf("\n. The frequencies are now : f(A)=%f, f(C)=%f, f(G)=%f, f(T)=%f.\n",
- io->mod->user_b_freq[0],
- io->mod->user_b_freq[1],
- io->mod->user_b_freq[2],
- io->mod->user_b_freq[3]);
- printf("\n. Enter any key to continue.\n");
- scanf("%c",bs);
+ PhyML_Printf("\n. The nucleotide frequencies have to be normalised in order to sum to 1.0.\n");
+ PhyML_Printf("\n. The frequencies are now : f(A)=%f, f(C)=%f, f(G)=%f, f(T)=%f.\n",
+ io->mod->e_frq->user_b_freq->v[0],
+ io->mod->e_frq->user_b_freq->v[1],
+ io->mod->e_frq->user_b_freq->v[2],
+ io->mod->e_frq->user_b_freq->v[3]);
+ PhyML_Printf("\n. Enter any key to continue.\n");
+ if(!scanf("%c",bs)) Exit("\n");
}
- For(i,4) Free(bases[i]);
+ for(i=0;i<4;i++) Free(bases[i]);
Free(bases);
Free(bs);
}
@@ -758,20 +941,22 @@ void Launch_Interface_Model(option *io)
char answer;
int n_trial;
+ answer = 0;
+
switch(io->mod->s_opt->opt_alpha)
{
case 0 :
{
- printf("\n. Optimise alpha ? [Y/n] ");
- scanf("%c",&answer);
+ PhyML_Printf("\n. Optimise alpha ? [Y/n] ");
+ if(!scanf("%c",&answer)) Exit("\n");
if(answer == '\n') answer = 'Y';
else getchar();
break;
}
case 1 :
{
- printf("\n. Optimise alpha ? [N/y] ");
- scanf("%c",&answer);
+ PhyML_Printf("\n. Optimise alpha ? [N/y] ");
+ if(!scanf("%c",&answer)) Exit("\n");
if(answer == '\n') answer = 'N';
else getchar();
break;
@@ -783,9 +968,9 @@ void Launch_Interface_Model(option *io)
while((answer != 'Y') && (answer != 'y') &&
(answer != 'N') && (answer != 'n'))
{
- if(++n_trial > 10) Exit("\n. Err : wrong answers !");
- printf("\n. Optimise alpha ? [N/y] ");
- scanf("%c",&answer);
+ if(++n_trial > 10) Exit("\n== Err : wrong answers !");
+ PhyML_Printf("\n. Optimise alpha ? [N/y] ");
+ if(!scanf("%c",&answer)) Exit("\n");
if(answer == '\n') answer = 'N';
else getchar();
}
@@ -795,26 +980,26 @@ void Launch_Interface_Model(option *io)
case 'Y' : case 'y' :
{
io->mod->s_opt->opt_alpha = 1;
- io->mod->s_opt->opt_num_param = 1;
+ io->mod->s_opt->opt_subst_param = 1;
break;
}
case 'N' : case 'n' :
{
char *a;
a = (char *)mCalloc(100,sizeof(char));
- io->mod->alpha = 10.0;
+ io->mod->ras->alpha->v = 10.0;
io->mod->s_opt->opt_alpha = 0;
- printf("\n. Enter your value of alpha > ");
+ PhyML_Printf("\n. Enter your value of alpha > ");
Getstring_Stdin(a);
n_trial = 0;
- while((!atof(a)) || (atof(a) < .0))
+ while(atof(a) < 1.E-10)
{
- if(++n_trial > 10) Exit("\n. Err : alpha must be a positive number\n");
- printf("\n. Alpha must be a positive number\n");
- printf("\n. Enter a new value > ");
+ if(++n_trial > 10) Exit("\n== Err : alpha must be > 1.E-10\n");
+ PhyML_Printf("\n. Alpha must be 1.E-10\n");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(a);
}
- io->mod->alpha = (phydbl)atof(a);
+ io->mod->ras->alpha->v = (phydbl)atof(a);
Free(a);
io->mod->s_opt->opt_alpha = 0;
break;
@@ -828,25 +1013,25 @@ void Launch_Interface_Model(option *io)
char *c;
int n_trial;
- printf("\n. Enter your number of categories > ");
+ PhyML_Printf("\n. Enter your number of categories > ");
c = (char *)mCalloc(100,sizeof(char));
Getstring_Stdin(c);
n_trial = 0;
while((!atoi(c)) || (atoi(c) < 0))
{
- if(++n_trial > 10) Exit("\n. Err : the number of categories must be a positive integer\n");
- printf("\n. The number of categories must be a positive integer\n");
- printf("\n. Enter a new value > ");
+ if(++n_trial > 10) Exit("\n== Err : the number of categories must be a positive integer\n");
+ PhyML_Printf("\n. The number of categories must be a positive integer\n");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(c);
}
- io->mod->n_catg = atoi(c);
+ io->mod->ras->n_catg = atoi(c);
Free(c);
break;
}
case 'R' :
{
- (io->mod->n_catg == 1)?(io->mod->n_catg = 4):(io->mod->n_catg = 1);
+ io->mod->ras->n_catg = (io->mod->ras->n_catg == 1)?(4):(1);
break;
}
@@ -854,21 +1039,24 @@ void Launch_Interface_Model(option *io)
{
char answer;
int n_trial;
+
+ answer = 0;
switch(io->mod->s_opt->opt_pinvar)
{
case 0 :
{
- printf("\n. Optimise p-invar ? [Y/n] ");
- scanf("%c", &answer);
+ PhyML_Printf("\n. Optimise p-invar ? [Y/n] ");
+ answer = 0;
+ if(!scanf("%c", &answer)) Exit("\n");
if(answer == '\n') answer = 'Y';
else getchar();
break;
}
case 1 :
{
- printf("\n. Optimise p-invar ? [N/y] ");
- scanf("%c", &answer);
+ PhyML_Printf("\n. Optimise p-invar ? [N/y] ");
+ if(!scanf("%c", &answer)) Exit("\n");
if(answer == '\n') answer = 'N';
else getchar();
break;
@@ -880,9 +1068,9 @@ void Launch_Interface_Model(option *io)
while((answer != 'Y') && (answer != 'y') &&
(answer != 'N') && (answer != 'n'))
{
- if(++n_trial > 10) Exit("\n. Err : wrong answers !");
- printf("\n. Optimise p-invar ? [N/y] ");
- scanf("%c", &answer);
+ if(++n_trial > 10) Exit("\n== Err : wrong answers !");
+ PhyML_Printf("\n. Optimise p-invar ? [N/y] ");
+ if(!scanf("%c", &answer)) Exit("\n");
if(answer == '\n') answer = 'N';
else getchar();
}
@@ -891,31 +1079,31 @@ void Launch_Interface_Model(option *io)
{
case 'Y' : case 'y' :
{
- io->mod->s_opt->opt_num_param = 1;
+ io->mod->s_opt->opt_subst_param = 1;
io->mod->s_opt->opt_pinvar = 1;
- io->mod->pinvar = 0.2;
- io->mod->invar = 1;
+ io->mod->ras->pinvar->v = 0.2;
+ io->mod->ras->invar = 1;
break;
}
case 'N' : case 'n' :
{
char *p;
p = (char *)mCalloc(100,sizeof(char));
- printf("\n. Enter your value of p-invar > ");
+ PhyML_Printf("\n. Enter your value of p-invar > ");
Getstring_Stdin(p);
n_trial = 0;
while((atof(p) < 0.0) || (atof(p) > 1.0))
{
if(++n_trial > 10)
- Exit("\n. Err : the proportion of invariable sites must be a positive number between 0.0 and 1.0");
- printf("\n. The proportion must be a positive number between 0.0 and 1.0\n");
- printf("\n. Enter a new value > ");
+ Exit("\n== Err : the proportion of invariable sites must be a positive number between 0.0 and 1.0");
+ PhyML_Printf("\n. The proportion must be a positive number between 0.0 and 1.0\n");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(p);
}
- io->mod->pinvar = (phydbl)atof(p);
+ io->mod->ras->pinvar->v = (phydbl)atof(p);
- if(io->mod->pinvar > 0.0+MDBL_MIN) io->mod->invar = 1;
- else io->mod->invar = 0;
+ if(io->mod->ras->pinvar->v > 0.0+SMALL) io->mod->ras->invar = 1;
+ else io->mod->ras->invar = 0;
Free(p);
@@ -930,16 +1118,18 @@ void Launch_Interface_Model(option *io)
{
char answer;
int n_trial;
-
- if((io->mod->datatype == AA) ||
+
+ answer = 0;
+
+ if((io->datatype == AA) ||
(io->mod->whichmodel == JC69)||
(io->mod->whichmodel == F81) ||
(io->mod->whichmodel == GTR) ||
(io->mod->whichmodel == CUSTOM))
{
- printf("\n. 'K' is not a valid choice for this model\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ PhyML_Printf("\n. 'K' is not a valid choice for this model\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
Exit("\n");
}
@@ -947,16 +1137,16 @@ void Launch_Interface_Model(option *io)
{
case 0 :
{
- printf("\n. Optimise ts/tv ratio ? [Y/n] ");
- scanf("%c", &answer);
+ PhyML_Printf("\n. Optimise ts/tv ratio ? [Y/n] ");
+ if(!scanf("%c", &answer)) Exit("\n");
if(answer == '\n') answer = 'Y';
else getchar();
break;
}
case 1 :
{
- printf("\n. Optimise ts/tv ratio ? [N/y] ");
- scanf("%c", &answer);
+ PhyML_Printf("\n. Optimise ts/tv ratio ? [N/y] ");
+ if(!scanf("%c", &answer)) Exit("\n");
if(answer == '\n') answer = 'N';
else getchar();
break;
@@ -968,9 +1158,9 @@ void Launch_Interface_Model(option *io)
while((answer != 'Y') && (answer != 'y') &&
(answer != 'N') && (answer != 'n'))
{
- if(++n_trial > 10) Exit("\n. Err : wrong answers !");
- printf("\n. Optimise ts/tv ratio ? [N/y] ");
- scanf("%c", &answer);
+ if(++n_trial > 10) Exit("\n== Err : wrong answers !");
+ PhyML_Printf("\n. Optimise ts/tv ratio ? [N/y] ");
+ if(!scanf("%c", &answer)) Exit("\n");
if(answer == '\n') answer = 'N';
else getchar();
}
@@ -979,9 +1169,8 @@ void Launch_Interface_Model(option *io)
{
case 'Y' : case 'y' :
{
- io->mod->kappa = 4.0;
- io->mod->s_opt->opt_num_param = 1;
- io->mod->s_opt->opt_kappa = 1;
+ io->mod->kappa->v = 4.0;
+ io->mod->s_opt->opt_subst_param = 1;
io->mod->s_opt->opt_kappa = 1;
if(io->mod->whichmodel == TN93)
io->mod->s_opt->opt_lambda = 1;
@@ -992,17 +1181,17 @@ void Launch_Interface_Model(option *io)
char *t;
t = (char *)mCalloc(100,sizeof(char));
io->mod->s_opt->opt_kappa = 0;
- printf("\n. Enter your value of the ts/tv ratio > ");
+ PhyML_Printf("\n. Enter your value of the ts/tv ratio > ");
Getstring_Stdin(t);
n_trial = 0;
- while((!atof(t)) || (atof(t) < .0))
+ while(atof(t) < .0)
{
- if(++n_trial > 10) Exit("\n. Err : the ts/tv ratio must be a positive number\n");
- printf("\n. The ratio must be a positive number");
- printf("\n. Enter a new value > ");
+ if(++n_trial > 10) Exit("\n== Err : the ts/tv ratio must be a positive number\n");
+ PhyML_Printf("\n. The ratio must be a positive number");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(t);
}
- io->mod->kappa = (phydbl)atof(t);
+ io->mod->kappa->v = (phydbl)atof(t);
io->mod->s_opt->opt_kappa = 0;
io->mod->s_opt->opt_lambda = 0;
Free(t);
@@ -1025,121 +1214,117 @@ void Launch_Interface_Model(option *io)
case 'M' :
{
- if(io->mod->datatype == NT)
+ if(io->datatype == NT)
{
if(!strcmp(io->nt_or_cd,"nucleotides"))
{
if(io->mod->whichmodel == JC69)
{
io->mod->whichmodel = K80;
- strcpy(io->mod->modelname,"K80");
}
else if(io->mod->whichmodel == K80)
{
io->mod->whichmodel = F81;
- strcpy(io->mod->modelname,"F81");
- io->mod->s_opt->opt_kappa = 0;
}
else if(io->mod->whichmodel == F81)
{
io->mod->whichmodel = HKY85;
- strcpy(io->mod->modelname,"HKY85");
}
else if(io->mod->whichmodel == HKY85)
{
io->mod->whichmodel = F84;
- strcpy(io->mod->modelname,"F84");
}
else if(io->mod->whichmodel == F84)
{
io->mod->whichmodel = TN93;
- strcpy(io->mod->modelname,"TN93");
- if(io->mod->s_opt->opt_kappa) io->mod->s_opt->opt_lambda = 1;
}
else if(io->mod->whichmodel == TN93)
{
io->mod->whichmodel = GTR;
- strcpy(io->mod->modelname,"GTR");
- io->mod->s_opt->opt_kappa = 0;
}
else if(io->mod->whichmodel == GTR)
{
io->mod->whichmodel = CUSTOM;
- strcpy(io->mod->modelname,"custom");
- io->mod->s_opt->opt_kappa = 0;
}
else if(io->mod->whichmodel == CUSTOM)
{
io->mod->whichmodel = JC69;
- strcpy(io->mod->modelname,"JC69");
- io->mod->s_opt->opt_kappa = 0;
}
}
}
- else
+ else if(io->datatype == AA)
{
if(io->mod->whichmodel == LG)
{
io->mod->whichmodel = WAG;
- strcpy(io->mod->modelname,"WAG");
}
else if(io->mod->whichmodel == WAG)
{
io->mod->whichmodel = DAYHOFF;
- strcpy(io->mod->modelname,"Dayhoff");
}
else if(io->mod->whichmodel == DAYHOFF)
{
io->mod->whichmodel = JTT;
- strcpy(io->mod->modelname,"JTT");
}
else if(io->mod->whichmodel == JTT)
{
io->mod->whichmodel = BLOSUM62;
- strcpy(io->mod->modelname,"Blossum62");
}
else if(io->mod->whichmodel == BLOSUM62)
{
io->mod->whichmodel = MTREV;
- strcpy(io->mod->modelname,"MtREV");
}
else if(io->mod->whichmodel == MTREV)
{
io->mod->whichmodel = RTREV;
- strcpy(io->mod->modelname,"RtREV");
}
else if(io->mod->whichmodel == RTREV)
{
io->mod->whichmodel = CPREV;
- strcpy(io->mod->modelname,"CpREV");
}
else if(io->mod->whichmodel == CPREV)
{
io->mod->whichmodel = DCMUT;
- strcpy(io->mod->modelname,"DCMut");
}
else if(io->mod->whichmodel == DCMUT)
{
io->mod->whichmodel = VT;
- strcpy(io->mod->modelname,"VT");
}
else if(io->mod->whichmodel == VT)
{
io->mod->whichmodel = MTMAM;
- strcpy(io->mod->modelname,"MtMam");
}
else if(io->mod->whichmodel == MTMAM)
+ {
+ io->mod->whichmodel = MTART;
+ }
+ else if(io->mod->whichmodel == MTART)
+ {
+ io->mod->whichmodel = HIVW;
+ }
+ else if(io->mod->whichmodel == HIVW)
+ {
+ io->mod->whichmodel = HIVB;
+ }
+ else if(io->mod->whichmodel == HIVB)
+ {
+ io->mod->whichmodel = AB;
+ }
+ else if(io->mod->whichmodel == AB)
{
io->mod->whichmodel = CUSTOMAA;
- strcpy(io->mod->modelname,"Read from file");
}
else if(io->mod->whichmodel == CUSTOMAA)
{
io->mod->whichmodel = LG;
- strcpy(io->mod->modelname,"LG");
}
}
+ else if(io->datatype == GENERIC)
+ {
+ io->mod->whichmodel = JC69;
+ }
+ Set_Model_Name(io->mod);
break;
}
case '-' :
@@ -1167,87 +1352,118 @@ void Launch_Interface_Model(option *io)
io->mod->s_opt->opt_kappa ||
io->mod->s_opt->opt_lambda ||
io->mod->s_opt->opt_pinvar ||
- io->mod->s_opt->opt_rr) io->mod->s_opt->opt_num_param = 1;
- else io->mod->s_opt->opt_num_param = 0;
-
-
-
-
+ io->mod->s_opt->opt_rr) io->mod->s_opt->opt_subst_param = 1;
+ else io->mod->s_opt->opt_subst_param = 0;
Free(s);
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Launch_Interface_Topo_Search(option *io)
{
char choix;
+ char *s;
+
+ s = (char *)mCalloc(100,sizeof(char));
Clear();
Print_Banner(stdout);
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" ....................... \n");
- printf(" Menu : Tree Searching \n");
- printf(" ............................. \n");
+ PhyML_Printf(" ....................... \n");
+ PhyML_Printf(" Menu : Tree Searching \n");
+ PhyML_Printf(" ............................. \n");
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" [+] "
+ PhyML_Printf(" [+] "
".................................... Next sub-menu\n");
- printf(" [-] "
+ PhyML_Printf(" [-] "
"................................ Previous sub-menu\n");
- printf(" [Y] "
+ PhyML_Printf(" [Y] "
".............................. Launch the analysis\n");
- printf("\n");
+ PhyML_Printf("\n");
- printf(" [O] "
+ PhyML_Printf(" [O] "
"........................... Optimise tree topology "
" %-15s \n",
(io->mod->s_opt->opt_topo)?("yes"):("no"));
+ if(io->mod->s_opt->opt_topo)
+ {
+ switch(io->in_tree)
+ {
+ case 0: { strcpy(s,"BioNJ"); break; }
+ case 1: { strcpy(s,"parsimony"); break; }
+ case 2: { strcpy(s,"user tree"); break; }
+ }
+
+ PhyML_Printf(" [U] "
+ "........ Starting tree (BioNJ/parsimony/user tree) "
+ " %-15s \n",s);
+ }
+ else
+ {
+ switch(io->in_tree)
+ {
+ case 0: { strcpy(s,"BioNJ"); break; }
+ case 2: { strcpy(s,"user tree"); break; }
+ }
+
+ PhyML_Printf(" [U] "
+ "..................... Input tree (BioNJ/user tree) "
+ " %-15s \n",s);
+ }
+
if(io->mod->s_opt->opt_topo)
{
char *s;
s = (char *)mCalloc(T_MAX_OPTION,sizeof(char));
+
+ io->mod->s_opt->topo_search = SPR_MOVE;
+
if(io->mod->s_opt->topo_search == NNI_MOVE)
{
- if(!io->mod->s_opt->spr_step_after_nnis)
- {
- strcpy(s,"NNI moves (default)\0");
- }
- else
- {
- strcpy(s,"NNI moves plus one SPR step\0");
- }
+ /* strcpy(s,"NNI moves (fast, approximate)\0"); */
+ strcpy(s,"SPR moves\0");
}
else if(io->mod->s_opt->topo_search == SPR_MOVE)
- strcpy(s,"SPR moves\0");
+ {
+ strcpy(s,"SPR moves\0");
+ }
+ else if(io->mod->s_opt->topo_search == BEST_OF_NNI_AND_SPR)
+ {
+ strcpy(s,"SPR moves\0");
+ /* strcpy(s,"Best of NNI and SPR \0"); */
+ }
- printf(" [S] "
+ PhyML_Printf(" [S] "
".................. Tree topology search operations "
" %-15s \n",s);
Free(s);
- if(io->mod->s_opt->topo_search == SPR_MOVE)
+ if(io->mod->s_opt->topo_search != NNI_MOVE)
{
- printf(" [R] "
- "......................... Use random starting tree "
+ PhyML_Printf(" [R] "
+ "........................ Add random starting trees "
" %-15s \n",
(io->mod->s_opt->random_input_tree)?("yes"):("no"));
if(io->mod->s_opt->random_input_tree)
{
- printf(" [N] "
+ PhyML_Printf(" [N] "
".................. Number of random starting trees "
" %-15d \n",io->mod->s_opt->n_rand_starts);
}
@@ -1255,29 +1471,24 @@ void Launch_Interface_Topo_Search(option *io)
}
else
{
- printf(" [L] "
+ PhyML_Printf(" [L] "
".......................... Optimise branch lengths "
" %-15s \n",
(io->mod->s_opt->opt_bl)?("yes"):("no"));
}
- if(!io->mod->s_opt->random_input_tree)
- {
- printf(" [U] "
- "..................... Input tree (BioNJ/user tree) "
- " %-15s \n",
- (!io->in_tree)?("BioNJ"):("user tree"));
- }
-
- printf("\n\n. Are these settings correct ? "
+ PhyML_Printf("\n\n. Are these settings correct ? "
"(type '+', '-', 'Y' or other letter for one to change) ");
- scanf("%c",&choix);
+ if(!scanf("%c",&choix)) Exit("\n");
if(choix != '\n') getchar(); /* \n */
+ Free(s);
+
Uppercase(&choix);
+
switch(choix)
{
case '-' :
@@ -1295,40 +1506,30 @@ void Launch_Interface_Topo_Search(option *io)
io->ready_to_go = 1;
break;
}
-
- case 'A' :
- {
- io->mod->s_opt->spr_step_after_nnis =
- (io->mod->s_opt->spr_step_after_nnis)?(0):(1);
- break;
- }
case 'U' :
{
- if(!io->in_tree)
+ io->in_tree++;
+ if(!io->mod->s_opt->opt_topo)
{
- io->in_tree = 1;
- printf("\n. Enter the name of the tree file > ");
- Getstring_Stdin(io->in_tree_file);
- io->fp_in_tree = Openfile(io->in_tree_file,0);
+ if(io->in_tree == 1) io->in_tree = 2;
}
- else io->in_tree = 0;
+ if(io->in_tree == 3) io->in_tree = 0;
break;
}
-
case 'N' :
{
char *n;
int n_trial;
- printf("\n. Enter your number of starting trees > ");
+ PhyML_Printf("\n. Enter your number of starting trees > ");
n = (char *)mCalloc(100,sizeof(char));
Getstring_Stdin(n);
n_trial = 0;
- while((!atoi(n)) || (atoi(n) < 0))
+ while(atoi(n) < 1)
{
- if(++n_trial > 10) Exit("\n. Err : the number of starting trees must be a positive integer\n");
- printf("\n. The number of starting trees must be a positive integer\n");
- printf("\n. Enter a new value > ");
+ if(++n_trial > 10) Exit("\n== Err : the number of starting trees must be a positive integer\n");
+ PhyML_Printf("\n. The number of starting trees must be a positive integer\n");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(n);
}
io->mod->s_opt->n_rand_starts = atoi(n);
@@ -1355,24 +1556,24 @@ void Launch_Interface_Topo_Search(option *io)
{
if(io->mod->s_opt->topo_search == NNI_MOVE)
{
- if(!io->mod->s_opt->spr_step_after_nnis)
- io->mod->s_opt->spr_step_after_nnis = 1;
- else
- {
- io->mod->s_opt->topo_search = SPR_MOVE;
- io->mod->s_opt->n_rand_starts = 1;
- io->mod->s_opt->random_input_tree = 0;
- io->mod->s_opt->greedy = 0;
- io->mod->s_opt->spr_step_after_nnis = 0;
- }
+ io->mod->s_opt->topo_search = SPR_MOVE;
+ io->mod->s_opt->n_rand_starts = 1;
+ io->mod->s_opt->random_input_tree = 0;
+ io->mod->s_opt->greedy = 0;
}
else if(io->mod->s_opt->topo_search == SPR_MOVE)
{
+ io->mod->s_opt->topo_search = BEST_OF_NNI_AND_SPR;
io->mod->s_opt->n_rand_starts = 1;
io->mod->s_opt->random_input_tree = 0;
+ io->mod->s_opt->greedy = 0;
+ }
+ else if(io->mod->s_opt->topo_search == BEST_OF_NNI_AND_SPR)
+ {
io->mod->s_opt->topo_search = NNI_MOVE;
+ io->mod->s_opt->n_rand_starts = 1;
+ io->mod->s_opt->random_input_tree = 0;
io->mod->s_opt->greedy = 0;
- io->mod->s_opt->spr_step_after_nnis = 0;
}
break;
}
@@ -1383,12 +1584,12 @@ void Launch_Interface_Topo_Search(option *io)
if(io->mod->s_opt->random_input_tree)
{
if(io->fp_in_tree) fclose(io->fp_in_tree);
- io->in_tree = 0;
+/* io->in_tree = 0; */
io->n_trees = 1;
io->mod->s_opt->n_rand_starts = 5;
- strcpy(io->out_best_tree_file,io->in_seq_file);
- strcat(io->out_best_tree_file,"_phyml_best_tree.txt");
+ strcpy(io->out_trees_file,io->in_align_file);
+ strcat(io->out_trees_file,"_phyml_trees.txt");
}
break;
}
@@ -1399,7 +1600,9 @@ void Launch_Interface_Topo_Search(option *io)
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
void Launch_Interface_Branch_Support(option *io)
{
@@ -1411,33 +1614,34 @@ void Launch_Interface_Branch_Support(option *io)
Clear();
Print_Banner(stdout);
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" ....................... \n");
- printf(" Menu : Branch Support \n");
- printf(" ............................. \n");
+ PhyML_Printf(" ....................... \n");
+ PhyML_Printf(" Menu : Branch Support \n");
+ PhyML_Printf(" ............................. \n");
- printf("\n\n");
+ PhyML_Printf("\n\n");
- printf(" [+] "
+ PhyML_Printf(" [+] "
".................................... Next sub-menu\n");
- printf(" [-] "
+ PhyML_Printf(" [-] "
"................................ Previous sub-menu\n");
- printf(" [Y] "
+ PhyML_Printf(" [Y] "
".............................. Launch the analysis\n");
- printf("\n");
+ PhyML_Printf("\n");
- strcpy(s,(io->mod->bootstrap > 0)?("yes"):("no"));
- if(io->mod->bootstrap > 0) sprintf(s+strlen(s)," (%d replicate%s)",
- io->mod->bootstrap,
- (io->mod->bootstrap>1)?("s"):(""));
+ strcpy(s,(io->do_boot || io->do_tbe)?("yes"):("no"));
+ if(io->n_boot_replicates > 0) sprintf(s+strlen(s)," (%d replicate%s%s)",
+ io->n_boot_replicates,
+ (io->n_boot_replicates>1)?("s"):(""),
+ (io->do_tbe)?(", TBE"):(""));
- /* printf(" [+] " */
- printf(" [B] "
+ /* PhyML_Printf(" [+] " */
+ PhyML_Printf(" [B] "
"................ Non parametric bootstrap analysis "
" %-15s \n",s);
@@ -1457,22 +1661,26 @@ void Launch_Interface_Branch_Support(option *io)
{
strcpy(s,"yes / min of SH-like & Chi2-based supports");
}
- else
+ else if(io->ratio_test == 4)
{
strcpy(s,"yes / SH-like supports");
}
+ else if(io->ratio_test == 5)
+ {
+ strcpy(s,"yes / aBayes supports");
+ }
- /* printf(" [+] " */
- printf(" [A] "
+ /* PhyML_Printf(" [+] " */
+ PhyML_Printf(" [A] "
"................ Approximate likelihood ratio test "
" %-15s \n",s);
- printf("\n. Are these settings correct ? "
+ PhyML_Printf("\n. Are these settings correct ? "
"(type '+', '-', 'Y' or other letter for one to change) ");
- scanf("%c",&choix);
+ if(!scanf("%c",&choix)) Exit("\n");
if(choix != '\n') getchar(); /* \n */
Uppercase(&choix);
@@ -1489,41 +1697,42 @@ void Launch_Interface_Branch_Support(option *io)
case 'B' :
{
- if(io->mod->bootstrap > 0) io->mod->bootstrap = 0;
+ if(io->n_boot_replicates > 0) io->n_boot_replicates = 0;
else
{
char *r;
char answer;
int n_trial;
+ answer = 0;
io->ratio_test = 0;
if(io->n_data_sets > 1)
{
- printf("\n. Bootstrap option is not allowed with multiple data sets.\n");
- printf("\n. Type any key to exit.\n");
- scanf("%c",&choix);
+ PhyML_Printf("\n. Bootstrap option is not allowed with multiple data sets.\n");
+ PhyML_Printf("\n. Type any key to exit.\n");
+ if(!scanf("%c",&choix)) Exit("\n");
Exit("\n");
}
- printf("\n. Number of replicates > ");
+ PhyML_Printf("\n. Number of replicates > ");
r = (char *)mCalloc(T_MAX_OPTION,sizeof(char));
Getstring_Stdin(r);
n_trial = 0;
while((!atoi(r)) || (atoi(r) < 0))
{
- if(++n_trial > 10) Exit("\n. Err : the number of replicates must be a positive integer\n");
- printf("\n. The number of replicates must be a positive integer");
- printf("\n. Enter a new value > ");
+ if(++n_trial > 10) Exit("\n== Err : the number of replicates must be a positive integer\n");
+ PhyML_Printf("\n. The number of replicates must be a positive integer");
+ PhyML_Printf("\n. Enter a new value > ");
Getstring_Stdin(r);
}
- io->mod->bootstrap = atoi(r);
-
- printf("\n. Print bootstrap trees (and statistics) ? (%s) > ",
- (io->print_boot_trees)?("Y/n"):("y/N"));
+ io->n_boot_replicates = atoi(r);
- scanf("%c",&answer);
+ PhyML_Printf("\n. Print bootstrap trees (and statistics) ? (%s) > ",
+ (io->print_boot_trees)?("Y/n"):("y/N"));
+
+ if(!scanf("%c",&answer)) Exit("\n");
if(answer == '\n') answer = (io->print_boot_trees)?('Y'):('N');
else getchar();
@@ -1533,11 +1742,12 @@ void Launch_Interface_Branch_Support(option *io)
{
io->print_boot_trees = 1;
- strcpy(io->out_boot_tree_file,io->in_seq_file);
+ strcpy(io->out_boot_tree_file,io->in_align_file);
+
strcat(io->out_boot_tree_file,"_phyml_boot_trees.txt");
io->fp_out_boot_tree = Openfile(io->out_boot_tree_file,1);
+ strcpy(io->out_boot_stats_file,io->in_align_file);
- strcpy(io->out_boot_stats_file,io->in_seq_file);
strcat(io->out_boot_stats_file,"_phyml_boot_stats.txt");
io->fp_out_boot_stats = Openfile(io->out_boot_stats_file,1);
@@ -1551,13 +1761,40 @@ void Launch_Interface_Branch_Support(option *io)
break;
}
}
+
+ PhyML_Printf("\n. Compute TBE instead of FBP ? (%s) > ",
+ (io->do_tbe)?("Y/n"):("y/N"));
+
+ if(!scanf("%c",&answer)) Exit("\n");
+ if(answer == '\n') answer = (io->do_tbe)?('Y'):('N');
+ else getchar();
+
+ switch(answer)
+ {
+ case 'Y' : case 'y' :
+ {
+ io->do_tbe = YES;
+ io->do_boot = NO;
+ break;
+ }
+ case 'N' : case 'n' :
+ {
+ io->do_tbe = NO;
+ io->do_boot = YES;
+ break;
+ }
+ }
Free(r);
}
break;
}
case 'A' :
{
- io->mod->bootstrap = 0;
+ io->do_boot = NO;
+ io->do_tbe = NO;
+ io->do_alrt = YES;
+
+ io->n_boot_replicates = 0;
switch(io->ratio_test)
{
@@ -1573,7 +1810,8 @@ void Launch_Interface_Branch_Support(option *io)
}
case 2 :
{
- io->ratio_test = 3;
+/* io->ratio_test = 3; */
+ io->ratio_test = 4;
break;
}
case 3 :
@@ -1582,6 +1820,11 @@ void Launch_Interface_Branch_Support(option *io)
break;
}
case 4 :
+ {
+ io->ratio_test = 5;
+ break;
+ }
+ case 5 :
{
io->ratio_test = 0;
break;
@@ -1609,46 +1852,47 @@ void Launch_Interface_Branch_Support(option *io)
}
}
-/*********************************************************/
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
void Launch_Interface_Multigene(option *io)
{
-#ifdef MG
+#ifdef PART
if((io->n_data_sets > 1) && (io->multigene))
{
int set, n_trial;
char choix;
- io->n_gt = io->n_data_sets;
- io->st = (superarbre *)Mg_Make_Superarbre_Light(io);
- io->st->n_gt = io->n_data_sets;
+ io->n_part = io->n_data_sets;
+ io->st = (supert_tree *)PART_Make_Supert_tree_Light(io);
+ io->st->n_part = io->n_data_sets;
- For(set,io->n_gt)
+ for(set=0;setn_part;set++)
{
io->st->optionlist[set] = Make_Input();
Set_Defaults_Input(io->st->optionlist[set]);
Set_Defaults_Model(io->st->optionlist[set]->mod);
Set_Defaults_Optimiz(io->st->optionlist[set]->mod->s_opt);
io->st->optionlist[set]->curr_gt = set;
- printf("\n. Enter the sequence file name [data set %2d] > ",set+1); fflush(NULL);
- Getstring_Stdin(io->st->optionlist[set]->in_seq_file);
- io->st->optionlist[set]->fp_in_seq = Openfile(io->st->optionlist[set]->in_seq_file,0);
+ PhyML_Printf("\n. Enter the sequence file name [data set %2d] > ",set+1); fflush(NULL);
+ Getstring_Stdin(io->st->optionlist[set]->in_align_file);
+ io->st->optionlist[set]->fp_in_align = Openfile(io->st->optionlist[set]->in_align_file,0);
}
- printf("\n. Do you want to use your own initial tree ? [N/y] ");
- scanf("%c", &choix);
+ PhyML_Printf("\n. Do you want to use your own initial tree ? [N/y] ");
+ if(!scanf("%c", &choix)) Exit("\n");
if(choix != '\n') getchar();
n_trial = 0;
while((choix != 'Y') && (choix != 'y') &&
(choix != 'N') && (choix != 'n'))
{
- if(++n_trial > 10) Exit("\n. Err : wrong answers !");
- printf("\n. Do you want to use your own initial tree ? [N/y] ? ");
- scanf("%c", &choix);
+ if(++n_trial > 10) Exit("\n== Err : wrong answers !");
+ PhyML_Printf("\n. Do you want to use your own initial tree ? [N/y] ? ");
+ if(!scanf("%c", &choix)) Exit("\n");
if(choix == '\n') choix = 'N';
else getchar();
}
@@ -1658,8 +1902,8 @@ void Launch_Interface_Multigene(option *io)
case '\n' : break;
case 'Y' : case 'y' :
{
- io->in_tree = 1;
- printf("\n. Enter the name of the tree file > ");
+ io->in_tree = 2;
+ PhyML_Printf("\n. Enter the name of the tree file > ");
Getstring_Stdin(io->in_tree_file);
io->fp_in_tree = Openfile(io->in_tree_file,0);
break;
@@ -1693,16 +1937,16 @@ void Launch_Interface_Multigene(option *io)
}
default :
{
- printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Printf("\n== Err in file %s at line %d\n\n",__FILE__,__LINE__);
Exit("");
break;
}
}
}while(!io->st->optionlist[io->curr_gt]->ready_to_go);
io->curr_gt++;
- }while(io->curr_gt < io->n_gt);
+ }while(io->curr_gt < io->n_part);
}
io->ready_to_go = 1;
- Mg_Fill_Model_Partitions_Table(io->st);
+ PART_Fill_Model_Partitions_Table(io->st);
#endif
}
diff --git a/phyml/interface.h b/phyml/interface.h
index add6ed9..d42730e 100644
--- a/phyml/interface.h
+++ b/phyml/interface.h
@@ -10,9 +10,18 @@ the GNU public licence. See http://www.opensource.org for details.
*/
+#include
+
#ifndef INTERFACE_H
#define INTERFACE_H
+#include "utilities.h"
+#include "help.h"
+#include "models.h"
+#include "free.h"
+#include "help.h"
+
+
void Launch_Interface(option *input);
void Clear();
void Launch_Interface_Input(option *input);
diff --git a/phyml/invitee.c b/phyml/invitee.c
new file mode 100644
index 0000000..736b71b
--- /dev/null
+++ b/phyml/invitee.c
@@ -0,0 +1,2599 @@
+#include "spr.h"
+#include "utilities.h"
+#include "lk.h"
+#include "optimiz.h"
+#include "bionj.h"
+#include "models.h"
+#include "free.h"
+#include "help.h"
+#include "simu.h"
+#include "eigen.h"
+#include "pars.h"
+#include "alrt.h"
+#include "mixt.h"
+#include "invitee.h"
+#ifdef MPI
+#include "mpi_boot.h"
+#endif
+#include
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void PhyTime_XML(char *xml_file)
+{
+
+ FILE *f;
+ char **clade, *clade_name, **mon_list;
+ phydbl low, up;
+ int i, j, n_taxa, clade_size, node_num, n_mon; //rnd_num
+ xml_node *n_r, *n_t, *n_m, *n_cur;
+ t_cal *last_calib;
+ align **data, **c_seq;
+ option *io;
+ calign *cdata;
+ t_opt *s_opt;
+ t_mod *mod;
+ time_t t_beg,t_end;
+ int r_seed;
+ char *most_likely_tree;
+ int user_lk_approx;
+ t_tree *tree;
+ t_node **a_nodes; //*node;
+ m4 *m4mod;
+
+ srand(time(NULL));
+
+ i = 0;
+ j = 0;
+ last_calib = NULL;
+ mod = NULL;
+ most_likely_tree = NULL;
+ n_taxa = 0;
+ node_num = -1;
+
+ //file can/cannot be open:
+ if ((f =(FILE *)fopen(xml_file, "r")) == NULL)
+ {
+ PhyML_Printf("\n== File '%s' can not be opened...\n",xml_file);
+ Exit("\n");
+ }
+
+ n_r = XML_Load_File(f);
+
+
+ //memory allocation for model parameters:
+ io = (option *)Make_Input();
+ mod = (t_mod *)Make_Model_Basic();
+ s_opt = (t_opt *)Make_Optimiz();
+ m4mod = (m4 *)M4_Make_Light();
+ Set_Defaults_Input(io);
+ Set_Defaults_Model(mod);
+ Set_Defaults_Optimiz(s_opt);
+ io -> mod = mod;
+ mod = io -> mod;
+ mod -> s_opt = s_opt;
+ clade_size = -1;
+
+ ////////////////////////////////////////////////////////////////////////////
+ //////////////////////reading tree topology:////////////////////////////////
+
+ //looking for a node
+ n_t = XML_Search_Node_Name("topology", YES, n_r);
+
+ //setting tree:
+ /* tree = (t_tree *)mCalloc(1,sizeof(t_tree)); */
+ n_cur = XML_Search_Node_Name("instance", YES, n_t);
+ if(n_cur != NULL)
+ {
+ if(XML_Search_Attribute(n_cur, "user.tree") != NULL)
+ {
+ strcpy(io -> out_tree_file, XML_Search_Attribute(n_cur, "user.tree") -> value);
+ io -> fp_out_tree = Openfile(io -> out_tree_file, 1);
+ io -> tree = Read_Tree_File_Phylip(io -> fp_in_tree);
+ }
+ else
+ {
+ PhyML_Printf("\n== No input tree was not found. \n");
+ PhyML_Printf("\n== Please specify either a tree file name or enter the whole tree directly in the XML file (in Newick format). \n");
+ Exit("\n");
+ }
+ }
+ else io -> tree = Read_Tree(&n_t -> value);
+ io -> n_otu = io -> tree -> n_otu;
+ tree = io -> tree;
+
+ //setting initial values to n_calib:
+ For(i, 2 * tree -> n_otu - 2)
+ {
+ tree -> a_nodes[i] -> n_calib = 0;
+ //PhyML_Printf("\n. '%d' \n", tree -> a_nodes[i] -> n_calib);
+ }
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
+ //memory for nodes:
+ a_nodes = (t_node **)mCalloc(2 * io -> n_otu - 1,sizeof(t_node *));
+ For(i, 2 * io -> n_otu - 2) a_nodes[i] = (t_node *)mCalloc(1,sizeof(t_node));
+
+ //setting a model:
+ tree -> rates = RATES_Make_Rate_Struct(io -> n_otu);
+ RATES_Init_Rate_Struct(tree -> rates, io -> rates, tree -> n_otu);
+
+ //reading seed:
+ if(XML_Search_Attribute(n_r, "seed")) io -> r_seed = String_To_Dbl(XML_Search_Attribute(n_r, "seed") -> value);
+
+ //TO DO: check that the tree has a root
+ Update_Ancestors(io -> tree -> n_root, io -> tree -> n_root -> v[2], io -> tree);
+ Update_Ancestors(io -> tree -> n_root, io -> tree -> n_root -> v[1], io -> tree);
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ //////////////////////memory allocation for temp parameters/////////////////
+
+ //memory for monitor flag:
+ io -> mcmc -> monitor = (int *)mCalloc(2 * io -> n_otu - 1,sizeof(int));
+
+
+ //memory for sequences:
+ n_cur = XML_Search_Node_Name("alignment", YES, n_r);
+
+ data = (align **)mCalloc(io -> n_otu,sizeof(align *));
+ For(i, io -> n_otu)
+ {
+ data[i] = (align *)mCalloc(1,sizeof(align));
+ data[i] -> name = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+ if(n_cur -> child -> value != NULL) data[i] -> state = (char *)mCalloc(strlen(n_cur -> child -> value) + 1,sizeof(char));
+ else data[i] -> state = (char *)mCalloc(T_MAX_SEQ,sizeof(char));
+ }
+ io -> data = data;
+ //tree -> data = data;
+
+
+ //memory for clade:
+ clade_name = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+
+ //memory for list of clades to be monitored
+ mon_list = (char **)mCalloc(T_MAX_FILE,sizeof(char *));
+ For(i, T_MAX_FILE)
+ {
+ mon_list[i] = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
+ //reading monitor node:
+ i = 0;
+ n_m = XML_Search_Node_Name("monitor", YES, n_r);
+ if(n_m != NULL)
+ {
+ do
+ {
+ strcpy(mon_list[i], n_m -> child -> attr -> value);
+ i++;
+ if(n_m -> child) n_m -> child = n_m -> child -> next;
+ else break;
+ }
+ while(n_m -> child);
+ n_mon = i;
+ }
+ else
+ {
+ n_mon = 0;
+ PhyML_Printf("\n. There is no clade to be monitored. \n");
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
+ //chekcing for calibration node (upper or lower bound) to exist:
+ n_cur = XML_Search_Node_Name("calibration", YES, n_r);
+
+ if(n_cur == NULL)
+ {
+ PhyML_Printf("\n== There is no calibration information provided. \n");
+ PhyML_Printf("\n== Please check your data. \n");
+ Exit("\n");
+ }
+ else
+ {
+ if(XML_Search_Node_Name("upper", NO, n_cur -> child) == NULL && XML_Search_Node_Name("lower", NO, n_cur -> child) == NULL)
+ {
+ PhyML_Printf("\n== There is no calibration information provided. \n");
+ PhyML_Printf("\n== Please check your data. \n");
+ Exit("\n");
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+
+
+ n_r = n_r -> child;
+ tree -> rates -> tot_num_cal = 0;
+ do
+ {
+ if(!strcmp(n_r -> name, "alignment"))//looking for a node .
+ {
+ if(!n_r -> attr -> value)
+ {
+ PhyML_Printf("\n== Sequence type (nt / aa) must be provided. \n");
+ PhyML_Printf("\n== Please, include this information as an attribute of component <%s>. \n", n_r -> name);
+ Exit("\n");
+ }
+ char *s;
+ s = To_Upper_String(n_r -> attr -> value);
+ /* if(!strcmp(To_Upper_String(n_r -> attr -> value), "NT")) */
+ if(!strcmp(s, "NT"))
+ {
+ io -> datatype = 0;
+ io -> mod -> ns = 4;
+ }
+ /* if(!strcmp(To_Upper_String(n_r -> attr -> value), "AA")) */
+ if(!strcmp(s, "AA"))
+ {
+ io -> datatype = 1;
+ io -> mod -> ns = 20;
+ }
+ free(s);
+ n_cur = XML_Search_Node_Name("instance", YES, n_r);
+ if(n_cur != NULL)
+ {
+ if(XML_Search_Attribute(n_cur, "user.alignment") != NULL)
+ {
+ strcpy(io -> in_align_file, XML_Search_Attribute(n_cur, "user.alignment") -> value);
+ io -> fp_in_align = Openfile(io -> in_align_file, 1);
+ Detect_Align_File_Format(io);
+ io -> data = Get_Seq(io);
+ }
+ }
+ else
+ {
+ char *s;
+ i = 0;
+ s = To_Upper_String(n_r -> child -> value);
+ do
+ {
+ strcpy(io -> in_align_file, "invitee");
+ strcpy(io -> data[i] -> name, n_r -> child -> attr -> value);
+ /* strcpy(io -> data[i] -> state, To_Upper_String(n_r -> child -> value)); */
+ strcpy(io -> data[i] -> state, s);
+ i++;
+ if(n_r -> child -> next) n_r -> child = n_r -> child -> next;
+ else break;
+ }
+ while(n_r -> child);
+ n_taxa = i;
+ free(s);
+ }
+
+ //checking if a sequences of the same lengths:
+
+ i = 1;
+ For(i, n_taxa) if(strlen(io -> data[0] -> state) != strlen(io -> data[i] -> state))
+ {
+ PhyML_Printf("\n== All the sequences should be of the same length. Please check your data...\n");
+ Exit("\n");
+ break;
+ }
+
+ //checking sequence names:
+ i = 0;
+ For(i, n_taxa) Check_Sequence_Name(io -> data[i] -> name);
+
+ //check if a number of tips is equal to a number of taxa:
+ if(n_taxa != io -> n_otu)
+ {
+ PhyML_Printf("\n== The number of taxa is not the same as a number of tips. Check your data...\n");
+ Exit("\n");
+ }
+
+ //deleting '-', etc. from sequences:
+ io -> data[0] -> len = strlen(io -> data[0] -> state);
+ Post_Process_Data(io);
+ n_r = n_r -> next;
+ }
+ else if(!strcmp(n_r -> name, "calibration"))//looking for a node .
+ {
+ tree -> rates -> tot_num_cal++;
+ if (tree -> rates -> calib == NULL) tree -> rates -> calib = Make_Calib(tree -> n_otu);
+ if(last_calib)
+ {
+ last_calib -> next = tree -> rates -> calib;
+ tree -> rates -> calib -> prev = last_calib;
+ }
+ last_calib = tree -> rates -> calib;
+
+ low = -BIG;
+ up = BIG;
+ n_cur = XML_Search_Node_Name("lower", YES, n_r);
+ if(n_cur != NULL) low = String_To_Dbl(n_cur -> value);
+ n_cur = XML_Search_Node_Name("upper", YES, n_r);
+ if(n_cur != NULL) up = String_To_Dbl(n_cur -> value);
+ do
+ {
+ if(!strcmp("appliesto", n_r -> child -> name))
+ {
+ //case of internal node:
+ strcpy(clade_name, n_r -> child -> attr -> value);//reached clade names n_r -> child -> attr -> value
+ if(!strcmp("root", clade_name))
+ {
+ node_num = io -> tree -> n_root -> num;
+ }
+ else if(strcmp("NO_CLADE", clade_name) && strcmp("root", clade_name))
+ {
+ xml_node *n_clade, *nd2;
+ nd2 = n_r -> parent;
+ n_clade = XML_Search_Node_Generic("clade", "id", clade_name, YES, nd2);
+ if(n_clade) //found clade with a given name
+ {
+ i = 0;
+ xml_node *nd;
+ nd = n_clade -> child;
+ clade = XML_Read_Clade(nd, tree);
+ clade_size = XML_Number_Of_Taxa_In_Clade(nd);
+ node_num = Find_Clade(clade, clade_size, io -> tree);
+ }
+ else
+ {
+ PhyML_Printf("\n== The calibration information for clade [%s] was not found.", clade_name);
+ PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+ }
+ if(strcmp("NO_CLADE", clade_name))
+ {
+ For(j, n_mon)
+ {
+ if(!strcmp(clade_name, mon_list[j])) io -> mcmc -> monitor[node_num] = YES;
+ }
+ }
+
+ if(strcmp("NO_CLADE", clade_name))
+ {
+ tree -> rates -> calib -> proba[node_num] = String_To_Dbl(n_r -> child -> attr -> next -> value);
+
+ if(!n_r -> child -> attr -> next && n_r -> child -> next == NULL) tree -> rates -> calib -> proba[node_num] = 1.;
+ if(!n_r -> child -> attr -> next && n_r -> child -> next)
+ {
+ PhyML_Printf("\n== You either need to provide information about the probability with which calibration ");
+ PhyML_Printf("\n== applies to a node or you need to apply calibration only to one node.");
+ PhyML_Printf("\n. Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ tree -> rates -> calib -> all_applies_to[tree -> rates -> calib -> n_all_applies_to] -> num = node_num;
+ }
+ else tree -> rates -> calib -> proba[2 * tree -> n_otu - 1] = String_To_Dbl(n_r -> child -> attr -> next -> value);
+ tree -> rates -> calib -> n_all_applies_to++;
+ tree -> rates -> calib -> lower = low;
+ tree -> rates -> calib -> upper = up;
+ PhyML_Printf("\n. Lower bound: %f.", low);
+ PhyML_Printf("\n. Upper bound: %f.", up);
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
+ PhyML_Printf("\n. .......................................................................");
+ PhyML_Printf("\n");
+ if(strcmp(clade_name, "NO_CLADE")) PhyML_Printf("\n. Clade name: [%s]", clade_name);
+ else
+ {
+ PhyML_Printf("\n. Calibration with:");
+ PhyML_Printf("\n. Lower bound set to: %15f time units.", low);
+ PhyML_Printf("\n. Upper bound set to: %15f time units.", up);
+ PhyML_Printf("\n. does not apply to any node with probability [%f]", String_To_Dbl(n_r -> child -> attr -> next -> value));
+ PhyML_Printf("\n. .......................................................................");
+ }
+
+ if(strcmp(clade_name, "root") && strcmp(clade_name, "NO_CLADE"))
+ {
+ For(i, clade_size) PhyML_Printf("\n. Taxon name: [%s]", clade[i]);
+ }
+ if(strcmp(clade_name, "NO_CLADE"))
+ {
+ PhyML_Printf("\n. Node number to which calibration applies to is [%d] with probability [%f]", node_num, String_To_Dbl(n_r -> child -> attr -> next -> value));
+ PhyML_Printf("\n. Lower bound set to: %15f time units.", low);
+ PhyML_Printf("\n. Upper bound set to: %15f time units.", up);
+ PhyML_Printf("\n. .......................................................................");
+ }
+ /////////////////////////////////////////////////////////////////////////////////////////////////////
+ if(n_r -> child -> next) n_r -> child = n_r -> child -> next;
+ else break;
+ }
+ else if(n_r -> child -> next) n_r -> child = n_r -> child -> next;
+ else break;
+ }
+ while(n_r -> child);
+
+ tree -> rates -> calib = tree -> rates -> calib -> next;
+ n_r = n_r -> next;
+ }
+ else if(!strcmp(n_r -> name, "ratematrices"))//initializing rate matrix:
+ {
+ if(n_r -> child)
+ {
+ Make_Ratematrice_From_XML_Node(n_r -> child, io, mod);
+ n_r = n_r -> next;
+ }
+ else n_r = n_r -> next;
+ }
+ else if(!strcmp(n_r -> name, "equfreqs"))//initializing frequencies:
+ {
+ if(n_r -> child)
+ {
+ Make_Efrq_From_XML_Node(n_r -> child , io, mod);
+ n_r = n_r -> next;
+ }
+ else n_r = n_r -> next;
+ }
+ else if(!strcmp(n_r -> name, "siterates"))//initializing site rates:
+ {
+ if(n_r -> child)
+ {
+ Make_RAS_From_XML_Node(n_r, io -> mod);
+ n_r = n_r -> next;
+ }
+ else n_r = n_r -> next;
+ }
+
+ else if (n_r -> next) n_r = n_r -> next;
+ else break;
+ }
+ while(1);
+
+ tree -> rates -> calib = last_calib;
+ while(tree -> rates -> calib -> prev) tree -> rates -> calib = tree -> rates -> calib -> prev;
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ //Check for the sum of probabilities for one calibration add up to one
+ do
+ {
+ phydbl p = 0.0;
+ for(i = tree -> n_otu; i < 2 * tree -> n_otu; i++)
+ {
+ p = p + tree -> rates -> calib -> proba[i];
+ /* PhyML_Printf("\n. # applies to %d \n", tree -> rates -> calib -> n_all_applies_to); */
+ /* PhyML_Printf("\n. %f \n", tree -> rates -> calib -> proba[i]); */
+ }
+ if(!Are_Equal(p, 1.0, 1.E-10))
+ {
+ PhyML_Printf("\n. .......................................................................");
+ PhyML_Printf("\n. WARNING! The sum of the probabilities for the calibration with:");
+ PhyML_Printf("\n. Lower bound set to: %15f time units.", tree -> rates -> calib -> lower);
+ PhyML_Printf("\n. Upper bound set to: %15f time units.", tree -> rates -> calib -> upper);
+ PhyML_Printf("\n. is not equal to 1.");
+ PhyML_Printf("\n. The probability that this calibration does not apply to any node is set to [%f].", 1.0 - p);
+ PhyML_Printf("\n. .......................................................................");
+ tree -> rates -> calib -> proba[2 * tree -> n_otu - 1] = 1.0 - p;
+ tree -> rates -> calib -> n_all_applies_to++;
+ /* PhyML_Printf("\n==You need to provide proper probabilities for the calibration. \n"); */
+ /* PhyML_Printf("\n. Err. in file %s at line %d\n",__FILE__,__LINE__); */
+ /* Exit("\n"); */
+ }
+ if(tree -> rates -> calib -> next) tree -> rates -> calib = tree -> rates -> calib -> next;
+ else break;
+
+ }
+ while(tree -> rates -> calib);
+ while(tree -> rates -> calib -> prev) tree -> rates -> calib = tree -> rates -> calib -> prev;
+
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ //clear memory:
+ free(clade_name);
+ For(i, tree -> n_otu)
+ {
+ free(clade[i]);
+ }
+ free(clade);
+ For(i, T_MAX_FILE)
+ {
+ free(mon_list[i]);
+ }
+ free(mon_list);
+ /* do */
+ /* { */
+ /* printf("\n %f %f \n", tree -> rates -> calib -> lower, tree -> rates -> calib -> upper); */
+ /* printf("\n numb applies to: %d \n", tree -> rates -> calib -> n_all_applies_to); */
+ /* For(i, tree -> rates -> calib -> n_all_applies_to) printf("\n Node number %d \n", tree -> rates -> calib -> all_applies_to[i] -> num); */
+ /* if(tree -> rates -> calib -> next) tree -> rates -> calib = tree -> rates -> calib -> next; */
+ /* else break; */
+
+ /* } */
+ /* while(tree -> rates -> calib); */
+ /* while(tree -> rates -> calib -> prev) tree -> rates -> calib = tree -> rates -> calib -> prev; */
+
+ /* Exit("\n"); */
+ ////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////
+ //START analysis:
+ r_seed = (io -> r_seed < 0)?(time(NULL)):(io -> r_seed);
+ srand(r_seed);
+ rand();
+ PhyML_Printf("\n. Seed: %d\n", r_seed);
+ PhyML_Printf("\n. Pid: %d\n",getpid());
+ PhyML_Printf("\n. Compressing sequences...\n");
+ data = io -> data;
+ data[0] -> len = strlen(data[0] -> state);
+ ////////////////////////////////////////////////////////////////////////////
+ //memory for compressed sequences:
+ cdata = (calign *)mCalloc(1,sizeof(calign));
+ c_seq = (align **)mCalloc(io -> n_otu,sizeof(align *));
+ For(i, io -> n_otu)
+ {
+ c_seq[i] = (align *)mCalloc(1,sizeof(align));
+ c_seq[i] -> name = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+ c_seq[i] -> state = (char *)mCalloc(data[0] -> len + 1,sizeof(char));
+ }
+ cdata -> c_seq = c_seq;
+ ////////////////////////////////////////////////////////////////////////////
+ cdata = Compact_Data(data, io);
+ Free_Seq(io -> data, cdata -> n_otu);
+ io -> mod -> io = io;
+ Check_Ambiguities(cdata, io -> mod -> io -> datatype, io -> state_len);
+ Make_Model_Complete(mod);
+ Init_Model(cdata, mod, io);
+ if(io -> mod -> use_m4mod) M4_Init_Model(mod -> m4mod, cdata, mod);
+ time(&(t_beg));
+
+ RATES_Fill_Lca_Table(tree);
+
+ tree -> mod = mod;
+ tree -> io = io;
+ tree -> data = cdata;
+ tree -> n_pattern = tree -> data -> crunch_len / tree -> io -> state_len;
+
+ Set_Both_Sides(YES, tree);
+ Make_Tree_For_Pars(tree);
+ Make_Tree_For_Lk(tree);
+ Make_Spr(tree);
+
+
+
+ //calculate the probabilities of each combination of calibrations:
+ TIMES_Calib_Partial_Proba(tree);
+ int cal_numb = 0;
+ do
+ {
+ if(!Are_Equal(tree -> rates -> times_partial_proba[cal_numb], 0.0, 1.E-10)) break;
+ else cal_numb += 1;
+ }
+ while(1);
+ PhyML_Printf("\n. Calibration number chosen %d.\n", cal_numb);
+
+
+ Set_Current_Calibration(cal_numb, tree);
+ tree -> rates -> numb_calib_chosen[cal_numb]++;
+
+
+ int tot_num_comb;
+ tot_num_comb = Number_Of_Comb(tree -> rates -> calib);
+ PhyML_Printf("\n. The number of calibration combinations that is going to be considered is %d.\n", tot_num_comb);
+ /* For(i, tot_num_comb) Set_Current_Calibration(i, tree); */
+ /* Exit("\n"); */
+
+ //set initial value for Hastings ratio for conditional jump:
+ /* tree -> rates -> c_lnL_Hastings_ratio = 0.0; */
+
+ TIMES_Set_All_Node_Priors(tree);
+
+ tree -> rates -> cur_comb_numb = cal_numb;
+ tree -> rates -> log_K_cur = K_Constant_Prior_Times_Log(tree);
+
+ TIMES_Get_Number_Of_Time_Slices(tree);
+ TIMES_Label_Edges_With_Calibration_Intervals(tree);
+
+
+ tree -> write_br_lens = NO;
+
+ PhyML_Printf("\n. Input tree with calibration information ('almost' compatible with MCMCtree).\n");
+
+ char *t;
+ t = Write_Tree(tree, YES);
+ PhyML_Printf("\n. %s \n", t);
+ free(t);
+
+ tree -> write_br_lens = YES;
+
+
+ // Work with log of branch lengths?
+ if(tree -> mod -> log_l == YES) Log_Br_Len(tree);
+
+ if(io -> mcmc -> use_data == YES)
+ {
+ // Force the exact likelihood score
+ user_lk_approx = tree -> io -> lk_approx;
+ tree -> io -> lk_approx = EXACT;
+
+ /* MLE for branch lengths */
+ /* printf("\n. %s",Write_Tree(tree,NO)); */
+ /* printf("\n. alpha %f",tree->mod->ras->alpha->v); */
+ /* printf("\n. %f %f %f %f",tree->mod->e_frq->pi->v[0],tree->mod->e_frq->pi->v[1],tree->mod->e_frq->pi->v[2],tree->mod->e_frq->pi->v[3]); */
+ /* Lk(NULL,tree); */
+ /* printf("\n. %f",tree->c_lnL); */
+ /* Exit("\n"); */
+
+ Round_Optimize(tree, tree -> data, ROUND_MAX);
+ // Set vector of mean branch lengths for the Normal approximation of the likelihood
+ RATES_Set_Mean_L(tree);
+
+ // Estimate the matrix of covariance for the Normal approximation of the likelihood
+ PhyML_Printf("\n");
+ PhyML_Printf("\n. Computing Hessian...");
+ tree -> rates -> bl_from_rt = 0;
+ Free(tree -> rates -> cov_l);
+ tree -> rates -> cov_l = Hessian_Seo(tree);
+
+ // tree->rates->cov_l = Hessian_Log(tree);
+ For(i, (2 * tree -> n_otu - 3) * (2 * tree -> n_otu - 3)) tree -> rates -> cov_l[i] *= -1.0;
+ if(!Iter_Matinv(tree -> rates -> cov_l, 2 * tree -> n_otu - 3, 2 * tree -> n_otu - 3, YES)) Exit("\n");
+ tree -> rates -> covdet = Matrix_Det(tree -> rates -> cov_l, 2 * tree -> n_otu - 3, YES);
+ For(i,(2 * tree -> n_otu - 3) * (2 * tree -> n_otu - 3)) tree -> rates -> invcov[i] = tree -> rates -> cov_l[i];
+ if(!Iter_Matinv(tree -> rates -> invcov, 2 * tree -> n_otu - 3, 2 * tree -> n_otu - 3, YES)) Exit("\n");
+ tree -> rates -> grad_l = Gradient(tree);
+
+ // Pre-calculation of conditional variances to speed up calculations
+ RATES_Bl_To_Ml(tree);
+ RATES_Get_Conditional_Variances(tree);
+ RATES_Get_All_Reg_Coeff(tree);
+ RATES_Get_Trip_Conditional_Variances(tree);
+ RATES_Get_All_Trip_Reg_Coeff(tree);
+
+ Lk(NULL, tree);
+ PhyML_Printf("\n");
+ PhyML_Printf("\n. p(data|model) [exact ] ~ %.2f",tree -> c_lnL);
+ tree -> io -> lk_approx = NORMAL;
+ For(i,2 * tree -> n_otu - 3) tree -> rates -> u_cur_l[i] = tree -> rates -> mean_l[i] ;
+ tree -> c_lnL = Lk(NULL,tree);
+
+ PhyML_Printf("\n. p(data|model) [approx] ~ %.2f",tree -> c_lnL);
+
+ tree -> io -> lk_approx = user_lk_approx;
+
+ }
+
+
+ tree -> rates -> model = io -> rates -> model;
+
+ PhyML_Printf("\n. Selected model '%s' \n", RATES_Get_Model_Name(io -> rates -> model));
+
+ if(tree -> rates -> model == GUINDON) tree -> mod -> gamma_mgf_bl = YES;
+
+ tree -> rates -> bl_from_rt = YES;
+
+ if(tree -> io -> cstr_tree) Find_Surviving_Edges_In_Small_Tree(tree, tree -> io -> cstr_tree);
+ time(&t_beg);
+
+ tree -> mcmc = MCMC_Make_MCMC_Struct();
+
+ MCMC_Copy_MCMC_Struct(tree -> io -> mcmc, tree -> mcmc, "phytime");
+
+ tree -> mod -> m4mod = m4mod;
+
+ MCMC_Complete_MCMC(tree -> mcmc, tree);
+
+ tree -> mcmc -> is_burnin = NO;
+
+ MCMC(tree);
+ PhyML_Printf("\n");
+ for(i=0;i<6;i++) printf(" %d ", tree -> rates -> numb_calib_chosen[i]);
+ PhyML_Printf("\n");
+
+ MCMC_Close_MCMC(tree -> mcmc);
+ MCMC_Free_MCMC(tree -> mcmc);
+ PhyML_Printf("\n");
+
+ Free_Calib(tree -> rates -> calib);
+ Add_Root(tree->a_edges[0],tree);
+ Free_Tree_Pars(tree);
+ Free_Tree_Lk(tree);
+ Free_Tree(tree);
+ Free_Calign(cdata);
+ Free_Model(mod);
+ if(io -> fp_in_align) fclose(io -> fp_in_align);
+ if(io -> fp_in_tree) fclose(io -> fp_in_tree);
+ if(io -> fp_out_lk) fclose(io -> fp_out_lk);
+ if(io -> fp_out_tree) fclose(io -> fp_out_tree);
+ if(io -> fp_out_trees) fclose(io -> fp_out_trees);
+ if(io -> fp_out_stats) fclose(io -> fp_out_stats);
+ fclose(f);
+ Free(most_likely_tree);
+ Free_Input(io);
+ time(&t_end);
+ Print_Time_Info(t_beg,t_end);
+
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Calculate the prior probability for node times taking into account the
+//probailitis with which each calibration applies to the particular node.
+phydbl TIMES_Calib_Cond_Prob(t_tree *tree)
+{
+
+ phydbl times_lk, *Yule_val, *times_partial_proba, times_tot_proba, c, constant, ln_t;
+ int i, tot_num_comb;
+ t_cal *calib;
+
+
+ times_tot_proba = 0.0;
+ calib = tree -> rates -> calib;
+ times_partial_proba = tree -> rates -> times_partial_proba;
+
+ tot_num_comb = Number_Of_Comb(calib);
+
+
+ Yule_val = (phydbl *)mCalloc(tot_num_comb, sizeof(phydbl));
+ For(i, tot_num_comb)
+ {
+
+ Set_Current_Calibration(i, tree);
+
+ int result;
+ result = TRUE;
+ TIMES_Set_All_Node_Priors_S(&result, tree);
+
+ times_lk = TIMES_Lk_Yule_Order_Root_Cond(tree);
+
+ constant = 0.0;
+ if(tot_num_comb > 1 && times_lk > -INFINITY && result != FALSE && tree->rates->update_time_norm_const == YES)
+
+ Yule_val[i] = constant + times_lk;
+
+ while(calib -> prev) calib = calib -> prev;
+ }
+
+ /* Exit("\n"); */
+ c = .0;
+ times_tot_proba = 0.0;
+ For(i, tot_num_comb)
+ {
+ times_tot_proba += times_partial_proba[i] * exp(Yule_val[i] + c);
+ }
+
+ ln_t = -c + log(times_tot_proba);
+
+ free(Yule_val);
+
+ return(ln_t);
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+//Function calculates the normalizing constant K of the joint distribution Yule_Order.
+//Use the fact that density Yule_Order can be used streight forward only in case of the complete
+//overlap of the calibration intervals for all of the nodes or in case of no overlap.
+phydbl K_Constant_Prior_Times_Log(t_tree *tree)
+{
+ int i, j, k, f, n_otu, *indic, *n_slice, *slice_numbers;
+ phydbl buf, chop_bound, *t_prior_min, *t_prior_max, *t_slice, *t_slice_min, *t_slice_max, *g_i_node;
+
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ n_otu = tree -> n_otu;
+
+ t_slice = (phydbl *)mCalloc(2 * (n_otu - 1), sizeof(phydbl)); //the vector of the union of lower and upper bounds, lined up in incresing order.
+ t_slice_min = (phydbl *)mCalloc(2 * n_otu - 3, sizeof(phydbl)); //vector of the lower bounds of the sliced intervals.
+ t_slice_max = (phydbl *)mCalloc(2 * n_otu - 3, sizeof(phydbl)); //vector of the upper bounds of the sliced intervals.
+ indic = (int *)mCalloc((n_otu - 1) * (2 * n_otu - 3), sizeof(int)); //vector of the indicators, columns - node numbers (i + n_otu), rows - the number of the sliced interval.
+ slice_numbers = (int *)mCalloc((n_otu - 1) * (2 * n_otu - 3), sizeof(int )); //vecor of the slice intervals numbers, columns node numbers (i + n_otu), rows - the number of the sliced interval.
+ n_slice = (int *)mCalloc(n_otu - 1, sizeof(int)); //vector of the numbers of sliced intervals that apply to one node with number (i + n_otu).
+ g_i_node = (phydbl *)mCalloc((n_otu - 1) * (2 * n_otu - 3), sizeof(phydbl)); //vector of the values of the function g evaluated for each node.
+
+ i = 0;
+ /* K = 0; */
+ j = n_otu;
+ ////////////////////////////////////////////////////////////////////////////
+ //Put prior bounds in one vector t_slice. Excluding tips.
+ For(i, n_otu - 1)
+ {
+ t_slice[i] = t_prior_min[j];
+ j++;
+ }
+
+ j = n_otu;
+ for(i = n_otu - 1; i < 2 * n_otu - 3; i++)
+ {
+ t_slice[i] = t_prior_max[j];
+ j++;
+ }
+ if(tree -> rates -> nd_t[tree -> n_root -> num] > t_prior_min[tree -> n_root -> num]) chop_bound = MIN(tree -> rates -> nd_t[tree -> n_root -> num], t_prior_max[tree -> n_root -> num]);
+ else chop_bound = t_prior_min[tree -> n_root -> num];
+ t_slice[2 * n_otu - 3] = chop_bound;
+
+ ////////////////////////////////////////////////////////////////////////////
+ //Get slices in increasing order. Excluding tips.
+ do
+ {
+ f = NO;
+ For(j, 2 * n_otu - 3)
+ {
+ if(t_slice[j] > t_slice[j + 1])
+ {
+ buf = t_slice[j];
+ t_slice[j] = t_slice[j + 1];
+ t_slice[j + 1] = buf;
+ f = YES;
+ }
+ }
+ }
+ while(f);
+
+ for(j = 1; j < 2 * n_otu - 2; j++) t_slice[j] = MAX(chop_bound, t_slice[j]);
+ ////////////////////////////////////////////////////////////////////////////
+ //Get the intervals with respect to slices. Total number of t_slice_min(max) - 2 * n_otu - 3. Excluding tips.
+ i = 0;
+ For(j, 2 * n_otu - 3)
+ {
+ t_slice_min[j] = t_slice[i];
+ t_slice_max[j] = t_slice[i + 1];
+ i++;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+ //Getting indicators for the node number [i + n_otu] to have slice. i = i + n_otu is the node number on the tree and j is the slice number, total
+ //number of intervals is 2 * n_otu - 3. Excluding tips.
+ For(i, n_otu - 1)
+ {
+ For(j, 2 * n_otu - 3)
+ {
+
+ if(Are_Equal(t_prior_min[i + n_otu], t_slice_min[j], 1.E-10) && t_prior_max[i + n_otu] > t_slice_max[j] && t_prior_min[i + n_otu] < t_slice_max[j] && !Are_Equal(t_slice_max[j], t_slice_min[j], 1.E-10)) indic[i * (2 * n_otu - 3) + j] = 1;
+ else if(Are_Equal(t_prior_max[i + n_otu], t_slice_max[j], 1.E-10) && t_prior_min[i + n_otu] < t_slice_min[j] && t_prior_max[i + n_otu] > t_slice_min[j] && !Are_Equal(t_slice_max[j], t_slice_min[j], 1.E-10)) indic[i * (2 * n_otu - 3) + j] = 1;
+ else if(t_prior_min[i + n_otu] < t_slice_min[j] && t_prior_max[i + n_otu] > t_slice_max[j] && !Are_Equal(t_slice_max[j], t_slice_min[j], 1.E-10)) indic[i * (2 * n_otu - 3) + j] = 1;
+ else if(Are_Equal(t_prior_min[i + n_otu], t_slice_min[j], 1.E-10) && Are_Equal(t_prior_max[i + n_otu], t_slice_max[j], 1.E-10)) indic[i * (2 * n_otu - 3) + j] = 1;
+ }
+ }
+
+
+ For(i, n_otu - 2)
+ {
+ indic[i * (2 * n_otu - 3)] = 0;
+ }
+
+ for(j = 1; j < 2 * n_otu - 3; j++)
+ {
+ indic[(n_otu - 2) * (2 * n_otu - 3) + j] = 0;
+ }
+
+ /* printf("\n"); */
+ /* printf(" ", j); */
+ /* For(j, 2 * n_otu - 3) printf(". '%d' ", j); */
+ /* printf("\n"); */
+ /* For(i, n_otu - 1) */
+ /* { */
+ /* printf(" ['%d'] ", i + n_otu); */
+ /* For(j, 2 * n_otu - 3) */
+ /* { */
+ /* printf(". '%d' ", indic[i * (2 * n_otu - 3) + j]); */
+ /* } */
+ /* printf("\n"); */
+ /* } */
+
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ //Running through all of the combinations of slices
+ int *cur_slices, *cur_slices_shr, *cur_slices_cpy, *slices_start_node, shr_num_slices;
+ phydbl *t_cur_slice_min, *t_cur_slice_max;
+ phydbl tot_num_comb;
+ phydbl log_g_i, lmbd;
+
+ lmbd = tree -> rates -> birth_rate;
+
+ tot_num_comb = 1;
+
+ t_cur_slice_min = (phydbl *)mCalloc(n_otu - 1, sizeof(phydbl));
+ t_cur_slice_max = (phydbl *)mCalloc(n_otu - 1, sizeof(phydbl));
+ cur_slices = (int *)mCalloc(n_otu - 1, sizeof(int)); //the vector of the current slices with repetition.
+ cur_slices_cpy = (int *)mCalloc(n_otu - 1, sizeof(int));
+ slices_start_node = (int *)mCalloc(n_otu - 1, sizeof(int));
+ cur_slices_shr = (int *)mCalloc(n_otu - 1, sizeof(int)); //the vector of the current slices without repetition.
+
+
+
+ ////////////////////////////////////////////////////////////////////////////
+ //Get the number of slices that can be applied for each node and the vectors of slice numbers for each node.
+ For(i, n_otu - 1)
+ {
+ k = 0;
+ For(j, 2 * n_otu - 3)
+ {
+ if(indic[i * (2 * n_otu - 3) + j] == 1)
+ {
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ g_i_node[i * (2 * n_otu - 3) + j] = (exp(lmbd * t_slice_max[j]) - exp(lmbd * t_slice_min[j])) /
+ (exp(lmbd * t_prior_max[i + n_otu]) - exp(lmbd * t_prior_min[i + n_otu]));
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ slice_numbers[i * (2 * n_otu - 3) + k] = j;
+ n_slice[i]++;
+ k++;
+ }
+ }
+ }
+ /* printf("\n"); */
+ /* For(i, n_otu - 1) */
+ /* { */
+ /* printf(" ['%d'] ", i + n_otu); */
+ /* For(j, 2 * n_otu - 3) */
+ /* { */
+ /* printf(". '%f' ", g_i_node[i * (2 * n_otu - 3) + j]); */
+ /* } */
+ /* printf("\n"); */
+ /* } */
+
+ /* printf("\n"); */
+ /* For(i, n_otu - 1) */
+ /* { */
+ /* printf(" ['%d'] ", i + n_otu); */
+ /* For(j, n_slice[i]) */
+ /* { */
+ /* printf(". '%d' ", slice_numbers[i * (2 * n_otu - 3) + j]); */
+ /* } */
+ /* printf("\n"); */
+ /* } */
+ For(i, n_otu - 1)
+ {
+ tot_num_comb = tot_num_comb * n_slice[i];
+ }
+
+
+ int r, numb_unsuc, max_size, comb_numb, *combinations, *max_combination, numb_approx; /* **combinations; */
+ phydbl K_total;
+ phydbl *t_slice_min_f, *t_slice_max_f, *K_val_approx;
+ int *root_nodes, *dif;
+ phydbl K_total_cur, max_K_val, scl_const;
+
+ max_size = 1000000;
+ combinations = (int *)mCalloc(max_size*(n_otu-1), sizeof(int));
+ max_combination = (int *)mCalloc((n_otu-1), sizeof(int));
+ t_slice_min_f = (phydbl *)mCalloc(n_otu - 1, sizeof(phydbl));
+ t_slice_max_f = (phydbl *)mCalloc(n_otu - 1, sizeof(phydbl));
+ K_val_approx = (phydbl *)mCalloc(max_size, sizeof(phydbl));
+ root_nodes = (int *)mCalloc(n_otu - 1, sizeof(int));
+ dif = (int *)mCalloc(n_otu - 1, sizeof(int));
+ numb_approx = 0;
+ max_K_val = 0;
+ scl_const = 0.0;
+ /* lmbd = 4.0; */
+ numb_unsuc = 0;
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////CALCULATING THE MAXIMUM VALUE OF m_i * g_i FOR ONE COMBINATION OF SLICES:////////////////////////////////////////////////////////////////
+
+ comb_numb = 0;
+ K_total = 0.0;
+
+ do
+ {
+ /* printf("\n ____________________________________________________________________________________________________ \n"); */
+
+ int x = 0, f = FALSE;
+
+ For(i, n_otu - 1)
+ {
+ r = rand()%(n_slice[i]);
+ t_slice_min_f[i] = t_slice_min[slice_numbers[i * (2 * n_otu - 3) + r]];
+ t_slice_max_f[i] = t_slice_max[slice_numbers[i * (2 * n_otu - 3) + r]];
+ cur_slices[i] = slice_numbers[i * (2 * n_otu - 3) + r];
+ }
+
+ For(i, n_otu - 1)
+ {
+ cur_slices_cpy[i] = cur_slices[i];
+ slices_start_node[i] = cur_slices[i];
+ }
+
+ For(i, n_otu - 1)
+ {
+ for(j = i + 1; j < n_otu - 1; j++)
+ {
+ if(cur_slices[i] == cur_slices[j]) cur_slices[j] = -1;
+ }
+ }
+ //For(i, n_otu - 1) printf(" Slice number'%d' \n", cur_slices[i]);
+
+ shr_num_slices = 0;
+ For(i, n_otu -1)
+ {
+ if(cur_slices[i] >= 0)
+ {
+ cur_slices_shr[shr_num_slices] = cur_slices[i];
+ shr_num_slices++;
+ }
+ }
+
+ int result_1;
+ int c = 0;
+ int num_elem;
+
+
+ result_1 = TRUE;
+
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[1], &result_1, t_slice_min_f, t_slice_max_f, tree);
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[2], &result_1, t_slice_min_f, t_slice_max_f, tree);
+
+ /* printf("\n. [START] Result '%d' \n", result_1); */
+
+
+ K_total_cur = 0.0;
+
+ if(result_1 != TRUE) K_total_cur = 0.0;
+ else
+ {
+ int n_1, n_2;
+
+ num_elem = 0;
+
+ x = 0;
+ f = FALSE;
+
+ if(comb_numb > 0)
+ {
+ For(i, comb_numb)
+ {
+ x = 0;
+ For(j, n_otu - 1)
+ {
+
+ dif[j] = combinations[i*(n_otu-1) + j] - cur_slices_cpy[j];
+ if(dif[j] == 0) x++;
+ }
+ if(x == n_otu - 1) f = TRUE;
+ }
+ }
+ if(!f)
+ {
+ For(i, n_otu - 1) combinations[comb_numb*(n_otu - 1) + i] = cur_slices_cpy[i];
+
+ /* printf("\n"); */
+ /* printf(" [1][CUR SLICES PROPOSED] "); */
+ /* printf(" [COMB NUMBER] = [%d] --- ", comb_numb); */
+ /* For(i, n_otu - 1) printf(". [%d] .", combinations[comb_numb*(n_otu - 1) + i]); */
+ /* printf("\n"); */
+
+
+
+ For(i, shr_num_slices)
+ {
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[1], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[2], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ }
+ /* for(i = 0; i < n_otu - 2; i++) printf("\n. [START] Node [%d] Slice_min [%f] Slice_max [%f] \n", i + n_otu, t_slice_min_f[i], t_slice_max_f[i]); */
+ For(j, num_elem)
+ {
+ n_1 = 0;
+ n_2 = 0;
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[1], &n_1, t_slice_min_f, t_slice_max_f, tree);
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[2], &n_2, t_slice_min_f, t_slice_max_f, tree);
+ /* printf("\n. n_1 [%d] n_2 [%d]\n", n_1, n_2); */
+ K_total_cur = K_total_cur + log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1);
+ /* printf("\n. K_total_cur [%f] \n", K_total_cur); */
+ /* printf("\n. [START] log(m_i) [%f] \n", log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1)); */
+ }
+ /* printf("\n. [START] log(m_i) [%f] \n", K_total_cur); */
+ /* printf("\n. K_total_cur [%f] \n", K_total_cur); */
+
+ log_g_i = 0.0;
+ For(i, n_otu - 2)
+ log_g_i += log_g_i(lmbd,
+ t_slice_max_f[i],
+ t_slice_min_f[i],
+ t_prior_max[i + n_otu],
+ MAX(t_prior_min[i + n_otu],tree->rates->nd_t[tree->n_root->num]));
+
+ /* printf("\n. [START] log(g_i) [%f] \n", log_g_i); */
+
+ K_total_cur = exp(K_total_cur + log_g_i + scl_const);
+
+ if(K_total_cur > max_K_val)
+ {
+ For(i, n_otu - 1) max_combination[i] = cur_slices_cpy[i];
+ max_K_val = K_total_cur;
+ }
+
+ K_val_approx[numb_approx] = K_total_cur;
+ numb_approx++;
+ /* printf("\n. [APPROX] Approximated constant after start (K_total_cur) = [%f] \n", (K_total_cur)); */
+
+ /* printf("\n. [START] m_i * g_i [%f] \n", K_total_cur); */
+ /* printf("\n. [START] sum(m_i * g_i) = m_i * g_i [%f] \n", K_total_cur); */
+ /* printf("\n. K of the tree for starting combination of slices [%f] \n", K_total_cur); */
+ comb_numb++;
+ if(comb_numb > max_size)
+ {
+ combinations = (int *)mRealloc(combinations, max_size*(n_otu - 1) + (n_otu - 1),sizeof(char));
+ max_size = max_size + 1;
+ }
+ c++;
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /* printf("\n. ____________________________________________________________________________________________ \n"); */
+ phydbl K_part, K_max;
+ int m, n, count;
+
+ K_max = K_total_cur;
+
+
+ /* printf("\n. K_total [%f] \n", K_total); */
+ do
+ {
+ r = rand()%(n_otu - 1);
+
+ count = 0;
+ For(m, r)
+ {
+ /* printf("\n. NODE NUMBER ['%d'] \n", m + n_otu); */
+ For(n, 2 * n_otu - 3)
+ {
+ K_part = 0.0;
+ if(g_i_node[m * (2 * n_otu - 3) + n] > 0)
+ {
+ t_slice_min_f[m] = t_slice_min[n];
+ t_slice_max_f[m] = t_slice_max[n];
+ cur_slices_cpy[m] = n;
+
+ For(i, n_otu - 1) cur_slices[i] = cur_slices_cpy[i];
+ For(i, n_otu - 1)
+ {
+ for(j = i + 1; j < n_otu - 1; j++)
+ {
+ if(cur_slices[i] == cur_slices[j]) cur_slices[j] = -1;
+ }
+ }
+
+ shr_num_slices = 0;
+ For(i, n_otu -1)
+ {
+ if(cur_slices[i] >= 0)
+ {
+ cur_slices_shr[shr_num_slices] = cur_slices[i];
+ shr_num_slices++;
+ }
+ }
+
+ result_1 = TRUE;
+
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[1], &result_1, t_slice_min_f, t_slice_max_f, tree);
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[2], &result_1, t_slice_min_f, t_slice_max_f, tree);
+
+ if(result_1 != TRUE) K_part = 0.0;
+ else
+ {
+ int n_1, n_2;
+
+ x = 0;
+ f = FALSE;
+
+ num_elem = 0;
+
+ if(comb_numb > 0)
+ {
+ For(i, comb_numb)
+ {
+ x = 0;
+ For(j, n_otu - 1)
+ {
+
+ dif[j] = combinations[i*(n_otu-1) + j] - cur_slices_cpy[j];
+ if(dif[j] == 0) x++;
+ }
+ if(x == n_otu - 1) f = TRUE;
+ }
+ }
+
+
+ if(!f)
+ {
+ For(i, n_otu - 1) combinations[comb_numb*(n_otu-1) + i] = cur_slices_cpy[i];
+ /* printf("\n"); */
+ /* printf(" [2][CUR SLICES PROPOSED] "); */
+ /* printf(" [COMB NUMBER] = [%d] --- ", comb_numb); */
+ /* For(i, n_otu - 1) printf(". [%d] .", combinations[comb_numb*(n_otu-1) + i]); */
+ /* printf("\n"); */
+
+
+ For(i, shr_num_slices)
+ {
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[1], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[2], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ }
+ For(j, num_elem)
+ {
+ n_1 = 0;
+ n_2 = 0;
+
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[1], &n_1, t_slice_min_f, t_slice_max_f, tree);
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[2], &n_2, t_slice_min_f, t_slice_max_f, tree);
+ /* printf("\n. n_1 [%d] n_2 [%d]\n", n_1, n_2); */
+
+ K_part = K_part + log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1);
+ /* printf("\n. [CONT] log(m_i) [%f] \n", log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1)); */
+ }
+ /* printf("\n. [CONT] log(m_i) [%f] \n", K_part); */
+ /* printf("\n. K_part [%f] \n", K_part); */
+
+
+
+ if(K_part > max_K_val)
+ {
+ For(i, n_otu - 1) max_combination[i] = cur_slices_cpy[i];
+ max_K_val = K_part;
+ }
+
+ log_g_i = 0.0;
+ For(i, n_otu - 2)
+ log_g_i += log_g_i(lmbd,
+ t_slice_max_f[i],
+ t_slice_min_f[i],
+ t_prior_max[i + n_otu],
+ MAX(t_prior_min[i + n_otu],tree->rates->nd_t[tree->n_root->num]));
+
+ /* printf("\n. [START] log(g_i) [%f] \n", log_g_i); */
+
+ K_part = exp(K_part + log_g_i + scl_const);
+
+ if(K_part > max_K_val)
+ {
+ For(i, n_otu - 1) max_combination[i] = cur_slices_cpy[i];
+ max_K_val = K_part;
+ }
+
+ /* printf("\n. [START] m_i * g_i [%f] \n", K_part); */
+
+ K_val_approx[numb_approx] = K_part;
+ numb_approx++;
+
+ K_total_cur = K_total_cur + K_part;
+ /* printf("\n. [APPROX] Approximated constant after one run (K_part) = [%f] \n", (K_part)); */
+ /* printf("\n. K_max [%f] K_part [%f] \n", K_max, K_part); */
+ /* printf("\n. [CONT] sum(m_i * g_i) [%f] \n", K_total_cur); */
+ if(K_max < K_part)
+ {
+ K_max = K_part;
+ /* For(i, n_otu - 1) slices_start_node[i] = cur_slices_cpy[i]; */
+ count++;
+ }
+
+ comb_numb++;
+ if(comb_numb > max_size)
+ {
+ combinations = (int *)mRealloc(combinations, max_size*(n_otu - 1) + (n_otu - 1),sizeof(char));
+ max_size = max_size + 1;
+ }
+ c++;
+
+ }
+ }
+ }
+ }
+ }
+
+
+ for(m = r; m < n_otu - 1; m++)
+ {
+ For(n, 2 * n_otu - 3)
+ {
+
+ K_part = 0.0;
+ if(g_i_node[m * (2 * n_otu - 3) + n] > 0)
+ {
+ t_slice_min_f[m] = t_slice_min[n];
+ t_slice_max_f[m] = t_slice_max[n];
+ cur_slices_cpy[m] = n;
+
+ For(i, n_otu - 1) cur_slices[i] = cur_slices_cpy[i];
+ For(i, n_otu - 1)
+ {
+ for(j = i + 1; j < n_otu - 1; j++)
+ {
+ if(cur_slices[i] == cur_slices[j]) cur_slices[j] = -1;
+ }
+ }
+
+ shr_num_slices = 0;
+ For(i, n_otu -1)
+ {
+ if(cur_slices[i] >= 0)
+ {
+ cur_slices_shr[shr_num_slices] = cur_slices[i];
+ shr_num_slices++;
+ }
+ }
+
+ result_1 = TRUE;
+
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[1], &result_1, t_slice_min_f, t_slice_max_f, tree);
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[2], &result_1, t_slice_min_f, t_slice_max_f, tree);
+
+ if(result_1 != TRUE) K_part = 0.0;
+ else
+ {
+ int n_1, n_2;
+
+ x = 0;
+ f = FALSE;
+
+ num_elem = 0;
+
+ if(comb_numb > 0)
+ {
+ For(i, comb_numb)
+ {
+ x = 0;
+ For(j, n_otu - 1)
+ {
+
+ dif[j] = combinations[i*(n_otu-1) + j] - cur_slices_cpy[j];
+ /* dif[j] = combinations[i][j] - cur_slices_cpy[j]; */
+ if(dif[j] == 0) x++;
+ /* printf(". [%d] ", dif[j]); */
+ }
+ if(x == n_otu - 1) f = TRUE;
+ }
+ }
+
+
+ if(!f)
+ {
+ For(i, n_otu - 1) combinations[comb_numb*(n_otu-1) + i] = cur_slices_cpy[i];
+ /* printf("\n"); */
+ /* printf(" [2][CUR SLICES PROPOSED] "); */
+ /* printf(" [COMB NUMBER] = [%d] --- ", comb_numb); */
+ /* For(i, n_otu - 1) printf(". [%d] .", combinations[comb_numb*(n_otu-1) + i]); */
+ /* printf("\n"); */
+
+
+ For(i, shr_num_slices)
+ {
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[1], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[2], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ }
+ For(j, num_elem)
+ {
+ n_1 = 0;
+ n_2 = 0;
+
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[1], &n_1, t_slice_min_f, t_slice_max_f, tree);
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[2], &n_2, t_slice_min_f, t_slice_max_f, tree);
+ /* printf("\n. n_1 [%d] n_2 [%d]\n", n_1, n_2); */
+
+ K_part = K_part + log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1);
+ /* printf("\n. [CONT] log(m_i) [%f] \n", log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1)); */
+ }
+ /* printf("\n. [CONT] log(m_i) [%f] \n", K_part); */
+ /* printf("\n. K_part [%f] \n", K_part); */
+
+ log_g_i = 0.0;
+ For(i, n_otu - 2)
+ log_g_i += log_g_i(lmbd,
+ t_slice_max_f[i],
+ t_slice_min_f[i],
+ t_prior_max[i + n_otu],
+ MAX(t_prior_min[i + n_otu],tree->rates->nd_t[tree->n_root->num]));
+ /* printf("\n. [START] log(g_i) [%f] \n", log_g_i); */
+
+ K_part = exp(K_part + log_g_i + scl_const);
+
+ if(K_part > max_K_val)
+ {
+ For(i, n_otu - 1) max_combination[i] = cur_slices_cpy[i];
+ max_K_val = K_part;
+ }
+
+ /* printf("\n. [START] m_i * g_i [%f] \n", K_part); */
+
+ K_val_approx[numb_approx] = K_part;
+ numb_approx++;
+
+ K_total_cur = K_total_cur + K_part;
+
+ /* printf("\n. [APPROX] Approximated constant after one run (K_part) = [%f] \n", (K_part)); */
+ /* printf("\n. K_max [%f] K_part [%f] \n", K_max, K_part); */
+ /* printf("\n. [CONT] sum(m_i * g_i) [%f] \n", K_total_cur); */
+ if(K_max < K_part)
+ {
+ K_max = K_part;
+ /* For(i, n_otu - 1) slices_start_node[i] = cur_slices_cpy[i]; */
+ count++;
+ }
+
+ comb_numb++;
+ if(comb_numb > max_size)
+ {
+ combinations = (int *)mRealloc(combinations, max_size*(n_otu - 1) + (n_otu - 1),sizeof(char));
+ max_size = max_size + 1;
+ }
+ c++;
+ }
+ }
+ }
+ }
+ }
+ if(Are_Equal(count, 0, 1.E-10)) break;
+ }
+ while(1);
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ For(m, n_otu - 1)
+ {
+ For(i, n_otu - 1) cur_slices_cpy[i] = max_combination[i];
+ For(i, n_otu - 1)
+ {
+ t_slice_min_f[i] = t_slice_min[cur_slices_cpy[i]];
+ t_slice_max_f[i] = t_slice_max[cur_slices_cpy[i]];
+ }
+ For(n, 2 * n_otu - 3)
+ {
+
+ K_part = 0.0;
+ if(g_i_node[m * (2 * n_otu - 3) + n] > 0)
+ {
+ t_slice_min_f[m] = t_slice_min[n];
+ t_slice_max_f[m] = t_slice_max[n];
+ cur_slices_cpy[m] = n;
+
+ For(i, n_otu - 1) cur_slices[i] = cur_slices_cpy[i];
+ For(i, n_otu - 1)
+ {
+ for(j = i + 1; j < n_otu - 1; j++)
+ {
+ if(cur_slices[i] == cur_slices[j]) cur_slices[j] = -1;
+ }
+ }
+
+ shr_num_slices = 0;
+ For(i, n_otu -1)
+ {
+ if(cur_slices[i] >= 0)
+ {
+ cur_slices_shr[shr_num_slices] = cur_slices[i];
+ shr_num_slices++;
+ }
+ }
+
+ result_1 = TRUE;
+
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[1], &result_1, t_slice_min_f, t_slice_max_f, tree);
+ Check_Time_Slices(tree -> n_root, tree -> n_root -> v[2], &result_1, t_slice_min_f, t_slice_max_f, tree);
+
+ if(result_1 != TRUE) K_part = 0.0;
+ else
+ {
+ int n_1, n_2;
+
+ x = 0;
+ f = FALSE;
+
+ num_elem = 0;
+
+ if(comb_numb > 0)
+ {
+ For(i, comb_numb)
+ {
+ x = 0;
+ For(j, n_otu - 1)
+ {
+
+ dif[j] = combinations[i*(n_otu-1) + j] - cur_slices_cpy[j];
+ /* dif[j] = combinations[i][j] - cur_slices_cpy[j]; */
+ if(dif[j] == 0) x++;
+ /* printf(". [%d] ", dif[j]); */
+ }
+ if(x == n_otu - 1) f = TRUE;
+ }
+ }
+
+
+ if(!f)
+ {
+ For(i, n_otu - 1) combinations[comb_numb*(n_otu-1) + i] = cur_slices_cpy[i];
+ /* printf("\n"); */
+ /* printf(" [2][CUR SLICES PROPOSED] "); */
+ /* printf(" [COMB NUMBER] = [%d] --- ", comb_numb); */
+ /* For(i, n_otu - 1) printf(". [%d] .", combinations[comb_numb*(n_otu-1) + i]); */
+ /* printf("\n"); */
+
+
+ For(i, shr_num_slices)
+ {
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[1], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ Search_Root_Node_In_Slice(tree -> n_root, tree -> n_root -> v[2], root_nodes, &num_elem, t_slice_min[cur_slices_shr[i]], t_slice_max[cur_slices_shr[i]], t_slice_min_f, t_slice_max_f, tree);
+ }
+ For(j, num_elem)
+ {
+ n_1 = 0;
+ n_2 = 0;
+
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[1], &n_1, t_slice_min_f, t_slice_max_f, tree);
+ Number_Of_Nodes_In_Slice(tree -> a_nodes[root_nodes[j] + n_otu], tree -> a_nodes[root_nodes[j] + n_otu] -> v[2], &n_2, t_slice_min_f, t_slice_max_f, tree);
+ /* printf("\n. n_1 [%d] n_2 [%d]\n", n_1, n_2); */
+
+ K_part = K_part + log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1);
+ /* printf("\n. [CONT] log(m_i) [%f] \n", log(1) - log(n_1 + n_2 + 1) - LnGamma(n_1 + 1) - LnGamma(n_2 + 1)); */
+ }
+ /* printf("\n. [CONT] log(m_i) [%f] \n", K_part); */
+ /* printf("\n. K_part [%f] \n", K_part); */
+
+ log_g_i = 0.0;
+ For(i, n_otu - 2)
+ log_g_i += log_g_i(lmbd,
+ t_slice_max_f[i],
+ t_slice_min_f[i],
+ t_prior_max[i + n_otu],
+ MAX(t_prior_min[i + n_otu],tree->rates->nd_t[tree->n_root->num]));
+ /* printf("\n. [START] log(g_i) [%f] \n", log_g_i); */
+
+ K_part = exp(K_part + log_g_i + scl_const);
+
+ if(K_part > max_K_val)
+ {
+ For(i, n_otu - 1) max_combination[i] = cur_slices_cpy[i];
+ max_K_val = K_part;
+ }
+
+ /* printf("\n. [START] m_i * g_i [%f] \n", K_part); */
+
+ K_val_approx[numb_approx] = K_part;
+ numb_approx++;
+
+ K_total_cur = K_total_cur + K_part;
+
+ comb_numb++;
+ if(comb_numb > max_size)
+ {
+ combinations = (int *)mRealloc(combinations, max_size*(n_otu - 1) + (n_otu - 1),sizeof(char));
+ max_size = max_size + 1;
+ }
+ c++;
+ }
+ }
+ }
+ }
+ }
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ K_total = K_total + K_total_cur;
+ /* printf("\n. [APPROX TOTAL] Approximated constant (K_total) = [%f] \n", (K_total)); */
+ /* printf("\n%G %d", K_total, c); */
+ if(Are_Equal(c, 0, 1.E-10)) numb_unsuc++;
+ else numb_unsuc = 0;
+ }
+ while(numb_unsuc < 100);
+
+ /* printf("\n"); */
+ /* printf("\n. [APPROX TOTAL] log(K_total) = [%f] \n", log(K_total)); */
+ /* printf("\n. [APPROX TOTAL] log(Constant) = scl_const - log(K_total) = [%f] \n", scl_const - log(K_total)); */
+ /* printf("\n. [APPROX TOTAL] Approximated constant 1 / (K_total) = [%f] \n", 1 / (K_total)); */
+ /* printf("\n ____________________________________________________________________________________________________ \n"); */
+ /* printf("\n. [APPROX TOTAL] Numb_approx = [%d] \n", numb_approx); */
+ /* printf("\n"); */
+ /* } */
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+ free(combinations);
+ free(max_combination);
+ free(dif);
+
+ free(t_cur_slice_min);
+ free(t_cur_slice_max);
+ free(cur_slices);
+ free(cur_slices_cpy);
+ free(slices_start_node);
+ free(cur_slices_shr);
+ free(t_slice);
+ free(t_slice_min);
+ free(t_slice_max);
+ free(t_slice_min_f);
+ free(t_slice_max_f);
+ free(indic);
+ free(slice_numbers);
+ free(root_nodes);
+ free(n_slice);
+ free(g_i_node);
+ free(K_val_approx);
+
+ return(-log(K_total));
+}
+
+////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+int Number_Of_Comb_Slices(int m, int num_elem, int *n_slice)
+{
+ int i, num_comb;
+
+ i = 0;
+ num_comb = 1;
+
+ for(i = m; i < num_elem; i++) num_comb = num_comb * n_slice[i];
+
+ return(num_comb);
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Check the combination of the time slices to be set correctly.
+void Check_Time_Slices(t_node *a, t_node *d, int *result, phydbl *t_cur_slice_min, phydbl *t_cur_slice_max, t_tree *tree)
+{
+ int n_otu;
+
+ n_otu = tree -> n_otu;
+
+
+ d -> anc = a;
+ if(d -> tax) return;
+ else
+ {
+ if(t_cur_slice_max[d -> num - n_otu] < t_cur_slice_max[a -> num - n_otu])
+ {
+ *result = FALSE;
+ }
+
+ int i;
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Check_Time_Slices(d, d -> v[i], result, t_cur_slice_min, t_cur_slice_max, tree);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////
+//Getting the number of nodes on both sides from the node d_start, that are in the slice of that node.
+void Number_Of_Nodes_In_Slice(t_node *d_start, t_node *d, int *n, phydbl *t_cur_slice_min, phydbl *t_cur_slice_max, t_tree *tree)
+{
+ int n_otu;
+
+ n_otu = tree -> n_otu;
+
+
+ if(d -> tax) return;
+ else
+ {
+ if(Are_Equal(t_cur_slice_max[d_start -> num - n_otu], t_cur_slice_max[d -> num - n_otu], 1.E-10) && Are_Equal(t_cur_slice_min[d_start -> num - n_otu], t_cur_slice_min[d -> num - n_otu], 1.E-10))
+ {
+ (*n)++;
+ int i;
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Number_Of_Nodes_In_Slice(d_start, d -> v[i], n, t_cur_slice_min, t_cur_slice_max, tree);
+ }
+ }
+}
+
+
+//////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////
+//Returnig the root node in the given slice.
+void Search_Root_Node_In_Slice(t_node *d_start, t_node *d, int *root_nodes, int *num_elem, phydbl t_slice_min, phydbl t_slice_max, phydbl *t_cur_slice_min, phydbl *t_cur_slice_max, t_tree *tree)
+{
+ int j, n_otu, f;
+ j = 0;
+ f = FALSE;
+ n_otu = tree -> n_otu;
+
+ if(Are_Equal(t_cur_slice_max[d_start -> num - n_otu], t_slice_max, 1.E-10) && Are_Equal(t_cur_slice_min[d_start -> num - n_otu], t_slice_min, 1.E-10))
+ {
+ For(j, *num_elem) if(d_start -> num - n_otu == (root_nodes[j])) f = TRUE;
+ if(f != TRUE)
+ {
+ (root_nodes[(*num_elem)]) = d_start -> num - n_otu;
+ (*num_elem)++;
+ return;
+ }
+
+ }
+ else
+ {
+ d -> anc = d_start;
+ if(d -> tax) return;
+ else
+ {
+ if(Are_Equal(t_cur_slice_max[d -> num - n_otu], t_slice_max, 1.E-10) && Are_Equal(t_cur_slice_min[d -> num - n_otu], t_slice_min, 1.E-10))
+ {
+ (root_nodes[*num_elem]) = d -> num - n_otu;
+ (*num_elem)++;
+ return;
+ }
+
+ int i;
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Search_Root_Node_In_Slice(d, d -> v[i], root_nodes, num_elem, t_slice_min, t_slice_max, t_cur_slice_min, t_cur_slice_max, tree);
+ }
+ }
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+int Factorial(int base)
+{
+ if(base == 0) return(1);
+ if(base == 1) return(1);
+ return(base * Factorial(base-1));
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Calculate the vector of the norm.constants for prior on node times.
+//The length of the vector is the total number of combinations of calibrations.
+phydbl *Norm_Constant_Prior_Times(t_tree *tree)
+{
+
+ phydbl *log_K_val;
+ int i, tot_num_comb;
+ t_cal *calib;
+
+ calib = tree -> rates -> calib;
+
+ tot_num_comb = Number_Of_Comb(calib);
+
+
+ log_K_val = (phydbl *)mCalloc(tot_num_comb, sizeof(phydbl));
+
+ For(i, tot_num_comb)
+ {
+
+ Set_Current_Calibration(i, tree);
+
+ int result = TRUE;
+
+ TIMES_Set_All_Node_Priors_S(&result, tree);
+
+ if(result == TRUE) log_K_val[i] = K_Constant_Prior_Times_Log(tree);
+
+ while(calib -> prev) calib = calib -> prev;
+ }
+ return(log_K_val);
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Sets a vector of the partial probabilities for each combination of calibrations
+void TIMES_Calib_Partial_Proba(t_tree *tree)
+{
+
+ phydbl *times_partial_proba, proba, *t_prior_min, *t_prior_max;
+ int i, j, k, tot_num_comb;
+ t_cal *calib;
+ short int *t_has_prior;
+
+ proba = 0.0;
+
+ times_partial_proba = tree -> rates -> times_partial_proba;
+ calib = tree -> rates -> calib;
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ t_has_prior = tree -> rates -> t_has_prior;
+
+ tot_num_comb = Number_Of_Comb(calib);
+
+ For(i, tot_num_comb)
+ {
+ times_partial_proba[i] = 1.0;
+ for(j = tree -> n_otu; j < 2 * tree -> n_otu - 1; j++)
+ {
+ t_prior_min[j] = -BIG;
+ t_prior_max[j] = BIG;
+ t_has_prior[j] = NO;
+ }
+ do
+ {
+ k = (i % Number_Of_Comb(calib)) / Number_Of_Comb(calib -> next);
+ if(calib -> all_applies_to[k] -> num)
+ {
+ t_prior_min[calib -> all_applies_to[k] -> num] = MAX(t_prior_min[calib -> all_applies_to[k] -> num], calib -> lower);
+ t_prior_max[calib -> all_applies_to[k] -> num] = MIN(t_prior_max[calib -> all_applies_to[k] -> num], calib -> upper);
+ t_has_prior[calib -> all_applies_to[k] -> num] = YES;
+ proba = calib -> proba[calib -> all_applies_to[k] -> num];
+ times_partial_proba[i] *= proba;
+ }
+ else
+ {
+ proba = calib -> proba[2 * tree -> n_otu - 1];
+ times_partial_proba[i] *= proba;
+
+ }
+
+ if(calib -> next) calib = calib -> next;
+ else break;
+ }
+ while(calib);
+
+ int result;
+
+ result = TRUE;
+
+ TIMES_Set_All_Node_Priors_S(&result, tree);
+
+ if(result != TRUE) times_partial_proba[i] = 0; /* printf("\n. [4] Partial Proba [%f] \n", times_partial_proba[i]); */
+
+ while(calib -> prev) calib = calib -> prev;
+
+ }
+
+ phydbl sum_proba;
+ sum_proba = 0.0;
+
+ For(i, tot_num_comb) sum_proba += times_partial_proba[i];
+ if(!Are_Equal(sum_proba, 1.0, 1.E-10))
+ {
+ For(i, tot_num_comb) times_partial_proba[i] = times_partial_proba[i] / sum_proba;
+ }
+
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Function checks if the randomized node times are within the
+//upper and lower time limits, taken into account the times of
+//the ancestor and descendent.
+void Check_Node_Time(t_node *a, t_node *d, int *result, t_tree *tree)
+{
+ phydbl t_low, t_up;
+ phydbl *t_prior_min, *t_prior_max, *nd_t;
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ nd_t = tree -> rates -> nd_t;
+
+ if((a == tree -> n_root) &&
+ ((nd_t[a -> num] > MIN(t_prior_max[a -> num], MIN(nd_t[a -> v[1] -> num], nd_t[a -> v[2] -> num]))) ||
+ (nd_t[a -> num] < t_prior_min[a -> num])))
+
+ {
+ *result = FALSE;
+ return;
+ }
+
+ if(d -> tax) return;
+ else
+ {
+ t_low = MAX(t_prior_min[d -> num], nd_t[d -> anc -> num]);
+ t_up = MIN(t_prior_max[d -> num], MIN(nd_t[d -> v[1] -> num], nd_t[d -> v[2] -> num]));
+ /* printf("\n. CHECK: %d t:%f u:%f d:%f",d->num,nd_t[d->num],t_up,t_low); */
+ if(nd_t[d -> num] < t_low || nd_t[d -> num] > t_up)
+ {
+ *result = FALSE;
+ return;
+ }
+
+ int i;
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Check_Node_Time(d, d -> v[i], result, tree);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Function calculates the TOTAL number of calibration combinations,
+//given the number of nodes to which each calibartion applies to.
+int Number_Of_Comb(t_cal *calib)
+{
+
+ int num_comb;
+
+ if(!calib) return(1);
+ num_comb = 1;
+ do
+ {
+ num_comb *= calib -> n_all_applies_to;
+ if(calib -> next) calib = calib -> next;
+ else break;
+ }
+ while(calib);
+ return(num_comb);
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Function calculates the TOTAL number of calibration combinations,
+//given the number of nodes to which each calibartion applies to.
+int Number_Of_Calib(t_cal *calib)
+{
+
+ int num_calib;
+
+
+ num_calib = 0;
+ do
+ {
+ num_calib++;
+ if(calib -> next) calib = calib -> next;
+ else break;
+ }
+ while(calib);
+ return(num_calib);
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// Function sets current calibration in the following way:
+// Suppose we have a vector of calibrations C=(C1, C2, C3), each calibration
+// applies to a set of nodes. We can reach each node number through the indexes (corresponds
+// to the number the information was read). C1={0,1,2}, C2={0,1}, C3={0};
+// The total number of combinations is 3*2*1=6. The first combination with row number 0
+// will be {0,0,0}, the second row will be {0,1,0} and so on. Calling the node numbers with
+// the above indexes will return current calibration. Also sets the vector of probabilities
+// for current calibration combination.
+void Set_Current_Calibration(int row, t_tree *tree)
+{
+ t_cal *calib;
+ phydbl *t_prior_min, *t_prior_max;
+ short int *t_has_prior;
+ int k, i, j, *curr_nd_for_cal;
+
+ calib = tree -> rates -> calib;
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ t_has_prior = tree -> rates -> t_has_prior;
+ curr_nd_for_cal = tree -> rates -> curr_nd_for_cal;
+ /* printf("\n COMBINATION NUMBER [%d] \n", row); */
+ for(j = tree -> n_otu; j < 2 * tree -> n_otu - 1; j++)
+ {
+ t_prior_min[j] = -BIG;
+ t_prior_max[j] = BIG;
+ t_has_prior[j] = NO;
+ }
+
+ k = -1;
+ i = 0;
+ do
+ {
+ k = (row % Number_Of_Comb(calib)) / Number_Of_Comb(calib -> next);
+ if(calib -> all_applies_to[k] -> num)
+ {
+ /* printf("\n"); */
+ /* printf(" %f %f %f %f ", calib -> lower, calib -> upper, t_prior_min[calib -> all_applies_to[k] -> num], t_prior_max[calib -> all_applies_to[k] -> num]); */
+ /* printf("\n"); */
+ /* printf("\n"); */
+ /* printf(" Node number [%d] ", calib -> all_applies_to[k] -> num); */
+ /* printf("\n"); */
+ t_prior_min[calib -> all_applies_to[k] -> num] = MAX(t_prior_min[calib -> all_applies_to[k] -> num], calib -> lower); /* printf("\n Prior min [%f] \n", t_prior_min[calib -> all_applies_to[k] -> num]); */
+ t_prior_max[calib -> all_applies_to[k] -> num] = MIN(t_prior_max[calib -> all_applies_to[k] -> num], calib -> upper); /* printf("\n Prior max [%f] \n", t_prior_max[calib -> all_applies_to[k] -> num]); */
+ t_has_prior[calib -> all_applies_to[k] -> num] = YES;
+ curr_nd_for_cal[i] = calib -> all_applies_to[k] -> num;
+ i++;
+ }
+ if(calib->next) calib = calib->next;
+ else break;
+ }
+ while(calib);
+ while(calib -> prev) calib = calib -> prev;
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Randomly choose a combination of calibrations drawing an index of calibration combination,
+//used function Set_Cur_Calibration.
+void Random_Calibration(t_tree *tree)
+{
+ int rnd, num_comb;
+ t_cal *calib;
+
+ calib = tree -> rates -> calib;
+
+ num_comb = Number_Of_Comb(calib);
+
+ srand(time(NULL));
+ rnd = rand()%(num_comb);
+
+ Set_Current_Calibration(rnd, tree);
+ TIMES_Set_All_Node_Priors(tree);
+
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Variable curr_nd_for_cal is a vector of node numbers, the length of that vector is a number of calibrations.
+//Function randomly updates that vector by randomly changing one node and setting times limits with respect
+//to a new vector.
+int RND_Calibration_And_Node_Number(t_tree *tree)
+{
+ int i, j, tot_num_cal, cal_num, node_ind, node_num, *curr_nd_for_cal;
+ phydbl *t_prior_min, *t_prior_max; //*times_partial_proba;
+ short int *t_has_prior;
+ t_cal *cal;
+
+ tot_num_cal = tree -> rates -> tot_num_cal;
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ t_has_prior = tree -> rates -> t_has_prior;
+ curr_nd_for_cal = tree -> rates -> curr_nd_for_cal;
+ cal = tree -> rates -> calib;
+
+ cal_num = rand()%(tot_num_cal - 1);
+
+ i = 0;
+ while (i != cal_num)
+ {
+ cal = cal -> next;
+ i++;
+ }
+
+ node_ind = rand()%(cal -> n_all_applies_to);
+ node_num = cal -> all_applies_to[node_ind] -> num;
+
+ curr_nd_for_cal[cal_num] = node_num;
+
+ for(j = tree -> n_otu; j < 2 * tree -> n_otu - 1; j++)
+ {
+ t_prior_min[j] = -BIG;
+ t_prior_max[j] = BIG;
+ t_has_prior[j] = NO;
+ }
+
+ while(cal -> prev) cal = cal -> prev;
+
+ i = 0;
+ do
+ {
+ t_prior_min[curr_nd_for_cal[i]] = cal -> lower;
+ t_prior_max[curr_nd_for_cal[i]] = cal -> upper;
+ t_has_prior[curr_nd_for_cal[i]] = YES;
+ i++;
+ if(cal->next) cal = cal -> next;
+ else break;
+ }
+ while(cal);
+
+ while(cal -> prev) cal = cal -> prev;
+
+ TIMES_Set_All_Node_Priors(tree);
+
+ return(node_num);
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Return the value uniformly distributed between two values.
+phydbl Randomize_One_Node_Time(phydbl min, phydbl max)
+{
+ phydbl u;
+
+ u = Uni();
+ u *= (max - min);
+ u += min;
+
+ return(u);
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Calculates the Hastings ratio for the analysis. Used in case of
+//calibration conditional jump. NOT THE RIGHT ONE TO USE!
+void Lk_Hastings_Ratio_Times(t_node *a, t_node *d, phydbl *tot_prob, t_tree *tree)
+{
+ phydbl t_low, t_up;
+ phydbl *t_prior_min, *t_prior_max, *nd_t;
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ nd_t = tree -> rates -> nd_t;
+
+ if(d -> tax) return;
+ else
+ {
+ t_low = MAX(t_prior_min[d -> num], nd_t[d -> anc -> num]);
+ t_up = MIN(t_prior_max[d -> num], MIN(nd_t[d -> v[1] -> num], nd_t[d -> v[2] -> num]));
+
+ (*tot_prob) += log(1) - log(t_up - t_low);
+
+ int i;
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ {
+ Lk_Hastings_Ratio_Times(d, d -> v[i], tot_prob, tree);
+ }
+ }
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Updates nodes which are below a randomized node in case if new proposed time
+//for that node is below the current value.
+void Update_Descendent_Cond_Jump(t_node *a, t_node *d, phydbl *L_Hast_ratio, t_tree *tree)
+{
+ int result = TRUE;
+ phydbl t_low, t_up;
+ phydbl *t_prior_min, *t_prior_max, *nd_t;
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ nd_t = tree -> rates -> nd_t;
+
+ Check_Node_Time(tree -> n_root, tree -> n_root -> v[1], &result, tree);
+ Check_Node_Time(tree -> n_root, tree -> n_root -> v[2], &result, tree);
+
+ if(d -> tax) return;
+ else
+ {
+ if(result != TRUE)
+ {
+ int i;
+ t_low = MAX(nd_t[a -> num], t_prior_min[d -> num]);
+ if(t_low < MIN(nd_t[d -> v[1] -> num], nd_t[d -> v[2] -> num])) t_up = MIN(t_prior_max[d -> num], MIN(nd_t[d -> v[1] -> num], nd_t[d -> v[2] -> num]));
+ else t_up = t_prior_max[d -> num];
+ nd_t[d -> num] = Randomize_One_Node_Time(t_low, t_up);
+ (*L_Hast_ratio) += log(1) - log(t_up - t_low);
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Update_Descendent_Cond_Jump(d, d -> v[i], L_Hast_ratio, tree);
+ }
+ else return;
+ }
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//Updates nodes which are above a randomized node in case if new proposed time
+//for that node is above the current value.
+void Update_Ancestor_Cond_Jump(t_node *d, phydbl *L_Hast_ratio, t_tree *tree)
+{
+ int result = TRUE;
+ phydbl t_low, t_up;
+ phydbl *t_prior_min, *t_prior_max, *nd_t;
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ nd_t = tree -> rates -> nd_t;
+
+ Check_Node_Time(tree -> n_root, tree -> n_root -> v[1], &result, tree);
+ Check_Node_Time(tree -> n_root, tree -> n_root -> v[2], &result, tree);
+
+ if(result != TRUE)
+ {
+ if(d == tree -> n_root)
+ {
+
+ t_low = t_prior_min[d -> num];
+ t_up = MIN(t_prior_max[d -> num], MIN(nd_t[d -> v[1] -> num], nd_t[d -> v[2] -> num]));
+ nd_t[d -> num] = Randomize_One_Node_Time(t_low, t_up);
+ (*L_Hast_ratio) += log(1) - log(t_up - t_low);
+ return;
+ }
+ else
+ {
+ t_up = MIN(t_prior_max[d -> num], MIN(nd_t[d -> v[1] -> num], nd_t[d -> v[2] -> num]));
+ if(nd_t[d -> anc -> num] > t_up) t_low = t_prior_min[d -> num];
+ else t_low = MAX(t_prior_min[d -> num], nd_t[d -> anc -> num]);
+ nd_t[d -> num] = Randomize_One_Node_Time(t_low, t_up);
+ (*L_Hast_ratio) += log(1) - log(t_up - t_low);
+ Update_Ancestor_Cond_Jump(d -> anc, L_Hast_ratio, tree);
+ }
+
+ }
+ else return;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//when made a calibration conditional jump, updates node times
+//with respect to the new calibration which was made with respect
+//to the randomly chosen node, the root is fixed. Updates only those nodes
+//that are not within new intervals. Traverse up and down.
+void Update_Times_RND_Node_Ancestor_Descendant(int rnd_node, phydbl *L_Hast_ratio, t_tree *tree)
+{
+ int i;
+ phydbl *t_prior_min, *t_prior_max, *nd_t;
+ phydbl new_time_rnd_node = 0.0;
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ nd_t = tree -> rates -> nd_t;
+
+ new_time_rnd_node = Randomize_One_Node_Time(t_prior_min[rnd_node], t_prior_max[rnd_node]);
+
+ nd_t[rnd_node] = new_time_rnd_node;
+
+ Update_Ancestor_Cond_Jump(tree -> a_nodes[rnd_node] -> anc, L_Hast_ratio, tree);
+ for(i=0;i<3;i++)
+ if((tree -> a_nodes[rnd_node] -> v[i] != tree -> a_nodes[rnd_node] -> anc) && (tree -> a_nodes[rnd_node] -> b[i] != tree -> e_root))
+ Update_Descendent_Cond_Jump(tree -> a_nodes[rnd_node], tree -> a_nodes[rnd_node] -> v[i], L_Hast_ratio, tree);
+
+}
+
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+//when made a calibration conditional jump, updates node times
+//with respect to the new calibration which was made with respect
+//to the randomly chosen node, starting from the root down to the tips.
+//Updates only those nodes that are not within new intervals.
+void Update_Times_Down_Tree(t_node *a, t_node *d, phydbl *L_Hastings_ratio, t_tree *tree)
+{
+ int i;
+ phydbl *t_prior_min, *t_prior_max, *nd_t, t_low, t_up;
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ nd_t = tree -> rates -> nd_t;
+
+
+ t_low = MAX(t_prior_min[d -> num], nd_t[a -> num]);
+ t_up = t_prior_max[d -> num];
+
+ //printf("\n. [1] Node number: [%d] \n", d -> num);
+ if(d -> tax) return;
+ else
+ {
+ if(nd_t[d -> num] > t_up || nd_t[d -> num] < t_low)
+ {
+ //printf("\n. [2] Node number: [%d] \n", d -> num);
+ //(*L_Hastings_ratio) += (log(1) - log(t_up - t_low));
+ (*L_Hastings_ratio) += (- log(t_up - t_low));
+ nd_t[d -> num] = Randomize_One_Node_Time(t_low, t_up);
+ /* t_prior_min[d -> num] = t_low; */
+ /* t_prior_max[d -> num] = t_up; */
+ }
+
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Update_Times_Down_Tree(d, d -> v[i], L_Hastings_ratio, tree);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+xml_node *XML_Search_Node_Attribute_Value_Clade(char *attr_name, char *value, int skip, xml_node *node)
+{
+ xml_node *match;
+
+ //printf("\n. Node name [%s] Attr name [%s] Attr value [%s] \n", node -> name, attr_name, value);
+ if(!node)
+ {
+ PhyML_Printf("\n== node: %p attr: %p",node,node?node->attr:NULL);
+ PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+
+ match = NULL;
+ if(skip == NO && node -> attr)
+ {
+ xml_attr *attr;
+ attr = node -> attr;
+ do
+ {
+ if(!strcmp(attr -> name, attr_name) && !strcmp(attr -> value, value))
+ {
+ match = node;
+ break;
+ }
+ attr = attr->next;
+ if(!attr) break;
+ }
+ while(1);
+ }
+ if(match) return(match);
+ if(node -> next && !match)
+ {
+ match = XML_Search_Node_Attribute_Value_Clade(attr_name, value, NO, node -> next);
+ return match;
+ }
+ return NULL;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+void TIMES_Set_All_Node_Priors_S(int *result, t_tree *tree)
+{
+ int i;
+ phydbl min_prior;
+
+
+ /* Set all t_prior_max values */
+ TIMES_Set_All_Node_Priors_Bottom_Up_S(tree->n_root,tree->n_root->v[2], result, tree);
+ TIMES_Set_All_Node_Priors_Bottom_Up_S(tree->n_root,tree->n_root->v[1], result, tree);
+
+ tree->rates->t_prior_max[tree->n_root->num] =
+ MIN(tree->rates->t_prior_max[tree->n_root->num],
+ MIN(tree->rates->t_prior_max[tree->n_root->v[2]->num],
+ tree->rates->t_prior_max[tree->n_root->v[1]->num]));
+
+
+ /* Set all t_prior_min values */
+ if(!tree->rates->t_has_prior[tree->n_root->num])
+ {
+ min_prior = 1.E+10;
+ For(i,2*tree->n_otu-2)
+ {
+ if(tree->rates->t_has_prior[i])
+ {
+ if(tree->rates->t_prior_min[i] < min_prior)
+ min_prior = tree->rates->t_prior_min[i];
+ }
+ }
+ tree->rates->t_prior_min[tree->n_root->num] = 2.0 * min_prior;
+ }
+
+ if(tree->rates->t_prior_min[tree->n_root->num] > 0.0)
+ {
+ *result = FALSE;
+ }
+
+
+ TIMES_Set_All_Node_Priors_Top_Down_S(tree->n_root,tree->n_root->v[2], result, tree);
+ TIMES_Set_All_Node_Priors_Top_Down_S(tree->n_root,tree->n_root->v[1], result, tree);
+
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+void TIMES_Set_All_Node_Priors_Bottom_Up_S(t_node *a, t_node *d, int *result, t_tree *tree)
+{
+ int i;
+ phydbl t_sup;
+
+ if(d->tax) return;
+ else
+ {
+ t_node *v1, *v2; /* the two sons of d */
+
+ for(i=0;i<3;i++)
+ {
+ if((d->v[i] != a) && (d->b[i] != tree->e_root))
+ {
+ TIMES_Set_All_Node_Priors_Bottom_Up_S(d,d->v[i], result, tree);
+ }
+ }
+
+ v1 = v2 = NULL;
+ for(i=0;i<3;i++) if((d->v[i] != a) && (d->b[i] != tree->e_root))
+ {
+ if(!v1) v1 = d->v[i];
+ else v2 = d->v[i];
+ }
+
+ if(tree->rates->t_has_prior[d->num] == YES)
+ {
+ t_sup = MIN(tree->rates->t_prior_max[d->num],
+ MIN(tree->rates->t_prior_max[v1->num],
+ tree->rates->t_prior_max[v2->num]));
+
+ tree->rates->t_prior_max[d->num] = t_sup;
+
+
+ if(tree->rates->t_prior_max[d->num] < tree->rates->t_prior_min[d->num])
+ {
+
+ *result = FALSE;
+
+ }
+ }
+ else
+ {
+ tree->rates->t_prior_max[d->num] =
+ MIN(tree->rates->t_prior_max[v1->num],
+ tree->rates->t_prior_max[v2->num]);
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
+void TIMES_Set_All_Node_Priors_Top_Down_S(t_node *a, t_node *d, int *result, t_tree *tree)
+{
+ if(d->tax) return;
+ else
+ {
+ int i;
+
+ if(tree->rates->t_has_prior[d->num] == YES)
+ {
+ tree->rates->t_prior_min[d->num] = MAX(tree->rates->t_prior_min[d->num],tree->rates->t_prior_min[a->num]);
+
+
+ if(tree->rates->t_prior_max[d->num] < tree->rates->t_prior_min[d->num])
+ {
+
+ *result = FALSE;
+
+ }
+ }
+ else
+ {
+ tree->rates->t_prior_min[d->num] = tree->rates->t_prior_min[a->num];
+ }
+
+ for(i=0;i<3;i++)
+ {
+ if((d->v[i] != a) && (d->b[i] != tree->e_root))
+ {
+ TIMES_Set_All_Node_Priors_Top_Down_S(d,d->v[i], result, tree);
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl log_g_i(phydbl lmbd, phydbl t_slice_max, phydbl t_slice_min, phydbl t_prior_max, phydbl t_prior_min)
+{
+ phydbl result = 0.0;
+
+
+ if(lmbd * t_prior_min < -10.0)
+ {
+ phydbl K;
+ K = -10.0 - lmbd * t_prior_min;
+ /* printf("\n. K = [%f] \n", K); */
+ if(lmbd * t_prior_max + K > 700.0)
+ {
+ PhyML_Printf("\n. Please scale your calibration intervals. \n");
+ PhyML_Printf("\n. Cannot calculate exp(-lmbd * t_prior_max). \n");
+ PhyML_Printf("\n. Err. in file %s at line %d\n\n",__FILE__,__LINE__);
+ Warn_And_Exit("\n");
+ }
+ else
+ {
+ result = log(exp(lmbd * t_slice_max + K) - exp(lmbd * t_slice_min + K)) - log(exp(lmbd * t_prior_max + K) - exp(lmbd * t_prior_min + K));
+ }
+ }
+ else
+ {
+ result = log(exp(lmbd * t_slice_max) - exp(lmbd * t_slice_min)) - log(exp(lmbd * t_prior_max) - exp(lmbd * t_prior_min));
+ }
+ return(result);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int CombineInt(int int1, int int2)
+{
+ int mem;
+
+ mem = 500 * 2;
+
+ char cResult[mem];
+
+ sprintf(cResult, "%d%d", int1, int2);
+ return atoi(cResult);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Jump_Calibration_Move_Pre(t_node *a, t_node *d, phydbl old_ta, phydbl *log_hastings_ratio, t_tree *tree)
+{
+ int i;
+ phydbl *t_prior_min_new, *t_prior_max_new, t_low_new, t_up_new;
+ phydbl *t_prior_min_old, *t_prior_max_old, t_low_old, t_up_old;
+ phydbl *nd_t, old_t;
+ phydbl eps = DBL_MIN;
+ int move_anyway;
+
+ t_prior_min_new = tree -> rates -> t_prior_min;
+ t_prior_max_new = tree -> rates -> t_prior_max;
+
+ t_prior_min_old = tree -> rates -> t_prior_min_ori;
+ t_prior_max_old = tree -> rates -> t_prior_max_ori;
+
+ nd_t = tree -> rates -> nd_t;
+
+ t_low_new = MAX(t_prior_min_new[d -> num], nd_t[a -> num]);
+ t_up_new = t_prior_max_new[d -> num];
+
+ t_low_old = MAX(t_prior_min_old[d -> num], old_ta);
+ t_up_old = t_prior_max_old[d -> num];
+
+ old_t = nd_t[d -> num];
+
+ /* move_anyway = NO; */
+ /* if(Uni() < .5) move_anyway = YES; */
+ move_anyway = YES;
+
+
+ if(d -> tax) return;
+ else
+ {
+ if((nd_t[d -> num] > t_up_new || nd_t[d -> num] < t_low_new) || (move_anyway == YES)) /* Hastings ratio */
+ {
+ (*log_hastings_ratio) += log(t_up_new - t_low_new + eps);
+ }
+
+ if((nd_t[d -> num] > t_up_new || nd_t[d -> num] < t_low_new) || (move_anyway == YES)) /* Do the jump */
+ {
+ nd_t[d -> num] = Uni()*(t_up_new - t_low_new) + t_low_new;
+ }
+
+
+ if((nd_t[d -> num] > t_up_old || nd_t[d -> num] < t_low_old) || (move_anyway == YES)) /* Hastings ratio */
+ {
+ (*log_hastings_ratio) -= log(t_up_old - t_low_old + eps);
+ }
+
+
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Jump_Calibration_Move_Pre(d, d -> v[i], old_t, log_hastings_ratio, tree);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Multiple_Time_Proposal_Density(t_node *a, t_node *d, phydbl *time_proposal_density, t_tree *tree)
+{
+ int i;
+ phydbl *t_prior_min, *t_prior_max, *nd_t, t_low, t_up;
+
+ t_prior_min = tree -> rates -> t_prior_min;
+ t_prior_max = tree -> rates -> t_prior_max;
+ nd_t = tree -> rates -> nd_t;
+
+
+ //printf("\n. [1] Node number: [%d] \n", d -> num);
+ if(d -> tax) return;
+ else
+ {
+
+ t_low = MAX(t_prior_min[d -> num], nd_t[a -> num]);
+ t_up = t_prior_max[d -> num];
+ /* t_up = MIN(t_prior_max[d -> num], MIN(nd_t[d -> v[1] -> num], nd_t[d -> v[2] -> num])); */
+ /* printf("\n. Low [%f] Up [%f] \n", t_low, t_up); */
+
+ (*time_proposal_density) += (- log(t_up - t_low));
+
+ for(i=0;i<3;i++)
+ if((d -> v[i] != d -> anc) && (d -> b[i] != tree -> e_root))
+ Multiple_Time_Proposal_Density(d, d -> v[i], time_proposal_density, tree);
+ }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+
diff --git a/phyml/invitee.h b/phyml/invitee.h
new file mode 100644
index 0000000..afc292a
--- /dev/null
+++ b/phyml/invitee.h
@@ -0,0 +1,43 @@
+#ifndef INVITEE_H
+#define INVITEE_H
+
+#include "utilities.h"
+
+int My_Function(int argc, char **argv);
+int My_main(int argc, char **argv);
+void PhyTime_XML(char *xml_file);
+phydbl TIMES_Calib_Cond_Prob(t_tree *tree);
+int Number_Of_Comb(t_cal *calib);
+int Number_Of_Calib(t_cal *calib);
+void Check_Node_Time(t_node *a, t_node *d, int *result, t_tree *tree);
+void Set_Current_Calibration(int row, t_tree *tree);
+void Random_Calibration(t_tree *tree);
+int RND_Calibration_And_Node_Number(t_tree *tree);
+phydbl Randomize_One_Node_Time(phydbl min, phydbl max);
+void Lk_Hastings_Ratio_Times(t_node *a, t_node *d, phydbl *tot_prob, t_tree *tree);
+void Update_Descendent_Cond_Jump(t_node *a, t_node *d, phydbl *L_Hast_ratio, t_tree *tree);
+void Update_Ancestor_Cond_Jump(t_node *d, phydbl *L_Hast_ratio, t_tree *tree);
+void Update_Times_RND_Node_Ancestor_Descendant(int rnd_node, phydbl *L_Hast_ratio, t_tree *tree);
+void Update_Times_Down_Tree(t_node *a, t_node *d, phydbl *L_Hastings_ratio, t_tree *tree);
+phydbl K_Constant_Prior_Times_Log(t_tree *tree);
+int Number_Of_Comb_Slices(int m, int num_elem, int *n_slice);
+void Check_Time_Slices(t_node *a, t_node *d, int *result, phydbl *t_cur_slice_min, phydbl *t_cur_slice_max, t_tree *tree);
+void Number_Of_Nodes_In_Slice(t_node *d_start, t_node *d, int *n, phydbl *t_cur_slice_min, phydbl *t_cur_slice_max, t_tree *tree);
+void Search_Root_Node_In_Slice(t_node *d_start, t_node *d, int *root_nodes, int *num_elem, phydbl t_slice_min, phydbl t_slice_max, phydbl *t_cur_slice_min, phydbl *t_cur_slice_max, t_tree *tree);
+int Factorial(int base);
+phydbl *Norm_Constant_Prior_Times(t_tree *tree);
+void TIMES_Calib_Partial_Proba(t_tree *tree);
+xml_node *XML_Search_Node_Attribute_Value_Clade(char *attr_name, char *value, int skip, xml_node *node);
+char **XML_Read_Clade(xml_node *n_clade, t_tree *tree);
+int XML_Number_Of_Taxa_In_Clade(xml_node *n_clade);
+void TIMES_Set_All_Node_Priors_S(int *result, t_tree *tree);
+void TIMES_Set_All_Node_Priors_Bottom_Up_S(t_node *a, t_node *d, int *result, t_tree *tree);
+void TIMES_Set_All_Node_Priors_Top_Down_S(t_node *a, t_node *d, int *result, t_tree *tree);
+phydbl LOG_g_i(phydbl lmbd, phydbl t_slice_max, phydbl t_slice_min, phydbl t_prior_max, phydbl t_prior_min);
+int CombineInt(int int1, int int2);
+void Update_Current_Times_Down_Tree(t_node *a, t_node *d, t_tree *tree);
+void Multiple_Time_Proposal_Density(t_node *a, t_node *d, phydbl *time_proposal_density, t_tree *tree);
+void Jump_Calibration_Move_Pre(t_node *a, t_node *d, phydbl old_ta, phydbl *log_hastings_ratio, t_tree *tree);
+
+#endif
+
diff --git a/phyml/io.c b/phyml/io.c
new file mode 100644
index 0000000..a92d8ab
--- /dev/null
+++ b/phyml/io.c
@@ -0,0 +1,6405 @@
+/*
+
+PhyML: a program that computes maximum likelihood phylogenies from
+DNA or AA homologous sequences.
+
+Copyright (C) Stephane Guindon. Oct 2003 onward.
+
+All parts of the source except where indicated are distributed under
+the GNU public licence. See http://www.opensource.org for details.
+
+*/
+
+#include "io.h"
+#include "assert.h"
+
+#ifdef BEAGLE
+#include "libhmsbeagle/beagle.h"
+#endif
+
+
+/* Tree parser function. We need to pass a pointer to the string of characters
+ since this string might be freed and then re-allocated by that function (i.e.,
+ its address in memory might change)
+*/
+t_tree *Read_Tree(char **s_tree)
+{
+ char **subs;
+ int i,n_ext,n_int,n_otu;
+ t_tree *tree;
+ int degree,len;
+ t_node *root_node;
+
+ n_int = n_ext = 0;
+
+ n_otu=0;
+ for(i=0;i<(int)strlen((*s_tree));++i)
+ {
+ if((*s_tree)[i] == '[') do ++i; while((*s_tree)[i] != ']'); // Skip labels
+ if((*s_tree)[i] == ',') n_otu++;
+ }
+ n_otu+=1;
+
+
+
+ tree = Make_Tree_From_Scratch(n_otu,NULL);
+ subs = Sub_Trees((*s_tree),°ree);
+ Clean_Multifurcation(subs,degree,3);
+
+ if(degree == 2)
+ {
+ /* Unroot_Tree(subs); */
+ /* degree = 3; */
+ /* root_node = tree->a_nodes[n_otu]; */
+
+ root_node = tree->a_nodes[2*n_otu-2];
+ root_node->num = 2*n_otu-2;
+ tree->n_root = root_node;
+ n_int -= 1;
+ }
+ else
+ {
+ root_node = tree->a_nodes[n_otu];
+ root_node->num = n_otu;
+ tree->n_root = NULL;
+ }
+
+ if(degree > 3) /* Multifurcation at the root. Need to re-assemble the subtrees
+ since Clean_Multifurcation added sets of parenthesis and
+ the corresponding NULL edges */
+ {
+ degree = 3;
+ Free((*s_tree));
+ len = 0;
+ for(i=0;itax = 0;
+
+ tree->has_branch_lengths = 0;
+ tree->num_curr_branch_available = tree->n_otu;
+ for(i=0;in_root)
+ {
+
+ if(tree->n_root->v[1]->tax == NO && tree->n_root->v[2]->tax == NO)
+ {
+ tree->e_root = tree->a_edges[tree->num_curr_branch_available];
+ tree->n_root->b[1] = tree->a_edges[tree->num_curr_branch_available+1];
+ tree->n_root->b[2] = tree->a_edges[tree->num_curr_branch_available+2];
+ }
+ else
+ {
+ for(i=0;in_otu;++i) if(tree->a_edges[i]->left == NULL && tree->a_edges[i]->rght == NULL) break;
+ assert(i != tree->n_otu);
+ tree->e_root = tree->a_edges[i];
+
+ tree->n_root->b[1] = tree->a_edges[tree->num_curr_branch_available];
+ tree->n_root->b[2] = tree->a_edges[tree->num_curr_branch_available+1];
+ }
+
+ tree->n_root->v[2]->v[0] = tree->n_root->v[1];
+ tree->n_root->v[1]->v[0] = tree->n_root->v[2];
+
+ // Reading edge lengths
+ subs = Sub_Trees((*s_tree),°ree);
+ Read_Branch_Length(subs[0],(*s_tree),tree->n_root->b[1],tree);
+ Read_Branch_Length(subs[1],(*s_tree),tree->n_root->b[2],tree);
+ Free(subs);
+
+ Connect_One_Edge_To_Two_Nodes(tree->n_root->v[2],
+ tree->n_root->v[1],
+ tree->e_root,
+ tree);
+
+ tree->e_root->l->v = tree->n_root->b[2]->l->v + tree->n_root->b[1]->l->v;
+ if(tree->e_root->l->v > 0.0)
+ tree->n_root_pos = tree->n_root->b[2]->l->v / tree->e_root->l->v;
+ else
+ tree->n_root_pos = .5;
+
+
+ Update_Ancestors(tree->n_root,tree->n_root->v[2],tree);
+ Update_Ancestors(tree->n_root,tree->n_root->v[1],tree);
+
+ }
+
+ return tree;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+/* 'a' in t_node a stands for ancestor. 'd' stands for descendant */
+void R_rtree(char *s_tree_a, char *s_tree_d, t_node *a, t_tree *tree, int *n_int, int *n_ext)
+{
+ int i;
+ t_node *d;
+ int n_otu = tree->n_otu;
+
+
+ if(strstr(s_tree_a," "))
+ {
+ PhyML_Fprintf(stderr,"\n. [%s]",s_tree_a);
+ Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ }
+
+ // Internal edge
+ if(s_tree_d[0] == '(')
+ {
+ char **subs;
+ int degree;
+ t_edge *b;
+
+ (*n_int)+=1;
+
+ if((*n_int + n_otu) == (2*n_otu-1))
+ {
+ PhyML_Fprintf(stderr,"\n. The number of internal nodes in the tree exceeds the number of taxa minus one.");
+ PhyML_Fprintf(stderr,"\n. There probably is a formating problem in the input tree.");
+ Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ }
+
+ d = tree->a_nodes[n_otu+*n_int];
+ d->num = n_otu + *n_int;
+ d->tax = 0;
+ b = tree->a_edges[tree->num_curr_branch_available];
+
+ Read_Branch_Support(s_tree_d,s_tree_a,b,tree);
+ Read_Branch_Length(s_tree_d,s_tree_a,b,tree);
+ Read_Node_Label(s_tree_d,s_tree_a,d);
+
+ if(tree->n_root && a == tree->n_root)
+ {
+ if(!a->v[1]) a->v[1] = d;
+ else a->v[2] = d;
+ }
+ else
+ {
+ for(i=0;i<3;i++)
+ {
+ if(!a->v[i])
+ {
+ a->v[i] = d;
+ break;
+ }
+ }
+ }
+ d->v[0]=a;
+
+ if(!(tree->n_root && a == tree->n_root)) Connect_One_Edge_To_Two_Nodes(a,d,tree->a_edges[tree->num_curr_branch_available],tree);
+
+ subs=Sub_Trees(s_tree_d,°ree);
+
+
+ if(degree < 2)
+ {
+ PhyML_Fprintf(stderr,"\n. A problem was detected in the following subtree:");
+ PhyML_Fprintf(stderr,"\n. %s",s_tree_d);
+ Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+ }
+
+ if(degree > 2)
+ {
+ Clean_Multifurcation(subs,degree,2);
+
+ Free(s_tree_d);
+
+ s_tree_d = (char *)mCalloc(strlen(subs[0])+strlen(subs[1])+5,sizeof(char));
+
+ i = 0;
+ while(subs[i] != NULL) Free(subs[i++]);
+ Free(subs);
+
+ subs=Sub_Trees(s_tree_d,°ree);
+ }
+
+ R_rtree(s_tree_d,subs[0],d,tree,n_int,n_ext);
+ R_rtree(s_tree_d,subs[1],d,tree,n_int,n_ext);
+
+ i = 2;
+ while(subs[i] != NULL) Free(subs[i++]);
+ Free(subs);
+ }
+
+ // External edge
+ else
+ {
+ int i;
+
+ d = tree->a_nodes[*n_ext];
+ d->tax = 1;
+
+ Read_Node_Name(d,s_tree_d,tree->a_edges[*n_ext],tree);
+ Read_Branch_Length(s_tree_d,s_tree_a,tree->a_edges[*n_ext],tree);
+ Read_Node_Label(s_tree_d,s_tree_a,d);
+
+ if(tree->n_root && a == tree->n_root)
+ {
+ if(!a->v[1]) a->v[1] = d;
+ else a->v[2] = d;
+ }
+ else
+ {
+ for(i=0;i<3;i++)
+ {
+ if(!a->v[i])
+ {
+ a->v[i]=d;
+ break;
+ }
+ }
+ }
+ d->v[0]=a;
+
+ if(!(tree->n_root && a == tree->n_root))
+ {
+ Connect_One_Edge_To_Two_Nodes(a,d,tree->a_edges[*n_ext],tree);
+ }
+
+ d->num=*n_ext;
+ (*n_ext)+=1;
+ }
+
+ Free(s_tree_d);
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Read_Node_Name(t_node *d, char *s_tree_d, t_edge *b, t_tree *tree)
+{
+ d->name = (char *)mCalloc(strlen(s_tree_d)+1,sizeof(char ));
+ strcpy(d->name,s_tree_d);
+ d->ori_name = d->name;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Read_Branch_Support(char *s_d, char *s_a, t_edge *b, t_tree *tree)
+{
+ char *sub_tp;
+ char *p;
+
+ if(s_d[0] != '(') return; // b is an external edge -> no edge support on it
+
+ sub_tp = (char *)mCalloc(10+strlen(s_d)+1,sizeof(char));
+
+ sub_tp[0] = '(';
+ sub_tp[1] = '\0';
+ strcat(sub_tp,s_d);
+ p = strstr(s_a,sub_tp);
+
+ if(!p)
+ {
+ sub_tp[0] = ',';
+ sub_tp[1] = '\0';
+ strcat(sub_tp,s_d);
+ p = strstr(s_a,sub_tp);
+ }
+
+
+ if(p)
+ {
+ b->support_val = atof((char *)p+(int)strlen(sub_tp));
+
+ p = p + strlen(sub_tp);
+ if(p[0] == '[') { while(p[0] != ']') p++; p++; } // Skip label
+ b->support_val = atof((char *)p);
+
+ /* PhyML_Printf("\n. READ SUPPORT for s_d: %s b: %f",s_d,b->support_val); */
+
+ }
+
+ Free(sub_tp);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Read_Branch_Length(char *s_d, char *s_a, t_edge *b, t_tree *tree)
+{
+ char *sub_tp;
+ char *p;
+
+ sub_tp = (char *)mCalloc(10+strlen(s_d)+1,sizeof(char));
+
+ sub_tp[0] = '(';
+ sub_tp[1] = '\0';
+ strcat(sub_tp,s_d);
+ p = strstr(s_a,sub_tp);
+
+ if(!p)
+ {
+ sub_tp[0] = ',';
+ sub_tp[1] = '\0';
+ strcat(sub_tp,s_d);
+ p = strstr(s_a,sub_tp);
+ }
+
+
+ if(p)
+ {
+ p = p + strlen(sub_tp);
+ while(p[0] != ':' && p[0] != '\0') p++;
+ if(p[0] == ':')
+ {
+ p++;
+ b->l->v = atof((char *)p);
+ /* PhyML_Printf("\n. READ LENGTH for s_d: %s b: %f",s_d,b->l->v); */
+ tree->has_branch_lengths = YES;
+ b->does_exist = YES;
+ }
+ else
+ {
+ b->l->v = -1.;
+ }
+ }
+ else
+ {
+ b->l->v = -1.;
+ }
+
+ Free(sub_tp);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Read_Node_Label(char *s_d, char *s_a, t_node *n)
+{
+ char *sub_tp,*s_lab;
+ char *p;
+
+ sub_tp = (char *)mCalloc(3+(int)strlen(s_d)+1,sizeof(char));
+ s_lab = (char *)mCalloc(strlen(s_a)+1,sizeof(char));
+
+
+ sub_tp[0] = '(';
+ sub_tp[1] = '\0';
+ strcat(sub_tp,s_d);
+ strcat(sub_tp,"[\0");
+ p = strstr(s_a,sub_tp);
+
+ if(!p)
+ {
+ sub_tp[0] = ',';
+ sub_tp[1] = '\0';
+ strcat(sub_tp,s_d);
+ strcat(sub_tp,"[\0");
+ p = strstr(s_a,sub_tp);
+ }
+
+ if(p)
+ {
+ p = p+strlen(sub_tp)-1;
+ assert(p[0]=='[');
+
+ s_lab[0]='[';
+ if(sscanf(p,"[%[^]]]",s_lab+1) != 1)
+ {
+ PhyML_Fprintf(stderr,"\n. Label is in wrong format. A proper label should");
+ PhyML_Fprintf(stderr,"\n. look as follows: \"[xxx={yyy},xxxx={yy},...]\"");
+ assert(FALSE);
+ }
+
+ s_lab[strlen(s_lab)]=']';
+ s_lab[strlen(s_lab)]='\0';
+
+ /* PhyML_Printf("\n. READ LABEL for s_d: %s b: %s",s_d,s_lab); */
+
+ n->label = Read_Labels(s_lab);
+ }
+
+ Free(sub_tp);
+ Free(s_lab);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Clean_Multifurcation(char **subtrees, int current_deg, int end_deg)
+{
+
+ if(current_deg <= end_deg) return;
+ else
+ {
+ char *s_tmp;
+ int i;
+
+ /* s_tmp = (char *)mCalloc(T_MAX_LINE,sizeof(char)); */
+ s_tmp = (char *)mCalloc(10+
+ (int)strlen(subtrees[0])+1+
+ (int)strlen(subtrees[1])+1,
+ sizeof(char));
+
+ strcat(s_tmp,"(\0");
+ strcat(s_tmp,subtrees[0]);
+ strcat(s_tmp,",\0");
+ strcat(s_tmp,subtrees[1]);
+ strcat(s_tmp,")#NULL\0"); /* Add the label 'NULL' to identify a non-existing edge */
+ Free(subtrees[0]);
+ subtrees[0] = s_tmp;
+
+ for(i=1;in_otu;++i) PhyML_Fprintf(fp,"\t%3d\t%s,\n",i+1,tree->a_nodes[i]->name);
+ PhyML_Fprintf(fp,"\tUTREE PAUP_1=\n");
+ PhyML_Fprintf(fp,"%s\n",s_tree);
+ PhyML_Fprintf(fp,"ENDBLOCK;");
+ }
+ Free(s_tree);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+char *Write_Tree(t_tree *tree)
+{
+ char *s;
+ int i,available;
+
+#ifndef MPI
+ int init_len;
+ init_len = 3*(int)T_MAX_NAME;
+ s=(char *)mCalloc(init_len,sizeof(char));
+ available = init_len;
+#elif defined MPI
+ s=(char *)mCalloc(T_MAX_LINE,sizeof(char));
+#endif
+
+ i = -1;
+ s[0]='(';
+
+ if(tree->n_root == NULL)
+ {
+ i = 0;
+ while((!tree->a_nodes[tree->n_otu+i]->v[0]) ||
+ (!tree->a_nodes[tree->n_otu+i]->v[1]) ||
+ (!tree->a_nodes[tree->n_otu+i]->v[2])) i++;
+
+ R_wtree(tree->a_nodes[tree->n_otu+i],tree->a_nodes[tree->n_otu+i]->v[0],tree->a_nodes[tree->n_otu+i]->b[0],&available,&s,tree);
+ R_wtree(tree->a_nodes[tree->n_otu+i],tree->a_nodes[tree->n_otu+i]->v[1],tree->a_nodes[tree->n_otu+i]->b[1],&available,&s,tree);
+ R_wtree(tree->a_nodes[tree->n_otu+i],tree->a_nodes[tree->n_otu+i]->v[2],tree->a_nodes[tree->n_otu+i]->b[2],&available,&s,tree);
+ }
+ else
+ {
+ R_wtree(tree->n_root,tree->n_root->v[1],tree->n_root->b[1],&available,&s,tree);
+ R_wtree(tree->n_root,tree->n_root->v[2],tree->n_root->b[2],&available,&s,tree);
+ }
+
+ s[(int)strlen(s)-1]=')';
+
+ if(tree->n_root != NULL) Print_Labels(NULL,s+(int)strlen(s),tree->n_root->label);
+
+ if(tree->io && tree->io->print_node_num == YES)
+ {
+ if(!tree->n_root)
+ sprintf(s+(int)strlen(s),"%d",tree->a_nodes[tree->n_otu+i]->num);
+ else
+ sprintf(s+(int)strlen(s),"%d",tree->n_root->num);
+ }
+ s[(int)strlen(s)]=';';
+
+ return s;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void R_wtree(t_node *pere, t_node *fils, t_edge *b, int *available, char **s_tree, t_tree *tree)
+{
+ int i,p;
+ char *format;
+ int last_len;
+ phydbl mean_len;
+
+ format = (char *)mCalloc(100,sizeof(char));
+
+ sprintf(format,"%%.%df",tree->bl_ndigits);
+
+ p = -1;
+ if(fils->tax == YES) // Tip node
+ {
+ last_len = (int)strlen(*s_tree);
+
+ if(OUTPUT_TREE_FORMAT == NEWICK)
+ {
+ if(tree->write_tax_names == YES)
+ {
+ if(tree->io && tree->io->long_tax_names)
+ {
+ strcat(*s_tree,tree->io->long_tax_names[fils->num]);
+ }
+ else
+ {
+ if(fils->name && strlen(fils->name) > 0)
+ strcat(*s_tree,fils->name);
+ else
+ sprintf(*s_tree+(int)strlen(*s_tree),"%d",fils->num+1);
+ }
+ }
+ else if(tree->write_tax_names == NO)
+ {
+ sprintf(*s_tree+(int)strlen(*s_tree),"%d",fils->num+1);
+ }
+ }
+ else if(OUTPUT_TREE_FORMAT == NEXUS)
+ {
+ sprintf(*s_tree+(int)strlen(*s_tree),"%d",fils->num+1);
+ }
+ else
+ {
+ PhyML_Printf("\n. Unknown tree format.");
+ PhyML_Printf("\n. Err. in file %s at line %d\n",__FILE__,__LINE__);
+ PhyML_Printf("\n. s=%s\n",*s_tree);
+ }
+
+ if((fils->b) && (fils->b[0]) && (tree->write_br_lens == YES))
+ {
+ Print_Labels(NULL,*s_tree+(int)strlen(*s_tree),fils->label);
+
+ (*s_tree)[(int)strlen(*s_tree)] = ':';
+
+ Print_Labels(NULL,*s_tree+(int)strlen(*s_tree),b->label);
+
+ if(tree->is_mixt_tree == NO) mean_len = b->l->v;
+ else mean_len = MIXT_Get_Mean_Edge_Len(b,tree);
+ sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len));
+ }
+
+ (*s_tree)[(int)strlen(*s_tree)] = ',';
+
+
+#ifndef MPI
+ (*available) -= ((int)strlen(*s_tree) - last_len);
+
+ /* printf("\n0 Available = %d [%d %d]",(*available),(int)strlen(*s_tree),last_len); */
+ /* printf("\n0 %s [%d,%d]",*s_tree,(int)(int)strlen(*s_tree),*available); */
+
+ if(*available < 0)
+ {
+ PhyML_Fprintf(stderr,"\n. s=%s\n",*s_tree);
+ PhyML_Fprintf(stderr,"\n. len=%d\n",(int)strlen(*s_tree));
+ PhyML_Fprintf(stderr,"\n. The sequence names in your input file might be too long.");
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Warn_And_Exit("");
+ }
+
+ if(*available < (int)T_MAX_NAME)
+ {
+ (*s_tree) = (char *)mRealloc(*s_tree,(int)strlen(*s_tree)+3*(int)T_MAX_NAME,sizeof(char));
+ for(i=0;i<3*(int)T_MAX_NAME;++i) (*s_tree)[(int)strlen(*s_tree)+i] = '\0';
+ (*available) = 3*(int)T_MAX_NAME;
+ }
+#endif
+
+ }
+ else // Internal node
+ {
+ (*s_tree)[(int)strlen(*s_tree)]='(';
+
+#ifndef MPI
+ (*available) -= 1;
+
+
+ if(*available < (int)T_MAX_NAME)
+ {
+ (*s_tree) = (char *)mRealloc(*s_tree,(int)strlen(*s_tree)+3*(int)T_MAX_NAME,sizeof(char));
+ for(i=0;i<3*(int)T_MAX_NAME;++i) (*s_tree)[(int)strlen(*s_tree)+i] = '\0';
+ (*available) = 3*(int)T_MAX_NAME;
+ }
+#endif
+
+
+ for(i=0;i<3;i++)
+ {
+ if((fils->v[i] != pere) && (fils->b[i] != tree->e_root))
+ R_wtree(fils,fils->v[i],fils->b[i],available,s_tree,tree);
+ else p=i;
+ }
+
+ if(p < 0)
+ {
+ PhyML_Fprintf(stderr,"\n. pere: %d fils=%d root=%d root->v[2]=%d root->v[1]=%d",pere->num,fils->num,tree->n_root->num,tree->n_root->v[2]->num,tree->n_root->v[1]->num);
+ PhyML_Fprintf(stderr,"\n. fils=%d root=%d root->v[2]=%d root->v[1]=%d",fils->num,tree->n_root->num,tree->n_root->v[2]->num,tree->n_root->v[1]->num);
+ PhyML_Fprintf(stderr,"\n. tree->e_root=%d fils->b[0]=%d fils->b[1]=%d fils->b[2]=%d",tree->e_root->num,fils->b[0]->num,fils->b[1]->num,fils->b[2]->num);
+ assert(false);
+ }
+
+ last_len = (int)strlen(*s_tree);
+
+ (*s_tree)[last_len-1] = ')';
+
+
+ if((fils->b) && (tree->write_br_lens == YES))
+ {
+ Print_Labels(NULL,*s_tree+(int)strlen(*s_tree),fils->label);
+
+ if(tree->io && tree->io->print_support_val == YES)
+ {
+ if(tree->io->do_boot == YES)
+ {
+ sprintf(*s_tree+(int)strlen(*s_tree),"%.0f",fils->b[p]->support_val);
+ }
+ else
+ {
+ sprintf(*s_tree+(int)strlen(*s_tree),"%f",fils->b[p]->support_val);
+ }
+ }
+ if(tree->io && tree->io->print_node_num == YES)
+ {
+ sprintf(*s_tree+(int)strlen(*s_tree),"%d",fils->num);
+ }
+
+
+ fflush(NULL);
+
+ (*s_tree)[(int)strlen(*s_tree)] = ':';
+
+ Print_Labels(NULL,*s_tree+(int)strlen(*s_tree),b->label);
+
+ if(tree->is_mixt_tree == NO) mean_len = b->l->v;
+ else mean_len = MIXT_Get_Mean_Edge_Len(b,tree);
+ sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len));
+ }
+
+ (*s_tree)[(int)strlen(*s_tree)] = ',';
+
+#ifndef MPI
+ (*available) -= ((int)strlen(*s_tree) - last_len);
+
+
+ if(*available < 0)
+ {
+ PhyML_Fprintf(stderr,"\n. available = %d",*available);
+ PhyML_Fprintf(stderr,"\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+ Warn_And_Exit("");
+ }
+
+ if(*available < (int)T_MAX_NAME)
+ {
+ (*s_tree) = (char *)mRealloc(*s_tree,(int)strlen(*s_tree)+3*(int)T_MAX_NAME,sizeof(char));
+ for(i=0;i<3*(int)T_MAX_NAME;++i) (*s_tree)[(int)strlen(*s_tree)+i] = '\0';
+ (*available) = 3*(int)T_MAX_NAME;
+ }
+#endif
+
+ }
+
+ Free(format);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Detect_Align_File_Format(option *io)
+{
+ int c;
+ fpos_t curr_pos;
+
+ fgetpos(io->fp_in_align,&curr_pos);
+
+ errno = 0;
+
+ while((c=fgetc(io->fp_in_align)) != EOF)
+ {
+ if(errno) io->data_file_format = PHYLIP;
+ else if(c == '#')
+ {
+ char s[10],t[6]="NEXUS";
+ if(!fgets(s,6,io->fp_in_align))
+ {
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Exit("\n");
+ }
+ if(!strcmp(t,s))
+ {
+ fsetpos(io->fp_in_align,&curr_pos);
+ io->data_file_format = NEXUS;
+ return;
+ }
+ }
+ }
+ fsetpos(io->fp_in_align,&curr_pos);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Detect_Tree_File_Format(option *io)
+{
+ int c;
+ fpos_t curr_pos;
+
+ fgetpos(io->fp_in_tree,&curr_pos);
+
+ errno = 0;
+
+ while((c=fgetc(io->fp_in_tree)) != EOF)
+ {
+ if(errno)
+ {
+ io->tree_file_format = PHYLIP;
+ PhyML_Printf("\n. Detected PHYLIP tree file format.");
+ }
+ else if(c == '#')
+ {
+ char s[10],t[6]="NEXUS";
+ if(!fgets(s,6,io->fp_in_tree))
+ {
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d\n",__FILE__,__LINE__);
+ Warn_And_Exit("");
+ }
+ if(!strcmp(t,s))
+ {
+ fsetpos(io->fp_in_tree,&curr_pos);
+ io->tree_file_format = NEXUS;
+ PhyML_Printf("\n. Detected NEXUS tree file format.");
+ return;
+ }
+ }
+ }
+
+ fsetpos(io->fp_in_tree,&curr_pos);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+align **Get_Seq(option *io)
+{
+ io->data = NULL;
+
+ if(!io->fp_in_align)
+ {
+ PhyML_Fprintf(stderr,"\n. Filehandle to '%s' seems to be closed.",io->in_align_file);
+ Exit("\n");
+ }
+
+ Detect_Align_File_Format(io);
+
+ switch(io->data_file_format)
+ {
+ case PHYLIP:
+ {
+ io->data = Get_Seq_Phylip(io);
+ break;
+ }
+ case NEXUS:
+ {
+ io->nex_com_list = Make_Nexus_Com();
+ Init_Nexus_Format(io->nex_com_list);
+ Get_Nexus_Data(io->fp_in_align,io);
+ Free_Nexus(io);
+ break;
+ }
+ default:
+ {
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d (function '%s')\n",__FILE__,__LINE__,__FUNCTION__);
+ Exit("\n");
+ break;
+ }
+ }
+
+ if(!io->data)
+ {
+ PhyML_Fprintf(stderr,"\n. Err. in file %s at line %d (function '%s')\n",__FILE__,__LINE__,__FUNCTION__);
+ Exit("\n");
+ }
+ else
+ {
+ Post_Process_Data(io);
+ }
+
+ if(io->n_otu < 3)
+ {
+ PhyML_Fprintf(stderr,"\n. PhyML needs at least three sequences to perform an analysis.");
+ assert(FALSE);
+ }
+
+ return io->data;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void Post_Process_Data(option *io)
+{
+ int i,j,swap;
+ align *data_buff;
+
+ for(i=0;idata[0]->len;++i)
+ {
+ for(j=0;jn_otu;++j)
+ {
+ if((io->data[j]->state[i] == '*') || (io->data[j]->state[i] == '?') || (io->data[j]->state[i] == '-')) io->data[j]->state[i] = 'X';
+ if((io->datatype == NT) && (io->data[j]->state[i] == 'N')) io->data[j]->state[i] = 'X';
+ if(io->data[j]->state[i] == 'U') io->data[j]->state[i] = 'T';
+ }
+ }
+
+ for(i=0;i