[med-svn] [phyml] 01/08: Imported Upstream version 3.2.0+dfsg

Kevin Murray daube-guest at moszumanska.debian.org
Sat Feb 6 16:53:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

daube-guest pushed a commit to branch master
in repository phyml.

commit 9f4c57b0d21dec7e1e3316c165dcbfbd267fb14a
Author: Kevin Murray <spam at kdmurray.id.au>
Date:   Sat Feb 6 16:05:29 2016 +0100

    Imported Upstream version 3.2.0+dfsg
---
 .gitignore                   |   29 +
 LICENSE                      |  339 +++
 README                       |   16 +-
 README.md                    |    6 +
 autogen.sh                   |    2 +
 config.h.in                  |   12 +-
 configure.ac                 |   29 +-
 confmc                       |    9 +
 confr                        |    9 +
 confrf                       |    9 +
 doc/example.html             | 1331 ----------
 doc/example.text             | 2812 ---------------------
 doc/naturemag.bst            | 3049 ++++++++++++-----------
 doc/phyml-manual.pdf         |  Bin 392421 -> 407931 bytes
 doc/phyml-manual.tex         |   21 +-
 doc/ref.bib                  | 5534 +++++++++++++++++++++++++++++++++++++++++-
 examples/X1.mat              |   21 -
 src/Makefile.am              |   29 +-
 src/Makefile_mc.am           |   39 +
 src/Makefile_r.am            |   86 +
 src/alrt.c                   |    2 +-
 src/bionj.c                  |   14 +-
 src/bionj.h                  |    2 +-
 src/cl.c                     |   95 +-
 src/cl.h                     |    2 +-
 src/free.c                   |   72 +-
 src/free.h                   |    2 +
 src/geo.c                    |    1 -
 src/help.c                   |    5 +-
 src/init.c                   |  362 ++-
 src/init.h                   |    8 +-
 src/interface.c              |    6 +-
 src/{sergeii.c => invitee.c} |    4 +-
 src/{sergeii.h => invitee.h} |    4 +-
 src/io.c                     |  590 +++--
 src/io.h                     |    2 +-
 src/lk.c                     |  507 ++--
 src/main.c                   |   58 +-
 src/make.c                   |  159 +-
 src/make.h                   |    9 +-
 src/mcmc.c                   | 4640 +++++++++++++++++++++++------------
 src/mcmc.h                   |   47 +-
 src/mg.c                     |    2 +-
 src/migrep.c                 | 1819 --------------
 src/migrep.h                 |   59 -
 src/mixt.c                   |   23 +-
 src/models.c                 |  106 +-
 src/mpi_boot.c               |    4 +-
 src/mxml.h                   |  329 +++
 src/nexus.c                  |   17 +-
 src/optimiz.c                | 1163 ++++-----
 src/phyrex.c                 | 4173 +++++++++++++++++++++++++++++++
 src/phyrex.h                 |  113 +
 src/rates.c                  |    4 +-
 src/simu.c                   |   42 +-
 src/spr.c                    |   12 +-
 src/stats.c                  |  980 +++++++-
 src/stats.h                  |   25 +
 src/times.c                  |   23 +-
 src/utilities.c              |  921 ++++---
 src/utilities.h              |  167 +-
 src/xml.c                    |   10 +-
 version                      |    1 +
 63 files changed, 18837 insertions(+), 11129 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..edf6645
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,29 @@
+# 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
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d7f1051
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,339 @@
+GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    {description}
+    Copyright (C) {year}  {fullname}
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  {signature of Ty Coon}, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/README b/README
index ecb5419..ee27cf1 100644
--- a/README
+++ b/README
@@ -1,3 +1,8 @@
+
+//////////////////////////////////////////////////////////////////////////
+// You have downloaded the Stable or the Development version of PhyML   //
+//////////////////////////////////////////////////////////////////////////
+
 To install PhyML, type the following commands:
 ./configure;
 make;
@@ -15,4 +20,13 @@ make;
 To compile a Windows executable, install MinGW and run:
 ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes mingw64-configure;
 make;
-
+
+
+//////////////////////////////////////////////////////////////////////////
+//                    You have cloned PhyML from GitHub                 //
+//////////////////////////////////////////////////////////////////////////
+
+To install PhyML, type the following command:
+sh ./autogen.sh;
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4eae14e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+phyml
+=====
+
+PhyML -- Phylogenetic estimation using (Maximum) Likelihood
+
+PhyML is a software that estimates maximum likelihood phylogenies from alignments of nucleotide or amino acid sequences. The main strength of PhyML lies in the large number of substitution models coupled to various options to search the space of phylogenetic tree topologies, going from very fast and efficient methods to slower but generally more accurate approaches. PhyML was designed to process moderate to large data sets. In theory, alignments with up to 4,000 sequences 2,000,000 chara [...]
diff --git a/autogen.sh b/autogen.sh
new file mode 100644
index 0000000..3064bae
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+autoreconf --force --install -v
diff --git a/config.h.in b/config.h.in
index af0fe70..ebe7993 100644
--- a/config.h.in
+++ b/config.h.in
@@ -83,6 +83,9 @@
 /* Define to 1 if you have the `vprintf' function. */
 #undef HAVE_VPRINTF
 
+/* INVITEE tag on */
+#undef INVITEE
+
 /* Define to the sub-directory in which libtool stores uninstalled libraries.
    */
 #undef LT_OBJDIR
@@ -90,9 +93,6 @@
 /* m4 tag on */
 #undef M4
 
-/* MIGREP tag on */
-#undef MIGREP
-
 /* MPI tag on */
 #undef MPI
 
@@ -126,6 +126,9 @@
 /* PHYML tag on */
 #undef PHYML
 
+/* PHYREX tag on */
+#undef PHYREX
+
 /* PHYTIME tag on */
 #undef PHYTIME
 
@@ -135,9 +138,6 @@
 /* RWRAP tag on */
 #undef RWRAP
 
-/* SERGEII tag on */
-#undef SERGEII
-
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
diff --git a/configure.ac b/configure.ac
index 1a9ad8a..b5d1d7d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -160,10 +160,10 @@ if test "$evolve" = yes; then
    AC_DEFINE([EVOLVE],[1],[EVOLVE tag on])
 fi
 
-AC_ARG_ENABLE([sergeii],[AS_HELP_STRING([--enable-sergeii],[Compile sergeii])],[sergeii=yes],[sergeii=no])
-AM_CONDITIONAL([WANT_SERGEII], [test "$sergeii" = yes])
-if test "$sergeii" = yes; then
-   AC_DEFINE([SERGEII],[1],[SERGEII tag on])
+AC_ARG_ENABLE([invitee],[AS_HELP_STRING([--enable-invitee],[Compile invitee])],[invitee=yes],[invitee=no])
+AM_CONDITIONAL([WANT_INVITEE], [test "$invitee" = yes])
+if test "$invitee" = yes; then
+   AC_DEFINE([INVITEE],[1],[INVITEE tag on])
 fi
 
 AC_ARG_ENABLE([geo],[AS_HELP_STRING([--enable-geo],[Compile geo])],[geo=yes],[geo=no])
@@ -179,17 +179,14 @@ if test "$checkpoint" = yes; then
 fi
 
 
-AC_ARG_ENABLE([migrep],[AS_HELP_STRING([--enable-migrep],[Compile migrep])],[migrep=yes],[migrep=no])
-AM_CONDITIONAL([WANT_MIGREP], [test "$migrep" = yes])
-if test "$migrep" = yes; then
-   AC_DEFINE([MIGREP],[1],[MIGREP tag on])
+AC_ARG_ENABLE([phyrex],[AS_HELP_STRING([--enable-phyrex],[Compile phyrex])],[phyrex=yes],[phyrex=no])
+AM_CONDITIONAL([WANT_PHYREX], [test "$phyrex" = yes])
+if test "$phyrex" = yes; then
+   AC_DEFINE([PHYREX],[1],[PHYREX tag on])
 fi
-dnl AS_IF([test "x$enable_migrep" = "xyes"],
-dnl       [CFLAGS="-I/usr/include/cairo ${ARCH_flag}"],
-dnl       [CFLAGS="-Wall -O2 ${MSSE} -fomit-frame-pointer -funroll-loops ${ARCH_flag}"])
-AS_IF([test "x$enable_migrep" = "xyes"],[PKG_CHECK_MODULES([GTK], [gtk+-3.0])])
-AS_IF([test "x$enable_migrep" = "xyes"],[PKG_CHECK_MODULES([CAIRO], [cairo])])
-AS_IF([test "x$enable_migrep" = "xyes"],[CFLAGS="${CFLAGS} `pkg-config --cflags --libs gtk+-3.0` ${ARCH_flag}"])
+dnl AS_IF([test "x$enable_phyrex" = "xyes"],[PKG_CHECK_MODULES([GTK], [gtk+-3.0])])
+dnl AS_IF([test "x$enable_phyrex" = "xyes"],[PKG_CHECK_MODULES([CAIRO], [cairo])])
+dnl AS_IF([test "x$enable_phyrex" = "xyes"],[CFLAGS="${CFLAGS} `pkg-config --cflags --libs gtk+-3.0` ${ARCH_flag}"])
 
 
 dnl AM_PATH_GTK_3_0(,,AC_MSG_ERROR(windoe-default needs GTK+-3))
@@ -201,11 +198,11 @@ if test "$rwrap" = no; then
 if test "$phycont" = no; then
 if test "$m4" = no; then
 if test "$test" = no; then
-if test "$sergeii" = no; then
+if test "$invitee" = no; then
 if test "$geo" = no; then
 if test "$evolve" = no; then
 if test "$checkpoint" = no; then
-if test "$migrep" = no; then
+if test "$phyrex" = no; then
    AC_DEFINE([PHYML],[1],[PHYML tag on])
 fi
 fi
diff --git a/confmc b/confmc
new file mode 100755
index 0000000..dc5bce5
--- /dev/null
+++ b/confmc
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+
+aclocal;
+autoheader;
+autoconf -f;
+automake -f --add-missing;
+./configure --enable-phytime;
+make clean;
+make;
diff --git a/confr b/confr
new file mode 100755
index 0000000..7dd91ac
--- /dev/null
+++ b/confr
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+
+aclocal;
+autoheader;
+autoconf -f;
+automake -f --add-missing;
+./configure --enable-rwrap;
+make clean;
+make;
diff --git a/confrf b/confrf
new file mode 100755
index 0000000..e46808b
--- /dev/null
+++ b/confrf
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+
+aclocal;
+autoheader;
+autoconf -f;
+automake -f --add-missing;
+./configure --enable-rf;
+make clean;
+make;
diff --git a/doc/example.html b/doc/example.html
deleted file mode 100644
index 8dcb7d9..0000000
--- a/doc/example.html
+++ /dev/null
@@ -1,1331 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-  <meta http-equiv="Content-Style-Type" content="text/css" />
-  <meta name="generator" content="pandoc" />
-  <title></title>
-  <style type="text/css">code{white-space: pre;}</style>
-  <link rel="stylesheet" href="/home/guindon/Downloads/pandoc.css" type="text/css" />
-  <script type="text/javascript">/*<![CDATA[*/
-  /* 
-  March 19, 2004 MathHTML (c) Peter Jipsen http://www.chapman.edu/~jipsen
-  Released under the GNU General Public License version 2 or later.
-  See the GNU General Public License (at http://www.gnu.org/copyleft/gpl.html)
-  for more details.
-  */
-  
-  function convertMath(node) {// for Gecko
-    if (node.nodeType==1) {
-      var newnode = 
-        document.createElementNS("http://www.w3.org/1998/Math/MathML",
-          node.nodeName.toLowerCase());
-      for(var i=0; i < node.attributes.length; i++)
-        newnode.setAttribute(node.attributes[i].nodeName,
-          node.attributes[i].nodeValue);
-      for (var i=0; i<node.childNodes.length; i++) {
-        var st = node.childNodes[i].nodeValue;
-        if (st==null || st.slice(0,1)!=" " && st.slice(0,1)!="\n") 
-          newnode.appendChild(convertMath(node.childNodes[i]));
-      }
-      return newnode;
-    }
-    else return node;
-  }
-  
-  function convert() {
-    var mmlnode = document.getElementsByTagName("math");
-    var st,str,node,newnode;
-    for (var i=0; i<mmlnode.length; i++)
-      if (document.createElementNS!=null)
-        mmlnode[i].parentNode.replaceChild(convertMath(mmlnode[i]),mmlnode[i]);
-      else { // convert for IE
-        str = "";
-        node = mmlnode[i];
-        while (node.nodeName!="/MATH") {
-          st = node.nodeName.toLowerCase();
-          if (st=="#text") str += node.nodeValue;
-          else {
-            str += (st.slice(0,1)=="/" ? "</m:"+st.slice(1) : "<m:"+st);
-            if (st.slice(0,1)!="/") 
-               for(var j=0; j < node.attributes.length; j++)
-                 if (node.attributes[j].nodeValue!="italic" &&
-                   node.attributes[j].nodeValue!="" &&
-                   node.attributes[j].nodeValue!="inherit" &&
-                   node.attributes[j].nodeValue!=undefined)
-                   str += " "+node.attributes[j].nodeName+"="+
-                       "\""+node.attributes[j].nodeValue+"\"";
-            str += ">";
-          }
-          node = node.nextSibling;
-          node.parentNode.removeChild(node.previousSibling);
-        }
-        str += "</m:math>";
-        newnode = document.createElement("span");
-        node.parentNode.replaceChild(newnode,node);
-        newnode.innerHTML = str;
-      }
-  }
-  
-  if (document.createElementNS==null) {
-    document.write("<object id=\"mathplayer\"\
-    classid=\"clsid:32F66A20-7614-11D4-BD11-00104BD3F987\"></object>");
-    document.write("<?import namespace=\"m\" implementation=\"#mathplayer\"?>");
-  }
-  if(typeof window.addEventListener != 'undefined'){
-    window.addEventListener('load', convert, false);
-  }
-  if(typeof window.attachEvent != 'undefined') {
-    window.attachEvent('onload', convert);
-  }
-  /*]]>*/
-  </script>
-</head>
-<body>
-<div id="TOC">
-<ul>
-<li><a href="#availability"><span class="toc-section-number">1</span> Availability</a></li>
-<li><a href="#authors"><span class="toc-section-number">2</span> Authors</a></li>
-<li><a href="#overview"><span class="toc-section-number">3</span> Overview</a></li>
-<li><a href="#bug-report"><span class="toc-section-number">4</span> Bug report</a></li>
-<li><a href="#installing-phyml"><span class="toc-section-number">5</span> Installing PhyML</a><ul>
-<li><a href="#sources-and-compilation"><span class="toc-section-number">5.1</span> Sources and compilation</a></li>
-<li><a href="#installing-phyml-on-unix-like-systems-including-mac-os"><span class="toc-section-number">5.2</span> Installing PhyML on UNIX-like systems (including Mac OS)</a></li>
-<li><a href="#sec:install-windows"><span class="toc-section-number">5.3</span> Installing PhyML on Microsoft Windows</a></li>
-<li><a href="#sec:MPI"><span class="toc-section-number">5.4</span> Installing the parallel version of PhyML</a></li>
-<li><a href="#sec:install-phyml-beagle"><span class="toc-section-number">5.5</span> Installing PhyML-BEAGLE</a></li>
-</ul></li>
-<li><a href="#sec:phyml_new"><span class="toc-section-number">6</span> Program usage.</a><ul>
-<li><a href="#phylip-like-interface"><span class="toc-section-number">6.1</span> PHYLIP-like interface</a><ul>
-<li><a href="#input-data-sub-menu"><span class="toc-section-number">6.1.1</span> Input Data sub-menu</a></li>
-<li><a href="#sec:submenus"><span class="toc-section-number">6.1.2</span> Substitution model sub-menu</a></li>
-<li><a href="#tree-searching-sub-menu"><span class="toc-section-number">6.1.3</span> Tree searching sub-menu</a></li>
-<li><a href="#branch-support-sub-menu"><span class="toc-section-number">6.1.4</span> Branch support sub-menu</a></li>
-</ul></li>
-<li><a href="#command-line-interface"><span class="toc-section-number">6.2</span> Command-line interface</a></li>
-<li><a href="#xml-interface"><span class="toc-section-number">6.3</span> XML interface</a></li>
-<li><a href="#sec:parallel_bootstrap"><span class="toc-section-number">6.4</span> Parallel bootstrap</a></li>
-</ul></li>
-<li><a href="#sec:input_output"><span class="toc-section-number">7</span> Inputs & outputs for command-line and PHYLIP interface </a><ul>
-<li><a href="#sequence-formats"><span class="toc-section-number">7.1</span> Sequence formats</a><ul>
-<li><a href="#gaps-and-ambiguous-characters"><span class="toc-section-number">7.1.1</span> Gaps and ambiguous characters</a></li>
-<li><a href="#sec:outgroupspecify"><span class="toc-section-number">7.1.2</span> Specifying outgroup sequences</a></li>
-</ul></li>
-<li><a href="#tree-format"><span class="toc-section-number">7.2</span> Tree format</a></li>
-<li><a href="#multiple-alignments-and-trees"><span class="toc-section-number">7.3</span> Multiple alignments and trees</a></li>
-<li><a href="#sec:customaa"><span class="toc-section-number">7.4</span> Custom amino-acid rate model</a></li>
-<li><a href="#sec:topoconstraints"><span class="toc-section-number">7.5</span> Topological constraint file</a></li>
-<li><a href="#output-files"><span class="toc-section-number">7.6</span> Output files</a></li>
-<li><a href="#treatment-of-invariable-sites-with-fixed-branch-lengths"><span class="toc-section-number">7.7</span> Treatment of invariable sites with fixed branch lengths</a></li>
-</ul></li>
-<li><a href="#sec:xmlio"><span class="toc-section-number">8</span> Inputs & outputs for the XML interface </a><ul>
-<li><a href="#mixture-models-in-phyml"><span class="toc-section-number">8.1</span> Mixture models in PhyML</a></li>
-<li><a href="#partitions"><span class="toc-section-number">8.2</span> Partitions</a></li>
-<li><a href="#combining-mixture-and-partitions-in-phyml-the-theory"><span class="toc-section-number">8.3</span> Combining mixture and partitions in PhyML: the theory</a></li>
-<li><a href="#sec:XML format"><span class="toc-section-number">8.4</span> The XML format and its use in PhyML</a></li>
-<li><a href="#setting-up-mixture-and-partition-models-in-phyml-the-basics"><span class="toc-section-number">8.5</span> Setting up mixture and partition models in PhyML: the basics</a></li>
-<li><a href="#xml-options"><span class="toc-section-number">8.6</span> XML options</a><ul>
-<li><a href="#phyml-component"><span class="toc-section-number">8.6.1</span> <span>phyml</span> component</a></li>
-<li><a href="#topology-component"><span class="toc-section-number">8.6.2</span> <span>topology</span> component</a></li>
-<li><a href="#ratematrices-component"><span class="toc-section-number">8.6.3</span> <span>ratematrices</span> component</a></li>
-<li><a href="#equfreqs-component"><span class="toc-section-number">8.6.4</span> <span>equfreqs</span> component</a></li>
-<li><a href="#branchlengths-component"><span class="toc-section-number">8.6.5</span> <span>branchlengths</span> component</a></li>
-<li><a href="#siterates-component"><span class="toc-section-number">8.6.6</span> <span>siterates</span> component</a></li>
-<li><a href="#partitionelem-and-mixtureelem-components"><span class="toc-section-number">8.6.7</span> <span>partitionelem</span> and <span>mixtureelem</span> components</a></li>
-</ul></li>
-<li><a href="#a-simple-example-gtr-gamma4-i"><span class="toc-section-number">8.7</span> A simple example: GTR + <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo></mrow></math>4 + I</a></li>
-<li><a href="#a-second-example-lg4x"><span class="toc-section-number">8.8</span> A second example: LG4X</a></li>
-<li><a href="#an-example-with-multiple-partition-elements"><span class="toc-section-number">8.9</span> An example with multiple partition elements</a></li>
-<li><a href="#branch-lengths-with-invariants-and-partionned-data"><span class="toc-section-number">8.10</span> Branch lengths with invariants and partionned data</a></li>
-</ul></li>
-<li><a href="#citing-phyml"><span class="toc-section-number">9</span> Citing PhyML</a></li>
-<li><a href="#other-programs-in-the-phyml-package"><span class="toc-section-number">10</span> Other programs in the PhyML package</a><ul>
-<li><a href="#phytime"><span class="toc-section-number">10.1</span> PhyTime</a><ul>
-<li><a href="#installing-phytime"><span class="toc-section-number">10.1.1</span> Installing PhyTime</a></li>
-<li><a href="#running-phytime"><span class="toc-section-number">10.1.2</span> Running PhyTime</a></li>
-<li><a href="#upper-bounds-of-model-parameters"><span class="toc-section-number">10.1.3</span> Upper bounds of model parameters</a></li>
-<li><a href="#phytime-specific-options"><span class="toc-section-number">10.1.4</span> PhyTime specific options</a></li>
-<li><a href="#phytime-output"><span class="toc-section-number">10.1.5</span> PhyTime output</a></li>
-<li><a href="#clockrate-vs.-evolrate"><span class="toc-section-number">10.1.6</span> ClockRate vs. EvolRate</a></li>
-<li><a href="#sec:ess"><span class="toc-section-number">10.1.7</span> Effective sample size</a></li>
-<li><a href="#sec:prior"><span class="toc-section-number">10.1.8</span> Prior distributions of model parameters</a></li>
-<li><a href="#sec:citephytime"><span class="toc-section-number">10.1.9</span> Citing PhyTime</a></li>
-</ul></li>
-<li><a href="#phylogeo"><span class="toc-section-number">10.2</span> PhyloGeo</a><ul>
-<li><a href="#installing-phylogeo"><span class="toc-section-number">10.2.1</span> Installing PhyloGeo</a></li>
-<li><a href="#running-phylogeo"><span class="toc-section-number">10.2.2</span> Running PhyloGeo</a></li>
-<li><a href="#sec:citephylogeo"><span class="toc-section-number">10.2.3</span> Citing PhyloGeo</a></li>
-</ul></li>
-</ul></li>
-<li><a href="#sec:progusage"><span class="toc-section-number">11</span> Recommendations on program usage</a><ul>
-<li><a href="#phyml"><span class="toc-section-number">11.1</span> PhyML</a></li>
-<li><a href="#sec:recomphytime"><span class="toc-section-number">11.2</span> PhyTime</a></li>
-</ul></li>
-<li><a href="#frequently-asked-questions"><span class="toc-section-number">12</span> Frequently asked questions</a></li>
-<li><a href="#acknowledgements"><span class="toc-section-number">13</span> Acknowledgements</a></li>
-</ul>
-</div>
-<p><br /></p>
-<p>©Copyright 1999 - 2008 by PhyML Development Team.<br />The software PhyML is provided “as is” without warranty of any kind. In no event shall the authors or his employer be held responsible for any damage resulting from the use of this software, including but not limited to the frustration that you may experience in using the package. All parts of the source and documentation except where indicated are distributed under the GNU public licence. See http://www.opensource.org for details.</p>
-<h1 id="availability"><a href="#availability"><span class="header-section-number">1</span> Availability</a></h1>
-<ul>
-<li><p>Binaries: <a href="http://www.atgc-montpellier.fr/phyml">http://www.atgc-montpellier.fr/phyml</a></p></li>
-<li><p>Sources: <a href="http://stephaneguindon.github.io/phyml-downloads/">http://stephaneguindon.github.io/phyml-downloads/</a></p></li>
-<li><p>Discussion forum: <a href="http://groups.google.com/group/phyml-forum">http://groups.google.com/group/phyml-forum</a></p></li>
-</ul>
-<h1 id="authors"><a href="#authors"><span class="header-section-number">2</span> Authors</a></h1>
-<ul>
-<li><p><span> Stéphane Guindon</span> and <span> Olivier Gascuel</span> conceived the original PhyML algorithm.</p></li>
-<li><p><span> Stéphane Guindon</span> conceived the PhyTime method.</p></li>
-<li><p><span> Stéphane Guindon, David Welch and Louis Ranjard</span> conceived the PhyloGeo method.</p></li>
-<li><p><span> Stéphane Guindon, Wim Hordjik</span> and <span> Olivier Gascuel</span> conceived the SPR-based tree search algorithm.</p></li>
-<li><p><span> Maria Anisimova</span> and <span> Olivier Gascuel</span> conceived the aLRT method for branch support.</p></li>
-<li><p><span> Stéphane Guindon, Franck Lethiec</span>, Jean-Francois Dufayard and Vincent Lefort implemented PhyML.</p></li>
-<li><p><span> Jean-Francois Dufayard</span> created the benchmark and implemented the tools that are used to check PhyML accuracy and performances.</p></li>
-<li><p><span> Vincent Lefort, Stéphane Guindon, Patrice Duroux</span> and <span> Olivier Gascuel</span> conceived and implemented PhyML web server.</p></li>
-<li><p><span> Imran Fanaswala</span> interfaced PhyML with BEAGLE.</p></li>
-<li><p>Stéphane Guindon wrote this document.</p></li>
-</ul>
-<h1 id="overview"><a href="#overview"><span class="header-section-number">3</span> Overview</a></h1>
-<p>PhyML <span class="citation"></span> is a software package which primary task that is to estimate maximum likelihood phylogenies from alignments of nucleotide or amino-acid sequences. It provides a wide range of options that were designed to facilitate standard phylogenetic analyses. The main strength of PhyML lies in the large number of substitution models coupled to various options to search the space of phylogenetic tree topologies, going from very fast and efficient methods to slo [...]
-<p>PhyML was designed to process moderate to large data sets. In theory, alignments with up to 4,000 sequences 2,000,000 character-long can analyzed. In practice however, the amount of memory required to process a data set is proportional of the product of the number of sequences by their length. Hence, a large number of sequences can only be processed provided that they are short. Also, PhyML can handle long sequences provided that they are not numerous. With most standard personal comp [...]
-<h1 id="bug-report"><a href="#bug-report"><span class="header-section-number">4</span> Bug report</a></h1>
-<p>While PhyML is, of course, bug-free (!) (please read the disclaimer carefuly...), if you ever come across an issue, please feel free to report it using the discuss group web site at the following address: <a href="https://groups.google.com/forum/?fromgroups#!forum/phyml-forum">https://groups.google.com/forum/?fromgroups#!forum/phyml-forum</a>. Alternatively, you can send an email to <a href="s.guindon at auckland.ac.nz">s.guindon at auckland.ac.nz</a>. Do not forget to mention the version o [...]
-<h1 id="installing-phyml"><a href="#installing-phyml"><span class="header-section-number">5</span> Installing PhyML</a></h1>
-<h2 id="sources-and-compilation"><a href="#sources-and-compilation"><span class="header-section-number">5.1</span> Sources and compilation</a></h2>
-<p>The sources of the program are available free of charge from <a href="http://stephaneguindon.github.io/phyml-downloads/">http://stephaneguindon.github.io/phyml-downloads/</a>. The compilation on UNIX-like systems is fairly standard. It is described in the ‘<code>INSTALL</code>’ file that comes with the sources. In a command-line window, go to the directory that contains the sources and type:</p>
-<pre><code>./configure;
-make clean;
-make V=0;</code></pre>
-<p>By default, PhyML will be compiled with optimization flags turned on. It is possible to generate a version of PhyML that can run through a debugging tool (such as <code>ddd</code>[ddd]) or a profiling tool (such as <code>gprof</code>[gprof]) using the following instructions:</p>
-<pre><code>./configure --enable-debug;
-make clean;
-make V=0;</code></pre>
-<h2 id="installing-phyml-on-unix-like-systems-including-mac-os"><a href="#installing-phyml-on-unix-like-systems-including-mac-os"><span class="header-section-number">5.2</span> Installing PhyML on UNIX-like systems (including Mac OS)</a></h2>
-<p>Copy PhyML binary file in the directory you like. For the operating system to be able to locate the program, this directory must be specified in the global variable <code>PATH</code>. In order to achieve this, you will have to add <code>export PATH=/your_path/:$PATH</code> to the <code>.bashrc</code> or the <code>.bash_profile</code> located in your home directory (<code>your_path</code> is the path to the directory that contains PhyML binary).</p>
-<h2 id="sec:install-windows"><a href="#sec:install-windows"><span class="header-section-number">5.3</span> Installing PhyML on Microsoft Windows</a></h2>
-<p>Copy the files <code>phyml.exe</code> and <code>phyml.bat</code> in the same directory. To launch PhyML, click on the icon corresponding to <code>phyml.bat</code>. Clicking on the icon for <code>phyml.exe</code> works too but the dimensions of the window will not fit PhyML PHYLIP-like interface.</p>
-<h2 id="sec:MPI"><a href="#sec:MPI"><span class="header-section-number">5.4</span> Installing the parallel version of PhyML</a></h2>
-<p>Bootstrap analysis can run on multiple processors. Each processor analyses one bootstraped dataset. Therefore, the computing time needed to perform <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>R</mi></mrow></math> bootstrap replicates is divided by the number of processors available.</p>
-<p>This feature of PhyML relies on the MPI (Message Passing Interface) library. To use it, your computer must have MPI installed on it. In case MPI is not installed, you can dowload it from <a href="http://www.mcs.anl.gov/research/projects/mpich2/">http://www.mcs.anl.gov/research/projects/mpich2/</a>. Once MPI is installed, it is necessary to launch the MPI daemon. This can be done by entering the following instruction: <code>mpd &</code>. Note however that in most cases, the MPI dae [...]
-<pre><code>./configure --enable-mpi;
-make clean;
-make;</code></pre>
-<p>A binary file named <code>phyml-mpi</code> has now been created in the <code>src/</code> directory and is ready to use with MPI. A typical MPI command-line which uses 4 CPUs is given below:</p>
-<pre><code>mpirun -n 4 ./phyml-mpi -i myseq -b 100</code></pre>
-<p>Please read section [sec:parallel<sub>b</sub>ootstrap] of this document for more information.</p>
-<h2 id="sec:install-phyml-beagle"><a href="#sec:install-phyml-beagle"><span class="header-section-number">5.5</span> Installing PhyML-BEAGLE</a></h2>
-<p>PhyML can use the BEAGLE<span class="citation"></span> library for the likelihood computation. BEAGLE provides provides significant speed-up: the single core version of PhyML-BEAGLE can be up to 10 times faster than PhyML on a single core and up to 150 times on Graphical Processing Units. PhyML-BEAGLE will eventually have of the features of PhyML, even though at the moment the boostrap and the invariant site options are not available. Also, please note that in some cases, the final lo [...]
-<p>In order to install PhyML-BEAGLE, you first need to download and install the BEAGLE library available from <a href="https://code.google.com/p/beagle-lib/">https://code.google.com/p/beagle-lib/</a>. Then run the following commands:</p>
-<pre><code>./configure --enable-beagle;
-make clean;
-make;</code></pre>
-<p>A binary file named <code>phyml-beagle</code> will be created in the <code>src/</code> directory. The interface to <code>phyml-beagle</code> (i.e., commandline option of PHYLIP-like interface) is exactly identical to that of PhyML.</p>
-<h1 id="sec:phyml_new"><a href="#sec:phyml_new"><span class="header-section-number">6</span> Program usage.</a></h1>
-<p>PhyML has three distinct user-interfaces. The first corresponds to a PHYLIP-like text interface that makes the choice of the options self-explanatory. The command-line interface is well-suited for people that are familiar with PhyML options or for running PhyML in batch mode. The XML interface is more sophisticated. It allows the user to analyse partitionned data using flexible mixture models of evolution.</p>
-<h2 id="phylip-like-interface"><a href="#phylip-like-interface"><span class="header-section-number">6.1</span> PHYLIP-like interface</a></h2>
-<p>The default is to use the PHYLIP-like text interface by simply typing ‘<code>phyml</code>’ in a command-line window or by clicking on the PhyML icon (see Section [sec:install-windows]). After entering the name of the input sequence file, a list of sub-menus helps the users set up the analysis. There are currently four distinct sub-menus:</p>
-<ol>
-<li><p><span><em>Input Data</em></span>: specify whether the input file contains amino-acid or nucleotide sequences. What the sequence format is (see Section [sec:input<sub>o</sub>utput]) and how many data sets should be analysed.</p></li>
-<li><p><span><em>Substitution Model</em></span>: selection of the Markov model of substitution.</p></li>
-<li><p><span><em>Tree Searching</em></span>: selection of the tree topology searching algorithm.</p></li>
-<li><p><span><em>Branch Support</em></span>: selection of the method that is used to measure branch support.</p></li>
-</ol>
-<p>‘<code>+</code>’ and ‘<code>-</code>’ keys are used to move forward and backward in the sub-menu list. Once the model parameters have been defined, typing ‘<code>Y</code>’ (or ‘<code>y</code>’) launches the calculations. The meaning of some options may not be obvious to users that are not familiar with phylogenetics. In such situation, we strongly recommend to use the default options. As long as the format of the input sequence file is correctly specified (sub-menu <span><em>Input dat [...]
-<h3 id="input-data-sub-menu"><a href="#input-data-sub-menu"><span class="header-section-number">6.1.1</span> Input Data sub-menu</a></h3>
-<p>Type of data in the input file. It can be either DNA or amino-acid sequences in PHYLIP format (see Section [sec:input<sub>o</sub>utput]). Type <code>D</code> to change settings.</p>
-<p>PHYLIP format comes in two flavours: interleaved or sequential (see Section [sec:input<sub>o</sub>utput]). Type <code>I</code> to selected among the two formats.</p>
-<p>If the input sequence file contains more than one data sets, PhyML can analyse each of them in a single run of the program. Type <code>M</code> to change settings.</p>
-<p>This option allows you to append a string that identifies the current PhyML run. Say for instance that you want to analyse the same data set with two models. You can then ‘tag’ the first PhyML run with the name of the first model while the second run is tagged with the name of the second model.</p>
-<h3 id="sec:submenus"><a href="#sec:submenus"><span class="header-section-number">6.1.2</span> Substitution model sub-menu</a></h3>
-<p>PhyML implements a wide range of substitution models: JC69 <span class="citation"></span>, K80 <span class="citation"></span>, F81 <span class="citation"></span>, F84 <span class="citation"></span>, HKY85 <span class="citation"></span>, TN93 <span class="citation"></span> GTR <span class="citation"></span> and custom for nucleotides; LG <span class="citation"></span>, WAG <span class="citation"></span>, Dayhoff <span class="citation"></span>, JTT <span class="citation"></span>, Blosum [...]
-<p>For nucleotide sequences, optimising equilibrium frequencies means that the values of these parameters are estimated in the maximum likelihood framework. When the custom model option is selected, it is also possible to give the program a user-defined nucleotide frequency distribution at equilibrium (option <code>E</code>). For protein sequences, the stationary amino-acid frequencies are either those defined by the substitution model or those estimated by counting the number of differe [...]
-<p>Fix or estimate the transition/transversion ratio in the maximum likelihood framework. This option is only available when DNA sequences are to be analysed under K80, HKY85 or TN93 models. The definition given to this parameter by PhyML is the same as PAML’s one. Therefore, the value of this parameter does <span><em>not</em></span> correspond to the ratio between the expected number of transitions and the expected number of transversions during a unit of time. This last definition is t [...]
-<p>The proportion of invariable sites, i.e., the expected frequency of sites that do not evolve, can be fixed or estimated. The default is to fix this proportion to 0.0. By doing so, we consider that each site in the sequence may accumulate substitutions at some point during its evolution, even if no differences across sequences are actually observed at that site. Users can also fix this parameter to any value in the <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow [...]
-<p>Rates of evolution often vary from site to site. This heterogeneity can be modelled using a discrete gamma distribution. Type <code>R</code> to switch this option on or off. The different categories of this discrete distribution correspond to different (relative) rates of evolution. The number of categories of this distribution is set to 4 by default. It is probably not wise to go below this number. Larger values are generally preferred. However, the computational burden involved is p [...]
-<p>The middle of each discretized substitution rate class can be determined using the mean or the median. PAML, MrBayes and RAxML use the mean. However, the median is generally associated with greater likelihoods than the mean. This conclusion is based on our analysis of several real-world data sets extracted from TreeBase. Despite this, the default option in PhyML is to use the mean in order to make PhyML likelihoods comparable to those of other phylogenetic software. One must bare in m [...]
-<p>The shape of the gamma distribution determines the range of rate variation across sites. Small values, typically in the <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo stretchy="false">[</mo><mn>0</mn><mo>.</mo><mn>1</mn><mo>,</mo><mn>1</mn><mo>.</mo><mn>0</mn><mo stretchy="false">]</mo></mrow></math> range, correspond to large variability. Larger values correspond to moderate to low heterogeneity. The gamma shape parameter can be fixed by the user or estim [...]
-<h3 id="tree-searching-sub-menu"><a href="#tree-searching-sub-menu"><span class="header-section-number">6.1.3</span> Tree searching sub-menu</a></h3>
-<p>By default the tree topology is optimised in order to maximise the likelihood. However, it is also possible to avoid any topological alteration. This option is useful when one wants to compute the likelihood of a tree given as input (see below). Type <code>O</code> to select among these two options.</p>
-<p>PhyML proposes three different methods to estimate tree topologies. The default approach is to use simultaneous NNI. This option corresponds to the original PhyML algorithm <span class="citation"></span>. The second approach relies on subtree pruning and regrafting (SPR). It generally finds better tree topologies compared to NNI but is also significantly slower. The third approach, termed BEST, simply estimates the phylogeny using both methods and returns the best solution among the t [...]
-<p>When the SPR or the BEST options are selected, is is possible to use random trees rather than BioNJ or a user-defined tree, as starting tree. If this option is turned on (type <code>R</code> to change), five trees, corresponding to five random starts, will be estimated. The output tree file will contain the best tree found among those five. The number of random starts can be modified by typing <code>N</code>. Setting the number of random starting trees to <math display="inline" xmlns= [...]
-<p>When the tree topology optimisation option is turned on, PhyML proceeds by refining an input tree. By default, this input tree is estimated using BioNJ <span class="citation"></span>. The alternative option is to use a parsimony tree. We found this option specially useful when analysing large data sets with NNI moves as it generally leads to greater likelihoods than those obtained when starting from a BioNJ trees. The user can also to input her/his own tree. This tree should be in New [...]
-<h3 id="branch-support-sub-menu"><a href="#branch-support-sub-menu"><span class="header-section-number">6.1.4</span> Branch support sub-menu</a></h3>
-<p>The support of the data for each internal branch of the phylogeny can be estimated using non-parametric bootstrap. By default, this option is switched off. Typing <code>B</code> switches on the bootstrap analysis. The user is then prompted for a number of bootstrap replicates. The largest this number the more precise the bootstrap support estimates are. However, for each bootstrap replicate a phylogeny is estimated. Hence, the time needed to analyse <math display="inline" xmlns="http: [...]
-<p>When the bootstrap option is switched off (see above), approximate likelihood branch supports are estimated. This approach is considerably faster than the bootstrap one. However, both methods intend to estimate different quantities and conducting a fair comparison between both criteria is not straightforward. The estimation of approximate likelihood branch support comes in multiple flavours. The default is set to aBayes, corresponding to the approximate Bayes method described in <span [...]
-<h2 id="command-line-interface"><a href="#command-line-interface"><span class="header-section-number">6.2</span> Command-line interface</a></h2>
-<p>An alternative to the PHYLIP-like interface is the command-line interface. Users that do not need to modify the default parameters can launch the program with the ‘<code>phyml -i seq_file_name</code>’ command. The list of all command line arguments and how to use them is given in the ‘Help’ section which is displayed when entering the ‘<code>phyml –help</code>’ command. The available command-line options are described in what follows.</p>
-<ul>
-<li><p><code>-i</code> (or <code>–input</code>) <code>seq_file_name</code><br /><code>seq_file_name</code> is the name of the nucleotide or amino-acid sequence file in PHYLIP format.</p></li>
-<li><p><code>-d</code> (or <code>–datatype</code>) <code>data_type</code><br /><code>data_type</code> is <code>nt</code> for nucleotide (default) and <code>aa</code> for amino-acid sequences.</p></li>
-<li><p><code>-q</code> (or <code>–sequential</code>)<br />Changes interleaved format (default) to sequential format.</p></li>
-<li><p><code>-n</code> (or <code>–multiple</code>) <code>nb_data_sets</code><br /><code>nb_data_sets</code> is an integer giving the number of data sets to analyse.</p></li>
-<li><p><code>-p</code> (or <code>–pars</code>)<br />Use a minimum parsimony starting tree. This option is taken into account when the ‘-u’ option is absent and when tree topology modifications are to be done.</p></li>
-<li><p><code>-b</code> (or <code>–bootstrap</code>) <code>int</code></p>
-<ul>
-<li><p><code>int</code> <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>></mo></mrow></math> 0: <code>int</code> is the number of bootstrap replicates.</p></li>
-<li><p><code>int</code> = 0: neither approximate likelihood ratio test nor bootstrap values are computed.</p></li>
-<li><p><code>int</code> = -1: approximate likelihood ratio test returning aLRT statistics.</p></li>
-<li><p><code>int</code> = -2: approximate likelihood ratio test returning Chi2-based parametric branch supports.</p></li>
-<li><p><code>int</code> = -4: SH-like branch supports alone.</p></li>
-<li><p><code>int</code> = -5: (default) approximate Bayes branch supports.</p></li>
-</ul></li>
-<li><p><code>-m</code> (or <code>–model</code>) <code>model_name</code><br /><code>model_name</code> : substitution model name.</p>
-<ul>
-<li><p><span><em>Nucleotide-based models</em></span>: <code>HKY85</code> (default) <code>| JC69 | K80 | F81 | F84 | TN93 | GTR | custom</code><br />The <code>custom</code> option can be used to define a new substitution model. A string of six digits identifies the model. For instance, 000000 corresponds to F81 (or JC69 provided the distribution of nucleotide frequencies is uniform). 012345 corresponds to GTR. This option can be used for encoding any model that is a nested within GTR. See [...]
-<li><p><span><em>Amino-acid based models</em></span>: <code>LG</code> (default) <code>| WAG | JTT | MtREV | Dayhoff | DCMut | RtREV | CpREV | VT | Blosum62 | MtMam | MtArt | HIVw | HIVb | custom</code><br />The <code>custom</code> option is useful when one wants to use an amino-acid substitution model that is not available by default in PhyML. The symmetric part of the rate matrix, as well as the equilibrium amino-acid frequencies, are given in a file which name is asked for by the progr [...]
-</ul>
-<table>
-<thead>
-<tr class="header">
-<th align="left">Name</th>
-<th align="left">Command-line option</th>
-</tr>
-</thead>
-<tbody>
-<tr class="odd">
-<td align="left">JC69</td>
-<td align="left"><code>-m 000000 -f 0.25,0.25,0.25,0.25</code></td>
-</tr>
-<tr class="even">
-<td align="left">F81</td>
-<td align="left"><code>-m 000000</code></td>
-</tr>
-<tr class="odd">
-<td align="left">K80</td>
-<td align="left"><code>-m 010010 -f 0.25,0.25,0.25,0.25</code></td>
-</tr>
-<tr class="even">
-<td align="left">HKY85</td>
-<td align="left"><code>-m 010010</code></td>
-</tr>
-<tr class="odd">
-<td align="left">TrNef</td>
-<td align="left"><code>-m 010020 -f 0.25,0.25,0.25,0.25</code></td>
-</tr>
-<tr class="even">
-<td align="left">TrN</td>
-<td align="left"><code>-m 010020</code></td>
-</tr>
-<tr class="odd">
-<td align="left">K81</td>
-<td align="left"><code>-m 123321 -f 0.25,0.25,0.25,0.25</code></td>
-</tr>
-<tr class="even">
-<td align="left">K81uf</td>
-<td align="left"><code>-m 123321</code></td>
-</tr>
-<tr class="odd">
-<td align="left">TIMef</td>
-<td align="left"><code>-m 132241 -f 0.25,0.25,0.25,0.25</code></td>
-</tr>
-<tr class="even">
-<td align="left">TIM</td>
-<td align="left"><code>-m 132241</code></td>
-</tr>
-<tr class="odd">
-<td align="left">TVMef</td>
-<td align="left"><code>-m 102304 -f 0.25,0.25,0.25,0.25</code></td>
-</tr>
-<tr class="even">
-<td align="left">TVM</td>
-<td align="left"><code>-m 102304</code></td>
-</tr>
-<tr class="odd">
-<td align="left">SYM</td>
-<td align="left"><code>-m 123456 -f 0.25,0.25,0.25,0.25</code></td>
-</tr>
-<tr class="even">
-<td align="left">GTR</td>
-<td align="left"><code>-m 123456</code></td>
-</tr>
-</tbody>
-</table>
-<p>[tab:modelcode]</p></li>
-<li><p><code>–aa_rate_file file_name</code><br />This option is compulsory when analysing amino-acid sequences under a ‘custom’ model (see above). <code>file_name</code> should provide a rate matrix and equilibrium amino acid in PAML format (see Section [sec:customaa]).</p></li>
-<li><p><code>-f e</code>, <code>m</code>, or ``<code>fA,fC,fG,fT</code>"<br />Nucleotide or amino-acid frequencies.</p>
-<ul>
-<li><p><code>e</code> : the character frequencies are determined as follows :</p>
-<ul>
-<li><p><span><em>Nucleotide sequences</em></span>: (Empirical) the equilibrium base frequencies are estimated by counting the occurence of the different bases in the alignment.</p></li>
-<li><p><span><em>Amino-acid sequences</em></span>: (Empirical) the equilibrium amino-acid frequencies are estimated by counting the occurence of the different amino-acids in the alignment.</p></li>
-</ul></li>
-<li><p><code>m</code> : the character frequencies are determined as follows :</p>
-<ul>
-<li><p><span><em>Nucleotide sequences</em></span>: (ML) the equilibrium base frequencies are estimated using maximum likelihood.</p></li>
-<li><p><span><em>Amino-acid sequences</em></span>: (Model) the equilibrium amino-acid frequencies are estimated using the frequencies defined by the substitution model.</p></li>
-</ul></li>
-<li><p>``<code>fA,fC,fG,fT</code>": only valid for nucleotide-based models. <code>fA</code>, <code>fC</code>, <code>fG</code> and <code>fT</code> are floating numbers that correspond to the frequencies of A, C, G and T respectively.</p></li>
-</ul></li>
-<li><p><code>-t</code> (or <code>–ts/tv</code>) <code>ts/tv_ratio</code><br /><code>ts/tv_ratio</code>: transition/transversion ratio. DNA sequences only. Can be a fixed positive value (e.g., 4.0) or type <code>e</code> to get the maximum likelihood estimate.</p></li>
-<li><p><code>-v</code> (or <code>–pinv</code>) <code>prop_invar</code><br /><code>prop_invar</code>: proportion of invariable sites. Can be a fixed value in the [0,1] range or type <code>e</code> to get the maximum likelihood estimate.</p></li>
-<li><p><code>-c</code> (or <code>–nclasses</code>) <code>nb_subst_cat</code><br /><code>nb_subst_cat</code>: number of relative substitution rate categories. Default: <code>nb_subst_cat=4</code>. Must be a positive integer.</p></li>
-<li><p><code>-a</code> (or <code>–alpha</code>) <code>gamma</code><br /><code>gamma</code>: value of the gamma shape parameter. Can be a fixed positive value or e to get the maximum likelihood estimate. The value of this parameter is estimated in the maximum likelihood framework by default.</p></li>
-<li><p><code>–use_median</code><br />The middle of each substitution rate class in the discrete gamma distribution is taken as the median. The mean is used by default.</p></li>
-<li><p><code>–free_rates</code><br />As an alternative to the discrete gamma model, it is possible to estimate the (relative) rate in each class of the (mixture) model and the corresponding frequencies directly from the data. This model, called the FreeRate model, has more parameters than the discrete gamma one but usually provides a significantly better fit to the data. See <span class="citation"></span> for more information about this model and an illustration of its use.</p></li>
-<li><p><code>–codpos</code> <code>1,2 or 3</code><br />When analysing an alignment of coding sequences, use this option to consider only the first, second or the third coding position for the estimation.</p></li>
-<li><p><code>-s</code> (or <code>–search</code>) <code>move</code><br />Tree topology search operation option. Can be either <code>NNI</code> (default, fast) or <code>SPR</code> (usually slower than <code>NNI</code> but more accurate) or <code>BEST</code> (best of NNI and SPR search).</p></li>
-<li><p><code>-u</code> (or <code>–inputtree</code>) <code>user_tree_file</code><br /><code>user_tree_file</code>: starting tree filename. The tree must be in Newick format.</p></li>
-<li><p><code>-o params</code><br />This option focuses on specific parameter optimisation.</p>
-<ul>
-<li><p><code>params=tlr</code>: tree topology (<code>t</code>), branch length (<code>l</code>) and substitution rate parameters (<code>r</code>) are optimised.</p></li>
-<li><p><code>params=tl</code>: tree topology and branch lengths are optimised.</p></li>
-<li><p><code>params=lr</code>: branch lengths and substitution rate parameters are optimised.</p></li>
-<li><p><code>params=l</code>: branch lengths are optimised.</p></li>
-<li><p><code>params=r</code>: substitution rate parameters are optimised.</p></li>
-<li><p><code>params=n</code>: no parameter is optimised.</p></li>
-</ul></li>
-<li><p><code>–rand_start</code><br />This option sets the initial tree to random. It is only valid if SPR searches are to be performed.</p></li>
-<li><p><code>–n_rand_starts num</code><br /><code>num</code> is the number of initial random trees to be used. It is only valid if SPR searches are to be performed.</p></li>
-<li><p><code>–r_seed num</code><br /><code>num</code> is the seed used to initiate the random number generator. Must be an integer.</p></li>
-<li><p><code>–print_site_lnl</code><br />Print the likelihood for each site in file *_phyml_lk.txt. For <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo></mrow></math>+I or FreeRate models, this option returns the posterior probability of each relative rate class at each site. Such information can then be used to identify fast- and slow-evolving regions of  [...]
-<li><p><code>–print_trace</code><br />Print each phylogeny explored during the tree search process in file *_phyml_trace.txt. This option can be useful for monitoring the progress of the analysis for very large data sets and have an approximate idea of what the final phylogeny will look like.</p></li>
-<li><p><code>–run_id ID_string</code><br />Append the string ID_string at the end of each PhyML output file. This option may be useful when running simulations involving PhyML. It can also be used to ‘tag’ multiple analysis of the same data set with various program settings.</p></li>
-<li><p><code>–no_memory_check</code><br />By default, when processing a large data set, PhyML will pause and ask the user to confirm that she/he wants to continue with the execution of the analysis despite the large amount of memory required. The <code>–no_memory_check</code> skips this question. It is especially useful when running PhyML in batch mode.</p></li>
-<li><p><code>–no_colalias</code><br />By default, PhyML preprocesses each alignment by putting together (or aliasing) the columns that are identical. Use this option to skip this step but be aware that the analysis might then take more time to complete.</p></li>
-<li><p><code>–constrained_lens</code><br />When an input tree with branch lengths is provided, this option will find the branch multiplier that maximises the likelihood (i.e., the relative branch lengths remain constant)</p></li>
-<li><p><code>–constraint_file</code> <code>file_name</code><br /><code>file_name</code> lists the topological constraints under which the tree topology search is conducted. This option should be used in conjunction with <code>-u</code> <code>file_name</code>. See Section [sec:topoconstraints] for more information.</p></li>
-<li><p><code>–quiet</code><br />Runs PhyML in quiet mode. The program will not pause if the memory required to run the analysis exceeds 256MB and will not output the log-likelihood score to the output.</p></li>
-<li><p><code>–ancestral</code><br />PhyML calculates the marginal probabilities of each character state at each internal node and each site of the sequence alignment.</p></li>
-</ul>
-<h2 id="xml-interface"><a href="#xml-interface"><span class="header-section-number">6.3</span> XML interface</a></h2>
-<ul>
-<li><p><code>–xml=xml_file_name</code><br /><code>xml_file_name</code> is the name of the XML file containing the information required to run the analysis. More details about this type of file is given in the section [sec:xmlio].</p></li>
-</ul>
-<h2 id="sec:parallel_bootstrap"><a href="#sec:parallel_bootstrap"><span class="header-section-number">6.4</span> Parallel bootstrap</a></h2>
-<p>Bootstrapping is a highly parallelizable task. Indeed, bootstrap replicates are independent from one another. Each bootstrap replicate can then be analysed separately. Modern computers often have more than one CPU. Each CPU can therefore be used to process a bootstrap sample. Using this parallel strategy, performing <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>R</mi></mrow></math> bootstrap replicates on <math display="inline" xmlns="http://www.w3.org/19 [...]
-<p>PhyML sources must be compiled with specific options to turn on the parallel option (see Section [sec:MPI]). Once the binary file (<code>phyml</code>) has been generated, running a bootstrap analysis with, say 100 replicates on 2 CPUs, can be done by typing the following command-line:</p>
-<pre><code>mpd &;
-mpirun -np 2 ./phyml -i seqfile -b 100;</code></pre>
-<p>The first command launches the mpi daemon while the second launches the analysis. Note that launching the daemon needs to be done only once. The output files are similar to the ones generated using the standard, non-parallel, analysis (see Section [sec:input<sub>o</sub>utput]). Note that running the program in batch mode, i.e.:</p>
-<pre><code>mpirun -np 2 ./phyml -i seqfile -b 100 &</code></pre>
-<p>will probably NOT work. I do not know how to run a mpi process in batch mode yet. Suggestions welcome... Also, at the moment, the number of bootstrap replicates must be a multiple of the number of CPUs required in the mpirun command.</p>
-<h1 id="sec:input_output"><a href="#sec:input_output"><span class="header-section-number">7</span> Inputs & outputs for command-line and PHYLIP interface </a></h1>
-<p>PhyML reads data from standard text files, without the need for any particular file name extension.</p>
-<h2 id="sequence-formats"><a href="#sequence-formats"><span class="header-section-number">7.1</span> Sequence formats</a></h2>
-<pre><code>
-5 80
-seq1  CCATCTCACGGTCGGTACGATACACCKGCTTTTGGCAGGAAATGGTCAATATTACAAGGT
-seq2  CCATCTCACGGTCAG---GATACACCKGCTTTTGGCGGGAAATGGTCAACATTAAAAGAT
-seq3  RCATCTCCCGCTCAG---GATACCCCKGCTGTTG????????????????ATTAAAAGGT
-seq4  RCATCTCATGGTCAA---GATACTCCTGCTTTTGGCGGGAAATGGTCAATCTTAAAAGGT
-seq5  RCATCTCACGGTCGGTAAGATACACCTGCTTTTGGCGGGAAATGGTCAAT????????GT
-
-ATCKGCTTTTGGCAGGAAAT
-ATCKGCTTTTGGCGGGAAAT
-AGCKGCTGTTG?????????
-ATCTGCTTTTGGCGGGAAAT
-ATCTGCTTTTGGCGGGAAAT</code></pre>
-<pre><code>
-5 40
-seq1  CCATCTCANNNNNNNNACGATACACCKGCTTTTGGCAGG
-seq2  CCATCTCANNNNNNNNGGGATACACCKGCTTTTGGCGGG
-seq3  RCATCTCCCGCTCAGTGAGATACCCCKGCTGTTGXXXXX
-seq4  RCATCTCATGGTCAATG-AATACTCCTGCTTTTGXXXXX
-seq5  RCATCTCACGGTCGGTAAGATACACCTGCTTTTGxxxxx</code></pre>
-<p>[fig:align<sub>t</sub>ree]</p>
-<pre><code>
-[ This is a comment ]
-#NEXUS
-BEGIN DATA;
-DIMENSIONS NTAX=10 NCHAR=20;
-FORMAT DATATYPE=DNA;
-MATRIX
-tax1       ?ATGATTTCCTTAGTAGCGG
-tax2       CAGGATTTCCTTAGTAGCGG
-tax3       ?AGGATTTCCTTAGTAGCGG
-tax4       ?????????????GTAGCGG
-tax5       CAGGATTTCCTTAGTAGCGG
-tax6       CAGGATTTCCTTAGTAGCGG
-tax7       ???GATTTCCTTAGTAGCGG
-tax8       ????????????????????
-tax9       ???GGATTTCTTCGTAGCGG
-tax10      ???????????????AGCGG;
-END;</code></pre>
-<pre><code>
-[ This is a comment ]
-#NEXUS
-BEGIN DATA;
-DIMENSIONS NTAX=10 NCHAR=20;
-FORMAT DATATYPE=STANDARD SYMBOLS="0 1 2 3";
-MATRIX
-tax1       ?0320333113302302122
-tax2       10220333113302302122
-tax3       ?0220333113302302122
-tax4       ?????????????2302122
-tax5       10220333113302302122
-tax6       10220333113302302122
-tax7       ???20333113302302122
-tax8       ????????????????????
-tax9       ???22033313312302122
-tax10      ???????????????02122;
-END;</code></pre>
-<pre><code>
-[ This is a comment ]
-#NEXUS
-BEGIN DATA;
-DIMENSIONS NTAX=10 NCHAR=20;
-FORMAT DATATYPE=STANDARD SYMBOLS="00 01 02 03";
-MATRIX
-tax1       ??00030200030303010103030002030002010202
-tax2       0100020200030303010103030002030002010202
-tax3       ??00020200030303010103030002030002010202
-tax4       ??????????????????????????02030002010202
-tax5       0100020200030303010103030002030002010202
-tax6       0100020200030303010103030002030002010202
-tax7       ??????0200030303010103030002030002010202
-tax8       ????????????????????????????????????????
-tax9       ??????0202000303030103030102030002010202
-tax10      ??????????????????????????????0002010202;
-END;</code></pre>
-<p>[fig:nexus]</p>
-<p>Alignments of DNA or protein sequences must be in PHYLIP or NEXUS <span class="citation"></span> sequential or interleaved format (Figures [fig:align<sub>t</sub>ree] and [fig:nexus]). For PHYLIP formated sequence alignments, the first line of the input file contains the number of species and the number of characters, in free format, separated by blank characters. One slight difference with PHYLIP format deals with sequence name lengths. While PHYLIP format limits this length to ten ch [...]
-<p>A PHYLIP input sequence file may also display more than a single data set. Each of these data sets must be in PHYLIP format and two successive alignments must be separated by an empty line. Processing multiple data sets requires to toggle the ‘<code>M</code>’ option in the <span><em>Input Data</em></span> sub-menu or use the ‘<code>-n</code>’ command line option and enter the number of data sets to analyse. The multiple data set option can be used to process re-sampled data that were  [...]
-<p>PhyML can also process alignments in NEXUS format. Although not all the options provided by this format are supported by PhyML, a few specific features are exploited. Of course, this format can handle nucleotide and protein sequence alignments in sequential or interleaved format. It is also possible to use custom alphabets, replacing the standard 4-state and 20-state alphabets for nucleotides and amino-acids respectively. Examples of a 4-state custom alphabet are given in Figure [fig: [...]
-<h3 id="gaps-and-ambiguous-characters"><a href="#gaps-and-ambiguous-characters"><span class="header-section-number">7.1.1</span> Gaps and ambiguous characters</a></h3>
-<p>Gaps correspond to the ‘<code>-</code>’ symbol. They are systematically treated as unknown characters “on the grounds that we don’t know what would be there if something were there” (J. Felsenstein, PHYLIP main documentation). The likelihood at these sites is summed over all the possible states (i.e., nucleotides or amino acids) that could actually be observed at these particular positions. Note however that columns of the alignment that display only gaps or unknown characters are sim [...]
-<table>
-<thead>
-<tr class="header">
-<th align="left">Character</th>
-<th align="right">Nucleotide</th>
-<th align="left">Character</th>
-<th align="right">Nucleotide</th>
-</tr>
-</thead>
-<tbody>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math></td>
-<td align="right">Adenosine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Y</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math></td>
-<td align="right">Guanosine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>K</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math></td>
-<td align="right">Cytidine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>B</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-<td align="right">Thymidine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>D</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>U</mi></mrow></math></td>
-<td align="right">Uridine (=<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math>)</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>H</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>M</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math></td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>V</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math></td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>R</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math></td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>−</mo></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>N</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>X</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>?</mo></mrow></math></td>
-<td align="right">unknown</td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>W</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-<td align="left"></td>
-<td align="right">(=<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math>)</td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>S</mi></mrow></math></td>
-<td align="right"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math></td>
-<td align="left"></td>
-<td align="right"></td>
-</tr>
-</tbody>
-</table>
-<p>[tab:ambigu<sub>n</sub>t]</p>
-<table>
-<thead>
-<tr class="header">
-<th align="left">Character</th>
-<th align="right">Amino-Acid</th>
-<th align="left">Character</th>
-<th align="right">Amino-Acid</th>
-</tr>
-</thead>
-<tbody>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math></td>
-<td align="right">Alanine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>L</mi></mrow></math></td>
-<td align="right">Leucine</td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>R</mi></mrow></math></td>
-<td align="right">Arginine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>K</mi></mrow></math></td>
-<td align="right">Lysine</td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>N</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>B</mi></mrow></math></td>
-<td align="right">Asparagine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>M</mi></mrow></math></td>
-<td align="right">Methionine</td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>D</mi></mrow></math></td>
-<td align="right">Aspartic acid</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>F</mi></mrow></math></td>
-<td align="right">Phenylalanine</td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>C</mi></mrow></math></td>
-<td align="right">Cysteine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>P</mi></mrow></math></td>
-<td align="right">Proline</td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Q</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Z</mi></mrow></math></td>
-<td align="right">Glutamine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>S</mi></mrow></math></td>
-<td align="right">Serine</td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>E</mi></mrow></math></td>
-<td align="right">Glutamic acid</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>T</mi></mrow></math></td>
-<td align="right">Threonine</td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>G</mi></mrow></math></td>
-<td align="right">Glycine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>W</mi></mrow></math></td>
-<td align="right">Tryptophan</td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>H</mi></mrow></math></td>
-<td align="right">Histidine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Y</mi></mrow></math></td>
-<td align="right">Tyrosine</td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>I</mi></mrow></math></td>
-<td align="right">Isoleucine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>V</mi></mrow></math></td>
-<td align="right">Valine</td>
-</tr>
-<tr class="odd">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>L</mi></mrow></math></td>
-<td align="right">Leucine</td>
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>−</mo></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>X</mi></mrow></math> or <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>?</mo></mrow></math></td>
-<td align="right">unknown</td>
-</tr>
-<tr class="even">
-<td align="left"><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>K</mi></mrow></math></td>
-<td align="right">Lysine</td>
-<td align="left"></td>
-<td align="right">(can be any amino acid)</td>
-</tr>
-</tbody>
-</table>
-<p>[tab:ambigu<sub>a</sub>a]</p>
-<h3 id="sec:outgroupspecify"><a href="#sec:outgroupspecify"><span class="header-section-number">7.1.2</span> Specifying outgroup sequences</a></h3>
-<p>PhyML can return rooted trees provided outgroup taxa are identified from the sequence file. In order to do so, sequence names that display a ‘*’ character will be automatically considered as belonging to the outgroup.</p>
-<p>The topology of the rooted tree is exactly the same as the unrooted version of the same tree. In other words, PhyML first ignores the distinction between ingroup and outgroup sequences, builds a maximum likelihood unrooted tree and then tries to add the root. If the outgroup has more than one sequence, the position of the root might be ambiguous. In such situation, PhyML tries to identify the most relevant position of the root by considering which edge provides the best separation bet [...]
-<h2 id="tree-format"><a href="#tree-format"><span class="header-section-number">7.2</span> Tree format</a></h2>
-<p>PhyML can read one or several phylogenetic trees from an input file. This option is accessible through the <span><em>Tree Searching</em></span> sub menu or the ‘<code>-u</code>’ argument from the command line. Input trees are generally used as initial maximum likelihood estimates to be subsequently adjusted by the tree searching algorithm. Trees can be either rooted or unrooted and multifurcations are allowed. Taxa names must, of course, match the corresponding sequence names.</p>
-<pre><code>((seq1:0.03,seq2:0.01):0.04,(seq3:0.01,(seq4:0.2,seq5:0.05):0.2):0.01);
-((seq3,seq2),seq1,(seq4,seq5));</code></pre>
-<p>[fig:trees]</p>
-<h2 id="multiple-alignments-and-trees"><a href="#multiple-alignments-and-trees"><span class="header-section-number">7.3</span> Multiple alignments and trees</a></h2>
-<p>Single or multiple sequence data sets may be used in combination with single or multiple input trees. When the number of data sets is one (<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>n</mi><mi>D</mi></msub><mo>=</mo><mn>1</mn></mrow></math>) and there is only one input tree (<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>n</mi><mi>T</mi></msub><mo>=</mo><mn>1</mn></mrow></math>), then this tree is simply used as  [...]
-<h2 id="sec:customaa"><a href="#sec:customaa"><span class="header-section-number">7.4</span> Custom amino-acid rate model</a></h2>
-<p>The custom amino-acid model of substitutions can be used to implement a model that is not hard-coded in PhyML. This model must be time-reversible. Hence, the matrix of substitution rates is symmetrical. The format of the rate matrix with the associated stationary frequencies is identical to the one used in PAML. An example is given below:</p>
-<p><span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span></span> &&&&&&&&&&&&&&& [...]
-<p>The entry on the <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>i</mi></mrow></math>-th row and <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>j</mi></mrow></math>-th column of this matrix corresponds to the rate of substitutions between amino-acids <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>i</mi></mrow></math> and <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>j</m [...]
-<h2 id="sec:topoconstraints"><a href="#sec:topoconstraints"><span class="header-section-number">7.5</span> Topological constraint file</a></h2>
-<p>PhyML can perform phylogenetic tree estimation under user-specified topological constraints. In order to do so, one should use the <code>–constraint_file</code> <code>file_name</code> command-line option where <code>file_name</code> lists the topological constraints. Such constraints are straightforward to define. For instance, the following constraints:</p>
-<pre><code>((A,B,C),(D,E,F));</code></pre>
-<p>indicate that taxa A, B and C belong to the same clade. D, E and F also belong to the same clade and the two clades hence defined should not overlap. Under these two constraints, the tree ((A,B),D,((E,F),C)) is not valid. From the example above, you will notice that the constraints are defined using a multifurcating tree in NEWICK format. Note that this tree does not need to display the whole list of taxa. For instance, while the only taxa involved in specifying topological constraint [...]
-<p>PhyML tree topology search algorithms all rely on improving a starting tree. By default, BioNJ is the method of choice for building this tree. However, there is no guarantee that the phylogeny estimated with PhyML does comply with the topological constraints. While it is probably possible to implement BioNJ with topological constraints, we have not done so yet. Instead, the same multifurcating tree that defines the topological constraints should also be used as starting tree using the [...]
-<h2 id="output-files"><a href="#output-files"><span class="header-section-number">7.6</span> Output files</a></h2>
-<p>Sequence file name : ‘<span>seq</span>’<br /></p>
-<table>
-<thead>
-<tr class="header">
-<th align="left">Output file name</th>
-<th align="left">Content</th>
-</tr>
-</thead>
-<tbody>
-<tr class="odd">
-<td align="left"><code>seq_phyml_tree</code></td>
-<td align="left">ML tree</td>
-</tr>
-<tr class="even">
-<td align="left"><code>seq_phyml_stats</code></td>
-<td align="left">ML model parameters</td>
-</tr>
-<tr class="odd">
-<td align="left"><code>seq_phyml_boot_trees</code></td>
-<td align="left">ML trees – bootstrap replicates</td>
-</tr>
-<tr class="even">
-<td align="left"><code>seq_phyml_boot_stats</code></td>
-<td align="left">ML model parameters – bootstrap replicates</td>
-</tr>
-<tr class="odd">
-<td align="left"><code>seq_phyml_rand_trees</code></td>
-<td align="left">ML trees – multiple random starts</td>
-</tr>
-<tr class="even">
-<td align="left"><code>seq_phyml_ancestral_seq</code></td>
-<td align="left">ML trees – ancestral sequences</td>
-</tr>
-</tbody>
-</table>
-<p>[tab:output]</p>
-<p>Table [tab:output] presents the list of files resulting from an analysis. Basically, each output file name can be divided into three parts. The first part is the sequence file name, the second part corresponds to the extension ‘<code>_phyml_</code>’ and the third part is related to the file content. When launched with the default options, PhyML only generates two files: the tree file and the model parameter file. The estimated maximum likelihood tree is in standard Newick format (see  [...]
-<p>PhyML estimates ancestral sequences by calculating the marginal probability of each character state at each internal node of the phylogeny. These probabilities are given in the file <code>seq_phyml_ancestral_seq</code>. The bulk of this file is a table where each row corresponds to a site in the original alignment and an the number corresponding to an internal node. It is relatively straightforward to identify which number corresponds to which node in the tree by examining the informa [...]
-<pre><code>
-Node nums:   0   4  (dir:  0) names = 'A'      '(null)';
-Node nums:   4   2  (dir:  1) names = '(null)' 'B';
-Node nums:   4   5  (dir:  2) names = '(null)' '(null)';
-Node nums:   5   1  (dir:  0) names = '(null)' 'C';
-Node nums:   5   3  (dir:  1) names = '(null)' 'D';</code></pre>
-<p>The two integers following <code>Node nums</code> are the node numbers. They are displayed in a recursive manner. The number on the left column is that of the ancestral node while the one on the right column is the direct descendant. The following columns are the node names. These names are set to <code>null</code> except for the tip nodes, where the corresponding taxon names are displayed.</p>
-<h2 id="treatment-of-invariable-sites-with-fixed-branch-lengths"><a href="#treatment-of-invariable-sites-with-fixed-branch-lengths"><span class="header-section-number">7.7</span> Treatment of invariable sites with fixed branch lengths</a></h2>
-<p>PhyML allows users to give an input tree with fixed topology and branch lengths and find the proportion of invariable sites that maximise the likelihood (option <code>-o r</code>). These two options can be considered as conflicting since branch lengths depend on the proportion of invariants. Hence, changing the proportion of invariants implies that branch lengths are changing too. More formally, let <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>l</mi></mr [...]
-<ol>
-<li><p>Calculate <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>l</mi><mo>ʹ</mo><mo>=</mo><mi>l</mi><mo>/</mo><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>p</mi><mo stretchy="false">)</mo></mrow></math> and leave <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>l</mi><mo>ʹ</mo></mrow></math> unchanged throughout the optimization.</p></li>
-<li><p>Find the value of <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>p</mi></mrow></math> that maximises the likelihood. Let <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>p</mi><mo>*</mo></msup></mrow></math> denote this value.</p></li>
-<li><p>Set <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>l</mi><mo>*</mo></msup><mo>=</mo><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><msup><mi>p</mi><mo>*</mo></msup><mo stretchy="false">)</mo><mi>l</mi><mo>ʹ</mo></mrow></math> and print out the tree with <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>l</mi><mo>*</mo></msup></mrow></math> (instead of <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML [...]
-</ol>
-<p>PhyML therefore assumes that the users wants to fix the branch lengths measured at _variable_ sites only (i.e., <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>l</mi><mo>*</mo></msup></mrow></math> is fixed). This is the reason why the branch lengths in the input and output trees do differ despite the use of the the <code>-o r</code> option. While we believe that this approach relies on a sound rationale, it is not perfect. In particular, the original [...]
-<h1 id="sec:xmlio"><a href="#sec:xmlio"><span class="header-section-number">8</span> Inputs & outputs for the XML interface </a></h1>
-<h2 id="mixture-models-in-phyml"><a href="#mixture-models-in-phyml"><span class="header-section-number">8.1</span> Mixture models in PhyML</a></h2>
-<p>[sec:mixtures]</p>
-<p>PhyML implements a wide range of mixture models. The discrete gamma model <span class="citation"></span> is arguably the most popular of these models in phylogenetics. However, in theory, mixture models are not restricted to the description of the variation of substitution rates across sites. For instance, if there are good reasons to believe that the relative rates of substitution between nucleotides vary along the sequence alignments, it makes sense to use a mixture of GTR models. C [...]
-<p>PhyML implements a generic framework that allows users to define mixtures on substitution rates, rate matrices and nucleotide or amino-acid equilibrium frequencies. Each class of the mixture model is built by assembling a substitution rate, a rate matrix<a href="#fn1" class="footnoteRef" id="fnref1"><sup>1</sup></a> and a vector of equilibrium frequencies. For instance, let <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo stretchy="false">{</mo><msub><mi>R</ [...]
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"><mi>Pr</mi><mo stretchy="false">(</mo><msub><mi>D</mi><mi>s</mi></msub><mo stretchy="false">)</mo><mo>=</mo><munderover><mo>∑</mo><mrow><mi>c</mi><mo>=</mo><mn>1</mn></mrow><mn>3</mn></munderover><mi>Pr</mi><mo stretchy="false">(</mo><msub><mi>D</mi><mi>s</mi></msub><mo stretchy="false">∣</mo><msub><mtext mathvariant="script">𝒞</mtext><mi>s</mi></msub><mo>=</mo><mi>c</mi><mo st [...]
-<p>where <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Pr</mi><mo stretchy="false">(</mo><msub><mtext mathvariant="script">𝒞</mtext><mi>s</mi></msub><mo>=</mo><mi>c</mi><mo stretchy="false">)</mo></mrow></math> is obtained by multiplying the probability (density) of the three components (i.e., rate, matrix, frequencies). For instance, <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Pr</mi><mo stretchy="false">(</mo><msub><mtext ma [...]
-<p>Note that, using the same substitution rates, rate matrices and vector of equilibrium frequencies, it is possible to construct many other mixture models. For instance, the mixture model with the largest number of classes can be created by considering all the combinations of these three components. We would then get a mixture of <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mn>3</mn><mo>×</mo><mn>2</mn><mo>×</mo><mn>2</mn><mo>=</mo><mn>12</mn></mrow></math> c [...]
-<h2 id="partitions"><a href="#partitions"><span class="header-section-number">8.2</span> Partitions</a></h2>
-<p>We first introduce some terms of vocabulary that have not been presented before. A partitionned data set, also referred to as partition, is a set of partition elements. Typically, a partitionned data set will be made of a set of distinct gene alignments. A partition element will then correspond to one (or several) of these gene alignments. Note that the biology litterature often uses the term partition to refer to an element of a partitionned data. We thus use here instead the mathema [...]
-<p>Phylogenetics models usually assume individual columns of an alignment to evolve independently from one another. Codon-based models (e.g., <span class="citation"></span>) are exceptions to this rule since the substitution process applies here to triplets of consecutive sites of coding sequences. The non-independence of the substitution process at the three coding positions (due to the specificities of the genetic code), can therefore be accounted for. Assuming that sites evolve indepe [...]
-<p>Some parameters of the phylogenetic model are considered to be common to all the sites in the alignment. The tree topology is typically one such parameter. The transition/transversion ratio is also generally assumed to be the same for all columns. Other parameters can vary from site to site. The rate at which substitutions accumulate is one of these parameters. Hence, different sites can have distinct rates. However, such rates are all “drawn” from the same probabilitic distribution ( [...]
-<p>This reasonning also applies on a larger scale. When analysing multiple genes, one can indeed assume that the same mechanism generated the different site patterns observed for every gene. Here again, we can assume that all the genes share the same underlying tree topology (commonly refered to as the “species tree”). Other parameters of the phylogenetic model, such as branch lengths for instance, might be shared across genes. However, due to the specificities of the gene evolution proc [...]
-<p>The likelihood of a data set made of the concatenation of <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>n</mi></mrow></math> sequence alignments noted <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msup></mrow></math>, <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>D</mi><mrow><mo stretchy="false">(</mo [...]
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"><mi>Pr</mi><mo stretchy="false">(</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msup><mo>,</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msup><mo>,</mo><mo>…</mo><mo>,</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msup><m [...]
-<p>where <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>L</mi><mi>i</mi></msub></mrow></math> is the number of site columns in partition element <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>i</mi></mrow></math>. <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Pr</mi><mo stretchy="false">(</mo><msubsup><mi>D</mi><mi>s</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="false">)</mo></mro [...]
-<p>PhyML implements a wide variety of partition models. The only parameter that is constrained to be shared by all the partition elements is the tree topology. This constraint makes sense when considering distantly related taxa, typically inter-species data. For closely related taxa, i.e., when analysing intra-species or population-level data, not all the genes might have the same evolutionary history. Recombination events combined to the incomplete lineage sorting phenomenon can generat [...]
-<p>Aside from the tree topology that is common to all the sites and all the partition elements, other parameters of the phylogenetic model can be either shared across partition elements or estimated separately for each of these. When analysing three partition elements, <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>A</mi></mrow></math>, <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>B</mi></mrow></math> and <math display="inline"  [...]
-<h2 id="combining-mixture-and-partitions-in-phyml-the-theory"><a href="#combining-mixture-and-partitions-in-phyml-the-theory"><span class="header-section-number">8.3</span> Combining mixture and partitions in PhyML: the theory</a></h2>
-<p>The rationale behind mixture models as implemented in PhyML lies in (1) the definition of suitable rate matrices, equilibrium frequency vectors and relative rates of substitution and (2) the assembly of these components so as to create the classes of a mixture. The main idea behind partitionned analysis in PhyML lies in (1) the hypothesis of statistical independance of the different data partition elements and (2) distinct data partition can share model components such as rate matrice [...]
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"><mi>Pr</mi><mo stretchy="false">(</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msup><mo>,</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msup><mo>,</mo><mo>…</mo><mo>,</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mi>n</mi><mo stretchy="false">)</mo></mrow></msup><m [...]
-<p>where <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>L</mi><mi>i</mi></msub></mrow></math> is the number of sites in partition element <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>i</mi></mrow></math> and <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>K</mi><mi>i</mi></msub></mrow></math> is the number of classes in the mixture model that applies to this same partition element. Each cl [...]
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"></mtd><mtd columnalign="left"></mtd><mtd><mi>Pr</mi><mo stretchy="false">(</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mn>1</mn><mo stretchy="false">)</mo></mrow></msup><mo>,</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo></mrow></msup><mo>,</mo><mo>…</mo><mo>,</mo><msup><mi>D</mi><mrow><mo stretchy="false">(</mo><mi>n</mi><m [...]
-<p>where <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mtext mathvariant="script">ℳ</mtext><mi>i</mi></msub></mrow></math>, <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mtext mathvariant="script">ℱ</mtext><mi>i</mi></msub></mrow></math> and <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mtext mathvariant="script">ℛ</mtext><mi>i</mi></msub></mrow></math> are the number of rate matrices, vect [...]
-<p>As stated before, our implementation assumes that the different components of a mixture are independant. In other words, we have <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Pr</mi><mo stretchy="false">(</mo><msubsup><mi>M</mi><mi>m</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="false">)</mo></mrow></msubsup><mo>,</mo><msubsup><mi>F</mi><mi>f</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="false">)</mo></mrow></msubsup><mo>,</m [...]
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"><mi>Pr</mi><mo stretchy="false">(</mo><msubsup><mi>M</mi><mi>m</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="false">)</mo></mrow></msubsup><mo>,</mo><msubsup><mi>F</mi><mi>f</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="false">)</mo></mrow></msubsup><mo>,</mo><msubsup><mi>R</mi><mi>r</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="fals [...]
-<p>The probabilities <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Pr</mi><mo stretchy="false">(</mo><msubsup><mi>M</mi><mi>m</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="false">)</mo></mrow></msubsup><mo stretchy="false">)</mo></mrow></math>, <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>Pr</mi><mo stretchy="false">(</mo><msubsup><mi>F</mi><mi>f</mi><mrow><mo stretchy="false">(</mo><mi>i</mi><mo stretchy="false" [...]
-<h2 id="sec:XML format"><a href="#sec:XML format"><span class="header-section-number">8.4</span> The XML format and its use in PhyML</a></h2>
-<p>The few paragraphs below are largely inspired from the Wikipedia page that describes the XML format (<a href="http://en.wikipedia.org/wiki/XML">http://en.wikipedia.org/wiki/XML</a>). XML (eXtensible Markup Language) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. An XML document is divided into <span><em>markup</em></span> and <span><em>content</em></span>, which may be distinguished by the applicati [...]
-<pre><code><markup>
- content
-</markup></code></pre>
-<p>A markup construct that begins with ‘<code><</code>’ and ends with ‘<code>></code>’ is called a <span><em>tag</em></span>. Tags come in three flavors: (1) start-tags (e.g, <code><section></code>), end-tags (e.g., <code></section></code>) and empty-element tags (e.g., <code><line-break /></code>). A <span><em>component</em></span> either begins with a start-tag and ends with a matching end-tag or consists only of an empty-element tag. The characters between the  [...]
-<p>In practice, building a mixture model in a XML file readable by PhyML is relatively straightforward. The first step is to define the different components of each class of the mixture. Consider for instance that the fitted model will have a Gamma distribution with four classes plus a proportion of invariants. The rate component of the mixture can then be specified using the following XML code:</p>
-<pre><code>
-<siterates id="SiteRates1">
-  <weights  id="Distrib" family="gamma+inv" alpha=".1" \
-  optimise.alpha="yes" pinv="0.4" optimise.pinv="yes">
-  </weights>
-  <instance id="R1" init.value="1.0"/>
-  <instance id="R2" init.value="1.0"/>
-  <instance id="R5" init.value="0.0"/>
-  <instance id="R3" init.value="1.0"/>
-  <instance id="R4" init.value="1.0"/>
-</siterates></code></pre>
-<p>In the example above, the <code><siterates></code> component completely defines a model of substitution rate variation across sites. This component has a particular identity, i.e., a name associated to it (“<code>SiteRates1</code>” here), which is not mandatory. This <code><siterates></code> component has six sub-components. The first is the <code><weights></code> component, followed by five <code><instance></code> components. The <code><weights></code> c [...]
-<p>Having specified the part of the phylogenetic model that describes the variation of rates across sites, we can now move on to build the rest of the model. The component below defines two substitution models:</p>
-<pre><code>
-<ratematrices id="RateMatrices">
-  <instance id="M1" model="HKY85" tstv="4.0" optimise.tstv="no"/>
-  <instance id="M2" model="GTR" optimise.rr="yes"/>
-</ratematrices></code></pre>
-<p>This <code><ratematrices></code> component sets out a list of substitution models (HKY85 and GTR here). Here again, the different elements in this list correspond to the <code><instance></code> sub-components. Each instance must have a unique <code>id</code> attribute for a reason that will become obvious shortly. The remaining attributes and their functions are described in Section [sec:xmlratematrices].</p>
-<p>The next “ingredient” in our phylogenetic model are vectors of nucleotide frequencies. The <code><equfreqs></code> component below specifies two of such vectors:</p>
-<pre><code>
-<equfreqs id="EquFreq">
-  <instance id="F1"/>
-  <instance id="F2"/>
-</equfreqs></code></pre>
-<p>Now, we need to assemble these three components (rate variation across sites, rate matrices and vectors of equilibrium frequencies) into a mixture model. The <code><partitionelem></code> component below defines one such model:</p>
-<pre><code>
-<partitionelem id="Part1" file.name="./nucleic.txt" data.type="nt">
-  <mixtureelem list="R1, R2, R3, R4, R5"/>
-  <mixtureelem list="M1, M1, M1, M2, M2"/>
-  <mixtureelem list="F1, F2, F1, F2, F2"/>
-</partitionelem></code></pre>
-<p>The <code><partitionelem></code> component defines a particular partition element. In this example, the partition element corresponds to the sequence file called <code>nucleic.txt</code>, which is an alignment of nucleotide sequences (see the <code>data.type</code> attribute value). The <code><mixtureelem></code> are sub-components of the <code><partitionelem></code> component. Each <code><mixtureelem></code> has a <code>list</code> atrribute. Each such <code>l [...]
-<h2 id="setting-up-mixture-and-partition-models-in-phyml-the-basics"><a href="#setting-up-mixture-and-partition-models-in-phyml-the-basics"><span class="header-section-number">8.5</span> Setting up mixture and partition models in PhyML: the basics</a></h2>
-<p>Mixture models are particularly relevant to the analysis of partitionned data. Indeed, some features of evolution are gene-specific (e.g., substitution rates vary across genes). Models that can accomodate for such variation, as mixture models do, are therefore relevant in this context. However, other evolutionary features are shared across loci (e.g., genes located in the same genomic region usually have similar GC contents). As a consequence, some components of mixture models need to [...]
-<p>Below is a simple example with a partitionned data set made of two elements:</p>
-<pre><code>
-<branchlengths id="BranchLens">
-  <instance id="L1"/>
-  <instance id="L2"/>
-</branchlengths>
-
-<partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-  <mixtureelem list="R1, R2, R3, R4, R5"/>
-  <mixtureelem list="L1, L1, L1, L1, L1"/>
-</partitionelem>
-
-<partitionelem id="Part2" file.name="./nucleic2.txt" data.type="nt">
-  <mixtureelem list="R1, R2, R3, R4, R5"/>
-  <mixtureelem list="L2, L2, L2, L2, L2"/>
-</partitionelem></code></pre>
-<p>Mixture elements with names <code>R1</code>,<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>…</mo></mrow></math>, <code>R5</code> refer to the <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo><mn>4</mn><mo>+</mo></mrow></math>I model defined previsouly (see Section [sec:XML format]). The <code><branchlengths></code> XML component defines a mixture element that had not been introduced before. It defined vectors of branc [...]
-<p>Note that a given partition element can only have one <span>branchlengths</span> instance associated to it. For instance, the example given below is not valid:</p>
-<pre><code>
-<partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-  <mixtureelem list="R1, R2, R3, R4, R5"/>
-  <mixtureelem list="L1, L1, L1, L2, L2"/>
-</partitionelem></code></pre>
-<p>In other words, mixture of branch lengths are forbidden. One reason for this restriction is that mixture of edge lengths sometimes lead to non-identifiable models (i.e., models with distinct sets of branch lengths have the same likelihood) <span class="citation"></span>. But mostly, combining mixture of branch lengths with mixture of rates appears like a deadly combination. Consider for instance the following model:</p>
-<pre><code>
-<partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-  <mixtureelem list="R1, R2, R3"/>
-  <mixtureelem list="L1, L2, L3"/>
-</partitionelem></code></pre>
-<p>It is here impossible to tell apart branch lengths and substitution rates. Such model is strongly non-identifiable and therefore not relevant.</p>
-<p>In the example given above, the same <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo><mn>4</mn><mo>+</mo></mrow></math>I model (i.e. the same gamma shape parameter and proportion of invariant ) applies to the two partition elements. It is possible to use two distinct <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo><mn>4</mn><mo>+</mo></mrow></math>I models instead using the following XML code:</p>
-<pre><code>
-<siterates id="SiteRates1">
-  <weights  id="Distrib1" family="gamma+inv" alpha=".1" \
-  optimise.alpha="yes" pinv="0.4" optimise.pinv="yes">
-  </weights>
-  <instance id="R1" init.value="1.0"/>
-  <instance id="R2" init.value="1.0"/>
-  <instance id="R5" init.value="0.0"/>
-  <instance id="R3" init.value="1.0"/>
-  <instance id="R4" init.value="1.0"/>
-</siterates>
-
-<siterates id="SiteRates2">
-  <weights  id="Distrib2" family="gamma+inv" alpha=".1" \
-  optimise.alpha="yes" pinv="0.4" optimise.pinv="yes">
-  </weights>
-  <instance id="R6"  init.value="1.0"/>
-  <instance id="R7"  init.value="1.0"/>
-  <instance id="R8"  init.value="0.0"/>
-  <instance id="R9"  init.value="1.0"/>
-  <instance id="R10" init.value="1.0"/>
-</siterates>
-
-<partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-  <mixtureelem list="R1, R2, R3, R4, R5"/>
-  <mixtureelem list="L1, L1, L1, L1, L1"/>
-</partitionelem>
-
-<partitionelem id="Part2" file.name="./nucleic2.txt" data.type="nt">
-  <mixtureelem list="R6, R7, R8, R9, R10"/>
-  <mixtureelem list="L2, L2, L2, L2, L2"/>
-</partitionelem></code></pre>
-<p><code>SiteRates1</code> and <code>SiteRates2</code> here define two distinct <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo><mn>4</mn><mo>+</mo></mrow></math>I models. Each of these models apply to one of the two partition elements (<code>nucleic1.txt</code> and <code>nucleic2.txt</code>), allowing them to display different patterns of rate variation across sites.</p>
-<h2 id="xml-options"><a href="#xml-options"><span class="header-section-number">8.6</span> XML options</a></h2>
-<h3 id="phyml-component"><a href="#phyml-component"><span class="header-section-number">8.6.1</span> <span>phyml</span> component</a></h3>
-<p>Options:</p>
-<ul>
-<li><p><code>output.file=filename</code>. The main output files of PhyML analysis will be named <code>filename_phyml_tree</code> and <code>filename_phyml_stats</code>.</p></li>
-<li><p><code>bootstrap=nreplicates</code>. Run <code>nreplicates</code> replicates for the non-parametric bootstrap analysis.</p></li>
-<li><p><code>run.id=idstring</code>. PhyML will append the string <code>idstring</code> to each output file.</p></li>
-<li><p><code>print.trace=yes|true|no|false</code>. PhyML will print the estimated trees (and the corresponding loglikelihoods) at multiple stages of the estimation process. This option is useful for monitoring the progress of the analysis when processing large data sets.</p></li>
-<li><p><code>branch.test=aBayes|aLRT|SH|no</code>. Calculate fast branch support using the aBayes method <span class="citation"></span>, aLRT <span class="citation"></span> or SH <span class="citation"></span> tests. These branch statistics are much faster to estimate than the bootrap proportions and usually provide good estimates of the probabilities that the corresponding edges are correctly inferred (see Anisimova et al. 2011 for more precision). By default and if no bootstrap analysi [...]
-</ul>
-<h3 id="topology-component"><a href="#topology-component"><span class="header-section-number">8.6.2</span> <span>topology</span> component</a></h3>
-<p>Options:</p>
-<ul>
-<li><p><code>init.tree=bionj|user|random</code>. Starting tree. Default is <code>bionj</code>.</p></li>
-<li><p><code>file.name=name_of_tree_file</code>. In case <code>init.tree=user</code>, this attribute is mandatory. <code>name_of_tree_file</code> is a text file containing a tree in NEWICK format.</p></li>
-<li><p><code>optimise.tree=yes|true|no|false</code>. The starting tree topology as defined by <code>init.tree</code> is to be optimised (or not) so as to maximise the likelihood function.</p></li>
-<li><p><code>search=nni|spr|none</code>. Tree topology search is conducted using NNI (fast), SPR (a bit slower but more accurate) or no moves.</p></li>
-</ul>
-<pre><code>
-<topology>
-  <instance id="T1" init.tree="bionj" optimise.tree="true" \
-   search="spr"/>
-</topology></code></pre>
-<h3 id="ratematrices-component"><a href="#ratematrices-component"><span class="header-section-number">8.6.3</span> <span>ratematrices</span> component</a></h3>
-<p>[sec:xmlratematrices] Options:</p>
-<ul>
-<li><p><code>model=JC69|K80|F81|F84|HKY85|TN93|GTR|custom</code> for nucleotide data. The default is <code>HKY85</code>.<br /><code>model=LG|WAG|JTT|MtREV|Dayhoff|DCMut|RtREV|CpREV|VT</code><br /><code>|Blosum62|MtMam|MtArt|HIVw|HIVb|customaa</code> for amino-acid sequences. The default is <code>LG</code>.</p></li>
-<li><p><code>model.code=012345</code>. For <code>custom</code> model applied to nucleotide sequences: set the string of digits that define a custom substitution model. See Table [tab:modelcode] on page for more information about the model codes.</p></li>
-<li><p><code>ratematrix.code=filename</code>. When used in conjunction with <code>model=customaa</code>, <code>filename</code> is the name of the file that gives the rates of substitution between amino-acids as well as their frequences at equilibrium using PAML rate matrix format. An example of such file is provided in <span>phyml/examples/X1.mat</span>.</p></li>
-<li><p><code>optimise.rr=yes|true|no|false</code>. For <code>custom</code> and <code>GTR</code> nucleotide models only: optimise the substitution rate model parameters.</p></li>
-<li><p><code>optimise.tstv=yes|true|no|false</code>. For <code>K80</code>, <code>F84</code>, <code>HKY85</code> and <code>TN93</code> models only: optimise the transition/transversion rate ratio.</p></li>
-<li><p><code>tstv=value</code>. For <code>K80</code>, <code>HKY85</code> and <code>TN93</code> models only: set the transition/transversion to a given value.</p></li>
-</ul>
-<p>The <span>ratematrices</span> component has the attribute <span>optimise.weights=yes/no</span> (default is <span>no</span>). If <span>optimise.weights=yes</span>, then the probabilities (or weights) or each matrix in the set of matrices defined by this component (see Equation [equ:weights]), will be estimated from the data.</p>
-<pre><code>
-  <ratematrices id="RM1" optimise.weights="yes">
-    <instance id="M1" model="custom" model.code="000000"/>
-    <instance id="M2" model="GTR" optimise.rr="yes"/>
-    <instance id="M3" model="WAG"/>
-  </ratematrices></code></pre>
-<h3 id="equfreqs-component"><a href="#equfreqs-component"><span class="header-section-number">8.6.4</span> <span>equfreqs</span> component</a></h3>
-<p>Options:</p>
-<ul>
-<li><p><code>base.freqs=a,b,c,d</code> where <code>a-d</code> are nucleotide frequencies. Make sure that these frequencies are separated by comas and no space character is inserted.</p></li>
-<li><p><code>aa.freqs=empirical|model</code>. Amino-acid frequencies are derived from counting the number of occurence of each amino-acid in the alignment (<code>aa.freqs=empirical</code>) or given by the substitution model (<code>aa.freqs=model</code>).</p></li>
-<li><p><code>optimise.freqs=true|yes|false|no</code>. Nucleotide frequencies can be optimised so as to maximise the likelihood (<code>optimise.freqs=yes|true</code>).</p></li>
-</ul>
-<p>The <span>equfreqs</span> component has the attribute <span>optimise.weights=yes/no</span> (default is <span>no</span>). If <span>optimise.weights=yes</span>, then the probabilities (or weights) or each vector of equilibrium frequencies in the set of vectors defined by this component (see Equation [equ:weights]), will be estimated from the data.</p>
-<pre><code>
-  <equfreqs id="EF1" optimise.weights="yes">
-    <instance id="F1" base.freqs="0.25,0.25,0.25,0.25"/>
-    <instance id="F2" aa.freqs="empirical"/>
-    <instance id="F3" optimise.freq="yes"/>
-  </equfreqs></code></pre>
-<h3 id="branchlengths-component"><a href="#branchlengths-component"><span class="header-section-number">8.6.5</span> <span>branchlengths</span> component</a></h3>
-<p>Options:</p>
-<ul>
-<li><p><code>optimise.lens=yes|true|no|false</code>: branch lengths are optimised or not. The default is set to <code>yes</code>.</p></li>
-</ul>
-<pre><code>
-  <branchlengths id="BL1">
-    <instance id="L1" optimise.lens="yes"/>
-    <instance id="L2"/>
-    <instance id="L3" optimise.lens="false"/>
-  </branchlengths></code></pre>
-<h3 id="siterates-component"><a href="#siterates-component"><span class="header-section-number">8.6.6</span> <span>siterates</span> component</a></h3>
-<p>Options:</p>
-<ul>
-<li><p><code>value=val</code>, where <code>val</code> is the relative substitution rate for the corresponding class.</p></li>
-</ul>
-<p>A <code>siterate</code> component generally includes a <code>weights</code> element that specifies the probabilitic distribution of the relative rates. The available options for such element are:</p>
-<ul>
-<li><p><code>family=gamma|gamma+inv|freerates</code>. <code>gamma</code> indicates that the distribution of the relative rates is set to be a discrete Gamma density. <code>gamma+inv</code> indicates that the relative rate model is a mixture of Gamma and invariant sites (this is the common <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo><mo>+</mo></mrow></math>I model). FreeRate is a model that does not use any parametric function to describe the distribu [...]
-<li><p><code>alpha=value|optimised</code>, where <code>value</code> is a real positive number. Use this option to set the gamma shape parameter to the selected value. <code>optimised</code>: the parameter is estimated from the data (see also next option).</p></li>
-<li><p><code>optimise.alpha=yes|true|no|false</code>. Optimise the shape of the Gamma distribution of relative rates (or not).</p></li>
-<li><p><code>pinv=value|optimised</code>, where <code>value</code> is in <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo stretchy="false">[</mo><mn>0</mn><mo>,</mo><mn>1</mn><mo stretchy="false">]</mo></mrow></math>. Use this option to set the proportion of invariants to the selected value. <code>optimised</code>: the parameter is estimated from the data (see also next option).</p></li>
-<li><p><code>optimise.pinv=yes|true|no|false</code>. Optimise the proportion of invariable sites (or not).</p></li>
-<li><p><code>optimise.freerates=yes|true|no|false</code>. Optimise the parameters of the FreeRate model, i.e., the relative rates and the corresponding frequencies.</p></li>
-</ul>
-<pre><code>
-  <siterates id="SR1">
-    <instance id="R1" init.value="1.0"/>
-    <instance id="R2" init.value="1.0"/>
-    <instance id="R3" init.value="1.0"/>
-    <instance id="R4" init.value="1.0"/>
-    <weights  id="D1" family="gamma" optimise.alpha="yes" \
-    optimise.pinv="no">
-    </weights>
-  </siterates></code></pre>
-<h3 id="partitionelem-and-mixtureelem-components"><a href="#partitionelem-and-mixtureelem-components"><span class="header-section-number">8.6.7</span> <span>partitionelem</span> and <span>mixtureelem</span> components</a></h3>
-<p>Options:</p>
-<ul>
-<li><p><code>file.name=inputfilename</code>, where <code>inputfilename</code> is the name of the input sequence file (in PHYLIP format) to be analysed.</p></li>
-<li><p><code>data.type=nt|aa</code>. Specify the type of sequences to be processed (nucleotide of amino-acid sequences).</p></li>
-<li><p><code>interleaved=yes|true|no|false</code>. Interleaved (<code>yes|true</code>) or sequential format (<code>no|false</code>) for the sequence alignment.</p></li>
-</ul>
-<p>Each <code>partitionelem</code> element should include exactly four <code>mixtureelem</code> elements, corresponding to branch lengths, equilibrium frequencies, substitution rate model and tree topology. The ordering of in which the <code>mixtureelem</code> elements are given does not matter, though exceptions apply for the <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo><mo>+</mo><mi>I</mi></mrow></math> model (see below). The <math display="inline"  [...]
-<pre><code>
-  <partitionelem id="partition1" file.name="./small_p1.nxs" \
-   data.type="nt" interleaved="yes">
-    <mixtureelem list="T1, T1, T1, T1"/>
-    <mixtureelem list="F1, F1, F1, F1"/>
-    <mixtureelem list="R1, R2, R3, R4"/>
-    <mixtureelem list="L1, L1, L1, L1"/>
-  </partitionelem></code></pre>
-<p>In general, the ordering of the <code>mixtureelem</code> elements does not matter. However, when the model has invariable sites, then the corresponding class should be first in the list of classes provided by <code>mixtureelem</code>. For instance, in the example above, if the rates are defined as follows:</p>
-<pre><code>
-  <siterates id="SR1">
-    <instance id="R1" init.value="0.0"/>
-    <instance id="R2" init.value="1.0"/>
-    <instance id="R3" init.value="1.0"/>
-    <instance id="R4" init.value="1.0"/>
-    <weights  id="D1" family="gamma+inv" optimise.alpha="yes" \
-    optimise.pinv="no">
-    </weights>
-  </siterates></code></pre>
-<p>then <code>R1</code> corresponds to the invariable rate class (as <code>init.value=0.0</code>). As <code>R1</code> is first in the <code>mixtureelem</code> (see line 6 in the example of <code>partionelem</code> given above), PhyML will print out an explicit error message and bail out. One way to avoid this shortcoming is to define <code>mixtureelem</code> as <code>R4, R2, R3, R1</code> instead.</p>
-<h2 id="a-simple-example-gtr-gamma4-i"><a href="#a-simple-example-gtr-gamma4-i"><span class="header-section-number">8.7</span> A simple example: GTR + <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo></mrow></math>4 + I</a></h2>
-<p>The example below provides all the required options to fit a <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>Γ</mo></mrow></math>4+I model to a single alignment of nucleotide sequences under the GTR model of substitution using a SPR search for the best tree topology. The <code>phyml</code> component sets the name for the analysis to <code>simple.example</code>, meaning that each output file will display this particular string of characters. Also, the tree a [...]
-<pre><code>
-<phyml runid="simple.example" output.file="p1.output">
-
-  <topology>
-    <instance id="T1" init.tree="bionj" optimise.tree="yes" \
-    search="spr"/>
-  </topology>
-
-  <branchlengths id="BL1">
-    <instance id="L1" optimise.lens="yes"/>
-  </branchlengths>
-
-  <ratematrices id="RM1">
-    <instance id="M1" model="GTR"/>
-  </ratematrices>
-
-  <equfreqs id="EF1">
-    <instance id="F1"/>
-  </equfreqs>
-
-  <siterates id="SR1">
-    <instance id="R1" value="1.0"/>
-    <instance id="R2" value="1.0"/>
-    <instance id="R3" value="1.0"/>
-    <instance id="R4" value="1.0"/>
-    <instance id="R5" value="0.0"/>
-    <weights  id="D1" family="gamma+inv" optimise.alpha="yes" \
-    optimise.pinv="yes">
-    </weights>
-  </siterates>
-
-  <partitionelem id="partition_elem1" file.name=\
-  "./p1.seq" data.type="nt" interleaved="yes">
-    <mixtureelem list="T1, T1, T1, T1, T1"/>
-    <mixtureelem list="M1, M1, M1, M1, M1"/>
-    <mixtureelem list="F1, F1, F1, F1, F1"/>
-    <mixtureelem list="R1, R2, R3, R4, R5"/>
-    <mixtureelem list="L1, L1, L1, L1, L1"/>
-  </partitionelem>
-
-</phyml></code></pre>
-<h2 id="a-second-example-lg4x"><a href="#a-second-example-lg4x"><span class="header-section-number">8.8</span> A second example: LG4X</a></h2>
-<p>The example below shows how to fit the LG4X model <span class="citation"></span> to a given alignment of amino-acid sequences (file <code>M587.nex.Phy</code>). LG4X is a mixture model with four classes. Each class has its own rate and corresponding frequencies (hence the use of the FreeRate model below, see the <code><siterates></code> component). In the particular example given here, the rate values and frequencies are set by the users. These parameters will then be optimized b [...]
-<pre><code><phyml run.id="lg4x" output.file="M587.tests" branch.test="no">
-
-  <!-- Tree topology: start with BioNJ and then SPRs -->
-  <topology>
-    <instance id="T1" init.tree="user" file.name="user_tree.txt" \
-    search="spr" optimise.tree="no"/>
-  </topology>
-
-
-  <!-- Four rate matrices, read from files -->
-  <ratematrices id="RM1">
-    <instance id="M1" model="customaa" ratematrix.file="X1.mat"/>
-    <instance id="M2" model="customaa" ratematrix.file="X2.mat"/>
-    <instance id="M3" model="customaa" ratematrix.file="X3.mat"/>
-    <instance id="M4" model="customaa" ratematrix.file="X4.mat"/>
-  </ratematrices>
-
-  <!-- Freerate model of variation of rates across sites -->
-  <siterates id="SR1">
-    <instance id="R1" init.value="0.197063"/>
-    <instance id="R2" init.value="0.750275"/>
-    <instance id="R3" init.value="1.951569"/>
-    <instance id="R4" init.value="5.161586"/>
-    <weights  id="D1" family="freerates" optimise.freerates="yes">
-      <instance appliesto="R1" value="0.422481"/>
-      <instance appliesto="R2" value="0.336848"/>
-      <instance appliesto="R3" value="0.180132"/>
-      <instance appliesto="R4" value="0.060539"/>
-    </weights>
-  </siterates>
-
-  <!-- Amino-acid equilibrium freqs. are given by the models -->
-  <equfreqs id="EF1">
-    <instance id="F1" aa.freqs="model"/>
-    <instance id="F2" aa.freqs="model"/>
-    <instance id="F3" aa.freqs="model"/>
-    <instance id="F4" aa.freqs="model"/>
-  </equfreqs>
-
-
-  <!-- One vector of branch lengths -->
-  <branchlengths id="BL1" >
-    <instance id="L1" optimise.lens="yes"/>
-  </branchlengths>
-
-
-  <!-- Mixture model assemblage -->
-  <partitionelem id="partition1" file.name="M587.nex.Phy" \
-  data.type="aa" interleaved="yes">
-    <mixtureelem list="T1, T1, T1, T1"/>
-    <mixtureelem list="M1, M2, M3, M4"/>
-    <mixtureelem list="F1, F2, F3, F4"/>
-    <mixtureelem list="R1, R2, R3, R4"/>
-    <mixtureelem list="L1, L1, L1, L1"/>
-  </partitionelem>
-
-</phyml></code></pre>
-<p>In order to fit the LG4X model to the <code>proteic</code> sequence file provided in the <code>examples/</code> directory, simply type <code>./phyml –xml=../examples/lg4x/lg4x.xml</code> (assuming the PhyML binary is installed in the <code>src/</code> directory). You can of course slightly tweak the file <code>../examples/lg4x/lg4x.xml</code> and use it as a template to fit this model to another data set.</p>
-<h2 id="an-example-with-multiple-partition-elements"><a href="#an-example-with-multiple-partition-elements"><span class="header-section-number">8.9</span> An example with multiple partition elements</a></h2>
-<p>The example below gives the complete XML file to specify the analysis of three partition elements, corresponding to the nucleotide sequence files <code>small_p1_pos1.seq</code>, <code>small_p1_pos2.seq</code> and <code>small_p1_pos3.seq</code> in interleaved PHYLIP format. <code>small_p1_pos1.seq</code> is fitted with the HKY85 model of substitution (with the transition/transversion ratio being estimated from the data), combined to a <math display="inline" xmlns="http://www.w3.org/199 [...]
-<pre><code>
-<phyml runid="nnisearch" output.file="small_p1_output">
-
-  <topology>
-    <instance id="T1" init.tree="bionj" optimise.tree="yes" \
-    search="nni"/>
-  </topology>
-
-  <branchlengths id="BL1">
-    <instance id="L1" optimise.lens="yes"/>
-    <instance id="L2"/>
-    <instance id="L3"/>
-  </branchlengths>
-
-  <ratematrices id="RM1">
-    <instance id="M1" model="HKY85" optimise.tstv="yes"/>
-    <instance id="M2" model="custom" model.code="102304" \
-    optimise.rr="yes"/>
-    <instance id="M3" model="GTR"/>
-  </ratematrices>
-
-  <equfreqs id="EF1">
-    <instance id="F1"/>
-    <instance id="F2" base.freqs="0.25,0.25,0.25,0.25"/>
-    <instance id="F3"/>
-  </equfreqs>
-
-  <siterates id="SR1">
-    <instance id="R1" value="1.0"/>
-    <instance id="R2" value="1.0"/>
-    <instance id="R3" value="1.0"/>
-    <instance id="R4" value="1.0"/>
-    <weights  id="D1" family="gamma" optimise.alpha="yes" \
-    optimise.pinv="no">
-    </weights>
-  </siterates>
-
-  <siterates id="SR2">
-    <instance id="R8" value="1.0"/>
-    <weights  id="D2" family="gamma" optimise.alpha="yes" \
-    optimise.pinv="yes">
-    </weights>
-  </siterates>
-
-  <siterates id="SR3">
-    <instance id="R10" value="1.0"/>
-    <instance id="R11" value="1.0"/>
-    <instance id="R12" value="1.0"/>
-    <instance id="R13" value="1.0"/>
-    <instance id="R14" value="1.0"/>
-    <weights  id="D3" family="gamma" optimise.alpha="yes" \
-    optimise.pinv="yes">
-    </weights>
-  </siterates></code></pre>
-<pre><code>
-  <partitionelem id="partition_elem1" file.name=\
-  "./small_p1_pos1.seq" data.type="nt" interleaved="yes">
-    <mixtureelem list="T1, T1, T1, T1"/>
-    <mixtureelem list="M1, M1, M1, M1"/>
-    <mixtureelem list="F1, F1, F1, F1"/>
-    <mixtureelem list="R1, R2, R3, R4"/>
-    <mixtureelem list="L1, L1, L1, L1"/>
-  </partitionelem>
-
-  <partitionelem id="partition_elem2" file.name=\
-  "./small_p1_pos2.seq" data.type="nt" interleaved="yes">
-    <mixtureelem list="T1"/>
-    <mixtureelem list="M2"/>
-    <mixtureelem list="R8"/>
-    <mixtureelem list="F2"/>
-    <mixtureelem list="L2"/>
-  </partitionelem>
-
-  <partitionelem id="partition_elem3" file.name=\
-  "./small_p1_pos3.seq" data.type="nt" interleaved="yes">
-    <mixtureelem list="T1, T1, T1, T1, T1"/>
-    <mixtureelem list="M3, M3, M3, M3, M3"/>
-    <mixtureelem list="R10, R11, R12, R13, R14"/>
-    <mixtureelem list="F3, F3, F3, F1, F1"/>
-    <mixtureelem list="L3, L3, L3, L3, L3"/>
-  </partitionelem>
-
-</phyml></code></pre>
-<h2 id="branch-lengths-with-invariants-and-partionned-data"><a href="#branch-lengths-with-invariants-and-partionned-data"><span class="header-section-number">8.10</span> Branch lengths with invariants and partionned data</a></h2>
-<p>Accommodating for models with invariable sites applying to some elements of a partitioned data, with these elements sharing the same set of edge lengths can lead to inconsistencies. Consider for instance a partitioned data set with two elements. Assume that these two elements share the same set of edge lengths. Also, consider that GTR+I applies to the first element and HKY applies to the second. Now, the expected number of substitutions per site for the first element of the partition  [...]
-<h1 id="citing-phyml"><a href="#citing-phyml"><span class="header-section-number">9</span> Citing PhyML</a></h1>
-<p>The “default citation” for PhyML is:</p>
-<ul>
-<li><p>“New algorithms and methods to estimate maximum-likelihood phylogenies: assessing the performance of PhyML 3.0”. Guindon S., Dufayard J.F., Lefort V., Anisimova M., Hordijk W., Gascuel O. 2010, <span><em>Systematic Biology</em></span>, 59(3):307-321</p></li>
-</ul>
-<p>The “historic citation” for PhyML is:</p>
-<ul>
-<li><p>“A simple, fast and accurate algorithm to estimate large phylogenies by maximum likelihood” Guindon S., Gascuel O. 2003, <span><em>Systematic Biology</em></span>, 52(5):696-704</p></li>
-</ul>
-<h1 id="other-programs-in-the-phyml-package"><a href="#other-programs-in-the-phyml-package"><span class="header-section-number">10</span> Other programs in the PhyML package</a></h1>
-<p>PhyML is software package that provides tools to tackle problems other than estimating maximum likelihood phylogenies. Installing these tools and processing data sets is explained is the following sections.</p>
-<h2 id="phytime"><a href="#phytime"><span class="header-section-number">10.1</span> PhyTime</a></h2>
-<p>PhyTime is a program that estimates node ages and substitution rates using a Bayesian approach. The performance and main features of this software are described in two article (see Section [sec:citephytime]).</p>
-<p>It relies on a Gibbs sampler which outperforms the “standard” Metropolis-Hastings algorithm implemented in a number of phylogenetic softwares. The details and performance of this approach are described in the following article:</p>
-<h3 id="installing-phytime"><a href="#installing-phytime"><span class="header-section-number">10.1.1</span> Installing PhyTime</a></h3>
-<p>Compiling PhyTime is straightforward on Unix-like machines (i.e., linux and MacOS systems). PhyTime is not readily available for Windows machines but compilation should be easy on this system too. In the ‘phyml’ directory, where the ‘src/’ and ‘doc/’ directories stand, enter the following commands:</p>
-<pre><code>./configure --enable-phytime;
-make clean;
-make;</code></pre>
-<p>This set of commands generates a binary file called <code>phytime</code> which can be found in the ‘src/’ directory.</p>
-<h3 id="running-phytime"><a href="#running-phytime"><span class="header-section-number">10.1.2</span> Running PhyTime</a></h3>
-<p>Passing options and running PhyTime on your data set is quite similar to running PhyML in commmand-line mode. The main differences between the two programs are explained below:</p>
-<ul>
-<li><p>PhyTime takes as mandatory input a <span><em>rooted</em></span> phylogenetic tree. Hence, the ‘<code>-u</code>’ option must be used. Also, unlike PhyML, PhyTime does not modify the tree topology. Hence, the options that go with the ‘<code>-s</code>’ command do not alter the input tree topology.</p></li>
-<li><p>PhyTime needs an input file giving information about calibration nodes. The command ‘<code>–calibration=</code>’ followed by the name of the file containing the calibration node information is mandatory. The content of that file should look as follows:</p>
-<pre><code>Dugong_dugon Procavia_capensis Elephantidae | -65 -54
-Equus_sp. Ceratomorpha | -58 -54
-Cercopithecus_solatus Macaca_mulatta Hylobates_lar Homo_sapiens | -35 -25
-Lepus_crawshayi Oryctolagus_cuniculus Ochotona_princeps | -90 -37
-Marmota_monax Aplodontia_rufa | -120 -37
-Dryomys_nitedula Glis_glis | -120 -28.5
- at root@ | -100 -120</code></pre>
-<p>Every row in this file lists a set of taxa that belong to the same subtree (i.e., a clade). This list of taxa is followed by the character ‘<code>|</code>’ and two real numbers corresponding to the lower and upper bounds of the calibration interval for the node at the root of the clade. In the example given here, the clade grouping the three taxa “Dugong_dugon”, “Procavia_capensis” and “Elephantida” has -65 as lower bound and -54 as upper bound. Node ages (or node heights) are relativ [...]
-<pre><code>taxaA | -65 -65
-taxaB | -65 -65
-taxaC | -20 -20
-taxaD | -30 -30
-taxaE | -30 -30
-taxaF | -60 -60
-taxaG | -61 -51
- at root@ | -100 -120</code></pre>
-<p>Note that the node corresponding to the root of the whole tree has a specific label: ‘<code>@root@</code>’. As a consequence, leaving the prior on root height interval unspecified may produce inaccurate estimates of node ages, especially if there are only few otherwise calibration nodes available.</p>
-<p>A notable exception to this rule comes from the analysis of serial sample data, i.e., alignments in which sequences were not sampled at the same time point. For such data, the estimated number of substitutions accumulated between successive time points is used to estimate the substitution rate averaged over lineages. Because the time of collection of the sequences is generally known without ambiguity, this extra piece of data is translated into very informative calibration intervals f [...]
-</ul>
-<p>A typical PhyTime command-line should look like the following:</p>
-<pre><code>./phytime -i seqname -u treename --calibration=calibration_file -m GTR -c 8</code></pre>
-<p>Assuming the file ‘<code>seqname</code>’ contains DNA sequences in PHYLIP or NEXUS format, ‘<code>treename</code>’ is the rooted input tree in Newick format and ‘<code>calibration_file</code>’ is a set of calibration nodes, PhyTime will estimate the posterior distribution of node times and substitution rates under the assumption that the substitution process follows a GTR model with 8 classes of rates in the Gamma distribution of rates across sites. The model parameter values are esti [...]
-<h3 id="upper-bounds-of-model-parameters"><a href="#upper-bounds-of-model-parameters"><span class="header-section-number">10.1.3</span> Upper bounds of model parameters</a></h3>
-<p>The maximum expected number of substitutions per along a given branch is set to 1.0. Since calibration times provide prior information about the time scale considered, it is possible to use that information to define an upper bound for the substitution rate. This upper bound is equal to the ratio of the maximum value for a branch length (1.0) by the amount of time elapsed since the oldest calibration point (i.e., the minimum of the lower bounds taken over the whole set of calibration  [...]
-<p>PhyTime implements two models that authorize rates to be autocorrelated. The strength of autocorrelation is governed by a parameter which value is estimated from the data. However, it is necessary to set an appropriate upper bound for this parameter prior running the analysis. The maximum value is set such that the correlation between the rate at the beginning and at the end of a branch of length 1.0 calendar time unit is not different from 0. Here again the upper bound for the model  [...]
-<h3 id="phytime-specific-options"><a href="#phytime-specific-options"><span class="header-section-number">10.1.4</span> PhyTime specific options</a></h3>
-<p>Beside the <code>–calibration</code> option, there are other command line options that are specific to PhyTime:</p>
-<ul>
-<li><p><code>–chain_len=num</code><br /><code>num</code> is the number of iterations required to estimate the joint posterior density of all the model parameters, i.e., the length of the MCMC chain. Its default is set to 1E+6.</p></li>
-<li><p><code>–sample_freq=num</code><br /><code>num</code> is the number of generations between successive collection of the model parameter values throughout the MCMC algorithm. For instance, the <code>–sample_freq=1E+2</code> option will make PhyTime sample the model parameter every 100th iteration of the MCMC algorithm. Its default is set to 1E+3.</p></li>
-<li><p><code>–fastlk=yes (no)</code> [Default: no]<br />The option is used to turn on (off) the approximation of the likelihood function using a multivariate normal density. By default, the exact likelihood is used. Using the normal approximation considerably speeds up the calculation. However, it is necessary to ensure that this approximation is appropriate by looking at the correlation between the exact and approximated likelihood values that are sampled. Please read Section [sec:recom [...]
-<li><p><code>–no_sequences</code><br />Use this option to run the sampler without sequence data. This option can be useful when one wants to compare the marginal posterior density of model parameters to those derived when ignoring the information conveyed by the sequences. Such comparison should be conducted on a systematic basis so as to determine whether the parameters estimates are mostly determined by the prior of driven by the sequence data.</p></li>
-<li><p><code>–rate_model=gbs/gbd/gamma/clock</code><br />This option is to select the model of evolution of the rate of evolution. <code>gbs</code> (default) stands for Geometric Brownian + Stochastic. This model considers that rates evolve along the tree according to a geometric Brownian process <span class="citation"></span> and the average rate of substitution along a branch is a gamma distributed random variable. This model is described in <span class="citation"></span>. The <code>gb [...]
-</ul>
-<h3 id="phytime-output"><a href="#phytime-output"><span class="header-section-number">10.1.5</span> PhyTime output</a></h3>
-<p>The program PhyTime generates two output files. The file called ‘<code>your_seqfile_phytime.XXXX.stats</code>’, where XXXX is a randomly generated integer, lists the node times and branch relative rates sampled during the estimation process. It also gives the sampled values for other parameters, such as the autocorrelation of rates (parameter ‘Nu’), and the rate of evolution (parameter ‘EvolRate’) amongst others. This output file can be analysed with the program Tracer from the BEAST  [...]
-<p>Important information is also displayed on the standard output of PhyTime (the standard output generally corresponds to the terminal window from which PhyTime was launched). The first column of this output gives the current generation, or run, of the chain. It starts at 1 and goes up to 1E+6 by default (use <code>–chain_len</code> to change this value, see above). The second column gives the time elapsed in seconds since the sampling began. The third column gives the log likelihood of [...]
-<h3 id="clockrate-vs.-evolrate"><a href="#clockrate-vs.-evolrate"><span class="header-section-number">10.1.6</span> ClockRate vs. EvolRate</a></h3>
-<p>The average rate of evolution along a branch is broken into two components. One is called ClockRate and is the same throughout the tree. The other is called EvolRate and corresponds to a weighted average of branch-specific rates. The model of rate evolution implemented in PhyTime forces the branch-specific rate values to be greater than one. As a consequence, ClockRate is usually smaller EvolRate.</p>
-<p>In more mathematical terms, let <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>μ</mi></mrow></math> be the value of ClockRate, <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>r</mi><mi>i</mi></msub></mrow></math> be the value of the relative rate along branch <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>i</mi></mrow></math> and <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML" [...]
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"><mtext mathvariant="normal">EvolRate</mtext><mo>=</mo><mi>μ</mi><mfrac><mrow><munderover><mo>∑</mo><mi>i</mi><mrow><mn>2</mn><mi>n</mi><mo>−</mo><mn>3</mn></mrow></munderover><msub><mi>r</mi><mi>i</mi></msub><msub><mo>Δ</mo><mi>i</mi></msub></mrow><mrow><munderover><mo>∑</mo><mi>i</mi><mrow><mn>2</mn><mi>n</mi><mo>−</mo><mn>3</mn></mrow></munderover><msub><mo>Δ</mo><mi>i</mi></ [...]
-<p>It is clear from this equation that multiplying each <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>r</mi><mi>i</mi></msub></mrow></math> by a constant and dividing <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>μ</mi></mrow></math> by the same constant does not change the value of EvolRate. The <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>r</mi><mi>i</mi></msub></mrow></math>s and <ma [...]
-<h3 id="sec:ess"><a href="#sec:ess"><span class="header-section-number">10.1.7</span> Effective sample size</a></h3>
-<p>The MCMC technique generates samples from a target distribution (in our case, the joint posterior density of parameters). Due to the Markovian nature of the method, these samples are not independent. The ESS is the estimated number of independent measurements obtained from a set of (usually dependent) measurements. It is calculated using the following formula:</p>
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"><mtext mathvariant="normal">ESS</mtext><mo>=</mo><mi>N</mi><mrow><mo stretchy="true">(</mo><mfrac><mrow><mn>1</mn><mo>−</mo><mi>r</mi></mrow><mrow><mn>1</mn><mo>+</mo><mi>r</mi></mrow></mfrac><mo stretchy="true">)</mo></mrow><mo>,</mo></mtd></mtr></mtable></mrow></math></p>
-<p>where <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>N</mi></mrow></math> is the length of the chain (i.e., the ‘raw’ or ‘correlated’ sample size) and <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>r</mi></mrow></math> is the autocorrelation value, which is obtained using the following formula:</p>
-<p><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mtable><mtr><mtd columnalign="right"><mi>r</mi><mo>=</mo><mfrac><mn>1</mn><mrow><mo stretchy="false">(</mo><mi>N</mi><mo>−</mo><mi>k</mi><mo stretchy="false">)</mo><msubsup><mi>σ</mi><mi>x</mi><mn>2</mn></msubsup></mrow></mfrac><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mrow><mi>N</mi><mo>−</mo><mi>k</mi></mrow></munderover><mo stretchy="false">(</mo><msub><mi>X</mi><mi>i</mi></msub><mo>−</m [...]
-<p>where <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>μ</mi><mi>x</mi></msub></mrow></math> and <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>σ</mi><mi>x</mi></msub></mrow></math> are the mean and standard deviation of the <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msub><mi>X</mi><mi>i</mi></msub></mrow></math> values respectively and <math display="inline" xmlns="http://www.w3.org/1998 [...]
-<h3 id="sec:prior"><a href="#sec:prior"><span class="header-section-number">10.1.8</span> Prior distributions of model parameters</a></h3>
-<p>Any Bayesian analysis requires specifying a prior distribution of model parameters. The outcome of the data analysis, i.e., the posterior distribution, is influenced by the priors. It is especially true if the signal conveyed by the data is weak. While some have argued that the specification of priors relies more on arbitrary decisions than sound scientific reasoning, choosing relevant prior distributions is in fact fully integrated in the process of building model that generates the  [...]
-<h3 id="sec:citephytime"><a href="#sec:citephytime"><span class="header-section-number">10.1.9</span> Citing PhyTime</a></h3>
-<p>The “default citation” is:</p>
-<ul>
-<li><p>Guindon S. “From trajectories to averages: an improved description of the heterogeneity of substitution rates along lineages”, <span><em>Systematic Biology</em></span>, 2012. doi: 10.1093/sysbio/sys063.</p></li>
-</ul>
-<p>An earlier article also described some of the methods implemented in PhyTime:</p>
-<ul>
-<li><p>Guindon S. “Bayesian estimation of divergence times from large data sets”, <span><em>Molecular Biology and Evolution</em></span>, 2010, 27(8):1768:81.</p></li>
-</ul>
-<h2 id="phylogeo"><a href="#phylogeo"><span class="header-section-number">10.2</span> PhyloGeo</a></h2>
-<p>PhyloGeo is a program that implements the competition-dispersal phylogeography model described in Ranjard, Welch, Paturel and Guindon “Modelling competition and dispersal in a statistical phylogeographic framework”. Accepted for publication in <span><em>Systematic Biology</em></span>.</p>
-<p>It implements a Markov Chain Monte Carlo approach that samples from the posterior distribution of the three parameters of interest in this model, namely the competition intensity <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>λ</mi></mrow></math>, the dispersal bias parameter <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>σ</mi></mrow></math> and the overal dispersal rate <math display="inline" xmlns="http://www.w3.org/1998/Mat [...]
-<h3 id="installing-phylogeo"><a href="#installing-phylogeo"><span class="header-section-number">10.2.1</span> Installing PhyloGeo</a></h3>
-<p>Compiling PhyloGeo is straightforward on Unix-like machines (i.e., linux and MacOS systems). PhyloGeo is not readily available for Windows machines but compilation should be easy on this system too. In the ‘phyml’ directory, where the ‘src/’ and ‘doc/’ directories stand, enter the following commands:</p>
-<pre><code>./configure --enable-geo;
-make clean;
-make;</code></pre>
-<p>This set of commands generates a binary file called <code>phylogeo</code> which can be found in the ‘src/’ directory.</p>
-<h3 id="running-phylogeo"><a href="#running-phylogeo"><span class="header-section-number">10.2.2</span> Running PhyloGeo</a></h3>
-<p>PhyloGeo takes as input a rooted tree file in Newick format and a tree with geographical locations for all the tips of the phylogeny. Here is an example of valid tree and the corresponding spatial locations just below:</p>
-<pre><code>(((unicaA:1.30202,unicaB:1.30202):1.34596,(((nitidaC:0.94617,(nitidaA:0.31497,
-nitidaB:0.31497):0.63120):0.18955,(((mauiensisA:0.00370,mauiensisB:0.00370):0.20068,
-(pilimauiensisA:0.05151,pilimauiensisB:0.05151):0.15287):0.78769,(brunneaA:0.10582,
-brunneaB:0.10582):0.88625):0.14365):0.80126,(((molokaiensisA:0.03728,
-molokaiensisB:0.03728):0.71371,(deplanataA:0.01814,deplanataB:0.01814):0.73285):0.34764,
-((parvulaA:0.20487,parvulaB:0.20487):0.40191,(kauaiensisA:0.24276,
-kauaiensisB:0.24276):0.36401):0.49186):0.83835):0.71099):1.38043,
-(nihoaA:0.05673,nihoaB:0.05673):3.97168);</code></pre>
-<pre><code>nihoaA                  23.062222   161.926111
-nihoaB                  23.062222   161.926111
-kauaiensisA             22.0644445  159.5455555
-kauaiensisB             22.0644445  159.5455555
-unicaA                  21.436875   158.0524305
-unicaB                  21.436875   158.0524305
-parvulaA                21.436875   158.0524305
-parvulaB                21.436875   158.0524305
-molokaiensisA           20.90532    156.6499
-molokaiensisB           20.90532    156.6499
-deplanataA              20.90532    156.6499
-deplanataB              20.90532    156.6499
-brunneaA                20.90532    156.6499
-brunneaB                20.90532    156.6499
-mauiensisA              20.90532    156.6499
-mauiensisB              20.90532    156.6499
-pilimauiensisA          20.90532    156.6499
-pilimauiensisB          20.90532    156.6499
-nitidaA                 19.7362         155.6069
-nitidaB                 19.7362         155.6069
-nitidaC                 19.7362         155.6069</code></pre>
-<p>In order to run PhyloGeo, enter the following command: <code>./phylogeo ./tree_file ./spatial_location_file > phylogeo_output</code>. PhyloGeo will then print out the sampled values of the model parameters in the file <code>phylogeo_output</code>. This file can then be used to generate the marginal posterior densities of the model parameters. In particular, evidence for competition corresponds to value of <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>λ [...]
-<h3 id="sec:citephylogeo"><a href="#sec:citephylogeo"><span class="header-section-number">10.2.3</span> Citing PhyloGeo</a></h3>
-<p>Ranjard, L., Welch D., Paturel M. and Guindon S. “Modelling competition and dispersal in a statistical phylogeographic framework”. 2014. Systematic Biology.</p>
-<h1 id="sec:progusage"><a href="#sec:progusage"><span class="header-section-number">11</span> Recommendations on program usage</a></h1>
-<h2 id="phyml"><a href="#phyml"><span class="header-section-number">11.1</span> PhyML</a></h2>
-<p>The choice of the tree searching algorithm among those provided by PhyML is generally a tough one. The fastest option relies on local and simultaneous modifications of the phylogeny using NNI moves. More thorough explorations of the space of topologies are also available through the SPR options. As these two classes of tree topology moves involve different computational burdens, it is important to determine which option is the most suitable for the type of data set or analysis one wan [...]
-<ol>
-<li><p><span><em>Single data set, unlimited computing time.</em></span> The best option here is probably to use a SPR search (i.e., straight SPR of best of SPR and NNI). If the focus is on estimating the relationships between species, it is a good idea to use more than one starting tree to decrease the chance of getting stuck in a local maximum of the likelihood function. Using NNIs is appropriate if the analysis does not mainly focus on estimating the evolutionary relationships between  [...]
-<li><p><span><em>Single data set, restricted computing time.</em></span> The three tree searching options can be used depending on the computing time available and the size of the data set. For small data sets (i.e., <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo><</mo></mrow></math> 50 sequences), NNI will generally perform well provided that the phylogenetic signal is strong. It is relevant to estimate a first tree using NNI moves and examine the reconst [...]
-<li><p><span><em>Multiple data sets, unlimited computing time.</em></span> Comparative genomic analyses sometimes rely on building phylogenies from the analysis of a large number of gene families. Here again, the NNI option is the most relevant if the focus is not on recovering the most accurate picture of the evolutionary relationships between species. Slower SPR-based heuristics should be used when the topology of the tree is an important parameter of the analysis (e.g., identification [...]
-<li><p><span><em>Multiple data sets, limited computing time.</em></span> The large amount of data to be processed in a limited time generally requires the use of the fastest tree searching and branch support estimation methods Hence, NNI and approximate likelihood ratios rather than SPR and non-parametric bootstrap are generally the most appropriate here.</p></li>
-</ol>
-<p>Another important point is the choice of the substitution model. While default options generally provide acceptable results, it is often warranted to perform a pre-analysis in order to identify the best-fit substitution model. This pre-analysis can be done using popular software such as Modeltest <span class="citation"></span> or ProtTest <span class="citation"></span> for instance. These programs generally recommend the use of a discrete gamma distribution to model the substitution p [...]
-<h2 id="sec:recomphytime"><a href="#sec:recomphytime"><span class="header-section-number">11.2</span> PhyTime</a></h2>
-<p>Analysing a data set using PhyTime should involve three steps based on the following questions: (1) do the priors seem to be adequate (2) can I use the fast approximation of the likelihood and (3) how long shall I run the program for? I explain below how to provide answers to these questions.</p>
-<ul>
-<li><p><span><em>Are the priors adequate?</em></span> Bayesian analysis relies on specifiying the joint prior density of model parameters. In the case of node age estimation, these priors essentially describe how rates of substitution vary across lineages and the probabilistic distribution that node ages have when ignoring the information provided by the genetic sequences. These priors vary from tree to tree. It is therefore essential to check the adequacy of priors for each user-defined [...]
-<li><p><span><em>Can I use the fast approximation to the likelihood?</em></span> The suface of the log-likelihood function can be approximated using a multivariate normal density. This technique is saving very substantial amounts of computation time. However, like most approximations, there are situations where it does not provide a good fit to the actual function. This usually happens when the phylogeny displays a lot of short branches, i.e., the signal conveyed by the sequences is weak [...]
-<li><p><span><em>How long shall I run the program for?</em></span> PhyTime should be run long enough such that the ESS of each parameter is ‘large enough’. The last column on the right handside of the standard output gives the minimum ESS across all internal node heights. It is recommended to run the program so that this number reaches at least 100.</p></li>
-</ul>
-<h1 id="frequently-asked-questions"><a href="#frequently-asked-questions"><span class="header-section-number">12</span> Frequently asked questions</a></h1>
-<ol>
-<li><p><span><em>PhyML crashes before reading the sequences. What’s wrong ?</em></span><br /></p>
-<ul>
-<li><p>The format of your sequence file is not recognized by PhyML. See Section [sec:input<sub>o</sub>utput]</p></li>
-<li><p>The carriage return characters in your sequence files are not recognized by PhyML. You must make sure that your sequence file is a plain text file, with standard carriage return characters (i.e., corresponding to “<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>∖</mo></mrow></math><code>n</code>”, or “<math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>∖</mo></mrow></math><code>r</code>”)</p></li>
-</ul></li>
-<li><p><span><em>The program crashes after reading the sequences. What’s wrong ?</em></span><br /></p>
-<ul>
-<li><p>You analyse protein sequences and did not enter the <code>-d aa</code> option in the command-line.</p></li>
-<li><p>The format of your sequence file is not recognized by PhyML. See Section [sec:input<sub>o</sub>utput]</p></li>
-</ul></li>
-<li><p><span><em>Does PhyML handle outgroup sequences ?</em></span><br /></p>
-<ul>
-<li><p>Yes, it does. Outgroup taxa are identified by adding the ‘*’ sign at the end of each corresponding sequence name (see Section [sec:outgroupspecify])</p></li>
-</ul></li>
-<li><p><span><em>Does PhyML estimate clock-constrained trees ?</em></span><br /></p>
-<ul>
-<li><p>No, the PhyML program does not estimate clock-contrained trees. One can however use the program PhyTime to perform such analysis but the tree topology will not be estimated.</p></li>
-</ul></li>
-<li><p><span><em>Can PhyML analyse partitioned data, such as multiple gene sequences ?</em></span><br /></p>
-<ul>
-<li><p>We are currently working on this topic. Future releases of the program will provide options to estimate trees from phylogenomic data sets, with the opportunity to use different substitution models on the different data partitions (e.g., different genes). PhyML will also include specific algorithms to search the space of tree topologies for this type of data.</p></li>
-</ul></li>
-</ol>
-<h1 id="acknowledgements"><a href="#acknowledgements"><span class="header-section-number">13</span> Acknowledgements</a></h1>
-<p>The development of PhyML since 2000 has been supported by the Centre National de la Recherche Scientifique (CNRS) and the Ministère de l’Éducation Nationale.</p>
-<div class="footnotes">
-<hr />
-<ol>
-<li id="fn1"><p>the rate matrix corresponds here the symmetrical matrix giving the so-called “echangeability rates”<a href="#fnref1">↩</a></p></li>
-<li id="fn2"><p>The actual formula involves an extra parameter which does not need to be introduced here<a href="#fnref2">↩</a></p></li>
-</ol>
-</div>
-</body>
-</html>
diff --git a/doc/example.text b/doc/example.text
deleted file mode 100644
index dcb7441..0000000
--- a/doc/example.text
+++ /dev/null
@@ -1,2812 +0,0 @@
--   Availability
--   Authors
--   Overview
--   Bug report
--   Installing PhyML
-    -   Sources and compilation
-    -   Installing PhyML on UNIX-like systems (including Mac OS)
-    -   Installing PhyML on Microsoft Windows
-    -   Installing the parallel version of PhyML
-    -   Installing PhyML-BEAGLE
--   Program usage.
-    -   PHYLIP-like interface
-        -   Input Data sub-menu
-        -   Substitution model sub-menu
-        -   Tree searching sub-menu
-        -   Branch support sub-menu
-    -   Command-line interface
-    -   XML interface
-    -   Parallel bootstrap
--   Inputs & outputs for command-line and PHYLIP interface
-    -   Sequence formats
-        -   Gaps and ambiguous characters
-        -   Specifying outgroup sequences
-    -   Tree format
-    -   Multiple alignments and trees
-    -   Custom amino-acid rate model
-    -   Topological constraint file
-    -   Output files
-    -   Treatment of invariable sites with fixed branch lengths
--   Inputs & outputs for the XML interface
-    -   Mixture models in PhyML
-    -   Partitions
-    -   Combining mixture and partitions in PhyML: the theory
-    -   The XML format and its use in PhyML
-    -   Setting up mixture and partition models in PhyML: the basics
-    -   XML options
-        -   <span>phyml</span> component
-        -   <span>topology</span> component
-        -   <span>ratematrices</span> component
-        -   <span>equfreqs</span> component
-        -   <span>branchlengths</span> component
-        -   <span>siterates</span> component
-        -   <span>partitionelem</span> and <span>mixtureelem</span>
-            components
-    -   A simple example: GTR + $\Gamma$4 + I
-    -   A second example: LG4X
-    -   An example with multiple partition elements
-    -   Branch lengths with invariants and partionned data
--   Citing PhyML
--   Other programs in the PhyML package
-    -   PhyTime
-        -   Installing PhyTime
-        -   Running PhyTime
-        -   Upper bounds of model parameters
-        -   PhyTime specific options
-        -   PhyTime output
-        -   ClockRate vs. EvolRate
-        -   Effective sample size
-        -   Prior distributions of model parameters
-        -   Citing PhyTime
-    -   PhyloGeo
-        -   Installing PhyloGeo
-        -   Running PhyloGeo
-        -   Citing PhyloGeo
--   Recommendations on program usage
-    -   PhyML
-    -   PhyTime
--   Frequently asked questions
--   Acknowledgements
-
-\
-
-©Copyright 1999 - 2008 by PhyML Development Team.\
-The software PhyML is provided “as is” without warranty of any kind. In
-no event shall the authors or his employer be held responsible for any
-damage resulting from the use of this software, including but not
-limited to the frustration that you may experience in using the package.
-All parts of the source and documentation except where indicated are
-distributed under the GNU public licence. See http://www.opensource.org
-for details.
-
-Availability
-============
-
--   Binaries: <http://www.atgc-montpellier.fr/phyml>
-
--   Sources: <http://stephaneguindon.github.io/phyml-downloads/>
-
--   Discussion forum: <http://groups.google.com/group/phyml-forum>
-
-Authors
-=======
-
--   <span> Stéphane Guindon</span> and <span> Olivier Gascuel</span>
-    conceived the original PhyML algorithm.
-
--   <span> Stéphane Guindon</span> conceived the PhyTime method.
-
--   <span> Stéphane Guindon, David Welch and Louis Ranjard</span>
-    conceived the PhyloGeo method.
-
--   <span> Stéphane Guindon, Wim Hordjik</span> and <span> Olivier
-    Gascuel</span> conceived the SPR-based tree search algorithm.
-
--   <span> Maria Anisimova</span> and <span> Olivier Gascuel</span>
-    conceived the aLRT method for branch support.
-
--   <span> Stéphane Guindon, Franck Lethiec</span>, Jean-Francois
-    Dufayard and Vincent Lefort implemented PhyML.
-
--   <span> Jean-Francois Dufayard</span> created the benchmark and
-    implemented the tools that are used to check PhyML accuracy and
-    performances.
-
--   <span> Vincent Lefort, Stéphane Guindon, Patrice Duroux</span> and
-    <span> Olivier Gascuel</span> conceived and implemented PhyML web
-    server.
-
--   <span> Imran Fanaswala</span> interfaced PhyML with BEAGLE.
-
--   Stéphane Guindon wrote this document.
-
-Overview
-========
-
-PhyML @guindon03 is a software package which primary task that is to
-estimate maximum likelihood phylogenies from alignments of nucleotide or
-amino-acid sequences. It provides a wide range of options that were
-designed to facilitate standard phylogenetic analyses. The main strength
-of PhyML lies in the large number of substitution models coupled to
-various options to search the space of phylogenetic tree topologies,
-going from very fast and efficient methods to slower but generally more
-accurate approaches. It also implements two methods to evaluate branch
-supports in a sound statistical framework (the non-parametric bootstrap
-and the approximate likelihood ratio test).
-
-PhyML was designed to process moderate to large data sets. In theory,
-alignments with up to 4,000 sequences 2,000,000 character-long can
-analyzed. In practice however, the amount of memory required to process
-a data set is proportional of the product of the number of sequences by
-their length. Hence, a large number of sequences can only be processed
-provided that they are short. Also, PhyML can handle long sequences
-provided that they are not numerous. With most standard personal
-computers, the “comfort zone” for PhyML generally lies around 100-500
-sequences less than 10,000 character long. For larger data sets, we
-recommend using other softwares such as RAxML @raxml or GARLI @garli or
-Treefinder (<http://www.treefinder.de>).
-
-Bug report
-==========
-
-While PhyML is, of course, bug-free (!) (please read the disclaimer
-carefuly...), if you ever come across an issue, please feel free to
-report it using the discuss group web site at the following address:
-<https://groups.google.com/forum/?fromgroups#!forum/phyml-forum>.
-Alternatively, you can send an email to
-[s.guindon at auckland.ac.nz](s.guindon at auckland.ac.nz). Do not forget to
-mention the version of PhyML and program options you are using.
-
-Installing PhyML
-================
-
-Sources and compilation
------------------------
-
-The sources of the program are available free of charge from
-<http://stephaneguindon.github.io/phyml-downloads/>. The compilation on
-UNIX-like systems is fairly standard. It is described in the ‘`INSTALL`’
-file that comes with the sources. In a command-line window, go to the
-directory that contains the sources and type:
-
-    ./configure;
-    make clean;
-    make V=0;
-
-By default, PhyML will be compiled with optimization flags turned on. It
-is possible to generate a version of PhyML that can run through a
-debugging tool (such as `ddd`[ddd]) or a profiling tool (such as
-`gprof`[gprof]) using the following instructions:
-
-    ./configure --enable-debug;
-    make clean;
-    make V=0;
-
-Installing PhyML on UNIX-like systems (including Mac OS)
---------------------------------------------------------
-
-Copy PhyML binary file in the directory you like. For the operating
-system to be able to locate the program, this directory must be
-specified in the global variable `PATH`. In order to achieve this, you
-will have to add `export PATH=/your_path/:$PATH` to the `.bashrc` or the
-`.bash_profile` located in your home directory (`your_path` is the path
-to the directory that contains PhyML binary).
-
-Installing PhyML on Microsoft Windows {#sec:install-windows}
--------------------------------------
-
-Copy the files `phyml.exe` and `phyml.bat` in the same directory. To
-launch PhyML, click on the icon corresponding to `phyml.bat`. Clicking
-on the icon for `phyml.exe` works too but the dimensions of the window
-will not fit PhyML PHYLIP-like interface.
-
-Installing the parallel version of PhyML {#sec:MPI}
-----------------------------------------
-
-Bootstrap analysis can run on multiple processors. Each processor
-analyses one bootstraped dataset. Therefore, the computing time needed
-to perform $R$ bootstrap replicates is divided by the number of
-processors available.
-
-This feature of PhyML relies on the MPI (Message Passing Interface)
-library. To use it, your computer must have MPI installed on it. In case
-MPI is not installed, you can dowload it from
-<http://www.mcs.anl.gov/research/projects/mpich2/>. Once MPI is
-installed, it is necessary to launch the MPI daemon. This can be done by
-entering the following instruction: `mpd &`. Note however that in most
-cases, the MPI daemon will already be running on your server so that you
-most likely do not need to worry about this. You can then just go in the
-`phyml/` directory (the directory that contains the `src/`, `examples/`
-and `doc/` folders) and enter the commands below:
-
-    ./configure --enable-mpi;
-    make clean;
-    make;
-
-A binary file named `phyml-mpi` has now been created in the `src/`
-directory and is ready to use with MPI. A typical MPI command-line which
-uses 4 CPUs is given below:
-
-    mpirun -n 4 ./phyml-mpi -i myseq -b 100
-
-Please read section [sec:parallel~b~ootstrap] of this document for more
-information.
-
-Installing PhyML-BEAGLE {#sec:install-phyml-beagle}
------------------------
-
-PhyML can use the BEAGLE at ayres12 library for the likelihood computation.
-BEAGLE provides provides significant speed-up: the single core version
-of PhyML-BEAGLE can be up to 10 times faster than PhyML on a single core
-and up to 150 times on Graphical Processing Units. PhyML-BEAGLE will
-eventually have of the features of PhyML, even though at the moment the
-boostrap and the invariant site options are not available. Also, please
-note that in some cases, the final log-likelihood reported by PhyML and
-PhyML-BEALGE may not exactly match, though the differences observed are
-very minor (in the 10$^{-4}$ to 10$^{-4}$ range).
-
-In order to install PhyML-BEAGLE, you first need to download and install
-the BEAGLE library available from
-<https://code.google.com/p/beagle-lib/>. Then run the following
-commands:
-
-    ./configure --enable-beagle;
-    make clean;
-    make;
-
-A binary file named `phyml-beagle` will be created in the `src/`
-directory. The interface to `phyml-beagle` (i.e., commandline option of
-PHYLIP-like interface) is exactly identical to that of PhyML.
-
-Program usage. {#sec:phyml_new}
-==============
-
-PhyML has three distinct user-interfaces. The first corresponds to a
-PHYLIP-like text interface that makes the choice of the options
-self-explanatory. The command-line interface is well-suited for people
-that are familiar with PhyML options or for running PhyML in batch mode.
-The XML interface is more sophisticated. It allows the user to analyse
-partitionned data using flexible mixture models of evolution.
-
-PHYLIP-like interface
----------------------
-
-The default is to use the PHYLIP-like text interface by simply typing
-‘`phyml`’ in a command-line window or by clicking on the PhyML icon (see
-Section [sec:install-windows]). After entering the name of the input
-sequence file, a list of sub-menus helps the users set up the analysis.
-There are currently four distinct sub-menus:
-
-1.  <span>*Input Data*</span>: specify whether the input file contains
-    amino-acid or nucleotide sequences. What the sequence format is (see
-    Section [sec:input~o~utput]) and how many data sets should be
-    analysed.
-
-2.  <span>*Substitution Model*</span>: selection of the Markov model of
-    substitution.
-
-3.  <span>*Tree Searching*</span>: selection of the tree topology
-    searching algorithm.
-
-4.  <span>*Branch Support*</span>: selection of the method that is used
-    to measure branch support.
-
-‘`+`’ and ‘`-`’ keys are used to move forward and backward in the
-sub-menu list. Once the model parameters have been defined, typing ‘`Y`’
-(or ‘`y`’) launches the calculations. The meaning of some options may
-not be obvious to users that are not familiar with phylogenetics. In
-such situation, we strongly recommend to use the default options. As
-long as the format of the input sequence file is correctly specified
-(sub-menu <span>*Input data*</span>), the safest option for non-expert
-users is to use the default settings. The different options provided
-within each sub-menu are described in what follows.
-
-### Input Data sub-menu
-
-Type of data in the input file. It can be either DNA or amino-acid
-sequences in PHYLIP format (see Section [sec:input~o~utput]). Type `D`
-to change settings.
-
-PHYLIP format comes in two flavours: interleaved or sequential (see
-Section [sec:input~o~utput]). Type `I` to selected among the two
-formats.
-
-If the input sequence file contains more than one data sets, PhyML can
-analyse each of them in a single run of the program. Type `M` to change
-settings.
-
-This option allows you to append a string that identifies the current
-PhyML run. Say for instance that you want to analyse the same data set
-with two models. You can then ‘tag’ the first PhyML run with the name of
-the first model while the second run is tagged with the name of the
-second model.
-
-### Substitution model sub-menu {#sec:submenus}
-
-PhyML implements a wide range of substitution models: JC69 @jukes69, K80
- at kimura80, F81 @felsenstein81a, F84 @phylip2, HKY85 @hasegawa85, TN93
- at tamura93 GTR @lanave84 [@tavare86] and custom for nucleotides; LG
- at le08, WAG @whelan01b, Dayhoff @dayhoff78, JTT @jones92, Blosum62
- at henikoff92, mtREV @adachi96, rtREV @dimmic02, cpREV @adachi00, DCMut
- at kosiol04, VT @muller00 and mtMAM @cao98 and custom for amino acids.
-Cycle through the list of nucleotide or amino-acids substitution models
-by typing `M`. Both nucleotide and amino-acid lists include a ‘custom’
-model. The custom option provides the most flexible way to specify the
-nucleotide substitution model. The model is defined by a string made of
-six digits. The default string is ‘`000000`’, which means that the six
-relative rates of nucleotide changes: $A \leftrightarrow C$,
-$A \leftrightarrow G$, $A
-\leftrightarrow T$, $C \leftrightarrow  G$, $C  \leftrightarrow T$ and
-$G \leftrightarrow  T$, are equal. The string ‘`010010`’ indicates that
-the rates $A  \leftrightarrow   G$ and $C
-\leftrightarrow  T$ are equal and distinct from
-$A  \leftrightarrow C  = A  \leftrightarrow T  = C
-\leftrightarrow G = G  \leftrightarrow T$. This model corresponds to
-HKY85 (default) or K80 if the nucleotide frequencies are all set to
-0.25. ‘`010020`’ and ‘`012345`’ correspond to TN93 and GTR models
-respectively. The digit string therefore defines groups of relative
-substitution rates. The initial rate within each group is set to 1.0,
-which corresponds to F81 (JC69 if the base frequencies are equal). Users
-also have the opportunity to define their own initial rate values. These
-rates are then optimised afterwards (option ‘`O`’) or fixed to their
-initial values. The custom option can be used to implement all
-substitution models that are special cases of GTR. Table [tab:modelcode]
-on page gives the correspondence between the ‘standard’ name of the
-model (see
-<http://mbe.oxfordjournals.org/content/18/6/897/F2.large.jpg>) and the
-custom model code. The custom model also exists for protein sequences.
-It is useful when one wants to use an amino-acid substitution model that
-is not hard-coded in PhyML. The symmetric part of the rate matrix, as
-well as the equilibrium amino-acid frequencies, are given in a file
-which name is given as input of the program. The format of this file is
-described in the section [sec:customaa].
-
-For nucleotide sequences, optimising equilibrium frequencies means that
-the values of these parameters are estimated in the maximum likelihood
-framework. When the custom model option is selected, it is also possible
-to give the program a user-defined nucleotide frequency distribution at
-equilibrium (option `E`). For protein sequences, the stationary
-amino-acid frequencies are either those defined by the substitution
-model or those estimated by counting the number of different amino-acids
-observed in the data. Hence, the meaning of the `F` option depends on
-the type of the data to be processed.
-
-Fix or estimate the transition/transversion ratio in the maximum
-likelihood framework. This option is only available when DNA sequences
-are to be analysed under K80, HKY85 or TN93 models. The definition given
-to this parameter by PhyML is the same as PAML’s one. Therefore, the
-value of this parameter does <span>*not*</span> correspond to the ratio
-between the expected number of transitions and the expected number of
-transversions during a unit of time. This last definition is the one
-used in PHYLIP. PAML’s manual gives more detail about the distinction
-between the two definitions
-(<http://abacus.gene.ucl.ac.uk/software/paml.html>).
-
-The proportion of invariable sites, i.e., the expected frequency of
-sites that do not evolve, can be fixed or estimated. The default is to
-fix this proportion to 0.0. By doing so, we consider that each site in
-the sequence may accumulate substitutions at some point during its
-evolution, even if no differences across sequences are actually observed
-at that site. Users can also fix this parameter to any value in the
-$[0.0,1.0]$ range or estimate it from the data in the maximum-likelihood
-framework.
-
-Rates of evolution often vary from site to site. This heterogeneity can
-be modelled using a discrete gamma distribution. Type `R` to switch this
-option on or off. The different categories of this discrete distribution
-correspond to different (relative) rates of evolution. The number of
-categories of this distribution is set to 4 by default. It is probably
-not wise to go below this number. Larger values are generally preferred.
-However, the computational burden involved is proportional to the number
-of categories (i.e., an analysis with 8 categories will generally take
-twice the time of the same analysis with only 4 categories). Note that
-the likelihood will not necessarily increase as the number of categories
-increases. Hence, the number of categories should be kept below a
-“reasonable” number, say 20. The default number of categories can be
-changed by typing `C`.
-
-The middle of each discretized substitution rate class can be determined
-using the mean or the median. PAML, MrBayes and RAxML use the mean.
-However, the median is generally associated with greater likelihoods
-than the mean. This conclusion is based on our analysis of several
-real-world data sets extracted from TreeBase. Despite this, the default
-option in PhyML is to use the mean in order to make PhyML likelihoods
-comparable to those of other phylogenetic software. One must bare in
-mind that .
-
-The shape of the gamma distribution determines the range of rate
-variation across sites. Small values, typically in the $[0.1,1.0]$
-range, correspond to large variability. Larger values correspond to
-moderate to low heterogeneity. The gamma shape parameter can be fixed by
-the user or estimated via maximum-likelihood. Type `A` to select one or
-the other option.
-
-### Tree searching sub-menu
-
-By default the tree topology is optimised in order to maximise the
-likelihood. However, it is also possible to avoid any topological
-alteration. This option is useful when one wants to compute the
-likelihood of a tree given as input (see below). Type `O` to select
-among these two options.
-
-PhyML proposes three different methods to estimate tree topologies. The
-default approach is to use simultaneous NNI. This option corresponds to
-the original PhyML algorithm @guindon03. The second approach relies on
-subtree pruning and regrafting (SPR). It generally finds better tree
-topologies compared to NNI but is also significantly slower. The third
-approach, termed BEST, simply estimates the phylogeny using both methods
-and returns the best solution among the two. Type `S` to choose among
-these three choices.
-
-When the SPR or the BEST options are selected, is is possible to use
-random trees rather than BioNJ or a user-defined tree, as starting tree.
-If this option is turned on (type `R` to change), five trees,
-corresponding to five random starts, will be estimated. The output tree
-file will contain the best tree found among those five. The number of
-random starts can be modified by typing `N`. Setting the number of
-random starting trees to $N$ means that the analysis will take (slightly
-more than) $N$ times the time required for a standard analysis where
-only one (BioNJ) starting tree is used. However, the analysis of real
-data sets shows that the best trees estimated using the random start
-option almost systematically have higher likelihoods than those inferred
-using a single starting tree.
-
-When the tree topology optimisation option is turned on, PhyML proceeds
-by refining an input tree. By default, this input tree is estimated
-using BioNJ @gascuelNJ. The alternative option is to use a parsimony
-tree. We found this option specially useful when analysing large data
-sets with NNI moves as it generally leads to greater likelihoods than
-those obtained when starting from a BioNJ trees. The user can also to
-input her/his own tree. This tree should be in Newick format (see
-Section [sec:input~o~utput]). This option is useful when one wants to
-evaluate the likelihood of a given tree with a fixed topology, using
-PhyML. Type `U` to choose among these two options.
-
-### Branch support sub-menu
-
-The support of the data for each internal branch of the phylogeny can be
-estimated using non-parametric bootstrap. By default, this option is
-switched off. Typing `B` switches on the bootstrap analysis. The user is
-then prompted for a number of bootstrap replicates. The largest this
-number the more precise the bootstrap support estimates are. However,
-for each bootstrap replicate a phylogeny is estimated. Hence, the time
-needed to analyse $N$ bootstrap replicates corresponds to $N$-times the
-time spent on the analysis of the original data set. $N=100$ is
-generally considered as a reasonable number of replicates.
-
-When the bootstrap option is switched off (see above), approximate
-likelihood branch supports are estimated. This approach is considerably
-faster than the bootstrap one. However, both methods intend to estimate
-different quantities and conducting a fair comparison between both
-criteria is not straightforward. The estimation of approximate
-likelihood branch support comes in multiple flavours. The default is set
-to aBayes, corresponding to the approximate Bayes method described in
- at anisimova11. The approximate likelihood ratio test (aLRT) @anisimova06,
-Shimodaira–Hasegawa aLRT (SH-aLRT) statistics are the other available
-options.
-
-Command-line interface
-----------------------
-
-An alternative to the PHYLIP-like interface is the command-line
-interface. Users that do not need to modify the default parameters can
-launch the program with the ‘`phyml -i seq_file_name`’ command. The list
-of all command line arguments and how to use them is given in the ‘Help’
-section which is displayed when entering the ‘`phyml –help`’ command.
-The available command-line options are described in what follows.
-
--   `-i` (or `–input`) `seq_file_name`\
-    `seq_file_name` is the name of the nucleotide or amino-acid sequence
-    file in PHYLIP format.
-
--   `-d` (or `–datatype`) `data_type`\
-    `data_type` is `nt` for nucleotide (default) and `aa` for amino-acid
-    sequences.
-
--   `-q` (or `–sequential`)\
-    Changes interleaved format (default) to sequential format.
-
--   `-n` (or `–multiple`) `nb_data_sets`\
-    `nb_data_sets` is an integer giving the number of data sets to
-    analyse.
-
--   `-p` (or `–pars`)\
-    Use a minimum parsimony starting tree. This option is taken into
-    account when the ‘-u’ option is absent and when tree topology
-    modifications are to be done.
-
--   `-b` (or `–bootstrap`) `int`
-
-    -   `int` $>$ 0: `int` is the number of bootstrap replicates.
-
-    -   `int` = 0: neither approximate likelihood ratio test nor
-        bootstrap values are computed.
-
-    -   `int` = -1: approximate likelihood ratio test returning aLRT
-        statistics.
-
-    -   `int` = -2: approximate likelihood ratio test returning
-        Chi2-based parametric branch supports.
-
-    -   `int` = -4: SH-like branch supports alone.
-
-    -   `int` = -5: (default) approximate Bayes branch supports.
-
--   `-m` (or `–model`) `model_name`\
-    `model_name` : substitution model name.
-
-    -   <span>*Nucleotide-based models*</span>: `HKY85` (default)
-        `| JC69 | K80 | F81 | F84 | TN93 | GTR | custom`\
-        The `custom` option can be used to define a new substitution
-        model. A string of six digits identifies the model. For
-        instance, 000000 corresponds to F81 (or JC69 provided the
-        distribution of nucleotide frequencies is uniform). 012345
-        corresponds to GTR. This option can be used for encoding any
-        model that is a nested within GTR. See Section [sec:submenus]
-        and Table [tab:modelcode]. <span>*NOTE:*</span> the substitution
-        parameters of the custom model will be optimised so as to
-        maximise the likelihood. It is possible to specify and fix
-        (i.e., avoid optimisation) the values of the substitution rates
-        only through the PHYLIP-like interface.
-
-    -   <span>*Amino-acid based models*</span>: `LG` (default)
-        `| WAG | JTT | MtREV | Dayhoff | DCMut | RtREV | CpREV | VT | Blosum62 | MtMam | MtArt | HIVw | HIVb | custom`\
-        The `custom` option is useful when one wants to use an
-        amino-acid substitution model that is not available by default
-        in PhyML. The symmetric part of the rate matrix, as well as the
-        equilibrium amino-acid frequencies, are given in a file which
-        name is asked for by the program. The format of this file is
-        described in section [sec:customaa].
-
-      Name    Command-line option
-      ------- ------------------------------------
-      JC69    `-m 000000 -f 0.25,0.25,0.25,0.25`
-      F81     `-m 000000`
-      K80     `-m 010010 -f 0.25,0.25,0.25,0.25`
-      HKY85   `-m 010010`
-      TrNef   `-m 010020 -f 0.25,0.25,0.25,0.25`
-      TrN     `-m 010020`
-      K81     `-m 123321 -f 0.25,0.25,0.25,0.25`
-      K81uf   `-m 123321`
-      TIMef   `-m 132241 -f 0.25,0.25,0.25,0.25`
-      TIM     `-m 132241`
-      TVMef   `-m 102304 -f 0.25,0.25,0.25,0.25`
-      TVM     `-m 102304`
-      SYM     `-m 123456 -f 0.25,0.25,0.25,0.25`
-      GTR     `-m 123456`
-
-    [tab:modelcode]
-
--   `–aa_rate_file file_name`\
-    This option is compulsory when analysing amino-acid sequences under
-    a ‘custom’ model (see above). `file_name` should provide a rate
-    matrix and equilibrium amino acid in PAML format (see Section
-    [sec:customaa]).
-
--   `-f e`, `m`, or \`\``fA,fC,fG,fT`"\
-    Nucleotide or amino-acid frequencies.
-
-    -   `e` : the character frequencies are determined as follows :
-
-        -   <span>*Nucleotide sequences*</span>: (Empirical) the
-            equilibrium base frequencies are estimated by counting the
-            occurence of the different bases in the alignment.
-
-        -   <span>*Amino-acid sequences*</span>: (Empirical) the
-            equilibrium amino-acid frequencies are estimated by counting
-            the occurence of the different amino-acids in the alignment.
-
-    -   `m` : the character frequencies are determined as follows :
-
-        -   <span>*Nucleotide sequences*</span>: (ML) the equilibrium
-            base frequencies are estimated using maximum likelihood.
-
-        -   <span>*Amino-acid sequences*</span>: (Model) the equilibrium
-            amino-acid frequencies are estimated using the frequencies
-            defined by the substitution model.
-
-    -   \`\``fA,fC,fG,fT`": only valid for nucleotide-based models.
-        `fA`, `fC`, `fG` and `fT` are floating numbers that correspond
-        to the frequencies of A, C, G and T respectively.
-
--   `-t` (or `–ts/tv`) `ts/tv_ratio`\
-    `ts/tv_ratio`: transition/transversion ratio. DNA sequences only.
-    Can be a fixed positive value (e.g., 4.0) or type `e` to get the
-    maximum likelihood estimate.
-
--   `-v` (or `–pinv`) `prop_invar`\
-    `prop_invar`: proportion of invariable sites. Can be a fixed value
-    in the [0,1] range or type `e` to get the maximum likelihood
-    estimate.
-
--   `-c` (or `–nclasses`) `nb_subst_cat`\
-    `nb_subst_cat`: number of relative substitution rate categories.
-    Default: `nb_subst_cat=4`. Must be a positive integer.
-
--   `-a` (or `–alpha`) `gamma`\
-    `gamma`: value of the gamma shape parameter. Can be a fixed positive
-    value or e to get the maximum likelihood estimate. The value of this
-    parameter is estimated in the maximum likelihood framework by
-    default.
-
--   `–use_median`\
-    The middle of each substitution rate class in the discrete gamma
-    distribution is taken as the median. The mean is used by default.
-
--   `–free_rates`\
-    As an alternative to the discrete gamma model, it is possible to
-    estimate the (relative) rate in each class of the (mixture) model
-    and the corresponding frequencies directly from the data. This
-    model, called the FreeRate model, has more parameters than the
-    discrete gamma one but usually provides a significantly better fit
-    to the data. See @soubrier12 for more information about this model
-    and an illustration of its use.
-
--   `–codpos` `1,2 or 3`\
-    When analysing an alignment of coding sequences, use this option to
-    consider only the first, second or the third coding position for the
-    estimation.
-
--   `-s` (or `–search`) `move`\
-    Tree topology search operation option. Can be either `NNI` (default,
-    fast) or `SPR` (usually slower than `NNI` but more accurate) or
-    `BEST` (best of NNI and SPR search).
-
--   `-u` (or `–inputtree`) `user_tree_file`\
-    `user_tree_file`: starting tree filename. The tree must be in Newick
-    format.
-
--   `-o params`\
-    This option focuses on specific parameter optimisation.
-
-    -   `params=tlr`: tree topology (`t`), branch length (`l`) and
-        substitution rate parameters (`r`) are optimised.
-
-    -   `params=tl`: tree topology and branch lengths are optimised.
-
-    -   `params=lr`: branch lengths and substitution rate parameters are
-        optimised.
-
-    -   `params=l`: branch lengths are optimised.
-
-    -   `params=r`: substitution rate parameters are optimised.
-
-    -   `params=n`: no parameter is optimised.
-
--   `–rand_start`\
-    This option sets the initial tree to random. It is only valid if SPR
-    searches are to be performed.
-
--   `–n_rand_starts num`\
-    `num` is the number of initial random trees to be used. It is only
-    valid if SPR searches are to be performed.
-
--   `–r_seed num`\
-    `num` is the seed used to initiate the random number generator. Must
-    be an integer.
-
--   `–print_site_lnl`\
-    Print the likelihood for each site in file \*\_phyml\_lk.txt. For
-    $\Gamma$ or $\Gamma$+I or FreeRate models, this option returns the
-    posterior probability of each relative rate class at each site. Such
-    information can then be used to identify fast- and slow-evolving
-    regions of the alignment.
-
--   `–print_trace`\
-    Print each phylogeny explored during the tree search process in file
-    \*\_phyml\_trace.txt. This option can be useful for monitoring the
-    progress of the analysis for very large data sets and have an
-    approximate idea of what the final phylogeny will look like.
-
--   `–run_id ID_string`\
-    Append the string ID\_string at the end of each PhyML output file.
-    This option may be useful when running simulations involving PhyML.
-    It can also be used to ‘tag’ multiple analysis of the same data set
-    with various program settings.
-
--   `–no_memory_check`\
-    By default, when processing a large data set, PhyML will pause and
-    ask the user to confirm that she/he wants to continue with the
-    execution of the analysis despite the large amount of memory
-    required. The `–no_memory_check` skips this question. It is
-    especially useful when running PhyML in batch mode.
-
--   `–no_colalias`\
-    By default, PhyML preprocesses each alignment by putting together
-    (or aliasing) the columns that are identical. Use this option to
-    skip this step but be aware that the analysis might then take more
-    time to complete.
-
--   `–constrained_lens`\
-    When an input tree with branch lengths is provided, this option will
-    find the branch multiplier that maximises the likelihood (i.e., the
-    relative branch lengths remain constant)
-
--   `–constraint_file` `file_name`\
-    `file_name` lists the topological constraints under which the tree
-    topology search is conducted. This option should be used in
-    conjunction with `-u` `file_name`. See Section [sec:topoconstraints]
-    for more information.
-
--   `–quiet`\
-    Runs PhyML in quiet mode. The program will not pause if the memory
-    required to run the analysis exceeds 256MB and will not output the
-    log-likelihood score to the output.
-
--   `–ancestral`\
-    PhyML calculates the marginal probabilities of each character state
-    at each internal node and each site of the sequence alignment.
-
-XML interface
--------------
-
--   `–xml=xml_file_name`\
-    `xml_file_name` is the name of the XML file containing the
-    information required to run the analysis. More details about this
-    type of file is given in the section [sec:xmlio].
-
-Parallel bootstrap {#sec:parallel_bootstrap}
-------------------
-
-Bootstrapping is a highly parallelizable task. Indeed, bootstrap
-replicates are independent from one another. Each bootstrap replicate
-can then be analysed separately. Modern computers often have more than
-one CPU. Each CPU can therefore be used to process a bootstrap sample.
-Using this parallel strategy, performing $R$ bootstrap replicates on $C$
-CPUs ‘costs’ the same amount of computation time as processing
-$R  \times C$ bootstrap replicates on a single CPU. In other words, for
-a given number of replicates, the computation time is divided by $R$
-compared to the non-parallel approach.
-
-PhyML sources must be compiled with specific options to turn on the
-parallel option (see Section [sec:MPI]). Once the binary file (`phyml`)
-has been generated, running a bootstrap analysis with, say 100
-replicates on 2 CPUs, can be done by typing the following command-line:
-
-    mpd &;
-    mpirun -np 2 ./phyml -i seqfile -b 100;
-
-The first command launches the mpi daemon while the second launches the
-analysis. Note that launching the daemon needs to be done only once. The
-output files are similar to the ones generated using the standard,
-non-parallel, analysis (see Section [sec:input~o~utput]). Note that
-running the program in batch mode, i.e.:
-
-    mpirun -np 2 ./phyml -i seqfile -b 100 &
-
-will probably NOT work. I do not know how to run a mpi process in batch
-mode yet. Suggestions welcome... Also, at the moment, the number of
-bootstrap replicates must be a multiple of the number of CPUs required
-in the mpirun command.
-
-Inputs & outputs for command-line and PHYLIP interface  {#sec:input_output}
-=======================================================
-
-PhyML reads data from standard text files, without the need for any
-particular file name extension.
-
-Sequence formats
-----------------
-
-
-    5 80
-    seq1  CCATCTCACGGTCGGTACGATACACCKGCTTTTGGCAGGAAATGGTCAATATTACAAGGT
-    seq2  CCATCTCACGGTCAG---GATACACCKGCTTTTGGCGGGAAATGGTCAACATTAAAAGAT
-    seq3  RCATCTCCCGCTCAG---GATACCCCKGCTGTTG????????????????ATTAAAAGGT
-    seq4  RCATCTCATGGTCAA---GATACTCCTGCTTTTGGCGGGAAATGGTCAATCTTAAAAGGT
-    seq5  RCATCTCACGGTCGGTAAGATACACCTGCTTTTGGCGGGAAATGGTCAAT????????GT
-
-    ATCKGCTTTTGGCAGGAAAT
-    ATCKGCTTTTGGCGGGAAAT
-    AGCKGCTGTTG?????????
-    ATCTGCTTTTGGCGGGAAAT
-    ATCTGCTTTTGGCGGGAAAT
-
-
-    5 40
-    seq1  CCATCTCANNNNNNNNACGATACACCKGCTTTTGGCAGG
-    seq2  CCATCTCANNNNNNNNGGGATACACCKGCTTTTGGCGGG
-    seq3  RCATCTCCCGCTCAGTGAGATACCCCKGCTGTTGXXXXX
-    seq4  RCATCTCATGGTCAATG-AATACTCCTGCTTTTGXXXXX
-    seq5  RCATCTCACGGTCGGTAAGATACACCTGCTTTTGxxxxx
-
-[fig:align~t~ree]
-
-
-    [ This is a comment ]
-    #NEXUS
-    BEGIN DATA;
-    DIMENSIONS NTAX=10 NCHAR=20;
-    FORMAT DATATYPE=DNA;
-    MATRIX
-    tax1       ?ATGATTTCCTTAGTAGCGG
-    tax2       CAGGATTTCCTTAGTAGCGG
-    tax3       ?AGGATTTCCTTAGTAGCGG
-    tax4       ?????????????GTAGCGG
-    tax5       CAGGATTTCCTTAGTAGCGG
-    tax6       CAGGATTTCCTTAGTAGCGG
-    tax7       ???GATTTCCTTAGTAGCGG
-    tax8       ????????????????????
-    tax9       ???GGATTTCTTCGTAGCGG
-    tax10      ???????????????AGCGG;
-    END;
-
-
-    [ This is a comment ]
-    #NEXUS
-    BEGIN DATA;
-    DIMENSIONS NTAX=10 NCHAR=20;
-    FORMAT DATATYPE=STANDARD SYMBOLS="0 1 2 3";
-    MATRIX
-    tax1       ?0320333113302302122
-    tax2       10220333113302302122
-    tax3       ?0220333113302302122
-    tax4       ?????????????2302122
-    tax5       10220333113302302122
-    tax6       10220333113302302122
-    tax7       ???20333113302302122
-    tax8       ????????????????????
-    tax9       ???22033313312302122
-    tax10      ???????????????02122;
-    END;
-
-
-    [ This is a comment ]
-    #NEXUS
-    BEGIN DATA;
-    DIMENSIONS NTAX=10 NCHAR=20;
-    FORMAT DATATYPE=STANDARD SYMBOLS="00 01 02 03";
-    MATRIX
-    tax1       ??00030200030303010103030002030002010202
-    tax2       0100020200030303010103030002030002010202
-    tax3       ??00020200030303010103030002030002010202
-    tax4       ??????????????????????????02030002010202
-    tax5       0100020200030303010103030002030002010202
-    tax6       0100020200030303010103030002030002010202
-    tax7       ??????0200030303010103030002030002010202
-    tax8       ????????????????????????????????????????
-    tax9       ??????0202000303030103030102030002010202
-    tax10      ??????????????????????????????0002010202;
-    END;
-
-[fig:nexus]
-
-Alignments of DNA or protein sequences must be in PHYLIP or NEXUS
- at maddison97 sequential or interleaved format (Figures [fig:align~t~ree]
-and [fig:nexus]). For PHYLIP formated sequence alignments, the first
-line of the input file contains the number of species and the number of
-characters, in free format, separated by blank characters. One slight
-difference with PHYLIP format deals with sequence name lengths. While
-PHYLIP format limits this length to ten characters, PhyML can read up to
-hundred character long sequence names. Blanks and the symbols “(),:” are
-not allowed within sequence names because the Newick tree format makes
-special use of these symbols. Another slight difference with PHYLIP
-format is that actual sequences must be separated from their names by at
-least one blank character.
-
-A PHYLIP input sequence file may also display more than a single data
-set. Each of these data sets must be in PHYLIP format and two successive
-alignments must be separated by an empty line. Processing multiple data
-sets requires to toggle the ‘`M`’ option in the <span>*Input
-Data*</span> sub-menu or use the ‘`-n`’ command line option and enter
-the number of data sets to analyse. The multiple data set option can be
-used to process re-sampled data that were generated using a
-non-parametric procedure such as cross-validation or jackknife (a
-bootstrap option is already included in PhyML). This option is also
-useful in multiple gene studies, even if fitting the same substitution
-model to all data sets may not be suitable.
-
-PhyML can also process alignments in NEXUS format. Although not all the
-options provided by this format are supported by PhyML, a few specific
-features are exploited. Of course, this format can handle nucleotide and
-protein sequence alignments in sequential or interleaved format. It is
-also possible to use custom alphabets, replacing the standard 4-state
-and 20-state alphabets for nucleotides and amino-acids respectively.
-Examples of a 4-state custom alphabet are given in Figure [fig:nexus].
-Each state must here correspond to one digit or more. The set of states
-must be a list of consecutive digits starting from 0. For instance, the
-list “0, 1, 3, 4” is not a valid alphabet. Each state in the symbol list
-must be separated from the next one by a space. Hence, alphabets with
-large number of states can be easily defined by using two-digit number
-(starting with 00 up to 19 for a 20 state alphabet). Most importantly,
-this feature gives the opportunity to analyse data sets made of
-presence/absence character states (use the `symbols=0 1` option for such
-data). Alignments made of custom-defined states will be processed using
-the Jukes and Cantor model. Other options of the program (e.g., number
-of rate classes, tree topology search algorithm) are freely
-configurable. Note that, at the moment, the maximum number of different
-states is set to 22 in order to save memory space. It is however
-possible to lift this threshold by modifiying the value of the variable
-`T_MAX_ALPHABET` in the file ‘`utilities.h`’. The program will then have
-to be re-compiled.
-
-### Gaps and ambiguous characters
-
-Gaps correspond to the ‘`-`’ symbol. They are systematically treated as
-unknown characters “on the grounds that we don’t know what would be
-there if something were there” (J. Felsenstein, PHYLIP main
-documentation). The likelihood at these sites is summed over all the
-possible states (i.e., nucleotides or amino acids) that could actually
-be observed at these particular positions. Note however that columns of
-the alignment that display only gaps or unknown characters are simply
-discarded because they do not carry any phylogenetic information (they
-are equally well explained by any model). PhyML also handles ambiguous
-characters such as $R$ for $A$ or $G$ (purines) and $Y$ for $C$ or $T$
-(pyrimidines). Tables [tab:ambigu~n~t] and [tab:ambigu~a~a] give the
-list of valid characters/symbols and the corresponding nucleotides or
-amino acids.
-
-  Character         Nucleotide Character                                     Nucleotide
-  ----------- ---------------- -------------------------- -----------------------------
-  $A$                Adenosine $Y$                                           $C$ or $T$
-  $G$                Guanosine $K$                                           $G$ or $T$
-  $C$                 Cytidine $B$                                    $C$ or $G$ or $T$
-  $T$                Thymidine $D$                                    $A$ or $G$ or $T$
-  $U$           Uridine (=$T$) $H$                                    $A$ or $C$ or $T$
-  $M$               $A$ or $C$ $V$                                    $A$ or $C$ or $G$
-  $R$               $A$ or $G$ $-$ or $N$ or $X$ or $?$                         unknown
-  $W$               $A$ or $T$                              (=$A$ or $C$ or $G$ or $T$)
-  $S$               $C$ or $G$                            
-
-[tab:ambigu~n~t]
-
-  Character         Amino-Acid Character                          Amino-Acid
-  ------------ --------------- ------------------- -------------------------
-  $A$                  Alanine $L$                                   Leucine
-  $R$                 Arginine $K$                                    Lysine
-  $N$ or $B$        Asparagine $M$                                Methionine
-  $D$            Aspartic acid $F$                             Phenylalanine
-  $C$                 Cysteine $P$                                   Proline
-  $Q$ or $Z$         Glutamine $S$                                    Serine
-  $E$            Glutamic acid $T$                                 Threonine
-  $G$                  Glycine $W$                                Tryptophan
-  $H$                Histidine $Y$                                  Tyrosine
-  $I$               Isoleucine $V$                                    Valine
-  $L$                  Leucine $-$ or $X$ or $?$                     unknown
-  $K$                   Lysine                       (can be any amino acid)
-
-[tab:ambigu~a~a]
-
-### Specifying outgroup sequences {#sec:outgroupspecify}
-
-PhyML can return rooted trees provided outgroup taxa are identified from
-the sequence file. In order to do so, sequence names that display a ‘\*’
-character will be automatically considered as belonging to the outgroup.
-
-The topology of the rooted tree is exactly the same as the unrooted
-version of the same tree. In other words, PhyML first ignores the
-distinction between ingroup and outgroup sequences, builds a maximum
-likelihood unrooted tree and then tries to add the root. If the outgroup
-has more than one sequence, the position of the root might be ambiguous.
-In such situation, PhyML tries to identify the most relevant position of
-the root by considering which edge provides the best separation between
-ingroup and outgroup taxa (i.e., we are trying to make the outgroup “as
-monophyletic as possible”).
-
-Tree format
------------
-
-PhyML can read one or several phylogenetic trees from an input file.
-This option is accessible through the <span>*Tree Searching*</span> sub
-menu or the ‘`-u`’ argument from the command line. Input trees are
-generally used as initial maximum likelihood estimates to be
-subsequently adjusted by the tree searching algorithm. Trees can be
-either rooted or unrooted and multifurcations are allowed. Taxa names
-must, of course, match the corresponding sequence names.
-
-    ((seq1:0.03,seq2:0.01):0.04,(seq3:0.01,(seq4:0.2,seq5:0.05):0.2):0.01);
-    ((seq3,seq2),seq1,(seq4,seq5));
-
-[fig:trees]
-
-Multiple alignments and trees
------------------------------
-
-Single or multiple sequence data sets may be used in combination with
-single or multiple input trees. When the number of data sets is one
-($n_D = 1$) and there is only one input tree ($n_T = 1$), then this tree
-is simply used as input for the single data set analysis. When $n_D = 1$
-and $n_T >
-1$, each input tree is used successively for the analysis of the single
-alignment. PhyML then outputs the tree with the highest likelihood. If
-$n_D > 1$ and $n_T = 1$, the same input tree is used for the analysis of
-each data set. The last combination is $n_D > 1$ and $n_T  > 1$. In this
-situation, the $i$-th tree in the input tree file is used to analyse the
-$i$-th data set. Hence, $n_D$ and $n_T$ must be equal here.
-
-Custom amino-acid rate model {#sec:customaa}
-----------------------------
-
-The custom amino-acid model of substitutions can be used to implement a
-model that is not hard-coded in PhyML. This model must be
-time-reversible. Hence, the matrix of substitution rates is symmetrical.
-The format of the rate matrix with the associated stationary frequencies
-is identical to the one used in PAML. An example is given below:
-
-<span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span>p<span>0.33cm</span></span>
-&&&&&&&&&&&&&&&&&&&\
-0.55 & &&&&&&&&&&&&&&&&&&\
-0.51 & 0.64 & &&&&&&&&&&&&&&&&\
-0.74 & 0.15 & 5.43 & &&&&&&&&&&&&&&&&\
-1.03 & 0.53 & 0.27 & 0.03 & &&&&&&&&&&&&&&&\
-0.91 & 3.04 & 1.54 & 0.62 & 0.10 & &&&&&&&&&&&&&&\
-1.58 & 0.44 & 0.95 & 6.17 & 0.02 & 5.47 & &&&&&&&&&&&&&\
-1.42 & 0.58 & 1.13 & 0.87 & 0.31 & 0.33 & 0.57 & &&&&&&&&&&&&\
-0.32 & 2.14 & 3.96 & 0.93 & 0.25 & 4.29 & 0.57 & 0.25 & &&&&&&&&&&&\
-0.19 & 0.19 & 0.55 & 0.04 & 0.17 & 0.11 & 0.13 & 0.03 & 0.14 &
-&&&&&&&&&&\
-0.40 & 0.50 & 0.13 & 0.08 & 0.38 & 0.87 & 0.15 & 0.06 & 0.50 & 3.17 &
-&&&&&&&&&\
-0.91 & 5.35 & 3.01 & 0.48 & 0.07 & 3.89 & 2.58 & 0.37 & 0.89 & 0.32 &
-0.26 & &&&&&&&&\
-0.89 & 0.68 & 0.20 & 0.10 & 0.39 & 1.55 & 0.32 & 0.17 & 0.40 & 4.26 &
-4.85 & 0.93 & &&&&&&&\
-0.21 & 0.10 & 0.10 & 0.05 & 0.40 & 0.10 & 0.08 & 0.05 & 0.68 & 1.06 &
-2.12 & 0.09 & 1.19 & &&&&&&\
-1.44 & 0.68 & 0.20 & 0.42 & 0.11 & 0.93 & 0.68 & 0.24 & 0.70 & 0.10 &
-0.42 & 0.56 & 0.17 & 0.16 & &&&&&\
-3.37 & 1.22 & 3.97 & 1.07 & 1.41 & 1.03 & 0.70 & 1.34 & 0.74 & 0.32 &
-0.34 & 0.97 & 0.49 & 0.55 & 1.61 & &&&&\
-2.12 & 0.55 & 2.03 & 0.37 & 0.51 & 0.86 & 0.82 & 0.23 & 0.47 & 1.46 &
-0.33 & 1.39 & 1.52 & 0.17 & 0.80 & 4.38 & &&&\
-0.11 & 1.16 & 0.07 & 0.13 & 0.72 & 0.22 & 0.16 & 0.34 & 0.26 & 0.21 &
-0.67 & 0.14 & 0.52 & 1.53 & 0.14 & 0.52 & 0.11 & &&\
-0.24 & 0.38 & 1.09 & 0.33 & 0.54 & 0.23 & 0.20 & 0.10 & 3.87 & 0.42 &
-0.40 & 0.13 & 0.43 & 6.45 & 0.22 & 0.79 & 0.29 & 2.49 & &\
-2.01 & 0.25 & 0.20 & 0.15 & 1.00 & 0.30 & 0.59 & 0.19 & 0.12 & 7.82 &
-1.80 & 0.31 & 2.06 & 0.65 & 0.31 & 0.23 & 1.39 & 0.37 & 0.31 &\
-\
-8.66 & 4.40 & 3.91 & 5.70 & 1.93 & 3.67 & 5.81 & 8.33 & 2.44 & 4.85 &
-8.62 & 6.20 & 1.95 & 3.84 & 4.58 & 6.95 & 6.10 & 1.44 & 3.53 & 7.09\
-
-The entry on the $i$-th row and $j$-th column of this matrix corresponds
-to the rate of substitutions between amino-acids $i$ and $j$. The last
-line in the file gives the stationary frequencies and must be separated
-from the rate matrix by one line. The ordering of the amino-acids is
-alphabetical, i.e, Ala, Arg, Asn, Asp, Cys, Gln, Glu, Gly, His, Ile,
-Leu, Lys, Met, Phe, Pro, Ser, Thr, Trp, Tyr and Val.
-
-Topological constraint file {#sec:topoconstraints}
----------------------------
-
-PhyML can perform phylogenetic tree estimation under user-specified
-topological constraints. In order to do so, one should use the
-`–constraint_file` `file_name` command-line option where `file_name`
-lists the topological constraints. Such constraints are straightforward
-to define. For instance, the following constraints:
-
-    ((A,B,C),(D,E,F));
-
-indicate that taxa A, B and C belong to the same clade. D, E and F also
-belong to the same clade and the two clades hence defined should not
-overlap. Under these two constraints, the tree ((A,B),D,((E,F),C)) is
-not valid. From the example above, you will notice that the constraints
-are defined using a multifurcating tree in NEWICK format. Note that this
-tree does not need to display the whole list of taxa. For instance,
-while the only taxa involved in specifying topological constraints above
-are A, B, C, D, E & F, the actual data set could include more than these
-six taxa only.
-
-PhyML tree topology search algorithms all rely on improving a starting
-tree. By default, BioNJ is the method of choice for building this tree.
-However, there is no guarantee that the phylogeny estimated with PhyML
-does comply with the topological constraints. While it is probably
-possible to implement BioNJ with topological constraints, we have not
-done so yet. Instead, the same multifurcating tree that defines the
-topological constraints should also be used as starting tree using the
-`-u` (`–inputtree`) option. Altogether, the command line should look
-like the following: `-u`=`file_name` `–constraint_file`=`file_name`. It
-is not possible to use as input tree a non-binary phylogeny that is
-distinct from that provided in the constraint tree file. However, any
-binary tree compatible with the constraint one can be used as input
-tree.
-
-Output files
-------------
-
-Sequence file name : ‘<span>seq</span>’\
-
-  Output file name            Content
-  --------------------------- --------------------------------------------
-  `seq_phyml_tree`            ML tree
-  `seq_phyml_stats`           ML model parameters
-  `seq_phyml_boot_trees`      ML trees – bootstrap replicates
-  `seq_phyml_boot_stats`      ML model parameters – bootstrap replicates
-  `seq_phyml_rand_trees`      ML trees – multiple random starts
-  `seq_phyml_ancestral_seq`   ML trees – ancestral sequences
-
-[tab:output]
-
-Table [tab:output] presents the list of files resulting from an
-analysis. Basically, each output file name can be divided into three
-parts. The first part is the sequence file name, the second part
-corresponds to the extension ‘`_phyml_`’ and the third part is related
-to the file content. When launched with the default options, PhyML only
-generates two files: the tree file and the model parameter file. The
-estimated maximum likelihood tree is in standard Newick format (see
-Figure [fig:trees]). The model parameters file, or statistics file,
-displays the maximum likelihood estimates of the substitution model
-parameters, the likelihood of the maximum likelihood phylogenetic model,
-and other important information concerning the settings of the analysis
-(e.g., type of data, name of the substitution model, starting tree,
-etc.). Two additional output files are created if bootstrap supports
-were evaluated. These files simply contain the maximum likelihood trees
-and the substitution model parameters estimated from each bootstrap
-replicate. Such information can be used to estimate sampling errors
-around each parameter of the phylogenetic model. When the random tree
-option is turned on, the maximum likelihood trees estimated from each
-random starting trees are printed in a separate tree file (see last row
-of Table [tab:output]).
-
-PhyML estimates ancestral sequences by calculating the marginal
-probability of each character state at each internal node of the
-phylogeny. These probabilities are given in the file
-`seq_phyml_ancestral_seq`. The bulk of this file is a table where each
-row corresponds to a site in the original alignment and an the number
-corresponding to an internal node. It is relatively straightforward to
-identify which number corresponds to which node in the tree by examining
-the information provided at the beginning of `seq_phyml_ancestral_seq`.
-This section of the file displays the tree structure in terms of a list
-of node numbers rather than in the NEWICK format. For instance, the tree
-`(A,B,(C,D));` corresponds to the following list of nodes:
-
-
-    Node nums:   0   4  (dir:  0) names = 'A'      '(null)';
-    Node nums:   4   2  (dir:  1) names = '(null)' 'B';
-    Node nums:   4   5  (dir:  2) names = '(null)' '(null)';
-    Node nums:   5   1  (dir:  0) names = '(null)' 'C';
-    Node nums:   5   3  (dir:  1) names = '(null)' 'D';
-
-The two integers following `Node nums` are the node numbers. They are
-displayed in a recursive manner. The number on the left column is that
-of the ancestral node while the one on the right column is the direct
-descendant. The following columns are the node names. These names are
-set to `null` except for the tip nodes, where the corresponding taxon
-names are displayed.
-
-Treatment of invariable sites with fixed branch lengths
--------------------------------------------------------
-
-PhyML allows users to give an input tree with fixed topology and branch
-lengths and find the proportion of invariable sites that maximise the
-likelihood (option `-o r`). These two options can be considered as
-conflicting since branch lengths depend on the proportion of invariants.
-Hence, changing the proportion of invariants implies that branch lengths
-are changing too. More formally, let $l$ denote the length of a branch,
-i.e., the expected number of substitutions per site, and $p$ be the
-proportion of invariants. We have $l =  (1-p)l'$, where $l'$ is the
-expected number of substitutions per \_variable\_ sites. When asked to
-optimize $p$ but leave $l$ unchanged, PhyML does the following:
-
-1.  Calculate $l' = l/(1-p)$ and leave $l'$ unchanged throughout the
-    optimization.
-
-2.  Find the value of $p$ that maximises the likelihood. Let $p^{*}$
-    denote this value.
-
-3.  Set $l^{*} = (1-p^{*})l'$ and print out the tree with $l^{*}$
-    (instead of $l$).
-
-PhyML therefore assumes that the users wants to fix the branch lengths
-measured at \_variable\_ sites only (i.e., $l^{*}$ is fixed). This is
-the reason why the branch lengths in the input and output trees do
-differ despite the use of the the `-o r` option. While we believe that
-this approach relies on a sound rationale, it is not perfect. In
-particular, the original transformation of branch lengths
-($l' =  l/(1-p)$) relies on a default value for $p$ with is set to 0.2
-in practice. It is difficult to justify the use of this value rather
-than another one. One suggestion proposed by Bart Hazes is to avoid
-fixing the branch lengths altogether and rather estimate the value of a
-scaling factor applied to each branch length in the input tree (option
-`–contrained_lens`). We agree that this solution probably matches very
-well most users expectation, i.e., “find the best value of $p$ while
-constraining the ratio of branch lengths to be that given in the input
-tree”. Please feel free to send us your suggestions regarding this
-problem by posting on the forum
-(<http://groups.google.com/group/phyml-forum>).
-
-Inputs & outputs for the XML interface  {#sec:xmlio}
-=======================================
-
-Mixture models in PhyML
------------------------
-
-[sec:mixtures]
-
-PhyML implements a wide range of mixture models. The discrete gamma
-model @yang94b is arguably the most popular of these models in
-phylogenetics. However, in theory, mixture models are not restricted to
-the description of the variation of substitution rates across sites. For
-instance, if there are good reasons to believe that the relative rates
-of substitution between nucleotides vary along the sequence alignments,
-it makes sense to use a mixture of GTR models. Consider the case where
-substitutions between $A$ and $C$ occur at high rate in some regions of
-the alignment and low rate elsewhere, a mixture with two classes, each
-class having its own GTR rate matrix, would be suitable. The likelihood
-at any site of the alignment is then obtained by averaging the
-likelihoods obtained for each GTR rate matrix, with the same weight
-given to each of these matrices.
-
-PhyML implements a generic framework that allows users to define
-mixtures on substitution rates, rate matrices and nucleotide or
-amino-acid equilibrium frequencies. Each class of the mixture model is
-built by assembling a substitution rate, a rate matrix[^1] and a vector
-of equilibrium frequencies. For instance, let $\{R_1,R_2,R_3\}$ be a set
-of substitution rates, $\{M_1,M_2\}$ a set of rate matrices and
-$\{F_1,F_2\}$ a set of vectors of equilibrium frequencies. One could
-then define the first class of the mixture model as
-$\mathcal{C}_1 = \{R_1,M_1,F_1\}$, a second class as
-$\mathcal{C}_2  = \{R_2,M_1,F_1\}$, and a third class as
-$\mathcal{C}_3  = \{R_3,M_2,F_2\}$. If $R_1$, $R_2$ and $R_3$ correspond
-to slow, medium and fast substitution rates, then this mixture model
-allows the fast evolving rates to have their own vector of equilibrium
-frequencies and rate matrix, distinct from that found at the medium or
-slow evolving sites. The likelihood at any given site $D_s$ of the
-alignment is then:
-
-$$\begin{aligned}
-\Pr(D_s) = \sum_{c=1}^{3} \Pr(D_s | \mathcal{C}_s=c) \Pr(\mathcal{C}_s=c),
-\label{equ:mixtlk}\end{aligned}$$
-
-where $\Pr(\mathcal{C}_s=c)$ is obtained by multiplying the probability
-(density) of the three components (i.e., rate, matrix, frequencies). For
-instance, $\Pr(\mathcal{C}_1=\{R_1,M_1,F_1\}) =
- \Pr(R_1)\times \Pr(M_1) \times \Pr(F_1)$. We therefore assume here that
-substitution rates, rate matrices and equilibrium frequencies are
-independent from one another.
-
-Note that, using the same substitution rates, rate matrices and vector
-of equilibrium frequencies, it is possible to construct many other
-mixture models. For instance, the mixture model with the largest number
-of classes can be created by considering all the combinations of these
-three components. We would then get a mixture of $3\times 2 \times 2=12$
-classes, corresponding to all the possible combinations of 3 rates, 2
-matrices and 2 vectors of frequencies.
-
-Partitions
-----------
-
-We first introduce some terms of vocabulary that have not been presented
-before. A partitionned data set, also referred to as partition, is a set
-of partition elements. Typically, a partitionned data set will be made
-of a set of distinct gene alignments. A partition element will then
-correspond to one (or several) of these gene alignments. Note that the
-biology litterature often uses the term partition to refer to an element
-of a partitionned data. We thus use here instead the mathematical
-definition of the terms ‘partition’ and ‘partition element’.
-
-Phylogenetics models usually assume individual columns of an alignment
-to evolve independently from one another. Codon-based models (e.g.,
- at yang98 [@yang00b; @yang02; @guindon04]) are exceptions to this rule
-since the substitution process applies here to triplets of consecutive
-sites of coding sequences. The non-independence of the substitution
-process at the three coding positions (due to the specificities of the
-genetic code), can therefore be accounted for. Assuming that sites
-evolve independently does not mean that a distinct model is fitted to
-each site of the alignment. Estimating the parameters of these models
-would not make much sense in practice due to the very limited amount of
-phylogenetic signal conveyed by individual sites. Site independence
-means instead that the columns of the observed alignment were sampled
-randomly from the same “population of columns”. The stochasticity of the
-substitution process running along the tree is deemed responsible to the
-variability of site patterns.
-
-Some parameters of the phylogenetic model are considered to be common to
-all the sites in the alignment. The tree topology is typically one such
-parameter. The transition/transversion ratio is also generally assumed
-to be the same for all columns. Other parameters can vary from site to
-site. The rate at which substitutions accumulate is one of these
-parameters. Hence, different sites can have distinct rates. However,
-such rates are all “drawn” from the same probabilitic distribution
-(generally a discrete Gamma density). Hence, while different sites may
-have distinct rates of evolution, they all share the same
-<span>*distribution*</span> of rates.
-
-This reasonning also applies on a larger scale. When analysing multiple
-genes, one can indeed assume that the same mechanism generated the
-different site patterns observed for every gene. Here again, we can
-assume that all the genes share the same underlying tree topology
-(commonly refered to as the “species tree”). Other parameters of the
-phylogenetic model, such as branch lengths for instance, might be shared
-across genes. However, due to the specificities of the gene evolution
-processes, some model parameters need to be adjusted for each gene
-separately. To sum up, the phylogenetic analysis of partitionned data
-requires flexible models with parameters, or distribution of parameters,
-shared across several partition elements and other parameters estimated
-separately for each element of the partition.
-
-The likelihood of a data set made of the concatenation of $n$ sequence
-alignments noted $D^{(1)}$, $D^{(2)}, \ldots, D^{(n)}$ is then obtained
-as follows:
-
-$$\begin{aligned}
-\Pr(D^{(1)},D^{(2)},\ldots,D^{(n)}) &=& \prod_{i=1}^{n}  \Pr(D^{(i)}) \\
-&=& \prod_{i=1}^{n}  \prod_{s=1}^{L_i} \Pr(D^{(i)}_s),\end{aligned}$$
-
-where $L_i$ is the number of site columns in partition element $i$.
-$\Pr(D^{(i)}_s)$ is then obtained using Equation [equ:mixtlk], i.e., by
-summing over the different classes of the mixture model that applies to
-site $s$ for partition element $i$. Hence, the joint probability of all
-the partition elements is here broken down into the product of
-likelihood of every site for each partition element. As noted just
-above, any given component of the mixture model at a given particular
-site is shared by the other sites that belong to the same partition
-element and, for some of them, by sites in other partition elements
-(e.g., the same tree topology is shared by all the sites, throughout all
-the partition elements).
-
-PhyML implements a wide variety of partition models. The only parameter
-that is constrained to be shared by all the partition elements is the
-tree topology. This constraint makes sense when considering distantly
-related taxa, typically inter-species data. For closely related taxa,
-i.e., when analysing intra-species or population-level data, not all the
-genes might have the same evolutionary history. Recombination events
-combined to the incomplete lineage sorting phenomenon can generate
-discrepancies between the gene trees and the underlying species tree
-(see @degnan09 for a review). The phylogenetic softwares BEST @best,
-STEM @stem and \*BEAST @startbeast are dedicated to the estimation of
-species tree phylogenies from the analysis of multi-gene data and allow
-gene-tree topologies to vary across genes.
-
-Aside from the tree topology that is common to all the sites and all the
-partition elements, other parameters of the phylogenetic model can be
-either shared across partition elements or estimated separately for each
-of these. When analysing three partition elements, $A$, $B$ and $C$ for
-instance, PhyML can fit a model where the same set of branch lengths
-applies to $A$ and $B$ while $C$ has its own estimated lengths. The same
-goes for the substitution model: the same GTR model, with identical
-parameter values, can be fitted to $A$ and $C$ and JC69 for instance can
-be used for $B$. The sections below give more detailed information on
-the range of models available and how to set up the corresponding XML
-configuration files to implement them.
-
-Combining mixture and partitions in PhyML: the theory
------------------------------------------------------
-
-The rationale behind mixture models as implemented in PhyML lies in (1)
-the definition of suitable rate matrices, equilibrium frequency vectors
-and relative rates of substitution and (2) the assembly of these
-components so as to create the classes of a mixture. The main idea
-behind partitionned analysis in PhyML lies in (1) the hypothesis of
-statistical independance of the different data partition elements and
-(2) distinct data partition can share model components such as rate
-matrices, equilibrium frequencies or distribution of rates across sites.
-More formally, the likelihood of a data set made of $n$ partition
-elements is written as follows:
-
-$$\begin{aligned}
-\Pr(D^{(1)},D^{(2)},\ldots,D^{(n)}) &=& \prod_{i=1}^{n}  \prod_{s=1}^{L_i} \Pr(D^{(i)}_s) \\
-&=& \prod_{i=1}^{n}  \prod_{s=1}^{L_i} \sum_{c=1}^{K_i} \Pr(D^{(i)}_s|\mathcal{C}=c) \Pr(\mathcal{C}=c),\end{aligned}$$
-
-where $L_i$ is the number of sites in partition element $i$ and $K_i$ is
-the number of classes in the mixture model that applies to this same
-partition element. Each class of a mixture is made of a rate matrix $M$,
-a vector of equilibrium frequencies $F$ and a relative rate of
-substitution $R$. Branch lengths, $L$ and tree topology $\tau$ are also
-required for the calculation of the likelihood. Hence we have:
-
-$$\begin{aligned}
-&& \Pr(D^{(1)},D^{(2)},\ldots,D^{(n)})  \\
-&&=  \prod_{i=1}^{n}  \prod_{s=1}^{L_i} \sum_{c=1}^{K_i} \Pr(D^{(i)}_s|\mathcal{C}=c) \Pr(\mathcal{C}=c) \\
-&&= \prod_{i=1}^{n}  \prod_{s=1}^{L_i} \sum_{m}^{\mathcal{M}_i} \sum_{f}^{\mathcal{F}_i} \sum_{r}^{\mathcal{R}_i}  \Pr(D^{(i)}_s|M_m^{(i)},F_f^{(i)},R_r^{(i)},L^{(i)},\tau) \Pr(M_m^{(i)},F_f^{(i)},R_r^{(i)}) \mathcal{I}(m,f,r,i)\end{aligned}$$
-
-where $\mathcal{M}_i$, $\mathcal{F}_i$ and $\mathcal{R}_i$ are the
-number of rate matrices, vector of equilibrium frequencies and relative
-rates that apply to partition element $i$ respectively.
-$\mathcal{I}(m,f,r,i)$ is an indicator function that takes value 1 if
-the combination $M_m$, $F_f$ and $R_r$ is acually defined in the model
-for this particular partition element $i$. Its value is 0 otherwise. In
-the example given in section [sec:mixtures] $\{R_1,R_2,R_3\}$ is the set
-of substitution rates, $\{M_1,M_2\}$ the set of rate matrices and
-$\{F_1,F_2\}$ the set of vectors of equilibrium frequencies. We then
-define the first class of the mixture model as
-$\mathcal{C}_1 = \{R_1,M_1,F_1\}$, a second class as
-$\mathcal{C}_2  = \{R_2,M_1,F_1\}$ and the third as
-$\mathcal{C}_3  = \{R_3,M_2,F_2\}$. Hence, we have
-$\mathcal{I}(1,1,1,i)$, $\mathcal{I}(1,1,2,i)$ and
-$\mathcal{I}(2,2,3,i)$ equal to one while the nine other values that
-this indicator function takes, corresponding to the possible
-combinations of two vectors of frequencies, two matrices and three
-rates, are all zero.
-
-As stated before, our implementation assumes that the different
-components of a mixture are independant. In other words, we have
-$\Pr(M_m^{(i)},F_f^{(i)},R_r^{(i)}) = \Pr(M_m^{(i)}) \times
-\Pr(F_f^{(i)}) \times \Pr(R_r^{(i)})$. In practice, the joint
-probability $\Pr(M_m^{(i)},F_f^{(i)},R_r^{(i)})$ is obtained as follows:
-
-$$\begin{aligned}
-\Pr(M_m^{(i)},F_f^{(i)},R_r^{(i)}) = \frac{\Pr(M_m^{(i)}) \Pr(F_f^{(i)}) \Pr(R_r^{(i)})}{
-  \sum_{m,f,r} \Pr(M_m^{(i)}) \Pr(F_f^{(i)}) \Pr(R_r^{(i)}) \mathcal{I}(m,f,r,i)}
-\label{equ:weights}\end{aligned}$$
-
-The probabilities $\Pr(M_m^{(i)})$, $\Pr(F_f^{(i)})$ and
-$\Pr(R_r^{(i)})$, also called ‘weights’, can be fixed or estimated from
-the data.
-
-The XML format and its use in PhyML {#sec:XML format}
------------------------------------
-
-The few paragraphs below are largely inspired from the Wikipedia page
-that describes the XML format (<http://en.wikipedia.org/wiki/XML>). XML
-(eXtensible Markup Language) is a markup language that defines a set of
-rules for encoding documents in a format that is both human-readable and
-machine-readable. An XML document is divided into <span>*markup*</span>
-and <span>*content*</span>, which may be distinguished by the
-application of simple syntactic rules. Generally, strings that
-constitute markup either begin with the character ‘`<`’ and end with a
-‘`>`’. Strings of characters that are not markup are content:
-
-    <markup>
-     content
-    </markup>
-
-A markup construct that begins with ‘`<`’ and ends with ‘`>`’ is called
-a <span>*tag*</span>. Tags come in three flavors: (1) start-tags (e.g,
-`<section>`), end-tags (e.g., `</section>`) and empty-element tags
-(e.g., `<line-break />`). A <span>*component*</span> either begins with
-a start-tag and ends with a matching end-tag or consists only of an
-empty-element tag. The characters between the start- and end-tags, if
-any, are the element’s content, and may contain markup, including other
-elements, which are called child elements. In the following example, the
-element `img` has two <span>*attributes*</span>, `src` and `alt`:
-`<img src=madonna.jpg alt=Foligno Madonna, by Raphael/>`. Another
-example would be `<step number=3>Connect A to B.</step>` where the name
-of the attribute is \`\``number`“ and the value is \`\``3`”.
-
-In practice, building a mixture model in a XML file readable by PhyML is
-relatively straightforward. The first step is to define the different
-components of each class of the mixture. Consider for instance that the
-fitted model will have a Gamma distribution with four classes plus a
-proportion of invariants. The rate component of the mixture can then be
-specified using the following XML code:
-
-
-    <siterates id="SiteRates1">
-      <weights  id="Distrib" family="gamma+inv" alpha=".1" \
-      optimise.alpha="yes" pinv="0.4" optimise.pinv="yes">
-      </weights>
-      <instance id="R1" init.value="1.0"/>
-      <instance id="R2" init.value="1.0"/>
-      <instance id="R5" init.value="0.0"/>
-      <instance id="R3" init.value="1.0"/>
-      <instance id="R4" init.value="1.0"/>
-    </siterates>
-
-In the example above, the `<siterates>` component completely defines a
-model of substitution rate variation across sites. This component has a
-particular identity, i.e., a name associated to it (“`SiteRates1`”
-here), which is not mandatory. This `<siterates>` component has six
-sub-components. The first is the `<weights>` component, followed by five
-`<instance>` components. The `<weights>` component defines the type of
-distribution that characterizes the variation of rates across sites. A
-discrete Gamma plus invariants is used here. Two parameters specify this
-distribution: the gamma shape and the proportion of invariant
-parameters. Their initial values are set by using the corresponding
-attributes and attribute values (`alpha=0.1` and `pinv=0.4`). Also,
-PhyML can optimise these parameters so as to maximise the likelihood of
-the whole phylogenetic model (`optimise.pinv=yes` and
-`optimise.alpha=yes`). The following five `<instance>` components define
-the rate classes themselves. The `id` attribute is here mandatory and
-must be unique to each class. Note that one of the initial (relative)
-rate (`init.value` attribute) is set to zero. The corresponding rate
-class (the third in this example) will then correspond to the invariant
-site category.
-
-Having specified the part of the phylogenetic model that describes the
-variation of rates across sites, we can now move on to build the rest of
-the model. The component below defines two substitution models:
-
-
-    <ratematrices id="RateMatrices">
-      <instance id="M1" model="HKY85" tstv="4.0" optimise.tstv="no"/>
-      <instance id="M2" model="GTR" optimise.rr="yes"/>
-    </ratematrices>
-
-This `<ratematrices>` component sets out a list of substitution models
-(HKY85 and GTR here). Here again, the different elements in this list
-correspond to the `<instance>` sub-components. Each instance must have a
-unique `id` attribute for a reason that will become obvious shortly. The
-remaining attributes and their functions are described in Section
-[sec:xmlratematrices].
-
-The next “ingredient” in our phylogenetic model are vectors of
-nucleotide frequencies. The `<equfreqs>` component below specifies two
-of such vectors:
-
-
-    <equfreqs id="EquFreq">
-      <instance id="F1"/>
-      <instance id="F2"/>
-    </equfreqs>
-
-Now, we need to assemble these three components (rate variation across
-sites, rate matrices and vectors of equilibrium frequencies) into a
-mixture model. The `<partitionelem>` component below defines one such
-model:
-
-
-    <partitionelem id="Part1" file.name="./nucleic.txt" data.type="nt">
-      <mixtureelem list="R1, R2, R3, R4, R5"/>
-      <mixtureelem list="M1, M1, M1, M2, M2"/>
-      <mixtureelem list="F1, F2, F1, F2, F2"/>
-    </partitionelem>
-
-The `<partitionelem>` component defines a particular partition element.
-In this example, the partition element corresponds to the sequence file
-called `nucleic.txt`, which is an alignment of nucleotide sequences (see
-the `data.type` attribute value). The `<mixtureelem>` are sub-components
-of the `<partitionelem>` component. Each `<mixtureelem>` has a `list`
-atrribute. Each such `list` gives the ID of components that have been
-defined before. For instance, the first `<mixtureelem>` refers to the
-five classes of the `<siterates>` component. The ordering of the
-different term in these list matters a lot since it is directly related
-to the elements in each class of the mixture model. Hence, the first
-element in the `<list>` attribute of the first `<mixtureelem>` added to
-the first element in the `<list>` attribute of the second
-`<mixtureelem>` plus the the first element in `<list>` attribute of the
-third `<mixtureelem>` defines the first class of the mixture model.
-Therefore, the mixture model defined above has five classes:
-$\mathcal{C}_1   =   \{R_1,M_1,F_1\}$, $\mathcal{C}_2   =
-\{R_2,M_1,F_2\}$, $\mathcal{C}_3   =  \{R_3,M_1,F_1\}$,
-$\mathcal{C}_4  =   \{R_4,M_2,F_2\}$ and
-$\mathcal{C}_5 = \{R_5,M_2,F_2\}$.
-
-Setting up mixture and partition models in PhyML: the basics
-------------------------------------------------------------
-
-Mixture models are particularly relevant to the analysis of partitionned
-data. Indeed, some features of evolution are gene-specific (e.g.,
-substitution rates vary across genes). Models that can accomodate for
-such variation, as mixture models do, are therefore relevant in this
-context. However, other evolutionary features are shared across loci
-(e.g., genes located in the same genomic region usually have similar GC
-contents). As a consequence, some components of mixture models need to
-be estimated separately for each partition element while others should
-be shared by different partition elements.
-
-Below is a simple example with a partitionned data set made of two
-elements:
-
-
-    <branchlengths id="BranchLens">
-      <instance id="L1"/>
-      <instance id="L2"/>
-    </branchlengths>
-
-    <partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-      <mixtureelem list="R1, R2, R3, R4, R5"/>
-      <mixtureelem list="L1, L1, L1, L1, L1"/>
-    </partitionelem>
-
-    <partitionelem id="Part2" file.name="./nucleic2.txt" data.type="nt">
-      <mixtureelem list="R1, R2, R3, R4, R5"/>
-      <mixtureelem list="L2, L2, L2, L2, L2"/>
-    </partitionelem>
-
-Mixture elements with names `R1`,$\ldots$, `R5` refer to the $\Gamma4+$I
-model defined previsouly (see Section [sec:XML format]). The
-`<branchlengths>` XML component defines a mixture element that had not
-been introduced before. It defined vectors of branch lengths that apply
-to the estimated phylogeny. Two instances of such vectors are defined:
-`L1` and `L2`. When examining the two partition elements
-(`<partitionelem>` component), it appears that `L1` is associated with
-`Part1` while `L2` is associated with `Part2`. Hence, branch lengths
-will be estimated separately for these two partition elements.
-
-Note that a given partition element can only have one
-<span>branchlengths</span> instance associated to it. For instance, the
-example given below is not valid:
-
-
-    <partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-      <mixtureelem list="R1, R2, R3, R4, R5"/>
-      <mixtureelem list="L1, L1, L1, L2, L2"/>
-    </partitionelem>
-
-In other words, mixture of branch lengths are forbidden. One reason for
-this restriction is that mixture of edge lengths sometimes lead to
-non-identifiable models (i.e., models with distinct sets of branch
-lengths have the same likelihood) @matsen07. But mostly, combining
-mixture of branch lengths with mixture of rates appears like a deadly
-combination. Consider for instance the following model:
-
-
-    <partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-      <mixtureelem list="R1, R2, R3"/>
-      <mixtureelem list="L1, L2, L3"/>
-    </partitionelem>
-
-It is here impossible to tell apart branch lengths and substitution
-rates. Such model is strongly non-identifiable and therefore not
-relevant.
-
-In the example given above, the same $\Gamma4+$I model (i.e. the same
-gamma shape parameter and proportion of invariant ) applies to the two
-partition elements. It is possible to use two distinct $\Gamma4+$I
-models instead using the following XML code:
-
-
-    <siterates id="SiteRates1">
-      <weights  id="Distrib1" family="gamma+inv" alpha=".1" \
-      optimise.alpha="yes" pinv="0.4" optimise.pinv="yes">
-      </weights>
-      <instance id="R1" init.value="1.0"/>
-      <instance id="R2" init.value="1.0"/>
-      <instance id="R5" init.value="0.0"/>
-      <instance id="R3" init.value="1.0"/>
-      <instance id="R4" init.value="1.0"/>
-    </siterates>
-
-    <siterates id="SiteRates2">
-      <weights  id="Distrib2" family="gamma+inv" alpha=".1" \
-      optimise.alpha="yes" pinv="0.4" optimise.pinv="yes">
-      </weights>
-      <instance id="R6"  init.value="1.0"/>
-      <instance id="R7"  init.value="1.0"/>
-      <instance id="R8"  init.value="0.0"/>
-      <instance id="R9"  init.value="1.0"/>
-      <instance id="R10" init.value="1.0"/>
-    </siterates>
-
-    <partitionelem id="Part1" file.name="./nucleic1.txt" data.type="nt">
-      <mixtureelem list="R1, R2, R3, R4, R5"/>
-      <mixtureelem list="L1, L1, L1, L1, L1"/>
-    </partitionelem>
-
-    <partitionelem id="Part2" file.name="./nucleic2.txt" data.type="nt">
-      <mixtureelem list="R6, R7, R8, R9, R10"/>
-      <mixtureelem list="L2, L2, L2, L2, L2"/>
-    </partitionelem>
-
-`SiteRates1` and `SiteRates2` here define two distinct $\Gamma4+$I
-models. Each of these models apply to one of the two partition elements
-(`nucleic1.txt` and `nucleic2.txt`), allowing them to display different
-patterns of rate variation across sites.
-
-XML options
------------
-
-### <span>phyml</span> component
-
-Options:
-
--   `output.file=filename`. The main output files of PhyML analysis will
-    be named `filename_phyml_tree` and `filename_phyml_stats`.
-
--   `bootstrap=nreplicates`. Run `nreplicates` replicates for the
-    non-parametric bootstrap analysis.
-
--   `run.id=idstring`. PhyML will append the string `idstring` to each
-    output file.
-
--   `print.trace=yes|true|no|false`. PhyML will print the estimated
-    trees (and the corresponding loglikelihoods) at multiple stages of
-    the estimation process. This option is useful for monitoring the
-    progress of the analysis when processing large data sets.
-
--   `branch.test=aBayes|aLRT|SH|no`. Calculate fast branch support using
-    the aBayes method @anisimova11, aLRT @anisimova06 or SH
-    @shimodaira99 tests. These branch statistics are much faster to
-    estimate than the bootrap proportions and usually provide good
-    estimates of the probabilities that the corresponding edges are
-    correctly inferred (see Anisimova et al. 2011 for more precision).
-    By default and if no bootstrap analysis is performed, branch
-    supports are estimated using the aBayes approach.
-
-### <span>topology</span> component
-
-Options:
-
--   `init.tree=bionj|user|random`. Starting tree. Default is `bionj`.
-
--   `file.name=name_of_tree_file`. In case `init.tree=user`, this
-    attribute is mandatory. `name_of_tree_file` is a text file
-    containing a tree in NEWICK format.
-
--   `optimise.tree=yes|true|no|false`. The starting tree topology as
-    defined by `init.tree` is to be optimised (or not) so as to maximise
-    the likelihood function.
-
--   `search=nni|spr|none`. Tree topology search is conducted using NNI
-    (fast), SPR (a bit slower but more accurate) or no moves.
-
-<!-- -->
-
-
-    <topology>
-      <instance id="T1" init.tree="bionj" optimise.tree="true" \
-       search="spr"/>
-    </topology>
-
-### <span>ratematrices</span> component
-
-[sec:xmlratematrices] Options:
-
--   `model=JC69|K80|F81|F84|HKY85|TN93|GTR|custom` for nucleotide data.
-    The default is `HKY85`.\
-    `model=LG|WAG|JTT|MtREV|Dayhoff|DCMut|RtREV|CpREV|VT`\
-    `|Blosum62|MtMam|MtArt|HIVw|HIVb|customaa` for amino-acid sequences.
-    The default is `LG`.
-
--   `model.code=012345`. For `custom` model applied to nucleotide
-    sequences: set the string of digits that define a custom
-    substitution model. See Table [tab:modelcode] on page for more
-    information about the model codes.
-
--   `ratematrix.code=filename`. When used in conjunction with
-    `model=customaa`, `filename` is the name of the file that gives the
-    rates of substitution between amino-acids as well as their
-    frequences at equilibrium using PAML rate matrix format. An example
-    of such file is provided in <span>phyml/examples/X1.mat</span>.
-
--   `optimise.rr=yes|true|no|false`. For `custom` and `GTR` nucleotide
-    models only: optimise the substitution rate model parameters.
-
--   `optimise.tstv=yes|true|no|false`. For `K80`, `F84`, `HKY85` and
-    `TN93` models only: optimise the transition/transversion rate ratio.
-
--   `tstv=value`. For `K80`, `HKY85` and `TN93` models only: set the
-    transition/transversion to a given value.
-
-The <span>ratematrices</span> component has the attribute
-<span>optimise.weights=yes/no</span> (default is <span>no</span>). If
-<span>optimise.weights=yes</span>, then the probabilities (or weights)
-or each matrix in the set of matrices defined by this component (see
-Equation [equ:weights]), will be estimated from the data.
-
-
-      <ratematrices id="RM1" optimise.weights="yes">
-        <instance id="M1" model="custom" model.code="000000"/>
-        <instance id="M2" model="GTR" optimise.rr="yes"/>
-        <instance id="M3" model="WAG"/>
-      </ratematrices>
-
-### <span>equfreqs</span> component
-
-Options:
-
--   `base.freqs=a,b,c,d` where `a-d` are nucleotide frequencies. Make
-    sure that these frequencies are separated by comas and no space
-    character is inserted.
-
--   `aa.freqs=empirical|model`. Amino-acid frequencies are derived from
-    counting the number of occurence of each amino-acid in the alignment
-    (`aa.freqs=empirical`) or given by the substitution model
-    (`aa.freqs=model`).
-
--   `optimise.freqs=true|yes|false|no`. Nucleotide frequencies can be
-    optimised so as to maximise the likelihood
-    (`optimise.freqs=yes|true`).
-
-The <span>equfreqs</span> component has the attribute
-<span>optimise.weights=yes/no</span> (default is <span>no</span>). If
-<span>optimise.weights=yes</span>, then the probabilities (or weights)
-or each vector of equilibrium frequencies in the set of vectors defined
-by this component (see Equation [equ:weights]), will be estimated from
-the data.
-
-
-      <equfreqs id="EF1" optimise.weights="yes">
-        <instance id="F1" base.freqs="0.25,0.25,0.25,0.25"/>
-        <instance id="F2" aa.freqs="empirical"/>
-        <instance id="F3" optimise.freq="yes"/>
-      </equfreqs>
-
-### <span>branchlengths</span> component
-
-Options:
-
--   `optimise.lens=yes|true|no|false`: branch lengths are optimised or
-    not. The default is set to `yes`.
-
-<!-- -->
-
-
-      <branchlengths id="BL1">
-        <instance id="L1" optimise.lens="yes"/>
-        <instance id="L2"/>
-        <instance id="L3" optimise.lens="false"/>
-      </branchlengths>
-
-### <span>siterates</span> component
-
-Options:
-
--   `value=val`, where `val` is the relative substitution rate for the
-    corresponding class.
-
-A `siterate` component generally includes a `weights` element that
-specifies the probabilitic distribution of the relative rates. The
-available options for such element are:
-
--   `family=gamma|gamma+inv|freerates`. `gamma` indicates that the
-    distribution of the relative rates is set to be a discrete Gamma
-    density. `gamma+inv` indicates that the relative rate model is a
-    mixture of Gamma and invariant sites (this is the common $\Gamma+$I
-    model). FreeRate is a model that does not use any parametric
-    function to describe the distribution of the relative rates (see
-    @soubrier12). Under this option, relative rates and the
-    corresponding frequencies of these classes are directly estimated
-    from the data. While such approach is slightly more computationally
-    demanding than the $\Gamma$ (or $\Gamma$+I) model, it often provides
-    a significantly better fit to the data.
-
--   `alpha=value|optimised`, where `value` is a real positive number.
-    Use this option to set the gamma shape parameter to the selected
-    value. `optimised`: the parameter is estimated from the data (see
-    also next option).
-
--   `optimise.alpha=yes|true|no|false`. Optimise the shape of the Gamma
-    distribution of relative rates (or not).
-
--   `pinv=value|optimised`, where `value` is in $[0,1]$. Use this option
-    to set the proportion of invariants to the selected value.
-    `optimised`: the parameter is estimated from the data (see also next
-    option).
-
--   `optimise.pinv=yes|true|no|false`. Optimise the proportion of
-    invariable sites (or not).
-
--   `optimise.freerates=yes|true|no|false`. Optimise the parameters of
-    the FreeRate model, i.e., the relative rates and the corresponding
-    frequencies.
-
-<!-- -->
-
-
-      <siterates id="SR1">
-        <instance id="R1" init.value="1.0"/>
-        <instance id="R2" init.value="1.0"/>
-        <instance id="R3" init.value="1.0"/>
-        <instance id="R4" init.value="1.0"/>
-        <weights  id="D1" family="gamma" optimise.alpha="yes" \
-        optimise.pinv="no">
-        </weights>
-      </siterates>
-
-### <span>partitionelem</span> and <span>mixtureelem</span> components
-
-Options:
-
--   `file.name=inputfilename`, where `inputfilename` is the name of the
-    input sequence file (in PHYLIP format) to be analysed.
-
--   `data.type=nt|aa`. Specify the type of sequences to be processed
-    (nucleotide of amino-acid sequences).
-
--   `interleaved=yes|true|no|false`. Interleaved (`yes|true`) or
-    sequential format (`no|false`) for the sequence alignment.
-
-Each `partitionelem` element should include exactly four `mixtureelem`
-elements, corresponding to branch lengths, equilibrium frequencies,
-substitution rate model and tree topology. The ordering of in which the
-`mixtureelem` elements are given does not matter, though exceptions
-apply for the $\Gamma+I$ model (see below). The $n$-th element in the
-`list` attribute of each `mixtureelem` defines the $n$-th class of the
-mixture model. In the example given below, the first class of the
-mixture is made of the following elements: `T1`, `F1`, `R1` and `L1`,
-the second class is made of `T1`, `F1`, `R2` and `L1`, etc.
-
-
-      <partitionelem id="partition1" file.name="./small_p1.nxs" \
-       data.type="nt" interleaved="yes">
-        <mixtureelem list="T1, T1, T1, T1"/>
-        <mixtureelem list="F1, F1, F1, F1"/>
-        <mixtureelem list="R1, R2, R3, R4"/>
-        <mixtureelem list="L1, L1, L1, L1"/>
-      </partitionelem>
-
-In general, the ordering of the `mixtureelem` elements does not matter.
-However, when the model has invariable sites, then the corresponding
-class should be first in the list of classes provided by `mixtureelem`.
-For instance, in the example above, if the rates are defined as follows:
-
-
-      <siterates id="SR1">
-        <instance id="R1" init.value="0.0"/>
-        <instance id="R2" init.value="1.0"/>
-        <instance id="R3" init.value="1.0"/>
-        <instance id="R4" init.value="1.0"/>
-        <weights  id="D1" family="gamma+inv" optimise.alpha="yes" \
-        optimise.pinv="no">
-        </weights>
-      </siterates>
-
-then `R1` corresponds to the invariable rate class (as
-`init.value=0.0`). As `R1` is first in the `mixtureelem` (see line 6 in
-the example of `partionelem` given above), PhyML will print out an
-explicit error message and bail out. One way to avoid this shortcoming
-is to define `mixtureelem` as `R4, R2, R3, R1` instead.
-
-A simple example: GTR + $\Gamma$4 + I
--------------------------------------
-
-The example below provides all the required options to fit a $\Gamma$4+I
-model to a single alignment of nucleotide sequences under the GTR model
-of substitution using a SPR search for the best tree topology. The
-`phyml` component sets the name for the analysis to `simple.example`,
-meaning that each output file will display this particular string of
-characters. Also, the tree and statistics file names will begin with
-`p1.output`. The tree topology will be estimated so as to maximise the
-likelihood and the topology search algorithm used here is SPR, as
-indicated by the value of the corresponding attribute (i.e.,
-`search=spr`). Only one vector of branch lengths will be used here since
-only one partition element will be processed. Hence, the
-`<branchlengths>` component only has one `<instance>` sub-component.
-Also, a single GTR model will apply to all the classes for the mixture
-model – the `<ratematrices>` component has only one `<instance>`
-sub-component, corresponding to this particular substitution model. The
-next component, `<equfreqs>`, indicates that a single vector of
-equilibrium frequencies will apply here. Next, the `<siterates>`
-component has five `<instance>` sub-components. Four of these correspond
-to the non-zero relative rates of evolution a defined by a discrete
-Gamma distribution. The last one (`<instance id=R5 value=0.0/>`) defines
-the class of the mixture corresponding to invariable sites. The
-`<weight>` component indicates that a $\Gamma+$I model will be fitted
-here. The shape parameter of the Gamma distribution and the proportion
-of invariants will be estimated from the data. The `<partitionelem>`
-gives information about the sequence alignment (the corresponding file
-name, the type of data and the alignment format). The `<mixtureelem>`
-components next define the mixture model. Each class of the fitted model
-corresponds to one column, with the first column made of the following
-elements: `T1, M1, F1, R1` and `L1`. The second class of the mixture is
-made of `T1, M1, F1, R2, L1` and so forth.
-
-
-    <phyml runid="simple.example" output.file="p1.output">
-
-      <topology>
-        <instance id="T1" init.tree="bionj" optimise.tree="yes" \
-        search="spr"/>
-      </topology>
-
-      <branchlengths id="BL1">
-        <instance id="L1" optimise.lens="yes"/>
-      </branchlengths>
-
-      <ratematrices id="RM1">
-        <instance id="M1" model="GTR"/>
-      </ratematrices>
-
-      <equfreqs id="EF1">
-        <instance id="F1"/>
-      </equfreqs>
-
-      <siterates id="SR1">
-        <instance id="R1" value="1.0"/>
-        <instance id="R2" value="1.0"/>
-        <instance id="R3" value="1.0"/>
-        <instance id="R4" value="1.0"/>
-        <instance id="R5" value="0.0"/>
-        <weights  id="D1" family="gamma+inv" optimise.alpha="yes" \
-        optimise.pinv="yes">
-        </weights>
-      </siterates>
-
-      <partitionelem id="partition_elem1" file.name=\
-      "./p1.seq" data.type="nt" interleaved="yes">
-        <mixtureelem list="T1, T1, T1, T1, T1"/>
-        <mixtureelem list="M1, M1, M1, M1, M1"/>
-        <mixtureelem list="F1, F1, F1, F1, F1"/>
-        <mixtureelem list="R1, R2, R3, R4, R5"/>
-        <mixtureelem list="L1, L1, L1, L1, L1"/>
-      </partitionelem>
-
-    </phyml>
-
-A second example: LG4X
-----------------------
-
-The example below shows how to fit the LG4X model @lg4x to a given
-alignment of amino-acid sequences (file `M587.nex.Phy`). LG4X is a
-mixture model with four classes. Each class has its own rate and
-corresponding frequencies (hence the use of the FreeRate model below,
-see the `<siterates>` component). In the particular example given here,
-the rate values and frequencies are set by the users. These parameters
-will then be optimized by PhyML (`optimise.freerates=yes`). Each class
-also has its own rate matrix and vector of equilibrium frequencies,
-which need to be provided by the user (Note that these matrices can be
-downloaded from the following web address:
-<http://www.atgc-montpellier.fr/download/datasets/models/lg4x/LG4X_4M.txt>.
-They are also provided in the PhyML package `example/lg4x/` directory.)
-
-    <phyml run.id="lg4x" output.file="M587.tests" branch.test="no">
-
-      <!-- Tree topology: start with BioNJ and then SPRs -->
-      <topology>
-        <instance id="T1" init.tree="user" file.name="user_tree.txt" \
-        search="spr" optimise.tree="no"/>
-      </topology>
-
-
-      <!-- Four rate matrices, read from files -->
-      <ratematrices id="RM1">
-        <instance id="M1" model="customaa" ratematrix.file="X1.mat"/>
-        <instance id="M2" model="customaa" ratematrix.file="X2.mat"/>
-        <instance id="M3" model="customaa" ratematrix.file="X3.mat"/>
-        <instance id="M4" model="customaa" ratematrix.file="X4.mat"/>
-      </ratematrices>
-
-      <!-- Freerate model of variation of rates across sites -->
-      <siterates id="SR1">
-        <instance id="R1" init.value="0.197063"/>
-        <instance id="R2" init.value="0.750275"/>
-        <instance id="R3" init.value="1.951569"/>
-        <instance id="R4" init.value="5.161586"/>
-        <weights  id="D1" family="freerates" optimise.freerates="yes">
-          <instance appliesto="R1" value="0.422481"/>
-          <instance appliesto="R2" value="0.336848"/>
-          <instance appliesto="R3" value="0.180132"/>
-          <instance appliesto="R4" value="0.060539"/>
-        </weights>
-      </siterates>
-
-      <!-- Amino-acid equilibrium freqs. are given by the models -->
-      <equfreqs id="EF1">
-        <instance id="F1" aa.freqs="model"/>
-        <instance id="F2" aa.freqs="model"/>
-        <instance id="F3" aa.freqs="model"/>
-        <instance id="F4" aa.freqs="model"/>
-      </equfreqs>
-
-
-      <!-- One vector of branch lengths -->
-      <branchlengths id="BL1" >
-        <instance id="L1" optimise.lens="yes"/>
-      </branchlengths>
-
-
-      <!-- Mixture model assemblage -->
-      <partitionelem id="partition1" file.name="M587.nex.Phy" \
-      data.type="aa" interleaved="yes">
-        <mixtureelem list="T1, T1, T1, T1"/>
-        <mixtureelem list="M1, M2, M3, M4"/>
-        <mixtureelem list="F1, F2, F3, F4"/>
-        <mixtureelem list="R1, R2, R3, R4"/>
-        <mixtureelem list="L1, L1, L1, L1"/>
-      </partitionelem>
-
-    </phyml>
-
-In order to fit the LG4X model to the `proteic` sequence file provided
-in the `examples/` directory, simply type
-`./phyml –xml=../examples/lg4x/lg4x.xml` (assuming the PhyML binary is
-installed in the `src/` directory). You can of course slightly tweak the
-file `../examples/lg4x/lg4x.xml` and use it as a template to fit this
-model to another data set.
-
-An example with multiple partition elements
--------------------------------------------
-
-The example below gives the complete XML file to specify the analysis of
-three partition elements, corresponding to the nucleotide sequence files
-`small_p1_pos1.seq`, `small_p1_pos2.seq` and `small_p1_pos3.seq` in
-interleaved PHYLIP format. `small_p1_pos1.seq` is fitted with the HKY85
-model of substitution (with the transition/transversion ratio being
-estimated from the data), combined to a $\Gamma4$ model of rate
-variation across sites (with the gamma shape parameter being estimated
-from the data). `small_p1_pos2.seq` is fitted to a custom substitution
-model with the constraint $A\leftrightarrow  G$=$C\leftrightarrow  T$.
-The nucleotide frequencies are set to $\frac{1}{4}$ here. The model does
-not allow substitution rates to vary across sites. `small_p1_pos3.seq`
-is fitted using a GTR model conbined to a $\Gamma4+$I model of rate
-variation across sites. Note that the equilibrium nucleotide frequencies
-for the fourth and fifth class of the mixture are set to be equal to
-that estimated from the first partition element (i.e., `F1`) . The
-initial phylogeny is built using BioNJ and the tree topology is to be
-estimated using a NNI search algorithm.
-
-
-    <phyml runid="nnisearch" output.file="small_p1_output">
-
-      <topology>
-        <instance id="T1" init.tree="bionj" optimise.tree="yes" \
-        search="nni"/>
-      </topology>
-
-      <branchlengths id="BL1">
-        <instance id="L1" optimise.lens="yes"/>
-        <instance id="L2"/>
-        <instance id="L3"/>
-      </branchlengths>
-
-      <ratematrices id="RM1">
-        <instance id="M1" model="HKY85" optimise.tstv="yes"/>
-        <instance id="M2" model="custom" model.code="102304" \
-        optimise.rr="yes"/>
-        <instance id="M3" model="GTR"/>
-      </ratematrices>
-
-      <equfreqs id="EF1">
-        <instance id="F1"/>
-        <instance id="F2" base.freqs="0.25,0.25,0.25,0.25"/>
-        <instance id="F3"/>
-      </equfreqs>
-
-      <siterates id="SR1">
-        <instance id="R1" value="1.0"/>
-        <instance id="R2" value="1.0"/>
-        <instance id="R3" value="1.0"/>
-        <instance id="R4" value="1.0"/>
-        <weights  id="D1" family="gamma" optimise.alpha="yes" \
-        optimise.pinv="no">
-        </weights>
-      </siterates>
-
-      <siterates id="SR2">
-        <instance id="R8" value="1.0"/>
-        <weights  id="D2" family="gamma" optimise.alpha="yes" \
-        optimise.pinv="yes">
-        </weights>
-      </siterates>
-
-      <siterates id="SR3">
-        <instance id="R10" value="1.0"/>
-        <instance id="R11" value="1.0"/>
-        <instance id="R12" value="1.0"/>
-        <instance id="R13" value="1.0"/>
-        <instance id="R14" value="1.0"/>
-        <weights  id="D3" family="gamma" optimise.alpha="yes" \
-        optimise.pinv="yes">
-        </weights>
-      </siterates>
-
-
-      <partitionelem id="partition_elem1" file.name=\
-      "./small_p1_pos1.seq" data.type="nt" interleaved="yes">
-        <mixtureelem list="T1, T1, T1, T1"/>
-        <mixtureelem list="M1, M1, M1, M1"/>
-        <mixtureelem list="F1, F1, F1, F1"/>
-        <mixtureelem list="R1, R2, R3, R4"/>
-        <mixtureelem list="L1, L1, L1, L1"/>
-      </partitionelem>
-
-      <partitionelem id="partition_elem2" file.name=\
-      "./small_p1_pos2.seq" data.type="nt" interleaved="yes">
-        <mixtureelem list="T1"/>
-        <mixtureelem list="M2"/>
-        <mixtureelem list="R8"/>
-        <mixtureelem list="F2"/>
-        <mixtureelem list="L2"/>
-      </partitionelem>
-
-      <partitionelem id="partition_elem3" file.name=\
-      "./small_p1_pos3.seq" data.type="nt" interleaved="yes">
-        <mixtureelem list="T1, T1, T1, T1, T1"/>
-        <mixtureelem list="M3, M3, M3, M3, M3"/>
-        <mixtureelem list="R10, R11, R12, R13, R14"/>
-        <mixtureelem list="F3, F3, F3, F1, F1"/>
-        <mixtureelem list="L3, L3, L3, L3, L3"/>
-      </partitionelem>
-
-    </phyml>
-
-Branch lengths with invariants and partionned data
---------------------------------------------------
-
-Accommodating for models with invariable sites applying to some elements
-of a partitioned data, with these elements sharing the same set of edge
-lengths can lead to inconsistencies. Consider for instance a partitioned
-data set with two elements. Assume that these two elements share the
-same set of edge lengths. Also, consider that GTR+I applies to the first
-element and HKY applies to the second. Now, the expected number of
-substitutions per site for the first element of the partition is equal
-to $(1-p)l$, where $p$ is the estimated proportion of invariants and $l$
-is the maximum-likelihood estimate for the length of that specific edge.
-For the second element of the partition, the expected number of
-substitutions per site is equal to $l$, rather than $(1-p)l$. While $l$
-are common to the two elements, matching the specification of the input
-model, the actual edge lengths do differ across the two partition
-elements. Please be aware that, due to the programming structure
-implemented in PhyML, the program will only return one value here, which
-will be equal to $(1-p)l$.
-
-Citing PhyML
-============
-
-The “default citation” for PhyML is:
-
--   “New algorithms and methods to estimate maximum-likelihood
-    phylogenies: assessing the performance of PhyML 3.0”. Guindon S.,
-    Dufayard J.F., Lefort V., Anisimova M., Hordijk W., Gascuel O. 2010,
-    <span>*Systematic Biology*</span>, 59(3):307-321
-
-The “historic citation” for PhyML is:
-
--   “A simple, fast and accurate algorithm to estimate large phylogenies
-    by maximum likelihood” Guindon S., Gascuel O. 2003,
-    <span>*Systematic Biology*</span>, 52(5):696-704
-
-Other programs in the PhyML package
-===================================
-
-PhyML is software package that provides tools to tackle problems other
-than estimating maximum likelihood phylogenies. Installing these tools
-and processing data sets is explained is the following sections.
-
-PhyTime
--------
-
-PhyTime is a program that estimates node ages and substitution rates
-using a Bayesian approach. The performance and main features of this
-software are described in two article (see Section [sec:citephytime]).
-
-It relies on a Gibbs sampler which outperforms the “standard”
-Metropolis-Hastings algorithm implemented in a number of phylogenetic
-softwares. The details and performance of this approach are described in
-the following article:
-
-### Installing PhyTime
-
-Compiling PhyTime is straightforward on Unix-like machines (i.e., linux
-and MacOS systems). PhyTime is not readily available for Windows
-machines but compilation should be easy on this system too. In the
-‘phyml’ directory, where the ‘src/’ and ‘doc/’ directories stand, enter
-the following commands:
-
-    ./configure --enable-phytime;
-    make clean;
-    make;
-
-This set of commands generates a binary file called `phytime` which can
-be found in the ‘src/’ directory.
-
-### Running PhyTime
-
-Passing options and running PhyTime on your data set is quite similar to
-running PhyML in commmand-line mode. The main differences between the
-two programs are explained below:
-
--   PhyTime takes as mandatory input a <span>*rooted*</span>
-    phylogenetic tree. Hence, the ‘`-u`’ option must be used. Also,
-    unlike PhyML, PhyTime does not modify the tree topology. Hence, the
-    options that go with the ‘`-s`’ command do not alter the input tree
-    topology.
-
--   PhyTime needs an input file giving information about calibration
-    nodes. The command ‘`–calibration=`’ followed by the name of the
-    file containing the calibration node information is mandatory. The
-    content of that file should look as follows:
-
-        Dugong_dugon Procavia_capensis Elephantidae | -65 -54
-        Equus_sp. Ceratomorpha | -58 -54
-        Cercopithecus_solatus Macaca_mulatta Hylobates_lar Homo_sapiens | -35 -25
-        Lepus_crawshayi Oryctolagus_cuniculus Ochotona_princeps | -90 -37
-        Marmota_monax Aplodontia_rufa | -120 -37
-        Dryomys_nitedula Glis_glis | -120 -28.5
-        @root@ | -100 -120
-
-    Every row in this file lists a set of taxa that belong to the same
-    subtree (i.e., a clade). This list of taxa is followed by the
-    character ‘`|`’ and two real numbers corresponding to the lower and
-    upper bounds of the calibration interval for the node at the root of
-    the clade. In the example given here, the clade grouping the three
-    taxa “Dugong\_dugon”, “Procavia\_capensis” and “Elephantida” has -65
-    as lower bound and -54 as upper bound. Node ages (or node heights)
-    are relative to the most recent tip node in the phylogeny, which age
-    is set to 0. It is also possible to define a clade using only two
-    taxon names. PhyTime will then search for the most recent common
-    ancestor of these two taxa in the user-defined phylogeny and assign
-    time boundaries to the corresponding node. For serially-sampled
-    data, the calibration nodes correspond to tips in the tree. A
-    calibration file will then look as follows:
-
-        taxaA | -65 -65
-        taxaB | -65 -65
-        taxaC | -20 -20
-        taxaD | -30 -30
-        taxaE | -30 -30
-        taxaF | -60 -60
-        taxaG | -61 -51
-        @root@ | -100 -120
-
-    Note that the node corresponding to the root of the whole tree has a
-    specific label: ‘`@root@`’. As a consequence, leaving the prior on
-    root height interval unspecified may produce inaccurate estimates of
-    node ages, especially if there are only few otherwise calibration
-    nodes available.
-
-    A notable exception to this rule comes from the analysis of serial
-    sample data, i.e., alignments in which sequences were not sampled at
-    the same time point. For such data, the estimated number of
-    substitutions accumulated between successive time points is used to
-    estimate the substitution rate averaged over lineages. Because the
-    time of collection of the sequences is generally known without
-    ambiguity, this extra piece of data is translated into very
-    informative calibration intervals for the tip nodes (i.e.,
-    calibration interval of zero width), which in turn results in
-    substitution rate estimates with descreased variances. Posterior
-    distribution of substitution rates with small variances then allows
-    one to get good estimates of the root age.
-
-A typical PhyTime command-line should look like the following:
-
-    ./phytime -i seqname -u treename --calibration=calibration_file -m GTR -c 8
-
-Assuming the file ‘`seqname`’ contains DNA sequences in PHYLIP or NEXUS
-format, ‘`treename`’ is the rooted input tree in Newick format and
-‘`calibration_file`’ is a set of calibration nodes, PhyTime will
-estimate the posterior distribution of node times and substitution rates
-under the assumption that the substitution process follows a GTR model
-with 8 classes of rates in the Gamma distribution of rates across sites.
-The model parameter values are estimated by a Gibbs sampling technique.
-This algorithm tries diferent values of the model parameters and record
-the most probable ones. By default, $10^6$ values for each parameter are
-collected. These values are recorded every $10^3$ sample. These settings
-can be modified using the appropriate command-line options (see below).
-
-### Upper bounds of model parameters
-
-The maximum expected number of substitutions per along a given branch is
-set to 1.0. Since calibration times provide prior information about the
-time scale considered, it is possible to use that information to define
-an upper bound for the substitution rate. This upper bound is equal to
-the ratio of the maximum value for a branch length (1.0) by the amount
-of time elapsed since the oldest calibration point (i.e., the minimum of
-the lower bounds taken over the whole set of calibration points)[^2]. It
-is important to keep in mind that the upper bound of the average
-substitution rate depends on the time unit used in the calibration
-priors. The value of the upper bound is printed on screen at the start
-of the execution.
-
-PhyTime implements two models that authorize rates to be autocorrelated.
-The strength of autocorrelation is governed by a parameter which value
-is estimated from the data. However, it is necessary to set an
-appropriate upper bound for this parameter prior running the analysis.
-The maximum value is set such that the correlation between the rate at
-the beginning and at the end of a branch of length 1.0 calendar time
-unit is not different from 0. Here again the upper bound for the model
-parameter depends on the time unit. It is important to choose this unit
-so that a branch of length 1.0 calendar unit can be considered as short.
-For this reason, .
-
-### PhyTime specific options
-
-Beside the `–calibration` option, there are other command line options
-that are specific to PhyTime:
-
--   `–chain_len=num`\
-    `num` is the number of iterations required to estimate the joint
-    posterior density of all the model parameters, i.e., the length of
-    the MCMC chain. Its default is set to 1E+6.
-
--   `–sample_freq=num`\
-    `num` is the number of generations between successive collection of
-    the model parameter values throughout the MCMC algorithm. For
-    instance, the `–sample_freq=1E+2` option will make PhyTime sample
-    the model parameter every 100th iteration of the MCMC algorithm. Its
-    default is set to 1E+3.
-
--   `–fastlk=yes (no)` [Default: no]\
-    The option is used to turn on (off) the approximation of the
-    likelihood function using a multivariate normal density. By default,
-    the exact likelihood is used. Using the normal approximation
-    considerably speeds up the calculation. However, it is necessary to
-    ensure that this approximation is appropriate by looking at the
-    correlation between the exact and approximated likelihood values
-    that are sampled. Please read Section [sec:recomphytime] for a
-    description of the appropriate steps to take.
-
--   `–no_sequences`\
-    Use this option to run the sampler without sequence data. This
-    option can be useful when one wants to compare the marginal
-    posterior density of model parameters to those derived when ignoring
-    the information conveyed by the sequences. Such comparison should be
-    conducted on a systematic basis so as to determine whether the
-    parameters estimates are mostly determined by the prior of driven by
-    the sequence data.
-
--   `–rate_model=gbs/gbd/gamma/clock`\
-    This option is to select the model of evolution of the rate of
-    evolution. `gbs` (default) stands for Geometric Brownian +
-    Stochastic. This model considers that rates evolve along the tree
-    according to a geometric Brownian process @kishino01 and the average
-    rate of substitution along a branch is a gamma distributed random
-    variable. This model is described in @guindon12. The `gbd` model
-    (Geometric Browninan with Deterministic calculation of edge lengths)
-    assumes the same Geometric Brownian model of rates. However, as
-    opposed to `gbs`, this model uses a deterministic approximation to
-    calculate the average rates of evolution along edges. This model
-    corresponds to the one described in @kishino01 and implemented in
-    the program Multidivtime. `gamma` is a less sophisticated model that
-    assumes that average rates along edges are distributed a priori
-    according to a gamma distribution. It is analogous to the
-    uncorrelated clock model implemented in BEAST with a gamma
-    distribution replacing the exponential one. The `clock` option
-    corresponds to the strict clock model where all the lineages in the
-    tree evolve at the same pace.
-
-### PhyTime output
-
-The program PhyTime generates two output files. The file called
-‘`your_seqfile_phytime.XXXX.stats`’, where XXXX is a randomly generated
-integer, lists the node times and branch relative rates sampled during
-the estimation process. It also gives the sampled values for other
-parameters, such as the autocorrelation of rates (parameter ‘Nu’), and
-the rate of evolution (parameter ‘EvolRate’) amongst others. This output
-file can be analysed with the program Tracer from the BEAST package
-(<http://beast.bio.ed.ac.uk/Main_Page>). The second file is called
-‘`your_seqfile_phytime.XXXX.trees`’. It is the list of trees that were
-collected during the estimation process, i.e., phylogenies sampled from
-the posterior density of trees. This file can be processed using the
-software TreeAnnotator, also part of the BEAST package (see
-<http://beast.bio.ed.ac.uk/Main_Page>) in order to generate confidence
-sets for the node time estimates.
-
-Important information is also displayed on the standard output of
-PhyTime (the standard output generally corresponds to the terminal
-window from which PhyTime was launched). The first column of this output
-gives the current generation, or run, of the chain. It starts at 1 and
-goes up to 1E+6 by default (use `–chain_len` to change this value, see
-above). The second column gives the time elapsed in seconds since the
-sampling began. The third column gives the log likelihood of the
-phylogenetic model (i.e., ‘Felsenstein’s likelihood’). The fourth column
-gives the logarithm of the joint prior probability of substitution rates
-along the tree and node heights. The fifth column gives the current
-sampled value of the EvolRate parameter along with the corresponding
-Effective Sample Size (ESS) (see Section [sec:ess]) for this parameter.
-The sixth column gives the tree height and the corresponding ESS. The
-seventh column gives the value of the autocorrelation parameter followed
-by the corresponding ESS. The eightth column gives the values of the
-birth rate parameter that governs the birth-rate model of species
-divergence dates. The last column of the standard output gives the
-minimum of the ESS values taken over the whole set of node height
-estimates. It provides useful information when one has to decide whether
-or not the sample size is large enough to draw valid conclusion, i.e.,
-decide whether the chain was run for long enough (see Section
-[sec:recomphytime] for more detail about adequate chain length).
-
-### ClockRate vs. EvolRate
-
-The average rate of evolution along a branch is broken into two
-components. One is called ClockRate and is the same throughout the tree.
-The other is called EvolRate and corresponds to a weighted average of
-branch-specific rates. The model of rate evolution implemented in
-PhyTime forces the branch-specific rate values to be greater than one.
-As a consequence, ClockRate is usually smaller EvolRate.
-
-In more mathematical terms, let $\mu$ be the value of ClockRate, $r_i$
-be the value of the relative rate along branch $i$ and $\Delta_i$ the
-time elapsed along branch $i$. The value of EvolRate is then given by:
-
-$$\begin{aligned}
-\mathrm{EvolRate} = \mu \frac{\sum_{i}^{2n-3} r_i \Delta_i}{\sum_{i}^{2n-3} \Delta_i}.\end{aligned}$$
-
-It is clear from this equation that multiplying each $r_i$ by a constant
-and dividing $\mu$ by the same constant does not change the value of
-EvolRate. The $r_i$s and $\mu$ are then confounded, or non-identifiable,
-and only the value of EvolRate can be estimated from the data. .
-
-### Effective sample size {#sec:ess}
-
-The MCMC technique generates samples from a target distribution (in our
-case, the joint posterior density of parameters). Due to the Markovian
-nature of the method, these samples are not independent. The ESS is the
-estimated number of independent measurements obtained from a set of
-(usually dependent) measurements. It is calculated using the following
-formula:
-
-$$\begin{aligned}
-\mathrm{ESS} = N\left(\frac{1-r}{1+r}\right),\end{aligned}$$
-
-where $N$ is the length of the chain (i.e., the ‘raw’ or ‘correlated’
-sample size) and $r$ is the autocorrelation value, which is obtained
-using the following formula:
-
-$$\begin{aligned}
-r = \frac{1}{(N-k)\sigma_x^2} \sum_{i=1}^{N-k} (X_i - \mu_x)(X_{i+k}-\mu_x),\end{aligned}$$
-
-where $\mu_x$ and $\sigma_x$ are the mean and standard deviation of the
-$X_i$ values respectively and $k$ is the lag. The value of $r$ that is
-used in PhyTime corresponds to the case where $k=1$, which therefore
-gives a first order approximation of the ‘average’ autocorrelation value
-(i.e., the autocorrelation averaged over the set of possible values of
-the lag).
-
-### Prior distributions of model parameters {#sec:prior}
-
-Any Bayesian analysis requires specifying a prior distribution of model
-parameters. The outcome of the data analysis, i.e., the posterior
-distribution, is influenced by the priors. It is especially true if the
-signal conveyed by the data is weak. While some have argued that the
-specification of priors relies more on arbitrary decisions than sound
-scientific reasoning, choosing relevant prior distributions is in fact
-fully integrated in the process of building model that generates the
-observed data. In particular, the problem of estimating divergence times
-naturally lends itself to hierarchical Bayesian modelling. Based on the
-hypothesis that rates of evolution are conserved (to some extant)
-throughout the course of evolution, the hierarchical Bayesian approach
-provides an adequate framework for inferring substitution rates and
-divergence dates separately. Hence, in this situation, it makes good
-sense to use what is known about a relatively well-defined feature of
-the evolution of genetic sequences (the “molecular clock” hypothesis
-combined to stochastic variations of rates across lineages) to build a
-prior distribution on rates along edges.
-
-### Citing PhyTime {#sec:citephytime}
-
-The “default citation” is:
-
--   Guindon S. “From trajectories to averages: an improved description
-    of the heterogeneity of substitution rates along lineages”,
-    <span>*Systematic Biology*</span>, 2012. doi: 10.1093/sysbio/sys063.
-
-An earlier article also described some of the methods implemented in
-PhyTime:
-
--   Guindon S. “Bayesian estimation of divergence times from large data
-    sets”, <span>*Molecular Biology and Evolution*</span>, 2010,
-    27(8):1768:81.
-
-PhyloGeo
---------
-
-PhyloGeo is a program that implements the competition-dispersal
-phylogeography model described in Ranjard, Welch, Paturel and Guindon
-“Modelling competition and dispersal in a statistical phylogeographic
-framework”. Accepted for publication in <span>*Systematic
-Biology*</span>.
-
-It implements a Markov Chain Monte Carlo approach that samples from the
-posterior distribution of the three parameters of interest in this
-model, namely the competition intensity $\lambda$, the dispersal bias
-parameter $\sigma$ and the overal dispersal rate $\tau$. The data
-consist in a phylogeny with node heights proportional to their ages and
-geographical locations for evety taxon in this tree.
-
-### Installing PhyloGeo
-
-Compiling PhyloGeo is straightforward on Unix-like machines (i.e., linux
-and MacOS systems). PhyloGeo is not readily available for Windows
-machines but compilation should be easy on this system too. In the
-‘phyml’ directory, where the ‘src/’ and ‘doc/’ directories stand, enter
-the following commands:
-
-    ./configure --enable-geo;
-    make clean;
-    make;
-
-This set of commands generates a binary file called `phylogeo` which can
-be found in the ‘src/’ directory.
-
-### Running PhyloGeo
-
-PhyloGeo takes as input a rooted tree file in Newick format and a tree
-with geographical locations for all the tips of the phylogeny. Here is
-an example of valid tree and the corresponding spatial locations just
-below:
-
-    (((unicaA:1.30202,unicaB:1.30202):1.34596,(((nitidaC:0.94617,(nitidaA:0.31497,
-    nitidaB:0.31497):0.63120):0.18955,(((mauiensisA:0.00370,mauiensisB:0.00370):0.20068,
-    (pilimauiensisA:0.05151,pilimauiensisB:0.05151):0.15287):0.78769,(brunneaA:0.10582,
-    brunneaB:0.10582):0.88625):0.14365):0.80126,(((molokaiensisA:0.03728,
-    molokaiensisB:0.03728):0.71371,(deplanataA:0.01814,deplanataB:0.01814):0.73285):0.34764,
-    ((parvulaA:0.20487,parvulaB:0.20487):0.40191,(kauaiensisA:0.24276,
-    kauaiensisB:0.24276):0.36401):0.49186):0.83835):0.71099):1.38043,
-    (nihoaA:0.05673,nihoaB:0.05673):3.97168);
-
-    nihoaA                  23.062222   161.926111
-    nihoaB                  23.062222   161.926111
-    kauaiensisA             22.0644445  159.5455555
-    kauaiensisB             22.0644445  159.5455555
-    unicaA                  21.436875   158.0524305
-    unicaB                  21.436875   158.0524305
-    parvulaA                21.436875   158.0524305
-    parvulaB                21.436875   158.0524305
-    molokaiensisA           20.90532    156.6499
-    molokaiensisB           20.90532    156.6499
-    deplanataA              20.90532    156.6499
-    deplanataB              20.90532    156.6499
-    brunneaA                20.90532    156.6499
-    brunneaB                20.90532    156.6499
-    mauiensisA              20.90532    156.6499
-    mauiensisB              20.90532    156.6499
-    pilimauiensisA          20.90532    156.6499
-    pilimauiensisB          20.90532    156.6499
-    nitidaA                 19.7362         155.6069
-    nitidaB                 19.7362         155.6069
-    nitidaC                 19.7362         155.6069
-
-In order to run PhyloGeo, enter the following command:
-`./phylogeo ./tree_file ./spatial_location_file > phylogeo_output`.
-PhyloGeo will then print out the sampled values of the model parameters
-in the file `phylogeo_output`. This file can then be used to generate
-the marginal posterior densities of the model parameters. In particular,
-evidence for competition corresponds to value of $\lambda$ smaller than
-1.0. Please see the original article for more information on how to
-interpret the model parameters.
-
-### Citing PhyloGeo {#sec:citephylogeo}
-
-Ranjard, L., Welch D., Paturel M. and Guindon S. “Modelling competition
-and dispersal in a statistical phylogeographic framework”. 2014.
-Systematic Biology.
-
-Recommendations on program usage {#sec:progusage}
-================================
-
-PhyML
------
-
-The choice of the tree searching algorithm among those provided by PhyML
-is generally a tough one. The fastest option relies on local and
-simultaneous modifications of the phylogeny using NNI moves. More
-thorough explorations of the space of topologies are also available
-through the SPR options. As these two classes of tree topology moves
-involve different computational burdens, it is important to determine
-which option is the most suitable for the type of data set or analysis
-one wants to perform. Below is a list of recommendations for typical
-phylogenetic analyses.
-
-1.  <span>*Single data set, unlimited computing time.*</span> The best
-    option here is probably to use a SPR search (i.e., straight SPR of
-    best of SPR and NNI). If the focus is on estimating the
-    relationships between species, it is a good idea to use more than
-    one starting tree to decrease the chance of getting stuck in a local
-    maximum of the likelihood function. Using NNIs is appropriate if the
-    analysis does not mainly focus on estimating the evolutionary
-    relationships between species (e.g. a tree is needed to estimate the
-    parameters of codon-based models later on). Branch supports can be
-    estimated using bootstrap and approximate likelihood ratios.
-
-2.  <span>*Single data set, restricted computing time.*</span> The three
-    tree searching options can be used depending on the computing time
-    available and the size of the data set. For small data sets (i.e.,
-    $<$ 50 sequences), NNI will generally perform well provided that the
-    phylogenetic signal is strong. It is relevant to estimate a first
-    tree using NNI moves and examine the reconstructed phylogeny in
-    order to have a rough idea of the strength of the phylogenetic
-    signal (the presence of small internal branch lengths is generally
-    considered as a sign of a weak phylogenetic signal, specially when
-    sequences are short). For larger data sets ($>$ 50 sequences), a SPR
-    search is recommended if there are good evidence of a lack of
-    phylogenetic signal. Bootstrap analysis will generally involve large
-    computational burdens. Estimating branch supports using approximate
-    likelihood ratios therefore provides an interesting alternative
-    here.
-
-3.  <span>*Multiple data sets, unlimited computing time.*</span>
-    Comparative genomic analyses sometimes rely on building phylogenies
-    from the analysis of a large number of gene families. Here again,
-    the NNI option is the most relevant if the focus is not on
-    recovering the most accurate picture of the evolutionary
-    relationships between species. Slower SPR-based heuristics should be
-    used when the topology of the tree is an important parameter of the
-    analysis (e.g., identification of horizontally transferred genes
-    using phylogenetic tree comparisons). Internal branch support is
-    generally not a crucial parameter of the multiple data set analyses.
-    Using approximate likelihood ratio is probably the best choice here.
-
-4.  <span>*Multiple data sets, limited computing time.*</span> The large
-    amount of data to be processed in a limited time generally requires
-    the use of the fastest tree searching and branch support estimation
-    methods Hence, NNI and approximate likelihood ratios rather than SPR
-    and non-parametric bootstrap are generally the most appropriate
-    here.
-
-Another important point is the choice of the substitution model. While
-default options generally provide acceptable results, it is often
-warranted to perform a pre-analysis in order to identify the best-fit
-substitution model. This pre-analysis can be done using popular software
-such as Modeltest @posada98 or ProtTest @abascal05 for instance. These
-programs generally recommend the use of a discrete gamma distribution to
-model the substitution process as variability of rates among sites is a
-common feature of molecular evolution. The choice of the number of rate
-classes to use for this distribution is also an important one. While the
-default is set to four categories in PhyML, it is recommended to use
-larger number of classes if possible in order to best approximate the
-patterns of rate variation across sites @galtier04. Note however that
-run times are directly proportional to the number of classes of the
-discrete gamma distribution. Here again, a pre-analysis with the
-simplest model should help the user to determine the number of rate
-classes that represents the best trade-off between computing time and
-fit of the model to the data.
-
-PhyTime {#sec:recomphytime}
--------
-
-Analysing a data set using PhyTime should involve three steps based on
-the following questions: (1) do the priors seem to be adequate (2) can I
-use the fast approximation of the likelihood and (3) how long shall I
-run the program for? I explain below how to provide answers to these
-questions.
-
--   <span>*Are the priors adequate?*</span> Bayesian analysis relies on
-    specifiying the joint prior density of model parameters. In the case
-    of node age estimation, these priors essentially describe how rates
-    of substitution vary across lineages and the probabilistic
-    distribution that node ages have when ignoring the information
-    provided by the genetic sequences. These priors vary from tree to
-    tree. It is therefore essential to check the adequacy of priors for
-    each user-defined input tree. In order to do so, PhyTime needs to be
-    run with the `–no_data` option. When this option is required, the
-    sequence data provided as input will be ignored and the rest of the
-    analysis will proceed normally. The prior distribution of model
-    parameters, essentially edge rates and node heights, can then be
-    checked using the program Tracer as one would do for the standard
-    ‘posterior’ analysis.
-
--   <span>*Can I use the fast approximation to the likelihood?*</span>
-    The suface of the log-likelihood function can be approximated using
-    a multivariate normal density. This technique is saving very
-    substantial amounts of computation time. However, like most
-    approximations, there are situations where it does not provide a
-    good fit to the actual function. This usually happens when the
-    phylogeny displays a lot of short branches, i.e., the signal
-    conveyed by the sequences is weak. It is therefore important to
-    first check whether using the approximate likelihood is reasonable.
-    In order to do so, it is recommended to first run the program
-    without the approximation, i.e., using the default settings. Once
-    the minimum value of the ESS of node ages (the last column on the
-    right of the standard output) has reached 40-50, open the
-    `phytime.XXXX` output file with Tracer and examine the correlation
-    between the exact and approximate likelihood values. If the
-    correlation is deemed to be good enough, PhyTime can be re-run using
-    the `–fast_lk` option, which uses the fast normal approximation to
-    the likelihood function.
-
--   <span>*How long shall I run the program for?*</span> PhyTime should
-    be run long enough such that the ESS of each parameter is ‘large
-    enough’. The last column on the right handside of the standard
-    output gives the minimum ESS across all internal node heights. It is
-    recommended to run the program so that this number reaches at least
-    100.
-
-Frequently asked questions
-==========================
-
-1.  <span>*PhyML crashes before reading the sequences. What’s wrong
-    ?*</span>\
-
-    -   The format of your sequence file is not recognized by PhyML. See
-        Section [sec:input~o~utput]
-
-    -   The carriage return characters in your sequence files are not
-        recognized by PhyML. You must make sure that your sequence file
-        is a plain text file, with standard carriage return characters
-        (i.e., corresponding to “$\backslash$`n`”, or “$\backslash$`r`”)
-
-2.  <span>*The program crashes after reading the sequences. What’s wrong
-    ?*</span>\
-
-    -   You analyse protein sequences and did not enter the `-d aa`
-        option in the command-line.
-
-    -   The format of your sequence file is not recognized by PhyML. See
-        Section [sec:input~o~utput]
-
-3.  <span>*Does PhyML handle outgroup sequences ?*</span>\
-
-    -   Yes, it does. Outgroup taxa are identified by adding the ‘\*’
-        sign at the end of each corresponding sequence name (see Section
-        [sec:outgroupspecify])
-
-4.  <span>*Does PhyML estimate clock-constrained trees ?*</span>\
-
-    -   No, the PhyML program does not estimate clock-contrained trees.
-        One can however use the program PhyTime to perform such analysis
-        but the tree topology will not be estimated.
-
-5.  <span>*Can PhyML analyse partitioned data, such as multiple gene
-    sequences ?*</span>\
-
-    -   We are currently working on this topic. Future releases of the
-        program will provide options to estimate trees from phylogenomic
-        data sets, with the opportunity to use different substitution
-        models on the different data partitions (e.g., different genes).
-        PhyML will also include specific algorithms to search the space
-        of tree topologies for this type of data.
-
-Acknowledgements
-================
-
-The development of PhyML since 2000 has been supported by the Centre
-National de la Recherche Scientifique (CNRS) and the Ministère de
-l’Éducation Nationale.
-
-[^1]: the rate matrix corresponds here the symmetrical matrix giving the
-    so-called “echangeability rates”
-
-[^2]: The actual formula involves an extra parameter which does not need
-    to be introduced here
diff --git a/doc/naturemag.bst b/doc/naturemag.bst
index 5e4018d..e270104 100644
--- a/doc/naturemag.bst
+++ b/doc/naturemag.bst
@@ -1,1525 +1,1524 @@
-%%
-%% This is file `naturemag.bst',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% merlin.mbs  (with options: `head,seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
-%% physjour.mbs  (with options: `seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
-%% geojour.mbs  (with options: `seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
-%% photjour.mbs  (with options: `seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
-%% merlin.mbs  (with options: `tail,seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
-%% ----------------------------------------
-%% *** Style for the journal Nature (created by Peter Czoschke) ***
-%% 
-%% Copyright 1994-2002 Patrick W Daly
- % ===============================================================
- % IMPORTANT NOTICE:
- % This bibliographic style (bst) file has been generated from one or
- % more master bibliographic style (mbs) files, listed above.
- %
- % This generated file can be redistributed and/or modified under the terms
- % of the LaTeX Project Public License Distributed from CTAN
- % archives in directory macros/latex/base/lppl.txt; either
- % version 1 of the License, or any later version.
- % ===============================================================
- % Name and version information of the main mbs file:
- % \ProvidesFile{merlin.mbs}[2002/10/21 4.05 (PWD, AO, DPC)]
- %   For use with BibTeX version 0.99a or later
- %-------------------------------------------------------------------
- % This bibliography style file is intended for texts in ENGLISH
- % This is a numerical citation style, and as such is standard LaTeX.
- % It requires no extra package to interface to the main text.
- % The form of the \bibitem entries is
- %   \bibitem{key}...
- % Usage of \cite is as follows:
- %   \cite{key} ==>>          [#]
- %   \cite[chap. 2]{key} ==>> [#, chap. 2]
- % where # is a number determined by the ordering in the reference list.
- % The order in the reference list is that by which the works were originally
- %   cited in the text, or that in the database.
- %---------------------------------------------------------------------
-
-ENTRY
-  { address
-    archive
-    author
-    booktitle
-    chapter
-    edition
-    editor
-    eprint
-    howpublished
-    institution
-    journal
-    key
-    month
-    note
-    number
-    organization
-    pages
-    publisher
-    school
-    series
-    title
-    type
-    url
-    volume
-    year
-  }
-  {}
-  { label }
-INTEGERS { output.state before.all mid.sentence after.sentence after.block }
-FUNCTION {init.state.consts}
-{ #0 'before.all :=
-  #1 'mid.sentence :=
-  #2 'after.sentence :=
-  #3 'after.block :=
-}
-STRINGS { s t}
-FUNCTION {output.nonnull}
-{ 's :=
-  output.state mid.sentence =
-    { ", " * write$ }
-    { output.state after.block =
-        { add.period$ write$
-          newline$
-          "\newblock " write$
-        }
-        { output.state before.all =
-            'write$
-            { add.period$ " " * write$ }
-          if$
-        }
-      if$
-      mid.sentence 'output.state :=
-    }
-  if$
-  s
-}
-FUNCTION {output}
-{ duplicate$ empty$
-    'pop$
-    'output.nonnull
-  if$
-}
-FUNCTION {output.check}
-{ 't :=
-  duplicate$ empty$
-    { pop$ "empty " t * " in " * cite$ * warning$ }
-    'output.nonnull
-  if$
-}
-FUNCTION {fin.entry}
-{ add.period$
-  write$
-  newline$
-}
-
-FUNCTION {new.block}
-{ output.state before.all =
-    'skip$
-    { after.block 'output.state := }
-  if$
-}
-FUNCTION {new.sentence}
-{ output.state after.block =
-    'skip$
-    { output.state before.all =
-        'skip$
-        { after.sentence 'output.state := }
-      if$
-    }
-  if$
-}
-FUNCTION {add.blank}
-{  " " * before.all 'output.state :=
-}
-
-FUNCTION {date.block}
-{
-  new.block
-}
-
-FUNCTION {not}
-{   { #0 }
-    { #1 }
-  if$
-}
-FUNCTION {and}
-{   'skip$
-    { pop$ #0 }
-  if$
-}
-FUNCTION {or}
-{   { pop$ #1 }
-    'skip$
-  if$
-}
-FUNCTION {new.block.checka}
-{ empty$
-    'skip$
-    'new.block
-  if$
-}
-FUNCTION {new.block.checkb}
-{ empty$
-  swap$ empty$
-  and
-    'skip$
-    'new.block
-  if$
-}
-FUNCTION {new.sentence.checka}
-{ empty$
-    'skip$
-    'new.sentence
-  if$
-}
-FUNCTION {new.sentence.checkb}
-{ empty$
-  swap$ empty$
-  and
-    'skip$
-    'new.sentence
-  if$
-}
-FUNCTION {field.or.null}
-{ duplicate$ empty$
-    { pop$ "" }
-    'skip$
-  if$
-}
-FUNCTION {emphasize}
-{ duplicate$ empty$
-    { pop$ "" }
-    { "\emph{" swap$ * "}" * }
-  if$
-}
-FUNCTION {bolden}
-{ duplicate$ empty$
-    { pop$ "" }
-    { "\textbf{" swap$ * "}" * }
-  if$
-}
-FUNCTION {tie.or.space.prefix}
-{ duplicate$ text.length$ #3 <
-    { "~" }
-    { " " }
-  if$
-  swap$
-}
-
-FUNCTION {capitalize}
-{ "u" change.case$ "t" change.case$ }
-
-FUNCTION {space.word}
-{ " " swap$ * " " * }
- % Here are the language-specific definitions for explicit words.
- % Each function has a name bbl.xxx where xxx is the English word.
- % The language selected here is ENGLISH
-FUNCTION {bbl.and}
-{ "and"}
-
-FUNCTION {bbl.etal}
-{ "et~al." }
-
-FUNCTION {bbl.editors}
-{ "eds." }
-
-FUNCTION {bbl.editor}
-{ "ed." }
-
-FUNCTION {bbl.edby}
-{ "edited by" }
-
-FUNCTION {bbl.edition}
-{ "edn." }
-
-FUNCTION {bbl.volume}
-{ "vol." }
-
-FUNCTION {bbl.of}
-{ "of" }
-
-FUNCTION {bbl.number}
-{ "no." }
-
-FUNCTION {bbl.nr}
-{ "no." }
-
-FUNCTION {bbl.in}
-{ "in" }
-
-FUNCTION {bbl.pages}
-{ "" }
-
-FUNCTION {bbl.page}
-{ "" }
-
-FUNCTION {bbl.chapter}
-{ "chap." }
-
-FUNCTION {bbl.techrep}
-{ "Tech. Rep." }
-
-FUNCTION {bbl.mthesis}
-{ "Master's thesis" }
-
-FUNCTION {bbl.phdthesis}
-{ "Ph.D. thesis" }
-
-MACRO {jan} {"Jan."}
-
-MACRO {feb} {"Feb."}
-
-MACRO {mar} {"Mar."}
-
-MACRO {apr} {"Apr."}
-
-MACRO {may} {"May"}
-
-MACRO {jun} {"Jun."}
-
-MACRO {jul} {"Jul."}
-
-MACRO {aug} {"Aug."}
-
-MACRO {sep} {"Sep."}
-
-MACRO {oct} {"Oct."}
-
-MACRO {nov} {"Nov."}
-
-MACRO {dec} {"Dec."}
-
- %-------------------------------------------------------------------
- % Begin module:
- % \ProvidesFile{physjour.mbs}[2002/01/14 2.2 (PWD)]
-MACRO {aa}{"Astron. \& Astrophys."}
-MACRO {aasup}{"Astron. \& Astrophys. Suppl. Ser."}
-MACRO {aj} {"Astron. J."}
-MACRO {aph} {"Acta Phys."}
-MACRO {advp} {"Adv. Phys."}
-MACRO {ajp} {"Amer. J. Phys."}
-MACRO {ajm} {"Amer. J. Math."}
-MACRO {amsci} {"Amer. Sci."}
-MACRO {anofd} {"Ann. Fluid Dyn."}
-MACRO {am} {"Ann. Math."}
-MACRO {ap} {"Ann. Phys. (NY)"}
-MACRO {adp} {"Ann. Phys. (Leipzig)"}
-MACRO {ao} {"Appl. Opt."}
-MACRO {apl} {"Appl. Phys. Lett."}
-MACRO {app} {"Astroparticle Phys."}
-MACRO {apj} {"Astrophys. J."}
-MACRO {apjsup} {"Astrophys. J. Suppl."}
-MACRO {apss} {"Astrophys. Space Sci."}
-MACRO {araa} {"Ann. Rev. Astron. Astrophys."}
-MACRO {baas} {"Bull. Amer. Astron. Soc."}
-MACRO {baps} {"Bull. Amer. Phys. Soc."}
-MACRO {cmp} {"Comm. Math. Phys."}
-MACRO {cpam} {"Commun. Pure Appl. Math."}
-MACRO {cppcf} {"Comm. Plasma Phys. \& Controlled Fusion"}
-MACRO {cpc} {"Comp. Phys. Comm."}
-MACRO {cqg} {"Class. Quant. Grav."}
-MACRO {cra} {"C. R. Acad. Sci. A"}
-MACRO {fed} {"Fusion Eng. \& Design"}
-MACRO {ft} {"Fusion Tech."}
-MACRO {grg} {"Gen. Relativ. Gravit."}
-MACRO {ieeens} {"IEEE Trans. Nucl. Sci."}
-MACRO {ieeeps} {"IEEE Trans. Plasma Sci."}
-MACRO {ijimw} {"Interntl. J. Infrared \& Millimeter Waves"}
-MACRO {ip} {"Infrared Phys."}
-MACRO {irp} {"Infrared Phys."}
-MACRO {jap} {"J. Appl. Phys."}
-MACRO {jasa} {"J. Acoust. Soc. America"}
-MACRO {jcp} {"J. Comp. Phys."}
-MACRO {jetp} {"Sov. Phys.--JETP"}
-MACRO {jfe} {"J. Fusion Energy"}
-MACRO {jfm} {"J. Fluid Mech."}
-MACRO {jmp} {"J. Math. Phys."}
-MACRO {jne} {"J. Nucl. Energy"}
-MACRO {jnec} {"J. Nucl. Energy, C: Plasma Phys., Accelerators, Thermonucl. Res."}
-MACRO {jnm} {"J. Nucl. Mat."}
-MACRO {jpc} {"J. Phys. Chem."}
-MACRO {jpp} {"J. Plasma Phys."}
-MACRO {jpsj} {"J. Phys. Soc. Japan"}
-MACRO {jsi} {"J. Sci. Instrum."}
-MACRO {jvst} {"J. Vac. Sci. \& Tech."}
-MACRO {nat} {"Nature"}
-MACRO {nature} {"Nature"}
-MACRO {nedf} {"Nucl. Eng. \& Design/Fusion"}
-MACRO {nf} {"Nucl. Fusion"}
-MACRO {nim} {"Nucl. Inst. \& Meth."}
-MACRO {nimpr} {"Nucl. Inst. \& Meth. in Phys. Res."}
-MACRO {np} {"Nucl. Phys."}
-MACRO {npb} {"Nucl. Phys. B"}
-MACRO {nt/f} {"Nucl. Tech./Fusion"}
-MACRO {npbpc} {"Nucl. Phys. B (Proc. Suppl.)"}
-MACRO {inc} {"Nuovo Cimento"}
-MACRO {nc} {"Nuovo Cimento"}
-MACRO {pf} {"Phys. Fluids"}
-MACRO {pfa} {"Phys. Fluids A: Fluid Dyn."}
-MACRO {pfb} {"Phys. Fluids B: Plasma Phys."}
-MACRO {pl} {"Phys. Lett."}
-MACRO {pla} {"Phys. Lett. A"}
-MACRO {plb} {"Phys. Lett. B"}
-MACRO {prep} {"Phys. Rep."}
-MACRO {pnas} {"Proc. Nat. Acad. Sci. USA"}
-MACRO {pp} {"Phys. Plasmas"}
-MACRO {ppcf} {"Plasma Phys. \& Controlled Fusion"}
-MACRO {phitrsl} {"Philos. Trans. Roy. Soc. London"}
-MACRO {prl} {"Phys. Rev. Lett."}
-MACRO {pr} {"Phys. Rev."}
-MACRO {physrev} {"Phys. Rev."}
-MACRO {pra} {"Phys. Rev. A"}
-MACRO {prb} {"Phys. Rev. B"}
-MACRO {prc} {"Phys. Rev. C"}
-MACRO {prd} {"Phys. Rev. D"}
-MACRO {pre} {"Phys. Rev. E"}
-MACRO {ps} {"Phys. Scripta"}
-MACRO {procrsl} {"Proc. Roy. Soc. London"}
-MACRO {rmp} {"Rev. Mod. Phys."}
-MACRO {rsi} {"Rev. Sci. Inst."}
-MACRO {science} {"Science"}
-MACRO {sciam} {"Sci. Am."}
-MACRO {sam} {"Stud. Appl. Math."}
-MACRO {sjpp} {"Sov. J. Plasma Phys."}
-MACRO {spd} {"Sov. Phys.--Doklady"}
-MACRO {sptp} {"Sov. Phys.--Tech. Phys."}
-MACRO {spu} {"Sov. Phys.--Uspeki"}
-MACRO {st} {"Sky and Telesc."}
- % End module: physjour.mbs
- %-------------------------------------------------------------------
- % Begin module:
- % \ProvidesFile{geojour.mbs}[2002/07/10 2.0h (PWD)]
-MACRO {aisr} {"Adv. Space Res."}
-MACRO {ag} {"Ann. Geophys."}
-MACRO {anigeo} {"Ann. Geofis."}
-MACRO {angl} {"Ann. Glaciol."}
-MACRO {andmet} {"Ann. d. Meteor."}
-MACRO {andgeo} {"Ann. d. Geophys."}
-MACRO {andphy} {"Ann. Phys.-Paris"}
-MACRO {afmgb} {"Arch. Meteor. Geophys. Bioklimatol."}
-MACRO {atph} {"Atm\'osphera"}
-MACRO {aao} {"Atmos. Ocean"}
-MACRO {ass}{"Astrophys. Space Sci."}
-MACRO {atenv} {"Atmos. Environ."}
-MACRO {aujag} {"Aust. J. Agr. Res."}
-MACRO {aumet} {"Aust. Meteorol. Mag."}
-MACRO {blmet} {"Bound.-Lay. Meteorol."}
-MACRO {bams} {"Bull. Amer. Meteorol. Soc."}
-MACRO {cch} {"Clim. Change"}
-MACRO {cdyn} {"Clim. Dynam."}
-MACRO {cbul} {"Climatol. Bull."}
-MACRO {cap} {"Contrib. Atmos. Phys."}
-MACRO {dsr} {"Deep-Sea Res."}
-MACRO {dhz} {"Dtsch. Hydrogr. Z."}
-MACRO {dao} {"Dynam. Atmos. Oceans"}
-MACRO {eco} {"Ecology"}
-MACRO {empl}{"Earth, Moon and Planets"}
-MACRO {envres} {"Environ. Res."}
-MACRO {envst} {"Environ. Sci. Technol."}
-MACRO {ecms} {"Estuarine Coastal Mar. Sci."}
-MACRO {expa}{"Exper. Astron."}
-MACRO {geoint} {"Geofis. Int."}
-MACRO {geopub} {"Geofys. Publ."}
-MACRO {geogeo} {"Geol. Geofiz."}
-MACRO {gafd} {"Geophys. Astrophys. Fluid Dyn."}
-MACRO {gfd} {"Geophys. Fluid Dyn."}
-MACRO {geomag} {"Geophys. Mag."}
-MACRO {georl} {"Geophys. Res. Lett."}
-MACRO {grl} {"Geophys. Res. Lett."}
-MACRO {ga} {"Geophysica"}
-MACRO {gs} {"Geophysics"}
-MACRO {ieeetap} {"IEEE Trans. Antenn. Propag."}
-MACRO {ijawp} {"Int. J. Air Water Pollut."}
-MACRO {ijc} {"Int. J. Climatol."}
-MACRO {ijrs} {"Int. J. Remote Sens."}
-MACRO {jam} {"J. Appl. Meteorol."}
-MACRO {jaot} {"J. Atmos. Ocean. Technol."}
-MACRO {jatp} {"J. Atmos. Terr. Phys."}
-MACRO {jastp} {"J. Atmos. Solar-Terr. Phys."}
-MACRO {jce} {"J. Climate"}
-MACRO {jcam} {"J. Climate Appl. Meteor."}
-MACRO {jcm} {"J. Climate Meteor."}
-MACRO {jcy} {"J. Climatol."}
-MACRO {jgr} {"J. Geophys. Res."}
-MACRO {jga} {"J. Glaciol."}
-MACRO {jh} {"J. Hydrol."}
-MACRO {jmr} {"J. Mar. Res."}
-MACRO {jmrj} {"J. Meteor. Res. Japan"}
-MACRO {jm} {"J. Meteor."}
-MACRO {jpo} {"J. Phys. Oceanogr."}
-MACRO {jra} {"J. Rech. Atmos."}
-MACRO {jaes} {"J. Aeronaut. Sci."}
-MACRO {japca} {"J. Air Pollut. Control Assoc."}
-MACRO {jas} {"J. Atmos. Sci."}
-MACRO {jmts} {"J. Mar. Technol. Soc."}
-MACRO {jmsj} {"J. Meteorol. Soc. Japan"}
-MACRO {josj} {"J. Oceanogr. Soc. Japan"}
-MACRO {jwm} {"J. Wea. Mod."}
-MACRO {lao} {"Limnol. Oceanogr."}
-MACRO {mwl} {"Mar. Wea. Log"}
-MACRO {mau} {"Mausam"}
-MACRO {meteor} {"``Meteor'' Forschungsergeb."}
-MACRO {map} {"Meteorol. Atmos. Phys."}
-MACRO {metmag} {"Meteor. Mag."}
-MACRO {metmon} {"Meteor. Monogr."}
-MACRO {metrun} {"Meteor. Rundsch."}
-MACRO {metzeit} {"Meteor. Z."}
-MACRO {metgid} {"Meteor. Gidrol."}
-MACRO {mwr} {"Mon. Weather Rev."}
-MACRO {nwd} {"Natl. Weather Dig."}
-MACRO {nzjmfr} {"New Zeal. J. Mar. Freshwater Res."}
-MACRO {npg} {"Nonlin. Proc. Geophys."}
-MACRO {om} {"Oceanogr. Meteorol."}
-MACRO {ocac} {"Oceanol. Acta"}
-MACRO {oceanus} {"Oceanus"}
-MACRO {paleoc} {"Paleoceanography"}
-MACRO {pce} {"Phys. Chem. Earth"}
-MACRO {pmg} {"Pap. Meteor. Geophys."}
-MACRO {ppom} {"Pap. Phys. Oceanogr. Meteor."}
-MACRO {physzeit} {"Phys. Z."}
-MACRO {pps} {"Planet. Space Sci."}
-MACRO {pss} {"Planet. Space Sci."}
-MACRO {pag} {"Pure Appl. Geophys."}
-MACRO {qjrms} {"Quart. J. Roy. Meteorol. Soc."}
-MACRO {quatres} {"Quat. Res."}
-MACRO {rsci} {"Radio Sci."}
-MACRO {rse} {"Remote Sens. Environ."}
-MACRO {rgeo} {"Rev. Geophys."}
-MACRO {rgsp} {"Rev. Geophys. Space Phys."}
-MACRO {rdgeo} {"Rev. Geofis."}
-MACRO {revmeta} {"Rev. Meteorol."}
-MACRO {sgp}{"Surveys in Geophys."}
-MACRO {sp} {"Solar Phys."}
-MACRO {ssr} {"Space Sci. Rev."}
-MACRO {tellus} {"Tellus"}
-MACRO {tac} {"Theor. Appl. Climatol."}
-MACRO {tagu} {"Trans. Am. Geophys. Union (EOS)"}
-MACRO {wrr} {"Water Resour. Res."}
-MACRO {weather} {"Weather"}
-MACRO {wafc} {"Weather Forecast."}
-MACRO {ww} {"Weatherwise"}
-MACRO {wmob} {"WMO Bull."}
-MACRO {zeitmet} {"Z. Meteorol."}
- % End module: geojour.mbs
- %-------------------------------------------------------------------
- % Begin module:
- % \ProvidesFile{photjour.mbs}[1999/02/24 2.0b (PWD)]
-
-MACRO {appopt} {"Appl. Opt."}
-MACRO {bell} {"Bell Syst. Tech. J."}
-MACRO {ell} {"Electron. Lett."}
-MACRO {jasp} {"J. Appl. Spectr."}
-MACRO {jqe} {"IEEE J. Quantum Electron."}
-MACRO {jlwt} {"J. Lightwave Technol."}
-MACRO {jmo} {"J. Mod. Opt."}
-MACRO {josa} {"J. Opt. Soc. America"}
-MACRO {josaa} {"J. Opt. Soc. Amer.~A"}
-MACRO {josab} {"J. Opt. Soc. Amer.~B"}
-MACRO {jdp} {"J. Phys. (Paris)"}
-MACRO {oc} {"Opt. Commun."}
-MACRO {ol} {"Opt. Lett."}
-MACRO {phtl} {"IEEE Photon. Technol. Lett."}
-MACRO {pspie} {"Proc. Soc. Photo-Opt. Instrum. Eng."}
-MACRO {sse} {"Solid-State Electron."}
-MACRO {sjot} {"Sov. J. Opt. Technol."}
-MACRO {sjqe} {"Sov. J. Quantum Electron."}
-MACRO {sleb} {"Sov. Phys.--Leb. Inst. Rep."}
-MACRO {stph} {"Sov. Phys.--Techn. Phys."}
-MACRO {stphl} {"Sov. Techn. Phys. Lett."}
-MACRO {vr} {"Vision Res."}
-MACRO {zph} {"Z. f. Physik"}
-MACRO {zphb} {"Z. f. Physik~B"}
-MACRO {zphd} {"Z. f. Physik~D"}
-
-MACRO {CLEO} {"CLEO"}
-MACRO {ASSL} {"Adv. Sol.-State Lasers"}
-MACRO {OSA}  {"OSA"}
- % End module: photjour.mbs
-%% Copyright 1994-2002 Patrick W Daly
-MACRO {acmcs} {"ACM Comput. Surv."}
-
-MACRO {acta} {"Acta Inf."}
-
-MACRO {cacm} {"Commun. ACM"}
-
-MACRO {ibmjrd} {"IBM J. Res. Dev."}
-
-MACRO {ibmsj} {"IBM Syst.~J."}
-
-MACRO {ieeese} {"IEEE Trans. Software Eng."}
-
-MACRO {ieeetc} {"IEEE Trans. Comput."}
-
-MACRO {ieeetcad}
- {"IEEE Trans. Comput. Aid. Des."}
-
-MACRO {ipl} {"Inf. Process. Lett."}
-
-MACRO {jacm} {"J.~ACM"}
-
-MACRO {jcss} {"J.~Comput. Syst. Sci."}
-
-MACRO {scp} {"Sci. Comput. Program."}
-
-MACRO {sicomp} {"SIAM J. Comput."}
-
-MACRO {tocs} {"ACM Trans. Comput. Syst."}
-
-MACRO {tods} {"ACM Trans. Database Syst."}
-
-MACRO {tog} {"ACM Trans. Graphic."}
-
-MACRO {toms} {"ACM Trans. Math. Software"}
-
-MACRO {toois} {"ACM Trans. Office Inf. Syst."}
-
-MACRO {toplas} {"ACM Trans. Progr. Lang. Syst."}
-
-MACRO {tcs} {"Theor. Comput. Sci."}
-
-FUNCTION {bibinfo.check}
-{ swap$
-  duplicate$ missing$
-    {
-      pop$ pop$
-      ""
-    }
-    { duplicate$ empty$
-        {
-          swap$ pop$
-        }
-        { swap$
-          "\bibinfo{" swap$ * "}{" * swap$ * "}" *
-        }
-      if$
-    }
-  if$
-}
-FUNCTION {bibinfo.warn}
-{ swap$
-  duplicate$ missing$
-    {
-      swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
-      ""
-    }
-    { duplicate$ empty$
-        {
-          swap$ "empty " swap$ * " in " * cite$ * warning$
-        }
-        { swap$
-          "\bibinfo{" swap$ * "}{" * swap$ * "}" *
-        }
-      if$
-    }
-  if$
-}
-FUNCTION {format.eprint}
-{ eprint duplicate$ empty$
-    'skip$
-    { "\eprint"
-      archive empty$
-        'skip$
-        { "[" * archive * "]" * }
-      if$
-      "{" * swap$ * "}" *
-    }
-  if$
-}
-FUNCTION {format.url}
-{ url empty$
-    { "" }
-    { "\urlprefix\url{" url * "}" * }
-  if$
-}
-
-STRINGS  { bibinfo}
-INTEGERS { nameptr namesleft numnames }
-
-FUNCTION {format.names}
-{ 'bibinfo :=
-  duplicate$ empty$ 'skip$ {
-  's :=
-  "" 't :=
-  #1 'nameptr :=
-  s num.names$ 'numnames :=
-  numnames 'namesleft :=
-    { namesleft #0 > }
-    { s nameptr
-      "{vv~}{ll}{, f.}{, jj}"
-      format.name$
-      bibinfo bibinfo.check
-      't :=
-      nameptr #1 >
-        {
-          nameptr #1
-          #1 + =
-          numnames #5
-          > and
-            { "others" 't :=
-              #1 'namesleft := }
-            'skip$
-          if$
-          namesleft #1 >
-            { ", " * t * }
-            {
-              s nameptr "{ll}" format.name$ duplicate$ "others" =
-                { 't := }
-                { pop$ }
-              if$
-              t "others" =
-                {
-                  " " * bbl.etal emphasize *
-                }
-                {
-                  "\&"
-                  space.word * t *
-                }
-              if$
-            }
-          if$
-        }
-        't
-      if$
-      nameptr #1 + 'nameptr :=
-      namesleft #1 - 'namesleft :=
-    }
-  while$
-  } if$
-}
-FUNCTION {format.names.ed}
-{
-  format.names
-}
-FUNCTION {format.authors}
-{ author "author" format.names
-}
-FUNCTION {get.bbl.editor}
-{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }
-
-FUNCTION {format.editors}
-{ editor "editor" format.names duplicate$ empty$ 'skip$
-    {
-      " " *
-      get.bbl.editor
-   "(" swap$ * ")" *
-      *
-    }
-  if$
-}
-FUNCTION {format.note}
-{
- note empty$
-    { "" }
-    { note #1 #1 substring$
-      duplicate$ "{" =
-        'skip$
-        { output.state mid.sentence =
-          { "l" }
-          { "u" }
-        if$
-        change.case$
-        }
-      if$
-      note #2 global.max$ substring$ * "note" bibinfo.check
-    }
-  if$
-}
-
-FUNCTION {format.title}
-{ title
-  duplicate$ empty$ 'skip$
-    { "t" change.case$ }
-  if$
-  "title" bibinfo.check
-}
-FUNCTION {output.bibitem}
-{ newline$
-  "\bibitem{" write$
-  cite$ write$
-  "}" write$
-  newline$
-  ""
-  before.all 'output.state :=
-}
-
-FUNCTION {n.dashify}
-{
-  't :=
-  ""
-    { t empty$ not }
-    { t #1 #1 substring$ "-" =
-        { t #1 #2 substring$ "--" = not
-            { "--" *
-              t #2 global.max$ substring$ 't :=
-            }
-            {   { t #1 #1 substring$ "-" = }
-                { "-" *
-                  t #2 global.max$ substring$ 't :=
-                }
-              while$
-            }
-          if$
-        }
-        { t #1 #1 substring$ *
-          t #2 global.max$ substring$ 't :=
-        }
-      if$
-    }
-  while$
-}
-
-FUNCTION {word.in}
-{ bbl.in capitalize
-  " " * }
-
-FUNCTION {format.date}
-{
-  ""
-  duplicate$ empty$
-  year  "year"  bibinfo.check duplicate$ empty$
-    { swap$ 'skip$
-        { "there's a month but no year in " cite$ * warning$ }
-      if$
-      *
-    }
-    { swap$ 'skip$
-        {
-          swap$
-          " " * swap$
-        }
-      if$
-      *
-    }
-  if$
-  duplicate$ empty$
-    'skip$
-    {
-      before.all 'output.state :=
-    " (" swap$ * ")" *
-    }
-  if$
-}
-FUNCTION {format.btitle}
-{ title "title" bibinfo.check
-  duplicate$ empty$ 'skip$
-    {
-      emphasize
-    }
-  if$
-}
-FUNCTION {either.or.check}
-{ empty$
-    'pop$
-    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
-  if$
-}
-FUNCTION {format.bvolume}
-{ volume empty$
-    { "" }
-    { bbl.volume volume tie.or.space.prefix
-      "volume" bibinfo.check * *
-      series "series" bibinfo.check
-      duplicate$ empty$ 'pop$
-        { swap$ bbl.of space.word * swap$
-          emphasize * }
-      if$
-      "volume and number" number either.or.check
-    }
-  if$
-}
-FUNCTION {format.number.series}
-{ volume empty$
-    { number empty$
-        { series field.or.null }
-        { series empty$
-            { number "number" bibinfo.check }
-        { output.state mid.sentence =
-            { bbl.number }
-            { bbl.number capitalize }
-          if$
-          number tie.or.space.prefix "number" bibinfo.check * *
-          bbl.in space.word *
-          series "series" bibinfo.check *
-        }
-      if$
-    }
-      if$
-    }
-    { "" }
-  if$
-}
-
-FUNCTION {format.edition}
-{ edition duplicate$ empty$ 'skip$
-    {
-      output.state mid.sentence =
-        { "l" }
-        { "t" }
-      if$ change.case$
-      "edition" bibinfo.check
-      " " * bbl.edition *
-    }
-  if$
-}
-INTEGERS { multiresult }
-FUNCTION {multi.page.check}
-{ 't :=
-  #0 'multiresult :=
-    { multiresult not
-      t empty$ not
-      and
-    }
-    { t #1 #1 substring$
-      duplicate$ "-" =
-      swap$ duplicate$ "," =
-      swap$ "+" =
-      or or
-        { #1 'multiresult := }
-        { t #2 global.max$ substring$ 't := }
-      if$
-    }
-  while$
-  multiresult
-}
-FUNCTION {format.pages}
-{ pages duplicate$ empty$ 'skip$
-    { duplicate$ multi.page.check
-        {
-          n.dashify
-        }
-        {
-        }
-      if$
-      "pages" bibinfo.check
-    }
-  if$
-}
-FUNCTION {format.journal.pages}
-{ pages duplicate$ empty$ 'pop$
-    { swap$ duplicate$ empty$
-        { pop$ pop$ format.pages }
-        {
-          ", " *
-          swap$
-          n.dashify
-          "pages" bibinfo.check
-          *
-        }
-      if$
-    }
-  if$
-}
-FUNCTION {format.vol.num.pages}
-{ volume field.or.null
-  duplicate$ empty$ 'skip$
-    {
-      "volume" bibinfo.check
-    }
-  if$
-  bolden
-  format.journal.pages
-}
-
-FUNCTION {format.chapter.pages}
-{ chapter empty$
-    'format.pages
-    { type empty$
-        { bbl.chapter }
-        { type "l" change.case$
-          "type" bibinfo.check
-        }
-      if$
-      chapter tie.or.space.prefix
-      "chapter" bibinfo.check
-      * *
-      pages empty$
-        'skip$
-        { ", " * format.pages * }
-      if$
-    }
-  if$
-}
-
-FUNCTION {format.booktitle}
-{
-  booktitle "booktitle" bibinfo.check
-  emphasize
-}
-FUNCTION {format.in.ed.booktitle}
-{ format.booktitle duplicate$ empty$ 'skip$
-    {
-      editor "editor" format.names.ed duplicate$ empty$ 'pop$
-        {
-          " " *
-          get.bbl.editor
-          "(" swap$ * ") " *
-          * swap$
-          * }
-      if$
-      word.in swap$ *
-    }
-  if$
-}
-FUNCTION {empty.misc.check}
-{ author empty$ title empty$ howpublished empty$
-  month empty$ year empty$ note empty$
-  and and and and and
-    { "all relevant fields are empty in " cite$ * warning$ }
-    'skip$
-  if$
-}
-FUNCTION {format.thesis.type}
-{ type duplicate$ empty$
-    'pop$
-    { swap$ pop$
-      "t" change.case$ "type" bibinfo.check
-    }
-  if$
-}
-FUNCTION {format.tr.number}
-{ number "number" bibinfo.check
-  type duplicate$ empty$
-    { pop$ bbl.techrep }
-    'skip$
-  if$
-  "type" bibinfo.check
-  swap$ duplicate$ empty$
-    { pop$ "t" change.case$ }
-    { tie.or.space.prefix * * }
-  if$
-}
-FUNCTION {format.article.crossref}
-{
-  key duplicate$ empty$
-    { pop$
-      journal duplicate$ empty$
-        { "need key or journal for " cite$ * " to crossref " * crossref * warning$ }
-        { "journal" bibinfo.check emphasize word.in swap$ * }
-      if$
-    }
-    { word.in swap$ * " " *}
-  if$
-  " \cite{" * crossref * "}" *
-}
-FUNCTION {format.crossref.editor}
-{ editor #1 "{vv~}{ll}" format.name$
-  "editor" bibinfo.check
-  editor num.names$ duplicate$
-  #2 >
-    { pop$
-      "editor" bibinfo.check
-      " " * bbl.etal
-      emphasize
-      *
-    }
-    { #2 <
-        'skip$
-        { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
-            {
-              "editor" bibinfo.check
-              " " * bbl.etal
-              emphasize
-              *
-            }
-            {
-              " \& "
-              * editor #2 "{vv~}{ll}" format.name$
-              "editor" bibinfo.check
-              *
-            }
-          if$
-        }
-      if$
-    }
-  if$
-}
-FUNCTION {format.book.crossref}
-{ volume duplicate$ empty$
-    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
-      pop$ word.in
-    }
-    { bbl.volume
-      capitalize
-      swap$ tie.or.space.prefix "volume" bibinfo.check * * bbl.of space.word *
-    }
-  if$
-  editor empty$
-  editor field.or.null author field.or.null =
-  or
-    { key empty$
-        { series empty$
-            { "need editor, key, or series for " cite$ * " to crossref " *
-              crossref * warning$
-              "" *
-            }
-            { series emphasize * }
-          if$
-        }
-        { key * }
-      if$
-    }
-    { format.crossref.editor * }
-  if$
-  " \cite{" * crossref * "}" *
-}
-FUNCTION {format.incoll.inproc.crossref}
-{
-  editor empty$
-  editor field.or.null author field.or.null =
-  or
-    { key empty$
-        { format.booktitle duplicate$ empty$
-            { "need editor, key, or booktitle for " cite$ * " to crossref " *
-              crossref * warning$
-            }
-            { word.in swap$ * }
-          if$
-        }
-        { word.in key * " " *}
-      if$
-    }
-    { word.in format.crossref.editor * " " *}
-  if$
-  " \cite{" * crossref * "}" *
-}
-FUNCTION {format.org.or.pub}
-{ 't :=
-  ""
-  year empty$
-    { "empty year in " cite$ * warning$ }
-    'skip$
-  if$
-  address empty$ t empty$ and
-  year empty$ and
-    'skip$
-    {
-      add.blank "(" *
-      t empty$
-        { address "address" bibinfo.check *
-        }
-        { t *
-          address empty$
-            'skip$
-            { ", " * address "address" bibinfo.check * }
-          if$
-        }
-      if$
-      year empty$
-        'skip$
-        { t empty$ address empty$ and
-            'skip$
-            { ", " * }
-          if$
-          year "year" bibinfo.check
-          *
-        }
-      if$
-      ")" *
-    }
-  if$
-}
-FUNCTION {format.publisher.address}
-{ publisher "publisher" bibinfo.warn format.org.or.pub
-}
-
-FUNCTION {format.organization.address}
-{ organization "organization" bibinfo.check format.org.or.pub
-}
-
-FUNCTION {article}
-{ output.bibitem
-  format.authors "author" output.check
-  new.block
-  format.title "title" output.check
-  new.block
-  crossref missing$
-    {
-      journal
-      "journal" bibinfo.check
-      emphasize
-      "journal" output.check
-      add.blank
-      format.vol.num.pages output
-      format.date "year" output.check
-    }
-    { format.article.crossref output.nonnull
-      format.pages output
-    }
-  if$
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-FUNCTION {book}
-{ output.bibitem
-  author empty$
-    { format.editors "author and editor" output.check
-      add.blank
-    }
-    { format.authors output.nonnull
-      crossref missing$
-        { "author and editor" editor either.or.check }
-        'skip$
-      if$
-    }
-  if$
-  new.block
-  format.btitle "title" output.check
-  crossref missing$
-    { format.bvolume output
-      new.block
-      format.number.series output
-      new.sentence
-      format.publisher.address output
-    }
-    {
-      new.block
-      format.book.crossref output.nonnull
-      format.date "year" output.check
-    }
-  if$
-  format.edition output
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-FUNCTION {booklet}
-{ output.bibitem
-  format.authors output
-  new.block
-  format.title "title" output.check
-  new.block
-  howpublished "howpublished" bibinfo.check output
-  address "address" bibinfo.check output
-  format.date output
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {inbook}
-{ output.bibitem
-  author empty$
-    { format.editors "author and editor" output.check
-    }
-    { format.authors output.nonnull
-      crossref missing$
-        { "author and editor" editor either.or.check }
-        'skip$
-      if$
-    }
-  if$
-  new.block
-  format.btitle "title" output.check
-  crossref missing$
-    {
-      format.bvolume output
-      format.chapter.pages "chapter and pages" output.check
-      new.block
-      format.number.series output
-      new.sentence
-      format.publisher.address output
-    }
-    {
-      format.chapter.pages "chapter and pages" output.check
-      new.block
-      format.book.crossref output.nonnull
-      format.date "year" output.check
-    }
-  if$
-  format.edition output
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {incollection}
-{ output.bibitem
-  format.authors "author" output.check
-  new.block
-  format.title "title" output.check
-  new.block
-  crossref missing$
-    { format.in.ed.booktitle "booktitle" output.check
-      format.bvolume output
-      format.number.series output
-      format.chapter.pages output
-      new.sentence
-      format.publisher.address output
-      format.edition output
-    }
-    { format.incoll.inproc.crossref output.nonnull
-      format.chapter.pages output
-    }
-  if$
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-FUNCTION {inproceedings}
-{ output.bibitem
-  format.authors "author" output.check
-  new.block
-  format.title "title" output.check
-  new.block
-  crossref missing$
-    { format.in.ed.booktitle "booktitle" output.check
-      format.bvolume output
-      format.number.series output
-      format.pages output
-      new.sentence
-      publisher empty$
-        { format.organization.address output }
-        { organization "organization" bibinfo.check output
-          format.publisher.address output
-        }
-      if$
-    }
-    { format.incoll.inproc.crossref output.nonnull
-      format.pages output
-    }
-  if$
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-FUNCTION {conference} { inproceedings }
-FUNCTION {manual}
-{ output.bibitem
-  author empty$
-    { organization "organization" bibinfo.check
-      duplicate$ empty$ 'pop$
-        { output
-          address "address" bibinfo.check output
-        }
-      if$
-    }
-    { format.authors output.nonnull }
-  if$
-  new.block
-  format.btitle "title" output.check
-  author empty$
-    { organization empty$
-        {
-          address new.block.checka
-          address "address" bibinfo.check output
-        }
-        'skip$
-      if$
-    }
-    {
-      organization address new.block.checkb
-      organization "organization" bibinfo.check output
-      address "address" bibinfo.check output
-    }
-  if$
-  format.edition output
-  format.date output
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {mastersthesis}
-{ output.bibitem
-  format.authors "author" output.check
-  new.block
-  format.btitle
-  "title" output.check
-  new.block
-  bbl.mthesis format.thesis.type output.nonnull
-  school "school" bibinfo.warn output
-  address "address" bibinfo.check output
-  format.date "year" output.check
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {misc}
-{ output.bibitem
-  format.authors output
-  title howpublished new.block.checkb
-  format.title output
-  howpublished new.block.checka
-  howpublished "howpublished" bibinfo.check output
-  format.date output
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-  empty.misc.check
-}
-FUNCTION {phdthesis}
-{ output.bibitem
-  format.authors "author" output.check
-  new.block
-  format.btitle
-  "title" output.check
-  new.block
-  bbl.phdthesis format.thesis.type output.nonnull
-  school "school" bibinfo.warn output
-  address "address" bibinfo.check output
-  format.date "year" output.check
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {proceedings}
-{ output.bibitem
-  editor empty$
-    { organization "organization" bibinfo.check output
-    }
-    { format.editors output.nonnull }
-  if$
-  new.block
-  format.btitle "title" output.check
-  format.bvolume output
-  format.number.series output
-  editor empty$
-    { publisher empty$
-        'skip$
-        {
-          new.sentence
-          format.publisher.address output
-        }
-      if$
-    }
-    { publisher empty$
-        {
-          new.sentence
-          format.organization.address output }
-        {
-          new.sentence
-          organization "organization" bibinfo.check output
-          format.publisher.address output
-        }
-      if$
-     }
-  if$
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {techreport}
-{ output.bibitem
-  format.authors "author" output.check
-  new.block
-  format.title
-  "title" output.check
-  new.block
-  format.tr.number output.nonnull
-  institution "institution" bibinfo.warn output
-  address "address" bibinfo.check output
-  format.date "year" output.check
-  new.block
-  format.url output
-  new.block
-  format.note output
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {unpublished}
-{ output.bibitem
-  format.authors "author" output.check
-  new.block
-  format.title "title" output.check
-  format.date output
-  new.block
-  format.url output
-  new.block
-  format.note "note" output.check
-  format.eprint output
-  fin.entry
-}
-
-FUNCTION {default.type} { misc }
-READ
-STRINGS { longest.label }
-INTEGERS { number.label longest.label.width }
-FUNCTION {initialize.longest.label}
-{ "" 'longest.label :=
-  #1 'number.label :=
-  #0 'longest.label.width :=
-}
-FUNCTION {longest.label.pass}
-{ number.label int.to.str$ 'label :=
-  number.label #1 + 'number.label :=
-  label width$ longest.label.width >
-    { label 'longest.label :=
-      label width$ 'longest.label.width :=
-    }
-    'skip$
-  if$
-}
-EXECUTE {initialize.longest.label}
-ITERATE {longest.label.pass}
-FUNCTION {begin.bib}
-{ preamble$ empty$
-    'skip$
-    { preamble$ write$ newline$ }
-  if$
-  "\begin{thebibliography}{"  longest.label  * "}" *
-  write$ newline$
-  "\expandafter\ifx\csname url\endcsname\relax"
-  write$ newline$
-  "  \def\url#1{\texttt{#1}}\fi"
-  write$ newline$
-  "\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi"
-  write$ newline$
-  "\providecommand{\bibinfo}[2]{#2}"
-  write$ newline$
-  "\providecommand{\eprint}[2][]{\url{#2}}"
-  write$ newline$
-}
-EXECUTE {begin.bib}
-EXECUTE {init.state.consts}
-ITERATE {call.type$}
-FUNCTION {end.bib}
-{ newline$
-  "\end{thebibliography}" write$ newline$
-}
-EXECUTE {end.bib}
-%% End of customized bst file
-%%
-%% End of file `nature.bst'.
-
+%%
+%% This is file `naturemag.bst',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% merlin.mbs  (with options: `head,seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
+%% physjour.mbs  (with options: `seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
+%% geojour.mbs  (with options: `seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
+%% photjour.mbs  (with options: `seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
+%% merlin.mbs  (with options: `tail,seq-no,nm-rev,ed-rev,jnrlst,nmlm,x5,m1,yr-par,xmth,vol-bf,vnum-x,volp-com,num-xser,jnm-x,bkpg-x,pub-date,edparxc,ppx,ed,abr,xedn,jabr,amper,and-xcom,etal-it,eprint,url,url-blk,bibinfo,nfss,{}')
+%% ----------------------------------------
+%% *** Style for the journal Nature (created by Peter Czoschke) ***
+%% 
+%% Copyright 1994-2002 Patrick W Daly
+ % ===============================================================
+ % IMPORTANT NOTICE:
+ % This bibliographic style (bst) file has been generated from one or
+ % more master bibliographic style (mbs) files, listed above.
+ %
+ % This generated file can be redistributed and/or modified under the terms
+ % of the LaTeX Project Public License Distributed from CTAN
+ % archives in directory macros/latex/base/lppl.txt; either
+ % version 1 of the License, or any later version.
+ % ===============================================================
+ % Name and version information of the main mbs file:
+ % \ProvidesFile{merlin.mbs}[2002/10/21 4.05 (PWD, AO, DPC)]
+ %   For use with BibTeX version 0.99a or later
+ %-------------------------------------------------------------------
+ % This bibliography style file is intended for texts in ENGLISH
+ % This is a numerical citation style, and as such is standard LaTeX.
+ % It requires no extra package to interface to the main text.
+ % The form of the \bibitem entries is
+ %   \bibitem{key}...
+ % Usage of \cite is as follows:
+ %   \cite{key} ==>>          [#]
+ %   \cite[chap. 2]{key} ==>> [#, chap. 2]
+ % where # is a number determined by the ordering in the reference list.
+ % The order in the reference list is that by which the works were originally
+ %   cited in the text, or that in the database.
+ %---------------------------------------------------------------------
+
+ENTRY
+  { address
+    archive
+    author
+    booktitle
+    chapter
+    edition
+    editor
+    eprint
+    howpublished
+    institution
+    journal
+    key
+    month
+    note
+    number
+    organization
+    pages
+    publisher
+    school
+    series
+    title
+    type
+    url
+    volume
+    year
+  }
+  {}
+  { label }
+INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+FUNCTION {init.state.consts}
+{ #0 'before.all :=
+  #1 'mid.sentence :=
+  #2 'after.sentence :=
+  #3 'after.block :=
+}
+STRINGS { s t}
+FUNCTION {output.nonnull}
+{ 's :=
+  output.state mid.sentence =
+    { ", " * write$ }
+    { output.state after.block =
+        { add.period$ write$
+          newline$
+          "\newblock " write$
+        }
+        { output.state before.all =
+            'write$
+            { add.period$ " " * write$ }
+          if$
+        }
+      if$
+      mid.sentence 'output.state :=
+    }
+  if$
+  s
+}
+FUNCTION {output}
+{ duplicate$ empty$
+    'pop$
+    'output.nonnull
+  if$
+}
+FUNCTION {output.check}
+{ 't :=
+  duplicate$ empty$
+    { pop$ "empty " t * " in " * cite$ * warning$ }
+    'output.nonnull
+  if$
+}
+FUNCTION {fin.entry}
+{ add.period$
+  write$
+  newline$
+}
+
+FUNCTION {new.block}
+{ output.state before.all =
+    'skip$
+    { after.block 'output.state := }
+  if$
+}
+FUNCTION {new.sentence}
+{ output.state after.block =
+    'skip$
+    { output.state before.all =
+        'skip$
+        { after.sentence 'output.state := }
+      if$
+    }
+  if$
+}
+FUNCTION {add.blank}
+{  " " * before.all 'output.state :=
+}
+
+FUNCTION {date.block}
+{
+  new.block
+}
+
+FUNCTION {not}
+{   { #0 }
+    { #1 }
+  if$
+}
+FUNCTION {and}
+{   'skip$
+    { pop$ #0 }
+  if$
+}
+FUNCTION {or}
+{   { pop$ #1 }
+    'skip$
+  if$
+}
+FUNCTION {new.block.checka}
+{ empty$
+    'skip$
+    'new.block
+  if$
+}
+FUNCTION {new.block.checkb}
+{ empty$
+  swap$ empty$
+  and
+    'skip$
+    'new.block
+  if$
+}
+FUNCTION {new.sentence.checka}
+{ empty$
+    'skip$
+    'new.sentence
+  if$
+}
+FUNCTION {new.sentence.checkb}
+{ empty$
+  swap$ empty$
+  and
+    'skip$
+    'new.sentence
+  if$
+}
+FUNCTION {field.or.null}
+{ duplicate$ empty$
+    { pop$ "" }
+    'skip$
+  if$
+}
+FUNCTION {emphasize}
+{ duplicate$ empty$
+    { pop$ "" }
+    { "\emph{" swap$ * "}" * }
+  if$
+}
+FUNCTION {bolden}
+{ duplicate$ empty$
+    { pop$ "" }
+    { "\textbf{" swap$ * "}" * }
+  if$
+}
+FUNCTION {tie.or.space.prefix}
+{ duplicate$ text.length$ #3 <
+    { "~" }
+    { " " }
+  if$
+  swap$
+}
+
+FUNCTION {capitalize}
+{ "u" change.case$ "t" change.case$ }
+
+FUNCTION {space.word}
+{ " " swap$ * " " * }
+ % Here are the language-specific definitions for explicit words.
+ % Each function has a name bbl.xxx where xxx is the English word.
+ % The language selected here is ENGLISH
+FUNCTION {bbl.and}
+{ "and"}
+
+FUNCTION {bbl.etal}
+{ "et~al." }
+
+FUNCTION {bbl.editors}
+{ "eds." }
+
+FUNCTION {bbl.editor}
+{ "ed." }
+
+FUNCTION {bbl.edby}
+{ "edited by" }
+
+FUNCTION {bbl.edition}
+{ "edn." }
+
+FUNCTION {bbl.volume}
+{ "vol." }
+
+FUNCTION {bbl.of}
+{ "of" }
+
+FUNCTION {bbl.number}
+{ "no." }
+
+FUNCTION {bbl.nr}
+{ "no." }
+
+FUNCTION {bbl.in}
+{ "in" }
+
+FUNCTION {bbl.pages}
+{ "" }
+
+FUNCTION {bbl.page}
+{ "" }
+
+FUNCTION {bbl.chapter}
+{ "chap." }
+
+FUNCTION {bbl.techrep}
+{ "Tech. Rep." }
+
+FUNCTION {bbl.mthesis}
+{ "Master's thesis" }
+
+FUNCTION {bbl.phdthesis}
+{ "Ph.D. thesis" }
+
+MACRO {jan} {"Jan."}
+
+MACRO {feb} {"Feb."}
+
+MACRO {mar} {"Mar."}
+
+MACRO {apr} {"Apr."}
+
+MACRO {may} {"May"}
+
+MACRO {jun} {"Jun."}
+
+MACRO {jul} {"Jul."}
+
+MACRO {aug} {"Aug."}
+
+MACRO {sep} {"Sep."}
+
+MACRO {oct} {"Oct."}
+
+MACRO {nov} {"Nov."}
+
+MACRO {dec} {"Dec."}
+
+ %-------------------------------------------------------------------
+ % Begin module:
+ % \ProvidesFile{physjour.mbs}[2002/01/14 2.2 (PWD)]
+MACRO {aa}{"Astron. \& Astrophys."}
+MACRO {aasup}{"Astron. \& Astrophys. Suppl. Ser."}
+MACRO {aj} {"Astron. J."}
+MACRO {aph} {"Acta Phys."}
+MACRO {advp} {"Adv. Phys."}
+MACRO {ajp} {"Amer. J. Phys."}
+MACRO {ajm} {"Amer. J. Math."}
+MACRO {amsci} {"Amer. Sci."}
+MACRO {anofd} {"Ann. Fluid Dyn."}
+MACRO {am} {"Ann. Math."}
+MACRO {ap} {"Ann. Phys. (NY)"}
+MACRO {adp} {"Ann. Phys. (Leipzig)"}
+MACRO {ao} {"Appl. Opt."}
+MACRO {apl} {"Appl. Phys. Lett."}
+MACRO {app} {"Astroparticle Phys."}
+MACRO {apj} {"Astrophys. J."}
+MACRO {apjsup} {"Astrophys. J. Suppl."}
+MACRO {apss} {"Astrophys. Space Sci."}
+MACRO {araa} {"Ann. Rev. Astron. Astrophys."}
+MACRO {baas} {"Bull. Amer. Astron. Soc."}
+MACRO {baps} {"Bull. Amer. Phys. Soc."}
+MACRO {cmp} {"Comm. Math. Phys."}
+MACRO {cpam} {"Commun. Pure Appl. Math."}
+MACRO {cppcf} {"Comm. Plasma Phys. \& Controlled Fusion"}
+MACRO {cpc} {"Comp. Phys. Comm."}
+MACRO {cqg} {"Class. Quant. Grav."}
+MACRO {cra} {"C. R. Acad. Sci. A"}
+MACRO {fed} {"Fusion Eng. \& Design"}
+MACRO {ft} {"Fusion Tech."}
+MACRO {grg} {"Gen. Relativ. Gravit."}
+MACRO {ieeens} {"IEEE Trans. Nucl. Sci."}
+MACRO {ieeeps} {"IEEE Trans. Plasma Sci."}
+MACRO {ijimw} {"Interntl. J. Infrared \& Millimeter Waves"}
+MACRO {ip} {"Infrared Phys."}
+MACRO {irp} {"Infrared Phys."}
+MACRO {jap} {"J. Appl. Phys."}
+MACRO {jasa} {"J. Acoust. Soc. America"}
+MACRO {jcp} {"J. Comp. Phys."}
+MACRO {jetp} {"Sov. Phys.--JETP"}
+MACRO {jfe} {"J. Fusion Energy"}
+MACRO {jfm} {"J. Fluid Mech."}
+MACRO {jmp} {"J. Math. Phys."}
+MACRO {jne} {"J. Nucl. Energy"}
+MACRO {jnec} {"J. Nucl. Energy, C: Plasma Phys., Accelerators, Thermonucl. Res."}
+MACRO {jnm} {"J. Nucl. Mat."}
+MACRO {jpc} {"J. Phys. Chem."}
+MACRO {jpp} {"J. Plasma Phys."}
+MACRO {jpsj} {"J. Phys. Soc. Japan"}
+MACRO {jsi} {"J. Sci. Instrum."}
+MACRO {jvst} {"J. Vac. Sci. \& Tech."}
+MACRO {nat} {"Nature"}
+MACRO {nature} {"Nature"}
+MACRO {nedf} {"Nucl. Eng. \& Design/Fusion"}
+MACRO {nf} {"Nucl. Fusion"}
+MACRO {nim} {"Nucl. Inst. \& Meth."}
+MACRO {nimpr} {"Nucl. Inst. \& Meth. in Phys. Res."}
+MACRO {np} {"Nucl. Phys."}
+MACRO {npb} {"Nucl. Phys. B"}
+MACRO {nt/f} {"Nucl. Tech./Fusion"}
+MACRO {npbpc} {"Nucl. Phys. B (Proc. Suppl.)"}
+MACRO {inc} {"Nuovo Cimento"}
+MACRO {nc} {"Nuovo Cimento"}
+MACRO {pf} {"Phys. Fluids"}
+MACRO {pfa} {"Phys. Fluids A: Fluid Dyn."}
+MACRO {pfb} {"Phys. Fluids B: Plasma Phys."}
+MACRO {pl} {"Phys. Lett."}
+MACRO {pla} {"Phys. Lett. A"}
+MACRO {plb} {"Phys. Lett. B"}
+MACRO {prep} {"Phys. Rep."}
+MACRO {pnas} {"Proc. Nat. Acad. Sci. USA"}
+MACRO {pp} {"Phys. Plasmas"}
+MACRO {ppcf} {"Plasma Phys. \& Controlled Fusion"}
+MACRO {phitrsl} {"Philos. Trans. Roy. Soc. London"}
+MACRO {prl} {"Phys. Rev. Lett."}
+MACRO {pr} {"Phys. Rev."}
+MACRO {physrev} {"Phys. Rev."}
+MACRO {pra} {"Phys. Rev. A"}
+MACRO {prb} {"Phys. Rev. B"}
+MACRO {prc} {"Phys. Rev. C"}
+MACRO {prd} {"Phys. Rev. D"}
+MACRO {pre} {"Phys. Rev. E"}
+MACRO {ps} {"Phys. Scripta"}
+MACRO {procrsl} {"Proc. Roy. Soc. London"}
+MACRO {rmp} {"Rev. Mod. Phys."}
+MACRO {rsi} {"Rev. Sci. Inst."}
+MACRO {science} {"Science"}
+MACRO {sciam} {"Sci. Am."}
+MACRO {sam} {"Stud. Appl. Math."}
+MACRO {sjpp} {"Sov. J. Plasma Phys."}
+MACRO {spd} {"Sov. Phys.--Doklady"}
+MACRO {sptp} {"Sov. Phys.--Tech. Phys."}
+MACRO {spu} {"Sov. Phys.--Uspeki"}
+MACRO {st} {"Sky and Telesc."}
+ % End module: physjour.mbs
+ %-------------------------------------------------------------------
+ % Begin module:
+ % \ProvidesFile{geojour.mbs}[2002/07/10 2.0h (PWD)]
+MACRO {aisr} {"Adv. Space Res."}
+MACRO {ag} {"Ann. Geophys."}
+MACRO {anigeo} {"Ann. Geofis."}
+MACRO {angl} {"Ann. Glaciol."}
+MACRO {andmet} {"Ann. d. Meteor."}
+MACRO {andgeo} {"Ann. d. Geophys."}
+MACRO {andphy} {"Ann. Phys.-Paris"}
+MACRO {afmgb} {"Arch. Meteor. Geophys. Bioklimatol."}
+MACRO {atph} {"Atm\'osphera"}
+MACRO {aao} {"Atmos. Ocean"}
+MACRO {ass}{"Astrophys. Space Sci."}
+MACRO {atenv} {"Atmos. Environ."}
+MACRO {aujag} {"Aust. J. Agr. Res."}
+MACRO {aumet} {"Aust. Meteorol. Mag."}
+MACRO {blmet} {"Bound.-Lay. Meteorol."}
+MACRO {bams} {"Bull. Amer. Meteorol. Soc."}
+MACRO {cch} {"Clim. Change"}
+MACRO {cdyn} {"Clim. Dynam."}
+MACRO {cbul} {"Climatol. Bull."}
+MACRO {cap} {"Contrib. Atmos. Phys."}
+MACRO {dsr} {"Deep-Sea Res."}
+MACRO {dhz} {"Dtsch. Hydrogr. Z."}
+MACRO {dao} {"Dynam. Atmos. Oceans"}
+MACRO {eco} {"Ecology"}
+MACRO {empl}{"Earth, Moon and Planets"}
+MACRO {envres} {"Environ. Res."}
+MACRO {envst} {"Environ. Sci. Technol."}
+MACRO {ecms} {"Estuarine Coastal Mar. Sci."}
+MACRO {expa}{"Exper. Astron."}
+MACRO {geoint} {"Geofis. Int."}
+MACRO {geopub} {"Geofys. Publ."}
+MACRO {geogeo} {"Geol. Geofiz."}
+MACRO {gafd} {"Geophys. Astrophys. Fluid Dyn."}
+MACRO {gfd} {"Geophys. Fluid Dyn."}
+MACRO {geomag} {"Geophys. Mag."}
+MACRO {georl} {"Geophys. Res. Lett."}
+MACRO {grl} {"Geophys. Res. Lett."}
+MACRO {ga} {"Geophysica"}
+MACRO {gs} {"Geophysics"}
+MACRO {ieeetap} {"IEEE Trans. Antenn. Propag."}
+MACRO {ijawp} {"Int. J. Air Water Pollut."}
+MACRO {ijc} {"Int. J. Climatol."}
+MACRO {ijrs} {"Int. J. Remote Sens."}
+MACRO {jam} {"J. Appl. Meteorol."}
+MACRO {jaot} {"J. Atmos. Ocean. Technol."}
+MACRO {jatp} {"J. Atmos. Terr. Phys."}
+MACRO {jastp} {"J. Atmos. Solar-Terr. Phys."}
+MACRO {jce} {"J. Climate"}
+MACRO {jcam} {"J. Climate Appl. Meteor."}
+MACRO {jcm} {"J. Climate Meteor."}
+MACRO {jcy} {"J. Climatol."}
+MACRO {jgr} {"J. Geophys. Res."}
+MACRO {jga} {"J. Glaciol."}
+MACRO {jh} {"J. Hydrol."}
+MACRO {jmr} {"J. Mar. Res."}
+MACRO {jmrj} {"J. Meteor. Res. Japan"}
+MACRO {jm} {"J. Meteor."}
+MACRO {jpo} {"J. Phys. Oceanogr."}
+MACRO {jra} {"J. Rech. Atmos."}
+MACRO {jaes} {"J. Aeronaut. Sci."}
+MACRO {japca} {"J. Air Pollut. Control Assoc."}
+MACRO {jas} {"J. Atmos. Sci."}
+MACRO {jmts} {"J. Mar. Technol. Soc."}
+MACRO {jmsj} {"J. Meteorol. Soc. Japan"}
+MACRO {josj} {"J. Oceanogr. Soc. Japan"}
+MACRO {jwm} {"J. Wea. Mod."}
+MACRO {lao} {"Limnol. Oceanogr."}
+MACRO {mwl} {"Mar. Wea. Log"}
+MACRO {mau} {"Mausam"}
+MACRO {meteor} {"``Meteor'' Forschungsergeb."}
+MACRO {map} {"Meteorol. Atmos. Phys."}
+MACRO {metmag} {"Meteor. Mag."}
+MACRO {metmon} {"Meteor. Monogr."}
+MACRO {metrun} {"Meteor. Rundsch."}
+MACRO {metzeit} {"Meteor. Z."}
+MACRO {metgid} {"Meteor. Gidrol."}
+MACRO {mwr} {"Mon. Weather Rev."}
+MACRO {nwd} {"Natl. Weather Dig."}
+MACRO {nzjmfr} {"New Zeal. J. Mar. Freshwater Res."}
+MACRO {npg} {"Nonlin. Proc. Geophys."}
+MACRO {om} {"Oceanogr. Meteorol."}
+MACRO {ocac} {"Oceanol. Acta"}
+MACRO {oceanus} {"Oceanus"}
+MACRO {paleoc} {"Paleoceanography"}
+MACRO {pce} {"Phys. Chem. Earth"}
+MACRO {pmg} {"Pap. Meteor. Geophys."}
+MACRO {ppom} {"Pap. Phys. Oceanogr. Meteor."}
+MACRO {physzeit} {"Phys. Z."}
+MACRO {pps} {"Planet. Space Sci."}
+MACRO {pss} {"Planet. Space Sci."}
+MACRO {pag} {"Pure Appl. Geophys."}
+MACRO {qjrms} {"Quart. J. Roy. Meteorol. Soc."}
+MACRO {quatres} {"Quat. Res."}
+MACRO {rsci} {"Radio Sci."}
+MACRO {rse} {"Remote Sens. Environ."}
+MACRO {rgeo} {"Rev. Geophys."}
+MACRO {rgsp} {"Rev. Geophys. Space Phys."}
+MACRO {rdgeo} {"Rev. Geofis."}
+MACRO {revmeta} {"Rev. Meteorol."}
+MACRO {sgp}{"Surveys in Geophys."}
+MACRO {sp} {"Solar Phys."}
+MACRO {ssr} {"Space Sci. Rev."}
+MACRO {tellus} {"Tellus"}
+MACRO {tac} {"Theor. Appl. Climatol."}
+MACRO {tagu} {"Trans. Am. Geophys. Union (EOS)"}
+MACRO {wrr} {"Water Resour. Res."}
+MACRO {weather} {"Weather"}
+MACRO {wafc} {"Weather Forecast."}
+MACRO {ww} {"Weatherwise"}
+MACRO {wmob} {"WMO Bull."}
+MACRO {zeitmet} {"Z. Meteorol."}
+ % End module: geojour.mbs
+ %-------------------------------------------------------------------
+ % Begin module:
+ % \ProvidesFile{photjour.mbs}[1999/02/24 2.0b (PWD)]
+
+MACRO {appopt} {"Appl. Opt."}
+MACRO {bell} {"Bell Syst. Tech. J."}
+MACRO {ell} {"Electron. Lett."}
+MACRO {jasp} {"J. Appl. Spectr."}
+MACRO {jqe} {"IEEE J. Quantum Electron."}
+MACRO {jlwt} {"J. Lightwave Technol."}
+MACRO {jmo} {"J. Mod. Opt."}
+MACRO {josa} {"J. Opt. Soc. America"}
+MACRO {josaa} {"J. Opt. Soc. Amer.~A"}
+MACRO {josab} {"J. Opt. Soc. Amer.~B"}
+MACRO {jdp} {"J. Phys. (Paris)"}
+MACRO {oc} {"Opt. Commun."}
+MACRO {ol} {"Opt. Lett."}
+MACRO {phtl} {"IEEE Photon. Technol. Lett."}
+MACRO {pspie} {"Proc. Soc. Photo-Opt. Instrum. Eng."}
+MACRO {sse} {"Solid-State Electron."}
+MACRO {sjot} {"Sov. J. Opt. Technol."}
+MACRO {sjqe} {"Sov. J. Quantum Electron."}
+MACRO {sleb} {"Sov. Phys.--Leb. Inst. Rep."}
+MACRO {stph} {"Sov. Phys.--Techn. Phys."}
+MACRO {stphl} {"Sov. Techn. Phys. Lett."}
+MACRO {vr} {"Vision Res."}
+MACRO {zph} {"Z. f. Physik"}
+MACRO {zphb} {"Z. f. Physik~B"}
+MACRO {zphd} {"Z. f. Physik~D"}
+
+MACRO {CLEO} {"CLEO"}
+MACRO {ASSL} {"Adv. Sol.-State Lasers"}
+MACRO {OSA}  {"OSA"}
+ % End module: photjour.mbs
+%% Copyright 1994-2002 Patrick W Daly
+MACRO {acmcs} {"ACM Comput. Surv."}
+
+MACRO {acta} {"Acta Inf."}
+
+MACRO {cacm} {"Commun. ACM"}
+
+MACRO {ibmjrd} {"IBM J. Res. Dev."}
+
+MACRO {ibmsj} {"IBM Syst.~J."}
+
+MACRO {ieeese} {"IEEE Trans. Software Eng."}
+
+MACRO {ieeetc} {"IEEE Trans. Comput."}
+
+MACRO {ieeetcad}
+ {"IEEE Trans. Comput. Aid. Des."}
+
+MACRO {ipl} {"Inf. Process. Lett."}
+
+MACRO {jacm} {"J.~ACM"}
+
+MACRO {jcss} {"J.~Comput. Syst. Sci."}
+
+MACRO {scp} {"Sci. Comput. Program."}
+
+MACRO {sicomp} {"SIAM J. Comput."}
+
+MACRO {tocs} {"ACM Trans. Comput. Syst."}
+
+MACRO {tods} {"ACM Trans. Database Syst."}
+
+MACRO {tog} {"ACM Trans. Graphic."}
+
+MACRO {toms} {"ACM Trans. Math. Software"}
+
+MACRO {toois} {"ACM Trans. Office Inf. Syst."}
+
+MACRO {toplas} {"ACM Trans. Progr. Lang. Syst."}
+
+MACRO {tcs} {"Theor. Comput. Sci."}
+
+FUNCTION {bibinfo.check}
+{ swap$
+  duplicate$ missing$
+    {
+      pop$ pop$
+      ""
+    }
+    { duplicate$ empty$
+        {
+          swap$ pop$
+        }
+        { swap$
+          "\bibinfo{" swap$ * "}{" * swap$ * "}" *
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {bibinfo.warn}
+{ swap$
+  duplicate$ missing$
+    {
+      swap$ "missing " swap$ * " in " * cite$ * warning$ pop$
+      ""
+    }
+    { duplicate$ empty$
+        {
+          swap$ "empty " swap$ * " in " * cite$ * warning$
+        }
+        { swap$
+          "\bibinfo{" swap$ * "}{" * swap$ * "}" *
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {format.eprint}
+{ eprint duplicate$ empty$
+    'skip$
+    { "\eprint"
+      archive empty$
+        'skip$
+        { "[" * archive * "]" * }
+      if$
+      "{" * swap$ * "}" *
+    }
+  if$
+}
+FUNCTION {format.url}
+{ url empty$
+    { "" }
+    { "\urlprefix\url{" url * "}" * }
+  if$
+}
+
+STRINGS  { bibinfo}
+INTEGERS { nameptr namesleft numnames }
+
+FUNCTION {format.names}
+{ 'bibinfo :=
+  duplicate$ empty$ 'skip$ {
+  's :=
+  "" 't :=
+  #1 'nameptr :=
+  s num.names$ 'numnames :=
+  numnames 'namesleft :=
+    { namesleft #0 > }
+    { s nameptr
+      "{vv~}{ll}{, f.}{, jj}"
+      format.name$
+      bibinfo bibinfo.check
+      't :=
+      nameptr #1 >
+        {
+          nameptr #1
+          #1 + =
+          numnames #5
+          > and
+            { "others" 't :=
+              #1 'namesleft := }
+            'skip$
+          if$
+          namesleft #1 >
+            { ", " * t * }
+            {
+              s nameptr "{ll}" format.name$ duplicate$ "others" =
+                { 't := }
+                { pop$ }
+              if$
+              t "others" =
+                {
+                  " " * bbl.etal emphasize *
+                }
+                {
+                  "\&"
+                  space.word * t *
+                }
+              if$
+            }
+          if$
+        }
+        't
+      if$
+      nameptr #1 + 'nameptr :=
+      namesleft #1 - 'namesleft :=
+    }
+  while$
+  } if$
+}
+FUNCTION {format.names.ed}
+{
+  format.names
+}
+FUNCTION {format.authors}
+{ author "author" format.names
+}
+FUNCTION {get.bbl.editor}
+{ editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }
+
+FUNCTION {format.editors}
+{ editor "editor" format.names duplicate$ empty$ 'skip$
+    {
+      " " *
+      get.bbl.editor
+   "(" swap$ * ")" *
+      *
+    }
+  if$
+}
+FUNCTION {format.note}
+{
+ note empty$
+    { "" }
+    { note #1 #1 substring$
+      duplicate$ "{" =
+        'skip$
+        { output.state mid.sentence =
+          { "l" }
+          { "u" }
+        if$
+        change.case$
+        }
+      if$
+      note #2 global.max$ substring$ * "note" bibinfo.check
+    }
+  if$
+}
+
+FUNCTION {format.title}
+{ title
+  duplicate$ empty$ 'skip$
+    { "t" change.case$ }
+  if$
+  "title" bibinfo.check
+}
+FUNCTION {output.bibitem}
+{ newline$
+  "\bibitem{" write$
+  cite$ write$
+  "}" write$
+  newline$
+  ""
+  before.all 'output.state :=
+}
+
+FUNCTION {n.dashify}
+{
+  't :=
+  ""
+    { t empty$ not }
+    { t #1 #1 substring$ "-" =
+        { t #1 #2 substring$ "--" = not
+            { "--" *
+              t #2 global.max$ substring$ 't :=
+            }
+            {   { t #1 #1 substring$ "-" = }
+                { "-" *
+                  t #2 global.max$ substring$ 't :=
+                }
+              while$
+            }
+          if$
+        }
+        { t #1 #1 substring$ *
+          t #2 global.max$ substring$ 't :=
+        }
+      if$
+    }
+  while$
+}
+
+FUNCTION {word.in}
+{ bbl.in capitalize
+  " " * }
+
+FUNCTION {format.date}
+{
+  ""
+  duplicate$ empty$
+  year  "year"  bibinfo.check duplicate$ empty$
+    { swap$ 'skip$
+        { "there's a month but no year in " cite$ * warning$ }
+      if$
+      *
+    }
+    { swap$ 'skip$
+        {
+          swap$
+          " " * swap$
+        }
+      if$
+      *
+    }
+  if$
+  duplicate$ empty$
+    'skip$
+    {
+      before.all 'output.state :=
+    " (" swap$ * ")" *
+    }
+  if$
+}
+FUNCTION {format.btitle}
+{ title "title" bibinfo.check
+  duplicate$ empty$ 'skip$
+    {
+      emphasize
+    }
+  if$
+}
+FUNCTION {either.or.check}
+{ empty$
+    'pop$
+    { "can't use both " swap$ * " fields in " * cite$ * warning$ }
+  if$
+}
+FUNCTION {format.bvolume}
+{ volume empty$
+    { "" }
+    { bbl.volume volume tie.or.space.prefix
+      "volume" bibinfo.check * *
+      series "series" bibinfo.check
+      duplicate$ empty$ 'pop$
+        { swap$ bbl.of space.word * swap$
+          emphasize * }
+      if$
+      "volume and number" number either.or.check
+    }
+  if$
+}
+FUNCTION {format.number.series}
+{ volume empty$
+    { number empty$
+        { series field.or.null }
+        { series empty$
+            { number "number" bibinfo.check }
+        { output.state mid.sentence =
+            { bbl.number }
+            { bbl.number capitalize }
+          if$
+          number tie.or.space.prefix "number" bibinfo.check * *
+          bbl.in space.word *
+          series "series" bibinfo.check *
+        }
+      if$
+    }
+      if$
+    }
+    { "" }
+  if$
+}
+
+FUNCTION {format.edition}
+{ edition duplicate$ empty$ 'skip$
+    {
+      output.state mid.sentence =
+        { "l" }
+        { "t" }
+      if$ change.case$
+      "edition" bibinfo.check
+      " " * bbl.edition *
+    }
+  if$
+}
+INTEGERS { multiresult }
+FUNCTION {multi.page.check}
+{ 't :=
+  #0 'multiresult :=
+    { multiresult not
+      t empty$ not
+      and
+    }
+    { t #1 #1 substring$
+      duplicate$ "-" =
+      swap$ duplicate$ "," =
+      swap$ "+" =
+      or or
+        { #1 'multiresult := }
+        { t #2 global.max$ substring$ 't := }
+      if$
+    }
+  while$
+  multiresult
+}
+FUNCTION {format.pages}
+{ pages duplicate$ empty$ 'skip$
+    { duplicate$ multi.page.check
+        {
+          n.dashify
+        }
+        {
+        }
+      if$
+      "pages" bibinfo.check
+    }
+  if$
+}
+FUNCTION {format.journal.pages}
+{ pages duplicate$ empty$ 'pop$
+    { swap$ duplicate$ empty$
+        { pop$ pop$ format.pages }
+        {
+          ", " *
+          swap$
+          n.dashify
+          "pages" bibinfo.check
+          *
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {format.vol.num.pages}
+{ volume field.or.null
+  duplicate$ empty$ 'skip$
+    {
+      "volume" bibinfo.check
+    }
+  if$
+  bolden
+  format.journal.pages
+}
+
+FUNCTION {format.chapter.pages}
+{ chapter empty$
+    'format.pages
+    { type empty$
+        { bbl.chapter }
+        { type "l" change.case$
+          "type" bibinfo.check
+        }
+      if$
+      chapter tie.or.space.prefix
+      "chapter" bibinfo.check
+      * *
+      pages empty$
+        'skip$
+        { ", " * format.pages * }
+      if$
+    }
+  if$
+}
+
+FUNCTION {format.booktitle}
+{
+  booktitle "booktitle" bibinfo.check
+  emphasize
+}
+FUNCTION {format.in.ed.booktitle}
+{ format.booktitle duplicate$ empty$ 'skip$
+    {
+      editor "editor" format.names.ed duplicate$ empty$ 'pop$
+        {
+          " " *
+          get.bbl.editor
+          "(" swap$ * ") " *
+          * swap$
+          * }
+      if$
+      word.in swap$ *
+    }
+  if$
+}
+FUNCTION {empty.misc.check}
+{ author empty$ title empty$ howpublished empty$
+  month empty$ year empty$ note empty$
+  and and and and and
+    { "all relevant fields are empty in " cite$ * warning$ }
+    'skip$
+  if$
+}
+FUNCTION {format.thesis.type}
+{ type duplicate$ empty$
+    'pop$
+    { swap$ pop$
+      "t" change.case$ "type" bibinfo.check
+    }
+  if$
+}
+FUNCTION {format.tr.number}
+{ number "number" bibinfo.check
+  type duplicate$ empty$
+    { pop$ bbl.techrep }
+    'skip$
+  if$
+  "type" bibinfo.check
+  swap$ duplicate$ empty$
+    { pop$ "t" change.case$ }
+    { tie.or.space.prefix * * }
+  if$
+}
+FUNCTION {format.article.crossref}
+{
+  key duplicate$ empty$
+    { pop$
+      journal duplicate$ empty$
+        { "need key or journal for " cite$ * " to crossref " * crossref * warning$ }
+        { "journal" bibinfo.check emphasize word.in swap$ * }
+      if$
+    }
+    { word.in swap$ * " " *}
+  if$
+  " \cite{" * crossref * "}" *
+}
+FUNCTION {format.crossref.editor}
+{ editor #1 "{vv~}{ll}" format.name$
+  "editor" bibinfo.check
+  editor num.names$ duplicate$
+  #2 >
+    { pop$
+      "editor" bibinfo.check
+      " " * bbl.etal
+      emphasize
+      *
+    }
+    { #2 <
+        'skip$
+        { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
+            {
+              "editor" bibinfo.check
+              " " * bbl.etal
+              emphasize
+              *
+            }
+            {
+              " \& "
+              * editor #2 "{vv~}{ll}" format.name$
+              "editor" bibinfo.check
+              *
+            }
+          if$
+        }
+      if$
+    }
+  if$
+}
+FUNCTION {format.book.crossref}
+{ volume duplicate$ empty$
+    { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
+      pop$ word.in
+    }
+    { bbl.volume
+      capitalize
+      swap$ tie.or.space.prefix "volume" bibinfo.check * * bbl.of space.word *
+    }
+  if$
+  editor empty$
+  editor field.or.null author field.or.null =
+  or
+    { key empty$
+        { series empty$
+            { "need editor, key, or series for " cite$ * " to crossref " *
+              crossref * warning$
+              "" *
+            }
+            { series emphasize * }
+          if$
+        }
+        { key * }
+      if$
+    }
+    { format.crossref.editor * }
+  if$
+  " \cite{" * crossref * "}" *
+}
+FUNCTION {format.incoll.inproc.crossref}
+{
+  editor empty$
+  editor field.or.null author field.or.null =
+  or
+    { key empty$
+        { format.booktitle duplicate$ empty$
+            { "need editor, key, or booktitle for " cite$ * " to crossref " *
+              crossref * warning$
+            }
+            { word.in swap$ * }
+          if$
+        }
+        { word.in key * " " *}
+      if$
+    }
+    { word.in format.crossref.editor * " " *}
+  if$
+  " \cite{" * crossref * "}" *
+}
+FUNCTION {format.org.or.pub}
+{ 't :=
+  ""
+  year empty$
+    { "empty year in " cite$ * warning$ }
+    'skip$
+  if$
+  address empty$ t empty$ and
+  year empty$ and
+    'skip$
+    {
+      add.blank "(" *
+      t empty$
+        { address "address" bibinfo.check *
+        }
+        { t *
+          address empty$
+            'skip$
+            { ", " * address "address" bibinfo.check * }
+          if$
+        }
+      if$
+      year empty$
+        'skip$
+        { t empty$ address empty$ and
+            'skip$
+            { ", " * }
+          if$
+          year "year" bibinfo.check
+          *
+        }
+      if$
+      ")" *
+    }
+  if$
+}
+FUNCTION {format.publisher.address}
+{ publisher "publisher" bibinfo.warn format.org.or.pub
+}
+
+FUNCTION {format.organization.address}
+{ organization "organization" bibinfo.check format.org.or.pub
+}
+
+FUNCTION {article}
+{ output.bibitem
+  format.authors "author" output.check
+  new.block
+  format.title "title" output.check
+  new.block
+  crossref missing$
+    {
+      journal
+      "journal" bibinfo.check
+      emphasize
+      "journal" output.check
+      add.blank
+      format.vol.num.pages output
+      format.date "year" output.check
+    }
+    { format.article.crossref output.nonnull
+      format.pages output
+    }
+  if$
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {book}
+{ output.bibitem
+  author empty$
+    { format.editors "author and editor" output.check
+      add.blank
+    }
+    { format.authors output.nonnull
+      crossref missing$
+        { "author and editor" editor either.or.check }
+        'skip$
+      if$
+    }
+  if$
+  new.block
+  format.btitle "title" output.check
+  crossref missing$
+    { format.bvolume output
+      new.block
+      format.number.series output
+      new.sentence
+      format.publisher.address output
+    }
+    {
+      new.block
+      format.book.crossref output.nonnull
+      format.date "year" output.check
+    }
+  if$
+  format.edition output
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {booklet}
+{ output.bibitem
+  format.authors output
+  new.block
+  format.title "title" output.check
+  new.block
+  howpublished "howpublished" bibinfo.check output
+  address "address" bibinfo.check output
+  format.date output
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {inbook}
+{ output.bibitem
+  author empty$
+    { format.editors "author and editor" output.check
+    }
+    { format.authors output.nonnull
+      crossref missing$
+        { "author and editor" editor either.or.check }
+        'skip$
+      if$
+    }
+  if$
+  new.block
+  format.btitle "title" output.check
+  crossref missing$
+    {
+      format.bvolume output
+      format.chapter.pages "chapter and pages" output.check
+      new.block
+      format.number.series output
+      new.sentence
+      format.publisher.address output
+    }
+    {
+      format.chapter.pages "chapter and pages" output.check
+      new.block
+      format.book.crossref output.nonnull
+      format.date "year" output.check
+    }
+  if$
+  format.edition output
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {incollection}
+{ output.bibitem
+  format.authors "author" output.check
+  new.block
+  format.title "title" output.check
+  new.block
+  crossref missing$
+    { format.in.ed.booktitle "booktitle" output.check
+      format.bvolume output
+      format.number.series output
+      format.chapter.pages output
+      new.sentence
+      format.publisher.address output
+      format.edition output
+    }
+    { format.incoll.inproc.crossref output.nonnull
+      format.chapter.pages output
+    }
+  if$
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {inproceedings}
+{ output.bibitem
+  format.authors "author" output.check
+  new.block
+  format.title "title" output.check
+  new.block
+  crossref missing$
+    { format.in.ed.booktitle "booktitle" output.check
+      format.bvolume output
+      format.number.series output
+      format.pages output
+      new.sentence
+      publisher empty$
+        { format.organization.address output }
+        { organization "organization" bibinfo.check output
+          format.publisher.address output
+        }
+      if$
+    }
+    { format.incoll.inproc.crossref output.nonnull
+      format.pages output
+    }
+  if$
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+FUNCTION {conference} { inproceedings }
+FUNCTION {manual}
+{ output.bibitem
+  author empty$
+    { organization "organization" bibinfo.check
+      duplicate$ empty$ 'pop$
+        { output
+          address "address" bibinfo.check output
+        }
+      if$
+    }
+    { format.authors output.nonnull }
+  if$
+  new.block
+  format.btitle "title" output.check
+  author empty$
+    { organization empty$
+        {
+          address new.block.checka
+          address "address" bibinfo.check output
+        }
+        'skip$
+      if$
+    }
+    {
+      organization address new.block.checkb
+      organization "organization" bibinfo.check output
+      address "address" bibinfo.check output
+    }
+  if$
+  format.edition output
+  format.date output
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {mastersthesis}
+{ output.bibitem
+  format.authors "author" output.check
+  new.block
+  format.btitle
+  "title" output.check
+  new.block
+  bbl.mthesis format.thesis.type output.nonnull
+  school "school" bibinfo.warn output
+  address "address" bibinfo.check output
+  format.date "year" output.check
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {misc}
+{ output.bibitem
+  format.authors output
+  title howpublished new.block.checkb
+  format.title output
+  howpublished new.block.checka
+  howpublished "howpublished" bibinfo.check output
+  format.date output
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+  empty.misc.check
+}
+FUNCTION {phdthesis}
+{ output.bibitem
+  format.authors "author" output.check
+  new.block
+  format.btitle
+  "title" output.check
+  new.block
+  bbl.phdthesis format.thesis.type output.nonnull
+  school "school" bibinfo.warn output
+  address "address" bibinfo.check output
+  format.date "year" output.check
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {proceedings}
+{ output.bibitem
+  editor empty$
+    { organization "organization" bibinfo.check output
+    }
+    { format.editors output.nonnull }
+  if$
+  new.block
+  format.btitle "title" output.check
+  format.bvolume output
+  format.number.series output
+  editor empty$
+    { publisher empty$
+        'skip$
+        {
+          new.sentence
+          format.publisher.address output
+        }
+      if$
+    }
+    { publisher empty$
+        {
+          new.sentence
+          format.organization.address output }
+        {
+          new.sentence
+          organization "organization" bibinfo.check output
+          format.publisher.address output
+        }
+      if$
+     }
+  if$
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {techreport}
+{ output.bibitem
+  format.authors "author" output.check
+  new.block
+  format.title
+  "title" output.check
+  new.block
+  format.tr.number output.nonnull
+  institution "institution" bibinfo.warn output
+  address "address" bibinfo.check output
+  format.date "year" output.check
+  new.block
+  format.url output
+  new.block
+  format.note output
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {unpublished}
+{ output.bibitem
+  format.authors "author" output.check
+  new.block
+  format.title "title" output.check
+  format.date output
+  new.block
+  format.url output
+  new.block
+  format.note "note" output.check
+  format.eprint output
+  fin.entry
+}
+
+FUNCTION {default.type} { misc }
+READ
+STRINGS { longest.label }
+INTEGERS { number.label longest.label.width }
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+  #1 'number.label :=
+  #0 'longest.label.width :=
+}
+FUNCTION {longest.label.pass}
+{ number.label int.to.str$ 'label :=
+  number.label #1 + 'number.label :=
+  label width$ longest.label.width >
+    { label 'longest.label :=
+      label width$ 'longest.label.width :=
+    }
+    'skip$
+  if$
+}
+EXECUTE {initialize.longest.label}
+ITERATE {longest.label.pass}
+FUNCTION {begin.bib}
+{ preamble$ empty$
+    'skip$
+    { preamble$ write$ newline$ }
+  if$
+  "\begin{thebibliography}{"  longest.label  * "}" *
+  write$ newline$
+  "\expandafter\ifx\csname url\endcsname\relax"
+  write$ newline$
+  "  \def\url#1{\texttt{#1}}\fi"
+  write$ newline$
+  "\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi"
+  write$ newline$
+  "\providecommand{\bibinfo}[2]{#2}"
+  write$ newline$
+  "\providecommand{\eprint}[2][]{\url{#2}}"
+  write$ newline$
+}
+EXECUTE {begin.bib}
+EXECUTE {init.state.consts}
+ITERATE {call.type$}
+FUNCTION {end.bib}
+{ newline$
+  "\end{thebibliography}" write$ newline$
+}
+EXECUTE {end.bib}
+%% End of customized bst file
+%%
+%% End of file `nature.bst'.
diff --git a/doc/phyml-manual.pdf b/doc/phyml-manual.pdf
index 8901958..8fd0374 100644
Binary files a/doc/phyml-manual.pdf and b/doc/phyml-manual.pdf differ
diff --git a/doc/phyml-manual.tex b/doc/phyml-manual.tex
index 68c052b..3b42aee 100644
--- a/doc/phyml-manual.tex
+++ b/doc/phyml-manual.tex
@@ -666,7 +666,7 @@ conducted.  This option  should  be used  in  conjunction with  \x{-u}  \x{file\
 
 \item \x{--quiet} \index{command-line options!\x{--quiet}}\\
 Runs PhyML in quiet mode. The program will not pause if the memory required to run the analysis
-exceeds 256MB and will not output the log-likelihood score to the output.
+exceeds 256MB and will not output the progression of the log-likelihood scores on the standard output.
 
 \item \x{--ancestral} \index{command-line options!\x{--ancestral}}\\
 PhyML calculates the marginal probabilities of each character state at each internal node and each
@@ -1022,9 +1022,9 @@ order to do so, one should use the \x{--constraint\_file}  \x{file\_name} comman
 define. For instance, the following constraints:
 \vspace{0.2cm}
 \begin{Verbatim}
-((A,B,C),(D,E,F));
+((A,B),C,(D,E,F));
 \end{Verbatim}
-indicate that taxa A, B and C belong to the same clade. D, E and F also belong to the
+indicate that taxa D, E and F belong to the same clade. A, B and C also belong to the
 same  clade and the  two clades  hence defined  should not  overlap. Under  these two
 constraints, the tree ((A,B),D,((E,F),C)) is not valid. From the example above, you will notice that
 the constraints are defined  using a multifurcating tree in NEWICK format.  Note that this tree does
@@ -1599,6 +1599,14 @@ Options:
   estimates of the probabilities that the corresponding edges are correctly inferred (see Anisimova et
   al. 2011 for more precision). By default and if no bootstrap analysis is performed, branch supports
   are estimated using the aBayes approach.
+\item \x{quiet="yes|no"}. Runs PhyML in quiet mode when \x{quiet=yes}. The program will not pause if the memory required to run the analysis
+exceeds 256MB and will not output the progresssion of the log-likelihood scores on the standard output.
+\item \x{memory.check="yes|no"}. By default, when processing a large data set, PhyML will pause and ask the user to confirm that
+she/he wants to continue with the execution of the analysis despite the large amount of memory
+required. Setting \x{memory.check=no}  skips this question. It is especially useful when running
+PhyML in batch mode.
+
+
 
 \end{itemize}
 \subsubsection{{\tt topology} component}\index{XML options!{\tt topology} component}
@@ -2295,7 +2303,7 @@ parameters estimates are mostly determined by the prior of driven by the sequenc
 This option is to select the model of evolution of the rate of evolution. \x{gbs} (default) stands
 for Geometric Brownian + Stochastic. This model considers that rates evolve along the tree
 according to a geometric Brownian process \cite{kishino01} and the average rate of substitution
-along a branch is a gamma distributed random variable. This model is described in \cite{guindon12}.
+along a branch is a gamma distributed random variable. This model is described in \cite{guindon13}.
 The \x{gbd} model (Geometric Browninan with Deterministic calculation of edge lengths) assumes the
 same Geometric Brownian model of rates. However, as opposed to \x{gbs}, this model uses a
 deterministic approximation to calculate the average rates of evolution along edges. This model
@@ -2400,7 +2408,7 @@ The ``default citation'' is:
 
 \begin{itemize}
 \item Guindon S. ``From trajectories to averages: an improved description of the heterogeneity of
-substitution rates along lineages'', {\it Systematic Biology}, 2012. doi: 10.1093/sysbio/sys063.
+substitution rates along lineages'', {\it Systematic Biology}, 2013. 62(1): 22-34.
 \end{itemize}
 
 An earlier article also described some of the methods implemented in PhyTime:
@@ -2660,10 +2668,7 @@ algorithms to search the space of tree topologies for this type of data.
 The development of PhyML since 2000 has been supported by the Centre National de la Recherche
 Scientifique (CNRS) and the Minist\`ere de l'\'Education Nationale.
 
-% \bibliographystyle{/home/guindon/latex/biblio/OUPnum}
 \bibliographystyle{/home/guindon/latex/biblio/nature/naturemag}
-%\bibliographystyle{/home/imran/Workspace2/phyml/branches/beagle/doc/naturemag}
-%\bibliography{/home/imran/Workspace2/phyml/branches/beagle/doc/ref}
 \bibliography{/home/guindon/latex/biblio/ref}
 
 \printindex
diff --git a/doc/ref.bib b/doc/ref.bib
index 4d1b746..3a5f008 100644
--- a/doc/ref.bib
+++ b/doc/ref.bib
@@ -1,4 +1,27 @@
- at article{ayres2012beagle,
+
+ at article{tilman2011,
+  title={Diversification, biotic interchange, and the universal trade-off hypothesis},
+  author={D. Tilman},
+  journal={The American Naturalist},
+  volume={178},
+  number={3},
+  pages={355--371},
+  year={2011},
+  publisher={JSTOR}
+}
+
+
+ at article{gernhard08,
+  title={The conditioned reconstructed process},
+  author={Gernhard, Tanja},
+  journal={Journal of Theoretical Biology},
+  volume={253},
+  number={4},
+  pages={769--778},
+  year={2008},
+  publisher={Elsevier}
+}
+ at article{ayres12,
   title={BEAGLE: an application programming interface and high-performance computing library for statistical phylogenetics},
   author={Ayres, Daniel L and Darling, Aaron and Zwickl, Derrick J and Beerli, Peter and Holder, Mark T and Lewis, Paul O and Huelsenbeck, John P and Ronquist, Fredrik and Swofford, David L and Cummings, Michael P and others},
   journal={Systematic biology},
@@ -9,3 +32,5512 @@
   publisher={Oxford University Press}
 }
 
+ at article{ho11,
+  title={Time-dependent rates of molecular evolution},
+  author={Ho, Simon YW and Lanfear, Robert and Bromham, Lindell and Phillips, Matthew J and Soubrier, Julien and Rodrigo, Allen G and Cooper, Alan},
+  journal={Molecular ecology},
+  volume={20},
+  number={15},
+  pages={3087--3101},
+  year={2011},
+  publisher={Wiley Online Library}
+}
+
+
+ at article{fletcher10,
+  title={The effect of insertions, deletions, and alignment errors on the branch-site test of positive selection},
+  author={Fletcher, William and Yang, Ziheng},
+  journal={Molecular Biology and Evolution},
+  volume={27},
+  number={10},
+  pages={2257--2267},
+  year={2010},
+  publisher={SMBE}
+}
+
+
+ at article{degnan09,
+  title={Gene tree discordance, phylogenetic inference and the multispecies coalescent},
+  author={Degnan, J.H. and Rosenberg, N.A.},
+  journal={Trends in Ecology \& Evolution},
+  volume={24},
+  number={6},
+  pages={332--340},
+  year={2009},
+  publisher={Elsevier}
+}
+ at article{best,
+  title={BEST: Bayesian estimation of species trees under the coalescent model},
+  author={Liu, L.},
+  journal={Bioinformatics},
+  volume={24},
+  number={21},
+  pages={2542--2543},
+  year={2008},
+  publisher={Oxford Univ Press}
+}
+
+ at article{lg4x,
+  title={Modeling protein evolution with several amino acid replacement matrices depending on site rates},
+  author={Le, Si Quang and Dang, Cuong Cao and Gascuel, Olivier},
+  journal={Molecular Biology and Evolution},
+  volume={29},
+  number={10},
+  pages={2921--2936},
+  year={2012},
+  publisher={SMBE}
+}
+ at article{stem,
+  title={STEM: species tree estimation using maximum likelihood for gene trees under coalescence},
+  author={Kubatko, L.S. and Carstens, B.C. and Knowles, L.L.},
+  journal={Bioinformatics},
+  volume={25},
+  number={7},
+  pages={971--973},
+  year={2009},
+  publisher={Oxford Univ Press}
+}
+
+ at article{startbeast,
+  title={Bayesian inference of species trees from multilocus data},
+  author={Heled, J. and Drummond, A.J.},
+  journal={Molecular Biology and Evolution},
+  volume={27},
+  number={3},
+  pages={570--580},
+  year={2010},
+  publisher={SMBE}
+}
+
+
+%% Created for guindon at 2009-04-21 13:11:50 +1200 
+
+ at article{soubrier12,
+  title={The influence of rate heterogeneity among sites on the time dependence of molecular rates},
+  author={Soubrier, J. and Steel, M. and Lee, M.S.Y. and Sarkissian, C.D. and Guindon, S. and Ho, S.Y.W. and Cooper, A.},
+  journal={Molecular Biology and Evolution},
+  year={2012},
+  publisher={SMBE}
+}
+
+%% Saved with string encoding Unicode (UTF-8) 
+ at article{matsen07,
+  title={Phylogenetic mixtures on a single tree can mimic a tree of another topology},
+  author={Matsen, F.A. and Steel, M.},
+  journal={Systematic biology},
+  volume={56},
+  number={5},
+  pages={767--775},
+  year={2007},
+  publisher={Oxford University Press}
+}
+ at book{bailey64,
+  title={The elements of stochastic processes with applications to the natural sciences},
+  author={Bailey, Norman TJ},
+publisher={Wiley},
+  year={1964}
+}
+
+ at article{gillespie2011,
+  title={Long-distance dispersal: a framework for hypothesis testing},
+  author={Gillespie, R.G. and Baldwin, B.G. and Waters, J.M. and Fraser, C.I. and Nikula, R. and Roderick, G.K.},
+  journal={Trends in ecology \& evolution},
+  year={2011},
+  vol=27,
+  pages={47,56}
+}
+
+ at article{guindon13,
+  title={From trajectories to averages: an improved description of the heterogeneity of substitution rates along lineages.},
+  author={Guindon, S.},
+  journal={Systematic Biology},
+  year={2013},
+volume={62},
+pages={22-34},
+  publisher={Oxford University Press}
+}
+
+ at article{arnold01,
+Author = {Barry C. Arnold and Enrique Castillo and Jose Maria Sarabia},
+Title = {Conditionally Specified Distributions: An Introduction},
+Journal = {Statistical Science},
+Year = 2001,
+Volume = 16,
+Pages = {249,265}
+}
+
+ at article{arnold07,
+	Author = {Barry C. Arnold and Enrique Castillo and Jose Maria Sarabia},
+	Date-Added = {2009-04-21 13:08:07 +1200},
+	Date-Modified = {2009-04-21 13:11:32 +1200},
+	Journal = {Journal of Statistical Planning and Inference},
+	Pages = {3249-3260},
+	Read = {Yes},
+	Title = {Variations on the classical multivariate normal theme},
+	Volume = {137},
+	Year = {2007},
+	Bdsk-File-1 = {YnBsaXN0MDDUAQIDBAUGBwpZJGFyY2hpdmVyWCR2ZXJzaW9uVCR0b3BYJG9iamVjdHNfEA9OU0tleWVkQXJjaGl2ZXISAAGGoNEICVRyb290gAGoCwwXGBkaHiVVJG51bGzTDQ4PEBMWWk5TLm9iamVjdHNXTlMua2V5c1YkY2xhc3OiERKABIAFohQVgAKAA4AHXHJlbGF0aXZlUGF0aFlhbGlhc0RhdGFfECcuLi8uLi9teV9saWJyYXJ5L2NvbmRpdGlvbmFsX25vcm1hbC5wZGbSGw8cHVdOUy5kYXRhTxEBmgAAAAABmgACAAAKSGFyZCBEcml2ZQAAAAAAAAAAAAAAAAAAAAAAwttWiEgrAAAALPmGFmNvbmRpdGlvbmFsX25vcm1hbC5wZGYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4bJbF7sAUUERGIAAA [...]
+
+
+ at article{boussau06,
+  title={Efficient likelihood computations with nonreversible models of evolution},
+  author={Boussau, Bastien and Gouy, Manolo},
+  journal={Systematic biology},
+  volume={55},
+  number={5},
+  pages={756--768},
+  year={2006},
+  publisher={Oxford University Press}
+}
+
+ at article{boussau08,
+	Abstract = {Fossils of organisms dating from the origin and diversification of cellular life are scant and difficult to interpret, for this reason alternative means to investigate the ecology of the last universal common ancestor (LUCA) and of the ancestors of the three domains of life are of great scientific value. It was recently recognized that the effects of temperature on ancestral organisms left 'genetic footprints' that could be uncovered in extant genomes. Accordingly, analyses  [...]
+	Address = {Laboratoire de Biometrie et Biologie Evolutive, CNRS, Universite de Lyon, Universite Lyon I, 43 Boulevard du 11 Novembre, 69622 Villeurbanne, France.},
+	Au = {Boussau, B and Blanquart, S and Necsulea, A and Lartillot, N and Gouy, M},
+	Author = {Boussau, Bastien and Blanquart, Samuel and Necsulea, Anamaria and Lartillot, Nicolas and Gouy, Manolo},
+	Crdt = {2008/11/28 09:00},
+	Da = {20081218},
+	Date-Added = {2009-01-30 16:18:39 +1300},
+	Date-Modified = {2009-01-30 16:18:57 +1300},
+	Dcom = {20090113},
+	Dep = {20081126},
+	Doi = {10.1038/nature07393},
+	Edat = {2008/11/28 09:00},
+	Issn = {1476-4687 (Electronic)},
+	Jid = {0410462},
+	Journal = {Nature},
+	Jt = {Nature},
+	Language = {eng},
+	Mh = {Adaptation, Physiological/genetics/*physiology; Archaea/genetics/*physiology; Evolution, Molecular; Genes, rRNA/genetics; *Hot Temperature; Phylogeny},
+	Mhda = {2009/01/14 09:00},
+	Number = {7224},
+	Own = {NLM},
+	Pages = {942--945},
+	Phst = {2008/03/05 {$[$}received{$]$}; 2008/09/01 {$[$}accepted{$]$}; 2008/11/26 {$[$}aheadofprint{$]$}},
+	Pii = {nature07393},
+	Pl = {England},
+	Pmid = {19037246},
+	Pst = {ppublish},
+	Pt = {Journal Article; Research Support, Non-U.S. Gov't},
+	Sb = {IM},
+	So = {Nature. 2008 Dec 18;456(7224):942-5. Epub 2008 Nov 26. },
+	Stat = {MEDLINE},
+	Title = {Parallel adaptations to high temperatures in the Archaean eon.},
+	Volume = {456},
+	Year = {2008 Dec 18},
+	Bdsk-Url-1 = {http://dx.doi.org/10.1038/nature07393}}
+
+ at article{dereeper08,
+	Abstract = {Phylogenetic analyses are central to many research areas in biology and typically involve the identification of homologous sequences, their multiple alignment, the phylogenetic reconstruction and the graphical representation of the inferred tree. The Phylogeny.fr platform transparently chains programs to automatically perform these tasks. It is primarily designed for biologists with no experience in phylogeny, but can also meet the needs of specialists; the first ones will f [...]
+	Author = {Dereeper A, Guignon V, Blanc G, Audic S, Buffet S, Chevenet F, Dufayard JF, Guindon S, Lefort V, Lescot M, Claverie JM, Gascuel O.},
+	Date-Added = {2009-01-19 17:02:10 +1300},
+	Date-Modified = {2009-01-19 17:03:31 +1300},
+	Journal = { Nucleic Acids Res.},
+	Title = {Phylogeny.fr: robust phylogenetic analysis for the non-specialist.},
+	Volume = {36},
+	Year = {2008}}
+
+ at article{lartillot06,
+	Author = {Nicolas Lartillot},
+	Date-Added = {2008-12-18 09:36:03 +1300},
+	Date-Modified = {2008-12-18 09:39:29 +1300},
+	Journal = {Journal of Computational Biology},
+	Pages = {1701-1722},
+	Rating = {5},
+	Title = {Conjugate Gibbs Sampling for Bayesian Phylogenetic Models },
+	Volume = {13},
+	Year = {2006},
+	Bdsk-File-1 = {YnBsaXN0MDDUAQIDBAUGBwpZJGFyY2hpdmVyWCR2ZXJzaW9uVCR0b3BYJG9iamVjdHNfEA9OU0tleWVkQXJjaGl2ZXISAAGGoNEICVRyb290gAGoCwwXGBkaHiVVJG51bGzTDQ4PEBMWWk5TLm9iamVjdHNXTlMua2V5c1YkY2xhc3OiERKABIAFohQVgAKAA4AHXHJlbGF0aXZlUGF0aFlhbGlhc0RhdGFfEC4uLi8uLi9teV9saWJyYXJ5L2xhcnRpbGxvdF9jb25qdWdhdGVfZ2liYnMucGRm0hsPHB1XTlMuZGF0YU8RAbYAAAAAAbYAAgAACkhhcmQgRHJpdmUAAAAAAAAAAAAAAAAAAAAAAMLbVohIKwAAACz5hh1sYXJ0aWxsb3RfY29uanVnYXRlX2dpYmJzLnBkZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALPmOxMsH [...]
+
+ at book{aarts97,
+	Address = {Chichester},
+	Author = {E. Aarts and J. K. Lenstra},
+	Publisher = {Wiley},
+	Title = {Local search in combinatorial optimization},
+	Year = 1997}
+
+ at article{abascal05,
+	Author = {F. Abascal and R. Zardoya and D. Posada},
+	Journal = {Bioinformatics},
+	Pages = {2104-2105},
+	Title = {ProtTest: selection of best-fit models of protein evolution},
+	Volume = 21,
+	Year = {2005}}
+
+ at phdthesis{adachi95,
+	Author = {J. Adachi},
+	School = {The Graduate University for Advanced Studies},
+	Title = {Modeling of Molecular Evolution and Maximum Likelihood Inference of Molecular Phylogeny},
+	Year = 1995}
+
+ at article{akaike74,
+	Author = {H. Akaike},
+	Journal = {IEEE Transactions on Automatic Control},
+	Pages = {716-723},
+	Title = {A new look at the statistical model identification},
+	Volume = 19,
+	Year = {1974}}
+
+ at article{amrine03,
+	Author = {H. Amrine-Madsen and K Koepfli and R. Wayne and M. Springer},
+	Journal = {Molecular Phylogenetics and Evolution},
+	Pages = {225-240},
+	Title = {A new phylogenetic marker, apolipoprotein {B}, provides compelling evidence for eutherian relationships},
+	Volume = 28,
+	Year = {2003}}
+
+ at article{ane05,
+	Author = {C. An\'e and J. Burleigh and M. McMahon and M. Sanderson},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {914-924},
+	Title = {Covarion structure in plastid genome evolution: a new statistical test},
+	Volume = 22,
+	Year = {2005}}
+
+ at article{anisimova01,
+	Author = {M. Anisimova and J. Bielawski and Z. Yang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1585-1592},
+	Title = {The accuracy and power of likelihood ratio tests to detect positive selection at amino acid sites},
+	Volume = 18,
+	Year = {2001}}
+
+ at article{anisimova02,
+	Author = {M. Anisimova and J. Bielawski and Z. Yang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {950-958},
+	Title = {Accuracy and power of Bayes prediction of amino acid under positive selection},
+	Volume = 19,
+	Year = {2002}}
+
+ at article{anisimova03,
+	Author = {M. Anisimova and R. Nielsen and Z. Yang},
+	Journal = {Genetics},
+	Pages = {1229-1236},
+	Title = {Effect of recombination on the accuracy of the likelihood method for detecting positive selection at amino acid sites.},
+	Volume = 164,
+	Year = {2003}}
+
+ at article{anisimova06,
+	Author = {M. Anisimova and O. Gascuel},
+	Journal = {Syst. Biol.},
+	Pages = {539-552},
+	Title = {Approximate likelihood-ratio test for branches: a fast, accurate, and powerful alternative},
+	Volume = 55,
+	Year = {2006}}
+
+ at article{anisimova07,
+  title={Multiple hypothesis testing to detect lineages under positive selection that affects only a few sites},
+  author={Anisimova, Maria and Yang, Ziheng},
+  journal={Molecular Biology and Evolution},
+  volume={24},
+  number={5},
+  pages={1219--1228},
+  year={2007},
+  publisher={SMBE}
+}
+
+ at article{anisimova11,
+  title={Survey of branch support methods demonstrates accuracy, power, and robustness of fast likelihood-based approximation schemes},
+  author={Anisimova, M. and Gil, M. and Dufayard, J.F. and Dessimoz, C. and Gascuel, O.},
+  journal={Systematic biology},
+  volume={60},
+  number={5},
+  pages={685--699},
+  year={2011},
+  publisher={Oxford University Press}
+}
+
+
+
+ at article{atv,
+	Author = {C. Zmasek and S. Eddy},
+	Journal = {Bioinformatics},
+	Pages = {383-384},
+	Title = {{ATV}: display and manipulation of annotated phylogenetic trees},
+	Volume = 17,
+	Year = 2001}
+
+
+
+ at book{intro-algo,
+	Author = {T. H. Cormen and C. E. Leiserson and R. L. Rivest},
+	Chapter = { 17 greedy algorithms},
+	Pages = {329-356},
+	Publisher = {The massachuset Institute of Technology Press},
+	Title = {Introduction to algorithms},
+	Year = 1992}
+
+ at article{seqgen,
+	Author = {A. Rambaut and N.C. Grassly},
+	Journal = {Computer Applications in the Biosciences (CABIOS)},
+	Pages = {235-238},
+	Title = {{S}eq-{G}en: an application for the {M}onte {C}arlo simulation of {DNA} sequence evolution along phylogenetic trees.},
+	Volume = 13,
+	Year = 1997}
+
+ at article{bailey02,
+	Author = {J. Bailey and Z. Gu and R. Clark and K. Reinert and R. Samonte and S. Schwartz and M. Adams and E. Myers and P. Li and E. Eicher},
+	Journal = {Science},
+	Pages = {1003-1007},
+	Title = {Recent segmental duplications in the human genome},
+	Volume = 297,
+	Year = 2002}
+
+ at article{baele06,
+	Author = {G. Baele and J. Raes and Y. Van de Peer and S. Vansteelandt},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1397-1405},
+	Title = {An improved statistical method for detecting heterotachy in nucleotide sequences},
+	Volume = 23,
+	Year = 2006}
+
+ at article{berry,
+	Author = {V. Berry and O. Gascuel},
+	Journal = {Theoretical Computer Science ({\`a} paraitre)},
+	Title = {Inferring evolutionary trees with strong combinatorial confidence.},
+	Year = 2000}
+
+ at article{kumar02,
+	Author = {S. Kumar and S. Subramanian},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {803-808},
+	Title = {Mutation rates in mammalian genomes},
+	Volume = {99},
+	Year = {2002}}
+
+ at article{kumar96,
+	Author = {Sudhir Kumar},
+	Journal = {Molecular Biology and Evolution},
+	Title = {A Stepwise Algorithm for Finding Minimum Evolution Trees},
+	Year = 1996}
+
+ at article{nei97,
+	Author = {Masatoshi Nei, Sudhir Kumar, and Kei Takahashi},
+	Journal = {special series of inaugural articles by members of the national academy of science},
+	Pages = {584-593},
+	Title = {The optimization principle in phylogenetic analysis tends to give incorrect topologies when the number of nucleotides or amino acids is small},
+	Volume = 13,
+	Year = 1997}
+
+ at article{nei98,
+	Author = {M. Nei and S. Kumar and K. Takahashi},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {12390-12397},
+	Title = {The optimization principle in phylogenetic analysis tends to give incorrect topologies when the number of nucleotides or amino acids used is small},
+	Volume = 95,
+	Year = 1998}
+
+ at inproceedings{abf96,
+	Author = {R. Agarwala and V. Bafna and M. Farach and B. Narayanan                   and M. Paterson and M. Thorup},
+	Booktitle = {Proceedings of the 7th Annual ACM-SIAM                    Symposium on Discrete Algorithms},
+	Title = {On the approximability of numerical taxonomy:                   Fitting distances by tree metrics},
+	Year = 1996}
+
+ at article{adell94,
+	Author = {J. Adell and J. Dopazo},
+	Journal = {J. Mol. Evol},
+	Pages = {305-309},
+	Title = {{M}onte {C}arlo Simulation in phylogenies : An     application to Test the Constancy of Evolutionary Rates},
+	Volume = 38,
+	Year = 1994}
+
+ at incollection{adachi96,
+	Address = {Tokyo},
+	Author = {J. Adachi and M. Hasegawa},
+	Booktitle = {Computer Science Monographs},
+	Editor = {M. Ishiguro and G. Kitagawa and Y. Ogata and H. Takagi and Y. Tamura and T. Tsuchiya},
+	Number = {28},
+	Publisher = {The Institute of Statistical Mathematics},
+	Title = {{MOLPHY} Version 2.3. Programs for molecular phylogenetics based on maximum likelihood},
+	Year = 1996}
+
+ at article{adachi00,
+	Author = {J. Adachi and Waddell P. and W. Martin and M. Hasegawa},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {348-358},
+	Title = {Plastid genome phylogeny and a model of amino acid substitution for proteins encoded by chloroplast {DNA}},
+	Volume = 50,
+	Year = 2000}
+
+ at article{almagor83,
+	Author = {Hagai Almagor},
+	Journal = {Journal of theorical biology},
+	Note = {{I}nfluence du {V}oisinage sur l'{E}volution d'une     {S{\'e}}quence d'{ADN}},
+	Pages = {633-645},
+	Title = { A Markov analysis of {DNA} sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 104,
+	Year = 1983}
+
+ at book{alon92,
+	Address = {Chichester},
+	Author = {N. Alon and J.H. Spencer},
+	Publisher = {Wiley},
+	Title = {The Probabilistic Method},
+	Year = 1992}
+
+ at dea{andrieu92,
+	Address = {Montpellier},
+	Author = {Guillaume Andrieu},
+	School = {{E}cole {N}ationale {S}up{\'e}rieure {A}gronomique de {M}ontpellier},
+	Title = {{M}od{\`e}les {P}robabilistes de {C}onstruction des {A}rbres  {P}hylog{\'e}n{\'e}tique},
+	Utilisateur = {Gilles Caraux},
+	Year = 1992}
+
+ at phdthesis{andrieu97,
+	Author = {G. Andrieu},
+	Month = {d{\'e}cembre},
+	School = {Univ. Montpellier II},
+	Title = {Estimation par intervalle d'une distance {\'e}volutive},
+	Year = 1997}
+
+ at article{arisbrosou02,
+	Author = {S. Aris-Brosou and Z. Yang},
+	Journal = {Systematic Biology},
+	Pages = {703-714},
+	Title = {Effects of models of rate evolution on estimation of divergence dates with special reference to the metazoan {18S} ribosomal {RNA} phylogeny},
+	Volume = 51,
+	Year = 2002}
+
+ at book{atlan,
+	Address = {Petaouchnok},
+	Author = {Henri Atlan},
+	Publisher = {Herman},
+	Title = {L'organisation Biologique et la th{\'e}orie de l'information},
+	Year = 1992}
+
+ at misc{atteson96,
+	Author = {K. Atteson},
+	Howpublished = {DIMACS},
+	Month = {november},
+	Title = {Workshop on Mathematical Hierarchies and Biology},
+	Year = 1996}
+
+ at incollection{atteson97,
+	Author = {K. Atteson},
+	Booktitle = {Mathematical Hierarchies and Biology},
+	Editor = {B. Mirkin and F.R. McMorris and F.S. Roberts and A. Rhzetsky},
+	Pages = {133-148},
+	Publisher = {American Mathematical Society},
+	Title = {The performance of the {NJ} method of phylogeny reconstruction},
+	Year = 1997}
+
+ at article{bailly03,
+	Author = { X. Bailly and R. Leroy and S. Carney and O. Collin and F. Zal and A. Toulmond and D. Jollivet},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {5885-5890},
+	Title = {The loss of the hemoglobin \hbox{H$_2$S}-binding function in annelids from sulfide-free habitats reveals molecular adaptation driven by {D}arwinian positive selection},
+	Volume = 1000,
+	Year = 2003}
+
+ at article{bd86,
+	Author = {H-J. Bandelt and A. Dress},
+	Journal = {Advances in Applied Mathematics},
+	Pages = {309-343},
+	Title = {Reconstructing the Shape of a Tree from Observed     Dissimilarity Data},
+	Utilisateur = {Vincent},
+	Volume = 7,
+	Year = 1986}
+
+ at misc{bandelt90,
+	Author = {H.-J. Bandelt and A. von Haeseler and A. Bolick and                   H. Sch{\"u}tte},
+	Howpublished = {preprint},
+	Title = {A comparative study of sequence dissimilarities and                    evolutionnary distances derived from sets of aligned                    RNA sequences},
+	Year = 1990}
+
+ at article{bandelt92,
+	Author = {H.-J. Bandelt and A. Dress},
+	Journal = {Advances Math},
+	Pages = {47-105},
+	Title = {A canonical decomposition theory for metrics on a finite set},
+	Volume = 92,
+	Year = 1992}
+
+ at article{bandelt92b,
+	Author = {H.-J. Bandelt and A. Dress},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {242-252},
+	Title = {Split Decomposition: A New and Useful Approach to Phylogenetic Analysis of Distance Data},
+	Volume = 1,
+	Year = 1992}
+
+ at article{barry87,
+	Author = {Daniel Barry and J. A. Hartigan},
+	Journal = {Biometrics},
+	Pages = {261-276},
+	Title = {Asynchronous Distance Between Homologous {DNA} Sequences},
+	Volume = 43,
+	Year = 1987}
+
+ at article{barry872,
+	Author = {Daniel Barry and J. A. Hartigan},
+	Journal = {Statistical Science},
+	Pages = {191-210},
+	Title = {Statistical Analysis of Homimoid Molecular Evolution},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 2,
+	Year = 1987}
+
+ at inproceedings{barthelemy84,
+	Address = {La Grande-Motte},
+	Author = {J.-P. Barth{\'e}lemy and N.X. Luong},
+	Booktitle = {Colloque ASSU.},
+	Title = {Repr{\'e}sentations arbor{\'e}es de mesures de dissimilarit{\'e}},
+	Year = 1984}
+
+ at book{barthelemy88,
+	Author = {J.-P. Barth{\'e}lemy and Alain Gu{\'e}noche},
+	Publisher = {Masson},
+	Series = {{M}{\'e}thodes + {P}rogrammes},
+	Title = {Les arbres et les repr{\'e}sentations des proximit{\'e}s},
+	Year = 1988}
+
+ at article{barth88,
+	Author = {J. P. Barth{\'e}lemy},
+	Journal = {Journal of Classification},
+	Pages = {229-236},
+	Title = {Thresholded consensus for n-trees},
+	Utilisateur = {Gilles Caraux and Olivier Gascuel},
+	Volume = 5,
+	Year = 1988}
+
+ at article{bazykin04,
+	Author = {G. Bazykin and F. Kondrashov and A. Ogurtsov and S. Sunyaev and A. Kondrashov},
+	Journal = {Nature},
+	Pages = {558-562},
+	Title = {Positive selection at sites of multiple amino acid replacements since rat-mouse divergence.},
+	Volume = 3,
+	Year = 2004}
+
+ at book{barthelemy91,
+	Author = {J.P. Barth{\'e}lemy and A. Gu{\'e}noche},
+	Editor = {Chichester},
+	Publisher = {Wiley},
+	Title = {Trees and proximities representations},
+	Year = 1991}
+
+ at article{benjamini95,
+	Author = {Y. Benjamini and Y. Hochberg},
+	Journal = {Journal of the Royal Statistics Society: Series B (Statistical Methodology)},
+	Pages = {289-300},
+	Title = {Controlling the false discovery rate -- a practical and powerful approach to multiple testing},
+	Volume = {57},
+	Year = {1995}}
+
+ at article{benjamini00,
+	Author = {Y. Benjamini and Y. Hochberg},
+	Journal = {Journal of Educational and Behavioral Statistics},
+	Pages = {60-83},
+	Title = {The adaptive control of the false discovery rate in multiple hypothesis testing with independent statistics},
+	Volume = {25},
+	Year = {2000}}
+
+ at article{benjamini01,
+	Author = {Y. Benjamini and D. Yekutieli},
+	Journal = {Annals of Statistics},
+	Pages = {1165-1188},
+	Title = {The control of the false discovery rate in multiple testing under dependency},
+	Volume = {29},
+	Year = {2001}}
+
+ at inbook{benzecri,
+	Address = {Paris},
+	Author = {J. P. Benzecri},
+	Chapter = {TIB No 3},
+	Pages = {119-152},
+	Publisher = {Dunod},
+	Series = {L'analyse des donn{\'e}es},
+	Title = {Description math{\'e}matique des classifications},
+	Utilisateur = {Gilles Caraux},
+	Volume = {I~: La Taxinomie},
+	Year = 1973}
+
+ at article{benzer61,
+	Author = {S. Benzer},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {403-415},
+	Title = {On the topography of genetic fine structure},
+	Volume = 47,
+	Year = 1961}
+
+ at phdthesis{berrythese,
+	Author = {V. Berry},
+	Month = {d{\'e}cembre},
+	School = {Univ. Montpellier II},
+	Title = {M{\'e}thodes et algorithmes pour reconstruire les arbres de l'{\'e}volution},
+	Year = 1997}
+
+ at book{berge70,
+	Author = {C. Berge},
+	Publisher = {Dunod},
+	Title = {Graphes et hypergraphes},
+	Year = 1970}
+
+ at article{bertrand04,
+	Author = {D. Bertrand and O. Gascuel},
+	Journal = {WABI},
+	Title = {Topological rearrangements and local search method for tandem duplication trees},
+	Year = 2004}
+
+ at article{bertrand05,
+	Author = {D. Bertrand and O. Gascuel},
+	Journal = {{IEEE} Transactions on computational biology and bioinformatics},
+	Title = {Topological rearrangements and local search method for tandem duplication trees},
+	Volume = {In press},
+	Year = 2005}
+
+ at article{bg96_boot,
+	Author = {V. Berry and O. Gascuel},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {999-1011},
+	Title = {On the interpretation of Bootstrap trees:                   appropriate threshold of clade selection and induced                   gain},
+	Volume = 13,
+	Year = 1996}
+
+ at techreport{bg96_quad,
+	Author = {V. Berry and O. Gascuel},
+	Institution = {LIRMM},
+	Month = {july},
+	Number = {96-044},
+	Title = {A quartet-based heuristics for phylogeny reconstruction},
+	Year = 1996}
+
+ at inbook{bhattacharya,
+	Address = {New York},
+	Author = {Rabi N. Bhattacharya and Edwards C. Waymire},
+	Chapter = { No IV Continuous-Parameter {M}arkov chains},
+	Pages = {261-366},
+	Publisher = {Wiley},
+	Title = {Stochastic processes with applications},
+	Utilisateur = {Guillaume Andrieu},
+	Year = 1990}
+
+ at article{bielawski01,
+	Author = {J. Bielawski and Z. Yang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {523-529},
+	Title = {Positive and negative selection in the {\uppercase{\it{DAZ}}} gene family},
+	Volume = {18},
+	Year = 2001}
+
+ at article{bielawski03,
+	Author = {J. Bielawski and Z. Yang},
+	Journal = {Journal of Structural and Functional Genomics},
+	Pages = {201-212},
+	Title = {Maximum likelihood methods for detecting adaptive evolution after gene duplication},
+	Volume = {3},
+	Year = 2003}
+
+ at article{bielawski04,
+	Author = {J. Bielawski and Z. Yang},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {121-132},
+	Title = {A maximum likelihood method for detecting functional divergence at individual codon sites, with application to gene family evolution},
+	Volume = {59},
+	Year = 2004}
+
+ at article{bishop85,
+	Author = {M. J. Bishop and A. E. Friday},
+	Journal = {Proceeding of the Royal Society of London},
+	Pages = {271-302},
+	Title = {{E}volutionary trees from nucleic acid and protein sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = {B 226},
+	Year = 1985}
+
+ at article{blaisdell85,
+	Author = {B. Edwin Blaisdell},
+	Journal = {Journal of Molecular Evolution},
+	Note = {{I}nfluence du {V}oisinage sur l'{E}volution d'une     {S{\'e}}quence d'{ADN}},
+	Pages = {278-288},
+	Title = {Markov chain analysis find a significant influence of neighboring bases on the occurence of a base in eucaryotic nuclear {DNA} sequences both  protein-coding and noncoding},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 21,
+	Year = 1985}
+
+ at article{blaisdell91,
+	Author = {Edwin Blaisdell},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {521-528},
+	Title = {average values of a dissimilarity measure not requiring sequence alignment are twice the average of conventional mismatch counts requiring sequence alignment for a variety of computer-Generated model systems},
+	Utilisateur = {G. Andrieu},
+	Volume = 32,
+	Year = 1991}
+
+ at article{blake92,
+	Author = {R.D. Blake and Samuel T. Hess and Janice Nicholson-Tuell},
+	Journal = {Journal of Molecular Evolution},
+	Note = {{I}nfluence du {V}oisinage sur l'{E}volution d'une     {S{\'e}}quence d'{ADN}},
+	Pages = {189-200},
+	Title = {The Influence of Nearest Neighbors on the Rate and Pattern of Spontaneous Point Mutations},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 34,
+	Year = 1992}
+
+ at article{blanken82,
+	Author = {Roger L. Blanken and Lynn C. Klotz and Alan G. Hinnebusch},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {9-19},
+	Title = {Computer comparison of new and existing criteria for constructing evolutionary trees from sequence data},
+	Utilisateur = {Gilles Caraux},
+	Volume = 19,
+	Year = 1982}
+
+ at article{blast,
+	Author = {S. Altschul and W. Gish and W. Miller and  E. Myers and D. Lipman},
+	Journal = {Journal of Molecular Biology},
+	Pages = {403-410},
+	Title = {Basic local alignment search tool},
+	Volume = {215},
+	Year = {1990}}
+
+ at article{bledsoe90,
+	Author = {Anthony H. Bledsoe and Robert J. Raikow },
+	Journal = {Journal of Molecular Evolution},
+	Pages = {247-259},
+	Title = {A quantitative assessment of congruence  between molecular and nonmolecular estimates of phylogeny},
+	Utilisateur = {G. Andrieu},
+	Volume = 30,
+	Year = 1990}
+
+ at article{brauer02,
+	Author = { M.J. Brauer and M.T. Holder and L.A. Dries and D.J. Zwickl and P.O. Lewis and D.M. Hillis},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1717-1726},
+	Title = {Genetic algorithms and parallel processing in maximum-likelihood phylogeny inference},
+	Volume = 19,
+	Year = 2002}
+
+ at book{breiman84,
+	Author = {L. Breiman and J.H. Friedman and A. Olshen and Stone C.J.},
+	Editor = {Belmont},
+	Publisher = {Wadsworth},
+	Title = {Classification and regression trees},
+	Year = 1984}
+
+ at article{bremer88,
+	Author = {K. Bremer},
+	Journal = {Evolution},
+	Note = {Donne une bonne facon de tester la robustesse d'un     arbre infere par une meth de parcimonie : faire un     arbre de consensus strict pr les arbres de valeur     opt, puis un avec aussi ceux de val opt+1,... et     noter a quelle etape disparait chq noeud},
+	Pages = {795-803},
+	Title = {The limits of amino acid sequence data in angiosperm     phylogenetic reconstruction},
+	Utilisateur = {Vincent},
+	Volume = 42,
+	Year = 1988}
+
+ at book{brent73,
+	Author = {R. Brent},
+	Chapter = {5},
+	Publisher = {Prentice-Hall},
+	Title = {Algorithms for minimization without derivatives},
+	Year = 1973}
+
+ at article{brossier85,
+	Author = {Gildas Brossier},
+	Journal = {Math. Sci. hum.},
+	Pages = {5-21},
+	Title = {Approximation des dissimilarit{\'e}s par des arbres additifs},
+	Utilisateur = {Gilles Caraux},
+	Volume = 91,
+	Year = 1985}
+
+ at article{brown99,
+	Author = {K. S. Brown},
+	Journal = {Science},
+	Pages = {990-991},
+	Title = {Deep Green Rewrites Evolutionary History of Plants},
+	Volume = 285,
+	Year = 1999}
+
+ at article{bruno00,
+	Author = {W. Bruno and N. Socci and A. Halpern},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {189-197},
+	Title = {Weighted neighbor joining: a likelihood-based approach to distance-based phylogeny reconstruction},
+	Volume = 17,
+	Year = 2000}
+
+ at incollection{bryant05,
+	Address = {Oxford},
+	Author = {D. Bryant and N. Galtier and M.-A. Poursat},
+	Booktitle = {Mathematics of Evolution \& Phylogenetics},
+	Editor = {O. Gascuel},
+	Pages = {33-62},
+	Publisher = {Oxford University Press},
+	Title = {Likelihood Calculations in Phylogenetics},
+	Year = 2005}
+
+ at article{weighbor,
+	Author = {W. Bruno and N. D. Socci and A. L. Halpern},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {189-197},
+	Title = {Weighted Neighbor Joining: A Likelihood-based Approach to Distance-Based Phylogeny Reconstruction},
+	Volume = 17,
+	Year = 2000}
+
+ at article{buckley01,
+	Author = {Thomas R. Buckley and Chris Simon and Geoffrey K. Chambers},
+	Journal = {Systematic Biology},
+	Pages = {67-86},
+	Title = {Exploring Among-Site Rate Variation Models in a Maximum Likelihood Framework Using Empirical Data: Effects of Model Assumptions on Estimates of Topology, Branch Lengths, and Bootstrap Support},
+	Volume = 50,
+	Year = 2001}
+
+ at article{buckley01b,
+	Author = {Thomas R. Buckley and Chris Simon and Hidetoshi Shimodaira and Geoffrey K. Chambers},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {223-234},
+	Title = {Evaluating Hypotheses on the Origin and Evolution of the New Zealand Alpine Cicadas (Maoricicada) Using Multiple-Comparison Tests of Tree Topology},
+	Volume = 18,
+	Year = 2001}
+
+ at article{bulmer91,
+	Author = {Michael Bulmer},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {868-883},
+	Title = {Use of the method of generalized least squares in reconstructing phylogenies from sequence data},
+	Volume = 8,
+	Year = 1991}
+
+ at inbook{buneman71,
+	Author = {P. Buneman},
+	Chapter = {The recovery of trees from measures of dissimilarity},
+	Pages = {387-395},
+	Publisher = {Edhinburgh University Press},
+	Title = {Mathematics in Archeological and Historical Sciences},
+	Year = 1971}
+
+ at article{buneman74,
+	Author = {P. Buneman},
+	Journal = {J. of Comb. Theory},
+	Pages = {48-50},
+	Title = {A note on metric properties of trees},
+	Volume = 17,
+	Year = 1974}
+
+ at article{cao98,
+	Author = {Y. Cao and A. Janke and P. Waddell and M. Westerman and O. Takenaka and S. Murata and N. Okada and S. Paabo and M. Hasegawa},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {307-322},
+	Title = {Conflict among individual mitochondrial proteins in resolving the phylogeny of eutherian orders},
+	Volume = 47,
+	Year = 1998}
+
+ at article{carroll76,
+	Author = {J. Douglas Carroll},
+	Journal = {Psychometrika},
+	Pages = {439-463},
+	Title = {Spatial, non-spatial and hybrid models for scaling},
+	Utilisateur = {Gilles Caraux},
+	Volume = 41,
+	Year = 1976}
+
+ at article{cavalli67,
+	Author = {L. L. Cavalli-Sforza and A. W. F. Edwards},
+	Journal = {The American Journal of Human Genetics},
+	Pages = {233-257},
+	Title = {Phylogenetic analysis models and estimation procedures},
+	Volume = 19,
+	Year = 1967}
+
+ at article{cavender78,
+	Author = {J. A. Cavender},
+	Journal = {Mathematical Biosciences},
+	Pages = {271-280},
+	Title = {Taxonomy with Confidence},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 40,
+	Year = 1978}
+
+ at article{cavender81,
+	Author = {James A. Cavender},
+	Journal = {Mathematical Biosciences},
+	Pages = {217-229},
+	Title = {Tests of Phylogenetic Hypotheses under Generalized Models},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 54,
+	Year = 1981}
+
+ at article{chandon80,
+	Author = {Jean Louis Chandon and J. Lemaire and J. Pouget},
+	Journal = {R.A.I.R.O. Recherche op{\'e}rationnelle},
+	Pages = {157-170},
+	Title = {Construction de l'ultram{\'e}trique la plus proche d'une dissimilarit{\'e} au sens des moindres carr{\'e}s},
+	Utilisateur = {Gilles Caraux},
+	Volume = 14,
+	Year = 1980}
+
+ at article{chor00,
+	Author = {B. Chor and M. Hendy and B. Holland and D. Penny},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1529-1541},
+	Title = {Multiple maxima of likelihood in phylogenetic trees: an analytic approach},
+	Volume = 17,
+	Year = 2000}
+
+ at article{churchill92,
+	Author = {Gary A. Churchill and Arndt von Haesler and William C. Navidi},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {753-769},
+	Title = {Sample size for a phylogenetic inference },
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 9,
+	Year = 1992}
+
+ at article{clark92,
+	Author = {Andrew G. Clark and Thomas S. Whittam},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {744-752},
+	Title = { Sequencing errors and molecular evolutionary analysis},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 9,
+	Year = 1992}
+
+ at article{clark03,
+	Author = { A. Clark and S. Glanowski and R. Nielsen and P. Thomas and A. Kejariwal and M. Todd and D. Tanenbaum and D. Civello and F. Lu and B. Murphy and S. Ferriera and G. Wang and X. Zheng and T. White and J. Sninsky and M. Adams and M. Cargill},
+	Journal = {Science},
+	Pages = {1960-1963},
+	Title = {Inferring nonneutral evolution from human-chimp-mouse orthologous gene trios},
+	Volume = 302,
+	Year = 2003}
+
+ at inproceedings{cohen97,
+	Author = {J. Cohen and M. Farach},
+	Booktitle = {Proceedings of the 8th Annual ACM-SIAM                    Symposium On Discrete Algorithms},
+	Title = {Numerical Taxonomy on Data: Experimental Results},
+	Year = 1997}
+
+ at article{colless67,
+	Author = {Donald H. Colless},
+	Journal = {Systematic Zoology},
+	Pages = {289-295},
+	Title = {The phylogenetic fallacy},
+	Utilisateur = {Gilles Caraux},
+	Volume = 16,
+	Year = 1967}
+
+ at article{colonius81,
+	Author = {H. Colonius and H.H. Schulze},
+	Journal = {British Journal of Math. and Stat. Psychology},
+	Pages = {167-180},
+	Title = {Tree structures for proximity data},
+	Utilisateur = {Vincent},
+	Volume = 34,
+	Year = 1981}
+
+ at article{crandall99,
+	Author = {K. Crandall and C. Kelsey and H. Imamichi and H. Lane and N. Salzman},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {372-382},
+	Title = {Parallel evolution of drug resistance in {HIV} : failure of nonsynonymous/synonymous rate ratio to detect selection},
+	Volume = 16,
+	Year = 1999}
+
+ at article{curnow89,
+	Author = {R. N. Curnow and T. B. L. Kirkwood},
+	Journal = {J. of the Royal Statistical Society},
+	Pages = {199-220},
+	Title = {Statistical analysis of Desoxyribonucleic Acid Sequence Data-A review},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 152,
+	Year = 1989}
+
+ at incollection{czelusniak90,
+	Address = {New York},
+	Author = {John Czelusniak and Morris Goodman and Nancy D. Moncrieff and Suzanne M. Kehoe},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 37,
+	Editor = {Russsell F. Doolittle},
+	Note = {{P}resente les meths de branch-swapping sur un arbre},
+	Pages = {601-615},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Maximum Parsimony Approach to Construction of Evolutionary Trees from Aligned Homologous Sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at book{darwin,
+	Author = {C. Darwin},
+	Publisher = {John Murray},
+	Title = {On the origin of species},
+	Year = 1859}
+
+ at article{daubin03,
+	Author = {V. Daubin and G. Perri{\`e}re},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {471-483},
+	Title = {{G+C3} structuring along the genome : a common feature in prokaryotes},
+	Volume = 20,
+	Year = 2003}
+
+ at article{day85,
+	Author = {W.H. Day and F.R. McMorris},
+	Journal = {Bulletin of Math. Biol.},
+	Pages = {215-229},
+	Title = {A formalization of consensus index methods},
+	Volume = 47,
+	Year = 1985}
+
+ at incollection{day87,
+	Author = {W. H. E. Day},
+	Booktitle = {Bulletin of Mathematical Biology},
+	Pages = {461-467},
+	Title = {Computational Complexity of Inferring Phylogenies     from Dissimilarity Matrices},
+	Volume = 49,
+	Year = 1987}
+
+ at incollection{dayhoff78,
+	Address = {Washington, D. C.},
+	Author = {M. Dayhoff and R. Schwartz and B. Orcutt},
+	Booktitle = {Atlas of Protein Sequence and Structure},
+	Editor = {M. Dayhoff},
+	Pages = {345-352},
+	Publisher = {National Biomedical Research Foundation},
+	Title = {A model of evolutionary change in proteins},
+	Volume = 5,
+	Year = 1978}
+
+ at incollection{debry92,
+	Author = {R. W. DeBry},
+	Booktitle = {Molecular Biology and Evolution},
+	Pages = {537-551},
+	Title = {The Consistency of Several Phylogeny-Inference     Methods under Varying Evolutionary Rates},
+	Volume = 9,
+	Year = 1992}
+
+ at incollection{degens83,
+	Address = {Berlin Heidelberg},
+	Author = {Paul O. Degens},
+	Booktitle = {Numerical Taxonomy},
+	Editor = {Joseph Felsenstein},
+	Pages = {249-253},
+	Publisher = {Springer-Verlag},
+	Series = {NATO ASI},
+	Title = {Hierarchical cluster methods as maximum likelihood     estimators},
+	Utilisateur = {Gilles Caraux},
+	Volume = {G1},
+	Year = 1983}
+
+ at article{delsuc02,
+	Author = {F. Delsuc and M. Scally and O. Madsen and M. Stanhope and W. de Jong and F. Catzeflis and M. Springer and E. Douzery},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1656-1671},
+	Title = {Molecular phylogeny of living xenarthrans and the impact of character and taxon sampling on the placental tree rooting},
+	Volume = {19},
+	Year = {2002}}
+
+ at article{delsuc05,
+	Author = {F. Delsuc and H. Brinkmann and H. Philippe},
+	Journal = {Nature Review Genetics},
+	Pages = {361-375},
+	Title = {Phylogenomics and the reconstruction of the tree of life},
+	Volume = {6},
+	Year = {2005}}
+
+ at article{dempster77,
+	Author = {A. P. Dempster and N. M. Laird and D. B. Rubin},
+	Journal = {J. R. Statist. Soc. B},
+	Pages = {1-22},
+	Title = {Maximum Likelihood from incomplete data via the \hbox{\it EM} algorithm},
+	Utilisateur = {Gilles Caraux et Guillaume Andrieu},
+	Volume = 39,
+	Year = 1977}
+
+ at article{denis02,
+	Author = {F. Denis and O. Gascuel},
+	Journal = {Discrete Applied Mathematics},
+	Title = {On the consistency of the minimum evolution principle of phylogenetic inference},
+	Year = 2002}
+
+ at article{derchia96,
+	Author = {A.M. D'Erchia and C. Gissi and G. Pesole and C. Saccone and U. Arnason},
+	Journal = {Nature},
+	Pages = {597-600},
+	Title = {The guinea-pig is not a rodent},
+	Volume = 381,
+	Year = 1996}
+
+ at article{desoete83,
+	Author = {Geert de Soete},
+	Commentaire = {Ceci est mon commentaire},
+	Journal = {Psychometrika},
+	Pages = {621-626},
+	Title = {A least squares algorithm for fitting additive trees to proximity data},
+	Utilisateur = {Gilles Caraux},
+	Volume = 48,
+	Year = 1983}
+
+ at article{desper02,
+	Author = {R. Desper and O. Gascuel},
+	Journal = {Journal of Computational Biology},
+	Pages = {687-705},
+	Title = {Fast and accurate phylogeny reconstruction algorithms based on the minimum-evolution principle},
+	Volume = 9,
+	Year = 2002}
+
+ at article{dickerson71,
+	Author = {Richard Dickerson},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {26-45},
+	Title = {The structure of cytochrome $c$ and the rates of molecular evolution},
+	Utilisateur = {Gilles Caraux},
+	Volume = 1,
+	Year = 1971}
+
+ at article{dimmic02,
+	Author = {M. Dimmic and J. Rest and D. Mindell and D. Goldstein},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {65-73},
+	Title = {{rtREV}: an amino acid substitution matrix for inference of retrovirus and     reverse transcriptase phylogeny},
+	Volume = 55,
+	Year = 2002}
+
+ at incollection{dobson75,
+	Address = {Berlin},
+	Author = {Annette J. Dobson},
+	Booktitle = {Combinatorial Mathematics III},
+	Editor = {A. Dold and B. Eckmann},
+	Pages = {95-100},
+	Publisher = {Springer},
+	Series = {Lecture Notes in Mathematics},
+	Title = {Comparing the shapes of trees},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 452,
+	Year = 1975}
+
+ at incollection{doolittle90,
+	Author = {Russel F. Doolittle and Da-Fei Feng},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 41,
+	Editor = {Russsell F. Doolittle},
+	Pages = {659-669},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Nearset Neighbor Procedure for relating Progressively Amino Acid Sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{dopazo94,
+	Author = {Joaquin Dopazo},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {300-304},
+	Title = {Estimating Errors and Confidence Intervals for     Branch Lengths in Phylogenetic Trees by a Bootstrap Approach},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 38,
+	Year = 1994}
+
+ at article{douady03,
+	Author = {C. J. Douady and F. Delsuc and Y. Boucher and W. F. Doolittle and E. J. P. Douzery },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {248-254},
+	Title = {Comparison of Bayesian and Maximum Likelihood Bootstrap Measures of Phylogenetic Reliability},
+	Volume = 20,
+	Year = 2003}
+
+ at article{douzery03,
+	Author = {E. Douzery and F. Delsuc and M. Stanhope and D. Huchon},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {S201-13},
+	Title = {Local molecular clocks in three nuclear genes: divergence times for rodents and other mammals and incompatibility among fossil calibrations},
+	Volume = {57 Suppl 1},
+	Year = 2003}
+
+
+ at Article{douzery04,
+   Author="Douzery, E. J.  and Snell, E. A.  and Bapteste, E.  and Delsuc, F.  and Philippe, H. ",
+   Title="{{T}he timing of eukaryotic evolution: does a relaxed molecular clock reconcile proteins and fossils?}",
+   Journal="Proc. Natl. Acad. Sci. U.S.A.",
+   Year="2004",
+   Volume="101",
+   Pages="15386--15391",
+   Month="Oct"
+}
+
+ at article{dress86,
+	Author = {A. Dress and A. von Haeseler and M. Krueger},
+	Journal = {Studien zur Klassifikation},
+	Pages = {299-305},
+	Title = {Reconstructing phylogenetic trees using variants of     the "four-point condition"},
+	Year = 1986}
+
+ at article{drummond03,
+	Author = {A. Drummond and O. Pybus and A. Rambaut and R. Forsberg and A. Rodrigo},
+	Journal = {Trends in Ecology and Evolution},
+	Pages = {481-488},
+	Title = {Measurably evolving populations},
+	Volume = 18,
+	Year = 2003}
+
+ at article{drummond06,
+	Author = {A. Drummond and S. Ho and M. Phillips and A. Rambaut},
+	Journal = {PLoS Biology},
+	Pages = {e88},
+	Title = {Relaxed phylogenetics and dating with confidence},
+	Volume = 4,
+	Year = 2006}
+
+ at Article{drummond07,
+   Author="Drummond, A. J.  and Rambaut, A. ",
+   Title="{{B}{E}{A}{S}{T}: {B}ayesian evolutionary analysis by sampling trees}",
+   Journal="BMC Evol. Biol.",
+   Year="2007",
+   Volume="7",
+   Pages="214"
+}
+
+
+
+ at article{dudoit02,
+	Author = {S. Dudoit and J. Popper Shaffer and J. Boldrick},
+	Journal = {U.C. Berkeley Division of Biostatistics Working Paper Series},
+	Pages = {http://www.bepress.com/ucbbiostat/paper110},
+	Title = {Multiple Hypothesis Testing in Microarray Experiments},
+	Year = 2002}
+
+
+ at article{edgar04,
+author={R. Edgar},
+title={{MUSCLE}: multiple sequence alignment with high accuracy and high throughput},
+journal={Nucleic Acids Research},
+year={2004},
+volume={32},
+pages={1792-1797}
+}
+
+
+ at article{edwards63,
+	Author = {A. W. F. Edwards and L. L. Cavalli-Sforza},
+	Journal = {Ann. Hum. Genet.},
+	Pages = {104-105},
+	Title = {The reconstruction of evolution},
+	Volume = 27,
+	Year = 1963}
+
+ at article{edwards64,
+	Author = {A. W. F. Edwards and L. L. Cavalli-Sforza},
+	Journal = {Systematics Association Publication.},
+	Pages = {67-76},
+	Title = {Reconstruction of evolutionary trees},
+	Volume = 6,
+	Year = 1964}
+
+ at book{edwards72,
+	Address = {Cambridge, England},
+	Author = {A. W. F. Edwards},
+	Publisher = {University Press},
+	Title = {Likelihood},
+	Year = 1972}
+
+ at article{efron79,
+	Author = {B. Efron},
+	Journal = {Ann. Statistics},
+	Pages = {1-26},
+	Title = {Bootstrap methods: another look at the jackknife},
+	Volume = 7,
+	Year = 1979}
+
+ at article{efron85,
+	Author = {B. Efron},
+	Journal = {Biometrika},
+	Pages = {45-58},
+	Title = {Bootstrap confidence intervals for a class of parametric problems},
+	Volume = 72,
+	Year = 1985}
+
+ at article{efron87,
+	Author = {Bradley Efron},
+	Journal = {Journal of the american statistical association},
+	Month = {March},
+	Number = 397,
+	Pages = {171-185},
+	Title = {Better bootstrap confidence intervals},
+	Volume = 82,
+	Year = 1987}
+
+ at book{efron93,
+	Author = {Bradley Efron and Robert J. Tibshirani},
+	Publisher = {Chapman et Hall},
+	Title = {An {I}ntroduction to the {B}ootstrap},
+	Utilisateur = {Susan Holmes},
+	Year = 1993}
+
+ at techreport{efron95,
+	Author = {B. Efron and E. Halloran and S. Holmes},
+	Institution = {Standford University},
+	Number = {Tech. Rep. 179},
+	Title = {Bootstrap confidence levels for phylogenetic trees},
+	Year = 1995}
+
+ at article{efron96,
+	Author = {B. Efron and E. Halloran and S. Holmes},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {7085-7090},
+	Title = {Bootstrap confidence levels for phylogenetic trees},
+	Volume = 93,
+	Year = 1996}
+
+ at article{eigen81,
+	Author = {M. Eigen and R. Winkler-Oswatitsch},
+	Journal = {Die Naturwissenschaften},
+	Pages = {217-228},
+	Title = {Transfer-{\sc RNA} : The Early Adaptor},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 68,
+	Year = 1981}
+
+ at article{eigen88,
+	Author = {M. Eigen and R. Winkler-Oswatitsch and     A. Dress},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {5913-5917},
+	Title = {Statistical Geometry in Sequence Space : A Method     of Quantitative Comparative Sequence Analysis },
+	Volume = 85,
+	Year = 1988}
+
+ at incollection{eigen90a,
+	Author = {Manfred Eigen and Ruthild Winkler-Oswatitsch},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 32,
+	Editor = {Russsell F. Doolittle},
+	Pages = {505-530},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Statistical Geometry on Sequence Space},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{eigen90b,
+	Author = {Manfred Eigen and Katja Nieselt-Struwe},
+	Journal = {AIDS},
+	Pages = {585-593},
+	Title = {How old is the Immunodeficiency Virus~?},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = {4(suppl1)},
+	Year = 1990}
+
+ at article{elemento02,
+	Author = {O. Elemento and O. Gascuel and M.-P. Lefranc },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {278-288},
+	Title = {Reconstructing the duplication history of tandemly repeated genes},
+	Volume = {19},
+	Year = 2002}
+
+ at article{erchia96,
+	Author = {A.M. d'Erchia and C. Gissi and G. Pesole and     C. Saccone and U. Arnason},
+	Journal = {Nature},
+	Pages = {597-600},
+	Title = {The guinea-pig is not a rodent},
+	Volume = 381,
+	Year = 1996}
+
+ at article{estabrook72,
+	Author = {G.F. Estabrook},
+	Journal = {Ann. Rev. Ecol. Syst.},
+	Pages = {427-456},
+	Title = {Cladistic methodology: a discussion of the theoretical basis                   for the induction of evolutionary history},
+	Volume = 3,
+	Year = 1972}
+
+ at article{estabrook76,
+	Author = {G.F. Estabrook and C.S. Johnson and F.R. McMorris},
+	Journal = {Mathematical Biosciences},
+	Pages = {181-187},
+	Title = {A mathematical foundation for the analysis of cladistic                    character compatibility},
+	Volume = 29,
+	Year = 1976}
+
+ at inproceedings{fk96,
+	Author = {M. Farach and S. Kannan},
+	Booktitle = {Proceedings of the 28th Annual ACM Symposium on the Theory of                   Computing},
+	Pages = {230-235},
+	Title = {Efficient algorithms for inverting evolution},
+	Year = 1996}
+
+ at article{farris71,
+	Author = {James S. Farris},
+	Journal = {Annual Review of Ecology and Systematics},
+	Pages = {277-302},
+	Title = {The hypothesis of nonspecificity and taxonomic congruence},
+	Utilisateur = {Gilles Caraux},
+	Volume = 22,
+	Year = 1971}
+
+ at article{farris73a,
+	Author = {James S. Farris},
+	Journal = {Systematic Zoology},
+	Pages = {250-256},
+	Title = {A Probability Model for Inferring Evolutionary Trees},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 22,
+	Year = 1973}
+
+ at article{farris73b,
+	Author = {James S. Farris},
+	Journal = {American Naturalist},
+	Pages = {531-534},
+	Title = {Estimation of Amino-Acid Substitution when Back     Mutation can occur},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 107,
+	Year = 1973}
+
+ at article{felsenstein73a,
+	Author = {J. Felsenstein},
+	Journal = {The American Journal of Human Genetics},
+	Pages = {471-492},
+	Title = {Maximum-likelihood estimation of evolutionary trees     from continuous characters},
+	Utilisateur = {Gilles Caraux},
+	Volume = 25,
+	Year = 1973}
+
+ at article{felsenstein73b,
+	Author = {J. Felsenstein},
+	Journal = {Systematic Zoology},
+	Pages = {240-249},
+	Title = {Maximum Likelihood and Minimum Steps Methods for     Estimating Evolutionnary Trees from Data on Discrete     Characters},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 23,
+	Year = 1973}
+
+ at article{felsenstein78,
+	Author = {J. Felsenstein},
+	Journal = {Systematic Zoology},
+	Pages = {401-410},
+	Title = {Cases in which parsimony and compatibility methods     will be positively misleading},
+	Volume = 27,
+	Year = 1978}
+
+ at article{felsenstein81a,
+	Author = {J. Felsenstein},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {368-376},
+	Title = {Evolutionary Trees from {DNA} Sequences: a Maximum Likelihood Approach},
+	Volume = 17,
+	Year = 1981}
+
+ at article{felsenstein81b,
+	Author = {J. Felsenstein},
+	Journal = {Evolution},
+	Note = {({\it construction d'arbrtes par le maximum de vraisemblance})},
+	Number = 6,
+	Pages = {1229-1242},
+	Title = {Evolutionary Trees from gene frequencies and     quantitative characteres : finding maximum     likelihood estimates},
+	Volume = 35,
+	Year = 1981}
+
+ at article{felsenstein83,
+	Author = {J. Felsenstein},
+	Journal = {J. R. Statist. Soc. A},
+	Number = {Part 3},
+	Pages = {246-272},
+	Title = {Statistical Inference of Phylogenies},
+	Volume = 146,
+	Year = 1983}
+
+ at article{felsenstein84,
+	Author = {J. Felsenstein},
+	Journal = {Evolution},
+	Number = 1,
+	Pages = {16-24},
+	Title = {Distance methods for inferring phylogenies : a justification},
+	Utilisateur = {Gilles Caraux},
+	Volume = 38,
+	Year = 1984}
+
+ at article{felsenstein85a,
+	Author = {J. Felsenstein},
+	Journal = {Evolution},
+	Pages = {783-791},
+	Title = {Confidence limits on phylogenies: an     approach using the bootstrap},
+	Volume = 39,
+	Year = 1985}
+
+ at article{felsenstein85b,
+	Author = {J. Felsenstein},
+	Journal = {Systematic Zoology},
+	Pages = {27-33},
+	Title = {The number of evolutionary trees},
+	Utilisateur = {Gilles Caraux},
+	Volume = 34,
+	Year = 1985}
+
+ at article{felsenstein85c,
+	Author = {J. Felsenstein},
+	Journal = {Systematic Zoology},
+	Number = 2,
+	Pages = {152-161},
+	Title = {Confidence limits on phylogenies with a molecular clock},
+	Utilisateur = {Gilles Caraux},
+	Volume = 34,
+	Year = 1985}
+
+ at article{felsenstein87,
+	Author = {J. Felsenstein},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {123-131},
+	Title = { Estimation of Hominoid Phylogeny from a {DNA} Hybridation Data Set},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 26,
+	Year = 1987}
+
+ at article{felsenstein88,
+	Author = {J. Felsenstein},
+	Journal = {Annual Review of Genetics},
+	Pages = {521-565},
+	Title = {Phylogenies from molecular sequences:                     inference and reliability},
+	Volume = 22,
+	Year = 1988}
+
+ at book{felsensteinbook,
+	Address = {Sunderland, MA},
+	Author = {J. Felsenstein},
+	Publisher = {Sinauer Associates, Inc.},
+	Title = {Inferring phylogenies},
+	Year = 2003}
+
+ at article{phylip1,
+	Author = {J. Felsenstein},
+	Journal = {Cladistics},
+	Pages = {164-166},
+	Title = {Phylogeny Inference Package (Version 3.2)},
+	Volume = {5},
+	Year = {1989}}
+
+ at book{phylip2,
+	Address = {Department of Genetics, University of Washington, Seattle},
+	Author = {J. Felsenstein},
+	Publisher = {Distributed by the author},
+	Title = {PHYLIP ({PHYL}ogeny {I}nference {P}ackage) version 3.6a2},
+	Year = {1993}}
+
+ at article{gaucher01,
+	Author = {E. Gaucher and M. Miyamoto and S. Benner},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {548-552},
+	Title = {Function-structure analysis of proteins using covarion-based evolutionary approaches: {E}longation factors},
+	Volume = 98,
+	Year = 2001}
+
+
+ at ARTICLE{gouy09,
+author = { Manolo Gouy and  Stephane Guindon and  Olivier Gascuel},
+title = {Sea{V}iew version 4: {A} multiplatform graphical user interface for sequence
+      alignment and phylogenetic tree building.},
+journal = {Mol Biol Evol},
+year = {2010},
+volume = {27},
+number = {2},
+pages = {221-4}
+}
+
+ at article{haydon01,
+	Author = {D. Haydon and A. Bastos and N. Knowles and A. Samuel},
+	Journal = {Genetics},
+	Pages = {7-15},
+	Title = {Evidence for Positive Selection in Foot-and-Mouth Disease Virus Capsid Genes From Field Isolates},
+	Volume = 157,
+	Year = 2001}
+
+ at article{henikoff92,
+	Author = {S. Henikoff and J. Henikoff},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {10915-10919},
+	Title = {Amino acid substitution matrices from protein blocks.},
+	Volume = 89,
+	Year = 1992}
+
+ at article{hordijk05,
+	Author = {W. Hordijk and O. Gascuel},
+	Journal = {Bioinformatics},
+	Pages = {4338-4347},
+	Title = {Improving the efficiency of {SPR} moves in phylogenetic tree search methods based on maximum likelihood.},
+	Volume = 21,
+	Year = 2005}
+
+ at article{huelsenbeck00,
+	Author = {J. Huelsenbeck and B. Larget and D. Swofford},
+	Journal = {Genetics},
+	Pages = {1879-1892},
+	Title = {A compound {P}oisson process for relaxing the molecular clock},
+	Volume = 154,
+	Year = 2000}
+
+ at article{kuhner94,
+	Author = {M. Kuhner and J. Felsenstein},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {459-468},
+	Title = {A Simulation Comparison of Phylogeny Algorithms     under Equal and Unequal Evolutionary Rates},
+	Volume = 11,
+	Year = 1994}
+
+ at article{felsenstein96,
+	Author = {J. Felsenstein and G.A. Churchill},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {93-104},
+	Title = {A Hidden {M}arkov Model approach to variation among sites in rate of evolution},
+	Volume = 13,
+	Year = 1996}
+
+ at incollection{feng90,
+	Address = {New-York},
+	Author = {Da-Fei Feng and Russel F. Doolittle},
+	Booktitle = {Progressive alignement and phylogenetic tree construction of protein sequences},
+	Chapter = 23,
+	Editor = {Russsell F. Doolittle},
+	Pages = {375-387},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Nearset Neighbor Procedure for relating Progressively Amino Acid Sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{fitch67,
+	Author = {W. M. Fitch and E. Margoliash},
+	Journal = {Science},
+	Pages = {279-284},
+	Title = {Construction of phylogenetic trees},
+	Volume = 155,
+	Year = 1967}
+
+ at article{fitch71,
+	Author = {Walter M. Fitch},
+	Journal = {Systematic Zoology},
+	Title = {Toward defining the course of evolution : minimum     change for a specific tree topology},
+	Year = 1971}
+
+ at inproceedings{fitch75,
+	Author = {W.M. Fitch},
+	Booktitle = {Proceedings of the 8th International Conference on Numerical                    Taxonomy},
+	Pages = {189-230},
+	Title = {Towards finding the tree of Maximum Parsimony},
+	Year = 1975}
+
+ at article{fitch81,
+	Author = {W. M. Fitch},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {30-37},
+	Title = {A non-sequential method for constructing trees and                    hierarchical classifications},
+	Volume = 18,
+	Year = 1981}
+
+ at article{fitchfarris74,
+	Author = {Walter M. Fitch and James S. Farris},
+	Journal = {Journal of Molecular Evolution},
+	Note = {etendent la meth de Fitch71 pr les acides amines,     car il y a pr ce type de data qq ambiguites.},
+	Pages = {263-278},
+	Title = {Evolutionary trees with minimum nucleotide     replacements form amino acid sequences},
+	Utilisateur = {Vincent},
+	Volume = 3,
+	Year = 1974}
+
+ at article{forsberg03,
+	Author = {R. Forsberg and F. Christiansen},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1252-1259},
+	Title = {A codon-based model of host-specific selection in parasites with an application to the {I}nfluenza {A} virus},
+	Volume = 20,
+	Year = 2003}
+
+ at article{foulds84,
+	Author = {L.R. Foulds},
+	Journal = {Journal of Theoretical  Biology},
+	Pages = {471-474},
+	Title = {Maximum Savings in the Steiner Problem in Phylogeny},
+	Volume = 107,
+	Year = 1984}
+
+ at article{frommel85,
+	Author = {C. Fr\H{o}mmel and H. G. Holzh\H{u}tter},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {233-257},
+	Title = {an estimate on the effect of point mutation and natural  selection on the rate of amino acid replacement in proteins },
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 21,
+	Year = 1985}
+
+ at article{fukami89,
+	Author = {K. Fukami  and Y. Tateno},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {460-464},
+	Title = {On the maximum likelihood method for estimating molecular trees : uniquesness of the likelihood point},
+	Utilisateur = {Gilles Caraux},
+	Volume = 28,
+	Year = 1989}
+
+ at phdthesis{galtierthese,
+	Author = {N. Galtier},
+	Month = {novembre},
+	School = {Universit{\'e} Claude Bernard - Lyon I},
+	Title = {L'approche statistique en phylog{\'e}nie mol{\'e}culaire~: influence des composition en bases variables},
+	Year = 1997}
+
+ at article{galtier01,
+	Author = {N. Galtier},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {866-873},
+	Title = {Maximum-likelihood phylogenetic analysis under a covarion-like model},
+	Volume = 18,
+	Year = 2001}
+
+ at article{galtier99,
+	Author = {N. Galtier and N. Tourasse and M. Gouy},
+	Journal = {Science},
+	Pages = {220-221},
+	Title = {A nonhyperthermophilic common ancestor to extant life forms},
+	Volume = 283,
+	Year = 1999}
+
+ at article{galtier98,
+	Author = {N. Galtier and M. Gouy},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {871-879},
+	Title = {Inferring pattern and process: maximum-likelihood implementation of a nonhomogeneous model of {DNA} sequence evolution for phylogenetic analysis},
+	Volume = 15,
+	Year = 1998}
+
+ at article{galtier95,
+	Author = {N. Galtier and M. Gouy},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {11317-11321},
+	Title = {Inferring phylogenies from {DNA} sequences of unequal base compositions},
+	Volume = 92,
+	Year = 1995}
+
+ at article{galtier04,
+	Author = {N. Galtier and A. Jean-Marie},
+	Journal = {Journal of Computational Biology},
+	Pages = {727-733},
+	Title = {Markov-modulated {M}arkov chains and the covarion process of molecular evolution},
+	Volume = 11,
+	Year = 2004}
+
+ at book{gamerman06,
+	Author = {Dani Gamerman and Hedibert F. Lopes },
+	Isbn = {1584885874},
+	Publisher = {Chapman and Hall/CRC},
+	Title = {Markov Chain Monte Carlo: Stochastic Simulation for Bayesian Inference},
+	Year = {2006}}
+
+ at book{gareyjohnson,
+	Address = {San Fransisco},
+	Author = {M. Garey and D. Johnson},
+	Publisher = {Freeman},
+	Title = {{C}omputers and {I}ntractability - {A} guide to the     {T}heory of {NP}-{C}ompleteness},
+	Year = 1979}
+
+ at article{gascuel92,
+	Author = {O. Gascuel and G. Caraux},
+	Journal = {Pattern Recognition letters},
+	Note = {({\it Estimation d'une probab {\`a} partir d'une fr{\'e}quence}) },
+	Pages = {757-764},
+	Title = {{D}istribution-free performance bounds with the     resubstitution error estimate},
+	Volume = {13},
+	Year = {1992}}
+
+ at article{gascuel94,
+	Author = {O. Gascuel},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {961-963},
+	Title = {A Note on {S}attah and {T}versky's, {S}aitou and {N}ei's,     and {S}tudier and {K}eppler's Algorithms for Inferring     Phylogenies from Evolutionary Distances},
+	Volume = {11},
+	Year = {1994}}
+
+ at article{gascuel96,
+	Author = {O. Gascuel and D. Levy},
+	Journal = {J. of Classification},
+	Title = {A reduction for approximating a (non-metric)     dissimilarity by a tree distance},
+	Year = 1996}
+
+ at article{gascuelNJ,
+	Author = {O. Gascuel},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {685-695},
+	Title = {{B}IO{NJ}: an Improved Version of the {NJ} Algorithm Based on a Simple Model of Sequence Data},
+	Volume = {14},
+	Year = 1997}
+
+ at article{gascuel00,
+	Author = {O. Gascuel},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {401-405},
+	Title = {On the optimization principle in phylogenetic analysis and the minimum-evolution criterion},
+	Volume = 17,
+	Year = 2000}
+
+ at article{gascuel01,
+	Author = {O. Gascuel and D. Bryant and F. Denis},
+	Journal = {Systematic Biology},
+	Pages = {621-627},
+	Title = {Strengths and limitations of the minimum evolution principle},
+	Volume = {50},
+	Year = 2001}
+
+ at article{gascuel03,
+	Author = {O. Gascuel and M. Hendy and A. Jean-Marie and R. McLachlan},
+	Journal = {Systematic Biology},
+	Pages = {110-118},
+	Title = {The combinatorics of tandem duplication trees},
+	Volume = {52},
+	Year = {2003}}
+
+ at incollection{gascuel97,
+	Address = {Providence, USA},
+	Author = {O. Gascuel},
+	Booktitle = {Mathematical Hierarchies and Biology},
+	Editor = {B. Mirkin and F.R. McMorris and F.S. Roberts and     A. Rzhetsky},
+	Pages = {149-170},
+	Publisher = {Am. Math. Society},
+	Title = {Concerning the {NJ} algorithm and its unweighted     version {UNJ}},
+	Year = 1997}
+
+ at incollection{gascuel05,
+	Address = {Oxford},
+	Author = {O. Gascuel and D. Bertrand and O. Elemento},
+	Booktitle = {Mathematics of evolution and phylogeny},
+	Editor = {O. Gascuel},
+	Pages = {205-235},
+	Publisher = {Clarendon press},
+	Title = {Reconstructing the duplication history of tandemly repeated sequences},
+	Year = 2005}
+
+ at Article{gaut92,
+   Author="Gaut, B. S.  and Muse, S. V.  and Clark, W. D.  and Clegg, M. T. ",
+   Title="{{R}elative rates of nucleotide substitution at the rbc{L} locus of monocotyledonous plants}",
+   Journal="J. Mol. Evol.",
+   Year="1992",
+   Volume="35",
+   Pages="292--303",
+   Month="Oct"
+}
+
+ at article{gaut95,
+	Author = {B.S. Gaut and P.O. Lewis},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {152-162},
+	Title = {Success of maximum likelihood phylogeny inference in the four-taxon case},
+	Volume = 12,
+	Year = 1995}
+
+ at book{gill81,
+	Address = {London},
+	Author = {P. Gill and W. Murray and M. Wright},
+	Publisher = {Academic Press},
+	Title = {Practical optimization},
+	Year = 1981}
+
+ at article{geman84,
+        author = {Geman, Stuart   and Geman, Donald},
+	journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
+	keywords = {annealing, mrf, simulated},
+	month = {November},
+	number = {6},
+	pages = {721--741},
+	posted-at = {2008-05-07 06:09:28},
+	priority = {2},
+	publisher = {Routledge},
+	title = {Stochastic relaxation, Gibbs distributions and the Bayesian restoration of images},
+	volume = {6},
+	year = {1984}
+}
+
+ at dea{giordano91,
+	Address = {Montpellier},
+	Author = {Jean-Yves Giordano},
+	School = {Universit{\'e} Montpellier II},
+	Title = {{R}epr{\'e}sentation arbor{\'e}e des {P}roximit{\'e}s et {A}rbres  {P}hyllog{\'e}n{\'e}tique},
+	Utilisateur = {Guillaume Andrieu},
+	Year = 1991}
+
+ at article{gojobori82,
+	Author = {Takashi Gojobori and Kazushige Ishii and Masatoshi Nei},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {414-423},
+	Title = {Estimation of Average Number of Nucleotide Substitutions when the Rate of Substitution varies with Nucleotide},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 18,
+	Year = 1982}
+
+ at incollection{gojobori90,
+	Author = {Takashi Gojobori and Etsuko N. Moriyama and M. Kimura},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 33,
+	Editor = {Russsell F. Doolittle},
+	Pages = {531-550},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Statistical Methods for Estimating Sequence Divergence},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{golding83,
+	Author = {G. B. Golding},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {125-142},
+	Title = {Estimates of {DNA} and protein sequence divergence: an examination of some assumptions},
+	Volume = 1,
+	Year = 1983}
+
+ at article{goldman93,
+	Author = {N. Goldman },
+	Journal = {Journal of Molecular Evolution},
+	Pages = {182-198},
+	Title = {Statistical tests of models of {DNA} substitution},
+	Volume = 36,
+	Year = 1993}
+
+ at article{goldman94,
+	Author = {N. Goldman and Z. Yang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {725-736},
+	Title = {A Codon-based model of nucleotide substitution for protein-coding {DNA} sequences},
+	Volume = 11,
+	Year = 1994}
+
+ at article{goldman98a,
+	Author = {N. Goldman},
+	Journal = {Proceedings of the  Royal Society B: Biological Sciences},
+	Pages = {1779-1786},
+	Title = {Phylogenetic information and experimental design in molecular systematics },
+	Volume = 265,
+	Year = 1998}
+
+ at article{goldman98b,
+	Author = {N. Goldman and J. Thorne and D. Jones},
+	Journal = {Genetics},
+	Pages = {445-458},
+	Title = {Assessing the impact of secondary structure and solvent accessibility on protein evolution},
+	Volume = 149,
+	Year = 1998}
+
+ at article{goldman00,
+	Author = {N. Goldman and S. Whelan},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {975-978},
+	Title = {Statistical tests of {G}amma-distributed rate heterogeneity in models of sequence evolution in phylogenetics},
+	Volume = 17,
+	Year = 2000}
+
+ at article{goodman65,
+	Author = {Leo A. Goodman},
+	Journal = {Technometrics},
+	Month = {MAY},
+	Number = 2,
+	Pages = {247-253},
+	Title = {On Simultaneous Confidence Intervals for     Multinomial Proportions },
+	Volume = 7,
+	Year = 1965}
+
+ at article{gouy84,
+	Author = {M. Gouy and F. Milleret and C. Mugnier and M. Jacobzone and C. Gautier},
+	Journal = {Nucleic Acids Research},
+	Number = 2,
+	Pages = {121-127},
+	Title = {{ACNUC}: a nucleic acid sequence data base and analysis system},
+	Volume = 12,
+	Year = 1984}
+
+ at article{graur91,
+	Author = {D. Graur and W.A. Hide and W.-H. Li},
+	Journal = {Nature},
+	Pages = {649-652},
+	Title = {Is the guinea-pig a rodent?},
+	Volume = 351,
+	Year = 1991}
+
+ at article{gu95,
+	Author = {X. Gu and Y.X. Fu and W.H. Li},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {546-557},
+	Title = {Maximum likelihood estimation of the heterogeneity of substitution rate among nucleotide sites},
+	Volume = 12,
+	Year = 1995}
+
+ at article{gu97,
+	Author = {X. Gu and J.D. Zhang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1106-13},
+	Title = {A simple method for estimating the parameter of substitution rate variation among sites},
+	Volume = 14,
+	Year = 1997}
+
+ at article{gu98,
+	Author = {X. Gu and W.H. Li},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {5899-5905},
+	Title = {Estimation of evolutionary distances under stationary and nonstationary models of nucleotide substitution},
+	Volume = 95,
+	Year = 1998}
+
+ at inproceedings{guenoche00,
+	Author = {Alain Gu{\'e}noche},
+	Booktitle = {Recueil des Actes JOBIM 2000},
+	Editor = {O. Gascuel and M.-F Sagot},
+	Pages = {181-191},
+	Title = {Quelle confiance accorder {\`a} une repr{\'e}sentation arbor{\'e}e ?},
+	Year = 2000}
+
+ at article{guenoche87,
+	Author = {Alain Guenoche},
+	Journal = {Math. Sci. hum.},
+	Pages = {21-40},
+	Title = {Cinq algorithmes d'approximation d'une dissimilarit{\'e} par  des arbres {\`a} distances additives},
+	Utilisateur = {Gilles Caraux and Denise Levy},
+	Volume = 98,
+	Year = 1987}
+
+ at inproceedings{guenoche00b,
+	Author = {A. Gu{\'e}noche and H. Garreta},
+	Booktitle = {Computational biology, LNCS 2066},
+	Pages = {45-46},
+	Title = {Can we have confidence in a tree representation ?},
+	Year = 2000}
+
+ at book{gilks95,
+	author = {W. R. Gilks and S. Richardson and D. Spiegelhalter},
+	publisher = {{Chapman \& Hall/CRC}},
+	title = {Markov Chain Monte Carlo in Practice},
+	year = {1995}
+}
+
+
+ at article{gray09,
+author="R. Gray and A. Drummond and Greenhill S.",
+title="Language phylogenies reveal expansion pulses and pauses in {P}acific settlement",
+journal="Science",
+year="2009",
+pages={479-483}
+}
+
+
+ at article{guindon01,
+	Author = {S. Guindon and G. Perri{\`e}re},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1838-40},
+	Title = {Intragenomic base content variation is a potential source of biases when searching for horizontally transferred genes},
+	Volume = 18,
+	Year = 2001}
+
+ at article{guindon02,
+	Author = {S. Guindon and O. Gascuel},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {534-543},
+	Title = {Efficient biased estimation of evolutionary distances when substitution rates vary across sites},
+	Volume = 19,
+	Year = 2002}
+
+ at article{guindon03,
+	Author = {S. Guindon and O. Gascuel},
+	Journal = {Systematic Biology},
+	Pages = {696-704},
+	Title = {A simple, fast and accurate algorithm to estimate large phylogenies by maximum likelihood},
+	Volume = 52,
+	Year = 2003}
+
+ at article{guindon04,
+	Author = {S. Guindon and A. Rodrigo and K. Dyer and J. Huelsenbeck},
+	Journal = {Proceedings of the National Academy of Sciences},
+	Pages = {12957-12962},
+	Title = {Modeling the site-specific variation of selection patterns along lineages},
+	Volume = {101},
+	Year = 2004}
+
+ at article{guindon05,
+	Author = {S. Guindon and F. Lethiec and P. Duroux and O. Gascuel},
+	Journal = {Nucleic Acids Research},
+	Pages = {557-559},
+	Title = {{PHYML} {O}nline -- a web server for fast maximum likelihood-based phylogenetic inference},
+	Volume = {33(Web Server issue)},
+	Year = 2005}
+
+ at article{guindon06,
+	Author = {S. Guindon and M. Black and A. Rodrigo},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {919-926},
+	Title = {Control of the False Discovery Rate Applied to the Detection of Positively Selected Amino Acid Sites.},
+	Volume = {23},
+	Year = 2006}
+
+ at article{gusfield91,
+	Author = {D. Gusfield},
+	Journal = {Networks},
+	Pages = {19-28},
+	Title = {Efficient Algorithms for inferring evolutionnary trees},
+	Volume = 21,
+	Year = 1991}
+
+ at article{hamming,
+	Author = {R. W. Hamming},
+	Journal = {The Bell System Technical Journal},
+	Number = 2,
+	Pages = {147-160},
+	Title = {Error Detecting and Error Correcting Codes},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu },
+	Volume = 26,
+	Year = 1950}
+
+ at article{harshman94,
+	Author = {J. Harshman},
+	Journal = {Systematic Biology},
+	Number = 3,
+	Pages = {419-424},
+	Title = {The effect of irrelevant characters on bootstrap values},
+	Utilisateur = {Vincent},
+	Volume = 43,
+	Year = 1994}
+
+ at article{hartigan72,
+	Author = {J. Hartigan},
+	Journal = {Biometrics},
+	Pages = {53-65},
+	Title = {Minimum mutation fits to a given tree},
+	Volume = 29,
+	Year = 1972}
+
+ at article{hasegawa85,
+	Author = {M. Hasegawa and H. Kishino and T. Yano},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {160-174},
+	Title = {Dating of the {H}uman-{A}pe Splitting by a Molecular Clock of Mitochondrial-{DNA}},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 22,
+	Year = 1985}
+
+ at article{hasegawa87,
+	Author = {M. Hasegawa and H. Kishino and T. Yano},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {132-147},
+	Title = {Man's Place in Hominoidea as Inferred from Molecular Clocks of {DNA}},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 26,
+	Year = 1987}
+
+ at article{hasegawa89,
+	Author = {H. Kishino and M. Hasegawa},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {170-179},
+	Title = {Evaluation of the maximum likelihood estimate of the evolutionnary tree topology from {DNA} sequence data, and the branching order in Homonoidea},
+	Volume = 29,
+	Year = 1989}
+
+ at article{hasegawa94,
+	Author = {M. Hasegawa and H. Kishino},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {142-145},
+	Title = {Accuracies of the Simple Methods for Estimating the     Bootstrap Probability of a Maximum-Likelihood Tree},
+	Volume = 11,
+	Year = 1994}
+
+ at article{hein89,
+	Author = {J. Hein},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {669-684},
+	Title = {A tree reconstruction method that is economical in     the number of pairwise comparisons used.},
+	Utilisateur = {Vincent},
+	Volume = 6,
+	Year = 1989}
+
+ at incollection{hein90,
+	Author = {J. Hein},
+	Booktitle = {Molecular evolution : computer analysis of     protein and nucleic acid sequences},
+	Chapter = 39,
+	Editor = {Russsell F. Doolittle},
+	Pages = {626-644},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Unified Approach to Alignement and Phylogenies},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{hein93,
+	Author = {Jotun Hein },
+	Journal = {Journal of Molecular Evolution},
+	Pages = {396-405},
+	Title = {a heuristic method to reconstruct the history  of sequences subject to recombinaison},
+	Utilisateur = {G. Andrieu},
+	Volume = 36,
+	Year = 1993}
+
+ at incollection{hendy82,
+	Author = {M.D. Hendy and D. Penny},
+	Booktitle = {Mathematical Biosciences},
+	Pages = {277-290},
+	Publisher = {Elsevier Science Publishing},
+	Title = {Branch and bound Algorithms to Determine Minimal     Evolutionary Trees},
+	Utilisateur = {Vincent},
+	Volume = 59,
+	Year = 1982}
+
+ at article{hendy89,
+	Author = {M.D. Hendy and D. Penny},
+	Journal = {Syst Zool},
+	Number = 4,
+	Pages = {297-309},
+	Title = {A framework for the quantitative study of     evolutionary trees},
+	Utilisateur = {Vincent},
+	Volume = 38,
+	Year = 1989}
+
+ at article{hendy93,
+	Author = {M.D. Hendy and D. Penny},
+	Journal = {Journal of Classification},
+	Pages = {297-309},
+	Title = {Spectral analysis of phylogenetic data},
+	Volume = 10,
+	Year = 1993}
+
+ at article{hendy94,
+	Author = {M. Hendy and D. Penny and M. A. Steel},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {3339-3343},
+	Title = {A discrete {F}ourier analysis for evolutionary trees},
+	Volume = 91,
+	Year = 1994}
+
+ at article{hg01,
+	Author = {{International Human Genome Sequencing Consortium}},
+	Journal = {Nature},
+	Pages = {860-921},
+	Title = {Initial sequencing and analysis of the human genome},
+	Volume = 409,
+	Year = 2001}
+
+ at incollection{higgins96,
+	Address = {San Diego},
+	Author = {D. G. Higgins and J. D. Thompson and J. T. Gibbson},
+	Booktitle = {Methods in enzymology},
+	Editor = {R. F. Doolittle},
+	Pages = {383-401},
+	Publisher = {Academic Press},
+	Title = {Using {CLUSTAL} for multiple sequence alignments},
+	Year = 1996}
+
+ at inbook{hiv_epitope,
+	Address = {Los Alamos, New Mexico},
+	Author = {B. Korber and C. Brander and B. Haynes and R. Koup and C. Kuiken and J. Moore and B. Walker and D. Watkins},
+	Publisher = {Los Alamos National Laboratory, Theoretical Biology and Biophysics},
+	Title = {{HIV} molecular immunology database 2002},
+	Year = 2002}
+
+ at inbook{karlin,
+	Address = {New York},
+	Author = {Samuel Karlin},
+	Chapter = { No VII Examples of continuous Time {M}arkov Chains },
+	Pages = {189-209},
+	Publisher = {Academic Press},
+	Title = {A first course in Stochastic processes},
+	Utilisateur = {Guillaume Andrieu},
+	Year = 19}
+
+ at article{koshi96,
+	Author = {J. Koshi and R. Goldstein},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {313-320},
+	Title = {Probabilistic reconstruction of ancestral protein sequences},
+	Volume = 42,
+	Year = 1996}
+
+ at article{koshi98,
+	Author = {J. Koshi and R. Goldstein},
+	Journal = {Proteins},
+	Pages = {289-295},
+	Title = {Models of natural mutations including site heterogeneity},
+	Volume = 32,
+	Year = 1998}
+
+ at article{kirkpatrick83,
+	Author = {S. Kirkpatrick and C. D. Gelatt and M. P. Vecchi},
+	Journal = {Science},
+	Pages = {671-680},
+	Title = {Optimization by simulated annealing},
+	Volume = 220,
+	Year = 1983}
+
+ at inbook{hillis91,
+	Author = {D.M. Hillis},
+	Chapter = 13,
+	Note = {Preliminsaire a l'article hilhuels92},
+	Pages = {278-294},
+	Title = {Discriminating Between Phylogenetic Signal and     Random Noise in {DNA} Sequences},
+	Utilisateur = {Vincent}}
+
+ at article{hillishuels92,
+	Author = {D.M. Hillis and J.P. Huelsenbeck},
+	Journal = {Journal of Heredity},
+	Note = {Examine la distribution des arbres les plus     parcimonieux : gaussienne applatie},
+	Pages = {189-195},
+	Title = {Signal, Noise, and Reliability in Molecular     Phylogenetic Analyses},
+	Volume = 83,
+	Year = 1992}
+
+ at article{ho05,
+	Author = {S. Ho and M. Phillips and A. Drummond and A. Cooper},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1355-1363},
+	Title = {Accuracy of rate estimation using relaxed-clock models with a critical focus on the early {M}etazoan radiation},
+	Volume = 22,
+	Year = 2005}
+
+ at article{holm79,
+	Author = {S. Holm},
+	Journal = {Scandinavian Journal of Statistics},
+	Pages = {65-70},
+	Title = {A simple sequentially rejective multiple test procedure},
+	Volume = 6,
+	Year = 1979}
+
+ at article{holmquist72a,
+	Author = {Richard Holmquist},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {115-133},
+	Title = {Theoretical foundations for a quantitative approach to paleogenetics {Part I : DNA}},
+	Utilisateur = {Gilles Caraux et Guillaume Andrieu},
+	Volume = 1,
+	Year = 1972}
+
+ at article{holmquist72b,
+	Author = {Richard Holmquist},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {211-222},
+	Title = {Empirical support for stochastic model of evolution},
+	Utilisateur = {Gilles Caraux et Guillaume Andrieu},
+	Volume = 1,
+	Year = 1972}
+
+ at article{holmquist83,
+	Author = {R. Holmquist and M. Goodman and T. Conroy and J. Czelusniak},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {437-448},
+	Title = {The spatial distribution of fixed mutations within genes coding for proteins},
+	Volume = 19,
+	Year = 1983}
+
+ at article{huelsenbeck93,
+	Author = {J. P. Huelsenbeck and D. Hillis},
+	Journal = {Systematic Biology},
+	Pages = {247-264},
+	Title = {Success of phylogenetic methods in the four-taxon case},
+	Volume = 42,
+	Year = 1993}
+
+ at article{huelsenbeck95a,
+	Author = {J. P. Huelsenbeck},
+	Journal = {Systematic Biology},
+	Pages = {17-48},
+	Title = {Performance of phylogenetic methods in simulation},
+	Volume = 44,
+	Year = 1995}
+
+ at article{huelsenbeck95b,
+	Author = {J. P. Huelsenbeck},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {843-849},
+	Title = {The robustness of two phylogenetic methods: four-taxon simulations reveal a slight superiority of maximum likelihood over neighbor joining},
+	Volume = 12,
+	Year = 1995}
+
+ at article{huelsenbeck97a,
+	Author = {J. P. Huelsenbeck and K. A. Crandall},
+	Journal = {Annual Review of Ecology and Systematics},
+	Pages = {437-466},
+	Title = {Phylogeny estimation and hypothesis testing using maximum likelihood},
+	Volume = 28,
+	Year = 1997}
+
+ at article{huelsenbeck97b,
+	Author = {J. Huelsenbeck and B. Rannala},
+	Journal = {Science},
+	Pages = {218-219},
+	Title = {Phylogenetic methods come of age: testing hypotheses in an evolutionary context},
+	Volume = 276,
+	Year = 1997}
+
+ at article{huelsenbeck99,
+	Author = {J. Huelsenbeck and R. Nielsen},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {86-93},
+	Title = {Variation in the pattern of nucleotide substitution across sites},
+	Volume = 48,
+	Year = 1999}
+
+ at article{huelsenbeck01,
+	Author = {J. Huelsenbeck and F. Ronquist},
+	Journal = {Bioinformatics},
+	Pages = {754-755},
+	Title = {{MRBAYES} : Bayesian inference of phylogenetic trees},
+	Volume = 17,
+	Year = 2001}
+
+ at article{huelsenbeck01a,
+	Author = {J. P. Huelsenbeck and F. Ronquist and R. Nielsen and J. P. Bollack},
+	Journal = {Science},
+	Pages = {2310-2314},
+	Title = {Bayesian Inference of Phylogeny and Its Impact on Evolutionary Biology},
+	Volume = 294,
+	Year = 2001}
+
+ at article{huelsenbeck01c,
+	Author = {J. P. Huelsenbeck and J. P. Bollback},
+	Journal = {Systematic Biology},
+	Pages = {351-366},
+	Title = {Empirical and hierarchical bayesian estimation of ancestral states},
+	Volume = 50,
+	Year = 2001}
+
+ at article{huelsenbeck02,
+	Author = {J. P. Huelsenbeck},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {698-707},
+	Title = {Testing a Covariotide Model of {DNA} Substitution},
+	Volume = 19,
+	Year = 2002}
+
+ at article{huelsenbeck04,
+	Author = {J. Huelsenbeck and B. Larget and M. Alfaro},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1123-1133},
+	Title = {Bayesian phylogenetic model selection using reversible jump markov chain monte carlo.},
+	Volume = 21,
+	Year = 2004}
+
+ at article{huelsenbeck04b,
+	Author = {J. Huelsenbeck and K. Dyer},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {661-672},
+	Title = {Bayesian estimation of positively selected sites},
+	Volume = 58,
+	Year = 2004}
+
+ at article{huelsenbeck06,
+	Author = {J. Huelsenbeck and S. Jain and S. Frost and S. Pond},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {6263-6268},
+	Title = {A Dirichlet process model for detecting positive selection in protein-coding {DNA} sequences},
+	Volume = 103,
+	Year = 2006}
+
+
+
+
+ at article{hughes88,
+	Author = {A. Hughes and M. Nei},
+	Journal = {Nature},
+	Pages = {167-170},
+	Title = {Pattern of nucleotide substitution at major histocompatibility complex class {I} loci reveals overdominant selection},
+	Volume = 335,
+	Year = 1988}
+
+ at article{hughes90,
+	Author = {A. Hughes and T. Ota and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {515-524},
+	Title = {Positive darwinian selection promotes charge profile diversity in the antigen-binding cleft of class {I} major-histocompatibility-complex molecules},
+	Volume = 7,
+	Year = 1990}
+
+ at article{mrbayes,
+	Author = {J. P. Huelsenbeck and F. Ronquist},
+	Journal = {Bioinformatics},
+	Pages = {754-755},
+	Title = {{M}r{B}ayes: {B}ayesian inference of phylogeny},
+	Volume = 17,
+	Year = 2001}
+
+ at article{irwin91,
+	Author = {David M. Irwin and Thomas D. Kocher and Allan C. Wilson},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {128-144},
+	Title = {{E}volution of the {C}ytochrome {\em b} {G}ene of {M}amals},
+	Utilisateur = {F.Catzeflis et G. Andrieu},
+	Volume = 32,
+	Year = 1991}
+
+ at techreport{jiang92,
+	Author = {T. Jiang and Ming Li},
+	Institution = {Mc Master Univ. and University of Waterloo},
+	Title = {Some optimizations problems related to molecular biology},
+	Year = 1992}
+
+ at article{jiang94,
+	Author = {Tao Jiang, Eugene L. Lawler, Lusheng Wang},
+	Title = {Aligning Sequences via an Evolutionary Tree:     Complexity and Approximation},
+	Year = 1994}
+
+ at article{jin90,
+	Author = {L. Jin and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {82-102},
+	Title = {Limitations of the evolutionary parsimony method of phylogenetic analysis},
+	Volume = 7,
+	Year = 1990}
+
+ at article{jin94,
+	Author = {Li Jin and Ranajit Chakraborty},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {120-127},
+	Title = {Estimation of genetic distance and coefficient of gene diversity from single-probe multilocus {DNA} fingerprinting data},
+	Utilisateur = {Gilles Caraux},
+	Volume = 11,
+	Year = 1994}
+
+ at incollection{johnson90,
+	Address = {New York},
+	Author = {Mark S. Johnson and Andrej Sali and Tom L. Blundell},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 42,
+	Editor = {Russsell F. Doolittle},
+	Pages = {670-690},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Phylogenetic Relationships from Three-Dimensional Protein Structures},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{jones92,
+	Author = {D. Jones and W. Taylor and J. Thornton},
+	Journal = {Computer Applications in the Biosciences (CABIOS)},
+	Pages = {275-282},
+	Title = {The rapid generation of mutation data matrices from protein sequences},
+	Volume = 8,
+	Year = 1992}
+
+ at incollection{jukes69,
+	Address = {New York},
+	Author = {T. Jukes and C. Cantor},
+	Booktitle = {Mammalian Protein Metabolism},
+	Chapter = {24},
+	Editor = {H. Munro},
+	Pages = {21-132},
+	Publisher = {Academic Press},
+	Title = {Evolution of protein molecules},
+	Utilisateur = {Gilles Caraux},
+	Volume = {III},
+	Year = 1969}
+
+ at Manual{R,
+    title = {R: A Language and Environment for Statistical Computing},
+    author = {{R Core Team}},
+    organization = {R Foundation for Statistical Computing},
+    address = {Vienna, Austria},
+    year = {2013},
+    url = {http://www.R-project.org/},
+  }
+
+ at article{kaj03,
+  title={The coalescent process in a population with stochastically varying size},
+  author={Kaj, Ingemar and Krone, Stephen M},
+  journal={Journal of Applied Probability},
+  Volume = 40,
+  pages={33--48},
+  year={2003},
+  publisher={JSTOR}
+}
+
+
+ at article{kannan95,
+	Author = {S. Kannan and T. Warnow},
+	Journal = {SIAM J. Comp.},
+	Number = 3,
+	Pages = {511-519},
+	Title = {Tree reconstruction from partial orders},
+	Volume = 24,
+	Year = 1995}
+
+ at article{kannan97,
+	Author = {S. Kannan},
+	Journal = {Journal of the indian institute of science},
+	Number = 4,
+	Pages = {353-364},
+	Title = {consensus of trees : desirable properties and computationnal methods},
+	Volume = 77,
+	Year = 1997}
+
+ at article{kaplan79,
+	Author = {N. Kaplan and C.H. Langley},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {295-304},
+	Title = {A new estimate of sequence divergence of mitochondrial                     {\sc DNA} Using restriction endonuclease mappings},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 13,
+	Year = 1979}
+
+ at inbook{karlin,
+	Address = {New York},
+	Author = {Samuel Karlin},
+	Chapter = { No VII Examples of continuous Time {M}arkov Chains },
+	Pages = {189-209},
+	Publisher = {Academic Press},
+	Title = {A first course in Stochastic processes},
+	Utilisateur = {Guillaume Andrieu},
+	Year = 19}
+
+ at article{karlin93,
+	Author = {Samuel Karlin and Stephen F. Altschul},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {5873-5877},
+	Title = {Applications and Statistics for multiple     hight-scoring segments in molecular Sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 90,
+	Year = 1993}
+
+ at article{kashyap74,
+	Author = {R. L. Kashyap and S. Subas},
+	Journal = {Journal of Theoretical Biology},
+	Pages = {75-101},
+	Title = {Statistical estimation of parameters in a     phylogenetic tree using a dynamic model of the     substitutional process},
+	Utilisateur = {Gilles Caraux},
+	Volume = 47,
+	Year = 1974}
+
+ at article{kaslow87,
+	Author = {R. Kaslow and D. Ostrow and R. Detel and J. Phair and B. Polk and C. Rinaldo},
+	Journal = {American Journal of Epidemiology},
+	Pages = {310-318},
+	Title = {The {M}ulticenter {AIDS} {C}ohort {S}tudy : rationale, organization, and selected characteristics of the participants},
+	Volume = 126,
+	Year = 1987}
+
+ at book{kendall73,
+	Address = {London},
+	Author = {M. G. Kendall and A. Stuart},
+	Publisher = {Griffin},
+	Title = {The Advanced Theory of Statistics},
+	Volume = {II~: Inference and relationship},
+	Year = 1973}
+
+ at article{kidd71,
+	Author = {K.K. Kidd and L.A. Sgaramella-Zonta},
+	Journal = {The American Journal of Human Genetics},
+	Pages = {235-252},
+	Title = {Phylogenetic analysis: concepts and methods},
+	Volume = 23,
+	Year = 1971}
+
+ at article{kimura72,
+	Author = {M. Kimura and Tomoko Otha},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {87-90},
+	Title = { On the stochastic model for estimation of     mutational distance between homologous proteins},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 2,
+	Year = 1972}
+
+ at article{kimura80,
+	Author = {M. Kimura},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {111-120},
+	Title = {A simple method for estimating evolutionary rates of base substitutions through comparative studies of nucleotide sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 16,
+	Year = 1980}
+
+ at article{kimura81,
+	Author = {M. Kimura},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {454-458},
+	Title = {Estimation of evolutionary distances between homologous nucleotide sequences},
+	Volume = 78,
+	Year = 1981}
+
+ at article{kimura87,
+	Author = {M. Kimura},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {24-33},
+	Title = {Molecular Evolutionnary Clock and the Neutral Theory},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 26,
+	Year = 1987}
+
+ at article{kingman82,
+	Author = {Kingman, J. F. C. },
+	Citeulike-Article-Id = {3431666},
+	Journal = {Stochastic Processes and their Applications},
+	Keywords = {coalescent, ebsp-paper},
+	Pages = {235--248},
+	Posted-At = {2008-10-20 21:06:45},
+	Priority = {0},
+	Title = {The coalescent},
+	Volume = {13},
+	Year = {1982}}
+
+ at article{kishino89,
+	Author = {H. Kishino and  M. Hasegawa},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {170-179},
+	Title = {Evaluation of the Maximum Likelihood Estimate of the Evolutionnary Tree Topology from {DNA} Sequence Data, and the Branching Order in Hominoidea},
+	Utilisateur = {Gilles Caraux and  Guillaume Andrieu},
+	Volume = 29,
+	Year = 1989}
+
+ at incollection{kishino90,
+	Address = {New York},
+	Author = {H. Kishino and M. Hasegawa },
+	Booktitle = {Molecular evolution : computer analysis of                       protein and nucleic acid sequences},
+	Chapter = 34,
+	Editor = {Russsell F. Doolittle},
+	Pages = {550-570},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Converting Distance to Time : Application to Human                     Evolution},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{kishino90b,
+	Author = {H. Kishino and T. Miyata and M. Hasegawa},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {151-160},
+	Title = {Maximum likelihood inference of protein phylogeny and the origin of chloroplasts},
+	Volume = 31,
+	Year = 1990}
+
+ at Article{kishino01,
+   Author="Kishino, H.  and Thorne, J.  and Bruno, W.",
+   Title="{{P}erformance of a divergence time estimation method under a probabilistic model of rate evolution}",
+   Journal="Mol. Biol. Evol.",
+   Year="2001",
+   Volume="18",
+   Pages="352--361",
+   Month="Mar"
+}
+
+ at Article{kitazoe07,
+   Author="Kitazoe, Y.  and Kishino, H.  and Waddell, P. J.  and Nakajima, N.  and Okabayashi, T.  and Watabe, T.  and Okuhara, Y. ",
+   Title="{{R}obust time estimation reconciles views of the antiquity of placental mammals}",
+   Journal="PLoS ONE",
+   Year="2007",
+   Volume="2",
+   Pages="e384"
+}
+
+
+ at article{klotz79,
+	Author = {Lynn C. Klotz and Ned Komar and Roger L. Blanken and Ralph M. Mitchell},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {4516-4520},
+	Title = {Calculation of evolutionary trees from sequence data},
+	Utilisateur = {Gilles Caraux},
+	Volume = 76,
+	Year = 1979}
+
+ at article{klotz81,
+	Author = {Lynn C. Klotz and Roger L. Blanken},
+	Journal = {Journal of Theoretical Biology},
+	Pages = {261-272},
+	Title = {A practical method for calculating evolutionary trees from sequence data},
+	Utilisateur = {Gilles Caraux},
+	Volume = 91,
+	Year = 1981}
+
+ at article{kolaczkowski04,
+	Author = {B. Kolaczkowski and J. Thornton},
+	Journal = {Nature},
+	Pages = {980-984},
+	Title = {Performance of maximum parsimony and likelihood phylogenetics when evolution is heterogeneous},
+	Volume = 431,
+	Year = 2004}
+
+ at article{kondo93,
+	Author = {Rumi Kondo and Satoshi Horai and Yoko Satta and Naoyuki Takahata},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {517-531},
+	Title = {Evolution of Hominoid Mitochondrial {DNA} with special Reference to the \\ Silent Substitution Rate over the Genome },
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 36,
+	Year = 1993}
+
+ at article{kondrashov02,
+	Author = {A.S. Kondrashov and S. Sunyaev and F.A.  Kondrashov},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {14878-14883},
+	Title = {Dobzhansky-{M}uller incompatibilities in protein evolution},
+	Volume = 99,
+	Year = 2002}
+
+ at article{kosiol04,
+	Author = {C. Kosiol and N. Goldman},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {193-199},
+	Title = {Different versions of the {D}ayhoff rate matrix},
+	Volume = {22},
+	Year = 2004}
+
+ at incollection{kruskal71,
+	Author = {J. B. Kruskal and Isidor Dyen and Paul Black},
+	Booktitle = {Mathematics in the archeological and     histor. sciences},
+	Editor = {F. R. Hodson and D. G. Kendall and P. Tautu},
+	Pages = {361-380},
+	Publisher = {Edinburgh University Press},
+	Title = {The vocabulary method of reconstructing language     trees: innovations and large-scale applications},
+	Utilisateur = {Gilles Caraux},
+	Year = 1971}
+
+ at article{kufels94,
+	Author = {M. Kuhner and J. Felsenstein},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {459-468},
+	Title = {A simulation comparison of phylogeny algorithms     under equal and unequal evolutionary rates},
+	Utilisateur = {Vincent},
+	Volume = 11,
+	Year = 1994}
+
+ at article{lanave84,
+	Author = {C. Lanave and G. Preparata and C. Saccone and G. Serio},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {86-93},
+	Title = {A new method for calculating evolutionary substitution rates},
+	Volume = 20,
+	Year = 1984}
+
+ at article{lake87,
+	Author = {James A. Lake},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {167-191},
+	Title = {A rate-independent technique for analysis of nucleic acid sequences : Evolutionary parsimony},
+	Utilisateur = {Gilles Caraux},
+	Volume = 4,
+	Year = 1987}
+
+ at article{langley74,
+	Author = {C. H. Langley and Walter M. Fitch},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {161-177},
+	Title = {An examination of the constancy of the rate of molecular evolution},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 3,
+	Year = 1974}
+
+ at article{lanyon85,
+	Author = {S. M. Lanyon},
+	Journal = {Systematic Zoology},
+	Number = 4,
+	Pages = {397-403},
+	Title = {Detecting internal inconsistencies in distance data},
+	Utilisateur = {Vincent},
+	Volume = 34,
+	Year = 1985}
+
+ at article{larget99,
+	Author = {B. Larget and D. L. Simon},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {750-759},
+	Title = {Markov Chain {M}onte {C}arlo algorithms for the bayesian analysis of phylogenetic trees},
+	Volume = 16,
+	Year = 1999}
+
+ at article{lartillot04,
+	Author = {N. Lartillot and H. Philippe},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1095-1109},
+	Title = {A Bayesian mixture model for across-site heterogeneities in the amino-acid replacement process},
+	Volume = 21,
+	Year = 2004}
+
+ at incollection{lausen86,
+	Author = {Berthold Lausen and Paul O. Degens},
+	Booktitle = {Die klassifikation und ihr umfeld},
+	Editor = {Paul O. Degens and H. J. Hermes and O. Opitz},
+	Pages = {306-314},
+	Publisher = {Indeks Verlag},
+	Series = {Studien zur Klassification},
+	Title = {Variance estimation and the reconstruction of phylogenies},
+	Utilisateur = {Gilles Caraux},
+	Volume = 17,
+	Year = 1986}
+
+ at incollection{lausen88,
+	Author = {Berthold Lausen and Paul O. Degens},
+	Booktitle = {Classification and related methods of data analysis},
+	Editor = {H. H. Bock},
+	Pages = {367-374},
+	Publisher = {Elsevier},
+	Title = {Evaluation of the reconstruction of phylogenies with {DNA-DNA}-Hybridization data},
+	Utilisateur = {Gilles Caraux},
+	Year = 1988}
+
+ at incollection{lausen89,
+	Author = {Berthold Lausen},
+	Booktitle = {Conceptual and numerical analysis of data},
+	Editor = {O. Opitz},
+	Pages = {481-488},
+	Publisher = {Springer Verlag},
+	Title = {Exploring homologous t{\sc rna} sequence data: positional mutation rates and genetic},
+	Utilisateur = {Gilles Caraux},
+	Year = 1989}
+
+ at article{lawrence97,
+	Author = {J. Lawrence and H. Ochman},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {383-397},
+	Title = {Amelioration of bacterial genomes: rates of change and exchange},
+	Volume = 44,
+	Year = 1997}
+
+ at article{lawrence98,
+	Author = {J. Lawrence and H. Ochman},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {9413-9417},
+	Title = {Molecular archaeology of the {\it \hbox{E}scherichia coli} genome},
+	Volume = 95,
+	Year = 1998}
+
+ at article{le08,
+	Author = {SQ. Le and O. Gascuel},
+	Journal = {Mol. Biol. Evol.},
+	Title = {An Improved General Amino-Acid Replacement Matrix},
+Volume = {25},
+Pages = {1307-1320},
+	Year = 2008}
+
+ at article{le_calve85,
+	Author = {Georges {Le Calve}},
+	Journal = {Statistiques et Analyse de Donn{\'e}es},
+	Number = 2,
+	Pages = {29-44},
+	Title = {Distance {\`a} centre},
+	Utilisateur = {Gilles Caraux},
+	Volume = 10,
+	Year = 1985}
+
+ at article{leclerc85a,
+	Author = {Bruno Leclerc},
+	Journal = {Math. Sci. hum.},
+	Pages = {5-40},
+	Title = {La comparaison des hierarchies : Indices et metriques},
+	Utilisateur = {Gilles Caraux},
+	Volume = 92,
+	Year = 1985}
+
+ at article{leclerc85b,
+	Author = {Bruno Leclerc},
+	Journal = {Math. Sci. hum.},
+	Pages = {5-34},
+	Title = {La hi{\'e}rarchies de parties et leur demi-treillis},
+	Utilisateur = {Gilles Caraux},
+	Volume = 89,
+	Year = 1985}
+
+ at article{leclerc94,
+	Author = {Bruno Leclerc},
+	Journal = {To appear in Journal of Classification},
+	Title = {Minimum spanning trees for tree metrics :     abridgements and adjustements},
+	Utilisateur = {Vincent},
+	Year = 1994}
+
+ at article{lecointre93,
+	Author = {G. Lecointre and H. Philippe      and H.L.V. L{\^e} and H. Le Guyader},
+	Journal = {Mol. Phylogenet. Evol.},
+	Pages = {205-224},
+	Title = {Species sampling has a major impact on      phylogenetic inference},
+	Volume = 2,
+	Year = 1993}
+
+ at article{lemmon02,
+	Author = {A. Lemmon and M. Milinkovitch},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {10516-10521},
+	Title = {The metapopulation genetic algorithm: an efficient solution for the problem of large phylogeny estimation},
+	Volume = 99,
+	Year = 2002}
+
+ at article{metapiga,
+	Author = {A.R. Lemmon and Milinkovitch M.C.},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {10516-10521},
+	Title = {The metapopulation genetic algorithm: An efficient solution for the problem of large phylogeny estimation},
+	Volume = 99,
+	Year = 2002}
+
+ at article{lee95,
+	Author = {Y. Lee and T. Ota and V. Vaquier},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {231-238},
+	Title = {Positive selection is a general phenomenon in the evolution of abalone sperm lysin},
+	Volume = 12,
+	Year = 1995}
+
+ at Article{lepage06,
+   Author="Lepage, T.  and Lawi, S.  and Tupper, P.  and Bryant, D. ",
+   Title="{{C}ontinuous and tractable models for the variation of evolutionary rates}",
+   Journal="Math Biosci",
+   Year="2006",
+   Volume="199",
+   Pages="216--233",
+   Month="Feb"
+}
+
+
+ at article{lepage07,
+	Author = {T. Lepage and D. Bryant and H. Philippe and N. Lartillot},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {2669-2680},
+	Title = {A general comparison of relaxed molecular clock models},
+	Volume = 24,
+	Year = 2007}
+
+ at article{lewis98,
+	Author = {P. Lewis},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {277-283},
+	Title = {A genetic algorithm for maximum likelihood phylogeny inference using nucleotide sequence data},
+	Volume = 15,
+	Year = 1998}
+
+ at article{lewontin89,
+	Author = {R. C. Lewontin},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {15-32},
+	Title = {Inferring the number of evolutionary events from                   {DNA} coding sequence differences},
+	Utilisateur = {Gilles Caraux},
+	Volume = 6,
+	Year = 1989}
+
+ at inproceedings{li87,
+	Author = {W.-H. Li and K.-H. Wolfe and J. Sourdis and P.M. Sharp},
+	Booktitle = {Cold Spring Harbor Symposia on Quantitative Biology},
+	Editor = {Cold Spring Harbore Laboratory},
+	Pages = {847-856},
+	Title = {Reconstruction of phylogenetic trees and estimation     of divergence times under nonconstant rates of evolution},
+	Volume = {LII},
+	Year = 1987}
+
+ at article{li89,
+	Author = {Wen-Hsiung Li},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {424-435},
+	Title = {A statistical test of phylogenies estimated from sequence data},
+	Utilisateur = {Gilles Caraux},
+	Volume = 6,
+	Year = 1989}
+
+ at incollection{li90,
+	Address = {New York},
+	Author = {Wen-Hsiung Li and Manolo Gouy},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 40,
+	Editor = {Russsell F. Doolittle},
+	Pages = {645-659},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Statistical Tests of Molecular Phylogenies},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at incollection{li91,
+	Author = {Wen-Hsiung Li and Manolo Gouy},
+	Booktitle = {Phylogenetic analysis of {DNA} sequences},
+	Chapter = 12,
+	Editor = {Michael M. Miyamoto and Joel Cracraft},
+	Pages = {249-277},
+	Publisher = {Oxford university press},
+	Title = {Statistical methods for testing molecular phylogenies},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Year = 1991}
+
+ at article{li92,
+	Author = {Wen-Hsiung Li and Bousquet, J},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1185-1189},
+	Title = {Relative-Rate test for nucleotide substitutions between two lineages},
+	Utilisateur = {G. Andrieu},
+	Volume = 9,
+	Year = 1992}
+
+ at article{li93,
+	Author = {Wen-Hsiung Li},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {96-99},
+	Title = { Unbiased estimation of the rates of synonimous  and nonsynonimous substitution},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 36,
+	Year = 1993}
+
+ at article{li94,
+	Author = {W.-H. Li and A. Zharkikh},
+	Journal = {Systematic Biology},
+	Pages = {424-430},
+	Title = {What is the bootstrap technique?},
+	Utilisateur = {Vincent},
+	Volume = 43,
+	Year = 1994}
+
+ at article{li95,
+	Author = {W.-H. Li and A. Zharkikh},
+	Journal = {Systematic Biology},
+	Pages = {49-63},
+	Title = {Statistical tests of {DNA} phylogenies},
+	Volume = 44,
+	Year = 1995}
+
+ at phdthesis{li96,
+	Author = {S. Li},
+	School = {Ohio State University},
+	Title = {Phylogenetic tree construction using {M}arkov chain {M}onte {C}arlo},
+	Year = 1996}
+
+ at article{lin02,
+	Author = {Y.-H. Lin and P. McLenachan and A. Gore and M. Phillips and R. Ota and M. Hendy and D. Penny},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {2060-2070},
+	Title = {Four new mitochondrial genomes, and the stability of evolutionary trees of mammals},
+	Volume = 19,
+	Year = 2002}
+
+ at article{lockhart94,
+	Author = {P. Lockhart and M. Steel and M. Hendy and D Penny},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {605-612},
+	Title = {Recovering Evolutionary Trees under a More Realistic Model of Sequence},
+	Volume = 11,
+	Year = 1994}
+
+ at article{lockhart98,
+	Author = {P. Lockhart and M. Steel and A. Barbrook and D. Huson and M. Charleston and C. Howe},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1183-1188},
+	Title = {A covariotide model explains apparent  phylogenetic structure of oxygenic photosynthetic lineages},
+	Volume = 15,
+	Year = 1998}
+
+ at article{lockhart00,
+	Author = {P. Lockhart and  D. Huson and U. Maier and M. Fraunholz and Y. Van de Peer and  A. Barbrook and C. Howe and M. Steel.},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {835-838},
+	Title = {How molecules evolve in eubacteria},
+	Volume = 17,
+	Year = 2000}
+
+ at article{lockhart05,
+	Author = {P. Lockhart and M. Steel},
+	Journal = {Systematic Biology},
+	Pages = {948-951},
+	Title = {A tale of two processes},
+	Volume = 54,
+	Year = 2005}
+
+ at article{lopez99,
+	Author = {P. Lopez and P. Forterre and H. Philippe},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {496-508},
+	Title = {The root of the tree of life in the light of the covarion model},
+	Volume = 49,
+	Year = 1999}
+
+ at article{lopez02,
+	Author = {P. Lopez and D. Casane and H. Philippe},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1-7},
+	Title = {Heterotachy, an important process of protein evolution},
+	Volume = 19,
+	Year = 2002}
+
+ at article{lundy,
+	Author = {M. Lundy},
+	Journal = {Biometrika},
+	Number = 1,
+	Pages = {191-198},
+	Title = {Applications of the annealing algorithm to combinatorial problems in statistics},
+	Utilisateur = {Gilles Caraux and Fernando Carvalho},
+	Volume = 72,
+	Year = 1985}
+
+ at article{lundy,
+	Author = {M. Lundy},
+	Journal = {Biometrika},
+	Number = 1,
+	Pages = {191-198},
+	Title = {Applications of the annealing algorithm to combinatorial problems in statistics},
+	Utilisateur = {Gilles Caraux and Fernando Carvalho},
+	Volume = 72,
+	Year = 1985}
+
+ at article{lynch00,
+	Author = {M. Lynch and J. Conery},
+	Journal = {Science},
+	Pages = {1151-1155},
+	Title = {The evolutionary fate and consequences of duplicated genes},
+	Volume = 290,
+	Year = 2000}
+
+ at article{lynch03,
+	Author = {M. Lynch and J. Conery},
+	Journal = {Journal of Structural and Functional Genomics},
+	Pages = {35-44},
+	Title = {The evolutionary demography of duplicate genes},
+	Volume = 3,
+	Year = 2003}
+
+ at article{lynch03b,
+	Author = {M. Lynch and J. Conery},
+	Journal = {Science},
+	Pages = {1401-1404},
+	Title = {The origins of genome complexity},
+	Volume = 302,
+	Year = 2003}
+
+ at article{lynch04,
+	Author = {M. Lynch and J. Conery},
+	Journal = {Science},
+	Pages = {978b},
+	Title = {Reponse to Comment on \"The origins of genome complexity\"},
+	Volume = 306,
+	Year = 2004}
+
+ at article{maddison91,
+	Author = {D. R. Maddison},
+	Journal = {Syst Zool},
+	Note = {interessant, grpes d'arbres relies entre eux},
+	Number = 3,
+	Pages = {315-328},
+	Title = {The discovery and importance of multiple islands of     most parsimonious trees},
+	Utilisateur = {Vincent},
+	Volume = 40,
+	Year = 1991}
+
+ at article{maddison97,
+	Author = {D. Maddison and D. Swofford and W. Maddison},
+	Journal = {Systematic Biology},
+	Volume = 46,
+	Number = 4,
+	Pages = {590-621},
+	Title = {{NEXUS}: an extensible file format for systematic information},
+	Year = 1997}
+
+
+ at article{maidak94,
+	Author = {B.L. Maidak and N. Larsen and M.J. McCaughey and R. Overbeek and G.J. Olsen and K. Fogel and J. Blandy and C.R. Woese},
+	Journal = { Nucl. Acids. Res},
+	Pages = {3485-3487},
+	Title = {The {R}ibosomal {D}atabase {P}roject},
+	Volume = 22,
+	Year = 1994}
+
+ at article{maidak96,
+	Author = {B.L. Maidak and G.J. Olsen and N. Larsen and R. Overbeek and M.J. McCaughey and C.R. Woese},
+	Journal = { Nucl. Acids. Res},
+	Pages = {82-85},
+	Title = {The {R}ibosomal {D}atabase {P}roject ({RDP})},
+	Volume = 24,
+	Year = 1996}
+
+ at article{maidak97,
+	Author = {B.L. Maidak and G.J. Olsen and N. Larsen and R. Overbeek and M.J. McCaughey and C.R. Woese},
+	Journal = { Nucl. Acids. Res},
+	Pages = {109-111},
+	Title = {The {RDP} ({R}ibosomal {D}atabase {P}roject)},
+	Volume = 25,
+	Year = 1997}
+
+ at article{maidak99,
+	Author = {B.L. Maidak and J.R. Cole and C.T. Parker and G.M. Garrity and N. Larsen and B. Li and T.G. Lilburn and M.J. McCaughey and  G.J. Olsen and R. Overbeek and S. Pramanik and T.M. Schmidt and J.M. Tiedje and CR Woese},
+	Journal = { Nucl. Acids. Res},
+	Pages = {171-173},
+	Title = {A new version of the {RDP} ({R}ibosomal {D}atabase {P}roject)},
+	Volume = 27,
+	Year = 1999}
+
+ at article{maidak00,
+	Author = {B. L. Maidak and J. R. Cole and T. G. Lilburn and C. T. Parker and P. R. Saxman and J. M. Stredwick and G. M. Garrity and B. Li and G. J. Olsen and S. Pramanik and T. M. Schmidt and J. M. Tiedje},
+	Journal = {Nucl. Acids. Res},
+	Pages = {173-174},
+	Title = {The {RDP} ({R}ibosomal {D}atabase {P}roject) continues},
+	Volume = 28,
+	Year = 2000}
+
+ at article{maidak01,
+	Author = {B. L. Maidak and J. R. Cole and T. G. Lilburn and C. T. Parker and P. R. Saxman and                    R. J. Farris and G. M. Garrity and G. J. Olsen and T. M. Schmidt and J. M. Tiedje},
+	Journal = {Nucl. Acids. Res},
+	Pages = {173-174},
+	Title = {The {RDP}-II ({R}ibosomal {D}atabase {P}roject)},
+	Volume = 29,
+	Year = 2001}
+
+ at article{manske87,
+	Author = { Charles L. Manske and David J. Chapman},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {226-251},
+	Title = {Nonuniformity of Nucleotide Substitution Rates in Molecular Evolution:  Computer Simulation and Analysis of 5S Ribosomal Sequences},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 26,
+	Year = 1987}
+
+ at article{margush81,
+	Author = {T. Margush and F.R. McMorris},
+	Journal = {Bulletin of Math. Biol.},
+	Number = 2,
+	Pages = {239-244},
+	Title = {Consensus n-trees},
+	Volume = 43,
+	Year = 1981}
+
+ at article{massingham05,
+  title={Detecting amino acid sites under positive selection and purifying selection},
+  author={Massingham, Tim and Goldman, Nick},
+  journal={Genetics},
+  volume={169},
+  number={3},
+  pages={1753--1762},
+  year={2005},
+  publisher={Genetics Soc America}
+}
+
+ at phdthesis{mau96,
+	Author = {B. Mau},
+	School = {Wiscontin University},
+	Title = {Bayesian phylogenetic inference via Markov Chain {M}onte {C}arlo methods},
+	Year = 1996}
+
+ at article{meacham81,
+	Author = {C. Meacham},
+	Journal = {Taxon},
+	Pages = {591-600},
+	Title = {A manual method for character compatibility},
+	Volume = 30,
+	Year = 1981}
+
+ at article{metropolis53,
+	Author = {N. Metropolis and A.W. Rosenbluth and M.N. Rosenbluth and A.H. Teller and E. Teller},
+	Journal = {J. of Chem. Phys.},
+	Pages = {1087-1092},
+	Title = {Equation of State Calculations by Fast Computing Machines},
+	Volume = 21,
+	Year = 1953}
+
+ at article{messier97,
+	Author = {W. Messier and C.-B. Stewart},
+	Journal = {Nature},
+	Pages = {151-154},
+	Title = {Episodic adaptative evolution of primate lysozymes},
+	Volume = 385,
+	Year = 1997}
+
+ at article{misof02,
+	Author = {B. Misof and C. Anderson and T. Buckley and D. Erpenbeck and A. Rickert and K. Misof},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {330-340},
+	Title = {An empirical analysis of mt 16S r{RNA} covarion-like evolution  in insects: site-specific rate variation is clustered and frequently  detected},
+	Volume = 56,
+	Year = 2002}
+
+ at article{mitchison95,
+	Author = {G. Mitchison and R. Durbin},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {1139-1151},
+	Title = {Tree-based maximum likelihood substitution matrices and hidden Markov model},
+	Volume = 41,
+	Year = 1995}
+
+ at book{miyamoto91,
+	Address = {New York - Oxford},
+	Editor = {Michael M. Miyamoto and Joel Cracraft},
+	Publisher = {Oxford University Press},
+	Title = {{P}hylogenic {A}nalysis of {DNA} {S}equences},
+	Utilisateur = {Guillaume Andrieu},
+	Year = 1991}
+
+ at article{miyata81,
+	Author = { Takashi Miyata and Teruo Yasunaga},
+	Journal = {Genetics},
+	Pages = {641-657},
+	Title = {Molecular Evolution of m{RNA} : A Method for estimating  Evolutionary Rates of Synonymous and Amino Acid Substitutions from Homologous Nucleotide Sequences and its Application },
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 98,
+	Year = 1981}
+
+ at book{mood,
+	Address = {Paris},
+	Author = {Alexander Mood et Franklin A. Graybill},
+	Publisher = {Dunod},
+	Title = {Introduction a la {S}tatistique {T}heorique},
+	Year = 1973}
+
+ at article{moore73,
+	Author = {G. W. Moore, J. Barnabas, M. Goodman},
+	Journal = {Journal of Theoretical Biology},
+	Pages = {459-485},
+	Title = {A Method For Constructing Maximum Parsimony     Ancestral Amino Acid Sequences on a Given Network},
+	Volume = 38,
+	Year = 1973}
+
+ at techreport{moulton96,
+	Author = {V. Moulton and M.A. Steel},
+	Institution = {Univ. of Canterbury},
+	Number = 148,
+	Title = {Retractions of finite distance functions onto tree metrics},
+	Year = 1996}
+
+ at article{muller00,
+	Author = {T. Muller and M. Vingron},
+	Journal = {Journal of Computational Biology},
+	Pages = {761-776},
+	Title = {Modeling amino acid replacement.},
+	Volume = 7,
+	Year = 2000}
+
+ at article{mullis87,
+	Author = {K.B. Mullis and F.A. Faloona},
+	Journal = {Methods. in Enzym.},
+	Pages = {335-350},
+	Title = {Specific synthesis of {DNA} in vitro via polymerase                    catalyzed chained reaction},
+	Volume = 155,
+	Year = 1987}
+
+ at article{murphy01,
+	Author = {W. J. Murphy and E. Eizirik and W. E. Johnson and Zhang Y.P. and O.A. Ryder and S.J. O'Brien},
+	Journal = {Nature},
+	Pages = {614-618},
+	Title = {Molecular phylogenetics and the origins of placental mammals},
+	Volume = 409,
+	Year = 2001}
+
+ at article{murphy01b,
+	Author = {M. Murphy and E. Eizirik and S. O'Brien and O. Madsen and M. Scally and C. Douady and E. Teeling and O. Ryder and M. Stanhope and W. de Jong and M. Springer},
+	Journal = {Science},
+	Pages = {2348-2351},
+	Title = {Resolution of the early placental mammal radiation using Bayesian phylogenetics},
+	Volume = 294,
+	Year = 2001}
+
+ at article{muse94,
+	Author = {S. Muse and B. Gaut},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {715-724},
+	Title = {A likelihood approach for comparing synonymous and nonsynonymous nucleotide substitution rates, with application to the chloroplast genome},
+	Volume = 11,
+	Year = 1994}
+
+ at incollection{muse95,
+	Address = {Penn. State Univ.},
+	Author = {S. V. Muse},
+	Booktitle = {Current Topics on Molecular Evolution},
+	Editor = {M. Nei and N. Takahata},
+	Pages = {115-124},
+	Publisher = {University Park},
+	Title = {Evolutionary analyses when nucleotides do not evolve independently},
+	Year = 1995}
+
+ at article{muse95b,
+	Author = {S. Muse},
+	Journal = {Genetics},
+	Pages = {1429-1439},
+	Title = {Evolutionary analyses of {DNA} sequences subject to constraints on secondary structure},
+	Volume = 139,
+	Year = 1995}
+
+ at article{otha93,
+	Author = {T. Ohta},
+	Journal = {Genetics},
+	Pages = {1271-1276},
+	Title = {Pattern of nucleotide substitutions in growth hormone-prolactin gene family: a paradigm for evolution by gene duplication},
+	Volume = 134,
+	Year = 1993}
+
+ at article{navidi91,
+	Author = {W. C. Navidi and G. A. Churchill and A. von Haeseler},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {128-143},
+	Title = {Methods for infering phylogenies from nucleic acid sequence data by using maximum likelihood and linear invariants},
+	Utilisateur = {Gilles Caraux},
+	Volume = 8,
+	Year = 1991}
+
+ at article{navidi92,
+	Author = {W. C. Navidi and L. Beckett-Lemus},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1163-1175},
+	Title = {The effect of unequal transversion rates on the accuracy of evolutionary parsimony},
+	Utilisateur = {Gilles Caraux},
+	Volume = 9,
+	Year = 1992}
+
+ at article{needleman70,
+	Author = {S. G. Needleman and C. D. Wunsch},
+	Journal = {Journal of Molecular Biology},
+	Pages = {443-453},
+	Title = {A general method applicable to the search for similarities in the amino acid sequence of two proteins},
+	Volume = 48,
+	Year = 1970}
+
+ at article{nei79,
+	Author = {Masatoshi Nei and Wen Hsiung Li},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Number = 10,
+	Pages = {5269-5273},
+	Title = {Mathematical model for studying genetic variation in terms of restriction endonucleases},
+	Utilisateur = {Gilles Caraux},
+	Volume = 76,
+	Year = 1979}
+
+ at article{nei81,
+	Author = {Masatoshi Nei and Fumo Tajima},
+	Journal = {Genetics},
+	Pages = {145-163},
+	Title = {{DNA} polymorphism detectable by restriction endonucleases},
+	Utilisateur = {Gilles Caraux},
+	Volume = 97,
+	Year = 1981}
+
+ at article{nei85,
+	Author = {M. Nei and J. C. Stephens and N. Saitou},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {66-85},
+	Title = {Methods for computing the standard errors of branching points in an                    evolutionary tree and their application to molecular data from humans and apes},
+	Volume = 2,
+	Year = 1985}
+
+ at article{nei86,
+	Author = {M. Nei and T. Gojobori},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {418-426},
+	Title = {Simple methods for estimating the number of synonymous and nonsynonymous nucleotide substitutions},
+	Volume = 3,
+	Year = 1986}
+
+ at article{nei89,
+	Author = {Masatoshi Nei and L. Jin},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {290-300},
+	Title = {Variance of the averages numbers of substitutions within and between populations},
+	Utilisateur = {Ne Obt},
+	Volume = 6,
+	Year = 1989}
+
+ at incollection{nei91,
+	Author = {M. Nei},
+	Booktitle = {Phylogenetic analysis of {DNA} sequences},
+	Editor = {M.M. Miyamoto and J. Cracraft},
+	Publisher = {Oxford Univ. Press},
+	Title = {Relative efficiencies of different tree-making     methods for molecular data},
+	Year = 1991}
+
+ at article{nei92,
+	Author = {Masatoshi Nei},
+	Journal = {Molecular Biology and Evolution},
+	Number = 6,
+	Pages = {1176-1178},
+	Title = {Age of the common ancestor of Human Mitochondrial {DNA}},
+	Utilisateur = {Gilles Caraux},
+	Volume = 9,
+	Year = 1992}
+
+ at article{newton04,
+	Author = {M. Newton and A. Noueiry and D. Sarkar and P. Ahlquist},
+	Journal = {Biostatistics},
+	Pages = {155-176},
+	Title = {Detecting differential expression with a semiparametric hierarchical mixture method},
+	Volume = 5,
+	Year = 2004}
+
+ at article{nielsen98,
+	Author = {R. Nielsen and Z. Yang},
+	Journal = {Genetics},
+	Pages = {929-936},
+	Title = {Likelihood models for detecting positively selected amino acid sites and application to the {HIV}-1 envelope gene},
+	Volume = 148,
+	Year = 1998}
+
+ at book{nutall04,
+	Address = {Cambridge},
+	Author = {G.H.F. Nutall},
+	Publisher = {Cambridge Univ. Press},
+	Title = {Blood immunity and blood relationship},
+	Year = 1904}
+
+ at book{nr,
+	Address = {Cambridge},
+	Author = {W. Press and B. Flannery and S. Teukolsky and W. Vetterling},
+	Publisher = {Press Syndicate of the University of Cambridge},
+	Title = {Numerical Recipes in C.},
+	Year = 1988}
+
+ at article{olsen94,
+	Author = {G. Olsen and H. Matsuda and R. Hagstrom and R. Overbeek},
+	Journal = {Computer Applications in the Biosciences (CABIOS)},
+	Pages = {41-48},
+	Title = {{fastDNAml}: a tool for construction of phylogenetic trees of {DNA} sequences using maximum likelihood},
+	Volume = 10,
+	Year = 1994}
+
+ at article{fastdnaml,
+	Author = {G. J. Olsen and H. Matsuda and R. Hagstrom and R. Overbeek},
+	Journal = {Computer Applications in the Biosciences (CABIOS)},
+	Pages = {41-48},
+	Title = {{fastDNAml}: a tool for construction of phylogenetic trees of {DNA} sequences using maximum likelihood},
+	Volume = 10,
+	Year = 1994}
+
+ at incollection{neyman71,
+	Address = {New York},
+	Author = {J. Neyman},
+	Booktitle = {Statistical decision theory and related topics},
+	Editor = {S. Gupta and J. Yackel},
+	Pages = {1-27},
+	Publisher = {Academic Press},
+	Title = {Molecular studies of evolution: a source of novel statistical problems},
+	Year = 1971}
+
+ at article{ota00,
+	Author = {S. Ota and W.-H. Li},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1401-1409},
+	Title = {{NJML}: a Hybrid Algorithm for the Neighbor-Joining and Maximum-Likelihood Methods},
+	Volume = 17,
+	Year = 2000}
+
+ at article{ota01,
+	Author = {S. Ota and W.-H. Li},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1983-1992},
+	Title = {{NJML+}: an extension of the {NJML} method to handle protein sequence data and computer software implementation},
+	Volume = 18,
+	Year = 2001}
+
+ at article{ota00b,
+	Author = {R. Ota and P. Waddell and M. Hasegawa and H. Shimodaira and H. Kishino},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {798-803},
+	Title = {Appropriate likelihood ratio tests and marginal distribution for evolutionary tree models with constraints on parameters},
+	Volume = 17,
+	Year = 2000}
+
+ at article{otto00,
+	Author = {S. Otto and J. Whitton},
+	Journal = {Annual Review of Genetics},
+	Pages = {401-437},
+	Title = {Polyploid incidence and evolution},
+	Volume = 34,
+	Year = 2000}
+
+ at book{page98,
+	Address = {Osney Mead, Oxford},
+	Author = {Roderick Page and Eward Holmes},
+	Publisher = {Blackwell Science Ltd},
+	Title = {Molecular Evolution: a phylogenetic approach},
+	Year = 1998}
+
+ at article{pauplin00,
+	Author = {Y. Pauplin},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {41-47},
+	Title = {Direct calculation of a tree length using a distance matrix},
+	Volume = 51,
+	Year = 2000}
+
+ at article{penny87,
+	Author = {David Penny and Michael D. Hendy and I. M. Henderson},
+	Journal = {Cold Spring Harbor Symposia on Quantitative Biology},
+	Pages = {857-862},
+	Title = {Reliability of Evolutionary Trees},
+	Utilisateur = {Gilles Caraux},
+	Volume = 52,
+	Year = 1987}
+
+ at incollection{penny91,
+	Author = {D. Penny and M.D. Hendy and M.A. Steel},
+	Booktitle = {Phylogenetic analysis of {DNA} sequences},
+	Editor = {M. M. Miyamoto and J. Cracraft},
+	Pages = {155-183},
+	Title = {Testing the theory of descent},
+	Year = 1991}
+
+ at article{penny92,
+	Author = {David Penny and Michael D. Hendy and Michael A. Steel},
+	Journal = {Tree},
+	Pages = {73-78},
+	Title = {Progress with Methods for Constructing Evolutionary Trees},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu or Vincent},
+	Volume = 7,
+	Year = 1992}
+
+ at article{penny01,
+	Author = {D. Penny and B. McComish and M. Charleston and M. Hendy},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {711-723},
+	Title = {Mathematical elegance with biochemical realism: the covarion model of molecular evolution},
+	Volume = 53,
+	Year = 2001}
+
+ at article{hobacgen,
+	Author = {G. Perri{\`e}re and L. Duret and M. Gouy},
+	Journal = {Genome Research},
+	Pages = {379-385},
+	Title = {{HOBACGEN}: database system for comparative genomics in bacteria},
+	Volume = 10,
+	Year = 2000}
+
+ at article{hovergen,
+	Author = {L. Duret and D. Mouchiroud and M. Gouy},
+	Journal = {Nucleic Acids Research},
+	Pages = {2360-2365},
+	Title = {{HOVERGEN}, a database of homologous vertebrate genes},
+	Volume = 22,
+	Year = 1994}
+
+ at article{li85,
+	Author = {W.-H. Li and C.-I Wu and C.-C Luo},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {150-174},
+	Title = {A new method for estimating synonymous and non-synonymous rates of nucleotide substitutions considering the relative likelihood of nucleotide and codon changes},
+	Volume = 2,
+	Year = 1985}
+
+ at article{pagel04,
+	Author = {M. Pagel and A. Meade},
+	Journal = {Systematic Biology},
+	Pages = {571-581},
+	Title = {A phylogenetic mixture model for detecting pattern-heterogeneity in gene sequence or character-state data},
+	Volume = 53,
+	Year = 2004}
+
+ at article{phillips02,
+	Author = {M. Phillips and D. Penny},
+	Journal = {Molecular Phylogenetics and Evolution},
+	Pages = {171-185},
+	Title = {The root of the mammalian tree inferred from whole mitochondrial genomes},
+	Volume = 28,
+	Year = 2002}
+
+ at article{philippe97,
+	Author = {H. Philippe},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {712-715},
+	Title = {Rodent monophyly: pitfalls of molecular phylogenies},
+	Volume = 45,
+	Year = 1997}
+
+ at article{philippe00,
+	Author = {H. Philippe and P. Lopez and H. Brinkman and K. Budin and A. Germot and J. Laurent and D. Moreira and M. Muller and H. Le Guyader},
+	Journal = {Proceeding of the Royal Society B: Biological Sciences},
+	Pages = {1213-1221},
+	Title = {Early branching or fast evolving eukaryotes ? An answer based on slowly evolving positions},
+	Volume = 267,
+	Year = 2000}
+
+ at article{philippe00b,
+	Author = {H. Philippe},
+	Journal = {Protist},
+	Pages = {307-316},
+	Title = {Opinion : long branch attraction and protist phylogeny},
+	Volume = 151,
+	Year = 2000}
+
+ at article{philippe05,
+	Author = {H. Philippe and Y. Zhou and H. Brinkmann and N. Rodrigue and F. Delsuc},
+	Journal = {BMC Evolutionary Biology},
+	Pages = {http://www.biomedcentral.com/1471-2148/5/50},
+	Title = {Heterotachy and long-branch attraction in phylogenetics},
+	Year = 2005}
+
+ at article{pollock99,
+	Author = {D. Pollock and W. Taylor and N. Goldman},
+	Journal = {Journal of Molecular Biology},
+	Pages = {187-198},
+	Title = {Co-evolving protein residues: maximum likelihood analysis and relationship to structure},
+	Volume = 287,
+	Year = 1999}
+
+ at article{posada98,
+	Author = {D. Posada and K. Crandall},
+	Journal = {Bioinformatics},
+	Pages = {817-918},
+	Title = {Modeltest: testing the model of {DNA} substitution},
+	Volume = 14,
+	Year = 1998}
+
+ at article{posada01,
+  title={Selecting models of nucleotide substitution: an application to human immunodeficiency virus 1 (HIV-1)},
+  author={Posada, D. and Crandall, K.A.},
+  journal={Molecular Biology and Evolution},
+  volume={18},
+  number={6},
+  pages={897--906},
+  year={2001},
+  publisher={SMBE}
+}
+
+ at Article{poux06,
+   Author="Poux, C.  and Chevret, P.  and Huchon, D.  and de Jong, W. W.  and Douzery, E. J. ",
+   Title="{{A}rrival and diversification of caviomorph rodents and platyrrhine primates in {S}outh {A}merica}",
+   Journal="Syst. Biol.",
+   Year="2006",
+   Volume="55",
+   Pages="228--244",
+   Month="Apr"
+}
+
+
+ at techreport{prum92,
+	Author = {Bernard Prum and Fran{{\c C}}ois Rodolphe and Elisabeth     de Turckheim},
+	Institution = {INRA},
+	Month = {October},
+	Note = {{I}nfluence du {V}oisinage sur l'{E}volution d'une     {S{\'e}}quence d'{ADN}},
+	Title = {{F}inding words with unexpected frequencies in     {DNA} sequences},
+	Year = {1992}}
+
+ at article{pupko02,
+	Author = {T. Pupko and N. Galtier},
+	Journal = {Proceedings of The Royal Society B: Biological Sciences},
+	Pages = {1313-1316},
+	Title = {A covarion-based method for detecting molecular adaptation: application to the evolution of primate mitochondrial genomes},
+	Volume = 269,
+	Year = 2002}
+
+ at article{purvis97,
+	Author = {A. Purvis and D. L. J. Quicke},
+	Journal = {Trends in Ecology and Evolution},
+	Number = 2,
+	Pages = {49-50},
+	Title = {Building phylogenies: are the big easy ?},
+	Volume = 12,
+	Year = 1997}
+
+ at article{qu83,
+	Author = {L.H. Qu and B. Michot and J.P. Bachellerie},
+	Journal = {Nucleic Acids Research},
+	Pages = {5903-5920},
+	Title = {Improved methods for structure probing in large                   RNAs: a rapid heterologous sequencing approach                   is coupled to the direct mapping of nuclease accessible                   sites. Application to the 5' terminal domain of eukaryotic},
+	Volume = 11,
+	Year = 1983}
+
+ at article{quesenberry64,
+	Author = {C. P. Quesenberry and D. C. Hurst},
+	Journal = {Technometrics},
+	Month = {MAY},
+	Number = 2,
+	Pages = {191-195},
+	Title = {Large Sample Simultaneous Confidence Intervals for     Multinomial Proportions },
+	Volume = 6,
+	Year = 1964}
+
+ at article{rannala96,
+	Author = {B. Rannala and Z. Yang},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {304-311},
+	Title = {Probability distribution of molecular evolutionary trees: a new method of phylogenetic inference},
+	Volume = {43},
+	Year = 1996}
+
+ at Article{rannala07,
+   Author="Rannala, B.  and Yang, Z. ",
+   Title="{{I}nferring speciation times under an episodic molecular clock}",
+   Journal="Syst. Biol.",
+   Year="2007",
+   Volume="56",
+   Pages="453--466",
+   Month="Jun"
+}
+
+ at article{ranwez01,
+	Author = {V. Ranwez and O. Gascuel},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1103-11016},
+	Title = {Quartet-based phylogenetic inference: improvements and limits.},
+	Volume = {18},
+	Year = 2001}
+
+ at article{ranwez02,
+	Author = {V. Ranwez and O. Gascuel},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1952-1963},
+	Title = {Improvement of Distance-Based Phylogenetic Methods by a Local Maximum Likelihood Approach Using Triplets},
+	Volume = {19},
+	Year = 2002}
+
+ at article{rasmol,
+	Author = {R. Sayle and J. Milner-White},
+	Journal = {Trends in Biochemical Sciences},
+	Pages = {374},
+	Title = {{R}as{M}ol: Biomolecular graphics for all},
+	Volume = {20},
+	Year = 1995}
+
+ at phdthesis{ranwezthese,
+	Author = {V. Ranwez},
+	School = {Universit{\'e} Montpellier II},
+	Title = {M{\'e}thodes efficaces pour reconstruire des phylog{\'e}nies suivant le principe du maximum de vraisemblance},
+	Year = 2002}
+
+ at article{rdp,
+	Author = {B. L. Maidak and J.R. Cole and T.G. Lilburn and C.T. Parker Jr. and P.R. Saxman and R.J. Farris and G.M. Garrity and G.J. Olsen and T.M. Schmidt and J.M. Tiedje},
+	Journal = {Nucleic Acids Research},
+	Pages = {173-174},
+	Title = {The {RDP}-II ({R}ibosomal {D}atabase {P}roject)},
+	Volume = {29},
+	Year = 2001}
+
+ at article{ren05,
+	Author = {F. Ren and H. Tanaka and Z. Yang},
+	Journal = {Systematic Biology},
+	Pages = {808-818},
+	Title = {An empirical examination of the utility of codon-substitution models in phylogeny reconstruction},
+	Volume = 54,
+	Year = 2005}
+
+ at book{renyi66,
+	Address = {Paris},
+	Author = {A. Renyi},
+	Publisher = {Dunod},
+	Title = {{C}alcul des {P}robabilites},
+	Year = 1966}
+
+ at article{reyes98,
+	Author = {A. Reyes and G. Pesole and C. Saccone},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {499-505},
+	Title = {Complete mitochondrial {DNA} sequence of the fat dormouse, {G}lis glis: further evidence of rodent paraphyly},
+	Volume = {15},
+	Year = {1998}}
+
+ at article{reyes00,
+	Author = {A. Reyes and G. Pesole and C. Saccone},
+	Journal = {Gene},
+	Pages = {177-187},
+	Title = {Long-branch attraction phenomenon and the impact of among-site rate variation on rodent phylogeny},
+	Volume = {259},
+	Year = {2000}}
+
+ at article{reyes04,
+	Author = {A. Reyes and C. Gissi and F. Catzeflis and E. Nevo and G. Pesole and C. Saccone},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {397-403},
+	Title = {Congruent mammalian trees from mitochondrial and nuclear genes using Bayesian methods},
+	Volume = {21},
+	Year = {2004}}
+
+ at article{rice97,
+	Author = {K. Rice and M. J. Donoghue and R. G. Olmstead},
+	Journal = {Systematic Biology},
+	Pages = {554-563},
+	Title = {Analyzing large data sets: {\it rbcL} 500 revisited},
+	Volume = {46},
+	Year = {1997}}
+
+
+
+
+ at article{robinson71,
+	Author = {D. Robinson},
+	Journal = {J. Combinatorial Theory Ser B},
+	Pages = {105-119},
+	Title = {Comparison of labeled trees with valency three},
+	Utilisateur = {Gilles Caraux},
+	Volume = 11,
+	Year = 1971}
+
+ at incollection{robinson79,
+	Address = {Berlin},
+	Author = {D. Robinson and L. Foulds},
+	Booktitle = {Lectures Notes in Mathematics},
+	Pages = {119-126},
+	Publisher = {Springer},
+	Title = {Comparison of weighted labeled trees},
+	Utilisateur = {Gilles Caraux},
+	Volume = 748,
+	Year = 1979}
+
+ at article{robinson81,
+	Author = {D. F. Robinson and L. R. Foulds},
+	Journal = {Mathematical Biosciences},
+	Pages = {131-147},
+	Title = {Comparison of phylogenetic trees},
+	Utilisateur = {Gilles Caraux et Vincent},
+	Volume = 53,
+	Year = 1981}
+
+ at Article{robinson98,
+   Author="Robinson, M.  and Gouy, M.  and Gautier, C.  and Mouchiroud, D. ",
+   Title="{{S}ensitivity of the relative-rate test to taxonomic sampling}",
+   Journal="Mol. Biol. Evol.",
+   Year="1998",
+   Volume="15",
+   Pages="1091--1098",
+   Month="Sep"
+}
+
+ at article{gharib13,
+  title={The branch-site test of positive selection is surprisingly robust but lacks power under synonymous substitution saturation and variation in {GC}},
+  author={Gharib, Walid H and Robinson-Rechavi, Marc},
+  journal={Molecular Biology and Evolution},
+  volume={30},
+  number={7},
+  pages={1675--1686},
+  year={2013},
+  publisher={SMBE}
+}
+
+
+ at article{zhang05,
+  title={Evaluation of an improved branch-site likelihood method for detecting positive selection at the molecular level},
+  author={Zhang, J. and Nielsen, R. and Yang, Z.},
+  journal={Molecular Biology and Evolution},
+  volume={22},
+  number={12},
+  pages={2472--2479},
+  year={2005},
+  publisher={SMBE}
+}
+
+
+ at incollection{rodrigo01,
+	Address = {Boston, Mass.},
+	Author = {A. Rodrigo and E. Hanley and P. Goracke and G. Learn},
+	Booktitle = {Computational and evolutionary analysis of HIV molecular sequences},
+	Editor = {A. Rodrigo and G. Learn},
+	Pages = {1-17},
+	Publisher = {Kluwer Academic Publishers},
+	Title = {Sampling and processing {HIV} molecular sequences : a computatinal evolutionary biologist's perspective},
+	Year = 2001}
+
+ at article{rodriguez90,
+	Author = {F. Rodriguez and J. L. Olivier and A. Marin and J. R. Medina},
+	Journal = {Journal of Theoretical Biology},
+	Pages = {485-501},
+	Title = {The general stochastic model of nucleotide substitution},
+	Volume = 142,
+	Year = 1990}
+
+ at article{rodriguez03,
+	Author = {F. Rodriguez-Trelles and R. Tarrio and F. Ayala},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {13413-13417},
+	Title = {Convergent neofunctionalization by positive Darwinian selection after ancient recurrent duplications of the xanthine dehydrogenase gene},
+	Volume = {100},
+	Year = {2003}}
+
+ at article{rogers99,
+	Author = {J. Rogers and D. Swofford},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1079-1085},
+	Title = {Multiple local maxima for likelihoods of phylogenetic trees: a simulation study},
+	Volume = {16},
+	Year = {1999}}
+
+ at article{rohlf74,
+	Author = {F. James Rohlf},
+	Journal = {Annual Review of Ecology and Systematics},
+	Pages = {101-113},
+	Title = {Methods of comparing classifications},
+	Utilisateur = {Gilles Caraux},
+	Volume = 5,
+	Year = 1974}
+
+ at article{rosenberg01,
+	Author = {M. Rosenberg and S. Kumar},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1823-1827},
+	Title = {Traditional phylogenetic reconstruction methods reconstruct shallow and deep evolutionary relationship equally well},
+	Volume = 19,
+	Year = 2001}
+
+ at article{ross02,
+	Author = {H. Ross and A. Rodrigo},
+	Journal = {Journal of Virology},
+	Pages = {11715-11720},
+	Title = {Immune-mediated positive selection drives human immunodeficiency virus type 1 molecular variation and predicts disease duration},
+	Volume = 76,
+	Year = 2002}
+
+ at book{ruegg,
+	Address = {Lausanne},
+	Author = {Alan Ruegg},
+	Publisher = {Presses polytechniques romandes},
+	Series = {Methodes mathematiques pour l'ingenieur},
+	Title = {Processus Stochastiques},
+	Year = 1989}
+
+
+ at Article{rutschmann07,
+   Author="Rutschmann, F.  and Eriksson, T.  and Salim, K. A.  and Conti, E. ",
+   Title="{{A}ssessing calibration uncertainty in molecular dating: the assignment of fossils to alternative calibration points}",
+   Journal="Syst. Biol.",
+   Year="2007",
+   Volume="56",
+   Pages="591--608",
+   Month="Aug"
+}
+
+ at incollection{gascuel07,
+  Title={Modelling the variability of evolutionary processes},
+  Author={Gascuel, O. and Guindon, S.},
+  Editor={Olivier Gascuel and Mike Steel},
+  Booktitle={Reconstructing Evolution: new mathematical and computational advances},
+  Pages={65--99},
+  Publisher={Oxford University Press},
+  Year={2007}
+}
+
+ at article{slatkin91,
+  title={Pairwise comparisons of mitochondrial DNA sequences in stable and exponentially growing populations.},
+  author={M. Slatkin and R. R. Hudson},
+  journal={Genetics},
+  volume={129},
+  number={2},
+  pages={555--562},
+  year={1991},
+  publisher={Genetics Soc America}
+}
+
+
+ at article{rzhetsky92a,
+	Author = {Andrey Rzhetsky and Masatoshi Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {945-967},
+	Title = {A simple method for estimating and testing minimum-evolution trees},
+	Utilisateur = {Olivier Gascuel et Guillaume Andrieu},
+	Volume = 9,
+	Year = 1992}
+
+ at article{rzhetsky92b,
+	Author = {Andrey Rzhetsky and Masatoshi Nei },
+	Journal = {Journal of Molecular Evolution},
+	Pages = {367-375},
+	Title = {Statistical Properties of the Ordinary Least-Squares, Generalized Least-Squares,  and Minimum-Evolution Methods of Phylogenetic Inference},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 35,
+	Year = 1992}
+
+ at article{rzhetsky93,
+	Author = {A. Rzhetsky and M. Nei },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1073-1095},
+	Title = {Theoretical foundation of the minimum-evolution method of phylogenetic inference},
+	Volume = 10,
+	Year = 1993}
+
+ at article{rzhetsky94,
+	Author = {A. Rzhetsky and M. Nei},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {295-299},
+	Title = {Unbiaised estimates of the number of nucleotide substitutions when substitution rate varies among different sites},
+	Volume = 38,
+	Year = 1994}
+
+ at article{rzhetsky95,
+	Author = {A. Rzhetsky and S. Kumar and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {163-167},
+	Title = {Four-cluster analysis: a simple method to test phylogenetic                    hypotheses},
+	Volume = 12,
+	Year = 1995}
+
+ at article{rzhetsky95b,
+	Author = {A. Rzhetsky},
+	Journal = {Genetics.},
+	Number = 2,
+	Pages = {771-83},
+	Title = {Estimating substitution rates in ribosomal RNA genes},
+	Volume = 141,
+	Year = 1995}
+
+ at article{rzhetsky96,
+	Author = {A. Rzhetsky and T. Sitnikova},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1255-1265},
+	Title = {When is it Safe to use an Oversimplified Substitution Model in Tree-Making?},
+	Volume = 13,
+	Year = 1996}
+
+ at incollection{saccone90,
+	Address = {New York},
+	Author = {Cecilia Saccone and Cecilia Lanave and Graziano Pesole and Giuliano Preperata  },
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 35,
+	Editor = {Russsell F. Doolittle},
+	Pages = {570-583},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Influence of Base Composition on Quantitative Estimates of Gene Evolution},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at article{saccone91,
+	Author = {Cecilia Saccone and Graziano Pesole and Elisabetta Sbis\'{a} },
+	Journal = {Journal of Molecular Evolution},
+	Pages = {88-91},
+	Title = {the main regulatory region of mammalian mitochondria {DNA} : Stucture -function model and evilutionary pattern},
+	Utilisateur = {G. Andrieu},
+	Volume = 33,
+	Year = 1991}
+
+ at article{saitou87,
+	Author = {N. Saitou and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {406-425},
+	Title = {The neighbor-joining method: a new method for reconstructing phylogenetic trees},
+	Volume = 4,
+	Year = 1987}
+
+ at article{nj,
+	Author = {N. Saitou and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {406-425},
+	Title = {The neighbor-joining method: A new method for reconstruction phylogenetic trees},
+	Utilisateur = {Gilles Caraux},
+	Volume = 4,
+	Year = 1987}
+
+ at article{saitou88,
+	Author = {N. Saitou},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {261-273},
+	Title = {Property and efficiency of the maximum likelihood     method for molecular phylogeny},
+	Utilisateur = {Gilles Caraux},
+	Volume = 27,
+	Year = 1988}
+
+ at article{saitou89,
+	Author = {N. Saitou and T. Imanishi},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {514-525},
+	Title = {Relative efficiencies of the {F}itch-{M}argoliash,     {M}aximum-{P}arsimony, {M}aximum-{L}ikelihood,     {M}inimum-{E}volution, and {N}eighbor-{J}oining methods of     phylogenetic tree construction in obtaining the     correct tree},
+	Volume = 6,
+	Year = 1989}
+
+ at incollection{saitou90,
+	Address = {New York},
+	Author = {N. Saitou},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acid sequences},
+	Chapter = 36,
+	Editor = {Russsell F. Doolittle},
+	Pages = {584-598},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Maximum Likelihood Methods},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 183,
+	Year = 1990}
+
+ at incollection{saitou91,
+	Author = {N. Saitou},
+	Booktitle = {Statistical Methods in Biological and Medical Sciences},
+	Editor = {R. C. Rao and R. Chakraborty},
+	Pages = {317-346},
+	Publisher = {North-Holland},
+	Series = {Handbook of Statistics},
+	Title = {Statistical Methods for Phylogenetic Tree Reconstruction},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 8,
+	Year = 1991}
+
+ at article{salter01,
+	Author = {L. Salter and D. Pearl},
+	Journal = {Systematic Biology},
+	Pages = {7-17},
+	Title = {Stochastic search strategy for estimation of maximum likelihood phylogenetic trees},
+	Volume = 50,
+	Year = 2001}
+
+ at article{sanderson94,
+Author = {M. Sanderson and M. Donoghue and W. Piel and T. Eriksson},
+Title = {Tree{BASE}: a prototype database of phylogenetic analyses and an interactive tool for browsing the phylogeny of life},
+Journal = {American Journal of Botany},
+Volume = 81,
+Pages = {183},
+Year = {1994}
+}
+
+ at article{sanderson97,
+	Author = {M. Sanderson},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1218-1231},
+	Title = {A nonparametric approach to estimating divergence times in the absence of rate constancy},
+	Volume = 14,
+	Year = 1997}
+
+ at article{sanderson02,
+	Author = {M. Sanderson},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {101-109},
+	Title = {Estimating absolute rates of molecular evolution and divergence times: a penalized likelihood approach},
+	Volume = 19,
+	Year = 2002}
+
+ at article{sanger77,
+	Author = {F. Sanger and S. Nicklen and A.R. Coulson},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {5463-5467},
+	Title = {DNA sequencing with chain-terminating inhibitors},
+	Volume = 74,
+	Year = 1977}
+
+ at article{sankoff94,
+	Author = {D. Sankoff and Y. Abel and J. Hein},
+	Journal = {Journal of Classification},
+	Pages = {209-232},
+	Title = {A tree - a hill; generalization of nearest-neighbor     in phylogenetic optimization},
+	Utilisateur = {Vincent},
+	Volume = 11,
+	Year = 1994}
+
+ at inbook{saporta,
+	Author = {G. Saporta},
+	Chapter = { No 5 Notions {\'e}l{\'e}mentaires sur les processus al{\'e}atoires},
+	Pages = {103-113},
+	Publisher = {Technip},
+	Title = {Probabilit{\'e}s analyse des donn{\'e}es et statistique},
+	Utilisateur = {Guillaume Andrieu},
+	Year = 1990}
+
+ at article{sharp97,
+	Author = {P. Sharp},
+	Journal = {Nature},
+	Pages = {111-112},
+	Title = {In search of molecular Darwinism},
+	Volume = 385,
+	Year = 1997}
+
+ at article{sharp87,
+	Author = {P. Sharp and W.-H. Li},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {1281-1295},
+	Title = {The codon adaptation index--a measure of directional synonymous codon usage bias, and its potential applications},
+	Volume = 15,
+	Year = 1987}
+
+ at article{scherer89,
+	Author = {Siegfried Scherer},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {436-441},
+	Title = {The relative-rate test of the molecular clock hypothesis : a note of caution},
+	Utilisateur = {Gilles Caraux},
+	Volume = 6,
+	Year = 1989}
+
+ at article{shankarappa99,
+	Author = {R. Shankarappa and J. Margolick and S. Gange and A. Rodrigo and D. Upchurch  and H. Farzadegan and P. Gupta and C. Rinaldo and G. Learn and X. He and X.-L Huang and J. Mullins },
+	Journal = {Journal of Virology},
+	Pages = {10489-10502},
+	Title = {Consistent viral evolutionary changes associated with the progression of human immunodeficiency virus type 1 infection},
+	Volume = 73,
+	Year = 1999}
+
+ at article{schoniger93,
+	Author = {Michael Sch{\"o}niger and Arndt von Haesler },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {471-483},
+	Title = {A simple method to improve the reliability of tree reconstruction},
+	Utilisateur = {G. Andrieu},
+	Volume = 10,
+	Year = 1993}
+
+ at article{schoniger94,
+	Author = {M. Sch{\"o}niger and A. von Haesler },
+	Journal = {Molecular Phylogeny and Evolution},
+	Pages = {240-247},
+	Title = {A stochastic model for the evolution of autocorrelated {DNA} sequences},
+	Volume = 3,
+	Year = 1994}
+
+ at article{schoniger95,
+	Author = {M. Sch{\"o}niger and A. von Haesler },
+	Journal = {Systematic Biology},
+	Pages = {533-547},
+	Title = {Performance of the maximum likelihood, neighbor joining, and maximum parsimony methods when sequence sites are not independent},
+	Volume = 44,
+	Year = 1995}
+
+ at article{schwarz78,
+	Author = {G. Schwarz},
+	Journal = {The annals of statistics},
+	Pages = {461-464},
+	Title = {Estimating the dimension of a model},
+	Volume = 6,
+	Year = 1978}
+
+ at article{sibley84,
+	Author = {Charles G. Sibley and Jon E. Ahlquist},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {2-15},
+	Title = {the phylogeny of the hominoid primates, as indicated by {DNA-DNA} hybridization},
+	Utilisateur = {Gilles Caraux},
+	Volume = 20,
+	Year = 1984}
+
+ at article{sibley87,
+	Author = {Charles G. Sibley and Jon E. Ahlquist},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {99-121},
+	Title = {{DNA} hybridization evidence of hominoid phylogeny : results from expanded set},
+	Utilisateur = {Gilles Caraux},
+	Volume = 26,
+	Year = 1987}
+
+ at book{paup,
+	Address = {Sunderland, MA},
+	Author = {D. Swofford},
+	Publisher = {Sinauer},
+	Title = {{PAUP$^*$}: Phylogenetic Analysis by Parsimony$^*$ and other methods},
+	Year = 1999}
+
+ at book{bambe,
+	Address = {Duquesne University},
+	Author = {D. Simon and B. Larget},
+	Publisher = {Department of Mathematics and Computer Science},
+	Title = {Bayesian analysis in molecular biology and evolution (BAMBE), version 2.03 beta},
+	Year = 2000}
+
+ at article{sarich67,
+	Author = {V. Sarich and A. Wilson},
+	Journal = {Science},
+	Pages = {1200-1203},
+	Title = {Immunological time scale for hominid evolution},
+	Volume = 158,
+	Year = 1967}
+
+ at article{self87,
+	Author = {S. Self and K. Liang},
+	Journal = {Journal of the American Statistical Association},
+	Pages = {605--610},
+	Title = {Asymptotic properties of maximum likelihood  estimators and likelihood ratio tests under  nonstandard conditions},
+	Volume = 82,
+	Year = 1987}
+
+ at article{shan09,
+  title={Evolution of plant {MADS} box transcription factors: evidence for shifts in selection associated with early angiosperm diversification and concerted gene duplications},
+  author={Shan, H. and Zahn, L. and Guindon, S. and Wall, P.K. and Kong, H. and Ma, H. and DePamphilis, C.W. and Leebens-Mack, J. and others},
+  journal={Molecular Biology and Evolution},
+  volume={26},
+  number={10},
+  pages={2229--2244},
+  year={2009},
+  publisher={SMBE}
+}
+ at article{murrell12,
+  title={Detecting individual sites subject to episodic diversifying selection},
+  author={Murrell, Ben and Wertheim, Joel O and Moola, Sasha and Weighill, Thomas and Scheffler, Konrad and Pond, Sergei L Kosakovsky},
+  journal={PLoS Genetics},
+  volume={8},
+  number={7},
+  pages={e1002764},
+  year={2012},
+  publisher={Public Library of Science}
+}
+
+
+
+
+ at article{pond05,
+  title={Not so different after all: a comparison of methods for detecting amino acid sites under selection},
+  author={Kosakovsky Pond, Sergei   and Frost, Simon},
+  journal={Molecular Biology and Evolution},
+  volume={22},
+  number={5},
+  pages={1208--1222},
+  year={2005},
+  publisher={SMBE}
+}
+
+
+ at article{shimodaira99,
+	Author = {H. Shimodaira and M. Hasegawa},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1114-1116},
+	Title = {Multiple comparisons of log-likelihoods with applications to phylogenetic inference},
+	Volume = 16,
+	Year = 1999}
+
+ at article{shriner04,
+	Author = {D. Shrinner and A. Rodrigo and D. Nickle and J. Mullins},
+	Journal = {Genetics},
+	Pages = {1573-1583},
+	Title = {Pervasive genomic recombination of {HIV-1} \mbox{\it in vivo}},
+	Volume = {167},
+	Year = 2004}
+
+ at article{sokal58,
+	Author = {R. R. Sokal and C. D. Michener},
+	Journal = {University of Kansas Science Bulletin},
+	Pages = {1409-1438},
+	Title = {A statistical method for evaluating systematic relationships},
+	Volume = {38},
+	Year = {1958}}
+
+ at article{sourdis87,
+	Author = {J. Sourdis and C. Krimbas},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {159-166},
+	Title = {Accuracy of phylogenetic trees estimated from {DNA} sequence data},
+	Volume = {4},
+	Year = {1987}}
+
+ at article{springer01,
+	Author = {M. Springer and R. De Bry and C. Douady and H. Amrine and O. Madsen and W. de Jong and M. Stanhope.},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {132-143},
+	Title = {Mitochondrial versus nuclear gene sequences in deep-level mammalian phylogeny reconstruction},
+	Volume = {18},
+	Year = {2001}}
+
+ at article{sourdis88,
+	Author = {J. Sourdis and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {298-311},
+	Title = {Relative efficiencies of the maximum parsimony and distance-based methods in obtaining the correct phylogenetic tree},
+	Volume = {5},
+	Year = {1988}}
+
+ at article{srs,
+	Author = {T. Etzold and P. Argos},
+	Journal = {CABIOS},
+	Pages = {49-57},
+	Title = {{SRS}-an indexing and retrieval tool for flat file data libraries},
+	Volume = {9},
+	Year = {1993}}
+
+ at article{spencer05,
+	Author = {M. Spencer and E. Susko and A. Roger},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1161-1164},
+	Title = {Likelihood, parsimony, and heterogeneous evolution},
+	Volume = {22},
+	Year = {2005}}
+
+ at article{squires07,
+author = {B. Squires and C. Macken and A. Garcia-Sastre and S. Godbole and J. Noronha and V. Hunt and R. Chang and C. Larsen and E. Klem and K. Biersack and R. Scheuermann},
+title = {{B}io{H}ealth{B}ase: informatics support in the elucidation of influenza virus host-pathogen interactions and virulence},
+journal = {Nucleic Acids Research},
+volume = {Database issue},
+year = {2007}
+}
+
+
+
+ at article{raxml,
+	Author = {A. Stamatakis},
+	Journal = {Bioinformatics},
+	Pages = {2688-2690},
+	Title = {{RAxML-VI-HPC}: Maximum Likelihood-based Phylogenetic Analyses with Thousands of Taxa and Mixed Models},
+	Volume = 22,
+	Year = 2006}
+
+ at article{stamatakis06,
+	Author = {A. Stamatakis},
+	Journal = {Bioinformatics},
+	Pages = {2688-2690},
+	Title = {{RAxML-VI-HPC}: Maximum Likelihood-based Phylogenetic Analyses with Thousands of Taxa and Mixed Models},
+	Volume = 22,
+	Year = 2006}
+
+ at article{st77,
+	Author = {S. Sattah and A. Tversky},
+	Journal = {Psychometrika},
+	Pages = {319-345},
+	Title = {Additive similarity trees},
+	Volume = 42,
+	Year = 1977}
+
+ at article{steel92,
+	Author = {M. Steel},
+	Journal = {J. of Classification},
+	Pages = {91-116},
+	Title = {The complexity of reconstructing trees from     qualitative characters and subtrees},
+	Utilisateur = {Vincent},
+	Volume = 9,
+	Year = 1992}
+
+ at article{steel93,
+	Author = {M.A. Steel and D. Penny},
+	Journal = {Systematic Biology},
+	Number = 2,
+	Pages = {126-141},
+	Title = {Distributions of tree comparison metrics - some new results},
+	Volume = 42,
+	Year = 1993}
+
+ at article{steel94,
+	Author = {M. Steel},
+	Journal = {Systematic Biology},
+	Pages = {560-564},
+	Title = {The maximum likelihood point for a phylogenetic tree is not unique},
+	Volume = 43,
+	Year = 1994}
+
+ at article{steel00a,
+	Author = {M. Steel and D. Penny},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {839-50},
+	Title = {Parsimony, likelihood, and the role of models in molecular phylogenetics},
+	Volume = 17,
+	Year = 2000}
+
+ at article{steel00b,
+	Author = {M. Steel and D. Huson and P. Lockhart},
+	Journal = {Systematic Biology},
+	Pages = {225-232},
+	Title = {Invariable site models and their use in phylogeny reconstruction},
+	Volume = 49,
+	Year = 2000}
+
+ at article{steel05,
+	Author = {M. Steel},
+	Journal = {Trends in Genetics},
+	Pages = {307-309},
+	Title = {Should phylogenetic models be trying to ``fit an elephant''?},
+	Volume = 21,
+	Year = 2005}
+
+ at incollection{stewart93,
+	Author = {Caro-Beth Stewart},
+	Booktitle = {Nature},
+	Month = {february},
+	Pages = {603-607},
+	Title = {The Powers and pitfalls of parsimony},
+	Utilisateur = {Vincent},
+	Volume = 361,
+	Year = 1993}
+
+ at article{stoffberg10,
+author = {S. Stoffberg and D. Jacobs and I. Mackie and C. Matthee},
+title = {Molecular phylogenetics and historical biogeography of Rhinolophus bats},
+journal = {Molecular Phylogenetics and Evolution},
+Volume = 54,
+Pages = {1-9},
+Year = 2010}
+
+
+ at article{strimmer96,
+	Author = {K. Strimmer and A. von Haeseler},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {964-969},
+	Title = {Quartet puzzling: a quartet maximum-likelihood method for reconstructing tree topologies},
+	Volume = 13,
+	Year = 1996}
+
+ at article{strimmer97,
+	Author = {K. Strimmer and N. Goldman and A. von Haeseler},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {210-211},
+	Title = {Baysian Probabilities and Quartet puzzling},
+	Volume = 14,
+	Year = 1997}
+
+ at article{strimmer00,
+	Author = {K. Strimmer and V. Moulton},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {875-881},
+	Title = {Likelihood analysis of phylogenetic networks using directed graphical models},
+	Volume = 17,
+	Year = 2000}
+
+ at article{studier88,
+	Author = {J. Studier and K. Kepler},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {729-731},
+	Title = {A note on the neighbor-joining algorithm of Saitou and Nei},
+	Volume = 5,
+	Year = 1988}
+
+ at article{sullivan95,
+	Author = {J. Sullivan and K. E. Holsinger and C. Simon},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {988-1001},
+	Title = {Among-site variation and phylogenetic analysis of 12{S} r{RNA} in sigmontine rodents},
+	Volume = 12,
+	Year = 1995}
+
+ at article{sullivan97,
+	Author = {J. Sullivan and D. Swofford},
+	Journal = {Journal of Mammalian Evolution},
+	Pages = {77-86},
+	Title = {Are Guinea pigs Rodents? The importance of adequate models in molecular phylogenetics.},
+	Volume = 4,
+	Year = 1997}
+
+ at article{susko02,
+	Author = {E. Susko and Y. Inagaki and C. Field and M. Holder and A. Roger},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1514-1523},
+	Title = {Testing for differences in rates-across-sites distributions in phylogenetic subtrees},
+	Volume = 19,
+	Year = 2002}
+
+ at article{susko03,
+	Author = {E. Susko and C. Field and C. Blouin and A. Roger},
+	Journal = {Systematic Biology},
+	Pages = {594-603},
+	Title = {Estimation of rates-across-sites distributions in phylogenetic substitution models},
+	Volume = 52,
+	Year = 2003}
+
+ at article{suzuki99,
+	Author = {Y. Suzuki and T. Gojobori},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1315-1328},
+	Title = {A method for detecting positive selection at single amino acid sites},
+	Volume = 16,
+	Year = 1999}
+
+ at article{suzuki02,
+	Author = {Y. Suzuki and G. V. Glazko and M. Nei},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {16138-16143},
+	Title = {Overcredibility of molecular phylogenies obtained by Bayesian phylogenetics},
+	Volume = 99,
+	Year = 2002}
+
+ at article{suzuki04,
+	Author = {Y. Suzuki and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {914-921},
+	Title = {False-positive selection identified by {ML}-based methods: examples from the {\it Sig1} gene of the diatom {T}halassoria weissflogii and the {\it tax} gene of a human {T}-cell lymphotropic virus},
+	Volume = 21,
+	Year = 2004}
+
+ at article{swanson01,
+	Author = {W. Swanson and Z. Yang and M. Wolfner and C. Aquadro},
+	Journal = {Proceedings of the National Academy of Sciences of the United States of America (PNAS)},
+	Pages = {2509-2514},
+	Title = {Positive Darwinian selection drives the evolution of several female reproductive proteins in mammals},
+	Volume = 98,
+	Year = 2001}
+
+ at incollection{swofford90,
+	Address = {Sunderland, MA},
+	Author = {D. Swofford and G. Olsen},
+	Booktitle = {Molecular Systematics},
+	Chapter = 11,
+	Editor = {D. M. Hillis and C. Moritz},
+	Pages = {411-501},
+	Publisher = {Sinauer},
+	Title = {Phylogeny reconstruction},
+	Year = 1990}
+
+ at incollection{swofford91,
+	Author = {D. Swofford},
+	Booktitle = {Phylogenetic analysis of {DNA} sequences},
+	Chapter = 14,
+	Editor = {M. M. Miyamoto and J. Cracraft},
+	Pages = {295-333},
+	Publisher = {Oxford University press},
+	Title = {When are phylogeny estimates from molecular and     morphological data incongruent ?},
+	Year = 1991}
+
+ at incollection{swofford96,
+	Address = {Sunderland, MA},
+	Author = {D. Swofford and G. Olsen and P. Waddel and D. Hillis},
+	Booktitle = {Molecular Systematics},
+	Chapter = 11,
+	Editor = {D. Hillis and C. Moritz and B. Mable},
+	Publisher = {Sinauer},
+	Title = {Phylogenetic inference},
+	Year = 1996}
+
+ at article{tajima82,
+	Author = {Fumio Tajima and Masatoshi Nei },
+	Journal = {Journal of Molecular Evolution},
+	Pages = {115-120},
+	Title = {Biases of the estimates of {DNA} divergence obtained by the restriction enzyme technique},
+	Utilisateur = {Gilles Caraux},
+	Volume = 18,
+	Year = 1982}
+
+ at article{tajima84,
+	Author = {Fumio Tajima and Masatoshi Nei },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {269-285},
+	Title = {Estimation of evolution distance between nucleotide     sequences},
+	Volume = 1,
+	Year = 1984}
+
+ at article{tajima92,
+	Author = {Fumio Tajima },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {168-181},
+	Title = {Statistical Method for estimating the standard     errors of branch lengths in a phylognetic tree     reconstructed without assuming equal rates of     nucleotide substitution among different lineages},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 1,
+	Year = 1992}
+
+ at article{tajima93,
+	Author = {Fumio Tajima },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {677-688},
+	Title = {Unbiased Estimation of evolutionary distance between nucleotide sequences},
+	Utilisateur = {Gilles Caraux and Guillaume Andrieu},
+	Volume = 10,
+	Year = 1993}
+
+ at article{tajima94,
+	Author = {Fumio Tajima and Naoko Takezaki},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {278-286},
+	Title = {Estimation of Evolutionary Distance for Reconstructiong Molecular Phylogenetic Trees},
+	Volume = 11,
+	Year = 1994}
+
+ at article{takahashi00,
+	Author = {Kei Takahashi and Masatoshi Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1251-1258},
+	Title = {Efficiencies of Fast Algorithms of Phylogenetic Inference Under the Criteria of Maximum Parsimony, Minimum Evolution, and Maximum Likelihood When a Large Number of Sequences Are Used},
+	Volume = 17,
+	Year = 2000}
+
+ at article{takahata81,
+	Author = {Naoyuki Takahata and M. Kimura},
+	Journal = {Genetics},
+	Pages = {641-657},
+	Title = {A Model of Evolutionary Base Substitutions and its Application with special Reference to rapid change of Pseudogenes},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 98,
+	Year = 1981}
+
+ at article{takezaki94,
+	Author = {N. Takezaki and M. Nei},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {210-218},
+	Title = {Inconsistency of the maximum parsimony method when     the rate of nucleotide, substitution is constant},
+	Utilisateur = {Vincent},
+	Volume = 39,
+	Year = 1994}
+
+ at Article{takezaki95,
+   Author="Takezaki, N.  and Rzhetsky, A.  and Nei, M. ",
+   Title="{{P}hylogenetic test of the molecular clock and linearized trees}",
+   Journal="Mol. Biol. Evol.",
+   Year="1995",
+   Volume="12",
+   Pages="823--833",
+   Month="Sep"
+}
+
+ at article{tamura93,
+	Author = {K. Tamura and M. Nei},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {512-526},
+	Title = {Estimation of the number of nucleotide substitutions in the control region of mitochondrial {DNA} in humans and chimpanzees},
+	Volume = 10,
+	Year = 1993}
+
+ at article{tateno82,
+	Author = {Y. Tateno and M. Nei and F. Tajima},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {387-404},
+	Title = {Accuracy of Estimed Phylogenetic Trees from Molecular Data : I. Distantly Related Species},
+	Volume = 18,
+	Year = 1982}
+
+ at article{tavare86,
+	Author = {S. Tavar\'e},
+	Journal = {Lectures on Mathematics in the Life Sciences},
+	Pages = {57-86},
+	Title = {Some probabilistic and statistical problems on the analysis of {DNA} sequences},
+	Volume = 17,
+	Year = 1986}
+
+ at article{tillier98,
+	Author = {E. Tillier and R. Collins},
+	Journal = {Genetics},
+	Pages = {1993-2002},
+	Title = {High Apparent Rate of Simultaneous Compensatory Base-Pair Substitutions in Ribosomal RNA},
+	Volume = 148,
+	Year = 1998}
+
+ at article{clustal,
+	Author = {J. Thompson and D. Higgins and T. Gibson },
+	Journal = {Nucleic Acids Research},
+	Pages = {4673-4680},
+	Title = {{CLUSTAL W}: improving the sensitivity of progressive multiple sequence alignment through sequence weighting, position-specific gap penalties and weight matrix choice},
+	Volume = 22,
+	Year = 1994}
+
+ at article{clustalx,
+	Author = {J. Thompson and T. Gibson and F. Plewniak and F. Jeanmougin and D. Higgins},
+	Journal = {Nucleic Acids Research},
+	Pages = {4876-4882},
+	Title = {The {C}lustal{X} windows interface: flexible strategies for multiple sequences alignement aided by quality analysis tool},
+	Volume = 24,
+	Year = 1997}
+
+ at article{thorne91,
+	Author = { J. L. Thorne and H. Kishino and J. Felsenstein},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {114-124},
+	Title = {An Evolutionary Model for Maximum Likelihood     Alignement of {DNA} Sequences},
+	Volume = 33,
+	Year = 1991}
+
+ at article{thorne92a,
+	Author = { J. L. Thorne and H. Kishino and J. Felsenstein},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {3-16},
+	Title = {Inching toward Reality: an Improved Likelihood Model of Sequence Evolution},
+	Volume = 34,
+	Year = 1992}
+
+ at article{thorne92b,
+	Author = {J. L. Thorne and H. Kishino },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1148-1162},
+	Title = {Freeing Phylogenies from Artifacts of Alignement},
+	Utilisateur = {G. Andrieu},
+	Volume = 9,
+	Year = 1992}
+
+ at article{thorne98,
+	Author = {J. Thorne and H. Kishino and I. Painter},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1647-1657},
+	Title = {Estimating the rate of evolution of the rate of molecular evolution},
+	Volume = 15,
+	Year = 1998}
+
+ at article{tourasse97,
+	Author = {N.J. Tourasse and M. Gouy },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {287-98},
+	Title = {Evolutionary distances between nucleotide sequences based on the distribution of substitution rates among sites as estimated by parsimony},
+	Volume = 14,
+	Year = 1997}
+
+ at book{trivedi01,
+	Address = {Chichester},
+	Author = {K. Trivedi},
+	Publisher = {Wiley},
+	Title = {Probability and Statistics with Reliability, Queuing, and Computer Science Applications},
+	Year = {2001}}
+
+ at article{tuffley98,
+	Author = {C. Tuffley and M. Steel},
+	Journal = {Mathematical Biosciences},
+	Pages = {63-91},
+	Title = {Modeling the covarion hypothesis of nucleotide substitution},
+	Volume = 147,
+	Year = 1998}
+
+ at incollection{vach89,
+	Author = {Werner Vach},
+	Booktitle = {Conceptual and numerical analysis of data},
+	Editor = {O. Opitz},
+	Pages = {230-238},
+	Publisher = {Springer Verlag},
+	Title = {Least squares approximation of additive trees},
+	Year = 1989}
+
+ at article{wahlberg06,
+Author = {N. Wahlberg},
+Journal = {Systematic Biology},
+Title = {That awkward age for butterflies: insights from the age of the butterfly subfamily {N}ymphalinae ({L}epidoptera: {N}ymphalidae)},
+Pages = {703-714},
+Volume = {55},
+Year = {2006},
+}
+
+ at article{wakeley93,
+	Author = {J. Wakeley},
+	Journal = {J Mol Evol},
+	Number = 6,
+	Pages = {613-23},
+	Title = {Substitution rate variation among sites in hypervariable region 1 of human mitochondrial DNA.},
+	Volume = 37,
+	Year = 1993}
+
+ at article{wakeley94,
+	Author = {J. Wakeley},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {436-442},
+	Title = {Substitution rate variation among sites and the estimation of transition bias},
+	Year = 1994}
+
+ at article{vandepeer04,
+	Author = {Y. Van de Peer},
+	Journal = {Nature Reviews Genetics},
+	Pages = {752-763},
+	Title = {Computational approaches to unveiling ancient genome duplications},
+	Volume = 5,
+	Year = 2004}
+
+ at article{vin04,
+	Author = {L. Sy Vinh and A. von Haeseler},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1565-1571},
+	Title = {{IQPNNI}: Moving Fast Through Tree Space and Stopping in Time},
+	Volume = 21,
+	Year = 2004}
+
+ at article{vonhaeseler93,
+	Author = {Arndt Von Haeseler and Gary A. Churchill},
+	Journal = {J. Mol Evol},
+	Pages = {77-85},
+	Title = {Network Models for Sequence Evolution},
+	Utilisateur = {Guillaume Andrieu},
+	Volume = 37,
+	Year = 1993}
+
+ at article{wagner02,
+	Author = {A. Wagner},
+	Journal = {Genome Biology},
+	Pages = {1012.1-1012.3},
+	Title = {Selection and gene duplication : a view from the genome},
+	Volume = 3,
+	Year = 2002}
+
+ at phdthesis{waddell95,
+	Author = {P.J. Waddell},
+	School = {Massey University},
+	Title = {Statisctical Methods of Phylogenetic Analysis: Including Hadamard Conjugations, LogDet Transforms, and Maximum Likelihood},
+	Year = 1995}
+
+ at article{waterman77,
+	Author = {M. S. Waterman and T. F. Smith and M. Singh and W. A. Beyer},
+	Journal = {Journal of Theoretical Biology},
+	Pages = {199-213},
+	Title = {Additive Evolutonary trees},
+	Utilisateur = {Gilles Caraux et Vincent},
+	Volume = 64,
+	Year = 1977}
+
+ at article{waterman78,
+	Author = {M. S. Waterman and T. F. Smith},
+	Journal = {Journal of Theoretical Biology},
+	Pages = {789-800},
+	Title = {On the similarity of dendrograms},
+	Utilisateur = {Gilles Caraux},
+	Volume = 73,
+	Year = 1978}
+
+ at article{whelan01,
+	Author = {S. Whelan and Pietro Li{\`o} and Nick Goldman},
+	Journal = {Trends in Genetics},
+	Number = 5,
+	Pages = {262-272},
+	Title = {Molecular phylogenetics: state-of-the art methods for looking into the past},
+	Volume = 17,
+	Year = 2001}
+
+ at article{whelan01b,
+	Author = {S. Whelan and N. Goldman},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {691-699},
+	Title = {A General Empirical Model of Protein Evolution Derived from Multiple Protein Families Using a Maximum-Likelihood Approach},
+	Volume = 18,
+	Year = 2001}
+
+ at article{wilkinson95,
+	Author = {M. Wilkinson},
+	Journal = {Systematic Biology},
+	Optnumber = {3},
+	Optpages = {435-439},
+	Optvolume = {44},
+	Title = {More on reduced consensus methods},
+	Year = {1995}}
+
+ at article{whitley94,
+	Author = {D. Whitley},
+	Journal = {Statistics and Computing},
+	Pages = {65-85},
+	Title = {A Genetic Algorithm Tutorial},
+	Volume = 4,
+	Year = {1994}}
+
+ at incollection{williams90,
+	Address = {New York},
+	Author = {Patrick L. Williams and Walter M. Fitch},
+	Booktitle = {Molecular evolution : computer analysis of protein and nucleic acidsequences},
+	Chapter = 38,
+	Editor = {Russsell F. Doolittle},
+	Pages = {615-626},
+	Publisher = {Academic Press},
+	Series = {Methods In Enzymology},
+	Title = {Phylogeny Determination Using Dynamically Weighted Parsimony Method},
+	Volume = 183,
+	Year = 1990}
+
+ at article{suzuki08,
+  title={False-positive results obtained from the branch-site test of positive selection},
+  author={Suzuki, Yoshiyuki},
+  journal={Genes \& Genetic Systems},
+  volume={83},
+  number={4},
+  pages={331--338},
+  year={2008},
+  publisher={J-STAGE}
+}
+
+ at article{nozawa09,
+  title={Reliabilities of identifying positive selection by the branch-site and the site-prediction methods},
+  author={Nozawa, Masafumi and Suzuki, Yoshiyuki and Nei, Masatoshi},
+  journal={Proceedings of the National Academy of Sciences},
+  volume={106},
+  number={16},
+  pages={6700--6705},
+  year={2009},
+  publisher={National Acad Sciences}
+}
+
+ at article{wong04,
+	Author = {W. Wong  and Z. Yang and N. Goldman and R. Nielsen},
+	Journal = {Genetics},
+	Pages = {1041-1051},
+	Title = {Accuracy and power of statistical methods for detecting adaptive evolution in protein coding sequences and for identifying positively selected sites},
+	Volume = {168},
+	Year = 2004}
+
+ at article{yang11,
+  title={Statistical properties of the branch-site test of positive selection},
+  author={Yang, Ziheng and dos Reis, Mario},
+  journal={Molecular Biology and Evolution},
+  volume={28},
+  number={3},
+  pages={1217--1228},
+  year={2011},
+  publisher={SMBE}
+}
+
+
+ at article{yang93,
+	Author = {Z Yang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1396-1401},
+	Title = {Maximum-likelihood estimation of phylogeny from {DNA} sequences when substitution rates differ over sites},
+	Volume = {10},
+	Year = 1993}
+
+ at article{yang94,
+	Author = {Z. Yang and N. Goldman and A. Friday},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {316-324},
+	Title = {Comparison of models for nucleotide substitution used in maximum-likelihood phylogenetic estimation.},
+	Volume = 11,
+	Year = 1994}
+
+ at article{yang94b,
+	Author = {Z. Yang},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {306-314},
+	Title = {Maximum likelihood phylogenetic estimation from {DNA} sequences with variable rates over sites: approximate methods},
+	Volume = 39,
+	Year = 1994}
+
+ at article{yang94c,
+	Author = {Z. Yang},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {105-111},
+	Title = {Estimating the pattern of nucleotide substitution},
+	Volume = 10,
+	Year = 1994}
+
+ at article{yang94d,
+	Author = {Z. Yang},
+	Journal = {Systematic Biology},
+	Pages = {329-342},
+	Title = {Statistical properties of the maximum likelihood method of phylogenetic estimation and comparison with distance matrix methods},
+	Volume = 43,
+	Year = 1994}
+
+ at article{yang95a,
+	Author = {Z. Yang},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {689-697},
+	Title = {Evaluation of several methods for estimating phylogenetic trees when substitution rates differ over nucleotide sites},
+	Volume = 40,
+	Year = 1995}
+
+ at article{yang95b,
+	Author = {Z. Yang},
+	Journal = {Genetics},
+	Pages = {993-1005},
+	Title = {A space-time process model for the evolution of {DNA} sequences},
+	Volume = 193,
+	Year = 1995}
+
+ at article{yang96,
+	Author = {Z. Yang and S. Kumar},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {650-659},
+	Title = {Approximate methods for estimating the pattern of nucleotide substitution and the variation of substitution rates among sites},
+	Volume = 13,
+	Year = 1996}
+
+ at article{yang98,
+	Author = {Z. Yang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {568-573},
+	Title = {Likelihood ratio tests for detecting positive selection and application to primate lysozyme evolution},
+	Volume = 15,
+	Year = 1998}
+
+ at article{paml,
+	Author = {Z. Yang},
+	Journal = {Computer Applications in the Biosciences (CABIOS)},
+	Pages = {555-556},
+	Title = {{PAML} : a program package for phylogenetic analysis by maximum likelihood},
+	Volume = 13,
+	Year = 1997}
+
+ at article{paml4,
+  title={{PAML} 4: phylogenetic analysis by maximum likelihood},
+  author={Yang, Ziheng},
+  journal={Molecular Biology and Evolution},
+  volume={24},
+  number={8},
+  pages={1586--1591},
+  year={2007},
+  publisher={SMBE}
+}
+
+
+ at article{yang96b,
+	Author = {Z. Yang},
+	Journal = {Trends in Ecology and Evolution},
+	Number = 9,
+	Pages = {367-372},
+	Title = {Among-site rate variation and its impact on phylogenetic analyses},
+	Volume = 11,
+	Year = 1996}
+
+ at article{yang96c,
+	Author = {Z. Yang},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {294-307},
+	Title = {Phylogenetic analysis using parsimony and likelihood methods},
+	Volume = 42,
+	Year = 1996}
+
+ at article{yang97,
+	Author = {Z. Yang},
+	Journal = {Trends in Ecology and Evolution},
+	Number = 9,
+	Pages = {357},
+	Title = {Are big trees indeed easy ?},
+	Volume = 12,
+	Year = 1997}
+
+ at article{yang97b,
+	Author = {Z. Yang and B. Rannala},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {717-724},
+	Title = {Bayesian phylogenetic inference using {DNA} sequences: a Markov Chain {M}onte {C}arlo method},
+	Volume = 14,
+	Year = 1997}
+
+ at article{yang97c,
+	Author = {Z. Yang},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {105-108},
+	Title = {How often do wrong models produce better phylogenies?},
+	Volume = 14,
+	Year = 1997}
+
+ at article{yang00,
+	Author = {Z. Yang},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {423-432},
+	Title = {Maximum likelihood Estimation on large phylogenies and analysis of adaptative evolution in human influenza virus {A}},
+	Volume = 51,
+	Year = 2000}
+
+
+ at article{yang00d,
+  title={Maximum-likelihood analysis of molecular adaptation in abalone sperm lysin reveals variable selective pressures among lineages and sites},
+  author={Yang, Z. and Swanson, W.J. and Vacquier, V.D.},
+  journal={Molecular Biology and Evolution},
+  volume={17},
+  number={10},
+  pages={1446--1455},
+  year={2000},
+  publisher={SMBE}
+}
+
+
+ at Article{yang06,
+   Author="Yang, Z.  and Rannala, B. ",
+   Title="{{B}ayesian estimation of species divergence times under a molecular clock using multiple fossil calibrations with soft bounds}",
+   Journal="Mol. Biol. Evol.",
+   Year="2006",
+   Volume="23",
+   Pages="212--226",
+   Month="Jan"
+}
+
+
+
+
+ at book{yang06b,
+  title={Computational molecular evolution},
+  author={Yang, Z.},
+  volume={284},
+  year={2006},
+  publisher={Oxford University Press Oxford}
+}
+
+
+
+ at article{pond11,
+  title={A random effects branch-site model for detecting episodic diversifying selection},
+  author={Kosakovsky Pond, Sergei L  and Murrell, Ben and Fourment, Mathieu and Frost, Simon DW and Delport, Wayne and Scheffler, Konrad},
+  journal={Molecular Biology and Evolution},
+  volume={28},
+  number={11},
+  pages={3033--3043},
+  year={2011},
+  publisher={SMBE}
+}
+
+
+
+ at article{yokoyama96,
+	Author = {S. Yokoyama and R. Yokoyama},
+	Journal = {Annual Review of Ecology and Systematics},
+	Pages = {543-567},
+	Title = {Adaptative evolution of photoreceptors and visual pigments in vertebrates},
+	Volume = 27,
+	Year = 1996}
+
+ at article{yang00b,
+	Author = {Z. Yang and R. Nielsen},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {32-43},
+	Title = {Estimating synonymous and nonsynonymous substitution rates under realistic evolutionary models},
+	Volume = 17,
+	Year = 2000}
+
+ at article{yang00c,
+	Author = {Z. Yang and R. Nielsen and N. Goldman and A.-M. {Krabbe Pedersen}},
+	Journal = {Genetics},
+	Pages = {431-449},
+	Title = {Codon-substitution models for heterogeneous selection pressure at amino acid sites},
+	Volume = 155,
+	Year = 2000}
+
+ at article{yang02,
+	Author = {Z. Yang and R. Nielsen},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {908-917},
+	Title = {Codon-substitution models for detecting molecular adaptation at individual sites along specific lineages},
+	Volume = 19,
+	Year = 2002}
+
+ at article{yang05,
+	Author = {Z. Yang and W. Wong and R. Nielsen},
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1107-1118},
+	Title = {Bayes empirical {B}ayes inference of amino acid sites under positive selection},
+	Volume = 22,
+	Year = 2005}
+
+ at article{tateno94,
+	Author = {Y. Tateno and  N. Takezaki and M. Nei },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {261-77},
+	Title = {Relative efficiencies of the maximum-likelihood, neighbor-joining, and maximum-parsimony methods when substitution rate varies with site.},
+	Volume = 11,
+	Year = 1994}
+
+ at article{uzzell71,
+	Author = {T. Uzzell and K. Corbin},
+	Journal = {Science},
+	Pages = {1089-1096},
+	Title = {Fitting discrete probability distributions to evolutionary events},
+	Volume = 172,
+	Year = 1971}
+
+ at article{winter02,
+	Author = {K.-U. Winter and H. Saedler and G. Theissen},
+	Journal = {The Plant Journal},
+	Pages = {457-475},
+	Title = {On the origin of class {B} floral homeotic genes: functional substitution and dominant inhibition in {\em \uppercase{A}rabidopsis} by expression of an orthologue from the gymnosperm {\em \uppercase{G}netum}},
+	Volume = 31,
+	Year = 2002}
+
+ at article{zahn05,
+	Author = {L. Zahn and J. Leebens-Mack and C. DePamphilis and H. Ma and G. Theissen},
+	Journal = {Journal of Heredity},
+	Pages = {225-240},
+	Title = {To {B} or {N}ot to {B} a flower: the role of {DEFICIENS} and {GLOBOSA} orthologs in the evolution of the angiosperms},
+	Volume = {96},
+	Year = {2005}}
+
+ at article{zaretskii65,
+	Author = {K. Zaretskii },
+	Journal = {USpekHi Math. Nauk.},
+	Pages = {90-92},
+	Title = {Construction d'un arbre sur la base d'un ensemble de distances entre ses feuilles},
+	Volume = 20,
+	Year = 1965}
+
+ at article{zharkikh92a,
+	Author = {Andrey Zharkikh and Wen-Hsiung Li },
+	Journal = {Molecular Biology and Evolution},
+	Pages = {1119-1147},
+	Title = {Statistical properties of Bootstrap estimation of     phylogenies variability from nucleotide     sequences. {I.} Four Taxa with a molecular clock.},
+	Volume = 9,
+	Year = 1992}
+
+ at article{zharkikh92b,
+	Author = { Andrey Zharkikh and Wen-Hsiung Li},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {356-366},
+	Title = {Statistical Properties of Bootstrap Estimation of     Phylogenetic Variability from Nucleotide Sequences:     {II.} Four Taxa without a Molecular Clock},
+	Volume = 35,
+	Year = 1992}
+
+ at article{zharkikh93,
+	Author = {A. Zharkikh and W.-H. Li},
+	Journal = {Systematic Biology},
+	Pages = {113-125},
+	Title = {Inconsistency of the Maximum Parsimony Method: The     Case of Five Taxa With a Molecular Clock},
+	Utilisateur = {Vincent},
+	Volume = 42,
+	Year = 1993}
+
+ at article{zharkikh94,
+	Author = {A. Zharkikh},
+	Journal = {Journal of Molecular Evolution},
+	Pages = {315-329},
+	Title = {Estimation of evolutionary distance between nucleotide sequences},
+	Volume = 39,
+	Year = 1994}
+
+ at article{zharkikh95,
+	Author = {A. Zharkikh and W.-H. Li},
+	Journal = {Mol. Phylogenet. Evol.},
+	Number = 1,
+	Pages = {44-63},
+	Title = {Estimation of confidence in phylogeny: the     complete-and-partial bootstrap technique},
+	Utilisateur = {Vincent et Olivier},
+	Volume = 4,
+	Year = 1995}
+
+ at inbook{zuckerkandl62,
+	Address = {Amsterdam},
+	Author = {E. Zuckerkandl and L. Pauling},
+        Editor = {M. Kasha and B. Pullman},
+	Chapter = {Molecular disease, evolution, and genic heterogeneity},
+	Pages = {189-225},
+	Publisher = {Elsevier},
+	Title = {Horizons in Biochemistry},
+	Year = 1962}
+
+ at incollection{vach92,
+	Author = {V. Vach},
+	Booktitle = {Analysing and Modeling Data and Knowledge},
+	Editor = {M. Shader},
+	Pages = {141-150},
+	Publisher = {Springer},
+	Title = {The Jukes-Cantor Transformation and Additivity of Estimated Genetic Distances},
+	Year = 1992}
+
+ at Article{wu85,
+   Author="Wu, C. I.  and Li, W. H. ",
+   Title="{{E}vidence for higher rates of nucleotide substitution in rodents than in man}",
+   Journal="Proc. Natl. Acad. Sci. U.S.A.",
+   Year="1985",
+   Volume="82",
+   Pages="1741--1745",
+   Month="Mar"
+}
+
+ at phdthesis{garli,
+	Author = {D. Zwickl},
+	School = {The University of Texas at Austin},
+	Title = {Genetic algorithm approaches for the phylogenetic analysis of large biological sequence datasets under the maximum likelihood criterion},
+	Year = {2006}}
diff --git a/examples/X1.mat b/examples/X1.mat
deleted file mode 100644
index fe52a1b..0000000
--- a/examples/X1.mat
+++ /dev/null
@@ -1,21 +0,0 @@
-0.295719
-0.067388 0.448317
-0.253712 0.457483 2.358429
-1.029289 0.576016 0.251987 0.189008
-0.107964 1.741924 0.216561 0.599450 0.029955
-0.514644 0.736017 0.503084 109.901504 0.084794 4.117654
-10.868848 0.704334 0.435271 1.070052 1.862626 0.246260 1.202023
-0.380498 5.658311 4.873453 5.229858 0.553477 6.508329 1.634845 0.404968
-0.084223 0.123387 0.090748 0.052764 0.151733 0.054187 0.060194 0.048984 0.204296
-0.086976 0.221777 0.033310 0.021407 0.230320 0.195703 0.069359 0.069963 0.504221 1.495537
-0.188789 93.433377 0.746537 0.621146 0.096955 1.669092 2.448827 0.256662 1.991533 0.091940 0.122332
-0.286389 0.382175 0.128905 0.081091 0.352526 0.810168 0.232297 0.228519 0.655465 1.994320 3.256485 0.457430
-0.155567 0.235965 0.127321 0.205164 0.590018 0.066081 0.064822 0.241077 6.799829 0.754940 2.261319 0.163849 1.559944
-1.671061 6.535048 0.904011 5.164456 0.386853 2.437439 3.537387 4.320442 11.291065 0.170343 0.848067 5.260446 0.426508 0.438856
-2.132922 0.525521 0.939733 0.747330 1.559564 0.165666 0.435384 3.656545 0.961142 0.050315 0.064441 0.360946 0.132547 0.306683 4.586081
-0.529591 0.303537 0.435450 0.308078 0.606648 0.106333 0.290413 0.290216 0.448965 0.372166 0.102493 0.389413 0.498634 0.109129 2.099355 3.634276
-0.115551 0.641259 0.046646 0.260889 0.587531 0.093417 0.280695 0.307466 6.227274 0.206332 0.459041 0.033291 0.559069 18.392863 0.411347 0.101797 0.034710
-0.102453 0.289466 0.262076 0.185083 0.592318 0.035149 0.105999 0.096556 20.304886 0.097050 0.133091 0.115301 0.264728 66.647302 0.476350 0.148995 0.063603 20.561407
-0.916683 0.102065 0.043986 0.080708 0.885230 0.072549 0.206603 0.306067 0.205944 5.381403 0.561215 0.112593 0.693307 0.400021 0.584622 0.089177 0.755865 0.133790 0.154902
-
-0.147383 0.017579 0.058208 0.017707 0.026331 0.041582 0.017494 0.027859 0.011849 0.076971 0.147823 0.019535 0.037132 0.029940 0.008059 0.088179 0.089653 0.006477 0.032308 0.097931
diff --git a/src/Makefile.am b/src/Makefile.am
index ea98a59..79155d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,9 +38,9 @@ if WANT_TEST
 bin_PROGRAMS = test
 PROG = TEST
 else
-if WANT_SERGEII
-bin_PROGRAMS = sergeii
-PROG = SERGEII
+if WANT_INVITEE
+bin_PROGRAMS = invitee
+PROG = INVITEE
 else
 if WANT_GEO
 bin_PROGRAMS = phylogeo
@@ -58,9 +58,9 @@ if WANT_BEAGLE
 bin_PROGRAMS = phyml-beagle
 PROG = PHYML
 else
-if WANT_MIGREP
-bin_PROGRAMS = migrep
-PROG = MIGREP
+if WANT_PHYREX
+bin_PROGRAMS = phyrex
+PROG = PHYREX
 else
 bin_PROGRAMS = phyml
 PROG = PHYML
@@ -109,7 +109,8 @@ make.c make.h\
 mixt.c mixt.h\
 init.c init.h\
 nexus.c nexus.h\
-xml.c xml.h
+xml.c xml.h\
+phyrex.c phyrex.h
 phytime_LDADD = -lm
 else 
 if WANT_PHYCONT
@@ -341,8 +342,8 @@ xml.c xml.h\
 mixt.c mixt.h
 test_LDADD = -lm
 else
-if WANT_SERGEII
-sergeii_SOURCES = main.c \
+if WANT_INVITEE
+invitee_SOURCES = main.c \
 utilities.c  utilities.h\
 optimiz.c  optimiz.h\
 lk.c  lk.h\
@@ -370,9 +371,9 @@ make.c make.h\
 nexus.c nexus.h\
 init.c init.h\
 xml.c xml.h\
-sergeii.c sergeii.h\
+invitee.c invitee.h\
 mixt.c mixt.h
-sergeii_LDADD = -lm 
+invitee_LDADD = -lm 
 else
 if WANT_EVOLVE
 evolve_SOURCES = main.c\
@@ -472,8 +473,8 @@ mixt.c mixt.h\
 checkpoint.c checkpoint.h
 checkpoint_LDADD = -lm
 else
-if WANT_MIGREP
-migrep_SOURCES = main.c\
+if WANT_PHYREX
+phyrex_SOURCES = main.c\
 utilities.c  utilities.h\
 optimiz.c  optimiz.h\
 lk.c  lk.h\
@@ -502,7 +503,7 @@ nexus.c nexus.h\
 init.c init.h\
 xml.c xml.h\
 mixt.c mixt.h\
-migrep.c migrep.h
+phyrex.c phyrex.h
 else
 if WANT_BEAGLE
 phyml_beagle_SOURCES = main.c \
diff --git a/src/Makefile_mc.am b/src/Makefile_mc.am
new file mode 100644
index 0000000..67c020e
--- /dev/null
+++ b/src/Makefile_mc.am
@@ -0,0 +1,39 @@
+# AM_CFLAGS=-mpowerpc
+# AM_CFLAGS=-O3 -fomit-frame-pointer -funroll-loops -Wall -m64
+# AM_CFLAGS=-O2 -Wall
+# AM_CFLAGS=-m64
+# AM_CFLAGS=-g -Wall
+
+# AM_LDFLAGS=-lm
+
+# DEFS = -DUNIX -D$(PROG) -DDEBUG -DBATCH -DQUIET
+# DEFS=-DUNIX -D$(PROG) -DDEBUG
+# DEFS=-DUNIX -D$(PROG) 
+# DEFS = -DUNIX -D$(PROG)
+
+AM_MAKEFLAGS = -f Makefile_mc
+
+bin_PROGRAMS = mc
+PROG = MC
+
+DEFS=-DUNIX -D$(PROG) -DDEBUG
+
+mc_SOURCES = main.c utilities.c optimiz.c lk.c bionj.c models.c free.c\
+help.c simu.c eigen.c pars.c alrt.c interface.c cl.c spr.c mc.c m4.c draw.c rates.c mcmc.c numeric.c
+
+# mc_LDADD = -lm
+
+
+# SCOMPILE = $(CC) $(SDEFS) $(DEFS) $(INCLUDES) $(AM_CFLAGS) $(SCFLAGS)
+# SCCLD = $(CC) $(LIBS)
+# SLINK = $(SCCLD) $(AM_CFLAGS) $(SLDFLAGS) $(LDFLAGS) $(INCLUDES) $(AM_LDFLAGS)
+
+all-am: intro mc$(EXEEXT)
+	@echo ""
+	@echo "Done."
+
+intro:	
+	@echo ""
+	@echo "** Building MC version $(VERSION) **"
+	@echo ""
+
diff --git a/src/Makefile_r.am b/src/Makefile_r.am
new file mode 100644
index 0000000..96f479f
--- /dev/null
+++ b/src/Makefile_r.am
@@ -0,0 +1,86 @@
+bin_PROGRAMS = rwrapper
+PROG = RWRAP
+
+rwrapper_SOURCES = main.c utilities.c optimiz.c lk.c bionj.c models.c free.c\
+help.c simu.c eigen.c pars.c alrt.c interface.c cl.c spr.c draw.c rates.c rwrapper.c numeric.c mcmc.c
+rwrapper_LDADD = main.o utilities.o optimiz.o lk.o bionj.o models.o free.o\
+options.o simu.o eigen.o pars.o alrt.o interface.o cl.o spr.o draw.o rates.o rwrapper.o numeric.o mcmc.o
+
+
+AM_CFLAGS=-fPIC -Wall
+
+AM_LDFLAGS=-lm
+
+DEFS=-DUNIX -D$(PROG) -DDEBUG
+
+# SCOMPILE = $(CC) $(SDEFS) $(DEFS) $(INCLUDES) $(AM_CFLAGS) $(SCFLAGS)
+SCOMPILE = $(CC) $(SDEFS) $(DEFS) $(INCLUDES) $(AM_CFLAGS) $(SCFLAGS) -I/Library/Frameworks/R.framework/Versions/2.8/Resources/include/
+SCCLD = $(CC) $(LIBS)
+SLINK = $(SCCLD) $(AM_CFLAGS) $(SLDFLAGS) $(LDFLAGS) $(INCLUDES) $(AM_LDFLAGS) -bundle -flat_namespace -undefined suppress
+
+rwrapper$(EXEEXT): $(rwrapper_LDADD) $(rwrapper_SOURCES)
+	$(SLINK) $(rwrapper_LDADD) -o $@.so
+
+main.o: main.c
+	$(SCOMPILE) -c main.c
+
+utilities.o: utilities.c utilities.h
+	$(SCOMPILE) -c utilities.c
+
+optimiz.o: optimiz.c optimiz.h
+	$(SCOMPILE) -c optimiz.c
+
+lk.o: lk.c lk.h
+	$(SCOMPILE) -c lk.c
+
+bionj.o: bionj.c bionj.h
+	$(SCOMPILE) -c bionj.c
+
+models.o: models.c models.h
+	$(SCOMPILE) -c models.c
+
+free.o: free.c free.h
+	$(SCOMPILE) -c free.c
+
+options.o: help.c help.h
+	$(SCOMPILE) -c help.c
+
+simu.o: simu.c simu.h
+	$(SCOMPILE) -c simu.c
+
+eigen.o: eigen.c eigen.h
+	$(SCOMPILE) -c eigen.c
+
+pars.o: pars.c pars.h
+	$(SCOMPILE) -c pars.c
+
+alrt.o: alrt.c alrt.h
+	$(SCOMPILE) -c alrt.c
+
+interface.o: interface.c interface.h
+	$(SCOMPILE) -c interface.c
+
+cl.o: cl.c cl.h
+	$(SCOMPILE) -c cl.c
+
+spr.o: spr.c spr.h
+	$(SCOMPILE) -c spr.c
+
+
+mg.o: mg.c
+	$(SCOMPILE) -c mg.c
+
+draw.o: draw.c
+	$(SCOMPILE) -c draw.c
+
+rates.o: rates.c
+	$(SCOMPILE) -c rates.c
+
+rwrapper.o: rwrapper.c
+	$(SCOMPILE) -c rwrapper.c
+
+numeric.o: numeric.c
+	$(SCOMPILE) -c numeric.c
+
+mcmc.o: mcmc.c
+	$(SCOMPILE) -c mcmc.c
diff --git a/src/alrt.c b/src/alrt.c
index ca4f02f..e8ed543 100644
--- a/src/alrt.c
+++ b/src/alrt.c
@@ -925,7 +925,7 @@ void Make_Target_Swap(t_tree *tree, t_edge *b_fcus, int swaptodo)
 //////////////////////////////////////////////////////////////
 
 /**
-* Convert an aLRT statistic to a none parametric support
+* Convert an aLRT statistic to a non-parametric support
 * param in: the statistic
 */
 
diff --git a/src/bionj.c b/src/bionj.c
index d05251e..8934ce1 100644
--- a/src/bionj.c
+++ b/src/bionj.c
@@ -38,7 +38,7 @@ 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); 
@@ -315,8 +315,7 @@ phydbl Dist(matrix *mat, int x, int y)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
-phydbl Variance(matrix *mat, int x, int y)
+phydbl BioNJ_Variance(matrix *mat, int x, int y)
 {
     if(x > y)
       {
@@ -353,12 +352,11 @@ phydbl Dist_Red(matrix *mat, int x, phydbl lx, int y, phydbl ly, int i, phydbl l
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 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);
 }
@@ -383,7 +381,7 @@ phydbl Lamda(matrix *mat, int x, int y, phydbl vxy)
 	    For(i,mat->n_otu)
 	      {
 		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);
 	  }
@@ -452,7 +450,7 @@ int Bionj_Br_Length_Post(t_node *a, t_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); 
diff --git a/src/bionj.h b/src/bionj.h
index 99e47c3..8f0d6c7 100644
--- a/src/bionj.h
+++ b/src/bionj.h
@@ -25,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);
diff --git a/src/cl.c b/src/cl.c
index 0616dd2..4e75756 100644
--- a/src/cl.c
+++ b/src/cl.c
@@ -118,10 +118,11 @@ int Read_Command_Line(option *io, int argc, char **argv)
       {"xml",                 required_argument,NULL,73},
       {"l_var",               required_argument,NULL,74},
 #ifdef BEAGLE
-	  {"beagle_resource",     required_argument,NULL,75},
+      {"beagle_resource",     required_argument,NULL,75},
 #endif
-      {"ancestral",    no_argument,NULL,76},
-      {"anc",    no_argument,NULL,76},
+      {"ancestral",           no_argument,NULL,76},
+      {"anc",                 no_argument,NULL,76},
+      {"coord_file",          required_argument,NULL,77},
       {0,0,0,0}
     };
 
@@ -139,6 +140,43 @@ int Read_Command_Line(option *io, int argc, char **argv)
 
       switch(c)
 	{
+
+        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;
@@ -146,10 +184,10 @@ int Read_Command_Line(option *io, int argc, char **argv)
           }
 #ifdef BEAGLE
 	case 75:
-		{
-	    	io->beagle_resource = (int)atoi(optarg);
-	    	break;
-	    }
+          {
+            io->beagle_resource = (int)atoi(optarg);
+            break;
+          }
 #endif
 	case 74:
           {
@@ -158,16 +196,14 @@ int Read_Command_Line(option *io, int argc, char **argv)
           }
 	case 73:
 	  {
-#ifndef SERGEII
+#ifndef INVITEE
             Free_Optimiz(io->mod->s_opt);
             M4_Free_M4_Model(io->mod->m4mod);
             Free_Model_Basic(io->mod);
             Free_Input(io);
             PhyML_XML(optarg);
             return 0;
-#endif
-
-#ifdef SERGEII            
+#else
             Free_Optimiz(io->mod->s_opt);
             M4_Free_M4_Model(io->mod->m4mod);
             Free_Model_Basic(io->mod);
@@ -175,6 +211,7 @@ int Read_Command_Line(option *io, int argc, char **argv)
             PhyTime_XML(optarg);
             return 0;
 #endif
+            break;
 	  }
 	case 72:
 	  {
@@ -688,6 +725,7 @@ int 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)
 		   )
 		  {
@@ -864,6 +902,11 @@ int Read_Command_Line(option *io, int argc, char **argv)
 		io->datatype              = AA;
 		io->mod->whichmodel       = HIVB;
 	      }
+	    else if(strcmp(optarg, "AB") == 0)
+	      {
+		io->datatype              = AA;
+		io->mod->whichmodel       = AB;
+	      }
 	    else if (strcmp(optarg, "CUSTOM") == 0)
 	      {
 		io->datatype              = AA;
@@ -1081,6 +1124,8 @@ int Read_Command_Line(option *io, int argc, char **argv)
 		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
                 
 		strcpy(io->out_stats_file,optarg);
@@ -1088,7 +1133,17 @@ int Read_Command_Line(option *io, int argc, char **argv)
 		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
+
+
 	      }
 	    Free (tmp);
 	    break;
@@ -1337,7 +1392,7 @@ int Read_Command_Line(option *io, int argc, char **argv)
   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 or HIVb.\n");
+      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");
@@ -1430,20 +1485,22 @@ int Read_Command_Line(option *io, int argc, char **argv)
       Exit("\n");
     }
   
-#ifndef PHYTIME
+#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_Printf("\n== Err. in file %s at line %d (function '%s').\n",__FILE__,__LINE__,__FUNCTION__);
-      Exit("\n");      
-    }
+     !strcmp(io->out_stats_file,io->in_align_file)) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
 
-  writemode = 1;
+  writemode = WRITE;
 
   io->fp_out_tree  = Openfile(io->out_tree_file,writemode);
   io->fp_out_stats = Openfile(io->out_stats_file,writemode);
 #endif
+  
+
+#if defined(PHYREX)
+  io->fp_out_summary = Openfile(io->out_summary_file,writemode);
+#endif
+
   writemode++; // just to silence a warning message at compilation
   
   if(io->mod->whichmodel == GTR) 
diff --git a/src/cl.h b/src/cl.h
index 69760a5..8bb5d37 100644
--- a/src/cl.h
+++ b/src/cl.h
@@ -23,7 +23,7 @@ the GNU public licence.  See http://www.opensource.org for details.
 #include "models.h"
 #include "free.h"
 #include "interface.h"
-#include "sergeii.h"
+#include "invitee.h"
 
 
 int Read_Command_Line(option *input, int argc, char **argv);
diff --git a/src/free.c b/src/free.c
index 4b21f7c..10ef233 100644
--- a/src/free.c
+++ b/src/free.c
@@ -103,6 +103,11 @@ void Free_Node(t_node *n)
   Free(n->score);
   Free(n->s_ingrp);
   Free(n->s_outgrp);
+  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; }  */
@@ -217,7 +222,6 @@ void Free_Bip(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Free_Cseq(calign *data)
 {
   int i;
@@ -231,11 +235,11 @@ void Free_Cseq(calign *data)
     {
       Free(data->c_seq[i]->name);
       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]->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);
@@ -245,7 +249,6 @@ void Free_Cseq(calign *data)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Free_Seq(align **d, int n_otu)
 {
   int i;
@@ -316,12 +319,19 @@ void Free_Tree_Pars(t_tree *mixt_tree)
       Free(tree->step_mat);
       Free(tree->site_pars);
 
-      For(i,2*tree->n_otu-3) Free_Edge_Pars(tree->a_edges[i]);
+      For(i,2*tree->n_otu-3) 
+        {
+          /* printf("\n. FREE b->num: %d %p %p",tree->a_edges[i]->num,tree->a_edges[i]->pars_l,tree->a_edges[i]->pars_r); */
+          Free_Edge_Pars(tree->a_edges[i]);
+        }
 
       if(tree->n_root)
         {
+          /* printf("\n. FREE b1->num: %d %p %p",tree->n_root->b[1]->num,tree->n_root->b[1]->pars_l,tree->n_root->b[1]->pars_r); */
           Free_Edge_Pars_Left(tree->n_root->b[1]);
           Free_Edge_Pars_Left(tree->n_root->b[2]);
+          /* if(tree->n_root->b[1]->pars_r) Free_Edge_Pars_Rght(tree->n_root->b[1]); */
+          /* if(tree->n_root->b[2]->pars_r) Free_Edge_Pars_Rght(tree->n_root->b[2]); */
         }
       else
         {
@@ -398,6 +408,8 @@ void Free_Tree_Lk(t_tree *mixt_tree)
           Free(tree->n_root->b[2]->Pij_rr);
           Free_Edge_Lk_Left(tree->n_root->b[1]);
           Free_Edge_Lk_Left(tree->n_root->b[2]);
+          /* if(tree->n_root->b[1]->p_lk_rght) Free_Edge_Lk_Rght(tree->n_root->b[1]); */
+          /* if(tree->n_root->b[2]->p_lk_rght) Free_Edge_Lk_Rght(tree->n_root->b[2]); */
         }
       else
         {
@@ -698,6 +710,7 @@ void Free_Input(option *io)
       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);
@@ -705,6 +718,7 @@ void Free_Input(option *io)
       Free(io->out_boot_stats_file);
       Free(io->out_stats_file);
       Free(io->out_lk_file);
+      Free(io->out_summary_file);
       Free(io->out_ps_file);
       Free(io->out_trace_file);
       Free(io->out_ancestral_file);
@@ -1033,12 +1047,8 @@ void MCMC_Free_MCMC(t_mcmc *mcmc)
   Free(mcmc->ess_run);
   Free(mcmc->start_ess);
   Free(mcmc->ess);
-  Free(mcmc->sum_val);
-  Free(mcmc->sum_valsq);
-  Free(mcmc->sum_curval_nextval);
-  Free(mcmc->first_val);
-  Free(mcmc->old_param_val);
-  Free(mcmc->new_param_val);
+  Free(mcmc->sampled_val);
+  Free(mcmc->mode);
   Free(mcmc);
 }
 
@@ -1090,7 +1100,7 @@ void RATES_Free_Rates(t_rate *rates)
       Free(rates->t_prior_max);
       Free(rates->t_floor);
       Free(rates->t_has_prior);
-      Free(rates->t_ranked);
+      Free(rates->t_rank);
       Free(rates->dens);
       Free(rates->triplet);
       Free(rates->n_jps);
@@ -1114,8 +1124,10 @@ void RATES_Free_Rates(t_rate *rates)
       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);
@@ -1128,6 +1140,11 @@ void RATES_Free_Rates(t_rate *rates)
       Free(rates->survival_dur);
       Free(rates->calib_prob);
       Free(rates->node_height_dens_log_norm_const_update);
+      Free(rates->curr_nd_for_cal);
+      Free(rates->t_prior_min_ori);
+      Free(rates->t_prior_max_ori);
+      Free(rates->times_partial_proba);
+      Free(rates->numb_calib_chosen);
     }
   Free_Calib(rates->calib);
   Free(rates);
@@ -1166,6 +1183,10 @@ void Free_Geo(t_geo *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);
@@ -1192,21 +1213,36 @@ void Free_Ldisk(t_ldsk *t)
     {
       Free(t->next);
       Free_Geo_Coord(t->coord);
-      if(t->min_coord) Free_Geo_Coord(t->min_coord);
-      if(t->max_coord) Free_Geo_Coord(t->max_coord);
+      /* if(t->min_coord) Free_Geo_Coord(t->min_coord); */
+      /* if(t->max_coord) Free_Geo_Coord(t->max_coord); */
       if(t->cpy_coord) Free_Geo_Coord(t->cpy_coord);
       Free(t);
     }
 
 }
 
-
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
+
+void Free_Poly(t_poly *p)
+{
+  int i;
+  For(i,p->n_poly_vert) Free_Geo_Coord(p->poly_vert[i]);
+  Free(p->poly_vert);
+  Free(p);
+}
+
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
+
+void Free_Mmod(t_phyrex_mod *mmod)
+{
+  Free_Geo_Coord(mmod->lim);
+  Free(mmod);
+}
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
+
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
diff --git a/src/free.h b/src/free.h
index da7a542..868325c 100644
--- a/src/free.h
+++ b/src/free.h
@@ -77,5 +77,7 @@ 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);
 
 #endif
diff --git a/src/geo.c b/src/geo.c
index 54da541..8d554c8 100644
--- a/src/geo.c
+++ b/src/geo.c
@@ -1768,7 +1768,6 @@ void GEO_Read_In_Landscape(char *file_name, t_geo *t, phydbl **ldscape, int **lo
           /* Exit("\n"); */
           continue;
         }
-
       
       /* sscanf(line+pos,"%lf %lf",&longitude,&lattitude); */
       if(fscanf(fp,"%lf",&longitude) == EOF) break;
diff --git a/src/help.c b/src/help.c
index 75847b1..46e34fa 100644
--- a/src/help.c
+++ b/src/help.c
@@ -137,8 +137,9 @@ void Usage()
   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\n",	 
-	 FLAT,LINE,FLAT,
+  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,
diff --git a/src/init.c b/src/init.c
index 81267dc..e3ac4ee 100644
--- a/src/init.c
+++ b/src/init.c
@@ -146,6 +146,7 @@ void Init_Tree(t_tree *tree, int n_otu)
   tree->dp                        = 0;
   tree->ignore_root               = YES;
   tree->annealing_temp            = 0.;
+  tree->both_sides                = NO;
 #ifdef BEAGLE
   tree->b_inst                    = UNINITIALIZED;
 #endif
@@ -519,6 +520,7 @@ void Set_Defaults_Input(option* io)
   io->fp_out_boot_stats          = NULL;
   io->fp_out_stats               = NULL;
   io->fp_out_ancestral           = NULL;
+  io->fp_in_coord                = NULL;
   io->long_tax_names             = NULL;
   io->short_tax_names            = NULL;
   io->lon                        = NULL;
@@ -564,10 +566,11 @@ void Set_Defaults_Input(option* io)
   io->codpos                     = -1;
   io->mutmap                     = NO;
   io->state_len                  = 1;
+  io->ancestral                  = NO;
+  io->use_xml                    = NO;
 #ifdef BEAGLE
   io->beagle_resource            = 0;
 #endif
-  io->ancestral                  = NO;
 
   MCMC_Init_MCMC_Struct(NULL,io,io->mcmc);
   RATES_Init_Rate_Struct(io->rates,NULL,-1);
@@ -626,9 +629,9 @@ void Set_Defaults_Model(t_mod *mod)
   mod->br_len_mult->v     = 1.0;
 
 
-#if !(defined PHYTIME || defined SERGEII)
+#if !(defined PHYTIME || defined INVITEE)
   mod->l_min = 1.E-8;
-  mod->l_max = 100.0;
+  mod->l_max = 10.0;
   /* mod->l_min = 1.E-4; */
   /* mod->l_max = 2.0; */
 #else
@@ -641,6 +644,7 @@ void Set_Defaults_Model(t_mod *mod)
 
   mod->br_len_mult->v          = 1.0;
   mod->br_len_mult_unscaled->v = 1.0;
+  mod->augmented               = NO;
 }
 
 //////////////////////////////////////////////////////////////
@@ -872,7 +876,7 @@ void RATES_Init_Rate_Struct(t_rate *rates, t_rate *existing_rates, int n_otu)
 
   rates->step_rate     = 1.E-4;
   rates->approx        = 1;
-  rates->bl_from_rt    = 0;
+  rates->bl_from_rt    = NO;
 
   rates->update_mean_l = NO;
   rates->update_cov_l  = NO;
@@ -884,52 +888,52 @@ void RATES_Init_Rate_Struct(t_rate *rates, t_rate *existing_rates, int n_otu)
   if(n_otu > 0)
     {
       For(i,(2*n_otu-2)*(2*n_otu-2)) rates->cov_l[i] = 0.0;
-
+      
       For(i,2*n_otu-2)
-    {
-      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,2*n_otu-1)
-    {
-      if(rates->model_log_rates == YES)
-        {
-          rates->nd_r[i]   = 0.0;
-          rates->br_r[i]   = 0.0;
-        }
-      else
         {
-          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;
+          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;
         }
-      else
+      
+      For(i,2*n_otu-1)
         {
-          rates->t_has_prior[i] = NO;
-          rates->t_prior_max[i] =  BIG;
-          rates->t_prior_min[i] = -BIG;
+          if(rates->model_log_rates == YES)
+            {
+              rates->nd_r[i]   = 0.0;
+              rates->br_r[i]   = 0.0;
+            }
+          else
+            {
+              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] =  BIG;
+              rates->t_prior_min[i] = -BIG;
+            }
+          
+          rates->br_do_updt[i] = YES;
+          rates->has_survived[i] = NO;
+          
+          rates->t_rank[i] = i;
         }
-
-      rates->br_do_updt[i] = YES;
-      rates->has_survived[i] = NO;
-
-      rates->t_ranked[i] = i;
-    }
     }
-
+  
   rates->calib = NULL;
   rates->update_time_norm_const = NO;
 }
@@ -1011,8 +1015,8 @@ void Init_Model(calign *data, t_mod *mod, option *io)
     {
       if(mod->ras->n_catg > 1)
         {
-          For(i,mod->ras->n_catg) mod->ras->gamma_rr->v[i]               = (phydbl)i;
-          For(i,mod->ras->n_catg) mod->ras->gamma_rr_unscaled->v[i]      = (phydbl)i;
+          For(i,mod->ras->n_catg) mod->ras->gamma_rr->v[i]          = (phydbl)i;
+          For(i,mod->ras->n_catg) mod->ras->gamma_rr_unscaled->v[i] = (phydbl)i;
         }
       else
         {
@@ -1030,6 +1034,7 @@ void Init_Model(calign *data, t_mod *mod, option *io)
       mod->e_frq->pi_unscaled->v[i] = mod->e_frq->pi->v[i] * 100.;
     }
 
+
   if(io->datatype == NT)
     {
       /* Set the substitution parameters to their default values
@@ -1040,17 +1045,30 @@ void Init_Model(calign *data, t_mod *mod, option *io)
           mod->lambda->v = 1.0;
         }
       
-      /* if(mod->s_opt->opt_rr) */
-      if(mod->whichmodel == GTR || mod->whichmodel == CUSTOM)
+      if(mod->whichmodel == CUSTOM)
         {
-          mod->r_mat->rr->v[AC]     = 1.0;
-          mod->r_mat->rr->v[AG]     = 4.0;
-          mod->r_mat->rr->v[AT]     = 1.0;
-          mod->r_mat->rr->v[CG]     = 1.0;
-          mod->r_mat->rr->v[CT]     = 4.0;
-          mod->r_mat->rr->v[GT]     = 1.0;
-
-          For(i,6) mod->r_mat->rr_val->v[i] = mod->r_mat->rr->v[i];
+          For(i,6) mod->r_mat->rr_val->v[i] = 1.0;
+
+          /* Condition below is true for 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;i<mod->r_mat->n_diff_rr;i++) mod->r_mat->rr_val->v[i] = 4.0;          
+            }
+          else if(mod->r_mat->n_diff_rr == 6) /* Custom <-> GTR model */
+            {
+              mod->r_mat->rr_val->v[AG] = 4.0;
+              mod->r_mat->rr_val->v[CT] = 4.0;
+            }
+        }
+      else if(mod->whichmodel == GTR)
+        {
+          For(i,6) mod->r_mat->rr_val->v[i] = 1.0;
+          mod->r_mat->rr_val->v[AG] = 4.0;
+          mod->r_mat->rr_val->v[CT] = 4.0;
         }
     }
   
@@ -1085,20 +1103,20 @@ void Init_Model(calign *data, t_mod *mod, option *io)
       if(mod->whichmodel == F81)
         {
           mod->kappa->v = 1.;
-          mod->update_eigen          = NO;
+          mod->update_eigen = NO;
         }
       
       if(mod->whichmodel == F84)
         {
           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;
+          mod->update_eigen = NO;
         }
       
       if(mod->whichmodel == TN93)
         {
-          mod->update_eigen          = NO;
-          if(io->mod->s_opt->opt_kappa) io->mod->s_opt->opt_lambda = 1;
+          mod->update_eigen = NO;
+          if(io->mod->s_opt->opt_kappa) io->mod->s_opt->opt_lambda = YES;
         }
       
       if(mod->whichmodel == GTR)
@@ -1260,10 +1278,22 @@ void Init_Model(calign *data, t_mod *mod, option *io)
               For(i,mod->ns) mod->e_frq->pi->v[i] = data->b_frq[i];
             break;
           }
+         case AB :
+          {
+            Init_Qmat_AB(mod->r_mat->qmat->v,mod->e_frq->pi->v);
+            if(mod->s_opt->opt_state_freq)
+              For(i,mod->ns) mod->e_frq->pi->v[i] = data->b_frq[i];
+            break;
+          } 
         case CUSTOMAA :
           {
+            if(mod->fp_aa_rate_mat == NULL)
+              {
+                PhyML_Printf("\n. Cannot open custom rate matrix file '%s'.\n",mod->aa_rate_mat_file->s); 
+                Exit("\n");
+              }
+
             Read_Qmat(mod->r_mat->qmat->v,mod->e_frq->pi->v,mod->fp_aa_rate_mat);
-	    Print_Qmat_AA(mod->r_mat->qmat->v,mod->e_frq->pi->v);
             if(mod->s_opt->opt_state_freq) For(i,mod->ns) mod->e_frq->pi->v[i] = data->b_frq[i];
 	    break;
 	  }
@@ -3244,6 +3274,85 @@ int Init_Qmat_MtMam(phydbl *daa, phydbl *pi)
 //////////////////////////////////////////////////////////////
 
 
+int Init_Qmat_AB(phydbl *daa, phydbl *pi)
+{
+    /*
+       This model has been 'translated' from Alexander Mirsky,Linda Kazandjian and Maria Anisimova into PHYML format by J-E Longueville.
+       Many thanks to them.
+    */
+
+    /*
+    Antibody-Specific Model of Amino Acid Substitution for Immunological Inferences from Alignments of Antibody Sequences
+    Alexander Mirsky, Linda Kazandjian and Maria Anisimova
+    Mol Biol Evol (2015) 32 (3): 806-819. doi: 10.1093/molbev/msu340 First published online: December 21, 2014
+    */
+
+    int i,j,naa;
+    naa = 20;
+
+    daa[1*20+0]= 1.784266E-01;         daa[2*20+0]= 9.291290E-02;       daa[2*20+1]= 7.829130E-01;       daa[3*20+0]= 1.241095E+00;
+    daa[3*20+1]= 5.795374E-02;         daa[3*20+2]= 7.185182E+00;       daa[4*20+0]= 8.929181E-03;       daa[4*20+1]= 1.821885E-01;
+    daa[4*20+2]= 1.374268E-06;         daa[4*20+3]= 2.340019E-02;       daa[5*20+0]= 1.992269E-01;       daa[5*20+1]= 1.923901E+00;
+    daa[5*20+2]= 8.705989E-02;         daa[5*20+3]= 1.843856E-01;       daa[5*20+4]= 1.046446E-08;       daa[6*20+0]= 9.521821E-01;
+    daa[6*20+1]= 6.273863E-02;         daa[6*20+2]= 5.038373E-01;       daa[6*20+3]= 7.426619E+00;       daa[6*20+4]= 7.519215E-11;
+    daa[6*20+5]= 3.691671E+00;         daa[7*20+0]= 1.851951E+00;       daa[7*20+1]= 1.089400E+00;       daa[7*20+2]= 4.868901E-01;
+    daa[7*20+3]= 2.112400E+00;         daa[7*20+4]= 5.891123E-02;       daa[7*20+5]= 5.516340E-02;       daa[7*20+6]= 1.389370E+00;
+    daa[8*20+0]= 5.241316E+00;         daa[8*20+1]= 1.049550E+01;       daa[8*20+2]= 1.405444E+01;       daa[8*20+3]= 1.126995E+01;
+    daa[8*20+4]= 3.963388E+00;         daa[8*20+5]= 8.908434E+00;       daa[8*20+6]= 7.298080E+00;       daa[8*20+7]= 9.139518E+00;
+    daa[9*20+0]= 1.140412E-01;          daa[9*20+1]= 3.245175E-01;         daa[9*20+2]= 1.762721E+00;         daa[9*20+3]= 3.916999E-02;
+    daa[9*20+4]= 6.594967E-04;        daa[9*20+5]= 6.712736E-06;         daa[9*20+6]= 1.029959E-04;          daa[9*20+7]= 3.560482E-02;
+    daa[9*20+8]= 4.706586E+00;         daa[10*20+0]= 6.969101E-02;        daa[10*20+1]= 3.932002E-01;        daa[10*20+2]= 2.769442E-02;
+    daa[10*20+3]= 3.020502E-02;         daa[10*20+4]= 6.079219E-03;       daa[10*20+5]= 6.802781E-01;        daa[10*20+6]= 1.283121E-03;
+    daa[10*20+7]= 2.157936E-02;         daa[10*20+8]= 5.879103E+00;        daa[10*20+9]= 1.601123E+00;       daa[11*20+0]= 7.388355E-02;
+    daa[11*20+1]= 7.549240E+00;       daa[11*20+2]= 6.190318E+00;       daa[11*20+3]= 6.622772E-02;        daa[11*20+4]= 3.722878E-16;
+    daa[11*20+5]= 3.030805E+00;       daa[11*20+6]= 3.608816E+00;       daa[11*20+7]= 5.504400E-02;        daa[11*20+8]= 1.455741E+00;
+    daa[11*20+9]= 5.059793E-01;        daa[11*20+10]= 2.158451E-02;       daa[12*20+0]= 6.299271E-02;       daa[12*20+1]= 3.362326E-01;
+    daa[12*20+2]= 3.972173E-02;         daa[12*20+3]= 3.357577E-02;         daa[12*20+4]= 7.213178E-03;       daa[12*20+5]= 1.233336E-03;
+    daa[12*20+6]= 7.659566E-02;         daa[12*20+7]= 2.187264E-02;        daa[12*20+8]= 2.298295E+00;       daa[12*20+9]= 1.096748E+01;
+    daa[12*20+10]= 5.647985E+00;      daa[12*20+11]= 1.238634E+00;      daa[13*20+0]= 1.130146E-01;         daa[13*20+1]= 8.208677E-02;
+    daa[13*20+2]= 1.955446E-01;        daa[13*20+3]= 1.031734E-01;         daa[13*20+4]= 1.993818E-01;        daa[13*20+5]= 1.496610E-03;
+    daa[13*20+6]= 5.288625E-02;         daa[13*20+7]= 1.984772E-01;         daa[13*20+8]= 5.642309E+00;       daa[13*20+9]= 2.714705E+00;
+    daa[13*20+10]= 3.390618E+00;      daa[13*20+11]= 4.649035E-03;       daa[13*20+12]= 3.947940E+00;      daa[14*20+0]= 1.800713E+00;
+    daa[14*20+1]= 3.498713E-01;        daa[14*20+2]= 7.342554E-03;        daa[14*20+3]= 1.509482E-01;        daa[14*20+4]= 4.878395E-03;
+    daa[14*20+5]= 7.426909E-01;        daa[14*20+6]= 2.889815E-02;        daa[14*20+7]= 7.915056E-02;        daa[14*20+8]= 1.049496E+01;
+    daa[14*20+9]= 5.016568E-02;        daa[14*20+10]= 1.149931E+00;       daa[14*20+11]= 9.948994E-03;       daa[14*20+12]= 7.417279E-02;
+    daa[14*20+13]= 3.556198E-01;       daa[15*20+0]= 9.988358E-01;       daa[15*20+1]= 1.926435E+00;       daa[15*20+2]= 7.348346E+00;
+    daa[15*20+3]= 5.822988E-01;       daa[15*20+4]= 2.639482E-01;        daa[15*20+5]= 5.906405E-04;       daa[15*20+6]= 6.776709E-02;
+    daa[15*20+7]= 9.984215E-01;       daa[15*20+8]= 5.439116E+00;       daa[15*20+9]= 6.007607E-01;         daa[15*20+10]= 1.580539E-01;
+    daa[15*20+11]= 8.688405E-02;       daa[15*20+12]= 1.861354E-02;        daa[15*20+13]= 9.813064E-01;       daa[15*20+14]= 1.284651E+00;
+    daa[16*20+0]= 2.912317E+00;       daa[16*20+1]= 2.147175E+00;        daa[16*20+2]= 1.135258E+00;       daa[16*20+3]= 1.516881E-01;
+    daa[16*20+4]= 3.225214E-06;       daa[16*20+5]= 1.202094E-01;       daa[16*20+6]= 6.016624E-02;        daa[16*20+7]= 7.862767E-02;
+    daa[16*20+8]= 3.443285E+00;        daa[16*20+9]= 3.087152E+00;        daa[16*20+10]= 5.702792E-01;       daa[16*20+11]= 1.039298E+00;
+    daa[16*20+12]= 1.415612E+00;      daa[16*20+13]= 3.674486E-02;       daa[16*20+14]= 9.057112E-01;       daa[16*20+15]= 3.058575E+00;
+    daa[17*20+0]= 7.939549E-02;         daa[17*20+1]= 5.724286E-01;        daa[17*20+2]= 7.310937E-04;        daa[17*20+3]= 1.423897E-02;
+    daa[17*20+4]= 4.440833E-01;        daa[17*20+5]= 4.332983E-05;        daa[17*20+6]= 2.252612E-02;        daa[17*20+7]= 1.386853E-01;
+    daa[17*20+8]= 7.013890E+00;        daa[17*20+9]= 6.318748E-02;        daa[17*20+10]= 3.378544E-01;       daa[17*20+11]= 8.024263E-03;
+    daa[17*20+12]= 1.011149E-01;      daa[17*20+13]= 2.199856E-01;      daa[17*20+14]= 5.516074E-03;        daa[17*20+15]= 1.385142E-01;
+    daa[17*20+16]= 1.412361E-02;        daa[18*20+0]= 1.433528E-01;        daa[18*20+1]= 1.711315E-01;        daa[18*20+2]= 2.622763E+00;
+    daa[18*20+3]= 9.078338E-01;         daa[18*20+4]= 7.741612E-01;       daa[18*20+5]= 2.737091E-02;        daa[18*20+6]= 1.240642E-01;
+    daa[18*20+7]= 2.295842E-01;        daa[18*20+8]= 2.055414E+01;       daa[18*20+9]= 2.903165E-01;        daa[18*20+10]= 1.521320E-01;
+    daa[18*20+11]= 7.109973E-02;        daa[18*20+12]= 2.246759E-03;       daa[18*20+13]= 7.074464E+00;     daa[18*20+14]= 1.992133E-01;
+    daa[18*20+15]= 8.104751E-01;       daa[18*20+16]= 9.984255E-02;       daa[18*20+17]= 6.121284E-01;      daa[19*20+0]= 3.774477E+00;
+    daa[19*20+1]= 1.366145E-01;        daa[19*20+2]= 4.931206E-02;        daa[19*20+3]= 4.076074E-01;         daa[19*20+4]= 2.243512E-02;
+    daa[19*20+5]= 9.047737E-03;        daa[19*20+6]= 5.795409E-01;        daa[19*20+7]= 4.228200E-01;         daa[19*20+8]= 6.890244E+00;
+    daa[19*20+9]= 7.926675E+00;      daa[19*20+10]= 3.595310E+00;      daa[19*20+11]= 3.493440E-02;       daa[19*20+12]= 4.396720E+00;
+    daa[19*20+13]= 1.643946E+00;       daa[19*20+14]= 2.217442E-01;       daa[19*20+15]= 7.477041E-02;       daa[19*20+16]= 2.166054E-01;
+    daa[19*20+17]= 9.663569E-02;       daa[19*20+18]= 5.010635E-01;
+
+    for (i=0; i<naa; i++)  for (j=0; j<i; j++)  daa[j*naa+i] = daa[i*naa+j];
+
+    pi[0]= 6.541704E-02;     pi[1]= 4.708366E-02;     pi[2]= 3.168984E-02;     pi[3]= 4.688141E-02 ;
+    pi[4]= 2.150693E-02;     pi[5]= 4.240711E-02;     pi[6]= 2.842211E-02;     pi[7]= 1.005278E-01;
+    pi[8]= 9.812606E-03;     pi[9]= 3.424424E-02;     pi[10]= 6.222565E-02;    pi[11]= 4.844488E-02;
+    pi[12]= 1.760370E-02;    pi[13]= 3.478555E-02;    pi[14]= 3.962469E-02;    pi[15]= 1.280566E-01;
+    pi[16]= 8.199314E-02;    pi[17]= 3.393045E-02;    pi[18]= 7.586119E-02;    pi[19]= 4.948141E-02;
+    
+    return 1;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
 void M4_Init_Model(m4 *m4mod, calign *data, t_mod *mod)
 {
   int i,j,ct;
@@ -3302,11 +3411,10 @@ void GEO_Init_Coord(t_geo_coord *t, int n_dim)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void MIGREP_Init_Disk_Event(t_dsk *t, int n_dim, t_migrep_mod *mmod)
+void PHYREX_Init_Disk_Event(t_dsk *t, int n_dim, t_phyrex_mod *mmod)
 {
   t->prev         = NULL;
   t->next         = NULL;
-  t->nd           = NULL;
   t->mmod         = NULL;
   Random_String(t->id,3);
 
@@ -3318,38 +3426,60 @@ void MIGREP_Init_Disk_Event(t_dsk *t, int n_dim, t_migrep_mod *mmod)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void MIGREP_Init_Migrep_Mod(t_migrep_mod *t, int n_dim)
+void PHYREX_Init_Migrep_Mod(t_phyrex_mod *t, int n_dim, phydbl max_lat, phydbl max_lon)
 {
-  t->n_dim           = n_dim;
-
-  t->lbda            = 0.1;
-  t->min_lbda        = 1.E-6;
-  t->max_lbda        = 1.E+2;
+  assert(n_dim == 2);
 
-  t->mu              = 0.1;
-  t->min_mu          = 0.0;
-  t->max_mu          = 1.0;
-
-  t->rad             = 3.0;
-  t->min_rad         = 1.E-6;
-  t->max_rad         = 10.;
-  t->prior_param_rad = 0.3;
+  t->name             = PHYREX_NORMAL;
+  t->n_dim            = n_dim;
+  t->safe_phyrex      = NO;
+  
+  t->lim->lonlat[0]   = max_lat;
+  t->lim->lonlat[1]   = max_lon;
+
+  t->lbda             = 1.E-0;
+  t->min_lbda         = 1.E-6;
+  t->max_lbda         = 1.E+2;
+  t->prior_param_lbda = 1.0;
+
+  t->mu               = 0.300;
+  t->min_mu           = 0.001;
+  t->max_mu           = 1.000;
+  t->prior_param_mu   = 1.000;
+
+  t->min_rad           = 0.0;
+  t->max_rad           = 0.25*(max_lat+max_lon);
+  t->rad               = .10*(max_lat+max_lon);
+  t->prior_param_rad   = 0.5;
+  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->sampl_area      = 0.0;
 }
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void MIGREP_Init_Lindisk_Node(t_ldsk *t, t_dsk *disk, int n_dim)
+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->is_coal = NO;
   t->n_next  = 0;
   GEO_Init_Coord(t->coord,    n_dim);
   GEO_Init_Coord(t->cpy_coord,n_dim);
@@ -3357,3 +3487,77 @@ void MIGREP_Init_Lindisk_Node(t_ldsk *t, t_dsk *disk, int n_dim)
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
+
+void MCMC_Init_MCMC_Struct(char *filename, option *io, t_mcmc *mcmc)
+{
+  int pid;
+
+  mcmc->io               = io;
+  mcmc->is               = NO;
+  mcmc->use_data         = YES;
+  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; */
+    }
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
diff --git a/src/init.h b/src/init.h
index 6044c2e..7beea75 100644
--- a/src/init.h
+++ b/src/init.h
@@ -48,6 +48,7 @@ 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_Triplet_Struct(triplet *triplet);
@@ -59,8 +60,9 @@ 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 MIGREP_Init_Disk_Event(t_dsk *t, int n_dim, t_migrep_mod *mod);
-void MIGREP_Init_Lindisk_Node(t_ldsk *t, t_dsk *devt, int n_dim);
-void MIGREP_Init_Migrep_Mod(t_migrep_mod *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 max_lat, phydbl max_lon);
+void MCMC_Init_MCMC_Struct(char *filename, option *io, t_mcmc *mcmc);
 
 #endif
diff --git a/src/interface.c b/src/interface.c
index 959e853..dc91189 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -99,7 +99,7 @@ void Launch_Interface(option *io)
   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 or HIVb.\n");
+      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");
@@ -1331,6 +1331,10 @@ void Launch_Interface_Model(option *io)
 	      }
 	    else if(io->mod->whichmodel == HIVB)
 	      {
+		io->mod->whichmodel = AB;
+		  }
+		else if(io->mod->whichmodel == AB)
+	      {
 		io->mod->whichmodel = CUSTOMAA;
 	      }
 	    else if(io->mod->whichmodel == CUSTOMAA)
diff --git a/src/sergeii.c b/src/invitee.c
similarity index 99%
rename from src/sergeii.c
rename to src/invitee.c
index 7490cdf..2f49697 100644
--- a/src/sergeii.c
+++ b/src/invitee.c
@@ -11,7 +11,7 @@
 #include "pars.h"
 #include "alrt.h"
 #include "mixt.h"
-#include "sergeii.h"
+#include "invitee.h"
 #ifdef MPI
 #include "mpi_boot.h"
 #endif
@@ -265,7 +265,7 @@ void PhyTime_XML(char *xml_file)
               s = To_Upper_String(n_r -> child -> value);
 	      do
 		{
-                  strcpy(io -> in_align_file, "sergeii"); 
+                  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);
diff --git a/src/sergeii.h b/src/invitee.h
similarity index 98%
rename from src/sergeii.h
rename to src/invitee.h
index 1854f34..0b00c7a 100644
--- a/src/sergeii.h
+++ b/src/invitee.h
@@ -1,5 +1,5 @@
-#ifndef SERGEII_H
-#define SERGEII_H
+#ifndef INVITEE_H
+#define INVITEE_H
 
 #include "utilities.h"
 
diff --git a/src/io.c b/src/io.c
index 577c14c..8dd69e2 100644
--- a/src/io.c
+++ b/src/io.c
@@ -58,65 +58,65 @@ t_tree *Read_Tree(char **s_tree)
    }
 
   if(degree > 3) /* Multifurcation at the root. Need to re-assemble the subtrees
-            since Clean_Multifurcation added sets of prevhesis and
-            the corresponding NULL edges */
+                    since Clean_Multifurcation added sets of parenthesis and
+                    the corresponding NULL edges */
     {
       degree = 3;
       Free((*s_tree));
       len = 0;
       For(i,degree) len += (strlen(subs[i])+1);
       len += 5;
-
+      
       (*s_tree) = (char *)mCalloc(len,sizeof(char));
-
+      
       (*s_tree)[0] = '('; (*s_tree)[1] = '\0';
       For(i,degree)
-    {
-      strcat((*s_tree),subs[i]);
-      strcat((*s_tree),",\0");
-    }
-
+        {
+          strcat((*s_tree),subs[i]);
+          strcat((*s_tree),",\0");
+        }
+      
       sprintf((*s_tree)+strlen((*s_tree))-1,"%s",");\0");
-
+      
       For(i,NODE_DEG_MAX) Free(subs[i]);
       Free(subs);
-
+      
       subs = Sub_Trees((*s_tree),&degree);
     }
-
+  
   root_node->tax = 0;
-
+  
   tree->has_branch_lengths = 0;
   tree->num_curr_branch_available = 0;
   For(i,degree) R_rtree((*s_tree),subs[i],root_node,tree,&n_int,&n_ext);
-
+  
   for(i=degree;i<NODE_DEG_MAX;i++) Free(subs[i]);
   Free(subs);
-
+  
   if(tree->n_root)
     {
       tree->e_root = tree->a_edges[tree->num_curr_branch_available];
-
+      
       tree->n_root->v[2] = tree->n_root->v[0];
       tree->n_root->v[0] = NULL;
-
+      
       tree->n_root->l[2] = tree->n_root->l[0];
-
+      
       For(i,3) if(tree->n_root->v[2]->v[i] == tree->n_root) { tree->n_root->v[2]->v[i] = tree->n_root->v[1]; break; }
       For(i,3) if(tree->n_root->v[1]->v[i] == tree->n_root) { tree->n_root->v[1]->v[i] = tree->n_root->v[2]; break; }
-
+      
       Connect_One_Edge_To_Two_Nodes(tree->n_root->v[2],
-                        tree->n_root->v[1],
-                        tree->e_root,
-                        tree);
-
+                                    tree->n_root->v[1],
+                                    tree->e_root,
+                                    tree);
+      
       tree->e_root->l->v = tree->n_root->l[2] + tree->n_root->l[1];
       if(tree->e_root->l->v > 0.0)
-    tree->n_root_pos = tree->n_root->l[2] / tree->e_root->l->v;
+        tree->n_root_pos = tree->n_root->l[2] / tree->e_root->l->v;
       else
-    tree->n_root_pos = .5;
+        tree->n_root_pos = .5;
     }
-
+  
   return tree;
 }
 
@@ -148,8 +148,7 @@ void R_rtree(char *s_tree_a, char *s_tree_d, t_node *a, t_tree *tree, int *n_int
         {
           PhyML_Printf("\n== The number of internal nodes in the tree exceeds the number of taxa minus one.");
           PhyML_Printf("\n== There probably is a formating problem in the input tree.");
-          PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
-          Exit("\n");
+          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
         }
 
       d      = tree->a_nodes[n_otu+*n_int];
@@ -223,22 +222,22 @@ void R_rtree(char *s_tree_a, char *s_tree_d, t_node *a, t_tree *tree, int *n_int
       Read_Branch_Length(s_tree_d,s_tree_a,tree);
 
       For(i,3)
-    {
-     if(!a->v[i])
-       {
-         a->v[i]=d;
-         d->l[0]=tree->a_edges[tree->num_curr_branch_available]->l->v;
-         a->l[i]=tree->a_edges[tree->num_curr_branch_available]->l->v;
-         break;
-       }
-    }
+        {
+          if(!a->v[i])
+            {
+              a->v[i]=d;
+              d->l[0]=tree->a_edges[tree->num_curr_branch_available]->l->v;
+              a->l[i]=tree->a_edges[tree->num_curr_branch_available]->l->v;
+              break;
+            }
+        }
       d->v[0]=a;
-
+      
       if(a != tree->n_root)
-    {
-      Connect_One_Edge_To_Two_Nodes(a,d,tree->a_edges[tree->num_curr_branch_available],tree);
-    }
-
+        {
+          Connect_One_Edge_To_Two_Nodes(a,d,tree->a_edges[tree->num_curr_branch_available],tree);
+        }
+      
       d->num=*n_ext;
       (*n_ext)+=1;
     }
@@ -579,8 +578,8 @@ char *Write_Tree(t_tree *tree, int custom)
           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++;
-
+                (!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],&available,&s,tree);
           R_wtree(tree->a_nodes[tree->n_otu+i],tree->a_nodes[tree->n_otu+i]->v[1],&available,&s,tree);
           R_wtree(tree->a_nodes[tree->n_otu+i],tree->a_nodes[tree->n_otu+i]->v[2],&available,&s,tree);
@@ -602,7 +601,7 @@ char *Write_Tree(t_tree *tree, int custom)
           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++;
+                (!tree->a_nodes[tree->n_otu+i]->v[2])) i++;
 
           R_wtree_Custom(tree->a_nodes[tree->n_otu+i],tree->a_nodes[tree->n_otu+i]->v[0],&available,&s,&pos,tree);
           R_wtree_Custom(tree->a_nodes[tree->n_otu+i],tree->a_nodes[tree->n_otu+i]->v[1],&available,&s,&pos,tree);
@@ -630,7 +629,7 @@ void R_wtree(t_node *pere, t_node *fils, int *available, char **s_tree, t_tree *
   int i,p;
   char *format;
   int last_len;
-#if !(defined PHYTIME || defined SERGEII)
+#if !(defined PHYTIME || defined INVITEE)
   phydbl mean_len;
 #endif
 
@@ -651,13 +650,16 @@ void R_wtree(t_node *pere, t_node *fils, int *available, char **s_tree, t_tree *
           if(tree->write_tax_names == YES)
             {
               if(tree->io && tree->io->long_tax_names)
-            {
-              strcat(*s_tree,tree->io->long_tax_names[fils->num]);
-            }
+                {
+                  strcat(*s_tree,tree->io->long_tax_names[fils->num]);
+                }
               else
-            {
-              strcat(*s_tree,fils->name);
-            }
+                {
+                  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)
             {
@@ -674,72 +676,72 @@ void R_wtree(t_node *pere, t_node *fils, int *available, char **s_tree, t_tree *
 	  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))
-    {
-      (*s_tree)[(int)strlen(*s_tree)] = ':';
-
-#if !(defined PHYTIME || defined SERGEII)
-      if(!tree->n_root)
         {
+          (*s_tree)[(int)strlen(*s_tree)] = ':';
+          
+#if !(defined PHYTIME || defined INVITEE)
+          if(!tree->n_root)
+            {
               if(tree->is_mixt_tree == NO)
                 {
                   mean_len = fils->b[0]->l->v;
                 }
               else mean_len = MIXT_Get_Mean_Edge_Len(fils->b[0],tree);
-          sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len));
-        }
-      else
-        {
-          if(pere == tree->n_root)
-        {
-          phydbl root_pos = (fils == tree->n_root->v[2])?(tree->n_root_pos):(1.-tree->n_root_pos);
+              sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len));
+            }
+          else
+            {
+              if(pere == tree->n_root)
+                {
+                  phydbl root_pos = (fils == tree->n_root->v[2])?(tree->n_root_pos):(1.-tree->n_root_pos);
                   if(tree->is_mixt_tree == NO)
                     {
                       mean_len = tree->e_root->l->v;
                     }
                   else mean_len = MIXT_Get_Mean_Edge_Len(tree->e_root,tree);
-          sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len) * root_pos);
-        }
-          else
-        {
+                  sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len) * root_pos);
+                }
+              else
+                {
                   if(tree->is_mixt_tree == NO)
                     {
                       mean_len = fils->b[0]->l->v;
                     }
-
+                  
                   else mean_len = MIXT_Get_Mean_Edge_Len(fils->b[0],tree);
                   sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len));
-        }
-        }
+                }
+            }
 #else
-      if(!tree->n_root)
-        {
-          sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,fils->b[0]->l->v));
-        }
-      else
-        {
+          if(!tree->n_root)
+            {
+              sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,fils->b[0]->l->v));
+            }
+          else
+            {
               if(tree->rates) sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,tree->rates->cur_l[fils->num]));
-        }
+            }
 #endif
-    }
-
+        }
+      
       /* strcat(*s_tree,","); */
       (*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_Printf("\n== s=%s\n",*s_tree);
           PhyML_Printf("\n== len=%d\n",(int)strlen(*s_tree));
           PhyML_Printf("\n== The sequence names in your input file might be too long.");
-          PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+          PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
           Warn_And_Exit("");
         }
       
@@ -751,35 +753,35 @@ void R_wtree(t_node *pere, t_node *fils, int *available, char **s_tree, t_tree *
           /* printf("\n. ++ 0 Available = %d",(*available)); */
         }
 #endif
-
+      
     }
   else
     {
       (*s_tree)[(int)strlen(*s_tree)]='(';
-
+      
 #ifndef MPI
       (*available) -= 1;
-
+      
       /* printf("\n1 Available = %d [%d %d]",(*available),(int)strlen(*s_tree),last_len); */
       /* printf("\n1 %s [%d,%d]",*s_tree,(int)(int)strlen(*s_tree),*available); */
-
+      
       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,3*(int)T_MAX_NAME) (*s_tree)[(int)strlen(*s_tree)+i] = '\0';
+          For(i,3*(int)T_MAX_NAME) (*s_tree)[(int)strlen(*s_tree)+i] = '\0';
           (*available) = 3*(int)T_MAX_NAME;
-      /* printf("\n. ++ 1 Available = %d",(*available)); */
+          /* printf("\n. ++ 1 Available = %d",(*available)); */
         }
 #endif
       /* (*available)--; */
-
+      
       /* if(*available < (int)T_MAX_NAME/2) */
       /* 	{ */
       /* 	  (*s_tree) = (char *)mRealloc(*s_tree,*pos+(int)T_MAX_NAME,sizeof(char)); */
       /* 	  (*available) = (int)T_MAX_NAME; */
       /* 	} */
-
-
+      
+      
       if(tree->n_root)
         {
           For(i,3)
@@ -798,19 +800,20 @@ void R_wtree(t_node *pere, t_node *fils, int *available, char **s_tree, t_tree *
               else p=i;
             }
         }
-
+      
       if(p < 0)
         {
+          PhyML_Printf("\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_Printf("\n== fils=%p root=%p root->v[2]=%p root->v[1]=%p",fils,tree->n_root,tree->n_root->v[2],tree->n_root->v[1]);
           PhyML_Printf("\n== tree->e_root=%p fils->b[0]=%p fils->b[1]=%p fils->b[2]=%p",tree->e_root,fils->b[0],fils->b[1],fils->b[2]);
           PhyML_Printf("\n== Err. in file %s at line %d (function '%s')\n",__FILE__,__LINE__,__FUNCTION__);
           Exit("\n");
         }
-
+      
       last_len = (int)strlen(*s_tree);
-
+      
       (*s_tree)[last_len-1] = ')';
-
+      
       if((fils->b) && (tree->write_br_lens == YES))
         {
           if(tree->print_boot_val)
@@ -826,7 +829,7 @@ void R_wtree(t_node *pere, t_node *fils, int *available, char **s_tree, t_tree *
           
           (*s_tree)[(int)strlen(*s_tree)] = ':';
           
-#if !(defined PHYTIME || defined SERGEII)
+#if !(defined PHYTIME || defined INVITEE)
           if(!tree->n_root)
             {
               if(tree->is_mixt_tree == NO)
@@ -844,7 +847,7 @@ void R_wtree(t_node *pere, t_node *fils, int *available, char **s_tree, t_tree *
                   
                   if(tree->is_mixt_tree == NO)
                     {
-                      mean_len = tree->e_root->l->v;
+                      mean_len = (tree->e_root)?(tree->e_root->l->v):(-1.0);
                     }
                   else mean_len = MIXT_Get_Mean_Edge_Len(tree->e_root,tree);
                   sprintf(*s_tree+(int)strlen(*s_tree),format,MAX(0.0,mean_len) * root_pos);
@@ -962,7 +965,7 @@ void R_wtree_Custom(t_node *pere, t_node *fils, int *available, char **s_tree, i
       strcat(*s_tree,":");
       (*pos)++;
 
-#if !(defined PHYTIME || defined SERGEII)
+#if !(defined PHYTIME || defined INVITEE)
       if(!tree->n_root)
         {
           (*pos) += sprintf(*s_tree+*pos,format,fils->b[0]->l->v);
@@ -1090,7 +1093,7 @@ void R_wtree_Custom(t_node *pere, t_node *fils, int *available, char **s_tree, i
       strcat(*s_tree,":");
       (*pos)++;
 
-#if !(defined PHYTIME || defined SERGEII)
+#if !(defined PHYTIME || defined INVITEE)
       if(!tree->n_root)
         {
           (*pos) += sprintf(*s_tree+*pos,format,fils->b[p]->l->v);
@@ -1266,7 +1269,7 @@ align **Get_Seq(option *io)
         break;
       }
     }
-
+  
   if(!io->data)
     {
       PhyML_Printf("\n== Err. in file %s at line %d (function '%s')\n",__FILE__,__LINE__,__FUNCTION__);
@@ -1286,7 +1289,8 @@ align **Get_Seq(option *io)
 
 void Post_Process_Data(option *io)
 {
-  int i,j;
+  int i,j,swap;
+  align *data_buff;
 
   For(i,io->data[0]->len)
     {
@@ -1299,8 +1303,32 @@ void Post_Process_Data(option *io)
     }
 
   For(i,io->n_otu) io->data[i]->len = io->data[0]->len;
+
+  /* Sequences are ordered alphabetically */
+  data_buff = NULL;
+  swap = TRUE;
+  while(swap == TRUE)
+    {
+      swap = FALSE;
+      For(i,io->n_otu-1)
+        {
+          for(j=i+1;j<io->n_otu;j++)
+            {
+              if(strcmp(io->data[i]->name,io->data[j]->name) < 0)
+                {
+                  swap = TRUE;
+                  data_buff = io->data[i];
+                  io->data[i] = io->data[j];
+                  io->data[j] = data_buff;
+                }
+            }
+        }
+    }
 }
 
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
 /* align **Get_Seq_Nexus(option *io) */
 /* { */
 /*   char *s,*ori_s; */
@@ -1468,21 +1496,22 @@ int Get_Token(FILE *fp, char *token)
   char c;
 
   c = ' ';
-  while(c == ' ' || c == '\t' || c == '\n')
+
+  while(c == ' ' || c == '\t' || c == '\n' || c == '\r')
     {
       c = fgetc(fp);
       if(c == EOF) return 0;
     }
-
+  
   if(c == '"')
     {
       do
-    {
-      *token = c;
-      token++;
-      c = fgetc(fp);
-      if(c == EOF) return 0;
-    }
+        {
+          *token = c;
+          token++;
+          c = fgetc(fp);
+          if(c == EOF) return 0;
+        }
       while(c != '"');
       *token = c;
       /* c = fgetc(fp); */
@@ -1490,7 +1519,7 @@ int Get_Token(FILE *fp, char *token)
       *(token+1) = '\0';
       return 1;
     }
-
+  
   if(c == '[')
     {
       Skip_Comment(fp);
@@ -1515,12 +1544,12 @@ int Get_Token(FILE *fp, char *token)
   else
     {
       while(isgraph(c) && c != ';' && c != '-' && c != ',' && c != '=')
-    {
-      *(token++) = c;
-      c = fgetc(fp);
-      if(c == EOF) return 0;
-    }
-
+        {
+          *(token++) = c;
+          c = fgetc(fp);
+          if(c == EOF) return 0;
+        }
+      
       fseek(fp,-1*sizeof(char),SEEK_CUR);
 
     }
@@ -1823,7 +1852,6 @@ align **Read_Seq_Interleaved(option *io)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 int Read_One_Line_Seq(align ***data, int num_otu, FILE *in)
 {
   char c = ' ';
@@ -2229,12 +2257,12 @@ void Print_CSeq(FILE *fp, int compressed, calign *cdata)
   For(i,n_otu)
     {
       For(j,50)
-    {
-      if(j<(int)strlen(cdata->c_seq[i]->name))
-        fputc(cdata->c_seq[i]->name[j],fp);
-      else fputc(' ',fp);
-    }
-
+        {
+          if(j<(int)strlen(cdata->c_seq[i]->name))
+            fputc(cdata->c_seq[i]->name[j],fp);
+          else fputc(' ',fp);
+        }
+      
       if(compressed == YES) /* Print out compressed sequences */
         PhyML_Fprintf(fp,"%s",cdata->c_seq[i]->state);
       else /* Print out uncompressed sequences */
@@ -2346,14 +2374,10 @@ void Print_Node(t_node *a, t_node *d, t_tree *tree)
   int dir;
   dir = -1;
   For(i,3) if(a->v[i] == d) {dir = i; break;}
-  PhyML_Printf("Node nums: %3d %3d  (dir:%3d) (anc:%3d) ta:%12f [%12f;%12f] td:%12f [%12f;%12f];",
+  PhyML_Printf("Node nums: %3d %3d  (dir:%3d) (anc:%3d) ta:%12f td:%12f;",
                a->num,d->num,dir,a->anc?a->anc->num:(-1),
                tree->rates?tree->rates->nd_t[a->num]:-1.,
-               tree->rates?tree->rates->t_prior_min[a->num]:-1.,
-               tree->rates?tree->rates->t_prior_max[a->num]:-1.,
-               tree->rates?tree->rates->nd_t[d->num]:-1.,
-               tree->rates?tree->rates->t_prior_min[d->num]:-1.,
-               tree->rates?tree->rates->t_prior_max[d->num]:-1.);
+               tree->rates?tree->rates->nd_t[d->num]:-1.);
 
   PhyML_Printf("Node names = '%10s' '%10s' ; ",a->name,d->name);
   For(i,3) if(a->v[i] == d)
@@ -2505,15 +2529,14 @@ void Print_Model(t_mod *mod)
       PMat(0.01*mod->ras->gamma_rr->v[k],mod,mod->ns*mod->ns*k,mod->Pij_rr->v);
       PhyML_Printf("\n. l=%f\n",0.01*mod->ras->gamma_rr->v[k]);
       For(i,mod->ns)
-    {
-      PhyML_Printf("  ");
-      For(j,mod->ns)
-        PhyML_Printf("%8.5f  ",mod->Pij_rr->v[k*mod->ns*mod->ns+i*mod->ns+j]);
-      PhyML_Printf("\n");
-    }
+        {
+          PhyML_Printf("  ");
+          For(j,mod->ns)
+            PhyML_Printf("%8.5f  ",mod->Pij_rr->v[k*mod->ns*mod->ns+i*mod->ns+j]);
+          PhyML_Printf("\n");
+        }
     }
-
-
+    
   PhyML_Printf("\n");
 
   fflush(NULL);
@@ -2695,18 +2718,21 @@ void Print_Fp_Out(FILE *fp_out, time_t t_beg, time_t t_end, t_tree *tree, option
       PhyML_Fprintf(fp_out,"\n  - Number of classes: \t\t\t%d",tree->mod->ras->n_catg);
       PhyML_Fprintf(fp_out,"\n  - Gamma shape parameter: \t\t%.3f",tree->mod->ras->alpha->v);
       For(i,tree->mod->ras->n_catg)
-    {
-      PhyML_Fprintf(fp_out,"\n  - Relative rate in class %d: \t\t%.5f [freq=%4f] \t\t",i+1,tree->mod->ras->gamma_rr->v[i],tree->mod->ras->gamma_r_proba->v[i]);
-    }
+        {
+          PhyML_Fprintf(fp_out,"\n  - Relative rate in class %d: \t\t%.5f [freq=%4f] \t\t",i+1,tree->mod->ras->gamma_rr->v[i],tree->mod->ras->gamma_r_proba->v[i]);
+        }
     }
   else if(tree->mod->ras->free_mixt_rates == YES)
     {
+      int *rk;
+      rk = Ranks(tree->mod->ras->gamma_rr->v,tree->mod->ras->n_catg);
       PhyML_Fprintf(fp_out,"\n. FreeRate model: \t\t\t%s","Yes");
       PhyML_Fprintf(fp_out,"\n  - Number of classes: \t\t\t%d",tree->mod->ras->n_catg);
       For(i,tree->mod->ras->n_catg)
-    {
-      PhyML_Fprintf(fp_out,"\n  - Relative rate in class %d: \t\t%.5f [freq=%4f] \t\t",i+1,tree->mod->ras->gamma_rr->v[i],tree->mod->ras->gamma_r_proba->v[i]);
-    }
+        {
+          PhyML_Fprintf(fp_out,"\n  - Relative rate in class %d: \t\t%.5f [freq=%4f] \t\t",i+1,tree->mod->ras->gamma_rr->v[rk[i]],tree->mod->ras->gamma_r_proba->v[rk[i]]);
+        }
+      Free(rk);
     }
 
   if(tree->mod->ras->invar) PhyML_Fprintf(fp_out,"\n. Proportion of invariant: \t\t%.3f",tree->mod->ras->pinvar->v);
@@ -3114,18 +3140,18 @@ void Print_Settings(option *io)
   if (io->datatype == NT)
     {
       if ((io->mod->whichmodel == K80)  ||
-      (io->mod->whichmodel == HKY85)||
-      (io->mod->whichmodel == F84)  ||
-      (io->mod->whichmodel == TN93))
-    {
-      if (io->mod->s_opt->opt_kappa)
-        PhyML_Printf("\n                . Ts/tv ratio:\t\t\t\t\t estimated");
-      else
-        PhyML_Printf("\n                . Ts/tv ratio:\t\t\t\t\t %f", io->mod->kappa->v);
-    }
+          (io->mod->whichmodel == HKY85)||
+          (io->mod->whichmodel == F84)  ||
+          (io->mod->whichmodel == TN93))
+        {
+          if(io->mod->s_opt && io->mod->s_opt->opt_kappa)
+            PhyML_Printf("\n                . Ts/tv ratio:\t\t\t\t\t estimated");
+          else
+            PhyML_Printf("\n                . Ts/tv ratio:\t\t\t\t\t %f", io->mod->kappa->v);
+        }
     }
 
-  if (io->mod->s_opt->opt_pinvar)
+  if(io->mod->s_opt && io->mod->s_opt->opt_pinvar)
     PhyML_Printf("\n                . Proportion of invariable sites:\t\t estimated");
   else
     PhyML_Printf("\n                . Proportion of invariable sites:\t\t %f", io->mod->ras->pinvar->v);
@@ -3135,54 +3161,52 @@ void Print_Settings(option *io)
   if(io->mod->ras->n_catg > 1)
     {
       if(io->mod->ras->free_mixt_rates == NO)
-    {
-      if(io->mod->s_opt->opt_alpha)
-        PhyML_Printf("\n                . Gamma distribution parameter:\t\t\t estimated");
-      else
-        PhyML_Printf("\n                . Gamma distribution parameter:\t\t\t %f", io->mod->ras->alpha->v);
-      PhyML_Printf("\n                . 'Middle' of each rate class:\t\t\t %s",(io->mod->ras->gamma_median)?("median"):("mean"));
-    }
+        {
+          if(io->mod->s_opt && io->mod->s_opt->opt_alpha)
+            PhyML_Printf("\n                . Gamma distribution parameter:\t\t\t estimated");
+          else
+            PhyML_Printf("\n                . Gamma distribution parameter:\t\t\t %f", io->mod->ras->alpha->v);
+          PhyML_Printf("\n                . 'Middle' of each rate class:\t\t\t %s",(io->mod->ras->gamma_median)?("median"):("mean"));
+        }
     }
-
-
+  
+  
   if(io->datatype == AA)
     PhyML_Printf("\n                . Amino acid equilibrium frequencies:\t\t %s", (io->mod->s_opt->opt_state_freq) ? ("empirical"):("model"));
   else if(io->datatype == NT)
     {
       if((io->mod->whichmodel != JC69) &&
-     (io->mod->whichmodel != K80)  &&
-     (io->mod->whichmodel != F81))
-    {
-      if(!io->mod->s_opt->user_state_freq)
-        {
-          PhyML_Printf("\n                . Nucleotide equilibrium frequencies:\t\t %s", (io->mod->s_opt->opt_state_freq) ? ("ML"):("empirical"));
-        }
-      else
+         (io->mod->whichmodel != K80)  &&
+         (io->mod->whichmodel != F81))
         {
-          PhyML_Printf("\n                . Nucleotide equilibrium frequencies:\t\t %s","user-defined");
+          if(io->mod->s_opt && !io->mod->s_opt->user_state_freq)
+            {
+              PhyML_Printf("\n                . Nucleotide equilibrium frequencies:\t\t %s", (io->mod->s_opt->opt_state_freq) ? ("ML"):("empirical"));
+            }
+          else
+            {
+              PhyML_Printf("\n                . Nucleotide equilibrium frequencies:\t\t %s","user-defined");
+            }
         }
     }
-    }
-
-  PhyML_Printf("\n                . Optimise tree topology:\t\t\t %s", (io->mod->s_opt->opt_topo) ? "yes": "no");
-
+  
+  PhyML_Printf("\n                . Optimise tree topology:\t\t\t %s", (io->mod->s_opt && io->mod->s_opt->opt_topo) ? "yes": "no");
+  
   switch(io->in_tree)
     {
     case 0: { strcpy(s,"BioNJ");     break; }
     case 1: { strcpy(s,"parsimony"); break; }
     case 2: { strcpy(s,"user tree (");
-    strcat(s,Basename(io->in_tree_file));
-    strcat(s,")");         break; }
+        strcat(s,Basename(io->in_tree_file));
+        strcat(s,")");         break; }
     }
-
-  if(io->mod->s_opt->opt_topo)
+  
+  if(io->mod->s_opt && io->mod->s_opt->opt_topo)
     {
       if(io->mod->s_opt->topo_search == NNI_MOVE) PhyML_Printf("\n                . Tree topology search:\t\t\t\t NNIs");
       else if(io->mod->s_opt->topo_search == SPR_MOVE) PhyML_Printf("\n                . Tree topology search:\t\t\t\t SPRs");
       else if(io->mod->s_opt->topo_search == BEST_OF_NNI_AND_SPR) PhyML_Printf("\n                . Tree topology search:\t\t\t\t Best of NNIs and SPRs");
-
-
-
+      
       PhyML_Printf("\n                . Starting tree:\t\t\t\t %s",s);
 
       PhyML_Printf("\n                . Add random input tree:\t\t\t %s", (io->mod->s_opt->random_input_tree) ? "yes": "no");
@@ -3190,17 +3214,18 @@ void Print_Settings(option *io)
     PhyML_Printf("\n                . Number of random starting trees:\t\t %d", io->mod->s_opt->n_rand_starts);
     }
   else
-    if(!io->mod->s_opt->random_input_tree)
+    if(io->mod->s_opt && !io->mod->s_opt->random_input_tree)
       PhyML_Printf("\n                . Evaluated tree:\t\t\t\t \"%s\"",s);
 
-  PhyML_Printf("\n                . Optimise branch lengths:\t\t\t %s", (io->mod->s_opt->opt_bl) ? "yes": "no");
+  PhyML_Printf("\n                . Optimise branch lengths:\t\t\t %s", (io->mod->s_opt && io->mod->s_opt->opt_bl) ? "yes": "no");
 
   answer = 0;
-  if(io->mod->s_opt->opt_alpha  ||
-     io->mod->s_opt->opt_kappa  ||
-     io->mod->s_opt->opt_lambda ||
-     io->mod->s_opt->opt_pinvar ||
-     io->mod->s_opt->opt_rr) answer = 1;
+  if(io->mod->s_opt &&
+     (io->mod->s_opt->opt_alpha  ||
+      io->mod->s_opt->opt_kappa  ||
+      io->mod->s_opt->opt_lambda ||
+      io->mod->s_opt->opt_pinvar ||
+      io->mod->s_opt->opt_rr)) answer = 1;
 
   PhyML_Printf("\n                . Optimise substitution model parameters:\t %s", (answer) ? "yes": "no");
 
@@ -3319,6 +3344,7 @@ void Read_Qmat(phydbl *daa, phydbl *pi, FILE *fp)
   phydbl sum;
   double val;
 
+  assert(fp);
   rewind(fp);
 
   for(i=1;i<20;i++)
@@ -3735,7 +3761,7 @@ void PhyML_Printf(char *format, ...)
       va_end(ptr);
 #endif
 
-  fflush (NULL);
+  /* fflush (NULL); */
 }
 
 //////////////////////////////////////////////////////////////
@@ -3759,7 +3785,7 @@ void PhyML_Fprintf(FILE *fp, char *format, ...)
       va_end(ptr);
 #endif
 
-  fflush (NULL);
+  /* fflush (NULL); */
 }
 
 //////////////////////////////////////////////////////////////
@@ -3915,10 +3941,10 @@ option *Get_Input(int argc, char **argv)
   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;
   io->mod->m4mod = m4mod;
   mod->io        = io;
@@ -3926,11 +3952,12 @@ option *Get_Input(int argc, char **argv)
 
 #ifdef MPI
   rv = Read_Command_Line(io,argc,argv);
-#elif (defined PHYTIME || defined SERGEII)
+#elif (defined PHYTIME || defined INVITEE)
   rv = Read_Command_Line(io,argc,argv);
 #else
   putchar('\n');
 
+
   switch (argc)
     {
     case 1:
@@ -3938,15 +3965,13 @@ option *Get_Input(int argc, char **argv)
         Launch_Interface(io);
         break;
       }
-      /*
-        case 2:
-        Usage();
-        break;
-      */
     default:
-      rv = Read_Command_Line(io,argc,argv);
+      {
+        rv = Read_Command_Line(io,argc,argv);
+      }
     }
 #endif
+
   
   if(rv) return io;
   else   return NULL;
@@ -4082,6 +4107,11 @@ int Set_Whichmodel(int select)
       {
     wm = LG;
     break;
+	  }
+    case 27:
+      {
+    wm = AB;
+    break;
       }
     default:
       {
@@ -4153,6 +4183,9 @@ void Print_Data_Structure(int final, FILE *fp, t_tree *mixt_tree)
   if(final == YES)
     PhyML_Fprintf(fp,"\n. Final log-likelihood: %f",mixt_tree->c_lnL);
 
+  r_mat_weight_sum = MIXT_Get_Sum_Chained_Scalar_Dbl(mixt_tree->next->mod->r_mat_weight);
+  e_frq_weight_sum = MIXT_Get_Sum_Chained_Scalar_Dbl(mixt_tree->next->mod->e_frq_weight);
+
   do
     {
       int class = 0;
@@ -4183,15 +4216,12 @@ void Print_Data_Structure(int final, FILE *fp, t_tree *mixt_tree)
         }
       PhyML_Fprintf(fp,"\n. Relative average rate:\t\t%12f",mixt_tree->mod->br_len_mult->v);
 
-      
-      r_mat_weight_sum = MIXT_Get_Sum_Chained_Scalar_Dbl(mixt_tree->next->mod->r_mat_weight);
-      e_frq_weight_sum = MIXT_Get_Sum_Chained_Scalar_Dbl(mixt_tree->next->mod->e_frq_weight);
-
+     
       tree = mixt_tree;
       do
         {
           if(tree->is_mixt_tree) tree = tree->next;
-          
+
           PhyML_Fprintf(fp,"\n");
           PhyML_Fprintf(fp,"\n. Mixture class %d",class+1);
           
@@ -4269,9 +4299,9 @@ void Print_Data_Structure(int final, FILE *fp, t_tree *mixt_tree)
                 {
                   strcpy(s,"Model");
                 }
-
-          PhyML_Fprintf(fp,"\n   Amino-acid freq.:\t\t%12s",s);
-
+              
+              PhyML_Fprintf(fp,"\n   Amino-acid freq.:\t\t%12s",s);
+              
               Free(s);
             }
 
@@ -4540,11 +4570,11 @@ void Print_Data_Structure(int final, FILE *fp, t_tree *mixt_tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void PhyML_XML(char *xml_filename)
+option *PhyML_XML(char *xml_filename)
 {
   FILE *fp;
   xml_node *root,*p_elem,*m_elem,*parent,*instance;
-  option *io;
+  option *io,*dum;
   void *buff;
   t_mod *mod,*iomod;
   t_tree *tree,*mixt_tree,*root_tree;
@@ -4605,6 +4635,10 @@ void PhyML_XML(char *xml_filename)
   ori_lens_var_old = NULL;
   first            = YES;
 
+
+  dum = (option *)mCalloc(1,sizeof(option));
+  dum->use_xml = YES;
+
   // Make sure there are no duplicates in node's IDs
   XML_Check_Duplicate_ID(root);
 
@@ -4703,7 +4737,24 @@ void PhyML_XML(char *xml_filename)
         }
     }
   
-  
+  s = XML_Get_Attribute_Value(p_elem,"quiet");
+  if(s)
+    {
+      select = XML_Validate_Attr_Int(s,6,
+                                     "true","yes","y",
+                                     "false","no","n");
+      if(select < 3) io->quiet = YES;
+    }
+
+  s = XML_Get_Attribute_Value(p_elem,"memory.check");
+  if(s)
+    {
+      select = XML_Validate_Attr_Int(s,6,
+                                     "true","yes","y",
+                                     "false","no","n");
+      if(select >= 3) io->mem_question = NO;
+    }
+
   /*! Read all partitionelem nodes and mixturelem nodes in each of them
    */
   do
@@ -5004,7 +5055,7 @@ void PhyML_XML(char *xml_filename)
                           Set_Defaults_Model(this_mod);
                           this_mod->ras->n_catg = 1;
 
-                          /*! All br_len_mupltiplier point to the corresponding */
+                          /*! All br_len_multiplier point to the corresponding */
                           /*! parameter in the relevant mixt_tree */
                           Free_Scalar_Dbl(this_mod->br_len_mult);
                           this_mod->br_len_mult = iomod->br_len_mult;                          
@@ -5111,12 +5162,24 @@ void PhyML_XML(char *xml_filename)
                               ds->next      = (t_ds *)mCalloc(1,sizeof(t_ds));
                               ds = ds->next;
                               ds->obj = (t_string *)(mod->custom_mod_string);
+
+
+                              /*! Create and connect the data structure n->ds->next to mod->fp_aa_rate_mat */
+                              ds->next      = (t_ds *)mCalloc(1,sizeof(t_ds));
+                              ds = ds->next;
+                              ds->obj = (FILE *)(mod->fp_aa_rate_mat);
+
+                              /*! Create and connect the data structure n->ds->next to mod->aa_rate_mat_file */
+                              ds->next      = (t_ds *)mCalloc(1,sizeof(t_ds));
+                              ds = ds->next;
+                              ds->obj = (t_string *)mod->aa_rate_mat_file;                              
                             }
                           else
                             {
                               /*! Connect to already extisting r_mat & kappa structs. */
                               t_ds *ds;
                               
+                              
                               ds = instance->ds;
                               Free(mod->r_mat);
                               mod->r_mat             = (t_rmat *)ds->obj;
@@ -5144,6 +5207,14 @@ void PhyML_XML(char *xml_filename)
                               ds = ds->next;
                               Free_String(mod->custom_mod_string);
                               mod->custom_mod_string = (t_string *)ds->obj;
+
+                              ds = ds->next;
+                              mod->fp_aa_rate_mat = (FILE *)ds->obj;
+
+                              ds = ds->next;
+                              Free_String(mod->aa_rate_mat_file);
+                              mod->aa_rate_mat_file = (t_string *)ds->obj;
+
                             }
                         }
                       
@@ -5550,7 +5621,7 @@ void PhyML_XML(char *xml_filename)
           {
             if(!mixt_tree->io->fp_in_tree)
               {
-                PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+                PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
                 Exit("\n");
               }
 
@@ -5599,7 +5670,7 @@ void PhyML_XML(char *xml_filename)
       do
         {
           if(tree != mixt_tree) Copy_Tree(mixt_tree,tree);
-          Connect_CSeqs_To_Nodes(tree->data,tree);
+          Connect_CSeqs_To_Nodes(tree->data,io,tree);
           tree = tree->next;
         }
       while(tree);
@@ -5802,6 +5873,8 @@ void PhyML_XML(char *xml_filename)
   Free(class_num);
 
   fclose(fp);
+
+  return(dum);
 }
 
 //////////////////////////////////////////////////////////////
@@ -5825,7 +5898,7 @@ void Check_Taxa_Sets(t_tree *mixt_tree)
               if(strcmp(tree->a_nodes[i]->name,tree->next->a_nodes[i]->name))
                 {
                   PhyML_Printf("\n== There seems to be a problem in one (or more) of your");
-                  PhyML_Printf("\n== sequence alignment. PhyML could not match taxon");
+                  PhyML_Printf("\n== sequence alignments. PhyML could not match taxon");
                   PhyML_Printf("\n== '%s' found in file '%s' with any of the taxa",tree->a_nodes[i]->name,tree->io->in_align_file);
                   PhyML_Printf("\n== listed in file '%s'.",tree->next->io->in_align_file);
                   Exit("\n");
@@ -5855,7 +5928,7 @@ void Make_Ratematrice_From_XML_Node(xml_node *instance, option *io, t_mod *mod)
       Exit("\n");
     }
 
-  select = XML_Validate_Attr_Int(model,26,
+  select = XML_Validate_Attr_Int(model,27,
                                  "xxxxx",    //0
                                  "JC69",     //1
                                  "K80",      //2
@@ -5882,7 +5955,9 @@ void Make_Ratematrice_From_XML_Node(xml_node *instance, option *io, t_mod *mod)
                                  "HIVB",     //23
                                  "FLU",      //24
                                  "CUSTOMAA", //25
-                                 "LG");      //26
+                                 "LG",       //26
+                                 "AB" );     //27
+
 
   if(select < 9)
     {
@@ -6004,7 +6079,7 @@ void Make_Ratematrice_From_XML_Node(xml_node *instance, option *io, t_mod *mod)
           strcpy(mod->aa_rate_mat_file->s,r_mat_file);
         }
 
-      Free(r_mat_file);
+      /* Free(r_mat_file); */
     }
 
   char *buff;
@@ -6062,7 +6137,7 @@ void Make_Efrq_From_XML_Node(xml_node *instance, option *io, t_mod *mod)
               mod->s_opt->opt_state_freq = NO;
             }
         }
-      Free(buff);
+      /* Free(buff); */
     }
 
 
@@ -6182,39 +6257,48 @@ void Make_Topology_From_XML_Node(xml_node *instance, option *io, t_mod *mod)
           int select;
 
           search = XML_Get_Attribute_Value(instance,"search");
-          select = XML_Validate_Attr_Int(search,4,"spr","nni","best","none");
-
-          switch(select)
-            {
-            case 0:
-              {
+          
+          if(search == NULL) 
+            { 
                 io->mod->s_opt->topo_search = SPR_MOVE;
                 io->mod->s_opt->opt_topo    = YES;
-                break;
-              }
-            case 1:
-              {
-                io->mod->s_opt->topo_search = NNI_MOVE;
-                io->mod->s_opt->opt_topo    = YES;
-                break;
-              }
-            case 2:
-              {
-                io->mod->s_opt->topo_search = BEST_OF_NNI_AND_SPR;
-                io->mod->s_opt->opt_topo    = YES;
-                break;
-              }
-            case 3:
-              {
-                io->mod->s_opt->opt_topo    = NO;
-                break;
-              }
-            default:
-              {
-                PhyML_Printf("\n== Topology search option '%s' is not valid.",search);
-                Exit("\n");
-                break;
-              }
+            }
+          else
+            {
+              select = XML_Validate_Attr_Int(search,4,"spr","nni","best","none");
+              
+              switch(select)
+                {
+                case 0:
+                  {
+                    io->mod->s_opt->topo_search = SPR_MOVE;
+                    io->mod->s_opt->opt_topo    = YES;
+                    break;
+                  }
+                case 1:
+                  {
+                    io->mod->s_opt->topo_search = NNI_MOVE;
+                    io->mod->s_opt->opt_topo    = YES;
+                    break;
+                  }
+                case 2:
+                  {
+                    io->mod->s_opt->topo_search = BEST_OF_NNI_AND_SPR;
+                    io->mod->s_opt->opt_topo    = YES;
+                    break;
+                  }
+                case 3:
+                  {
+                    io->mod->s_opt->opt_topo    = NO;
+                    break;
+                  }
+                default:
+                  {
+                    PhyML_Printf("\n== Topology search option '%s' is not valid.",search);
+                    Exit("\n");
+                    break;
+                  }
+                }
             }
         }
     }
diff --git a/src/io.h b/src/io.h
index c511660..0422aa8 100644
--- a/src/io.h
+++ b/src/io.h
@@ -75,7 +75,7 @@ option *Get_Input(int argc,char **argv);
 void Print_Data_Structure(int final, FILE *fp, t_tree *root);
 int Set_Whichmodel(int select);
 void Print_Site(calign *cdata, int num, int n_otu, char *sep, int stepsize, FILE *fp);
-void PhyML_XML(char *xml_filename);
+option *PhyML_XML(char *xml_filename);
 void Check_Taxa_Sets(t_tree *mixt_tree);
 void Make_Ratematrice_From_XML_Node(xml_node *instance, option *io, t_mod *mod);
 void Make_Efrq_From_XML_Node(xml_node *instance, option *io, t_mod *mod);
diff --git a/src/lk.c b/src/lk.c
index 65ac5fd..96c2a9d 100644
--- a/src/lk.c
+++ b/src/lk.c
@@ -16,13 +16,6 @@ the GNU public licence. See http://www.opensource.org for details.
 #include "beagle_utils.h"
 #endif
 
-
-int n_sec2 = 0;
-/* int    LIM_SCALE; */
-/* phydbl LIM_SCALE_VAL; */
-/* phydbl BIG; */
-/* phydbl SMALL; */
-
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
@@ -75,7 +68,6 @@ void Init_Tips_At_One_Site_Nucleotides_Float(char state, int pos, phydbl *p_lk)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Init_Tips_At_One_Site_Nucleotides_Int(char state, int pos, short int *p_pars)
 {
   switch(state)
@@ -414,28 +406,32 @@ void Pre_Order_Lk(t_node *a, t_node *d, t_tree *tree)
 phydbl Lk(t_edge *b, t_tree *tree)
 {
   int br;
-
+  
   if(b == NULL && tree->mod->s_opt->curr_opt_free_rates == YES)
     {
       tree->mod->s_opt->curr_opt_free_rates = NO;
       Optimize_Free_Rate_Weights(tree,YES,YES);
       tree->mod->s_opt->curr_opt_free_rates = YES;
     }
-
-
+  
+  
   if(tree->is_mixt_tree) {
 #ifdef BEAGLE
-      Warn_And_Exit(TODO_BEAGLE);
+    Warn_And_Exit(TODO_BEAGLE);
 #endif
-      return MIXT_Lk(b,tree);
+    return MIXT_Lk(b,tree);
   }
-
+  
   tree->old_lnL = tree->c_lnL;
 
-#if (defined PHYTIME || defined SERGEII)
-  if((tree->rates) && (tree->rates->bl_from_rt)) RATES_Update_Cur_Bl(tree);
+  
+#ifdef PHYREX
+  PHYREX_Ldsk_To_Tree(tree);
 #endif
 
+#if (defined PHYTIME || defined INVITEE || defined PHYREX)
+  if((tree->rates) && (tree->rates->bl_from_rt)) RATES_Update_Cur_Bl(tree);
+#endif
 
   if(tree->rates && tree->io->lk_approx == NORMAL)
     {
@@ -445,20 +441,19 @@ phydbl Lk(t_edge *b, t_tree *tree)
       tree->c_lnL = Lk_Normal_Approx(tree);
       return tree->c_lnL;
     }
-
-  if(!b){
-    Set_Model_Parameters(tree->mod);
-  }
+  
+  if(!b) Set_Model_Parameters(tree->mod);
+  
   Set_Br_Len_Var(tree);
-
+  
   if(tree->mod->s_opt->skip_tree_traversal == NO)
     {
       if(!b)//Update the PMat for all edges
         {
           For(br,2*tree->n_otu-3)
-          {
+            {
               Update_PMat_At_Given_Edge(tree->a_edges[br],tree);
-          }
+            }
           if(tree->n_root && tree->ignore_root == NO)
             {
               Update_PMat_At_Given_Edge(tree->n_root->b[1],tree);
@@ -469,7 +464,7 @@ phydbl Lk(t_edge *b, t_tree *tree)
         {
           Update_PMat_At_Given_Edge(b,tree);
         }
-
+      
       if(!b)
         {
           if(tree->n_root)
@@ -492,8 +487,8 @@ phydbl Lk(t_edge *b, t_tree *tree)
                 {
                   Post_Order_Lk(tree->e_root->rght,tree->e_root->left,tree);
                   Post_Order_Lk(tree->e_root->left,tree->e_root->rght,tree);
-
-              if(tree->both_sides == YES)
+                  
+                  if(tree->both_sides == YES)
                     {
                       Pre_Order_Lk(tree->e_root->rght,tree->e_root->left,tree);
                       Pre_Order_Lk(tree->e_root->left,tree->e_root->rght,tree);
@@ -528,6 +523,7 @@ phydbl Lk(t_edge *b, t_tree *tree)
 #ifdef BEAGLE
   calc_edgelks_beagle(b, tree);
 #else
+
   int n_patterns,ambiguity_check,state;
   n_patterns = tree->n_pattern;
   For(tree->curr_site,n_patterns)
@@ -537,10 +533,10 @@ phydbl Lk(t_edge *b, t_tree *tree)
 
       if(tree->data->wght[tree->curr_site] > SMALL)
         {
-          if((b->rght->tax) && (!tree->mod->s_opt->greedy))
+          if((b->rght->tax) && (tree->mod->s_opt->greedy == NO))
             {
               ambiguity_check = b->rght->c_seq->is_ambigu[tree->curr_site];
-              if(!ambiguity_check)
+              if(ambiguity_check == NO)
                 {
                   state = b->rght->c_seq->d_state[tree->curr_site];
                 }
@@ -549,7 +545,9 @@ phydbl Lk(t_edge *b, t_tree *tree)
           if(tree->mod->use_m4mod) ambiguity_check = YES;
 
           Lk_Core(state,ambiguity_check,b,tree);
-//          fprintf(stdout,",%g:%d\n",tree->c_lnL,tree->data->wght[tree->curr_site]);fflush(stdout);
+
+          /* fprintf(stdout,"site %d lnL: %g:%d %g\n",tree->curr_site,tree->c_lnL_sorted[tree->curr_site],tree->data->wght[tree->curr_site],tree->c_lnL); */
+          /* fflush(stdout); */
         }
     }
 #endif
@@ -597,14 +595,14 @@ phydbl Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree)
 #endif
   dim2 = tree->mod->ns;
   dim3 = tree->mod->ns * tree->mod->ns;//Dimensions of the transition prob. matrix
-
+  
   log_site_lk     = .0;
   site_lk         = .0;
   site_lk_cat     = .0;
   site            = tree->curr_site;
   ns              = tree->mod->ns;
-
-
+  
+  
   /* Skip this if no tree traveral was required, i.e. likelihood in each class of the mixture is already up to date */
   if(tree->mod->s_opt->skip_tree_traversal == NO)
     {
@@ -615,7 +613,7 @@ phydbl Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree)
           site_lk_cat = .0;
 
           /* b is an external edge */
-          if((b->rght->tax) && (!tree->mod->s_opt->greedy))//By convention, tips are always on the right of an external edge
+          if((b->rght->tax) && (!tree->mod->s_opt->greedy)) /* By convention, tips are always on the right of an external edge */
             {
               if(!ambiguity_check)/* If the character observed at the tip is NOT ambiguous: ns x 1 terms to consider */
                 {
@@ -634,7 +632,7 @@ phydbl Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree)
                   For(k,ns)
                     {
                       sum = .0;
-                      if(b->p_lk_tip_r[site*dim2+k] > .0) //Only bother ascending into the subtrees if the likelihood of state k, at site "site*dim2" is > 0
+                      if(b->p_lk_tip_r[site*dim2+k] > .0) /* Only bother ascending into the subtrees if the likelihood of state k, at site "site*dim2" is > 0 */
                         {
                           For(l,ns)
                             {
@@ -672,17 +670,16 @@ phydbl Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree)
                     }
                 }
             }
-                    
-          tree->site_lk_cat[catg] = site_lk_cat;
           
-          //      fprintf(stdout,"[%d,%d,%d]site_lk_cat:%e,e.frq:%f,edge:%d,tax:%d\n",catg,site,state,site_lk_cat,tree->mod->e_frq->pi->v[state],b->num,b->rght->tax);fflush(stdout);
+          tree->site_lk_cat[catg] = site_lk_cat;
           
-        }//site likelihood for all rate classes          
+        } /* site likelihood for all rate classes */
       Pull_Scaling_Factors(site,b,tree);
     }
 
   fact_sum_scale = tree->fact_sum_scale[site];
 
+
   //Likelihood of the site; is the sum of the individual rate specific likelihoods
   site_lk = .0;
   For(catg,tree->mod->ras->n_catg)
@@ -709,7 +706,7 @@ phydbl Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree)
   
   log_site_lk = LOG(site_lk) - (phydbl)LOG2 * fact_sum_scale; // log_site_lk =  log(site_lk_scaled / 2^(left_subtree+right_subtree))      
   
-  // Calculation of the site likelihood (using the scaling factors)...
+  // Calculation of the site likelihood (using scaling factors)...
   int piecewise_exponent;
   phydbl multiplier;
   if(fact_sum_scale >= 0)
@@ -728,8 +725,8 @@ phydbl Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree)
   else
     {
       //In some cases fact_sum_scale can be negative. If you rescale the partials of two independent subtrees and make some of
-          //these numbers large in order to avoid underflow, then there is a chance that when multiplied them together you will
-          //get an overflow, in which case fact_sum_scale can become negative.
+      //these numbers large in order to avoid underflow, then there is a chance that when multiplied them together you will
+      //get an overflow, in which case fact_sum_scale can become negative.
       
       tree->cur_site_lk[site] = site_lk;
       exponent = fact_sum_scale;
@@ -805,7 +802,6 @@ phydbl Lk_Core(int state, int ambiguity_check, t_edge *b, t_tree *tree)
       Exit("\n");
     }
 
-
 /* Multiply log likelihood by the number of times this site pattern is found in the data */
   tree->c_lnL_sorted[site] = tree->data->wght[site]*log_site_lk;
   
@@ -1100,7 +1096,7 @@ void Update_P_Lk_Generic(t_tree *tree, t_edge *b, t_node *d)
       state_v1 = state_v2 = -1;
       ambiguity_check_v1 = ambiguity_check_v2 = NO;
 
-      if(!tree->mod->s_opt->greedy)
+      if(tree->mod->s_opt->greedy == NO)
         {
           /* n_v1 and n_v2 are tip nodes */
           if(n_v1 && n_v1->tax)
@@ -1127,7 +1123,7 @@ void Update_P_Lk_Generic(t_tree *tree, t_edge *b, t_node *d)
           ambiguity_check_v2 = YES;
         }
 
-      if(p_lk_loc[site] < site)//Have we seen this pattern before?
+      if(p_lk_loc[site] < site) /* Have we seen this pattern before? */
         {
           Copy_P_Lk(p_lk,p_lk_loc[site],site,tree);
           Copy_Scale(sum_scale,p_lk_loc[site],site,tree);
@@ -1329,7 +1325,6 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
       Exit("\n");
     }
 
-
   n_patterns = tree->n_pattern;
 
   n_v1 = n_v2                 = NULL;
@@ -1343,13 +1338,6 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
                &Pij2,&p_lk_v2,&sum_scale_v2,
                d,b,tree);
 
-//  fprintf(stdout, "\nUpdating partials on Branch %d (on the side where Node %d lies)\n",b->num,d->num);fflush(stdout);
-//  fprintf(stdout, "Left partials :");fflush(stdout);
-//  n_v1->tax?Dump_Arr_S(n_v1->b[0]->p_lk_tip_r, tree->mod->ns*tree->n_pattern):Dump_Arr_D(p_lk_v1,   tree->mod->ras->n_catg*tree->mod->ns*tree->n_pattern);
-//  fprintf(stdout, "Right partials:");fflush(stdout);
-//  n_v2->tax?Dump_Arr_S(n_v2->b[0]->p_lk_tip_r, tree->mod->ns*tree->n_pattern):Dump_Arr_D(p_lk_v2,   tree->mod->ras->n_catg*tree->mod->ns*tree->n_pattern);
-
-  /* printf("\n. p_lk: %p p_lk_v1: %p p_lk_v2: %p",p_lk,p_lk_v1,p_lk_v2); */
 
   /* For every site in the alignment */
   For(site,n_patterns)
@@ -1360,22 +1348,35 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
       if(!tree->mod->s_opt->greedy)
         {
           /* n_v1 and n_v2 are tip nodes */
-            if(n_v1 && n_v1->tax)
+          if(n_v1 && n_v1->tax)
             {
               /* Is the state at this tip ambiguous? */
               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)
+          
+          if(n_v2 && n_v2->tax)
             {
               /* Is the state at this tip ambiguous? */
               ambiguity_check_v2 = n_v2->c_seq->is_ambigu[site];
               if(ambiguity_check_v2 == NO) state_v2 = n_v2->c_seq->d_state[site];
             }
+          
+          if(tree->mod->augmented == YES && n_v1 && n_v1->tax == NO)
+            {
+              state_v1 = Assign_State(n_v1->c_seq_anc->state+site*tree->mod->io->state_len,
+                                      tree->io->datatype,
+                                      tree->mod->io->state_len);
+            }
+          
+          if(tree->mod->augmented == YES && n_v2 && n_v2->tax == NO)
+            {
+              state_v2 = Assign_State(n_v2->c_seq_anc->state+site*tree->mod->io->state_len,
+                                      tree->io->datatype,
+                                      tree->mod->io->state_len);
+            }
         }
-
-
+      
       if(tree->mod->use_m4mod)
         {
           ambiguity_check_v1 = YES;
@@ -1395,9 +1396,17 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
             {
               smallest_p_lk  =  BIG;
 
-              /* For all the state at node d */
+              /* For all states at node d */
               For(i,tree->mod->ns)
                 {
+                  if(tree->mod->augmented == YES)
+                    {
+                      For(i,tree->mod->ns) p_lk[site*dim1+catg*dim2+i] = 0.0;
+                      i = Assign_State(d->c_seq_anc->state+site*tree->mod->io->state_len,
+                                       tree->io->datatype,
+                                       tree->mod->io->state_len);
+                    }
+
                   p1_lk1 = .0;
 
                   if(n_v1)
@@ -1409,6 +1418,17 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
                             {
                               /* For the (non-ambiguous) state at node n_v1 */
                               p1_lk1 = Pij1[catg*dim3+i*dim2+state_v1];
+
+                              assert(!isnan(p1_lk1));
+
+                              /* if(isnan(p1_lk1)) */
+                              /*   { */
+                              /*     PhyML_Printf("\n== Tree %d",tree->tree_num); */
+                              /*     PhyML_Printf("\n== catg=%d dim3=%d dim2=%d i=%d state_v1=%d",catg,dim3,dim2,i,state_v1); */
+                              /*     PhyML_Printf("\n== Pij1[0] = %G l = %G",Pij1[0],b->l->v); */
+                              /*     Print_Model(tree->mod); */
+                              /*     Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
+                              /*   } */
                             }
                           else
                             {
@@ -1418,14 +1438,15 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
                               p2=Pij1[catg*dim3+i*dim2+2] * (phydbl)n_v1->b[0]->p_lk_tip_r[site*dim2+2];
                               p3=Pij1[catg*dim3+i*dim2+3] * (phydbl)n_v1->b[0]->p_lk_tip_r[site*dim2+3];
                               p1_lk1 = p0+p1+p2+p3;
-                              
-                              
-                              if(isnan(p1_lk1))
-                                {
-                                  PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3);
-                                  PhyML_Printf("\n== Err. in file %s at line %d (function '%s').",__FILE__,__LINE__,__FUNCTION__);
-                                  Exit("\n");
-                                }
+
+                              assert(!isnan(p1_lk1));
+
+                              /* if(isnan(p1_lk1)) */
+                              /*   { */
+                              /*     PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3); */
+                              /*     PhyML_Printf("\n== Err. in file %s at line %d (function '%s').",__FILE__,__LINE__,__FUNCTION__); */
+                              /*     Exit("\n"); */
+                              /*   } */
                             }
                         }
                       /* n_v1 is an internal node */
@@ -1433,15 +1454,21 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
                         {
                           //"catg*dim3" offsets into a rate-specific flat 4*4 DNA matrix P. Then, P[i,j] is given by "i*4+l"
                           //"site*dim1" offsets into a rate-specific flat num_rates*4 matrix L. Then, L[i,j] is given by "catg*dim2+l"
-                          p0=Pij1[catg*dim3+i*dim2+0] * p_lk_v1[site*dim1+catg*dim2+0];
-                          p1=Pij1[catg*dim3+i*dim2+1] * p_lk_v1[site*dim1+catg*dim2+1];
-                          p2=Pij1[catg*dim3+i*dim2+2] * p_lk_v1[site*dim1+catg*dim2+2];
-                          p3=Pij1[catg*dim3+i*dim2+3] * p_lk_v1[site*dim1+catg*dim2+3];
-                          p1_lk1 = p0+p1+p2+p3;
-                          
+                          if(tree->mod->augmented == YES)
+                            {
+                              p1_lk1 = Pij1[catg*dim3+i*dim2+state_v1] * p_lk_v1[site*dim1+catg*dim2+state_v1];
+                            }
+                          else
+                            {
+                              p0=Pij1[catg*dim3+i*dim2+0] * p_lk_v1[site*dim1+catg*dim2+0];
+                              p1=Pij1[catg*dim3+i*dim2+1] * p_lk_v1[site*dim1+catg*dim2+1];
+                              p2=Pij1[catg*dim3+i*dim2+2] * p_lk_v1[site*dim1+catg*dim2+2];
+                              p3=Pij1[catg*dim3+i*dim2+3] * p_lk_v1[site*dim1+catg*dim2+3];
+                              p1_lk1 = p0+p1+p2+p3;
+                            }
                           if(isnan(p1_lk1))
                             {
-                              PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3);
+                              /* PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3); */
                               PhyML_Printf("\n== Err. in file %s at line %d.",__FILE__,__LINE__);
                               Warn_And_Exit("\n");
                             }
@@ -1464,15 +1491,17 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
                             {
                               /* For the (non-ambiguous) state at node n_v2 */
                               p2_lk2 = Pij2[catg*dim3+i*dim2+state_v2];
-                              if(isnan(p2_lk2))
-                                {
-                                  PhyML_Printf("\n== Tree %d",tree->tree_num);
-                                  PhyML_Printf("\n== catg=%d dim3=%d dim2=%d i=%d state_v2=%d",catg,dim3,dim2,i,state_v2);
-                                  PhyML_Printf("\n== Pij2[0] = %f",Pij2[0]);
-                                  PhyML_Printf("\n== q[0]=%f",tree->mod->eigen->q[0]);
-                                  PhyML_Printf("\n== Err. in file %s at line %d (function '%s').",__FILE__,__LINE__,__FUNCTION__);
-                                  Exit("\n");
-                                }
+
+                              assert(!isnan(p2_lk2));
+
+                              /* if(isnan(p2_lk2)) */
+                              /*   { */
+                              /*     PhyML_Printf("\n== Tree %d",tree->tree_num); */
+                              /*     PhyML_Printf("\n== catg=%d dim3=%d dim2=%d i=%d state_v2=%d",catg,dim3,dim2,i,state_v2); */
+                              /*     PhyML_Printf("\n== Pij2[0] = %G l = %G",Pij2[0],b->l->v); */
+                              /*     Print_Model(tree->mod); */
+                              /*     Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
+                              /*   } */
                             }
                           else
                             {
@@ -1482,28 +1511,38 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
                               p2=Pij2[catg*dim3+i*dim2+2] * (phydbl)n_v2->b[0]->p_lk_tip_r[site*dim2+2];
                               p3=Pij2[catg*dim3+i*dim2+3] * (phydbl)n_v2->b[0]->p_lk_tip_r[site*dim2+3];
                               p2_lk2 = p0+p1+p2+p3;
-                                                            
-                              if(isnan(p2_lk2))
-                                {
-                                  PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3);
-                                  PhyML_Printf("\n== Err. in file %s at line %d.",__FILE__,__LINE__);
-                                  Warn_And_Exit("\n");
-                                }                             
+
+                              assert(!isnan(p2_lk2));
+
+                              /* if(isnan(p2_lk2)) */
+                              /*   { */
+                              /*     PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3); */
+                              /*     PhyML_Printf("\n== Err. in file %s at line %d.",__FILE__,__LINE__); */
+                              /*     Warn_And_Exit("\n"); */
+                              /*   }                              */
                             }
                         }
                       /* n_v2 is an internal node */
                       else
                         {
-                          /* For all the states at node n_v2 */
-                          p0=Pij2[catg*dim3+i*dim2+0] * p_lk_v2[site*dim1+catg*dim2+0];
-                          p1=Pij2[catg*dim3+i*dim2+1] * p_lk_v2[site*dim1+catg*dim2+1];
-                          p2=Pij2[catg*dim3+i*dim2+2] * p_lk_v2[site*dim1+catg*dim2+2];
-                          p3=Pij2[catg*dim3+i*dim2+3] * p_lk_v2[site*dim1+catg*dim2+3];
-                          p2_lk2 = p0+p1+p2+p3;
+                          if(tree->mod->augmented == YES)
+                            {
+                              p2_lk2 = Pij2[catg*dim3+i*dim2+state_v2] * p_lk_v2[site*dim1+catg*dim2+state_v2];
+                            }
+                          else
+                            {
+                              /* For all the states at node n_v2 */
+                              p0=Pij2[catg*dim3+i*dim2+0] * p_lk_v2[site*dim1+catg*dim2+0];
+                              p1=Pij2[catg*dim3+i*dim2+1] * p_lk_v2[site*dim1+catg*dim2+1];
+                              p2=Pij2[catg*dim3+i*dim2+2] * p_lk_v2[site*dim1+catg*dim2+2];
+                              p3=Pij2[catg*dim3+i*dim2+3] * p_lk_v2[site*dim1+catg*dim2+3];
+                              p2_lk2 = p0+p1+p2+p3;
+                            }
+
                           if(isnan(p2_lk2))
                             {
                               PhyML_Printf("\n== %f %f",b->l->v,b->l->v*b->l->v*tree->mod->l_var_sigma);
-                              PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3);
+                              /* PhyML_Printf("\n== p0=%f p1=%f p2=%f p3=%f",p0,p1,p2,p3); */
                               PhyML_Printf("\n== Pij2[0]=%f Pij2[1]=%f Pij2[2]=%f Pij2[3]=%f",Pij2[catg*dim3+i*dim2+0],Pij2[catg*dim3+i*dim2+1],Pij2[catg*dim3+i*dim2+2],Pij2[catg*dim3+i*dim2+3]);
                               PhyML_Printf("\n== Err. in file %s at line %d (function '%s').",__FILE__,__LINE__,__FUNCTION__);
                               Warn_And_Exit("\n");
@@ -1515,30 +1554,12 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
                       p2_lk2 = 1.0;
                     }
                   
-                  p_lk[site*dim1+catg*dim2+i] = p1_lk1 * p2_lk2;//Partial likelihood of character "i" at site "site" under rate "catg"
+                  /* Partial likelihood of character "i" at site "site" under rate "catg" */
+                  p_lk[site*dim1+catg*dim2+i] = p1_lk1 * p2_lk2;
                   
                   if(p_lk[site*dim1+catg*dim2+i] < smallest_p_lk) smallest_p_lk = p_lk[site*dim1+catg*dim2+i] ;
 
-
-                  /* if(site == 3658 && n_v1->tax == YES && n_v2->tax == YES) */
-                  /*   { */
-                  /*     printf("\n## i=%3d %12G %12G %12G == P1:%12G P2:%12G [%3d %3d] [%20s %20s] [%c %c] [%3d %3d]", */
-                  /*            i, */
-                  /*            p_lk[site*dim1+catg*dim2+i], */
-                  /*            p1_lk1, */
-                  /*            p2_lk2, */
-                  /*            (ambiguity_check_v1 == NO)? Pij1[catg*dim3+i*dim2+state_v1] : -1., */
-                  /*            (ambiguity_check_v2 == NO)? Pij2[catg*dim3+i*dim2+state_v2] : -1., */
-                  /*            (ambiguity_check_v1 == NO)? state_v1 : -1, */
-                  /*            (ambiguity_check_v2 == NO)? state_v2 : -1, */
-                  /*            n_v1->name, */
-                  /*            n_v2->name, */
-                  /*            n_v1->c_seq->state[site], */
-                  /*            n_v2->c_seq->state[site], */
-                  /*            n_v1->c_seq->d_state[site], */
-                  /*            n_v2->c_seq->d_state[site] */
-                  /*            ); */
-                  /*   } */
+                  if(tree->mod->augmented == YES) break;
 
                 }
               
@@ -1548,10 +1569,8 @@ void Update_P_Lk_Nucl(t_tree *tree, t_edge *b, t_node *d)
               
               sum_scale[catg*n_patterns+site] = sum_scale_v1_val + sum_scale_v2_val;
               
-
-
               /* Scaling */
-              if(smallest_p_lk < p_lk_lim_inf)
+              if(smallest_p_lk < p_lk_lim_inf && tree->mod->augmented == NO)
                 {
                   curr_scaler_pow = (int)(LOG(p_lk_lim_inf)-LOG(smallest_p_lk))/LOG2;
                   curr_scaler     = (phydbl)((unsigned long long)(1) << curr_scaler_pow);
@@ -1934,8 +1953,8 @@ matrix *ML_Dist(calign *data, t_mod *mod)
   tmpdata->init_len   = data->init_len;
 
   mat = NULL;
-  if(mod->io->datatype == NT) mat = (mod->whichmodel < 10)?(K80_dist(data,1E+6)):(JC69_Dist(data,mod));
-  else if(mod->io->datatype == AA) mat = JC69_Dist(data,mod);
+  if(mod->io->datatype == NT)           mat = (mod->whichmodel < 10)?(K80_dist(data,1E+6)):(JC69_Dist(data,mod));
+  else if(mod->io->datatype == AA)      mat = JC69_Dist(data,mod);
   else if(mod->io->datatype == GENERIC) mat = JC69_Dist(data,mod);
 
   For(i,mod->ras->n_catg) /* Don't use the discrete gamma distribution */
@@ -2241,7 +2260,6 @@ void Init_P_Lk_Tips_Double(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Init_P_Lk_Tips_Int(t_tree *tree)
 {
   int curr_site,i,dim1;
@@ -2262,12 +2280,13 @@ void Init_P_Lk_Tips_Int(t_tree *tree)
     {
       For(i,tree->n_otu)
         {
-              /* printf("\n. site: %3d %c",curr_site,tree->a_nodes[i]->c_seq->state[curr_site]); */
+          /* printf("\n. site: %3d %c",curr_site,tree->a_nodes[i]->c_seq->state[curr_site]); */
+          /* printf("\n. init at %s %p",tree->a_nodes[i]->name,tree->a_nodes[i]->b[0]->p_lk_tip_r); fflush(NULL); */
           if(tree->io->datatype == NT)
             {
               Init_Tips_At_One_Site_Nucleotides_Int(tree->a_nodes[i]->c_seq->state[curr_site],
-                                curr_site*dim1,
-                                tree->a_nodes[i]->b[0]->p_lk_tip_r);
+                                                    curr_site*dim1,
+                                                    tree->a_nodes[i]->b[0]->p_lk_tip_r);
           /* Init_Tips_At_One_Site_Nucleotides_Int(tree->data->c_seq[i]->state[curr_site], */
           /* 					    curr_site*dim1, */
           /* 					    tree->a_nodes[i]->b[0]->p_lk_tip_r); */
@@ -2545,22 +2564,22 @@ phydbl Lk_Dist(phydbl *F, phydbl dist, t_mod *mod)
   For(i,mod->ns-1)
     {
       for(j=i+1;j<mod->ns;j++)
-    {
-      For(k,mod->ras->n_catg)
         {
-          lnL +=
-        (F[dim1*k+dim2*i+j] + F[dim1*k+dim2*j+i])*
-        LOG(mod->e_frq->pi->v[i] * mod->Pij_rr->v[dim1*k+dim2*i+j]);
+          For(k,mod->ras->n_catg)
+            {
+              lnL +=
+                (F[dim1*k+dim2*i+j] + F[dim1*k+dim2*j+i])*
+                LOG(mod->e_frq->pi->v[i] * mod->Pij_rr->v[dim1*k+dim2*i+j]);
               /* printf("\n. f: %f Pij:%f F:%f", */
               /*        mod->e_frq->pi->v[i],  */
               /*        mod->Pij_rr->v[dim1*k+dim2*i+j], */
               /*        F[dim1*k+dim2*j+i]); */
+            }
         }
     }
-    }
-
+  
   For(i,mod->ns) For(k,mod->ras->n_catg) lnL += F[dim1*k+dim2*i+i]* LOG(mod->e_frq->pi->v[i] * mod->Pij_rr->v[dim1*k+dim2*i+i]);
-
+  
   return lnL;
 }
 
@@ -2856,12 +2875,12 @@ void Init_P_Lk_Loc(t_tree *tree)
   For(i,2*tree->n_otu-1)
     {
       For(j,tree->n_pattern)
-    {
-      tree->a_edges[i]->p_lk_loc_left[j] = j;
-      tree->a_edges[i]->p_lk_loc_rght[j] = j;
-    }
+        {
+          tree->a_edges[i]->p_lk_loc_left[j] = j;
+          tree->a_edges[i]->p_lk_loc_rght[j] = j;
+        }
     }
-
+  
   For(i,tree->n_otu)
     {
       d = tree->a_nodes[i];
@@ -3048,6 +3067,13 @@ void Sample_Ancestral_Seq(int mutmap, int fromprior, t_tree *tree)
 
   s = (char *)mCalloc(T_MAX_NAME,sizeof(char));
 
+  For(i,2*tree->n_otu-1) 
+    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));
+      }
+
   if(fromprior == YES)
     {
       /* Update P(D_x|X=i) for each state i and node X */
@@ -3081,30 +3107,30 @@ void Sample_Ancestral_Seq(int mutmap, int fromprior, t_tree *tree)
       u = Uni();
       rate_cat = -1;
       For(j,tree->mod->ras->n_catg)
-    if(probs[j] > u)
-      {
-        rate_cat = j;
-        break;
-      }
-
+        if(probs[j] > u)
+          {
+            rate_cat = j;
+            break;
+          }
+      
       n_mut = 0;
       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,&n_mut,
-                   mutmap,fromprior,tree);
-
+                               i,rate_cat,
+                               muttype,muttime,&n_mut,
+                               mutmap,fromprior,tree);
+      
 
       For(j,n_mut) ordering[j] = 0;
-
+      
       For(j,n_mut-1)
-    {
-      for(k=j+1;k<n_mut;k++)
         {
-          if(muttime[k] > muttime[j]) ordering[k]++;
-          else ordering[j]++;
+          for(k=j+1;k<n_mut;k++)
+            {
+              if(muttime[k] > muttime[j]) ordering[k]++;
+              else ordering[j]++;
+            }
         }
-    }
-
+      
       strcpy(s,"rosetta.");
       sprintf(s+strlen(s),"%d",i);
       fp = fopen(s,"a");
@@ -3126,11 +3152,11 @@ void Sample_Ancestral_Seq(int mutmap, int fromprior, t_tree *tree)
 
 
       For(j,n_mut)
-    {
-      muttype[j] = -2;
-      muttime[j] = +1.;
-    }
-
+        {
+          muttype[j] = -2;
+          muttime[j] = +1.;
+        }
+      
       fclose(fp);
     }
 
@@ -3145,9 +3171,9 @@ void Sample_Ancestral_Seq(int mutmap, int fromprior, t_tree *tree)
 //////////////////////////////////////////////////////////////
 
 void Sample_Ancestral_Seq_Pre(t_node *a, t_node *d, t_edge *b,
-                  int site, int rate_cat,
-                  int *muttype, phydbl *muttime, int *n_mut,
-                  int mutmap, int fromprior, t_tree *tree)
+                              int site, int rate_cat,
+                              int *muttype, phydbl *muttime, int *n_mut,
+                              int mutmap, int fromprior, t_tree *tree)
 {
 
   int i,j;
@@ -3164,142 +3190,127 @@ void Sample_Ancestral_Seq_Pre(t_node *a, t_node *d, t_edge *b,
 
   if(a->tax)
     c = a->c_seq->state+site*tree->mod->io->state_len;
-    /* c = tree->data->c_seq[a->num]->state+site*tree->mod->io->state_len; */
+  /* c = tree->data->c_seq[a->num]->state+site*tree->mod->io->state_len; */
   else
     c = a->c_seq_anc->state+site*tree->mod->io->state_len;
-    /* c = tree->anc_data->c_seq[a->num-tree->n_otu]->state+site*tree->mod->io->state_len; */
-
+  /* c = tree->anc_data->c_seq[a->num-tree->n_otu]->state+site*tree->mod->io->state_len; */
+  
   sa = Assign_State(c,
-            tree->mod->io->datatype,
-            tree->mod->io->state_len);
-
-  if(sa == -1) // c is an indel
+                    tree->mod->io->datatype,
+                    tree->mod->io->state_len);
+  
+  if(sa == -1) /* c is an indel */
     {
       For(j,tree->mod->ns) probs[j] = tree->mod->e_frq->pi->v[j];
-
+      
       for(j=1;j<tree->mod->ns;j++) probs[j] += probs[j-1];
-
+      
       u = Uni();
       For(j,tree->mod->ns)
-    if(probs[j] > u)
-      {
-        sa = j;
-        break;
-      }
+        if(probs[j] > u)
+          {
+            sa = j;
+            break;
+          }
     }
-
+  
   if(d->tax == NO) // Need to sample state at node d
     {
-
+      
       dim1 = tree->mod->ras->n_catg * tree->mod->ns;
       dim2 = tree->mod->ns;
       dim3 = tree->mod->ns * tree->mod->ns;
       sum  = 0.0;
-
-
+            
       Pij  = b->Pij_rr;
-
+      
       if(d == b->left)
-    p_lk = b->p_lk_left;
+        p_lk = b->p_lk_left;
       else
-    p_lk = b->p_lk_rght;
-
+        p_lk = b->p_lk_rght;
+      
       For(j,tree->mod->ns) probs[j] = 0.0;
-
+      
       /* Formula (10) in Nielsen's Mutation Maping paper, e.g. */
       For(j,tree->mod->ns)
-    {
-      if(fromprior == NO)
-        probs[j] =
-          p_lk[site*dim1+rate_cat*dim2+j] *
-          Pij[rate_cat*dim3+sa*dim2+j];
-      else
-        probs[j] = Pij[rate_cat*dim3+sa*dim2+j];
-    }
-
-
-      /* if(site == 92) */
-      /* 	printf("\n. l=%f pr[%f %f %f %f] Pij[%f %f %f %f] plk[%f %f %f %f]", */
-      /* 	       b->l->v * tree->mod->ras->gamma_rr->v[rate_cat], */
-      /* 	       probs[0],probs[1],probs[2],probs[3], */
-      /* 	       Pij[rate_cat*dim3+sa*dim2+0], */
-      /* 	       Pij[rate_cat*dim3+sa*dim2+1], */
-      /* 	       Pij[rate_cat*dim3+sa*dim2+2], */
-      /* 	       Pij[rate_cat*dim3+sa*dim2+3], */
-      /* 	       p_lk[site*dim1+rate_cat*dim2+0], */
-      /* 	       p_lk[site*dim1+rate_cat*dim2+1], */
-      /* 	       p_lk[site*dim1+rate_cat*dim2+2], */
-      /* 	       p_lk[site*dim1+rate_cat*dim2+3]); */
-
-
+        {
+          if(fromprior == NO)
+            probs[j] =
+              p_lk[site*dim1+rate_cat*dim2+j] *
+              Pij[rate_cat*dim3+sa*dim2+j];
+          else
+            probs[j] = Pij[rate_cat*dim3+sa*dim2+j];
+        }
+      
       /* Scale the probabilities */
       sum = 0.0;
       For(j,tree->mod->ns) sum += probs[j];
       For(j,tree->mod->ns) probs[j] /= sum;
-
+      
       /* CDF */
       for(j=1;j<tree->mod->ns;j++) probs[j] += probs[j-1];
-
+      
       /* Sample state according to their posterior probas. */
       sd = -1;
       u = Uni();
       For(j,tree->mod->ns)
-    if(probs[j] > u)
-      {
-        sd = j;
-        break;
-      }
-
+        if(probs[j] > u)
+          {
+            sd = j;
+            break;
+          }
+      
       /* Assign state */
       /* tree->anc_data->c_seq[d->num-tree->n_otu]->state[site] = Reciproc_Assign_State(sd,tree->io->datatype); */
+      /* printf("\n<> %p",d->c_seq_anc); fflush(NULL); */
       d->c_seq_anc->state[site] = Reciproc_Assign_State(sd,tree->io->datatype);
     }
   else
     {
       c = d->c_seq->state+site*tree->mod->io->state_len;
       /* c = tree->data->c_seq[d->num]->state+site*tree->mod->io->state_len; */
-
+      
       sd = Assign_State(c,
-            tree->mod->io->datatype,
-            tree->mod->io->state_len);
-
+                        tree->mod->io->datatype,
+                        tree->mod->io->state_len);
+      
       if(sd == -1) // c is an indel
-    {
-      For(j,tree->mod->ns) probs[j] = tree->mod->e_frq->pi->v[j];
-
-      for(j=1;j<tree->mod->ns;j++) probs[j] += probs[j-1];
-
-      u = Uni();
-      For(j,tree->mod->ns)
-        if(probs[j] > u)
-          {
-        sd = j;
-        break;
-          }
-    }
+        {
+          For(j,tree->mod->ns) probs[j] = tree->mod->e_frq->pi->v[j];
+          
+          for(j=1;j<tree->mod->ns;j++) probs[j] += probs[j-1];
+          
+          u = Uni();
+          For(j,tree->mod->ns)
+            if(probs[j] > u)
+              {
+                sd = j;
+                break;
+              }
+        }
     }
-
+  
   /* if(site == 92) */
   /*   { */
   /*     printf("\n. sa=%d (%s,%d) sd=%d (%s,%d) b->l->v=%f", */
   /* 	     sa,a->tax?a->name:"",a->num,sd,d->tax?d->name:"",d->num,b->l->v); */
   /*   } */
-
+  
   if(mutmap == YES) Map_Mutations(a,d,sa,sd,b,site,rate_cat,muttype,muttime,n_mut,tree);
-
+  
   Free(probs);
-
+  
   if(d->tax) return;
   else
     {
       For(i,3)
-    {
-      if(d->v[i] != a)
         {
-          Sample_Ancestral_Seq_Pre(d,d->v[i],d->b[i],site,rate_cat,muttype,muttime,n_mut,mutmap,fromprior,tree);
+          if(d->v[i] != a)
+            {
+              Sample_Ancestral_Seq_Pre(d,d->v[i],d->b[i],site,rate_cat,muttype,muttime,n_mut,mutmap,fromprior,tree);
+            }
         }
     }
-    }
 }
 
 //////////////////////////////////////////////////////////////
@@ -3495,13 +3506,13 @@ int Check_Lk_At_Given_Edge(int verbose, t_tree *tree)
   if(tree->n_root && tree->ignore_root == NO)
     {
       Lk(tree->n_root->b[1],tree);
-      if(verbose == YES) PhyML_Printf("\n. Edge %3d %13G %f %13G",
+      if(verbose == YES) PhyML_Printf("\nx Edge %3d %13G %f %13G",
                                       tree->n_root->b[1]->num,tree->n_root->b[1]->l->v,tree->c_lnL,
                                       tree->n_root->b[1]->l_var->v
                                       );
 
       Lk(tree->n_root->b[2],tree);
-      if(verbose == YES) PhyML_Printf("\n. Edge %3d %13G %f %13G",
+      if(verbose == YES) PhyML_Printf("\nx Edge %3d %13G %f %13G",
                                       tree->n_root->b[2]->num,tree->n_root->b[2]->l->v,tree->c_lnL,
                                       tree->n_root->b[2]->l_var->v
                                       );
@@ -3525,7 +3536,7 @@ void ML_Ancestral_Sequences(t_tree *tree)
 {
   int i;
 
-  PhyML_Printf("\n. %s \n",Write_Tree(tree,NO));
+  /* PhyML_Printf("\n. %s \n",Write_Tree(tree,NO)); */
 
   PhyML_Printf("\n\n. Estimating ancestral sequences...");
 
@@ -3599,7 +3610,7 @@ void ML_Ancestral_Sequences_One_Node(t_node *mixt_d, t_tree *mixt_tree)
       fp             = mixt_tree->io->fp_out_ancestral;
 
 
-      do // For each partition element
+      do /* For each partition element */
         {
           if(curr_mixt_tree->next)
             {
diff --git a/src/main.c b/src/main.c
index 0b92a93..e13fd42 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,7 +23,7 @@ the GNU public licence. See http://www.opensource.org for details.
 #include "pars.h"
 #include "alrt.h"
 #include "mixt.h"
-#include "sergeii.h"
+#include "invitee.h"
 //#include "geo.h"
 
 #ifdef MPI
@@ -55,10 +55,11 @@ int main(int argc, char **argv)
 #ifdef MPI
   int rc;
   rc = MPI_Init(&argc,&argv);
-  if (rc != MPI_SUCCESS) {
-    PhyML_Printf("\n== Err. starting MPI program. Terminating.\n");
-    MPI_Abort(MPI_COMM_WORLD, rc);
-  }
+  if (rc != MPI_SUCCESS) 
+    {
+      PhyML_Printf("\n== Err. starting MPI program. Terminating.\n");
+      MPI_Abort(MPI_COMM_WORLD, rc);
+    }
   MPI_Comm_size(MPI_COMM_WORLD,&Global_numTask);
   MPI_Comm_rank(MPI_COMM_WORLD,&Global_myRank);
 #endif
@@ -71,8 +72,14 @@ int main(int argc, char **argv)
   mod              = NULL;
   best_lnL         = UNLIKELY;
 
+
   io = (option *)Get_Input(argc,argv);
-  if(!io) return(-1);
+  if(!io) return(0);
+  else if(io->use_xml == YES)
+    {
+      Free(io);
+      return(0);
+    }
 
 
 #ifdef EVOLVE
@@ -198,6 +205,7 @@ int main(int argc, char **argv)
                       Exit("\n");
                     }
 
+
                   Prepare_Tree_For_Lk(tree);
                   Br_Len_Not_Involving_Invar(tree);
                   Unscale_Br_Len_Multiplier_Tree(tree);
@@ -218,7 +226,12 @@ int main(int argc, char **argv)
 #ifdef PHYML
                   if(io->in_tree == 1) Spr_Pars(tree);
 
-
+                  /* /\* ******************** *\/ */
+                  /* Sample_Ancestral_Seq(NO,YES,tree); */
+                  /* tree->mod->augmented = YES; */
+                  /* Lk(NULL,tree); */
+                  /* /\* ******************** *\/ */
+                                   
 		  if(tree->mod->s_opt->opt_topo)
 		    {
 		      if(tree->mod->s_opt->topo_search      == NNI_MOVE) Simu_Loop(tree);
@@ -246,8 +259,6 @@ int main(int argc, char **argv)
 
                   Set_Both_Sides(YES,tree);
                   Lk(NULL,tree);
-//                  Print_Model(tree->mod);
-//                  Print_All_Edge_Likelihoods(tree);
                   Pars(NULL,tree);
                   Get_Tree_Size(tree);
                   PhyML_Printf("\n\n. Log likelihood of the current tree: %f.",tree->c_lnL);
@@ -268,7 +279,6 @@ int main(int argc, char **argv)
                   Exit("\n. Exiting 'evolve'\n");
 #endif
 
-
                   if(!tree->n_root) Get_Best_Root_Position(tree);
 
                   /* Print the tree estimated using the current random (or BioNJ) starting tree */
@@ -313,7 +323,6 @@ int main(int argc, char **argv)
                   Free_Tree(tree);
                 } //Tree done
 
-
               /* Launch bootstrap analysis */
               if(mod->bootstrap)
                 {
@@ -323,18 +332,17 @@ int main(int argc, char **argv)
                   MPI_Bcast (most_likely_tree, strlen(most_likely_tree)+1, MPI_CHAR, 0, MPI_COMM_WORLD);
                   if(!io->quiet)  PhyML_Printf("\n\n. The bootstrap analysis will use %d CPUs.",Global_numTask);
 #endif
-
+                  
                   most_likely_tree = Bootstrap_From_String(most_likely_tree,cdata,mod,io);
 
-		PhyML_Printf("\n\n. Completed the bootstrap analysis succesfully."); fflush(NULL);
+                  PhyML_Printf("\n\n. Completed the bootstrap analysis succesfully."); fflush(NULL);
                 }
               else
-                  if(io->ratio_test)
-                    {
-                      /* Launch aLRT */
-                      most_likely_tree = aLRT_From_String(most_likely_tree,cdata,mod,io);
-                    }
-
+                if(io->ratio_test != NO)
+                  {
+                    /* Launch aLRT */
+                    most_likely_tree = aLRT_From_String(most_likely_tree,cdata,mod,io);
+                  }
 
               /* Print the most likely tree in the output file */
               if(!io->quiet) PhyML_Printf("\n\n. Printing the most likely tree in file '%s'.", Basename(io->out_tree_file));
@@ -351,7 +359,7 @@ int main(int argc, char **argv)
           PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
           Exit("\n");
         }
-    Free_Model_Complete(mod);
+      Free_Model_Complete(mod);
     }
 
   if(most_likely_tree) Free(most_likely_tree);
@@ -535,8 +543,8 @@ int main(int argc, char **argv)
 {
 }
 
-#elif(SERGEII)
-#include "sergeii.h"
+#elif(INVITEE)
+#include "invitee.h"
 int main(int argc, char **argv)
 {
   /*My_Function(argc, argv);*/
@@ -553,11 +561,11 @@ int main(int argc, char **argv)
   return 1;
 }
 
-#elif(MIGREP)
-#include "migrep.h"
+#elif(PHYREX)
+#include "phyrex.h"
 int main(int argc, char **argv)
 {
-  MIGREP_Main(argc,argv);
+  PHYREX_Main(argc,argv);
   return 1;
 }
 
diff --git a/src/make.c b/src/make.c
index e6f3f89..f70ebf7 100644
--- a/src/make.c
+++ b/src/make.c
@@ -66,15 +66,18 @@ void Make_All_Edges_Lk(t_node *a, t_node *d, t_tree *tree)
 {
   int i;
 
-  For(i,3) if((a->v[i]) && (a->v[i] == d)) Make_Edge_Lk(a->b[i],tree);
+  For(i,3) 
+    if((a->v[i]) && (a->v[i] == d)) 
+      Make_Edge_Lk(a->b[i],tree);
+
   if(d->tax) return;
   else
     {
       For(i,3)
-    {
-      if(d->v[i] != a)
-        Make_All_Edges_Lk(d,d->v[i],tree);
-    }
+        {
+          if(d->v[i] != a && d->b[i] != tree->e_root)
+            Make_All_Edges_Lk(d,d->v[i],tree);
+        }
     }
 }
 
@@ -128,8 +131,8 @@ t_edge *Make_Edge_Light(t_node *a, t_node *d, int num)
       /* a tip is necessary on the right side of the t_edge */
 
       (b->left == a)?
-    (Make_Edge_Dirs(b,a,d,NULL)):
-    (Make_Edge_Dirs(b,d,a,NULL));
+        (Set_Edge_Dirs(b,a,d,NULL)):
+        (Set_Edge_Dirs(b,d,a,NULL));
 
       b->l->v             = a->l[b->l_r];
       if(a->tax) b->l->v  = a->l[b->r_l];
@@ -211,7 +214,6 @@ void Make_Edge_Lk_Left(t_edge *b, t_tree *tree)
   else
     b->sum_scale_left = NULL;
 
-
   if(b->left)
     {
       if((!b->left->tax) || (tree->mod->s_opt->greedy))
@@ -555,7 +557,7 @@ void Make_Custom_Model(t_mod *mod)
 {
   if(!mod->r_mat)
     {
-      PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+      PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
       Warn_And_Exit("");
     }
 
@@ -639,6 +641,7 @@ t_mod *Make_Model_Basic()
 
 void Make_Model_Complete(t_mod *mod)
 {
+
   if(mod->use_m4mod == YES)
     {
       M4_Make_Complete(mod->m4mod->n_h,mod->m4mod->n_o,mod->m4mod);
@@ -802,6 +805,7 @@ option *Make_Input()
   io->in_align_file                     = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->in_tree_file                      = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->in_constraint_tree_file           = (char *)mCalloc(T_MAX_FILE,sizeof(char));
+  io->in_coord_file                     = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->out_file                          = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->out_tree_file                     = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->out_trees_file                    = (char *)mCalloc(T_MAX_FILE,sizeof(char));
@@ -811,6 +815,7 @@ option *Make_Input()
   io->out_stats_file                    = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->out_lk_file                       = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->out_ps_file                       = (char *)mCalloc(T_MAX_FILE,sizeof(char));
+  io->out_summary_file                  = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->out_trace_file                    = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->nt_or_cd                          = (char *)mCalloc(T_MAX_FILE,sizeof(char));
   io->run_id_string                     = (char *)mCalloc(T_MAX_OPTION,sizeof(char));
@@ -1025,7 +1030,7 @@ t_rate *RATES_Make_Rate_Struct(int n_otu)
   t_rate *rates;
 
   rates = (t_rate  *)mCalloc(1,sizeof(t_rate));
-  rates->is_allocated = NO;
+  rates->is_allocated = NO;  
 
   if(n_otu > 0)
     {
@@ -1042,7 +1047,7 @@ t_rate *RATES_Make_Rate_Struct(int n_otu)
       rates->t_prior_min          = (phydbl *)mCalloc(2*n_otu-1,sizeof(phydbl));
       rates->t_prior_max          = (phydbl *)mCalloc(2*n_otu-1,sizeof(phydbl));
       rates->t_floor              = (phydbl *)mCalloc(2*n_otu-1,sizeof(phydbl));
-      rates->t_ranked             = (int *)mCalloc(2*n_otu-1,sizeof(int));
+      rates->t_rank               = (int *)mCalloc(2*n_otu-1,sizeof(int));
       rates->t_has_prior          = (short int *)mCalloc(2*n_otu-1,sizeof(short int));
       rates->dens                 = (phydbl *)mCalloc(2*n_otu-2,sizeof(phydbl));
       rates->triplet              = (phydbl *)mCalloc(2*n_otu-1,sizeof(phydbl));
@@ -1113,7 +1118,7 @@ t_cal *Make_Calib(int n_otu)
 void Make_Rmat_Weight(t_tree *mixt_tree)
 {
   t_tree *tree, *buff_tree;
-
+  scalar_dbl *curr_weight;
 
   tree = mixt_tree;
   do
@@ -1137,7 +1142,7 @@ void Make_Rmat_Weight(t_tree *mixt_tree)
 
   tree = mixt_tree;
   do
-            {
+    {
       if(tree->is_mixt_tree == YES) tree = tree->next;
       tree->mod->r_mat_weight = NULL;
       tree = tree->next;
@@ -1149,53 +1154,40 @@ void Make_Rmat_Weight(t_tree *mixt_tree)
   tree->mod->r_mat_weight = (scalar_dbl *)mCalloc(1,sizeof(scalar_dbl));
   Init_Scalar_Dbl(tree->mod->r_mat_weight);
   tree->mod->r_mat_weight->v = 1.0;
+  curr_weight = tree->mod->r_mat_weight;
 
   buff_tree = tree = mixt_tree;
   do // For each mixt_tree
-                {
+    {
       if(tree->is_mixt_tree == YES) tree = tree->next;
-
+      
       buff_tree = mixt_tree->next;
       do
-                    {
+        {
           if(buff_tree->mod->r_mat == tree->mod->r_mat)
             {
               tree->mod->r_mat_weight = buff_tree->mod->r_mat_weight;
-                      break;
-                    }
-                  buff_tree = buff_tree->next;
-                }
+              break;
+            }
+          buff_tree = buff_tree->next;
+        }
       while(buff_tree != tree);
-
+      
       if(!tree->mod->r_mat_weight)
-                {
+        {
           tree->mod->r_mat_weight = (scalar_dbl *)mCalloc(1,sizeof(scalar_dbl));
           Init_Scalar_Dbl(tree->mod->r_mat_weight);
           tree->mod->r_mat_weight->v = 1.0;
-                }
-
-          tree = tree->next;
-
-        }
-  while(tree);
-
-  tree = mixt_tree;
-  do
-        {
-      if(tree->next)
-        {
-          tree->mod->r_mat_weight->next = tree->next->mod->r_mat_weight;
-          tree->next->mod->r_mat_weight->prev = tree->mod->r_mat_weight;
-        }
-      else
-        {
-          tree->mod->r_mat_weight->next = NULL;
+          curr_weight->next = tree->mod->r_mat_weight;
+          tree->mod->r_mat_weight->prev = curr_weight;
+          curr_weight = tree->mod->r_mat_weight;
         }
+      
       tree = tree->next;
+      
     }
   while(tree);
 
-
 }
 
 //////////////////////////////////////////////////////////////
@@ -1204,6 +1196,7 @@ void Make_Rmat_Weight(t_tree *mixt_tree)
 void Make_Efrq_Weight(t_tree *mixt_tree)
 {
   t_tree *tree, *buff_tree;
+  scalar_dbl *curr_weight;
 
 
   tree = mixt_tree;
@@ -1244,54 +1237,41 @@ void Make_Efrq_Weight(t_tree *mixt_tree)
   tree->mod->e_frq_weight = (scalar_dbl *)mCalloc(1,sizeof(scalar_dbl));
   Init_Scalar_Dbl(tree->mod->e_frq_weight);
   tree->mod->e_frq_weight->v = 1.0;
+  curr_weight = tree->mod->e_frq_weight;
 
 
   buff_tree = tree = mixt_tree;
   do // For each mixt_tree
-                    {
+    {
       if(tree->is_mixt_tree == YES) tree = tree->next;
-
+      
       buff_tree = mixt_tree->next;
       do
         {
           if(buff_tree->mod->e_frq == tree->mod->e_frq)
             {
               tree->mod->e_frq_weight = buff_tree->mod->e_frq_weight;
-                      break;
-                    }
-                  buff_tree = buff_tree->next;
-                }
+              break;
+            }
+          buff_tree = buff_tree->next;
+        }
       while(buff_tree != tree);
-
+      
       if(!tree->mod->e_frq_weight)
-                {
+        {
           tree->mod->e_frq_weight = (scalar_dbl *)mCalloc(1,sizeof(scalar_dbl));
           Init_Scalar_Dbl(tree->mod->e_frq_weight);
           tree->mod->e_frq_weight->v = 1.0;
-                }
-
-          tree = tree->next;
-
-        }
-  while(tree);
-
-
-  tree = mixt_tree;
-  do
-    {
-      if(tree->next)
-        {
-          tree->mod->e_frq_weight->next = tree->next->mod->e_frq_weight;
-          tree->next->mod->e_frq_weight->prev = tree->mod->e_frq_weight;
-    }
-      else
-        {
-          tree->mod->e_frq_weight->next = NULL;
+          curr_weight->next = tree->mod->e_frq_weight;
+          tree->mod->e_frq_weight->prev = curr_weight;
+          curr_weight = tree->mod->e_frq_weight;
         }
+      
       tree = tree->next;
+      
     }
   while(tree);
-}
+  }
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
@@ -1348,16 +1328,21 @@ t_geo_coord *GEO_Make_Geo_Coord(int dim)
   t = (t_geo_coord *)mCalloc(1,sizeof(t_geo_coord));
   t->lonlat = (phydbl *)mCalloc(dim,sizeof(phydbl));
   t->id = (char *)mCalloc(T_MAX_ID_COORD,sizeof(char));
+
+  t->cpy = (t_geo_coord *)mCalloc(1,sizeof(t_geo_coord));
+  t->cpy->lonlat = (phydbl *)mCalloc(dim,sizeof(phydbl));
+  t->cpy->id = (char *)mCalloc(T_MAX_ID_COORD,sizeof(char));
+
   return(t);
 }
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-t_migrep_mod *MIGREP_Make_Migrep_Model(int dim)
+t_phyrex_mod *PHYREX_Make_Migrep_Model(int dim)
 {
-  t_migrep_mod *t;
-  t = (t_migrep_mod *)mCalloc(1,sizeof(t_migrep_mod));
+  t_phyrex_mod *t;
+  t = (t_phyrex_mod *)mCalloc(1,sizeof(t_phyrex_mod));
   t->lim = GEO_Make_Geo_Coord(dim);
   return(t);
 }
@@ -1365,11 +1350,11 @@ t_migrep_mod *MIGREP_Make_Migrep_Model(int dim)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-t_dsk *MIGREP_Make_Disk_Event(int n_dim, int n_otu)
+t_dsk *PHYREX_Make_Disk_Event(int n_dim, int n_otu)
 {
   t_dsk *t;
 
-  t         = (t_dsk *)mCalloc(1,sizeof(t_dsk));
+  t         = (t_dsk *)mCalloc(1,sizeof(t_dsk));  
   t->centr  = GEO_Make_Geo_Coord(n_dim);
   t->id     = (char *)mCalloc(T_MAX_ID_DISK,sizeof(char));
   t->ldsk_a = (t_ldsk **)mCalloc(n_otu,sizeof(t_ldsk *));
@@ -1380,7 +1365,7 @@ t_dsk *MIGREP_Make_Disk_Event(int n_dim, int n_otu)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-t_ldsk *MIGREP_Make_Lindisk_Node(int n_dim)
+t_ldsk *PHYREX_Make_Lindisk_Node(int n_dim)
 {
   t_ldsk *t;
   t = (t_ldsk *)mCalloc(1,sizeof(t_ldsk));
@@ -1391,16 +1376,13 @@ t_ldsk *MIGREP_Make_Lindisk_Node(int n_dim)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void MIGREP_Make_Lindisk_Next(t_ldsk *t)
+void PHYREX_Make_Lindisk_Next(t_ldsk *t)
 {
-  int block;
-
-  block = 50;
-
   if(t->n_next == 0)
-    t->next = (t_ldsk **)mCalloc(block,sizeof(t_ldsk *));
-  else if(!(t->n_next%block))
-    t->next = (t_ldsk **)mRealloc(t->next,t->n_next+block,sizeof(t_ldsk *));
+    t->next = (t_ldsk **)mCalloc(NEXT_BLOCK_SIZE,sizeof(t_ldsk *));
+  else if(!(t->n_next%NEXT_BLOCK_SIZE))
+    t->next = (t_ldsk **)mRealloc(t->next,t->n_next+NEXT_BLOCK_SIZE,sizeof(t_ldsk *));
+
   t->n_next++;
   /* printf("\n. make next for ldsk %s n_next set to %d",t->coord->id,t->n_next); */
   /* fflush(NULL); */
@@ -1408,6 +1390,17 @@ void MIGREP_Make_Lindisk_Next(t_ldsk *t)
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
+
+t_poly *Make_Poly(int n)
+{
+  t_poly *p;
+  int i;
+  p = (t_poly *)mCalloc(1,sizeof(t_poly));
+  p->poly_vert = (t_geo_coord **)mCalloc(n,sizeof(t_geo_coord *));
+  For(i,n) p->poly_vert[i] = GEO_Make_Geo_Coord(2);
+  return(p);
+}
+
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
diff --git a/src/make.h b/src/make.h
index 7f55616..324bac5 100644
--- a/src/make.h
+++ b/src/make.h
@@ -66,9 +66,10 @@ void Make_Rmat_Weight(t_tree *mixt_tree);
 t_geo *GEO_Make_Geo_Basic();
 void GEO_Make_Geo_Complete(int ldscape_sz,int n_dim,int n_tax,t_geo *t);
 t_geo_coord *GEO_Make_Geo_Coord(int n_dim);
-t_migrep_mod *MIGREP_Make_Migrep_Model();
-t_dsk *MIGREP_Make_Disk_Event(int n_dim, int n_otu);
-t_ldsk *MIGREP_Make_Lindisk_Node(int n_dim);
-void MIGREP_Make_Lindisk_Next(t_ldsk *t);
+t_phyrex_mod *PHYREX_Make_Migrep_Model();
+t_dsk *PHYREX_Make_Disk_Event(int n_dim, int n_otu);
+t_ldsk *PHYREX_Make_Lindisk_Node(int n_dim);
+void PHYREX_Make_Lindisk_Next(t_ldsk *t);
+t_poly *Make_Poly(int n);
 
 #endif
diff --git a/src/mcmc.c b/src/mcmc.c
index 6c82c3b..0909182 100644
--- a/src/mcmc.c
+++ b/src/mcmc.c
@@ -43,7 +43,7 @@ void MCMC(t_tree *tree)
     {
       MCMC_Read_Param_Vals(tree);
     }
-/* #ifdef SERGEII */
+/* #ifdef INVITEE */
 /*   tree -> rates -> node_height_dens_log_norm_const_update = Norm_Constant_Prior_Times(tree); */
 /* #endif */
   Switch_Eigen(YES,tree->mod);
@@ -57,11 +57,11 @@ void MCMC(t_tree *tree)
   RATES_Update_Cur_Bl(tree);
   RATES_Lk_Rates(tree);	
 
-#ifdef SERGEII
+#ifdef INVITEE
   tree->rates->update_time_norm_const = YES;
 #endif
   TIMES_Lk_Times(tree); 
-#ifdef SERGEII
+#ifdef INVITEE
   tree->rates->update_time_norm_const = NO;
 #endif
   /* printf("\n"); */
@@ -87,7 +87,6 @@ void MCMC(t_tree *tree)
       char *s,*t;
       FILE *fp;
       
-      Make_Ancestral_Seq(tree);
       Make_MutMap(tree);
  
       For(j,tree->n_otu)
@@ -465,7 +464,8 @@ void MCMC_Single_Param_Generic(phydbl *val,
 	  ratio += (new_lnPrior - cur_lnPrior); 
 	}
       
-      if(like_func && tree->mcmc->use_data == YES)  /* Likelihood ratio */
+      /* if(like_func && tree->mcmc->use_data == YES)  /\* Likelihood ratio *\/ */
+      if(like_func)  /* Likelihood ratio */
 	{ 
 	  new_lnLike  = (*like_func)(branch,tree,stree);  
 	  ratio += (new_lnLike - cur_lnLike);  
@@ -484,7 +484,6 @@ void MCMC_Single_Param_Generic(phydbl *val,
       ratio = EXP(ratio);
       alpha = MIN(1.,ratio);
       
-
       /* Always accept move */
       if(tree->mcmc->always_yes == YES && new_lnLike > UNLIKELY) alpha = 1.0;
 
@@ -511,56 +510,109 @@ void MCMC_Single_Param_Generic(phydbl *val,
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
-
-
+/* Formula from ``Markov chain Monte Carlo in practice: a roundtable discussion'', 
+   Kass, Robert E and Carlin, Bradley P and Gelman, Andrew and Neal, Radford M
+   The American Statistician, 1998
+*/
 void MCMC_Update_Effective_Sample_Size(int move_num, t_mcmc *mcmc, t_tree *tree)
 {
-  phydbl new_val,cur_val;
+  int i,N,lag;
+  phydbl rho,mean,var,old_rho,act,ess; 
+  int burnin;
 
-  mcmc->ess_run[move_num]++;
+  N = mcmc->sample_num+1;
+  
+  burnin = (int)(0.1*N);
+  if(burnin < 1) return;
 
-  new_val = mcmc->new_param_val[move_num];
-  cur_val = mcmc->old_param_val[move_num];
+  N -= burnin;
 
-  if(mcmc->ess_run[move_num] == 1)
-    {
-      mcmc->first_val[move_num] = cur_val;
-      mcmc->sum_val[move_num]   = cur_val;
-      mcmc->sum_valsq[move_num] = POW(cur_val,2);
-      return;
+  mean = Weighted_Mean(mcmc->sampled_val+move_num*mcmc->sample_size+burnin,NULL,N);
+  var  = Variance(mcmc->sampled_val+move_num*mcmc->sample_size+burnin,N);
+  
+  /* if(move_num == tree->mcmc->num_move_phyrex_sigsq)  */
+  /*   printf("\n. %d %f %f\n",N,mean,var); */
+
+  act = -1.0;
+  old_rho = 1.0;
+  For(lag,MIN(N,mcmc->max_lag))
+    {      
+      rho = 0.0;
+      For(i,N-lag) rho += 
+        (mcmc->sampled_val[move_num*mcmc->sample_size+burnin+i]     - mean) *
+        (mcmc->sampled_val[move_num*mcmc->sample_size+burnin+i+lag] - mean) ;
+      
+      rho /= (N - lag)*var;
+
+      if(old_rho + rho < 0.0) 
+        {
+          break; /* Geyer (1992) stopping criterion */
+        }
+
+      old_rho = rho;
+
+      act += 2.*rho;
     }
 
-  mcmc->sum_val[move_num]            += new_val;
-  mcmc->sum_valsq[move_num]          += POW(new_val,2);
-  mcmc->sum_curval_nextval[move_num] += cur_val * new_val;
+  if(act > 0.0) ess = N/act;
+  else          ess = 0.0;
 
+  mcmc->ess[move_num] = ess;
 
-  mcmc->ess[move_num] = 
-    Effective_Sample_Size(mcmc->first_val[move_num],
-			  new_val,
-			  mcmc->sum_val[move_num],
-			  mcmc->sum_valsq[move_num],
-			  mcmc->sum_curval_nextval[move_num],
-			  mcmc->ess_run[move_num]);
-	
-  mcmc->old_param_val[move_num] = new_val;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void MCMC_Update_Mode(int move_num, t_mcmc *mcmc, t_tree *tree)
+{
+  int i,j,N,best_bin;
+  int burnin,breaks,*bin_score,best_score;
+  phydbl min,max;
+
+  breaks = 100;
+  bin_score = (int *)mCalloc(breaks,sizeof(int));
 
-  if(move_num == mcmc->num_move_nd_t+tree->n_root->num-tree->n_otu)
+  N = mcmc->sample_num+1;
+  
+  burnin = (int)(0.1*N);
+  if(burnin < 1) return;
+
+  N -= burnin;
+  
+  min = +INFINITY;
+  For(i,N) 
+    if(mcmc->sampled_val[move_num*mcmc->sample_size+burnin+i] < min)
+      min = mcmc->sampled_val[move_num*mcmc->sample_size+burnin+i];
+
+  max = -INFINITY;
+  For(i,N) 
+    if(mcmc->sampled_val[move_num*mcmc->sample_size+burnin+i] > max)
+      max = mcmc->sampled_val[move_num*mcmc->sample_size+burnin+i];
+
+
+  For(i,N) 
     {
-      /* FILE *fp; */
-      /* fp = fopen("out","a"); */
-      /* fprintf(fp,"%f\n",new_val); */
-      /* fclose(fp); */
-      /* printf("\n. first=%G last=%G sum=%f sum_valsq=%f sum_cur_next=%f run=%d ess=%f", */
-      /* 	     mcmc->first_val[move_num],new_val, */
-      /* 	     mcmc->sum_val[move_num], */
-      /* 	     mcmc->sum_valsq[move_num], */
-      /* 	     mcmc->sum_curval_nextval[move_num], */
-      /* 	     mcmc->run_move[move_num]+1, */
-      /* 	     mcmc->ess[move_num] */
-      /* 	     ); */
+      for(j=1;j<breaks;j++)
+        if(min+j*(max-min)/breaks > mcmc->sampled_val[move_num*mcmc->sample_size+burnin+i])
+          {
+            bin_score[j-1]++;
+            break;
+          }
     }
-      
+
+  best_score = 0;
+  best_bin = 0;
+  For(j,breaks) 
+    if(bin_score[j] > best_score) 
+      {
+        best_score = bin_score[j];
+        best_bin = j;
+      }
+        
+  mcmc->mode[move_num] = min + best_bin*(max-min)/breaks;
+
+  Free(bin_score);
 }
 
 //////////////////////////////////////////////////////////////
@@ -1162,7 +1214,7 @@ void MCMC_One_Time(t_node *a, t_node *d, int traversal, t_tree *tree)
 	  tree->c_lnL              = cur_lnL_data;
 	  tree->rates->c_lnL_rates = cur_lnL_rate;
 	  tree->rates->c_lnL_times = cur_lnL_time;
-
+          
           if(isinf(new_lnL_time) == NO)
             {
               Restore_Br_Len(tree);
@@ -1237,7 +1289,7 @@ void MCMC_One_Time(t_node *a, t_node *d, int traversal, t_tree *tree)
 
 void MCMC_Jump_Calibration(t_tree *tree)
 {
-#ifdef SERGEII
+#ifdef INVITEE
   phydbl u;
   phydbl *calib_prior_cumprob, *calib_prior_prob, *uniform_prob; 
   phydbl cur_lnL_data, new_lnL_data;
@@ -2495,7 +2547,6 @@ void MCMC_Print_Param(t_mcmc *mcmc, t_tree *tree)
 
   if(!(mcmc->run%mcmc->sample_interval)) 
     {
-
       MCMC_Copy_To_New_Param_Val(tree->mcmc,tree);
 
       For(i,tree->mcmc->n_moves)
@@ -2517,17 +2568,17 @@ void MCMC_Print_Param(t_mcmc *mcmc, t_tree *tree)
 	  /* PhyML_Fprintf(fp,"MeanRate\t"); */
 /* 	  PhyML_Fprintf(fp,"NormFact\t"); */
 
-	  For(i,mcmc->n_moves)
-	    {
-	      strcpy(s,"Acc.");
-	      PhyML_Fprintf(fp,"%s%d\t",strcat(s,mcmc->move_name[i]),i);
-	    }
+	  /* For(i,mcmc->n_moves) */
+	  /*   { */
+	  /*     strcpy(s,"Acc."); */
+	  /*     PhyML_Fprintf(fp,"%s%d\t",strcat(s,mcmc->move_name[i]),i); */
+	  /*   } */
 
-	  For(i,mcmc->n_moves)
-	    {
-	      strcpy(s,"Tune.");
-	      PhyML_Fprintf(fp,"%s%d\t",strcat(s,mcmc->move_name[i]),i);
-	    }
+	  /* For(i,mcmc->n_moves) */
+	  /*   { */
+	  /*     strcpy(s,"Tune."); */
+	  /*     PhyML_Fprintf(fp,"%s%d\t",strcat(s,mcmc->move_name[i]),i); */
+	  /*   } */
 
 	  /* For(i,mcmc->n_moves) */
 	  /*   { */
@@ -2664,8 +2715,8 @@ void MCMC_Print_Param(t_mcmc *mcmc, t_tree *tree)
 /*       PhyML_Fprintf(fp,"%f\t",RATES_Check_Mean_Rates(tree)); */
 
 /*       PhyML_Fprintf(fp,"%f\t",tree->rates->norm_fact); */
-      For(i,tree->mcmc->n_moves) PhyML_Fprintf(fp,"%f\t",tree->mcmc->acc_rate[i]);
-      For(i,tree->mcmc->n_moves) PhyML_Fprintf(fp,"%f\t",(phydbl)(tree->mcmc->tune_move[i]));
+      /* For(i,tree->mcmc->n_moves) PhyML_Fprintf(fp,"%f\t",tree->mcmc->acc_rate[i]); */
+      /* For(i,tree->mcmc->n_moves) PhyML_Fprintf(fp,"%f\t",(phydbl)(tree->mcmc->tune_move[i])); */
 /*       For(i,tree->mcmc->n_moves) PhyML_Fprintf(fp,"%d\t",(int)(tree->mcmc->run_move[i])); */
 
       orig_approx = tree->io->lk_approx;
@@ -3010,73 +3061,6 @@ void MCMC_Terminate()
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void MCMC_Init_MCMC_Struct(char *filename, option *io, t_mcmc *mcmc)
-{
-  int pid;
-
-  mcmc->io               = io;
-  mcmc->is               = NO;
-  mcmc->use_data         = YES;
-  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;
-
-  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; */
-    }
-}
-
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
@@ -3100,18 +3084,13 @@ void MCMC_Copy_MCMC_Struct(t_mcmc *ori, t_mcmc *cpy, char *filename)
   cpy->io                 = ori->io              ;
   cpy->in_fp_par          = ori->in_fp_par       ;
   cpy->nd_t_digits        = ori->nd_t_digits     ;
+  cpy->max_lag            = ori->max_lag         ;
 
   For(i,cpy->n_moves) 
     {
-      cpy->old_param_val[i]      = ori->old_param_val[i];
-      cpy->new_param_val[i]      = ori->new_param_val[i];
       cpy->start_ess[i]          = ori->start_ess[i];
       cpy->ess_run[i]            = ori->ess_run[i];
       cpy->ess[i]                = ori->ess[i];
-      cpy->sum_val[i]            = ori->sum_val[i];
-      cpy->sum_valsq[i]          = ori->sum_valsq[i];
-      cpy->first_val[i]          = ori->first_val[i];
-      cpy->sum_curval_nextval[i] = ori->sum_curval_nextval[i];
       cpy->move_weight[i]        = ori->move_weight[i];
       cpy->run_move[i]           = ori->run_move[i];
       cpy->acc_move[i]           = ori->acc_move[i];
@@ -3602,15 +3581,6 @@ void MCMC_Adjust_Tuning_Parameter(int move, t_mcmc *mcmc)
 	{
 	  rate_inf = 0.1;
 	  rate_sup = 0.1;
-	  /* rate_inf = 0.3; */
-	  /* rate_sup = 0.3; */
-	  /* rate_inf = 0.7; */
-	  /* rate_sup = 0.7; */
-	}
-      else if(!strcmp(mcmc->move_name[move],"migrep_rad"))
-	{
-	  rate_inf = 0.1;
-	  rate_sup = 0.1;
 	}
       else if(!strcmp(mcmc->move_name[move],"subtree_height"))
 	{
@@ -3627,22 +3597,48 @@ void MCMC_Adjust_Tuning_Parameter(int move, t_mcmc *mcmc)
 	  rate_inf = 0.1;
 	  rate_sup = 0.1;
 	}
+
       /* if(!strcmp(mcmc->move_name[move],"tree_rates")) */
       /* 	{ */
       /* 	  rate_inf = 0.05; */
       /* 	  rate_sup = 0.05; */
       /* 	} */
+      else if(!strcmp(mcmc->move_name[move],"phyrex_lbda"))
+	{
+	  rate_inf = 0.234;
+	  rate_sup = 0.234;
+	}
+      else if(!strcmp(mcmc->move_name[move],"phyrex_mu"))
+	{
+	  rate_inf = 0.234;
+	  rate_sup = 0.234;
+	}
+      else if(!strcmp(mcmc->move_name[move],"phyrex_rad"))
+	{
+	  rate_inf = 0.234;
+	  rate_sup = 0.234;
+	}
+      else if(!strcmp(mcmc->move_name[move],"phyrex_ldsk_and_disk"))
+	{
+	  rate_inf = 0.234;
+	  rate_sup = 0.234;
+	}
+      else if(!strcmp(mcmc->move_name[move],"phyrex_ldsk_multi"))
+	{
+	  rate_inf = 0.234;
+	  rate_sup = 0.234;
+	}
+      else if(!strcmp(mcmc->move_name[move],"phyrex_disk_multi"))
+	{
+	  rate_inf = 0.234;
+	  rate_sup = 0.234;
+	}
       else
 	{
 	  rate_inf = 0.234; // Gareth Robert's magic number !
 	  rate_sup = 0.234;
 	}
 
-      /* PhyML_Printf("\n. %s acc=%d run=%d tune=%f", */
-      /* 		   mcmc->move_name[move], */
-      /* 		   mcmc->acc_move[move], */
-      /* 		   mcmc->run_move[move], */
-      /* 		   mcmc->tune_move[move]); */
 
       rate = mcmc->acc_rate[move];
       
@@ -3801,7 +3797,6 @@ void MCMC_Br_Lens_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void MCMC_Kappa(t_tree *tree)
 {
   int change,i;
@@ -3818,7 +3813,7 @@ void MCMC_Kappa(t_tree *tree)
     }
   
   For(i,2*tree->n_otu-2) tree->rates->br_do_updt[i] = NO;
-  MCMC_Single_Param_Generic(&(tree->mod->kappa->v),0.,15.,tree->mcmc->num_move_kappa,
+  MCMC_Single_Param_Generic(&(tree->mod->kappa->v),0.,100.,tree->mcmc->num_move_kappa,
 			    NULL,&(tree->c_lnL),
 			    NULL,Wrap_Lk,tree->mcmc->move_type[tree->mcmc->num_move_kappa],NO,NULL,tree,NULL);
 	  
@@ -3827,14 +3822,12 @@ void MCMC_Kappa(t_tree *tree)
       tree->io->lk_approx = NORMAL;
       if(tree->mcmc->use_data == YES) Lk(NULL,tree);
     }
-  
   Switch_Eigen(NO,tree->mod);
 }
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void MCMC_Rate_Across_Sites(t_tree *tree)
 {
   if(tree->mod->ras->n_catg == 1) return;
@@ -4094,7 +4087,7 @@ void MCMC_Birth_Rate(t_tree *tree)
  
   /* printf("\n. BIRTH cur_lnL_time: %f ",tree->rates->c_lnL_times); */
 
-#ifdef SERGEII
+#ifdef INVITEE
   tree->rates->update_time_norm_const = YES;
 #endif
 
@@ -4105,7 +4098,7 @@ void MCMC_Birth_Rate(t_tree *tree)
 			    &(tree->rates->c_lnL_times),NULL,
 			    Wrap_Lk_Times,NULL,tree->mcmc->move_type[tree->mcmc->num_move_birth_rate],NO,NULL,tree,NULL); 
 
-#ifdef SERGEII
+#ifdef INVITEE
   TIMES_Lk_Times(tree); 
   tree->rates->update_time_norm_const = NO;
 #endif
@@ -4271,7 +4264,6 @@ void MCMC_Sim_Rate(t_node *a, t_node *d, t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
 {
   int i;
@@ -4289,69 +4281,73 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
   mcmc->num_move_nd_t = mcmc->n_moves;
   mcmc->n_moves += tree->n_otu-1;
 
-  mcmc->num_move_nu                    = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_clock_r               = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_tree_height           = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_subtree_height        = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_kappa                 = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_tree_rates            = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_subtree_rates         = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_updown_nu_cr          = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_ras                   = mcmc->n_moves; mcmc->n_moves += (tree->mod ? 2*tree->mod->ras->n_catg : 1);
-  mcmc->num_move_updown_t_cr           = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_cov_rates             = mcmc->n_moves; mcmc->n_moves += (tree->mod ? 2*tree->mod->m4mod->n_h : 1);
-  mcmc->num_move_cov_switch            = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_birth_rate            = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_updown_t_br           = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_jump_calibration      = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_geo_lambda            = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_geo_sigma             = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_geo_tau               = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_geo_updown_tau_lbda   = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_geo_updown_lbda_sigma = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_geo_dum               = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_lbda           = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_mu             = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_rad            = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_delete_disk    = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_insert_disk    = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_move_disk_ct   = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_move_disk_ud   = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_swap_disk      = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_delete_hit     = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_insert_hit     = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_move_ldsk      = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_ldsk_ct        = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_shift_ct_med   = mcmc->n_moves; mcmc->n_moves += 1;
-  mcmc->num_move_migrep_triplet        = mcmc->n_moves; mcmc->n_moves += 1;
-
-  mcmc->run_move           = (int *)mCalloc(mcmc->n_moves,sizeof(int));
-  mcmc->acc_move           = (int *)mCalloc(mcmc->n_moves,sizeof(int));
-  mcmc->prev_run_move      = (int *)mCalloc(mcmc->n_moves,sizeof(int));
-  mcmc->prev_acc_move      = (int *)mCalloc(mcmc->n_moves,sizeof(int));
-  mcmc->acc_rate           = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->move_weight        = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->move_type          = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->num_move_nu                       = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_clock_r                  = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_tree_height              = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_subtree_height           = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_kappa                    = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_tree_rates               = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_subtree_rates            = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_updown_nu_cr             = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_ras                      = mcmc->n_moves; mcmc->n_moves += (tree->mod ? 2*tree->mod->ras->n_catg : 1);
+  mcmc->num_move_updown_t_cr              = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_cov_rates                = mcmc->n_moves; mcmc->n_moves += (tree->mod->m4mod ? 2*tree->mod->m4mod->n_h : 1);
+  mcmc->num_move_cov_switch               = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_birth_rate               = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_updown_t_br              = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_jump_calibration         = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_geo_lambda               = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_geo_sigma                = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_geo_tau                  = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_geo_updown_tau_lbda      = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_geo_updown_lbda_sigma    = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_geo_dum                  = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_lbda              = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_mu                = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_rad               = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_indel_disk        = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_move_disk_ud      = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_swap_disk         = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_indel_hit         = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_spr               = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_scale_times       = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_ldscape_lim       = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_sigsq             = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_sim               = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_traj              = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_lbda_times        = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_indel_disk_serial = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_sim_plus          = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_indel_hit_serial  = mcmc->n_moves; mcmc->n_moves += 1;
+  
+  mcmc->num_move_phyrex_ldsk_given_disk   = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_disk_given_ldsk   = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_ldsk_and_disk     = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_ldsk_multi        = mcmc->n_moves; mcmc->n_moves += 1;
+  mcmc->num_move_phyrex_disk_multi        = mcmc->n_moves; mcmc->n_moves += 1;
+
+  mcmc->run_move       = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->acc_move       = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->prev_run_move  = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->prev_acc_move  = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->acc_rate       = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
+  mcmc->move_weight    = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
+  mcmc->move_type      = (int *)mCalloc(mcmc->n_moves,sizeof(int));
   
   /* TO DO: instead of n_moves here we should have something like n_param */
-  mcmc->sum_val            = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->first_val          = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->sum_valsq          = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->sum_curval_nextval = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->ess                = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->ess_run            = (int *)mCalloc(mcmc->n_moves,sizeof(int));
-  mcmc->start_ess          = (int *)mCalloc(mcmc->n_moves,sizeof(int));
-  mcmc->new_param_val      = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->old_param_val      = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-  mcmc->adjust_tuning      = (int *)mCalloc(mcmc->n_moves,sizeof(int));
-  mcmc->tune_move          = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
-
-  mcmc->move_name = (char **)mCalloc(mcmc->n_moves,sizeof(char *));
+  mcmc->ess            = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
+  mcmc->ess_run        = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->start_ess      = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->adjust_tuning  = (int *)mCalloc(mcmc->n_moves,sizeof(int));
+  mcmc->tune_move      = (phydbl *)mCalloc(mcmc->n_moves,sizeof(phydbl));
+  mcmc->sampled_val    = (phydbl *)mCalloc((int)mcmc->n_moves*(mcmc->chain_len/mcmc->sample_interval + 1),sizeof(phydbl));
+  mcmc->mode           = (phydbl *)mCalloc((int)mcmc->n_moves,sizeof(phydbl));
+  mcmc->move_name      = (char **)mCalloc(mcmc->n_moves,sizeof(char *));
   For(i,mcmc->n_moves) mcmc->move_name[i] = (char *)mCalloc(T_MAX_MCMC_MOVE_NAME,sizeof(char));
 
   For(i,mcmc->n_moves) mcmc->adjust_tuning[i] = YES;
 
-  for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) strcpy(mcmc->move_name[i],"br_rate");  
+  for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) strcpy(mcmc->move_name[i],"br_rate");
   for(i=mcmc->num_move_nd_r;i<mcmc->num_move_nd_r+2*tree->n_otu-1;i++) strcpy(mcmc->move_name[i],"nd_rate");
   for(i=mcmc->num_move_nd_t;i<mcmc->num_move_nd_t+tree->n_otu-1;i++)   strcpy(mcmc->move_name[i],"time");
   strcpy(mcmc->move_name[mcmc->num_move_nu],"nu");
@@ -4365,7 +4361,7 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
   for(i=mcmc->num_move_ras;i<mcmc->num_move_ras+(tree->mod ? 2*tree->mod->ras->n_catg : 1);i++) 
     strcpy(mcmc->move_name[i],"ras");  
   strcpy(mcmc->move_name[mcmc->num_move_updown_t_cr],"updown_t_cr");
-  for(i=mcmc->num_move_cov_rates;i<mcmc->num_move_cov_rates+(tree->mod ? 2*tree->mod->m4mod->n_h : 1);i++) 
+  for(i=mcmc->num_move_cov_rates;i<mcmc->num_move_cov_rates+(tree->mod->m4mod ? 2*tree->mod->m4mod->n_h : 1);i++) 
     strcpy(mcmc->move_name[i],"cov_rates");  
   strcpy(mcmc->move_name[mcmc->num_move_cov_switch],"cov_switch");
   strcpy(mcmc->move_name[mcmc->num_move_birth_rate],"birth_rate");
@@ -4377,29 +4373,40 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
   strcpy(mcmc->move_name[mcmc->num_move_geo_updown_tau_lbda],"geo_updown_tau_lbda");
   strcpy(mcmc->move_name[mcmc->num_move_geo_updown_lbda_sigma],"geo_updown_lbda_sigma");
   strcpy(mcmc->move_name[mcmc->num_move_geo_dum],"geo_dum");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_lbda],"migrep_lbda");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_mu],"migrep_mu");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_rad],"migrep_rad");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_delete_disk],"migrep_delete_disk");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_insert_disk],"migrep_insert_disk");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_move_disk_ct],"migrep_move_disk_ct");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_move_disk_ud],"migrep_move_disk_ud");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_swap_disk],"migrep_swap_disk");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_delete_hit],"migrep_delete_hit");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_insert_hit],"migrep_insert_hit");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_move_ldsk],"migrep_move_ldsk");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_ldsk_ct],"migrep_shift_ldsk_to_centre");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_shift_ct_med],"migrep_shift_centr_to_median");
-  strcpy(mcmc->move_name[mcmc->num_move_migrep_triplet],"migrep_triplet");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_lbda],"phyrex_lbda");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_mu],"phyrex_mu");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_rad],"phyrex_rad");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_indel_disk],"phyrex_indel_disk");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_move_disk_ud],"phyrex_move_disk_ud");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_swap_disk],"phyrex_swap_disk");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_indel_hit],"phyrex_indel_hit");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_spr],"phyrex_spr");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_scale_times],"phyrex_scale_times");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_ldscape_lim],"phyrex_ldscape_lim");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_sigsq],"phyrex_sigsq");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_sim],"phyrex_sim");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_traj],"phyrex_traj");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_lbda_times],"phyrex_lbda_times");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_indel_disk_serial],"phyrex_indel_disk_serial");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_sim_plus],"phyrex_sim_plus");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_indel_hit_serial],"phyrex_indel_hit_serial");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_ldsk_multi],"phyrex_ldsk_multi");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_disk_multi],"phyrex_disk_multi");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_ldsk_and_disk],"phyrex_ldsk_and_disk");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_disk_given_ldsk],"phyrex_disk_given_ldsk");
+  strcpy(mcmc->move_name[mcmc->num_move_phyrex_ldsk_given_disk],"phyrex_ldsk_given_disk");
+
+
+  For(i,mcmc->n_moves) mcmc->move_type[i] = -1;
   
   if(tree->rates && tree->rates->model_log_rates == YES)
-    for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) mcmc->move_type[i] = MCMC_MOVE_RANDWALK_NORMAL;  
+    for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) mcmc->move_type[i] = MCMC_MOVE_RANDWALK_NORMAL;
   else
-    for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) mcmc->move_type[i] = MCMC_MOVE_SCALE_THORNE;  
+    for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) mcmc->move_type[i] = MCMC_MOVE_SCALE_THORNE;
 
   for(i=mcmc->num_move_nd_r;i<mcmc->num_move_nd_r+2*tree->n_otu-1;i++) mcmc->move_type[i] = MCMC_MOVE_SCALE_THORNE;
-  for(i=mcmc->num_move_nd_t;i<mcmc->num_move_nd_t+tree->n_otu-1;i++)   mcmc->move_type[i] = MCMC_MOVE_RANDWALK_UNIFORM;
-  /* for(i=mcmc->num_move_nd_t;i<mcmc->num_move_nd_t+tree->n_otu-1;i++)   mcmc->move_type[i] = MCMC_MOVE_SCALE_THORNE; */
+  /* for(i=mcmc->num_move_nd_t;i<mcmc->num_move_nd_t+tree->n_otu-1;i++)   mcmc->move_type[i] = MCMC_MOVE_RANDWALK_UNIFORM; */
+  for(i=mcmc->num_move_nd_t;i<mcmc->num_move_nd_t+tree->n_otu-1;i++)   mcmc->move_type[i] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_nu] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_clock_r] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_tree_height] = MCMC_MOVE_SCALE_THORNE;
@@ -4410,7 +4417,7 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
   mcmc->move_type[mcmc->num_move_updown_nu_cr] = MCMC_MOVE_RANDWALK_NORMAL;
   for(i=mcmc->num_move_ras;i<mcmc->num_move_ras+(tree->mod ? 2*tree->mod->ras->n_catg : 1);i++) mcmc->move_type[i] = MCMC_MOVE_RANDWALK_NORMAL;  
   mcmc->move_type[mcmc->num_move_updown_t_cr] = MCMC_MOVE_SCALE_THORNE;
-  for(i=mcmc->num_move_cov_rates;i<mcmc->num_move_cov_rates+(tree-> mod ? 2*tree->mod->m4mod->n_h : 1);i++) mcmc->move_type[i] = MCMC_MOVE_SCALE_THORNE;
+  for(i=mcmc->num_move_cov_rates;i<mcmc->num_move_cov_rates+(tree->mod->m4mod ? 2*tree->mod->m4mod->n_h : 1);i++) mcmc->move_type[i] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_cov_switch] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_birth_rate] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_updown_t_br] = MCMC_MOVE_SCALE_THORNE;
@@ -4421,9 +4428,11 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
   mcmc->move_type[mcmc->num_move_geo_updown_tau_lbda] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_geo_updown_lbda_sigma] = MCMC_MOVE_SCALE_THORNE;
   mcmc->move_type[mcmc->num_move_geo_dum] = MCMC_MOVE_SCALE_THORNE;
-  mcmc->move_type[mcmc->num_move_migrep_lbda] = MCMC_MOVE_SCALE_THORNE;
-  mcmc->move_type[mcmc->num_move_migrep_mu] = MCMC_MOVE_SCALE_THORNE;
-  mcmc->move_type[mcmc->num_move_migrep_rad] = MCMC_MOVE_SCALE_THORNE;
+  mcmc->move_type[mcmc->num_move_phyrex_lbda] = MCMC_MOVE_SCALE_THORNE;
+  mcmc->move_type[mcmc->num_move_phyrex_mu] = MCMC_MOVE_SCALE_THORNE;
+  mcmc->move_type[mcmc->num_move_phyrex_rad] = MCMC_MOVE_SCALE_THORNE;
+  mcmc->move_type[mcmc->num_move_phyrex_scale_times] = MCMC_MOVE_SCALE_THORNE;
+  mcmc->move_type[mcmc->num_move_phyrex_sigsq] = MCMC_MOVE_SCALE_THORNE;
 
   /* We start with small tuning parameter values in order to have inflated ESS
      for clock_r */
@@ -4445,16 +4454,20 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
 	  }
 	case MCMC_MOVE_SCALE_GAMMA:
 	  {
-	    /* mcmc->tune_move[i] = 1.0; */
-	    mcmc->tune_move[i] = 10.0;
+	    mcmc->tune_move[i] = 1.0;
+	    /* mcmc->tune_move[i] = 10.0; */
 	    break;
 	  }
 	case MCMC_MOVE_SCALE_THORNE:
 	  {
-	    /* mcmc->tune_move[i] = 1.0; */
-	    mcmc->tune_move[i] = 10.0;
+	    mcmc->tune_move[i] = 1.0;
 	    break;
 	  }
+        default :
+          {
+            mcmc->tune_move[i] = 1.0;
+	    break;
+          }
 	}
     }
   
@@ -4472,11 +4485,11 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
   for(i=mcmc->num_move_ras;i<mcmc->num_move_ras+(tree->mod ? 2*tree->mod->ras->n_catg : 1);i++) mcmc->move_weight[i] = 0.5*(1./(tree->mod ? (phydbl)tree->mod->ras->n_catg : 1));
   mcmc->move_weight[mcmc->num_move_updown_t_cr]      = 0.0; /* Does not seem to work well (does not give uniform prior on root height
   							      when sampling from prior) */
-  for(i=mcmc->num_move_cov_rates;i<mcmc->num_move_cov_rates+(tree->mod ? 2*tree->mod->m4mod->n_h : 1);i++) mcmc->move_weight[i] = 0.5*(1./(tree->mod ? (phydbl)tree->mod->m4mod->n_h : 1));
+  for(i=mcmc->num_move_cov_rates;i<mcmc->num_move_cov_rates+(tree->mod->m4mod ? 2*tree->mod->m4mod->n_h : 1);i++) mcmc->move_weight[i] = 0.5*(1./(tree->mod->m4mod ? (phydbl)tree->mod->m4mod->n_h : 1));
   mcmc->move_weight[mcmc->num_move_cov_switch]            = 1.0;
   mcmc->move_weight[mcmc->num_move_birth_rate]            = 2.0;
   mcmc->move_weight[mcmc->num_move_updown_t_br]           = 1.0;
-#if defined (SERGEII)
+#if defined (INVITEE)
   mcmc->move_weight[mcmc->num_move_jump_calibration]      = 0.1;
 #else
   mcmc->move_weight[mcmc->num_move_jump_calibration]      = 0.0;
@@ -4488,44 +4501,61 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
   mcmc->move_weight[mcmc->num_move_geo_updown_lbda_sigma] = 1.0;
   mcmc->move_weight[mcmc->num_move_geo_dum]               = 1.0;
 
-# if defined (MIGREP)
-  mcmc->move_weight[mcmc->num_move_migrep_lbda]          = 1.0;
-  mcmc->move_weight[mcmc->num_move_migrep_mu]            = 1.0;
-  mcmc->move_weight[mcmc->num_move_migrep_rad]           = 3.0;
-  mcmc->move_weight[mcmc->num_move_migrep_insert_disk]   = 3.0;
-  mcmc->move_weight[mcmc->num_move_migrep_delete_disk]   = 3.0;  
-  mcmc->move_weight[mcmc->num_move_migrep_move_disk_ct]  = 1.0;
-  mcmc->move_weight[mcmc->num_move_migrep_move_disk_ud]  = 1.0;
-  mcmc->move_weight[mcmc->num_move_migrep_swap_disk]     = 1.0;
-  mcmc->move_weight[mcmc->num_move_migrep_delete_hit]    = 3.0;
-  mcmc->move_weight[mcmc->num_move_migrep_insert_hit]    = 3.0;
-  mcmc->move_weight[mcmc->num_move_migrep_move_ldsk]     = 1.0;
-  mcmc->move_weight[mcmc->num_move_migrep_ldsk_ct]       = 2.0;
-  mcmc->move_weight[mcmc->num_move_migrep_shift_ct_med]  = 6.0;
-  mcmc->move_weight[mcmc->num_move_migrep_triplet]       = 6.0;
-# else
-  mcmc->move_weight[mcmc->num_move_migrep_lbda]          = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_mu]            = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_rad]           = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_insert_disk]   = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_delete_disk]   = 0.0;  
-  mcmc->move_weight[mcmc->num_move_migrep_move_disk_ct]  = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_move_disk_ud]  = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_swap_disk]     = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_delete_hit]    = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_insert_hit]    = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_move_ldsk]     = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_ldsk_ct]       = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_shift_ct_med]  = 0.0;
-  mcmc->move_weight[mcmc->num_move_migrep_triplet]       = 0.0;
-#endif 
-
+# if defined (PHYREX)
+  mcmc->move_weight[mcmc->num_move_phyrex_lbda]                  = 5.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_mu]                    = 8.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_rad]                   = 5.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_sigsq]                 = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_disk]            = 2.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_hit]             = 2.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_move_disk_ud]          = 5.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_swap_disk]             = 1.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_spr]                   = 1.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_scale_times]           = 2.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_ldscape_lim]           = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_sim]                   = 2.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_traj]                  = 3.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_lbda_times]            = 1.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_sim_plus]              = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_disk_serial]     = 2.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_hit_serial]      = 2.0;
+
+  mcmc->move_weight[mcmc->num_move_phyrex_ldsk_given_disk]       = 1.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_disk_given_ldsk]       = 1.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_ldsk_and_disk]         = 1.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_ldsk_multi]            = 2.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_disk_multi]            = 2.0;
 
+# else
 
+  mcmc->move_weight[mcmc->num_move_phyrex_lbda]                  = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_mu]                    = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_rad]                   = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_sigsq]                 = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_disk]            = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_hit]             = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_move_disk_ud]          = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_swap_disk]             = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_spr]                   = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_scale_times]           = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_ldscape_lim]           = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_sim]                   = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_traj]                  = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_lbda_times]            = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_sim_plus]              = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_disk_serial]     = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_indel_hit_serial]      = 0.0;
+
+  mcmc->move_weight[mcmc->num_move_phyrex_ldsk_given_disk]       = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_disk_given_ldsk]       = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_ldsk_and_disk]         = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_ldsk_multi]            = 0.0;
+  mcmc->move_weight[mcmc->num_move_phyrex_disk_multi]            = 0.0;
+#endif
 
-/*   for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) mcmc->move_weight[i] = 0.0; /\* Rates *\/ */
-/*   for(i=mcmc->num_move_nd_r;i<mcmc->num_move_nd_r+2*tree->n_otu-1;i++) mcmc->move_weight[i] = 0.0; /\* Node rates *\/ */
-/*   for(i=mcmc->num_move_nd_t;i<mcmc->num_move_nd_t+tree->n_otu-1;i++)   mcmc->move_weight[i] = 0.0;  /\* Times *\/ */
+  /* for(i=mcmc->num_move_br_r;i<mcmc->num_move_br_r+2*tree->n_otu-2;i++) mcmc->move_weight[i] = 0.0; /\* Rates *\/ */
+  /* for(i=mcmc->num_move_nd_r;i<mcmc->num_move_nd_r+2*tree->n_otu-1;i++) mcmc->move_weight[i] = 0.0; /\* Node rates *\/ */
+  /* for(i=mcmc->num_move_nd_t;i<mcmc->num_move_nd_t+tree->n_otu-1;i++)   mcmc->move_weight[i] = 0.0;  /\* Times *\/ */
 /*   mcmc->move_weight[mcmc->num_move_clock_r]          = 0.0; */
 /*   mcmc->move_weight[mcmc->num_move_tree_height]      = 0.0; */
 /*   mcmc->move_weight[mcmc->num_move_subtree_height]   = 0.0; */
@@ -4543,7 +4573,7 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
 /*   mcmc->move_weight[mcmc->num_move_cov_switch]       = 0.0; */
 /*   mcmc->move_weight[mcmc->num_move_birth_rate]       = 0.0; */
 /*   mcmc->move_weight[mcmc->num_move_updown_t_br]      = 0.0; */
-/* #if defined (SERGEII) */
+/* #if defined (INVITEE) */
 /*   mcmc->move_weight[mcmc->num_move_jump_calibration] = 1.0; */
 /* #else */
 /*   mcmc->move_weight[mcmc->num_move_jump_calibration] = 0.0; */
@@ -4567,23 +4597,23 @@ void MCMC_Complete_MCMC(t_mcmc *mcmc, t_tree *tree)
 
 void MCMC_Initialize_Param_Val(t_mcmc *mcmc, t_tree *tree)
 {
-  int i;
+  /* int i; */
 
-  mcmc->old_param_val[mcmc->num_move_nu]          = tree->rates->nu;
-  mcmc->old_param_val[mcmc->num_move_clock_r]     = tree->rates->clock_r;
-  mcmc->old_param_val[mcmc->num_move_tree_height] = tree->rates->nd_t[tree->n_root->num];
-  mcmc->old_param_val[mcmc->num_move_kappa]       = tree->mod->kappa->v;
+  /* mcmc->lag_param_val[mcmc->num_move_nu]          = tree->rates->nu; */
+  /* mcmc->lag_param_val[mcmc->num_move_clock_r]     = tree->rates->clock_r; */
+  /* mcmc->lag_param_val[mcmc->num_move_tree_height] = tree->rates->nd_t[tree->n_root->num]; */
+  /* mcmc->lag_param_val[mcmc->num_move_kappa]       = tree->mod->kappa->v; */
 
-  For(i,2*tree->n_otu-2)
-    mcmc->old_param_val[mcmc->num_move_br_r+i] = tree->rates->br_r[i];
+  /* For(i,2*tree->n_otu-2) */
+  /*   mcmc->lag_param_val[mcmc->num_move_br_r+i] = tree->rates->br_r[i]; */
   
-  For(i,tree->n_otu-1)
-    mcmc->old_param_val[mcmc->num_move_nd_t+i] = tree->rates->nd_t[tree->n_otu+i];
+  /* For(i,tree->n_otu-1) */
+  /*   mcmc->lag_param_val[mcmc->num_move_nd_t+i] = tree->rates->nd_t[tree->n_otu+i]; */
 
-  For(i,2*tree->n_otu-1)
-    mcmc->old_param_val[mcmc->num_move_nd_r+i] = tree->rates->nd_r[i];
+  /* For(i,2*tree->n_otu-1) */
+  /*   mcmc->lag_param_val[mcmc->num_move_nd_r+i] = tree->rates->nd_r[i]; */
 
-  For(i,mcmc->n_moves) tree->mcmc->new_param_val[i] = tree->mcmc->old_param_val[i];
+  /* For(i,mcmc->n_moves) tree->mcmc->new_param_val[i] = tree->mcmc->lag_param_val[i]; */
 }
 
 //////////////////////////////////////////////////////////////
@@ -4592,30 +4622,31 @@ void MCMC_Initialize_Param_Val(t_mcmc *mcmc, t_tree *tree)
 
 void MCMC_Copy_To_New_Param_Val(t_mcmc *mcmc, t_tree *tree)
 {
-  int i;
-
-  mcmc->new_param_val[mcmc->num_move_nu]          = tree->rates->nu;
-  mcmc->new_param_val[mcmc->num_move_clock_r]     = tree->rates->clock_r;
-  mcmc->new_param_val[mcmc->num_move_tree_height] = tree->rates->nd_t[tree->n_root->num];
-  mcmc->new_param_val[mcmc->num_move_kappa]       = tree->mod ? tree->mod->kappa->v : -1.;
-  mcmc->new_param_val[mcmc->num_move_birth_rate]  = tree->rates->birth_rate;
-
-
-  mcmc->new_param_val[mcmc->num_move_geo_tau]    = tree->geo ? tree->geo->tau   : -1.;
-  mcmc->new_param_val[mcmc->num_move_geo_lambda] = tree->geo ? tree->geo->lbda  : -1.;
-  mcmc->new_param_val[mcmc->num_move_geo_sigma]  = tree->geo ? tree->geo->sigma : -1.;
-  mcmc->new_param_val[mcmc->num_move_geo_dum]    = tree->geo ? tree->geo->dum   : -1.;
-
+  mcmc->sampled_val[mcmc->num_move_nu*mcmc->sample_size+mcmc->sample_num]          = tree->rates->nu;
+  mcmc->sampled_val[mcmc->num_move_clock_r*mcmc->sample_size+mcmc->sample_num]     = tree->rates->clock_r;
+  mcmc->sampled_val[mcmc->num_move_tree_height*mcmc->sample_size+mcmc->sample_num] = tree->rates->nd_t[tree->n_root->num];
+  mcmc->sampled_val[mcmc->num_move_kappa*mcmc->sample_size+mcmc->sample_num]       = tree->mod ? tree->mod->kappa->v : -1.;
+  mcmc->sampled_val[mcmc->num_move_birth_rate*mcmc->sample_size+mcmc->sample_num]  = tree->rates->birth_rate;
 
-  For(i,2*tree->n_otu-2)
-    mcmc->new_param_val[mcmc->num_move_br_r+i] = tree->rates->br_r[i];
+  /* For(i,2*tree->n_otu-2) */
+  /*   mcmc->sampled_val[(mcmc->num_move_br_r+i)*mcmc->sample_size+mcmc->sample_num] = tree->rates->br_r[i]; */
   
-  For(i,tree->n_otu-1)
-    mcmc->new_param_val[mcmc->num_move_nd_t+i] = tree->rates->nd_t[tree->n_otu+i];
+  /* For(i,tree->n_otu-1) */
+  /*   mcmc->sampled_val[(mcmc->num_move_nd_t+i)*mcmc->sample_size+mcmc->sample_num] = tree->rates->nd_t[tree->n_otu+i]; */
 
-  For(i,2*tree->n_otu-1)
-    mcmc->new_param_val[mcmc->num_move_nd_r+i] = tree->rates->nd_r[i];
-  
+  /* For(i,2*tree->n_otu-1) */
+  /*   mcmc->sampled_val[(mcmc->num_move_nd_r+i)*mcmc->sample_size+mcmc->sample_num] = tree->rates->nd_r[i]; */
+
+  mcmc->sampled_val[mcmc->num_move_geo_tau*mcmc->sample_size+mcmc->sample_num]      = tree->geo ? tree->geo->tau   : -1.;
+  mcmc->sampled_val[mcmc->num_move_geo_lambda*mcmc->sample_size+mcmc->sample_num]   = tree->geo ? tree->geo->lbda  : -1.;
+  mcmc->sampled_val[mcmc->num_move_geo_sigma*mcmc->sample_size+mcmc->sample_num]    = tree->geo ? tree->geo->sigma : -1.;
+  mcmc->sampled_val[mcmc->num_move_geo_dum*mcmc->sample_size+mcmc->sample_num]      = tree->geo ? tree->geo->dum   : -1.;  
+  #ifdef PHYREX
+  mcmc->sampled_val[mcmc->num_move_phyrex_lbda*mcmc->sample_size+mcmc->sample_num]  = tree->mmod ? tree->mmod->lbda               : -1.;
+  mcmc->sampled_val[mcmc->num_move_phyrex_mu*mcmc->sample_size+mcmc->sample_num]    = tree->mmod ? PHYREX_Neighborhood_Size(tree) : -1.;  
+  mcmc->sampled_val[mcmc->num_move_phyrex_sigsq*mcmc->sample_size+mcmc->sample_num] = tree->mmod ? PHYREX_Update_Sigsq(tree)      : -1.;
+  mcmc->sampled_val[mcmc->num_move_phyrex_rad*mcmc->sample_size+mcmc->sample_num]   = tree->mmod ? tree->mmod->rad                : -1.;
+  #endif
 }
 
 //////////////////////////////////////////////////////////////
@@ -4849,448 +4880,284 @@ void MCMC_Read_Param_Vals(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-#ifdef MIGREP
-void MCMC_MIGREP_Lbda(t_tree *mixt_tree)
+#ifdef PHYREX
+void MCMC_PHYREX_Lbda(t_tree *tree)
 {
-  t_tree *tree;
-
-  tree = mixt_tree;
-  do
-    {
-      MCMC_Single_Param_Generic(&(tree->mmod->lbda),
-                                tree->mmod->min_lbda,
-                                tree->mmod->max_lbda,
-                                mixt_tree->mcmc->num_move_migrep_lbda,
-                                NULL,&(mixt_tree->mmod->c_lnL),
-                                NULL,MIGREP_Wrap_Lk,
-                                mixt_tree->mcmc->move_type[mixt_tree->mcmc->num_move_migrep_lbda],
-                                NO,NULL,mixt_tree,NULL);
-      tree = tree->next;
-    }
-  while(tree);
+  MCMC_Single_Param_Generic(&(tree->mmod->lbda),
+                            tree->mmod->min_lbda,
+                            tree->mmod->max_lbda,
+                            tree->mcmc->num_move_phyrex_lbda,
+                            NULL,&(tree->mmod->c_lnL),
+                            NULL,PHYREX_Wrap_Lk,
+                            tree->mcmc->move_type[tree->mcmc->num_move_phyrex_lbda],
+                            NO,NULL,tree,NULL);  
 }
 #endif
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-#ifdef MIGREP
-void MCMC_MIGREP_Mu(t_tree *mixt_tree)
+#ifdef PHYREX
+void MCMC_PHYREX_Mu(t_tree *tree)
 {
-  t_tree *tree;
+  /* phydbl u,alpha,ratio; */
+  /* phydbl cur_glnL, new_glnL, hr; */
+  /* phydbl ori_mu; */
+  /* phydbl ori_beta,new_beta; */
+  /* phydbl K; */
 
-  tree = mixt_tree;
-  do
-    {
-      MCMC_Single_Param_Generic(&(tree->mmod->mu),
-                                tree->mmod->min_mu,
-                                tree->mmod->max_mu,
-                                mixt_tree->mcmc->num_move_migrep_mu,
-                                NULL,&(mixt_tree->mmod->c_lnL),
-                                NULL,MIGREP_Wrap_Lk,
-                                mixt_tree->mcmc->move_type[mixt_tree->mcmc->num_move_migrep_mu],
-                                NO,NULL,mixt_tree,NULL);
-      tree = tree->next;
-    }
-  while(tree);
+  /* tree->mcmc->run_move[tree->mcmc->num_move_phyrex_mu]++; */
+
+  /* new_glnL       = UNLIKELY; */
+  /* cur_glnL       = tree->mmod->c_lnL; */
+  /* hr             = 0.0; */
+  /* ratio          = 0.0; */
+  /* ori_mu         = tree->mmod->mu; */
+  /* ori_beta       = (1./tree->mmod->mu)-1.; */
+  /* K              = tree->mcmc->tune_move[tree->mcmc->num_move_phyrex_mu]; */
+
+  /* u = Uni(); */
+  /* new_beta = ori_beta * EXP(K*(u-.5)); */
+  /* hr += LOG(new_beta/ori_beta); */
+
+  /* tree->mmod->mu = 1./(new_beta+1.); */
+
+  /* new_glnL = PHYREX_Lk(tree); */
+  
+  /* ratio += (new_glnL - cur_glnL); */
+  /* ratio += hr; */
+  
+  /* ratio = EXP(ratio); */
+  /* alpha = MIN(1.,ratio); */
+  
+  /* /\* Always accept move *\/ */
+  /* if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0; */
+
+  /* u = Uni(); */
+  
+
+  /* if(u > alpha) /\* Reject *\/ */
+  /*   { */
+  /*     tree->mmod->mu = ori_mu; */
+
+  /*     tree->mmod->c_lnL = cur_glnL; */
+
+  /*     /\* new_glnL = MIGREP_Lk(tree); *\/ */
+  /*     /\* if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO) *\/ */
+  /*     /\*   { *\/ */
+  /*     /\*     PhyML_Printf("\n. new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL); *\/ */
+  /*     /\*     Generic_Exit(__FILE__,__LINE__,__FUNCTION__); *\/ */
+  /*     /\*   } *\/ */
+  /*   } */
+  /* else */
+  /*   { */
+  /*     tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_mu]++; */
+  /*     /\* printf("- Accept"); *\/ */
+  /*   } */
+
+  MCMC_Single_Param_Generic(&(tree->mmod->mu),
+                            tree->mmod->min_mu,
+                            tree->mmod->max_mu,
+                            tree->mcmc->num_move_phyrex_mu,
+                            NULL,&(tree->mmod->c_lnL),
+                            NULL,PHYREX_Wrap_Lk,
+                            tree->mcmc->move_type[tree->mcmc->num_move_phyrex_mu],
+                            NO,NULL,tree,NULL);
 }
 #endif
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-#ifdef MIGREP
-void MCMC_MIGREP_Radius(t_tree *mixt_tree)
+#ifdef PHYREX
+void MCMC_PHYREX_Radius(t_tree *tree)
 {
-  t_tree *tree;
+  MCMC_Single_Param_Generic(&(tree->mmod->rad),
+                            tree->mmod->min_rad,
+                            tree->mmod->max_rad,
+                            tree->mcmc->num_move_phyrex_rad,
+                            NULL,&(tree->mmod->c_lnL),
+                            NULL,PHYREX_Wrap_Lk,
+                            tree->mcmc->move_type[tree->mcmc->num_move_phyrex_rad],
+                            NO,NULL,tree,NULL);
 
-  tree = mixt_tree;
-  do
-    {
-      MCMC_Single_Param_Generic(&(tree->mmod->rad),
-                                tree->mmod->min_rad,
-                                tree->mmod->max_rad,
-                                mixt_tree->mcmc->num_move_migrep_rad,
-                                &(mixt_tree->mmod->c_ln_prior_rad),&(mixt_tree->mmod->c_lnL),
-                                MIGREP_Wrap_Prior_Radius,MIGREP_Wrap_Lk,
-                                mixt_tree->mcmc->move_type[mixt_tree->mcmc->num_move_migrep_rad],
-                                NO,NULL,mixt_tree,NULL);
-      tree = tree->next;
-    }
-  while(tree);
-}
-#endif 
 
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
+  /* phydbl u,alpha,ratio; */
+  /* phydbl cur_glnL, new_glnL, hr; */
+  /* phydbl cur_rad, new_rad; */
+  /* phydbl rate; */
 
-#ifdef MIGREP
-void MCMC_MIGREP_Triplet(t_tree *tree)
-{
-  phydbl cur_lnL, new_lnL;
-  phydbl ratio, alpha, u, min_under_time, max_under_time, hr,T;
-  t_dsk **disk_bkup,*disk,*coal_disk;
-  t_ldsk *ldsk_coal_cur,**ldsk_under,*ldsk_up,*ldsk,**next_up_orig,**prev_under_orig,*old_ldsk_under,*young_ldsk_under,*ldsk_coal_new,*buff_ldsk;
-  int i,n_coal,n_rm_disk,dir_up_coal,n_next_up_orig,block,n_disk_cur,n_disk_new,n_rm_disk_up_cur,n_rm_disk_up_new,*n_rm_disk_under_cur,*n_rm_disk_under_new,old_ldsk_under_idx;
-  int ori_n_disk;
-
-  cur_lnL          = tree->disk->mmod->c_lnL;
-  new_lnL          = UNLIKELY;
-  disk_bkup        = NULL;
-  disk             = NULL;
-  ldsk_coal_cur    = NULL;
-  ldsk_coal_new    = NULL;
-  ldsk_under       = NULL;
-  ldsk_up          = NULL;
-  ldsk             = NULL;
-  next_up_orig     = NULL;
-  prev_under_orig  = NULL;
-  old_ldsk_under   = NULL;
-  young_ldsk_under = NULL;
-  coal_disk        = NULL;
-  buff_ldsk        = NULL;
-  hr               = 0.0;
-  block            = 100;
-
-  ori_n_disk = MIGREP_Total_Number_Of_Intervals(tree);
-
-  /* Go to the top of the tree */
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  
-  /* Record the disk events corresponding to coalescent events */
-  n_coal = 0;
-  do
-    {
-      if(disk->ldsk && disk->ldsk->is_coal == YES)
-        {
-          if(!n_coal)              disk_bkup = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-          else if(!(n_coal%block)) disk_bkup = (t_dsk **)mRealloc(disk_bkup,n_coal+block,sizeof(t_dsk *));
-          disk_bkup[n_coal] = disk;
-          n_coal++;
-        }
-      disk = disk->next;      
-    }
-  while(disk);
+  /* tree->mcmc->run_move[tree->mcmc->num_move_phyrex_rad]++; */
 
-  if(n_coal == 0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-    
-  /* Randomly select a coalescent disk */
-  i = Rand_Int(0,n_coal-1);
-  ldsk_coal_cur = disk_bkup[i]->ldsk;
-  Free(disk_bkup);
-  /* printf("\n. ldsk_coal_cur: %s (n_next: %d) n_coal: %d",ldsk_coal_cur->coord->id,ldsk_coal_cur->n_next,n_coal); fflush(NULL); */
+  /* new_glnL = tree->mmod->c_lnL; */
+  /* cur_glnL = tree->mmod->c_lnL; */
+  /* hr       = 0.0; */
+  /* ratio    = 0.0; */
+  /* cur_rad  = tree->mmod->rad; */
+  /* new_rad  = tree->mmod->rad; */
+  /* rate     = 1.0; */
 
-  /* Find the closest coalescent node towards the top along */
-  /* the path from ldsk_coal_cur to the root ldsk */
-  ldsk_up = MIGREP_Prev_Coal_Lindisk(ldsk_coal_cur->prev);
-  
-  /* ldsk_coal_cur is the root node */
-  if(ldsk_up == NULL) ldsk_up = ldsk_coal_cur; 
+  /* new_rad = Rexp_Trunc(rate, */
+  /*                      tree->mmod->min_rad, */
+  /*                      tree->mmod->max_rad); */
 
-  T = -ldsk_up->disk->time;
+  /* tree->mmod->rad = new_rad; */
 
-  /* /\* Do not change root node height if there are no sequences involved in the analysis *\/ */
-  /* if(ldsk_up == ldsk_coal_cur) return; */
+  /* hr += rate*(new_rad - cur_rad); */
 
-  /* printf("\n. ldsk_up: %s",ldsk_up->coord->id); fflush(NULL); */
+  /* new_glnL = PHYREX_Lk(tree); */
 
-  /* Copy ldsk_up->next */
-  next_up_orig = (t_ldsk **)mCalloc(ldsk_up->n_next,sizeof(t_ldsk *));
-  For(i,ldsk_up->n_next) next_up_orig[i] = ldsk_up->next[i];
-  n_next_up_orig = ldsk_up->n_next;
-  
-  ldsk_under          = (t_ldsk **)mCalloc(ldsk_coal_cur->n_next,sizeof(t_ldsk *));
-  prev_under_orig     = (t_ldsk **)mCalloc(ldsk_coal_cur->n_next,sizeof(t_ldsk *));
-  n_rm_disk_under_cur = (int *)mCalloc(ldsk_coal_cur->n_next,sizeof(int));
-  n_rm_disk_under_new = (int *)mCalloc(ldsk_coal_cur->n_next,sizeof(int));
 
-  For(i,ldsk_coal_cur->n_next) ldsk_under[i] = MIGREP_Next_Coal_Lindisk(ldsk_coal_cur->next[i]);
- 
-  /* Record the oldest ldsk_under. Coalescent has to happen */
-  /* prior the time of that ldisk */
-  min_under_time = +INFINITY;
-  old_ldsk_under_idx = -1;
-  For(i,ldsk_coal_cur->n_next)
-    {
-      if(ldsk_under[i]->disk->time < min_under_time) 
-        {
-          min_under_time     = ldsk_under[i]->disk->time;
-          old_ldsk_under     = ldsk_under[i];
-          old_ldsk_under_idx = i;
-        }
-    }
+  /* ratio += (new_glnL - cur_glnL); */
+  /* ratio += hr; */
+  
+  /* ratio = EXP(ratio); */
+  /* alpha = MIN(1.,ratio); */
+  
+  /* /\* Always accept move *\/ */
+  /* if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0; */
 
-  /* Record the youngest ldsk_under. */
-  max_under_time = -INFINITY;
-  For(i,ldsk_coal_cur->n_next)
-    {
-      if(ldsk_under[i]->disk->time > max_under_time) 
-        {
-          max_under_time   = ldsk_under[i]->disk->time;
-          young_ldsk_under = ldsk_under[i];
-        }
-    }
+  /* u = Uni(); */
   
-  /* T is the time elapsed between ldsk_up and young_ldsk_under */
-  /* Used in the calculation of the Hastings ratio */
-  T += young_ldsk_under->disk->time;
+  /* if(u > alpha) /\* Reject *\/ */
+  /*   { */
+  /*     tree->mmod->rad = cur_rad; */
+  /*     PHYREX_Lk(tree); */
+  /*   } */
+  /* else */
+  /*   { */
+  /*     tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_rad]++; */
+  /*   } */
+}
+#endif 
 
-  /* Count current number of disks between ldsk_up and young_ldsk_under */
-  n_disk_cur = 0;
-  disk = young_ldsk_under->disk->prev;
-  while(disk != ldsk_up->disk)
-    {
-      n_disk_cur++;
-      disk = disk->prev;
-    }
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
 
-  /* First part of Hastings ratio */
-  hr += MIGREP_Uniform_Path_Density(old_ldsk_under,ldsk_up);
-  For(i,ldsk_coal_cur->n_next)
-    if(ldsk_under[i] != old_ldsk_under)
-      hr += MIGREP_Uniform_Path_Density(ldsk_under[i],ldsk_coal_cur);
+#ifdef PHYREX
+void MCMC_PHYREX_Sigsq(t_tree *tree)
+{
+  tree->mmod->update_rad = YES;
+  MCMC_Single_Param_Generic(&(tree->mmod->sigsq),
+                            tree->mmod->min_sigsq,
+                            tree->mmod->max_sigsq,
+                            tree->mcmc->num_move_phyrex_sigsq,
+                            NULL,&(tree->mmod->c_lnL),
+                            NULL,PHYREX_Wrap_Lk,
+                            tree->mcmc->move_type[tree->mcmc->num_move_phyrex_sigsq],
+                            NO,NULL,tree,NULL);
+  tree->mmod->rad = PHYREX_Update_Radius(tree);
+  tree->mmod->update_rad = NO;
+}
+#endif 
 
-  /* Remove disks between ldsk_coal_cur and ldsk_up, including ldsk_coal_cur (if different from ldsk_up) */
-  n_rm_disk = 0;  
-  n_rm_disk_up_cur = 0;
-  ldsk = ldsk_coal_cur;
-  while(ldsk != ldsk_up)
-    {
-      if(!n_rm_disk)              disk_bkup = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-      else if(!(n_rm_disk%block)) disk_bkup = (t_dsk **)mRealloc(disk_bkup,n_rm_disk+block,sizeof(t_dsk *));
-      disk_bkup[n_rm_disk] = ldsk->disk;
-      MIGREP_Remove_Disk(ldsk->disk);
-      n_rm_disk++;
-      n_rm_disk_up_cur++;
-      ldsk = ldsk->prev;
-    }
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+#ifdef PHYREX
+void MCMC_PHYREX_Indel_Disk(t_tree *tree)
+{
+  int cur_n_disk, new_n_disk;
+  int cur_n_int;
+  int cur_n_hit;
+  phydbl hr;
+  phydbl cur_lbda,new_lbda;
+  phydbl cur_mu,new_mu;
+  phydbl cur_rad,new_rad;
+  phydbl T;
   
-  /* Remove disks between ldsk_coal_cur and the next coalescent lindisks underneath */
-  For(i,ldsk_coal_cur->n_next)
-    {
-      prev_under_orig[i] = ldsk_under[i]->prev;
+  T = PHYREX_Tree_Height(tree);
+  T = FABS(T);
 
-      /* printf("\n. ldsk_under %d: %s",i+1,ldsk_under[i]->coord->id); fflush(NULL); */
+  hr = 0.0;
 
-      n_rm_disk_under_cur[i] = 0;
-      ldsk = ldsk_under[i]->prev;
-      while(ldsk != ldsk_coal_cur)
-        {
-          if(!n_rm_disk)              disk_bkup = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-          else if(!(n_rm_disk%block)) disk_bkup = (t_dsk **)mRealloc(disk_bkup,n_rm_disk+block,sizeof(t_dsk *));
-          disk_bkup[n_rm_disk] = ldsk->disk;
-          MIGREP_Remove_Disk(ldsk->disk);
-          n_rm_disk++;
-          n_rm_disk_under_cur[i]++;
-          ldsk = ldsk->prev;
-        }
-    }
+  new_lbda = tree->mmod->lbda;
+  cur_lbda = tree->mmod->lbda;
+  new_mu = tree->mmod->mu;
+  cur_mu = tree->mmod->mu;
+  new_rad = tree->mmod->rad;
+  cur_rad = tree->mmod->rad;
 
-  /* printf("\n. Removed %d disks",n_rm_disk); */
+  /* new_lbda = cur_lbda * EXP(0.5*(Uni()-.5)); */
+  /* hr += LOG(new_lbda/cur_lbda); */
 
-  if(ldsk_coal_cur != ldsk_up)
-    {
-      /* Insert the disk on which coalescent will occur. Time of this disk */
-      /* has to be older than old_ldsk_under and younger than ldsk_up  */
-      coal_disk= MIGREP_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
-      MIGREP_Init_Disk_Event(coal_disk,tree->mmod->n_dim,tree->mmod);
-      
-      /* Set the time of the coalescent disk */
-      coal_disk->time =
-        Uni()*(old_ldsk_under->disk->time - ldsk_up->disk->time) +
-        ldsk_up->disk->time;
+  /* new_mu = cur_mu * EXP(0.5*(Uni()-.5)); */
+  /* hr += LOG(new_mu/cur_mu); */
 
-      /* Which index of ldsk_up->next leads to any of */
-      /* the ldsk in ldsk_under? This index also leads */
-      /* to ldsk_coal. */
-      dir_up_coal = MIGREP_Get_Next_Direction(ldsk_under[0],ldsk_up);
+  /* new_rad = cur_rad * EXP(0.5*(Uni()-.5)); */
+  /* hr += LOG(new_rad/cur_rad); */
 
-      /* Generate trajectory between the oldest ldisk in ldsk_under and ldsk_up */
-      n_rm_disk_up_new = MIGREP_One_New_Traj(old_ldsk_under,
-                                             ldsk_up,
-                                             dir_up_coal,
-                                             coal_disk,
-                                             n_rm_disk_up_cur + n_rm_disk_under_cur[old_ldsk_under_idx],
-                                             tree);
+  if(new_rad > tree->mmod->max_rad || new_rad < tree->mmod->min_rad)     return; 
+  if(new_mu > tree->mmod->max_mu || new_mu < tree->mmod->min_mu)         return; 
+  if(new_lbda > tree->mmod->max_lbda || new_lbda < tree->mmod->min_lbda) return; 
 
-      hr -= MIGREP_Uniform_Path_Density(old_ldsk_under,ldsk_up);
+  tree->mmod->lbda = new_lbda;
+  tree->mmod->mu   = new_mu;
+  tree->mmod->rad  = new_rad;
+  
+  cur_n_hit = PHYREX_Total_Number_Of_Hit_Disks(tree);
+  cur_n_int = PHYREX_Total_Number_Of_Intervals(tree);
 
-      /* The new coalescent ldsk should now be sitting on coal_disk */
-      ldsk_coal_new          = coal_disk->ldsk;
-      ldsk_coal_new->is_coal = YES;
+  cur_n_disk = cur_n_int - cur_n_hit;
 
-      /* Build new trajectories between each ldsk in ldsk_under */
-      /* ldsk_coal_new  */
-      For(i,ldsk_coal_cur->n_next)
-        {
-          if(ldsk_under[i] != old_ldsk_under)
-            {
-              MIGREP_Make_Lindisk_Next(ldsk_coal_new);
-              n_rm_disk_under_new[i] = MIGREP_One_New_Traj(ldsk_under[i],ldsk_coal_new,ldsk_coal_new->n_next-1,NULL,n_rm_disk_under_cur[i],tree);
-              hr -= MIGREP_Uniform_Path_Density(ldsk_under[i],ldsk_coal_new);
-            }
-        }
-    }
-  else /* Coalescent ldsk is the root ldsk */
+  if(cur_n_hit == 0)
     {
-      ldsk_coal_new = ldsk_up;
-      For(i,ldsk_coal_cur->n_next)
-        {
-          /* printf("\n@ Generate traj from %s to %s",ldsk_under[i]->coord->id,ldsk_up->coord->id); fflush(NULL); */
-          n_rm_disk_under_new[i] = MIGREP_One_New_Traj(ldsk_under[i],ldsk_coal_new,i,NULL,n_rm_disk_under_cur[i],tree);
-          hr -= MIGREP_Uniform_Path_Density(ldsk_under[i],ldsk_coal_new);
-        }
+      new_n_disk = (int)Rpois(cur_n_disk+1);
+      
+      hr += Dpois(cur_n_disk,new_n_disk+1,YES);
+      hr -= Dpois(new_n_disk,cur_n_disk+1,YES);
     }
-  
-  new_lnL = MIGREP_Lk(tree);
-
-  /* Count new number of disks between ldsk_up and young_ldsk_under */
-  n_disk_new = 0;
-  disk = young_ldsk_under->disk->prev;
-  while(disk != ldsk_up->disk)
+  else
     {
-      n_disk_new++;
-      disk = disk->prev;
+      new_n_disk = (int)Rpois(T*new_lbda*(phydbl)cur_n_disk/(cur_n_hit+cur_n_disk));
+      
+      hr += Dpois(cur_n_disk,T*cur_lbda*(phydbl)new_n_disk/(cur_n_hit+new_n_disk),YES);
+      hr -= Dpois(new_n_disk,T*new_lbda*(phydbl)cur_n_disk/(cur_n_hit+cur_n_disk),YES);
     }
 
-  /* Dimension matching term in the Hastings ratio */
-  if(n_disk_new > n_disk_cur)
-    hr = (n_disk_new - n_disk_cur)*(LOG(T) - LOG(n_disk_new));
-  else
-    hr = (n_disk_new - n_disk_cur)*(LOG(n_disk_cur) - LOG(T));
+  if(new_n_disk < cur_n_disk) MCMC_PHYREX_Delete_Disk(hr, cur_n_disk - new_n_disk , cur_lbda, cur_mu, cur_rad, tree);
+  else                        MCMC_PHYREX_Insert_Disk(hr, new_n_disk - cur_n_disk,  cur_lbda, cur_mu, cur_rad, tree);  
+}
+#endif
 
-  ratio = .0;
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Insert or delete a disk that does not affect any ldisk */
+#ifdef PHYREX
+void MCMC_PHYREX_Delete_Disk(phydbl hr, int n_delete_disks, phydbl cur_lbda, phydbl cur_mu, phydbl cur_rad, t_tree *tree)
+{
+  phydbl u,alpha,ratio;
+  phydbl cur_glnL, new_glnL;
+  phydbl T;
+  t_dsk  *disk,**target_disk,**valid_disks;
+  int i,j,block,n_valid_disks,*permut;
 
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_indel_disk]++;
 
-  if(new_lnL < UNLIKELY + 0.1) 
+  if(n_delete_disks == 0) 
     {
-      MIGREP_Print_Struct('=',tree);
-      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);      
+      tree->mmod->lbda = cur_lbda;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return; 
     }
 
-  ratio = EXP(ratio);
-  alpha = MIN(1.,ratio);
+  valid_disks     = NULL;
+  disk            = NULL;
+  new_glnL        = tree->mmod->c_lnL;
+  cur_glnL        = tree->mmod->c_lnL;
+  ratio           = 0.0;
+  block           = 100;
 
+  disk = tree->disk->prev;
 
-  /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  if(!disk->prev) 
+    {
+      tree->mmod->lbda = cur_lbda;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return; 
+    }
 
-  u = Uni();
-  
-  /* if(ldsk_coal_cur->n_next >= 10) */
-  /*   { */
-      /* printf(" u: %f alpha:%f",u,alpha); fflush(NULL); */
-      /* gtk_widget_queue_draw(tree->draw_area); */
-      /* sleep(2); */
-    /* } */
-
-  if(u > alpha) /* Reject */
-    {
-      /* if(ldsk_coal_cur->n_next >= 10) */
-        /* PhyML_Printf(" Reject"); */
-      /* We now go back to the original genealogy */
-     
- 
-      /* First, remove the new disks and free the memory  */
-      /* for the ldsk sitting on it and the disk as well  */
-      For(i,ldsk_coal_cur->n_next)
-        {
-          ldsk = ldsk_under[i]->prev;
-          while(ldsk != ldsk_coal_new)
-            {
-              /* printf("\n. ldsk: %s disk: %s target: %s",ldsk->coord->id,ldsk->disk->id,ldsk_coal_new->coord->id); fflush(NULL); */
-              MIGREP_Remove_Disk(ldsk->disk);
-              Free_Disk(ldsk->disk);
-              buff_ldsk = ldsk;
-              ldsk = ldsk->prev;
-              Free_Ldisk(buff_ldsk);
-            }      
-        }
-
-      while(ldsk != ldsk_up)
-        {
-          MIGREP_Remove_Disk(ldsk->disk);
-          Free_Disk(ldsk->disk);
-          buff_ldsk = ldsk;
-          ldsk = ldsk->prev;
-          Free_Ldisk(buff_ldsk);
-        }      
-            
-     
-      /* Second, re-insert the original disks */
-      For(i,n_rm_disk) MIGREP_Insert_Disk(disk_bkup[i]);
-
-      /* Then connect ldsk_up->next to the original corresponding
-         ldsk
-      */
-      Free(ldsk_up->next);
-      ldsk_up->n_next = n_next_up_orig;
-      ldsk_up->next   = next_up_orig;
-      
-      /* Then connect each ldsk in the array ldsk_under to the
-         original ldsks
-      */
-      For(i,ldsk_coal_cur->n_next) ldsk_under[i]->prev = prev_under_orig[i];
-      
-      /* tree->mmod->c_lnL = cur_lnL; */
-      new_lnL = MIGREP_Lk(tree);
-      
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
-        {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);      
-        }
-      if(ori_n_disk != MIGREP_Total_Number_Of_Intervals(tree)) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);        
-    }
-  else
-    {
-      Free(next_up_orig);
-      
-      For(i,n_rm_disk) 
-        {
-          Free_Ldisk(disk_bkup[i]->ldsk);
-          Free_Disk(disk_bkup[i]);
-        }
-    }
-
-
-  Free(ldsk_under);
-  Free(prev_under_orig);
-  if(n_rm_disk > 0) Free(disk_bkup);
-  Free(n_rm_disk_under_cur);
-  Free(n_rm_disk_under_new);
-
-
-  /* MIGREP_Print_Struct('e',tree); */
-  /* MIGREP_Check_Struct(tree); */
-
-}
-#endif
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/* Insert or delete a disk that does not affect any ldisk */
-#ifdef MIGREP
-void MCMC_MIGREP_Delete_Disk(t_tree *tree)
-{
-  phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr,T, cur_lbda;
-  t_dsk  *disk,**target_disk,**valid_disks;
-  int i,j,block,n_valid_disks,n_delete_disks,*permut;
-
-  disk          = NULL;
-  new_lnL       = UNLIKELY;
-  cur_lnL       = tree->mmod->c_lnL;
-  hr            = 0.0;
-  ratio         = 0.0;
-  block         = 100;
-  cur_lbda      = tree->mmod->lbda;
-
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  disk = tree->disk->prev;
   n_valid_disks = 0;
   do
     {
@@ -5303,75 +5170,89 @@ void MCMC_MIGREP_Delete_Disk(t_tree *tree)
         }
       disk = disk->prev;
     }
-  while(disk->prev);
+  while(disk && disk->prev);
 
-  if(!n_valid_disks) return;
-  
-  n_delete_disks = Rand_Int(1,MIN(10,n_valid_disks));
-  
-  target_disk = (t_dsk **)mCalloc(n_delete_disks,sizeof(t_dsk *));
+  if(!n_valid_disks)
+    {
+      tree->mmod->lbda = cur_lbda;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return; 
+    }
 
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  T = disk->time;
+
+  if(n_valid_disks - n_delete_disks < 0) 
+    {
+      tree->mmod->lbda = cur_lbda;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return; 
+    }
+
+  target_disk = (t_dsk **)mCalloc(n_delete_disks,sizeof(t_dsk *));
 
   permut = Permutate(n_valid_disks);
 
   For(j,n_delete_disks)
     {
       /* Uniform selection of a disk where no coalescent nor 'hit' occurred */
-      i = permut[j];
-      target_disk[j] = valid_disks[i];
+      target_disk[j] = valid_disks[permut[j]];
   
-      MIGREP_Remove_Disk(target_disk[j]);
+      PHYREX_Remove_Disk(target_disk[j]);
   
-      For(i,tree->mmod->n_dim) hr -= LOG(tree->mmod->lim->lonlat[i]);
-      hr += LOG(n_valid_disks-j);
-      hr -= LOG(-T);
+      For(i,tree->mmod->n_dim) hr += LOG(1./tree->mmod->lim->lonlat[i]);
     }
 
-  Free(valid_disks);
-  
-  /* Random decrease of the value of lambda */
-  tree->mmod->lbda = Uni()*.2 + (cur_lbda - .2);
-  if(tree->mmod->lbda > tree->mmod->max_lbda) tree->mmod->lbda = tree->mmod->max_lbda;
-  if(tree->mmod->lbda < tree->mmod->min_lbda) tree->mmod->lbda = tree->mmod->min_lbda;
+  T = PHYREX_Tree_Height(tree);
 
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+  hr += LnChoose(n_valid_disks,n_delete_disks);
+  hr -= n_delete_disks * LOG(-T);
+  hr += LnFact(n_delete_disks);
 
+  new_glnL = PHYREX_Lk(tree);
+  ratio += (new_glnL - cur_glnL);
+  ratio += hr;
+  
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
-  
+
   /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
 
   u = Uni();
   
-  /* printf("\n- Delete new_lnL: %f [%f] hr: %f u:%f alpha: %f",new_lnL,cur_lnL,hr,u,alpha); */
+  /* printf("\n- Delete new_glnL: %f [%f] hr: %f u:%f alpha: %f",new_glnL,cur_glnL,hr,u,alpha); */
 
   if(u > alpha) /* Reject */
     {
-      /* printf("- Reject"); */
-
       tree->mmod->lbda = cur_lbda;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
 
-      For(j,n_delete_disks) MIGREP_Insert_Disk(target_disk[j]);
-      
-      /* tree->mmod->c_lnL = cur_lnL; */
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      For(j,n_delete_disks) PHYREX_Insert_Disk(target_disk[j],tree);
+
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          new_glnL = PHYREX_Lk(tree);
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          PHYREX_Update_Lindisk_List(tree);
+          tree->mmod->c_lnL = cur_glnL;
         }
     }
   else
     {
       For(j,n_delete_disks) Free_Disk(target_disk[j]);
-      /* printf("- Accept"); */
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_indel_disk]++;
     }
+
+  Free(valid_disks);
   Free(target_disk);
   Free(permut);
 }
@@ -5380,27 +5261,32 @@ void MCMC_MIGREP_Delete_Disk(t_tree *tree)
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
 
-#ifdef MIGREP
-void MCMC_MIGREP_Insert_Disk(t_tree *tree)
+#ifdef PHYREX
+void MCMC_PHYREX_Insert_Disk(phydbl hr, int n_insert_disks, phydbl cur_lbda, phydbl cur_mu, phydbl cur_rad, t_tree *tree)
 {
   t_dsk  *disk,**new_disk,**target_disk;
   phydbl T,t;
-  phydbl cur_lnL, new_lnL, hr, cur_lbda;
+  phydbl cur_glnL, new_glnL;
   phydbl u,alpha,ratio;
-  int i,j,n_valid_disks,n_insert_disks;
+  int i,j,n_valid_disks;
+
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_indel_disk]++;
+
+  if(n_insert_disks == 0) 
+    {
+      tree->mmod->lbda = cur_lbda;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return; 
+    }
 
-  disk           = NULL;
-  new_lnL        = UNLIKELY;
-  cur_lnL        = tree->mmod->c_lnL;
-  hr             = 0.0;
-  n_insert_disks = 0;
-  cur_lbda       = tree->mmod->lbda;
+  disk            = NULL;
+  new_glnL        = tree->mmod->c_lnL;
+  cur_glnL        = tree->mmod->c_lnL;
 
   if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
 
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  T = disk->time;
+  T = PHYREX_Tree_Height(tree);
 
   disk = tree->disk->prev;
   n_valid_disks = 0;
@@ -5409,9 +5295,7 @@ void MCMC_MIGREP_Insert_Disk(t_tree *tree)
       if(!disk->ldsk) n_valid_disks++;
       disk = disk->prev;
     }
-  while(disk->prev);
-
-  n_insert_disks = Rand_Int(1,10);
+  while(disk && disk->prev);
 
   target_disk = (t_dsk **)mCalloc(n_insert_disks,sizeof(t_dsk *));
   new_disk    = (t_dsk **)mCalloc(n_insert_disks,sizeof(t_dsk *));
@@ -5419,183 +5303,219 @@ void MCMC_MIGREP_Insert_Disk(t_tree *tree)
   For(j,n_insert_disks)
     {
       t = Uni()*T;
-      disk = tree->disk;
-      while(disk->time > t) disk = disk->prev;
+      disk = tree->disk->prev;
+      while(disk && disk->time > t) disk = disk->prev;
+      assert(disk->next);
       target_disk[j] = disk->next;
       
-      new_disk[j]= MIGREP_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
-      MIGREP_Init_Disk_Event(new_disk[j],tree->mmod->n_dim,tree->mmod);
-      
-      new_disk[j]->prev = target_disk[j]->prev;
-      new_disk[j]->next = target_disk[j];
-      
+      new_disk[j] = PHYREX_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
+      PHYREX_Init_Disk_Event(new_disk[j],tree->mmod->n_dim,tree->mmod);
       new_disk[j]->time = t;
+        
+      PHYREX_Insert_Disk(new_disk[j],tree);
       
-      MIGREP_Insert_Disk(new_disk[j]);
-  
       For(i,tree->mmod->n_dim) new_disk[j]->centr->lonlat[i] = Uni()*tree->mmod->lim->lonlat[i];
 
-      For(i,tree->mmod->n_dim) hr += LOG(tree->mmod->lim->lonlat[i]);
-      hr -= LOG(n_valid_disks+1+j);
-      hr += LOG(-T);
+      For(i,tree->mmod->n_dim) hr -= LOG(1./tree->mmod->lim->lonlat[i]);
     }
 
-  /* Random increase of the value of lambda */
-  tree->mmod->lbda = Uni()*.2 + cur_lbda;
-  if(tree->mmod->lbda > tree->mmod->max_lbda) tree->mmod->lbda = tree->mmod->max_lbda;
-  if(tree->mmod->lbda < tree->mmod->min_lbda) tree->mmod->lbda = tree->mmod->min_lbda;
+  hr -= LnChoose(n_valid_disks+n_insert_disks,n_insert_disks);
+  hr += n_insert_disks * LOG(-T);
+  hr -= LnFact(n_insert_disks);
 
-  new_lnL = MIGREP_Lk(tree);
-  ratio = (new_lnL - cur_lnL);
+  new_glnL = PHYREX_Lk(tree);
+  ratio = (new_glnL - cur_glnL);
   ratio += hr;
-
+  
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
-
+  
   /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
 
   u = Uni();
   
-  /* printf("\n+ Insert %s new_lnL: %f [%f] hr: %f u: %f alpha: %f",new_disk->id,new_lnL,cur_lnL,hr,u,alpha); */
+  /* printf("\n+ Insert new_glnL: %f [%f] hr: %f u: %f alpha: %f",new_glnL,cur_glnL,hr,u,alpha); */
 
   if(u > alpha) /* Reject */
     {
-      /* printf("+ Reject"); */
-
       tree->mmod->lbda = cur_lbda;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      
+      /* printf("\nI Reject"); */
 
       For(j,n_insert_disks)
         {
-          MIGREP_Remove_Disk(new_disk[j]);      
+          PHYREX_Remove_Disk(new_disk[j]);
           Free_Disk(new_disk[j]);
         }
-      Free(target_disk);
-      Free(new_disk);
 
-      /* tree->mmod->c_lnL = cur_lnL; */
-
-      new_lnL = MIGREP_Lk(tree);      
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          new_glnL = PHYREX_Lk(tree);
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          PHYREX_Update_Lindisk_List(tree);
+          tree->mmod->c_lnL = cur_glnL;
         }
+
+      /* printf("\nI Reject %f",tree->mmod->lbda); */
     }
   else
     {
-      /* printf("+ Accept"); */
-      /* if(indel > 0) printf("\n. Accept"); */
+      /* printf("\nI Accept %f",tree->mmod->lbda); */
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_indel_disk]++;
     }
+
+  Free(target_disk);
+  Free(new_disk);
 }
 #endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
 
-#ifdef MIGREP
-void MCMC_MIGREP_Move_Disk_Centre(t_tree *tree)
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Update time of disk */
+#ifdef PHYREX
+void MCMC_PHYREX_Move_Disk_Updown(t_tree *tree)
 {
   phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr;
-  t_dsk  *disk,*target_disk,**all_disks;
-  int i,j,block,n_all_disks;
-  t_geo_coord *bkup_coord;
-  phydbl max, min, max_pos, min_pos;
+  phydbl cur_glnL, new_glnL, hr;
+  phydbl cur_alnL, new_alnL;
+  phydbl *ori_time, new_time;
+  phydbl max, min, log_lbda;
+  t_dsk  *disk,**target_disk,**all_disks;
+  int i,block,n_all_disks,n_move_disks,*permut;
 
   disk          = NULL;
-  new_lnL       = UNLIKELY;
-  cur_lnL       = tree->mmod->c_lnL;
+  new_alnL      = tree->c_lnL;
+  cur_alnL      = tree->c_lnL;
+  new_glnL      = tree->mmod->c_lnL;
+  cur_glnL      = tree->mmod->c_lnL;
   hr            = 0.0;
   ratio         = 0.0;
   block         = 100;
   all_disks     = NULL;
+  log_lbda      = tree->mmod->lbda;
 
   if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
   disk = tree->disk->prev;
   n_all_disks = 0;
   do
     {
-      if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-      else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
-      all_disks[n_all_disks] = disk;
-      n_all_disks++;
+      /* if(1) */
+      if(disk->ldsk && disk->ldsk->n_next > 1) /* Moving disks other than coalescent is pointless */
+        {
+          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
+          all_disks[n_all_disks] = disk;
+          n_all_disks++;
+        }
       disk = disk->prev;
     }
   while(disk);
 
   if(!n_all_disks) return;
   
-  /* Uniform selection of a disk */
-  i = Rand_Int(0,n_all_disks-1);
-  target_disk = all_disks[i];
-  Free(all_disks);
+  n_move_disks = Rand_Int(1,(int)(n_all_disks));
   
-  bkup_coord = MIGREP_Copy_Geo_Coord(target_disk->centr);
+  target_disk = (t_dsk **)mCalloc(n_all_disks,sizeof(t_dsk *));
+  ori_time    = (phydbl *)mCalloc(n_all_disks,sizeof(phydbl));
 
-  /* New disk center is chosen uniformly in the landscape */
-  /* in case this disk does not displace any lineage      */
-  if(target_disk->ldsk == NULL)
-    For(i,tree->mmod->n_dim) target_disk->centr->lonlat[i] = Uni()*tree->mmod->lim->lonlat[i];
-  else
+  permut = Permutate(n_all_disks);
+
+  For(i,n_move_disks)
     {
-      For(i,tree->mmod->n_dim)
+      target_disk[i] = all_disks[permut[i]];
+      
+      ori_time[i] = target_disk[i]->time;
+
+      if(target_disk[i]->prev)
         {
-          min_pos =  INFINITY;
-          max_pos = -INFINITY;
-          For(j,target_disk->ldsk->n_next)
-            {
-              if(target_disk->ldsk->next[j]->coord->lonlat[i] < min_pos)
-                min_pos = target_disk->ldsk->next[j]->coord->lonlat[i];
-              if(target_disk->ldsk->next[j]->coord->lonlat[i] > max_pos)
-                max_pos = target_disk->ldsk->next[j]->coord->lonlat[i];
-            }
-          
-          max_pos = MAX(target_disk->ldsk->coord->lonlat[i],max_pos);
-          min_pos = MIN(target_disk->ldsk->coord->lonlat[i],min_pos);
-          max = min_pos + tree->mmod->rad;
-          min = max_pos - tree->mmod->rad;
-          if(max < min) 
-            {
-              PhyML_Printf("\n. rad: %f",tree->mmod->rad);
-              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-            }
+          max = target_disk[i]->next->time;
+          min = target_disk[i]->prev->time;
+          new_time = Uni()*(max - min) + min;
+        }
+      else
+        {
+          phydbl new_plusmin, cur_plusmin;
+
+          max = target_disk[i]->next->time;
+
+          cur_plusmin = FABS(ori_time[i] - max);
+          new_plusmin = Rexp(1./cur_plusmin);
+
+          new_time = max - new_plusmin;
 
-          max = MIN(max,tree->mmod->lim->lonlat[i]);
-          min = MAX(min,0.0);
-          target_disk->centr->lonlat[i] = Uni()*(max - min) + min;          
+          hr += LOG(Dexp(cur_plusmin,1./new_plusmin));
+          hr -= LOG(Dexp(new_plusmin,1./cur_plusmin));
+
+          new_glnL -= (log_lbda - FABS(ori_time[i]-max)*tree->mmod->lbda);
+          new_glnL += (log_lbda - FABS(new_time   -max)*tree->mmod->lbda);
         }
+            
+      target_disk[i]->time = new_time;
     }
+  
 
+  tree->mmod->c_lnL = new_glnL;
 
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+  if(tree->mcmc->use_data == YES) new_alnL = Lk(NULL,tree);
 
+  ratio += (new_alnL - cur_alnL);
+  ratio += (new_glnL - cur_glnL);
+  ratio += hr;
+  
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
   
   /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
 
   u = Uni();
   
-  /* printf("\n- Delete new_lnL: %f [%f] hr: %f u:%f alpha: %f",new_lnL,cur_lnL,hr,u,alpha); */
+  /* printf("\n- Move disk new_glnL: %f [%f] hr: %f u:%f alpha: %f",new_alnL,cur_alnL,hr,u,alpha); */
 
   if(u > alpha) /* Reject */
     {
       /* printf("- Reject"); */
       
-      Free_Geo_Coord(target_disk->centr);
-      target_disk->centr = MIGREP_Copy_Geo_Coord(bkup_coord);
-      
-      /* tree->mmod->c_lnL = cur_lnL; */
+      For(i,n_move_disks) target_disk[i]->time = ori_time[i]; 
 
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          if(tree->mcmc->use_data == YES)
+            {
+              new_alnL = Lk(NULL,tree);
+              
+              if(Are_Equal(new_alnL,cur_alnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_alnL: %f cur_alnL: %f",new_alnL,cur_alnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          
+          new_glnL = PHYREX_Lk(tree);
+          
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          tree->mmod->c_lnL = cur_glnL;
+          tree->c_lnL       = cur_alnL;
         }
     }
   else
@@ -5603,431 +5523,569 @@ void MCMC_MIGREP_Move_Disk_Centre(t_tree *tree)
       /* printf("- Accept"); */
     }  
 
-  Free_Geo_Coord(bkup_coord);
-        
+  Free(target_disk);
+  Free(all_disks);
+  Free(ori_time);
+  Free(permut);
+
 }
 #endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
 
-#ifdef MIGREP
-void MCMC_MIGREP_Move_Ldsk(t_tree *tree)
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+#ifdef PHYREX
+void MCMC_PHYREX_Scale_Times(t_tree *tree)
 {
   phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr;
-  t_dsk  *disk,*target_disk,**all_disks;
-  int i,block,n_all_disks;
-  t_geo_coord *bkup_coord;
-  phydbl max,min;
-
-  disk          = NULL;
-  new_lnL       = UNLIKELY;
-  cur_lnL       = tree->mmod->c_lnL;
-  hr            = 0.0;
-  ratio         = 0.0;
-  block         = 100;
-  all_disks     = NULL;
+  phydbl cur_glnL, new_glnL, hr;
+  phydbl cur_alnL, new_alnL;
+  phydbl scale_fact_times;
+  int n_disks;
+  t_dsk  *disk;
+  phydbl K;
+  phydbl cur_lbda, new_lbda;
+
+  disk            = NULL;
+  cur_alnL        = tree->c_lnL;
+  new_alnL        = tree->c_lnL;
+  new_glnL        = tree->mmod->c_lnL;
+  cur_glnL        = tree->mmod->c_lnL;
+  hr              = 0.0;
+  ratio           = 0.0;
+  K               = tree->mcmc->tune_move[tree->mcmc->num_move_phyrex_scale_times];
+  cur_lbda        = tree->mmod->lbda;
+  new_lbda        = tree->mmod->lbda;
 
+  u = Uni();
+  scale_fact_times = EXP(K*(u-.5));
+  
   if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+
+  n_disks = 0;
   disk = tree->disk->prev;
-  n_all_disks = 0;
   do
     {
-      if(disk->ldsk != NULL)
-        {
-          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
-          all_disks[n_all_disks] = disk;
-          n_all_disks++;
-        }
+      disk->time = disk->time * scale_fact_times;
+      n_disks++;
       disk = disk->prev;
     }
   while(disk);
 
-  if(!n_all_disks) return;
-  
-  /* Uniform selection of a disk */
-  i = Rand_Int(0,n_all_disks-1);
-  target_disk = all_disks[i];
-  Free(all_disks);
   
-  bkup_coord = MIGREP_Copy_Geo_Coord(target_disk->ldsk->coord);
+  /* The Hastings ratio involves (n_disk-2) when considering a uniform distrib
+     for the multiplier, which is not the case here.
+  */
+  hr += (n_disks)*LOG(scale_fact_times);
 
-  For(i,tree->mmod->n_dim) 
-    {
-      max = target_disk->centr->lonlat[i] + tree->mmod->rad;
-      min = target_disk->centr->lonlat[i] - tree->mmod->rad;
-      /* need to add condition here that new position also has to be into disk above */
-      max = MIN(tree->mmod->lim->lonlat[i],max);
-      min = MAX(0.0,min);
-      target_disk->ldsk->coord->lonlat[i] = Uni()*(max - min) + min;
-    }
+  /* Adjust the value of lambda */
+  new_lbda = cur_lbda * (1./scale_fact_times);
+  hr += LOG(1./scale_fact_times);
+  tree->mmod->lbda = new_lbda;
 
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+  new_glnL = PHYREX_Lk(tree);
+  if(tree->mcmc->use_data == YES) new_alnL = Lk(NULL,tree);
 
+  ratio += (new_alnL - cur_alnL);
+  ratio += (new_glnL - cur_glnL);
+  ratio += hr;
+  
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
   
   /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
 
   u = Uni();
   
-  /* printf("\n- Delete new_lnL: %f [%f] hr: %f u:%f alpha: %f",new_lnL,cur_lnL,hr,u,alpha); */
+  /* PhyML_Printf("\n. Scale times hr: %f new_glnL: %f cur_glnL: %f ratio: %f", */
+  /*              hr, */
+  /*              new_glnL,cur_glnL, */
+  /*              ratio) */
 
   if(u > alpha) /* Reject */
     {
-      /* printf("- Reject"); */
-      
-      Free_Geo_Coord(target_disk->ldsk->coord);
-      target_disk->ldsk->coord = MIGREP_Copy_Geo_Coord(bkup_coord);
-      
-      /* tree->mmod->c_lnL = cur_lnL; */
+      tree->mmod->lbda = cur_lbda;
+
+      /* printf("- Reject");       */
+      disk = tree->disk->prev;
+      do
+        {
+          disk->time /= scale_fact_times;
+          disk = disk->prev;
+        }
+      while(disk);
+
 
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          if(tree->mcmc->use_data == YES)
+            {
+              new_alnL = Lk(NULL,tree); /* Not necessary. Remove once tested */
+              
+              if(Are_Equal(new_alnL,cur_alnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_alnL: %f cur_alnL: %f lbda: %f",new_alnL,cur_alnL,tree->mmod->lbda);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          
+          new_glnL = PHYREX_Lk(tree); /* Same here */
+          
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n== new_glnL: %f cur_glnL: %f lbda: %f",new_glnL,cur_glnL,tree->mmod->lbda);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          tree->mmod->c_lnL = cur_glnL;
+          tree->c_lnL       = cur_alnL;
         }
     }
   else
     {
-      /* printf("- Accept"); */
+      /* printf("- Accept -> %f",tree->c_lnL); */
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_scale_times]++;
     }  
-
-  Free_Geo_Coord(bkup_coord);
-        
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_scale_times]++;
 }
 #endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
 
-#ifdef MIGREP
-void MCMC_MIGREP_Shift_Ldsk_To_Centre(t_tree *tree)
+#ifdef PHYREX
+void MCMC_PHYREX_Swap_Disk(t_tree *tree)
 {
   phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr;
-  t_dsk  *disk,*target_disk,**all_disks;
-  int i,block,n_all_disks;
-  t_geo_coord *bkup_coord;
-  phydbl max,min;
-
-  disk          = NULL;
-  new_lnL       = UNLIKELY;
-  cur_lnL       = tree->mmod->c_lnL;
-  hr            = 0.0;
-  ratio         = 0.0;
-  block         = 100;
-  all_disks     = NULL;
-
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  disk = tree->disk->prev;
-  n_all_disks = 0;
-  do
-    {
-      if(disk->ldsk != NULL)
+  phydbl cur_glnL, new_glnL;
+  phydbl cur_alnL, new_alnL;
+  phydbl hr,t,t_min,t_max,ori_time;
+  t_dsk  *disk,*target_disk,*ori_disk_old,*ori_disk_young,**valid_disks;
+  int i,j,block,n_valid_disks;
+
+  /* For(j,1+(int)(tree->n_otu/5)) */
+  For(j,1+tree->n_otu)
+    {
+      disk           = NULL;
+      target_disk    = NULL;
+      ori_disk_old   = NULL;
+      ori_disk_young = NULL;
+      valid_disks    = NULL;
+      new_glnL       = tree->mmod->c_lnL;
+      cur_glnL       = tree->mmod->c_lnL;
+      new_alnL       = tree->c_lnL;
+      cur_alnL       = tree->c_lnL;
+      hr             = 0.0;
+      ratio          = 0.0;
+      block          = 100;
+      
+      if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+      disk = tree->disk->prev;
+      if(!disk->prev) return;
+      n_valid_disks = 0;
+      do
         {
-          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
-          all_disks[n_all_disks] = disk;
-          n_all_disks++;
+          /* Record disk with a lineage displacement or coalescent that is not the root disk */
+          if(disk && disk->prev && disk->ldsk && disk->ldsk->n_next >= 1)
+            {
+              if(!n_valid_disks) valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+              else if(!(n_valid_disks%block)) valid_disks = (t_dsk **)mRealloc(valid_disks,n_valid_disks+block,sizeof(t_dsk *));
+              valid_disks[n_valid_disks] = disk;
+              n_valid_disks++;
+            }
+          disk = disk->prev;
         }
-      disk = disk->prev;
-    }
-  while(disk);
-
-  if(!n_all_disks) return;
-  
-  /* Uniform selection of a disk */
-  i = Rand_Int(0,n_all_disks-1);
-  target_disk = all_disks[i];
-  Free(all_disks);
-  
-  bkup_coord = MIGREP_Copy_Geo_Coord(target_disk->ldsk->coord);
-
-  For(i,tree->mmod->n_dim) 
-    {
-      if(target_disk->ldsk->coord->lonlat[i] > target_disk->centr->lonlat[i])
+      while(disk && disk->prev);
+      
+      if(n_valid_disks < 2) return;
+      
+      /* Uniform selection of a disk where either a coalescent or a 'hit/displacement' occurred */
+      i = Rand_Int(0,n_valid_disks-1);
+      target_disk = valid_disks[i];
+      Free(valid_disks);
+      
+      ori_disk_old   = target_disk->prev;
+      ori_disk_young = target_disk->next;
+      ori_time       = target_disk->time;
+      
+      t_min = target_disk->ldsk->prev->disk->time;
+      t_max = +INFINITY;
+      For(i,target_disk->ldsk->n_next)
+        if(target_disk->ldsk->next[i]->disk->time < t_max) 
+          t_max = target_disk->ldsk->next[i]->disk->time;
+      
+      t_max = t_max - 1.E-10;
+      t_min = t_min + 1.E-10;
+      
+      if(t_max < t_min) return;
+      
+      t = Uni()*(t_max - t_min) + t_min;
+      target_disk->time = t;
+      
+      PHYREX_Remove_Disk(target_disk);
+      
+      PHYREX_Insert_Disk(target_disk,tree);
+      
+      new_glnL = PHYREX_Lk(tree);
+      if(tree->mcmc->use_data == YES) new_alnL = Lk(NULL,tree);
+      
+      ratio += (new_alnL - cur_alnL);
+      ratio += (new_glnL - cur_glnL);
+      ratio += hr;
+            
+      ratio = EXP(ratio);
+      alpha = MIN(1.,ratio);
+      
+      /* Always accept move */
+      if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+      
+      u = Uni();
+      
+      /* printf("\n- Swap new_glnL: %f [%f] hr: %f u:%f alpha: %f",new_glnL,cur_glnL,hr,u,alpha); */
+      
+      if(u > alpha) /* Reject */
         {
-          max = target_disk->ldsk->coord->lonlat[i];
-          if(target_disk->prev)
-            min = MAX(target_disk->centr->lonlat[i],
-                      target_disk->ldsk->prev->disk->centr->lonlat[i] - tree->mmod->rad);              
+          /* printf("\n- Reject %f %f",target_disk->time,ori_time); */
+          
+          PHYREX_Remove_Disk(target_disk);
+          
+          target_disk->time = ori_time;
+          target_disk->prev = ori_disk_old;
+          target_disk->next = ori_disk_young;
+          
+          PHYREX_Insert_Disk(target_disk,tree);
+          
+          if(tree->mmod->safe_phyrex == YES)
+            {
+              if(tree->mcmc->use_data == YES)
+                {
+                  new_alnL = Lk(NULL,tree); /* Remove once checked */
+                  
+                  if(Are_Equal(new_alnL,cur_alnL,1.E-3) == NO)
+                    {
+                      PhyML_Printf("\n== new_alnL: %f cur_alnL: %f",new_alnL,cur_alnL);
+                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                    }
+                }
+              
+              new_glnL = PHYREX_Lk(tree); /* Same */
+              
+              if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
           else
-            min = target_disk->centr->lonlat[i];
+            {
+              PHYREX_Update_Lindisk_List(tree);
+              tree->mmod->c_lnL = cur_glnL;
+              tree->c_lnL       = cur_alnL;          
+            }
         }
       else
         {
-          min = target_disk->ldsk->coord->lonlat[i];
-          if(target_disk->prev)
-            max = MAX(target_disk->centr->lonlat[i],
-                      target_disk->ldsk->prev->disk->centr->lonlat[i] + tree->mmod->rad);              
-          else
-            max = target_disk->centr->lonlat[i];
+          /* printf("\n- Accept %f %f",target_disk->time,ori_time); */
         }
-      min = MAX(0.0,min);
-      max = MIN(tree->mmod->lim->lonlat[i],max);
-      target_disk->ldsk->coord->lonlat[i] = Uni()*(max - min) + min;
     }
+}
+#endif
   
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+#ifdef PHYREX
+void MCMC_PHYREX_Indel_Hit(t_tree *tree)
+{
+  int n_disks_cur, n_disks_new;
+  t_dsk  *disk;
+  phydbl hr;
+  phydbl cur_rad, new_rad;
+  phydbl cur_mu, new_mu;
 
-  ratio = EXP(ratio);
-  alpha = MIN(1.,ratio);
-  
-  /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  hr      = 0.0;
+  new_rad = tree->mmod->rad;
+  cur_rad = tree->mmod->rad;
+  new_mu  = tree->mmod->mu;
+  cur_mu  = tree->mmod->mu;
 
-  u = Uni();
-  
-  /* printf("\n- Delete new_lnL: %f [%f] hr: %f u:%f alpha: %f",new_lnL,cur_lnL,hr,u,alpha); */
+  /* new_rad = cur_rad * EXP(0.5*(Uni()-.5)); */
+  /* hr += LOG(new_rad/cur_rad); */
 
-  if(u > alpha) /* Reject */
-    {
-      /* printf("- Reject"); */
-      
-      Free_Geo_Coord(target_disk->ldsk->coord);
-      target_disk->ldsk->coord = MIGREP_Copy_Geo_Coord(bkup_coord);
-      
-      /* tree->mmod->c_lnL = cur_lnL; */
+  /* new_mu = cur_mu * EXP(0.5*(Uni()-.5)); */
+  /* hr += LOG(new_mu/cur_mu); */
 
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
-        {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-        }
-    }
-  else
+  if(new_rad > tree->mmod->max_rad || new_rad < tree->mmod->min_rad) return; 
+  if(new_mu > tree->mmod->max_mu || new_mu < tree->mmod->min_mu)     return; 
+
+  tree->mmod->rad = new_rad;
+  tree->mmod->mu  = new_mu;
+
+  disk = tree->disk->prev;
+  n_disks_cur = 0;
+  do
     {
-      /* printf("- Accept"); */
-    }  
+      if(disk->ldsk != NULL && disk->ldsk->n_next == 1) n_disks_cur++;
+      disk = disk->prev;
+    }
+  while(disk && disk->prev);
+  
+  n_disks_new = (int)Rpois(n_disks_cur+1);
+  
+  hr += Dpois(n_disks_cur,n_disks_new+1,YES);
+  hr -= Dpois(n_disks_new,n_disks_cur+1,YES);
 
-  Free_Geo_Coord(bkup_coord);
-        
+  /* K = 0.2; */
+  /* n_disks_new = (int)Rgamma((phydbl)n_disks_cur/K,K); */
+
+  /* hr += LOG(Pgamma(n_disks_cur+1,(phydbl)n_disks_new/K,K) - Pgamma(n_disks_cur,(phydbl)n_disks_new/K,K)); */
+  /* hr -= LOG(Pgamma(n_disks_new+1,(phydbl)n_disks_cur/K,K) - Pgamma(n_disks_new,(phydbl)n_disks_cur/K,K)); */
+
+  if(n_disks_new < n_disks_cur) MCMC_PHYREX_Delete_Hit(hr, n_disks_cur - n_disks_new, cur_rad, cur_mu, tree);
+  else                          MCMC_PHYREX_Insert_Hit(hr, n_disks_new - n_disks_cur, cur_rad, cur_mu, tree);  
 }
 #endif
 
+
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
-/* Shift centre to median position */
-#ifdef MIGREP
-void MCMC_MIGREP_Shift_Centre_To_Median(t_tree *tree)
+/* Insert a disk with a new lineage displacement */
+#ifdef PHYREX
+void MCMC_PHYREX_Insert_Hit(phydbl hr, int n_insert_disks, phydbl cur_rad, phydbl cur_mu, t_tree *tree)
 {
+  t_dsk  *disk,**new_disk,*young_disk;
+  t_ldsk **young_ldsk, **old_ldsk, **new_ldsk;
+  phydbl T,t;
+  phydbl cur_glnL, new_glnL;
   phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr;
-  t_dsk  *disk,*target_disk,**all_disks;
-  int i,j,block,n_all_disks;
-  t_geo_coord *bkup_coord;
-  phydbl max,min;
+  int i,j,*dir_old_young,n_valid_disks,err;
 
-  disk          = NULL;
-  new_lnL       = UNLIKELY;
-  cur_lnL       = tree->mmod->c_lnL;
-  hr            = 0.0;
-  ratio         = 0.0;
-  block         = 100;
-  all_disks     = NULL;
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_indel_hit]++;
+
+  disk            = NULL;
+  new_glnL        = tree->mmod->c_lnL;
+  cur_glnL        = tree->mmod->c_lnL;
 
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
   disk = tree->disk->prev;
-  n_all_disks = 0;
+  n_valid_disks = 0;
   do
     {
-      if(disk->ldsk != NULL)
-        {
-          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
-          all_disks[n_all_disks] = disk;
-          n_all_disks++;
-        }
+      if(disk->ldsk != NULL && disk->ldsk->n_next == 1) n_valid_disks++;
       disk = disk->prev;
     }
-  while(disk);
-
-  if(!n_all_disks) return;
-  
-  /* Uniform selection of a disk */
-  i = Rand_Int(0,n_all_disks-1);
-  target_disk = all_disks[i];
-  Free(all_disks);
+  while(disk && disk->prev);
   
-  bkup_coord = MIGREP_Copy_Geo_Coord(target_disk->centr);
-
-  For(i,tree->mmod->n_dim) 
+  if(n_insert_disks == 0) 
     {
-      min = +INFINITY;
-      max = -INFINITY;
-      For(j,target_disk->ldsk->n_next)
-        {
-          if(target_disk->ldsk->next[j]->coord->lonlat[i] < min) 
-            min = target_disk->ldsk->next[j]->coord->lonlat[i];
-          if(target_disk->ldsk->next[j]->coord->lonlat[i] > max) 
-            max = target_disk->ldsk->next[j]->coord->lonlat[i];         
-        }
-      min = MIN(min,target_disk->ldsk->coord->lonlat[i]);
-      max = MAX(max,target_disk->ldsk->coord->lonlat[i]);
-      min = MAX(0.0,min);
-      max = MIN(tree->mmod->lim->lonlat[i],max);
-      target_disk->centr->lonlat[i] = Uni()*(max - min) + min;
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return; 
     }
-  
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
 
-  ratio = EXP(ratio);
-  alpha = MIN(1.,ratio);
-  
-  /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  new_disk      = (t_dsk **)mCalloc(n_insert_disks,sizeof(t_dsk *));
+  new_ldsk      = (t_ldsk **)mCalloc(n_insert_disks,sizeof(t_ldsk *));
+  old_ldsk      = (t_ldsk **)mCalloc(n_insert_disks,sizeof(t_ldsk *));
+  young_ldsk    = (t_ldsk **)mCalloc(n_insert_disks,sizeof(t_ldsk *));
+  dir_old_young = (int *)mCalloc(n_insert_disks,sizeof(int));
 
-  u = Uni();
-  
-  /* printf("\n- Delete new_lnL: %f [%f] hr: %f u:%f alpha: %f",new_lnL,cur_lnL,hr,u,alpha); */
+  T = PHYREX_Tree_Height(tree);
 
-  if(u > alpha) /* Reject */
-    {
-      /* printf("- Reject"); */
+  For(j,n_insert_disks)
+    {  
+      /* Time of insertion of new disk */
+      t = Uni()*T;
+      disk = tree->disk;
+      while(disk && disk->time > t) disk = disk->prev;
       
-      Free_Geo_Coord(target_disk->centr);
-      target_disk->centr = MIGREP_Copy_Geo_Coord(bkup_coord);
+      /* Disks located just prior and after inserted disk */
+      young_disk = disk->next;
+
+      /* Make and initialize new disk */ 
+      new_disk[j] = PHYREX_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
+      PHYREX_Init_Disk_Event(new_disk[j],tree->mmod->n_dim,tree->mmod);
+        
+      /* Time of the new disk */
+      new_disk[j]->time = t;
       
-      /* tree->mmod->c_lnL = cur_lnL; */
+      /* Insert it */
+      PHYREX_Insert_Disk(new_disk[j],tree);
+
+      assert(young_disk->n_ldsk_a);
 
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      /* Which lineage is going to be hit ? */
+      hr += LOG(young_disk->n_ldsk_a);
+      
+      young_ldsk[j] = young_disk->ldsk_a[Rand_Int(0,young_disk->n_ldsk_a-1)];
+      old_ldsk[j]   = young_ldsk[j]->prev;
+  
+      if(old_ldsk[j]->disk->time > young_ldsk[j]->disk->time) 
         {
-          PhyML_Printf("\n== new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          PhyML_Printf("\n== young_ldsk: %f",young_ldsk[j]->disk->time);
+          PhyML_Printf("\n== old_ldsk: %f",old_ldsk[j]->disk->time);
+          assert(FALSE);
+        }
+      
+      /* Direction from old to young ldsk */
+      dir_old_young[j] = PHYREX_Get_Next_Direction(young_ldsk[j],old_ldsk[j]);
+      assert(dir_old_young[j] != -1);
+
+      /* Make and initialize new ldsk */
+      new_ldsk[j] = PHYREX_Make_Lindisk_Node(tree->mmod->n_dim);
+      PHYREX_Init_Lindisk_Node(new_ldsk[j],new_disk[j],tree->mmod->n_dim);
+      PHYREX_Make_Lindisk_Next(new_ldsk[j]);
+      new_disk[j]->ldsk = new_ldsk[j];
+
+      /* Connect it */
+      new_ldsk[j]->prev                   = old_ldsk[j];
+      new_ldsk[j]->next[0]                = young_ldsk[j];
+      young_ldsk[j]->prev                 = new_ldsk[j];  
+      old_ldsk[j]->next[dir_old_young[j]] = new_ldsk[j];
+
+      /* PHYREX_Update_Lindisk_List_Core(young_disk); */
+      /* PHYREX_Update_Lindisk_List_Core(new_disk[j]); */
+      /* PHYREX_Update_Lindisk_List_Core(old_disk); */
+
+      /* Really necessary given that lk function is called afterwards? */
+      PHYREX_Update_Lindisk_List(tree);
+      
+      /* Sample position of the displaced ldsk */
+      For(i,tree->mmod->n_dim)
+        {
+          new_ldsk[j]->coord->lonlat[i] = Rnorm_Trunc(0.5*(young_ldsk[j]->coord->lonlat[i]+old_ldsk[j]->coord->lonlat[i]),
+                                                      1.0*tree->mmod->rad,
+                                                      0.0,tree->mmod->lim->lonlat[i],&err);
+          hr -= Log_Dnorm_Trunc(new_ldsk[j]->coord->lonlat[i],
+                                0.5*(young_ldsk[j]->coord->lonlat[i]+old_ldsk[j]->coord->lonlat[i]),
+                                1.0*tree->mmod->rad,
+                                0.0,tree->mmod->lim->lonlat[i],&err);
         }
-    }
-  else
-    {
-      /* printf("- Accept"); */
-    }  
 
-  Free_Geo_Coord(bkup_coord);
-        
-}
-#endif
+      /* Sample position of the center of new_disk */
+      For(i,tree->mmod->n_dim)
+        {
+          new_disk[j]->centr->lonlat[i] = Rnorm_Trunc(new_ldsk[j]->coord->lonlat[i],
+                                                      1.0*tree->mmod->rad,
+                                                      0.0,tree->mmod->lim->lonlat[i],&err);
+          hr -= Log_Dnorm_Trunc(new_disk[j]->centr->lonlat[i],
+                                new_ldsk[j]->coord->lonlat[i],
+                                1.0*tree->mmod->rad,
+                                0.0,tree->mmod->lim->lonlat[i],&err);
 
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
+        }
 
-#ifdef MIGREP
-void MCMC_MIGREP_Move_Disk_Updown(t_tree *tree)
-{
-  phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr;
-  phydbl ori_time, new_time;
-  t_dsk  *disk,*target_disk,**all_disks;
-  int i,block,n_all_disks;
+    }
 
-  disk          = NULL;
-  new_lnL       = UNLIKELY;
-  cur_lnL       = tree->mmod->c_lnL;
-  hr            = 0.0;
-  ratio         = 0.0;
-  block         = 100;
-  all_disks     = NULL;
+  T = PHYREX_Tree_Height(tree);
 
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  disk = tree->disk->prev;
-  n_all_disks = 0;
-  do
-    {
-      if(disk->ldsk && disk->ldsk->n_next == 1) /* do not move coalescent disks */
-        {
-          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
-          all_disks[n_all_disks] = disk;
-          n_all_disks++;
-        }
-      disk = disk->prev;
-    }
-  while(disk->prev);
+  hr -= LnChoose(n_valid_disks+n_insert_disks,n_insert_disks);
+  hr += n_insert_disks * LOG(-T);  
+  hr -= LnFact(n_insert_disks);
 
-  if(!n_all_disks) return;
+  new_glnL = PHYREX_Lk(tree);
   
-  /* Uniform selection of a disk */
-  i = Rand_Int(0,n_all_disks-1);
-  target_disk = all_disks[i];
-  Free(all_disks);
-  
-  ori_time = target_disk->time;
-  new_time = Uni()*(target_disk->next->time - target_disk->prev->time) + target_disk->prev->time;
-  target_disk->time = new_time;
-
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+  ratio = (new_glnL - cur_glnL);
+  ratio += hr;  
 
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
-  
-  /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
-  
+
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+
   u = Uni();
   
-  /* printf("\n- Move disk new_lnL: %f [%f] hr: %f u:%f alpha: %f",new_lnL,cur_lnL,hr,u,alpha); */
+  /* printf("\n- Insert hit %15f %15f %5d",new_glnL - cur_glnL, alpha, n_insert_disks); */
 
   if(u > alpha) /* Reject */
     {
-      /* printf("- Reject"); */
+      /* printf("+ Reject"); */
+
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu  = cur_mu;
       
-      target_disk->time = ori_time; 
-      /* tree->mmod->c_lnL = cur_lnL; */
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      for(j=n_insert_disks-1;j>=0;j--)
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          PHYREX_Remove_Disk(new_disk[j]);      
+          Free_Disk(new_disk[j]);
+          Free_Ldisk(new_ldsk[j]);
+
+          old_ldsk[j]->next[dir_old_young[j]] = young_ldsk[j];
+          young_ldsk[j]->prev = old_ldsk[j];
+        }
+      
+
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          new_glnL = PHYREX_Lk(tree);
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
+        {
+          PHYREX_Update_Lindisk_List(tree);
+          tree->mmod->c_lnL = cur_glnL;
         }
+
     }
   else
     {
-      /* printf("- Accept"); */
-    }  
+      /* printf("+ Accept"); */
+      /* if(indel > 0) printf("\n. Accept"); */
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_indel_hit]++;
+    }
+
+
+  Free(new_disk);
+  Free(new_ldsk);
+  Free(old_ldsk);
+  Free(young_ldsk);
+  Free(dir_old_young);
+
+
 }
 #endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
-
-#ifdef MIGREP
-void MCMC_MIGREP_Swap_Disk(t_tree *tree)
+/* Remove one or more disks with a lineage displacement */
+#ifdef PHYREX
+void MCMC_PHYREX_Delete_Hit(phydbl hr, int n_delete_disks, phydbl cur_rad, phydbl cur_mu, t_tree *tree)
 {
   phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr,t,t_min,t_max,ori_time;
-  t_dsk  *disk,*target_disk,*ori_disk_old,*ori_disk_young,**valid_disks;
-  int i,block,n_valid_disks;
-
-  disk           = NULL;
-  target_disk    = NULL;
-  ori_disk_old   = NULL;
-  ori_disk_young = NULL;
-  new_lnL        = UNLIKELY;
-  cur_lnL        = tree->mmod->c_lnL;
-  hr             = 0.0;
-  ratio          = 0.0;
-  block          = 100;
+  phydbl cur_glnL,new_glnL,T;
+  t_dsk  *disk,**target_disk,**valid_disks;
+  t_ldsk **target_ldsk,**old_ldsk,**young_ldsk;
+  int i,j,block,n_valid_disks,*dir_old_young,*permut,err;
+
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_indel_hit]++;
+
+  disk            = NULL;
+  valid_disks     = NULL;
+  new_glnL        = tree->mmod->c_lnL;
+  cur_glnL        = tree->mmod->c_lnL;  
+  ratio           = 0.0;
+  block           = 100;
 
   if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
   disk = tree->disk->prev;
+  if(!disk->prev) 
+    {
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return;
+    }
+
   n_valid_disks = 0;
   do
     {
-      /* Record disk with a lineage displacement (not coalescent)*/
-      if(disk->ldsk && disk->ldsk->n_next == 1)
+      /* Include only disks with displacement that are not coalescent events */
+      if(disk->ldsk != NULL && disk->ldsk->n_next == 1) 
         {
           if(!n_valid_disks) valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
           else if(!(n_valid_disks%block)) valid_disks = (t_dsk **)mRealloc(valid_disks,n_valid_disks+block,sizeof(t_dsk *));
@@ -6036,562 +6094,2086 @@ void MCMC_MIGREP_Swap_Disk(t_tree *tree)
         }
       disk = disk->prev;
     }
-  while(disk->prev);
+  while(disk && disk->prev);
 
-  if(!n_valid_disks) return;
-  
-  /* Uniform selection of a disk where either a coalescent or a 'hit/displacement' occurred */
-  i = Rand_Int(0,n_valid_disks-1);
-  target_disk = valid_disks[i];
-  Free(valid_disks);
+  if(!n_valid_disks) 
+    {
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return;
+    }
   
-  ori_disk_old   = target_disk->prev;
-  ori_disk_young = target_disk->next;
-  ori_time       = target_disk->time;
-
-  MIGREP_Remove_Disk(target_disk);
+  if(n_valid_disks - n_delete_disks < 0) 
+    { 
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      return; 
+    }
 
-  t_min = target_disk->ldsk->prev->disk->time;
-  t_max = +INFINITY;
-  For(i,target_disk->ldsk->n_next)
-    if(target_disk->ldsk->next[i]->disk->time < t_max) 
-      t_max = target_disk->ldsk->next[i]->disk->time;
-    
+  target_disk   = (t_dsk **)mCalloc(n_delete_disks,sizeof(t_dsk *));
+  target_ldsk   = (t_ldsk **)mCalloc(n_delete_disks,sizeof(t_ldsk *));
+  old_ldsk      = (t_ldsk **)mCalloc(n_delete_disks,sizeof(t_ldsk *));
+  young_ldsk    = (t_ldsk **)mCalloc(n_delete_disks,sizeof(t_ldsk *));
+  dir_old_young = (int *)mCalloc(n_delete_disks,sizeof(int));
 
-  if(t_max < t_min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  permut = Permutate(n_valid_disks);
 
-  t = Uni()*(t_max - t_min) + t_min;
-  target_disk->time = t;
+  For(j,n_delete_disks)
+    {
+      target_disk[j] = valid_disks[permut[j]];  
+      target_ldsk[j] = target_disk[j]->ldsk;
+  
+      assert(target_ldsk[j] != NULL);
+      assert(target_ldsk[j]->n_next == 1);
 
+      old_ldsk[j]   = target_ldsk[j]->prev;
+      young_ldsk[j] = target_ldsk[j]->next[0];
+            
+      dir_old_young[j] = PHYREX_Get_Next_Direction(young_ldsk[j],old_ldsk[j]);
+      assert(dir_old_young[j] != -1);
+      
+      /* Part of the Hastings ratio corresponding to the probability of selecting */
+      /* one of target_disk->n_ldsk_a to be hit */ 
+      hr -= LOG(target_disk[j]->next->n_ldsk_a);
+            
+      /* Density for position of the displaced ldsk */
+      For(i,tree->mmod->n_dim)
+        {
+          hr += Log_Dnorm_Trunc(target_ldsk[j]->coord->lonlat[i],
+                                0.5*(young_ldsk[j]->coord->lonlat[i]+old_ldsk[j]->coord->lonlat[i]),
+                                1.0*tree->mmod->rad,
+                                0.0,
+                                tree->mmod->lim->lonlat[i],&err);
+        }
 
-  disk = target_disk->ldsk->prev->disk;
-  while(!(disk->time < t && disk->next->time > t)) 
-    {
-      disk = disk->next;     
-      if(!disk || disk->time > t) 
+      /* Density for position of the center of target_disk */
+      For(i,tree->mmod->n_dim)
         {
-          PhyML_Printf("\n. target_t: %f",t);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          hr += Log_Dnorm_Trunc(target_disk[j]->centr->lonlat[i],
+                                target_ldsk[j]->coord->lonlat[i],
+                                1.0*tree->mmod->rad,
+                                0.0,tree->mmod->lim->lonlat[i],&err);
         }
+
+      /* New connections between old_ldsk and young_ldsk */
+      old_ldsk[j]->next[dir_old_young[j]] = young_ldsk[j];
+      young_ldsk[j]->prev                 = old_ldsk[j];
+
+      /* Remove target disk */
+      PHYREX_Remove_Disk(target_disk[j]);
     }
   
+  T = PHYREX_Tree_Height(tree);
+  
+  hr += LnChoose(n_valid_disks,n_delete_disks);
+  hr -= n_delete_disks * LOG(-T);
+  hr += LnFact(n_delete_disks);
 
-  target_disk->prev = disk;
-  target_disk->next = disk->next;
+  Free(valid_disks);
 
-  MIGREP_Insert_Disk(target_disk);
+  new_glnL = PHYREX_Lk(tree);
 
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
+  ratio += (new_glnL - cur_glnL);
   ratio += hr;
 
-
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
   
   /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
 
   u = Uni();
   
-  /* printf("\n- Swap new_lnL: %f [%f] hr: %f u:%f alpha: %f",new_lnL,cur_lnL,hr,u,alpha); */
+  /* printf("\n- Delete hit %15f %15f %5d",new_glnL - cur_glnL, alpha, n_delete_disks); */
 
   if(u > alpha) /* Reject */
     {
+      tree->mmod->rad = cur_rad;
+      tree->mmod->mu = cur_mu;
+      
       /* printf("- Reject"); */
-
-      MIGREP_Remove_Disk(target_disk);
+      for(j=n_delete_disks-1;j>=0;j--) 
+        {
+          PHYREX_Insert_Disk(target_disk[j],tree);      
+          old_ldsk[j]->next[dir_old_young[j]] = target_ldsk[j];
+          young_ldsk[j]->prev                 = target_ldsk[j];
+        }
       
-      target_disk->time = ori_time;
-      target_disk->prev = ori_disk_old;
-      target_disk->next = ori_disk_young;
-
-      MIGREP_Insert_Disk(target_disk);
-
-      /* tree->mmod->c_lnL = cur_lnL; */
-
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          new_glnL = PHYREX_Lk(tree);
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          PHYREX_Update_Lindisk_List(tree);
+          tree->mmod->c_lnL = cur_glnL;
         }
     }
   else
     {
-      /* printf("- Accept"); */
+      /* printf(" ***"); */
+
+      For(j,n_delete_disks) Free_Disk(target_disk[j]);
+      For(j,n_delete_disks) Free_Ldisk(target_ldsk[j]);
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_indel_hit]++;
     }
+  
+
+  Free(target_disk);
+  Free(target_ldsk);
+  Free(old_ldsk);
+  Free(young_ldsk);
+  Free(dir_old_young);
+  Free(permut);
 }
 #endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
-/* Insert a disk with a new lineage displacement */
-#ifdef MIGREP
-void MCMC_MIGREP_Insert_Hit(t_tree *tree)
+
+#ifdef PHYREX
+void MCMC_PHYREX_Prune_Regraft(t_tree *tree)
 {
-  t_dsk  *disk,*new_disk,*young_disk,*old_disk;
-  t_ldsk *young_ldsk, *old_ldsk, *new_ldsk;
-  phydbl T,t,cur_lbda;
-  phydbl cur_lnL, new_lnL, hr;
-  phydbl u,alpha,ratio;
-  phydbl max, min;
-  int i,dir_old_young,n_valid_disks;
+  phydbl u,alpha,ratio,hr;
+  phydbl cur_glnL, new_glnL;
+  phydbl cur_alnL, new_alnL;
+  t_dsk  *disk,*prune_disk,*regraft_disk,**valid_disks,*dum_dum_disk;
+  t_ldsk *prune_ldsk,*regraft_ldsk,*prune_daughter_ldsk,*cur_path,*new_path,*ldsk,*ldsk_dum;
+  phydbl *prob_disks;
+  int i,block,n_valid_disks,prune_next_num,num_prune_disk,n_prune_disks;
+  phydbl rate,dt,sizeT,sum;
+  phydbl max_dist, param_exp;
+  int cur_path_len;
+  int n_hits,n_iter;
+  int cur_pos,new_pos;
+
+  n_iter   = MAX(1,(int)(tree->n_otu/5));
+
+  while(n_iter--)
+    {
+      tree->mcmc->run_move[tree->mcmc->num_move_phyrex_spr]++;
+  
+      valid_disks    = NULL;
+      disk           = NULL;
+      prob_disks     = NULL;
+      new_glnL       = tree->mmod->c_lnL;
+      cur_glnL       = tree->mmod->c_lnL;
+      new_alnL       = tree->c_lnL;
+      cur_alnL       = tree->c_lnL;
+      hr             = 0.0;
+      ratio          = 0.0;
+      block          = 100;
+      cur_pos        = -1;
+      new_pos        = -1;
+      num_prune_disk = -1;
+      sizeT          = PHYREX_Time_Tree_Length(tree);
+
+      if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+      
+      /* Get a ldsk from which you can prune a lineage */
+      disk = tree->disk->prev;
+      n_prune_disks = 0;
+      do
+        {
+          /* Include only disks with displacement that are coalescent events */
+          if(disk->ldsk != NULL && disk->ldsk->n_next > 1)
+            {
+              /* Root has degree 2: don't pull any lineage */
+              if(!(disk->prev == NULL && disk->ldsk->n_next == 2))
+                {
+                  if(!n_prune_disks) valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+                  else if(!(n_prune_disks%block)) valid_disks = (t_dsk **)mRealloc(valid_disks,n_prune_disks+block,sizeof(t_dsk *));
+                  valid_disks[n_prune_disks] = disk;
+                  n_prune_disks++;
+                }
+            }
+          disk = disk->prev;
+        }
+      while(disk);
+      
+      if(!n_prune_disks) return;
+            
+      /* Uniform selection of a disk where a coalescent occurred */
+      i = Rand_Int(0,n_prune_disks-1);
+      prune_disk = valid_disks[i];
+      Free(valid_disks);
+      
+      hr -= LOG(1./n_prune_disks);
+
+      prune_ldsk = prune_disk->ldsk;
+      /* Which daughter lineage are we pruning? */
+      prune_next_num = Rand_Int(0,prune_ldsk->n_next-1);
+      prune_daughter_ldsk = prune_ldsk->next[prune_next_num];
+      while(prune_daughter_ldsk->n_next < 2 && /* prune_daughter is a coalescent node */
+            prune_daughter_ldsk->disk->next) prune_daughter_ldsk = prune_daughter_ldsk->next[0];
+      
+      /* prune_daughter_ldsk has to be the next coalescent node under prune_ldsk for this move to work */
+      
+      /* Proba of pruning this particular one */
+      hr -= LOG(1./prune_ldsk->n_next);
+            
+      /* Get a ldsk to reattach the pruned lineage to */
+      disk = tree->disk->prev;
+      n_valid_disks = 0;
+      do
+        {
+          /* Include only disks with displacement that are not younger
+             than prune_daughter_ldsk */
+          if((disk->ldsk != NULL) && 
+             (disk->ldsk->n_next > 0) && 
+             (disk->time < prune_daughter_ldsk->disk->time) && 
+             (PHYREX_Is_On_Path(disk->ldsk,prune_daughter_ldsk,prune_ldsk) == NO))
+            {
+              if(!n_valid_disks) 
+                {
+                  valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+                  prob_disks  = (phydbl *)mCalloc(block,sizeof(phydbl));
+                }
+              else if(!(n_valid_disks%block)) 
+                {
+                  valid_disks = (t_dsk **)mRealloc(valid_disks,n_valid_disks+block,sizeof(t_dsk *));
+                  prob_disks  = (phydbl *)mRealloc(prob_disks,n_valid_disks+block,sizeof(phydbl));
+                }
 
-  disk     = NULL;
-  new_lnL  = UNLIKELY;
-  cur_lnL  = tree->mmod->c_lnL;
-  hr       = 0.0;
-  cur_lbda = tree->mmod->lbda;
+              valid_disks[n_valid_disks] = disk;
 
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+              prob_disks[n_valid_disks] = PHYREX_Dist_Between_Two_Ldsk(disk->ldsk,
+                                                                       prune_daughter_ldsk,
+                                                                       tree);
 
-  disk = tree->disk->prev;
-  n_valid_disks = 0;
-  do
-    {
-      if(disk->ldsk != NULL && disk->ldsk->n_next == 1) n_valid_disks++;
-      disk = disk->prev;
-    }
-  while(disk->prev);
+              if(disk == prune_disk) 
+                {
+                  num_prune_disk = n_valid_disks;
+                }
 
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  T = disk->time;
-  
-  /* Time of insertion of new disk */
-  t = Uni()*T;
-  disk = tree->disk;
-  while(disk->time > t) disk = disk->prev;
+              n_valid_disks++;
+            }
+          disk = disk->prev;
+        }
+      while(disk);
+      
+      if(!n_valid_disks) return;
 
-  /* Disks located just prior and after inserted disk */
-  young_disk = disk->next;
-  old_disk   = disk;
+      if(n_valid_disks > 1)
+        {
+          max_dist = -INFINITY;
+          For(i,n_valid_disks) if(prob_disks[i] > max_dist) max_dist = prob_disks[i];
+          
+          sum = 0.0;
+          For(i,n_valid_disks) prob_disks[i] /= max_dist;
 
-  /* Make and initialize new disk */ 
-  new_disk= MIGREP_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
-  MIGREP_Init_Disk_Event(new_disk,tree->mmod->n_dim,tree->mmod);
-  
-  /* Connect it */
-  new_disk->prev = old_disk;
-  new_disk->next = young_disk;
-  
-  /* Time of the new disk */
-  new_disk->time = t;
+          param_exp = 1.0;
+          For(i,n_valid_disks) prob_disks[i] = Dexp(prob_disks[i],param_exp);
+
+          sum = 0.0;
+          For(i,n_valid_disks) sum += prob_disks[i];
+          For(i,n_valid_disks) prob_disks[i] /= sum;
+          
+          i = Sample_i_With_Proba_pi(prob_disks,n_valid_disks);
+          
+          /* Prob of selecting this node as regraft site */
+          hr -= LOG(prob_disks[i]);
 
-  /* Insert it */
-  MIGREP_Insert_Disk(new_disk);
+          assert(num_prune_disk > -1);
 
-  /* Which lineage is going to be hit ? */
-  hr += LOG(young_disk->n_ldsk_a);
+          /* Prob of selecting this node as regraft site (opposite move) */
+          hr += LOG(prob_disks[num_prune_disk]);
+        }
+      else
+        {
+          i = 0;
+        }
 
-  young_ldsk = young_disk->ldsk_a[Rand_Int(0,young_disk->n_ldsk_a-1)];
-  old_ldsk   = young_ldsk->prev;
+      Free(prob_disks);
 
-  /* Bail out if departure point is not within disk of arrival, in */
-  /* which case the likelihood is zero */
-  if(MIGREP_Is_In_Disk(young_ldsk->coord,old_ldsk->disk) == NO) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  
-  if(old_ldsk->disk->time > young_ldsk->disk->time) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  
-  /* Direction from old to young ldsk */
-  dir_old_young = MIGREP_Get_Next_Direction(young_ldsk,old_ldsk);
-  
-  /* Make and initialize new ldsk */
-  new_ldsk = MIGREP_Make_Lindisk_Node(tree->mmod->n_dim);
-  MIGREP_Init_Lindisk_Node(new_ldsk,new_disk,tree->mmod->n_dim);
-  MIGREP_Make_Lindisk_Next(new_ldsk);
-  new_disk->ldsk = new_ldsk;
-  
-  /* Connect it */
-  new_ldsk->prev                = old_ldsk;
-  new_ldsk->next[0]             = young_ldsk;
-  young_ldsk->prev              = new_ldsk;  
-  old_ldsk->next[dir_old_young] = new_ldsk;
+      /* Uniform selection of a disk among the list of valid ones */
+      /* i = Rand_Int(0,n_valid_disks-1); */      
 
-  /* Sample position of the center of new_disk */
-  For(i,tree->mmod->n_dim)
-    {
-      max = MIN(tree->mmod->lim->lonlat[i],
-                MIN(old_ldsk->disk->centr->lonlat[i]+2.*tree->mmod->rad,
-                    young_ldsk->coord->lonlat[i]+tree->mmod->rad));
-      min = MAX(0.0,
-                MAX(old_ldsk->disk->centr->lonlat[i]-2.*tree->mmod->rad,
-                    young_ldsk->coord->lonlat[i]-tree->mmod->rad));
+      regraft_disk = valid_disks[i];
+      Free(valid_disks);
+            
+      regraft_ldsk = regraft_disk->ldsk;
 
-      new_disk->centr->lonlat[i] = Uni()*(max - min) + min;
-      if(max < min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-      hr += LOG(max - min);
-    }
+      dum_dum_disk = (regraft_disk->time < prune_disk->time ? regraft_disk : prune_disk); 
+            
+      new_glnL = cur_glnL;
+      new_glnL -= PHYREX_Lk_Range(prune_daughter_ldsk->disk->prev,dum_dum_disk,tree);
 
-  /* Sample position of the displaced ldsk */
-  For(i,tree->mmod->n_dim)
-    {
-      max = MIN(tree->mmod->lim->lonlat[i],
-                MIN(new_disk->centr->lonlat[i],
-                    old_ldsk->disk->centr->lonlat[i]) + tree->mmod->rad);
-      min = MAX(0.0,
-                MAX(new_disk->centr->lonlat[i],
-                    old_ldsk->disk->centr->lonlat[i]) - tree->mmod->rad);
+      /* Proba of pruning that particular lineage in the opposite move 
+       */
+      hr += LOG(1./(phydbl)(regraft_ldsk->n_next+1));
+      
+      /* Prob of selecting that prune ldsk in the opposite move. Number
+         of prune sites increases by one in case actual regraft ldsk
+         (i.e., regraft ldsk in the proposed move) has n_next = 1 
+      */
+      if(regraft_ldsk->n_next == 1) n_prune_disks += 1;
+      if(prune_ldsk->n_next == 2) n_prune_disks   -= 1;
+      hr += LOG(1./n_prune_disks);
 
-      if(max < min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-      new_ldsk->coord->lonlat[i] = Uni()*(max - min) + min;
-      hr += LOG(max - min);      
-    }
 
-  hr -= LOG(n_valid_disks+1);
-  hr += LOG(-T);
+      /* Prune and regraft */
+      n_hits = PHYREX_Total_Number_Of_Hit_Disks(tree) - PHYREX_Total_Number_Of_Coal_Disks(tree);
+      dt = FABS(prune_daughter_ldsk->disk->time - prune_ldsk->disk->time);
+      cur_path_len = PHYREX_Path_Len(prune_daughter_ldsk,prune_ldsk)-2;
+      rate = (phydbl)(n_hits - cur_path_len)/(sizeT - dt);
+      
+      hr += PHYREX_Path_Logdensity(prune_daughter_ldsk,prune_ldsk,rate*dt,1.0*tree->mmod->rad,tree);
+      
+      dt = FABS(prune_daughter_ldsk->disk->time - regraft_ldsk->disk->time);
+      new_path = PHYREX_Generate_Path(prune_daughter_ldsk,regraft_ldsk,rate*dt,1.0*tree->mmod->rad,tree);
+      cur_path = PHYREX_Remove_Path(prune_daughter_ldsk,prune_ldsk,&cur_pos,tree);
+      PHYREX_Insert_Path(prune_daughter_ldsk,regraft_ldsk,new_path,regraft_ldsk->n_next,tree);
+      
+      hr -= PHYREX_Path_Logdensity(prune_daughter_ldsk,regraft_ldsk,rate*dt,1.0*tree->mmod->rad,tree);
+      
+      /* prune_daughter_ldsk->prev = regraft_ldsk; */
+      /* PHYREX_Remove_Lindisk_Next(prune_ldsk,prune_daughter_ldsk); */
+      /* PHYREX_Random_Insert_Ldsk_In_Next_List(prune_daughter_ldsk,regraft_ldsk); */
+      
+      PHYREX_Ldsk_To_Tree(tree);
+      Update_Ancestors(tree->n_root,tree->n_root->v[2],tree);
+      Update_Ancestors(tree->n_root,tree->n_root->v[1],tree);
+      RATES_Fill_Lca_Table(tree);
+      RATES_Update_Cur_Bl(tree);
 
-  /* Random increase of the value of lambda */
-  tree->mmod->lbda = Uni()*.2 + cur_lbda;
-  if(tree->mmod->lbda > tree->mmod->max_lbda) tree->mmod->lbda = tree->mmod->max_lbda;
-  if(tree->mmod->lbda < tree->mmod->min_lbda) tree->mmod->lbda = tree->mmod->min_lbda;
 
-  new_lnL = MIGREP_Lk(tree);
-  ratio = (new_lnL - cur_lnL);
-  ratio += hr;
+      /* new_glnL = PHYREX_Lk(tree); */
 
-  /* gtk_widget_queue_draw(tree->draw_area); */
-  /* sleep(3); */
+      new_glnL += PHYREX_Lk_Range(prune_daughter_ldsk->disk->prev,dum_dum_disk,tree);
+      tree->mmod->c_lnL = new_glnL;
 
-  if(new_lnL < UNLIKELY + 0.1) 
-    {
-      PhyML_Printf("\n. rad: %f %d %d %d new_lnL: %f",
-                   tree->mmod->rad,
-                   MIGREP_Is_In_Disk(young_ldsk->coord,new_disk),
-                   MIGREP_Is_In_Disk(new_ldsk->coord,new_disk),
-                   MIGREP_Is_In_Disk(old_ldsk->coord,new_disk),
-                   new_lnL);
-      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+      if(tree->mcmc->use_data == YES) new_alnL = Lk(NULL,tree);
+      
+      ratio += (new_alnL - cur_alnL);
+      ratio += (new_glnL - cur_glnL);
+      ratio += hr;
+            
+      ratio = EXP(ratio);
+      alpha = MIN(1.,ratio);
+      
+      /* Always accept move */
+      if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+      
+      /* printf("\n. %3d %3d alpha:%12f %3d",prune_ldsk->n_next+1,regraft_ldsk->n_next-1,alpha,new_n_coal); */
+      
+      u = Uni();
+      
+      if(u > alpha) /* Reject */
+        {
+          new_path = PHYREX_Remove_Path(prune_daughter_ldsk,regraft_ldsk,&new_pos,tree);
+          
+          ldsk = new_path;
+          while(ldsk)
+            {
+              Free_Disk(ldsk->disk);
+              ldsk_dum = ldsk;
+              ldsk = ldsk->prev;
+              Free_Ldisk(ldsk_dum);
+            }
+          
+          PHYREX_Insert_Path(prune_daughter_ldsk,prune_ldsk,cur_path,cur_pos,tree);
+          
+          /* prune_daughter_ldsk->prev = prune_ldsk; */
+          /* PHYREX_Remove_Lindisk_Next(regraft_ldsk,prune_daughter_ldsk); */
+          /* PHYREX_Insert_Ldsk_In_Next_List(prune_daughter_ldsk,prune_next_num,prune_ldsk); */
+          
+          PHYREX_Ldsk_To_Tree(tree);
+          Update_Ancestors(tree->n_root,tree->n_root->v[2],tree);
+          Update_Ancestors(tree->n_root,tree->n_root->v[1],tree);
+          RATES_Fill_Lca_Table(tree);
+          RATES_Update_Cur_Bl(tree);
+          
+
+          if(tree->mmod->safe_phyrex == YES)
+            {
+              if(tree->mcmc->use_data == YES)
+                {
+                  new_alnL = Lk(NULL,tree);
+                  if(Are_Equal(new_alnL,cur_alnL,1.E-3) == NO)
+                    {
+                      PhyML_Printf("\n== new_alnL: %f cur_alnL: %f",new_alnL,cur_alnL);
+                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                    }
+                }
+              
+              new_glnL = PHYREX_Lk(tree);
+              if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          else
+            {
+              PHYREX_Update_Lindisk_List(tree);
+              tree->c_lnL       = cur_alnL;
+              tree->mmod->c_lnL = cur_glnL;          
+            }
+        }
+      else
+        {
+          ldsk = cur_path;
+          while(ldsk)
+            {
+              Free_Disk(ldsk->disk);
+              ldsk_dum = ldsk;
+              ldsk = ldsk->prev;
+              Free_Ldisk(ldsk_dum);
+            }
+          
+          tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_spr]++;
+        }
     }
-  ratio = EXP(ratio);
-  alpha = MIN(1.,ratio);
+}
+#endif
+  
+/*////////////////////////////////////////////////////////////l
+////////////////////////////////////////////////////////////*/
 
-  /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+#ifdef PHYREX
+void MCMC_PHYREX_Simulate_Backward(t_tree *tree)
+{
+  phydbl u,alpha,ratio,hr,T,t;
+  phydbl cur_alnL, new_alnL;
+  phydbl cur_glnL, new_glnL;
+  t_dsk  *disk,*bkp_disk,*target_disk;
+  t_ldsk **bkp_ldsk;
+  int i;
 
-  u = Uni();
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_sim]++;
+
+  disk        = NULL;
+  bkp_disk    = NULL;
+  target_disk = NULL;
+  bkp_ldsk    = NULL;
+
+  new_alnL      = tree->c_lnL;
+  cur_alnL      = tree->c_lnL;
+  cur_glnL      = tree->mmod->c_lnL;
+  new_glnL      = tree->mmod->c_lnL;
+  hr            = 0.0;
+  ratio         = 0.0;
+  T             = 0.0;
+  t             = 0.0;
+
+  /* Chop off the tree at time t and simulate upwards from here */
+  T = PHYREX_Tree_Height(tree);
+  t = Uni()*T;
   
-  /* printf("\n+ Insert hit %s new_lnL: %f [%f] hr: %f u: %f alpha: %f", */
-  /*        new_disk->id, */
-  /*        new_lnL, */
-  /*        cur_lnL,hr, */
-  /*        u,alpha); */
+  disk = tree->disk->prev;
+  while(disk && disk->time > t) disk = disk->prev;
+  target_disk = disk->next;
 
-  if(u > alpha) /* Reject */
-    {
-      /* printf("+ Reject"); */
+  hr -= LOG(FABS((target_disk->prev->time - target_disk->time)/T));
 
-      tree->mmod->lbda = cur_lbda;
+  bkp_disk = target_disk->prev;
 
-      MIGREP_Remove_Disk(new_disk);      
-      Free_Disk(new_disk);
-      Free_Ldisk(new_ldsk);
+  bkp_ldsk = (t_ldsk **)mCalloc(target_disk->n_ldsk_a,sizeof(t_ldsk *));
+  For(i,target_disk->n_ldsk_a) bkp_ldsk[i] = target_disk->ldsk_a[i]->prev;
 
-      old_ldsk->next[dir_old_young] = young_ldsk;
-      young_ldsk->prev = old_ldsk;
+  PHYREX_Simulate_Backward_Core(NO,target_disk,tree);
+  
+  T =  PHYREX_Tree_Height(tree);
+  hr += LOG(FABS((target_disk->prev->time - target_disk->time)/T));
+
+  if(tree->mcmc->use_data == YES) new_alnL = Lk(NULL,tree);
+  ratio += (new_alnL - cur_alnL);
+  ratio += hr;
+  
+  ratio = EXP(ratio);
+  alpha = MIN(1.,ratio);
+    
+ /* Always accept move */
+  if(tree->mcmc->always_yes == YES) alpha = 1.0;
+    
+  u = Uni();
+        
+  if(u > alpha) /* Reject */
+    {
+      disk = target_disk->prev;
+      while(disk->prev)
+        {
+          disk = disk->prev;
+          if(disk->next->ldsk != NULL) Free_Ldisk(disk->next->ldsk);
+          Free_Disk(disk->next);
+        }
 
-      /* tree->mmod->c_lnL = cur_lnL; */
+      /* Root */
+      Free_Ldisk(disk->ldsk);
+      Free_Disk(disk);
 
-      new_lnL = MIGREP_Lk(tree);      
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      target_disk->prev = bkp_disk;
+      For(i,target_disk->n_ldsk_a) target_disk->ldsk_a[i]->prev = bkp_ldsk[i];
+      
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          if(tree->mcmc->use_data == YES)
+            {
+              new_alnL = Lk(NULL,tree);
+              if(Are_Equal(new_alnL,cur_alnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_alnL: %f cur_alnL: %f",new_alnL,cur_alnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          
+          new_glnL = PHYREX_Lk(tree);
+          
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n. new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          PHYREX_Lk(tree);
+          tree->c_lnL       = cur_alnL;
+          tree->mmod->c_lnL = cur_glnL;
         }
     }
   else
     {
-      /* printf("+ Accept"); */
-      /* if(indel > 0) printf("\n. Accept"); */
+      /* Accept */
+      disk = bkp_disk;
+      while(disk->prev)
+        {
+          disk = disk->prev;
+          if(disk->next->ldsk != NULL) Free_Ldisk(disk->next->ldsk);
+          Free_Disk(disk->next);
+        }
+      
+      /* Root */
+      Free_Ldisk(disk->ldsk);
+      Free_Disk(disk);
+
+      /* Likelihood needs to be updated */
+      PHYREX_Lk(tree);
+
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_sim]++;
     }
+  
+
+  Free(bkp_ldsk);
 }
 #endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
-/* Remove a disk with a lineage displacement */
-#ifdef MIGREP
-void MCMC_MIGREP_Delete_Hit(t_tree *tree)
+
+
+#ifdef PHYREX
+void MCMC_PHYREX_Simulate_Backward_Plus(t_tree *tree)
 {
-  phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr,T, cur_lbda;
-  phydbl max,min;
-  t_dsk  *disk,*target_disk,**valid_disks;
-  t_ldsk *target_ldsk,*old_ldsk,*young_ldsk;
-  int i,block,n_valid_disks,dir_old_young;
+  phydbl u,alpha,ratio,hr,T,t;
+  phydbl cur_alnL, new_alnL;
+  phydbl cur_glnL_do, new_glnL_do;
+  phydbl cur_glnL, new_glnL;
+  phydbl cur_lbda, new_lbda;
+  phydbl cur_rad, new_rad;
+  phydbl cur_mu, new_mu;
+  t_dsk  *disk,*bkp_disk,*target_disk;
+  t_ldsk **bkp_ldsk;
+  int i;
+
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_sim_plus]++;
 
   disk          = NULL;
-  new_lnL       = UNLIKELY;
-  cur_lnL       = tree->mmod->c_lnL;
+  bkp_disk      = NULL;
+  target_disk   = NULL;
+  bkp_ldsk      = NULL;
+  new_alnL      = tree->c_lnL;
+  cur_alnL      = tree->c_lnL;
+  cur_glnL      = tree->mmod->c_lnL;
+  new_glnL      = tree->mmod->c_lnL;
+  cur_glnL_do   = UNLIKELY;
+  new_glnL_do   = UNLIKELY;
   hr            = 0.0;
   ratio         = 0.0;
-  block         = 100;
+  T             = 0.0;
+  t             = 0.0;
   cur_lbda      = tree->mmod->lbda;
+  cur_rad       = tree->mmod->rad;
+  cur_mu        = tree->mmod->mu;
+  new_lbda      = cur_lbda;
+  new_rad       = cur_rad;
+  new_mu        = cur_mu;
 
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  T = disk->time;
-
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  disk = tree->disk->prev;
-  n_valid_disks = 0;
-  do
-    {
-      /* Include only disks with displacement that are not coalescent events */
-      if(disk->ldsk != NULL && disk->ldsk->n_next == 1) 
-        {
-          if(!n_valid_disks) valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
-          else if(!(n_valid_disks%block)) valid_disks = (t_dsk **)mRealloc(valid_disks,n_valid_disks+block,sizeof(t_dsk *));
-          valid_disks[n_valid_disks] = disk;
-          n_valid_disks++;
-        }
-      disk = disk->prev;
-    }
-  while(disk->prev);
-
-  if(!n_valid_disks) return;
-  
-  /* Uniform selection of a disk where no coalescent nor 'hit' occurred */
-  i = Rand_Int(0,n_valid_disks-1);
-  target_disk = valid_disks[i];
-  Free(valid_disks);
-  
-  target_ldsk = target_disk->ldsk;
   
-  if(!target_ldsk) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  if(target_ldsk->n_next != 1) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  new_lbda = cur_lbda * EXP(0.2*(Uni()-.5));
+  hr += LOG(new_lbda/cur_lbda);
 
-  old_ldsk   = target_ldsk->prev;
-  young_ldsk = target_ldsk->next[0];
+  new_mu = cur_mu * EXP(0.2*(Uni()-.5));
+  hr += LOG(new_mu/cur_mu);
 
-  /* Bail out if departure point is not within disk of arrival, in */
-  /* which case the likelihood after removing target_disk is zero */
-  if(MIGREP_Is_In_Disk(young_ldsk->coord,old_ldsk->disk) == NO) return;
+  new_rad = cur_rad * EXP(0.2*(Uni()-.5));
+  hr += LOG(new_rad/cur_rad);
 
-  dir_old_young = MIGREP_Get_Next_Direction(young_ldsk,old_ldsk);
+  if(new_lbda < tree->mmod->min_lbda) return;
+  if(new_lbda > tree->mmod->max_lbda) return;
+  if(new_mu   < tree->mmod->min_mu)   return;
+  if(new_mu   > tree->mmod->max_mu)   return;
+  if(new_rad  < tree->mmod->min_rad)  return;
+  if(new_rad  > tree->mmod->max_rad)  return;
 
-  /* Part of the Hastings ratio corresponding to the probability of selecting */
-  /* one of target_disk->n_ldsk_a to be hit */ 
-  hr -= LOG(target_disk->n_ldsk_a);
 
-  /* New connections between old_ldsk and young_ldsk */
-  old_ldsk->next[dir_old_young] = young_ldsk;
-  young_ldsk->prev              = old_ldsk;
+  hr += PHYREX_LnPrior_Lbda(tree);
+  hr += PHYREX_LnPrior_Mu(tree);
+  hr += PHYREX_LnPrior_Radius(tree);
 
-  /* Remove target disk */
-  MIGREP_Remove_Disk(target_disk);
+  /* Chop off the tree at time t and simulate upwards from here */
+  T = PHYREX_Tree_Height(tree);
+  t = Uni()*T;
   
-  /* Density for position of the center of target_disk */
-  For(i,tree->mmod->n_dim)
-    {
-      max = MIN(tree->mmod->lim->lonlat[i],
-                MIN(old_ldsk->disk->centr->lonlat[i]+2.*tree->mmod->rad,
-                    young_ldsk->coord->lonlat[i]+tree->mmod->rad));
-      min = MAX(0.0,
-                MAX(old_ldsk->disk->centr->lonlat[i]-2.*tree->mmod->rad,
-                    young_ldsk->coord->lonlat[i]-tree->mmod->rad));
-      
-      /* max = tree->mmod->lim->lonlat[i]; */
-      /* min = 0.0; */
+  disk = tree->disk->prev;
+  while(disk && disk->time > t) disk = disk->prev;
+  target_disk = disk->next;
 
-      if(max < min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-      hr -= LOG(max - min);
-    }
+  hr -= LOG(FABS((target_disk->prev->time - target_disk->time)/T));
 
-  /* Density for position of the displaced ldsk */
-  For(i,tree->mmod->n_dim)
-    {
-      max = MIN(tree->mmod->lim->lonlat[i],
-                MIN(target_disk->centr->lonlat[i],
-                    old_ldsk->disk->centr->lonlat[i]) + tree->mmod->rad);
-      min = MAX(0.0,
-                MAX(target_disk->centr->lonlat[i],
-                    old_ldsk->disk->centr->lonlat[i]) - tree->mmod->rad);
+  bkp_disk = target_disk->prev;
 
-      /* max = MIN(tree->mmod->lim->lonlat[i], */
-      /*           target_disk->centr->lonlat[i] + tree->mmod->rad); */
-      /* min = MAX(0.0, */
-      /*           target_disk->centr->lonlat[i] - tree->mmod->rad); */
+  bkp_ldsk = (t_ldsk **)mCalloc(target_disk->n_ldsk_a,sizeof(t_ldsk *));
+  For(i,target_disk->n_ldsk_a) bkp_ldsk[i] = target_disk->ldsk_a[i]->prev;
 
-      if(max < min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-      hr -= LOG(max - min);      
-    }
+  cur_glnL_do = PHYREX_Lk_Range(tree->disk->prev,target_disk,tree);
 
-  hr += LOG(n_valid_disks);
-  hr -= LOG(-T);
-  
-  /* Random decrease of the value of lambda */
-  tree->mmod->lbda = Uni()*.2 + (cur_lbda-.2);
-  if(tree->mmod->lbda > tree->mmod->max_lbda) tree->mmod->lbda = tree->mmod->max_lbda;
-  if(tree->mmod->lbda < tree->mmod->min_lbda) tree->mmod->lbda = tree->mmod->min_lbda;
+  tree->mmod->lbda = new_lbda;
+  tree->mmod->mu   = new_mu;
+  tree->mmod->rad  = new_rad;
 
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+  new_glnL_do = PHYREX_Lk_Range(tree->disk->prev,target_disk,tree);
 
-  /* gtk_widget_queue_draw(tree->draw_area); */
-  /* sleep(3); */
+  hr -= PHYREX_LnPrior_Lbda(tree);
+  hr -= PHYREX_LnPrior_Mu(tree);
+  hr -= PHYREX_LnPrior_Radius(tree);
 
-  if(new_lnL < UNLIKELY + 0.1) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  PHYREX_Simulate_Backward_Core(NO,target_disk,tree);
+  
+  T =  PHYREX_Tree_Height(tree);
+  hr += LOG(FABS((target_disk->prev->time - target_disk->time)/T));
 
+  if(tree->mcmc->use_data == YES) new_alnL = Lk(NULL,tree);
+  ratio += (new_alnL - cur_alnL);
+  ratio += (new_glnL_do - cur_glnL_do);
+  ratio += hr;
+  
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
-  
-  /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
-
+    
+ /* Always accept move */
+  if(tree->mcmc->always_yes == YES) alpha = 1.0;
+    
   u = Uni();
-  
-  /* printf("\n- Delete hit %s new_lnL: %f [%f] hr: %f u:%f alpha: %f", */
-  /*        target_disk->id, */
-  /*        new_lnL,cur_lnL,hr,u,alpha); */
-
+        
   if(u > alpha) /* Reject */
     {
-      /* printf("- Reject"); */
-
       tree->mmod->lbda = cur_lbda;
+      tree->mmod->mu   = cur_mu;
+      tree->mmod->rad  = cur_rad;
 
-      MIGREP_Insert_Disk(target_disk);
-      
-      old_ldsk->next[dir_old_young] = target_ldsk;
-      young_ldsk->prev              = target_ldsk;
 
-      /* tree->mmod->c_lnL = cur_lnL; */
+      disk = target_disk->prev;
+      while(disk->prev)
+        {
+          disk = disk->prev;
+          if(disk->next->ldsk != NULL) Free_Ldisk(disk->next->ldsk);
+          Free_Disk(disk->next);
+        }
+
+      /* Root */
+      Free_Ldisk(disk->ldsk);
+      Free_Disk(disk);
 
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      target_disk->prev = bkp_disk;
+      For(i,target_disk->n_ldsk_a) target_disk->ldsk_a[i]->prev = bkp_ldsk[i];
+      
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          if(tree->mcmc->use_data == YES)
+            {
+              new_alnL = Lk(NULL,tree);
+              if(Are_Equal(new_alnL,cur_alnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_alnL: %f cur_alnL: %f",new_alnL,cur_alnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          
+          new_glnL = PHYREX_Lk(tree);
+          
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n. new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+          PHYREX_Lk(tree);
+          tree->c_lnL = cur_alnL;
         }
     }
   else
     {
-      Free_Disk(target_disk);
-      Free_Ldisk(target_ldsk);
-      /* printf("- Accept"); */
+      /* Accept */
+      disk = bkp_disk;
+      while(disk->prev)
+        {
+          disk = disk->prev;
+          if(disk->next->ldsk != NULL) Free_Ldisk(disk->next->ldsk);
+          Free_Disk(disk->next);
+        }
+      
+      /* Root */
+      Free_Ldisk(disk->ldsk);
+      Free_Disk(disk);
+
+      /* Likelihood needs to be updated */
+      PHYREX_Lk(tree);
+
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_sim_plus]++;
     }
+  
+
+  Free(bkp_ldsk);
 }
 #endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
 
-#ifdef MIGREP
-void MCMC_MIGREP_Shift_Ldsk_Path(t_tree *tree)
+#ifdef PHYREX
+void MCMC_PHYREX_Lineage_Traj(t_tree *tree)
 {
-  phydbl u,alpha,ratio;
-  phydbl cur_lnL, new_lnL, hr;
-  phydbl *max_coord,*min_coord;
-  t_dsk  *target_disk,**valid_disks,*disk;
-  t_ldsk *ldsk;
-  t_geo_coord **bkup_coord;
-  int i,block,n_valid_disks,n_coord_bkup;
-
-  new_lnL        = UNLIKELY;
-  cur_lnL        = tree->mmod->c_lnL;
-  hr             = 0.0;
-  ratio          = 0.0;
-  block          = 100;
-  valid_disks    = NULL;
-  bkup_coord     = NULL;
-
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  phydbl u,alpha,ratio,hr;
+  phydbl cur_glnL, new_glnL;
+  t_dsk  *disk,**valid_disks;
+  t_ldsk *start_ldsk,*end_ldsk,*cur_path,*new_path,*ldsk,*ldsk_dum;
+  int j,block,n_valid_disks;
+  phydbl rate,dt,sizeT;
+  int n_hits,n_iter,cur_path_len;
+  int pos,*permut;
+
+  n_iter      = 0;
+  valid_disks = NULL;
+  disk        = NULL;
+  new_glnL    = tree->mmod->c_lnL;
+  cur_glnL    = tree->mmod->c_lnL;
+  hr          = 0.0;
+  ratio       = 0.0;
+  block       = 100;
+  pos         = -1;
+  
+      
+  /* Get a ldsk from which you can prune a lineage */
   disk = tree->disk->prev;
   n_valid_disks = 0;
   do
     {
-      /* Include disks with displacement or coalescent events */
-      if(disk->ldsk != NULL) 
+      if(disk->ldsk && disk->ldsk->prev && disk->ldsk->n_next > 1)
+        /* if(disk->ldsk) */
         {
-          if(!n_valid_disks)              valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+          if(!n_valid_disks) valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
           else if(!(n_valid_disks%block)) valid_disks = (t_dsk **)mRealloc(valid_disks,n_valid_disks+block,sizeof(t_dsk *));
           valid_disks[n_valid_disks] = disk;
           n_valid_disks++;
         }
       disk = disk->prev;
     }
-  while(disk->prev);
-
-  if(!n_valid_disks) return;
+  while(disk);
+  
+  if(!n_valid_disks) return;
+      
+  permut = Permutate(n_valid_disks);
+  n_iter = Rand_Int(1,1+(int)(n_valid_disks/5));
+  
+  For(j,n_iter)
+    {
+      tree->mcmc->run_move[tree->mcmc->num_move_phyrex_traj]++;
+
+      new_glnL    = tree->mmod->c_lnL;
+      cur_glnL    = tree->mmod->c_lnL;
+      hr          = 0.0;
+      ratio       = 0.0;
+
+      start_ldsk = valid_disks[permut[j]]->ldsk;
+      assert(start_ldsk != NULL);
+
+      end_ldsk = start_ldsk->prev;
+      while(end_ldsk->n_next < 2) end_ldsk = end_ldsk->prev;
+
+      assert(end_ldsk != NULL); 
+
+      new_glnL = cur_glnL;
+      new_glnL -= PHYREX_Lk_Range(start_ldsk->disk->prev,end_ldsk->disk,tree);
+      
+      n_hits       = PHYREX_Total_Number_Of_Hit_Disks(tree) - PHYREX_Total_Number_Of_Coal_Disks(tree);
+      sizeT        = PHYREX_Time_Tree_Length(tree);
+      dt           = FABS(start_ldsk->disk->time - end_ldsk->disk->time);
+      cur_path_len = PHYREX_Path_Len(start_ldsk,end_ldsk)-2;
+      rate         = (phydbl)(n_hits - cur_path_len)/(sizeT - dt);
+      
+      hr += PHYREX_Path_Logdensity(start_ldsk,end_ldsk,rate*dt,1.*tree->mmod->rad,tree);
+      
+      new_path = PHYREX_Generate_Path(start_ldsk,end_ldsk,rate*dt,1.*tree->mmod->rad,tree);
+      cur_path = PHYREX_Remove_Path(start_ldsk,end_ldsk,&pos,tree);
+      PHYREX_Insert_Path(start_ldsk,end_ldsk,new_path,pos,tree);
+      
+      hr -= PHYREX_Path_Logdensity(start_ldsk,end_ldsk,rate*dt,1.*tree->mmod->rad,tree);
+      
+      /* new_glnL = PHYREX_Lk(tree); */
+
+      new_glnL += PHYREX_Lk_Range(start_ldsk->disk->prev,end_ldsk->disk,tree);
+      tree->mmod->c_lnL = new_glnL;
+
+      ratio += (new_glnL - cur_glnL);
+      ratio += hr;
+            
+      ratio = EXP(ratio);
+      alpha = MIN(1.,ratio);
+      
+      if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+            
+      /* PhyML_Printf("\n= Traj. new_alnL:%12f cur_alnL:%12f hr:%12f alpha:%12f",new_alnL,cur_alnL,hr,alpha); */
+
+      u = Uni();
+      
+      if(u > alpha) /* Reject */
+        {
+          new_path = PHYREX_Remove_Path(start_ldsk,end_ldsk,&pos,tree);
+          
+          ldsk = new_path;
+          while(ldsk) 
+            {
+              Free_Disk(ldsk->disk);
+              ldsk_dum = ldsk;
+              ldsk = ldsk->prev;
+              Free_Ldisk(ldsk_dum);
+            }
+          
+          PHYREX_Insert_Path(start_ldsk,end_ldsk,cur_path,pos,tree);
+          
+          if(tree->mmod->safe_phyrex == YES)
+            {
+              new_glnL = PHYREX_Lk(tree);
+              
+              if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          else
+            {
+              PHYREX_Update_Lindisk_List(tree);
+              tree->mmod->c_lnL = cur_glnL;
+            }
+        }
+      else
+        {
+          ldsk = cur_path;
+          while(ldsk) 
+            {
+              Free_Disk(ldsk->disk);
+              ldsk_dum = ldsk;
+              ldsk = ldsk->prev;
+              Free_Ldisk(ldsk_dum);
+            }      
+          
+          tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_traj]++;
+        }      
+    }
   
-  /* Uniform selection of a disk where no coalescent nor 'hit' occurred */
-  i = Rand_Int(0,n_valid_disks-1);
-  target_disk = valid_disks[i];
   Free(valid_disks);
+  Free(permut);
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+#ifdef PHYREX
+void MCMC_PHYREX_Lbda_Times(t_tree *tree)
+{
+  phydbl u,alpha,ratio,hr;
+  phydbl cur_glnL, new_glnL;
+  phydbl cur_alnL, new_alnL;
+  phydbl cur_lbda, new_lbda;
+  phydbl *cur_times,dt;
+  t_dsk  *disk;
+  int n_inter,i;
+
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_lbda_times]++;
+
+  dt          = 0.0;
+  hr          = 0.0;
+  ratio       = 0.0;
+  new_glnL    = tree->mmod->c_lnL;
+  cur_glnL    = tree->mmod->c_lnL;
+  new_alnL    = tree->c_lnL;
+  cur_alnL    = tree->c_lnL;
+  cur_lbda    = tree->mmod->lbda;
+  new_lbda    = cur_lbda;
+
+  n_inter = PHYREX_Total_Number_Of_Intervals(tree);
+
+  cur_times = (phydbl *)mCalloc(n_inter,sizeof(phydbl));
+
+  disk = tree->disk;
+  while(disk->prev != NULL) disk = disk->prev;
+  hr += (n_inter)*LOG(tree->mmod->lbda) + tree->mmod->lbda*disk->time;
+
+  new_glnL  = cur_glnL;
+  new_glnL -= (n_inter)*LOG(tree->mmod->lbda) + tree->mmod->lbda*disk->time;
+  new_lbda = cur_lbda * EXP(0.3*(Uni()-.5));
+  hr += LOG(new_lbda/cur_lbda);
+
+  tree->mmod->lbda = new_lbda;
+
+  i = 0;
+  disk = tree->disk->prev;  
+  do
+    {
+      cur_times[i++] = disk->time;
+      dt = Rexp(tree->mmod->lbda);
+      disk->time = disk->next->time - dt;
+      disk = disk->prev;
+    }
+  while(disk != NULL);
+
+  disk = tree->disk;
+  while(disk->prev != NULL) disk = disk->prev;
+  hr -= n_inter*LOG(tree->mmod->lbda) + tree->mmod->lbda*disk->time;
+  
+  new_glnL += n_inter*LOG(tree->mmod->lbda) + tree->mmod->lbda*disk->time;;
+  tree->mmod->c_lnL = new_glnL;
+
+  if(tree->mcmc->use_data == YES) new_alnL = Lk(NULL,tree);
     
-  ldsk = target_disk->ldsk;
+  ratio += (new_glnL - cur_glnL);
+  ratio += (new_alnL - cur_alnL);
+  ratio += hr;
+            
+  ratio = EXP(ratio);
+  alpha = MIN(1.,ratio);
+
+  u = Uni();
+
+  if(u > alpha) /* Reject */
+    {
+      tree->mmod->lbda = cur_lbda;
+
+      i = 0;
+      disk = tree->disk->prev;
+      do
+        {
+          disk->time = cur_times[i++];
+          disk = disk->prev;
+        }
+      while(disk != NULL);
+      
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          if(tree->mcmc->use_data == YES)
+            {
+              new_alnL = Lk(NULL,tree);
+              
+              if(Are_Equal(new_alnL,cur_alnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== new_alnL: %f cur_alnL: %f",new_alnL,cur_alnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          
+          new_glnL = PHYREX_Lk(tree);
+          
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
+        {
+          tree->c_lnL       = cur_alnL;
+          tree->mmod->c_lnL = cur_glnL;
+        }
+    }
+  else
+    {
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_lbda_times]++;
+    }
+
+  Free(cur_times);
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+#ifdef PHYREX
+void MCMC_PHYREX_Disk_Multi(t_tree *tree)
+{
+  phydbl u,alpha,ratio;
+  phydbl cur_glnL, new_glnL, hr;
+  t_dsk  *disk,**target_disk,**all_disks;
+  int i,j,block,n_all_disks,n_move_disks,*permut;
+  int err;
+
+  disk          = NULL;
+  new_glnL      = tree->mmod->c_lnL;
+  cur_glnL      = tree->mmod->c_lnL;
+  hr            = 0.0;
+  ratio         = 0.0;
+  block         = 100;
+  all_disks     = NULL;
+
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_disk_multi]++;
+
+  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  disk = tree->disk->prev;
+  n_all_disks = 0;
+  do
+    {
+      if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+      else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
+      all_disks[n_all_disks] = disk;
+      n_all_disks++;
+      disk = disk->prev;
+    }
+  while(disk);
+
+  if(!n_all_disks) return;
 
-  n_coord_bkup = 0;
-  while(ldsk->prev)
+  target_disk = (t_dsk **)mCalloc(n_all_disks,sizeof(t_dsk *));
+  
+  n_move_disks = Rand_Int(1,1+(int)(n_all_disks/5));
+  /* n_move_disks = n_all_disks; */
+
+  permut = Permutate(n_all_disks);
+
+  For(i,n_move_disks)
     {
-      if(!n_coord_bkup)              bkup_coord = (t_geo_coord **)mCalloc(block,sizeof(t_geo_coord *));
-      else if(!(n_coord_bkup%block)) bkup_coord = (t_geo_coord **)mRealloc(bkup_coord,n_coord_bkup+block,sizeof(t_geo_coord *));
+      target_disk[i] = all_disks[permut[i]];
+  
+      assert(target_disk[i]);
+
+      PHYREX_Store_Geo_Coord(target_disk[i]->centr);
       
-      bkup_coord[n_coord_bkup] = MIGREP_Copy_Geo_Coord(ldsk->coord);      
-      n_coord_bkup++;
+      if(target_disk[i]->ldsk != NULL)
+        {
+          For(j,tree->mmod->n_dim)
+            {
+              target_disk[i]->centr->lonlat[j] = 
+                Rnorm_Trunc(target_disk[i]->centr->lonlat[j],
+                            1.*tree->mmod->rad,
+                            0.0,
+                            tree->mmod->lim->lonlat[j],&err);
+              
+              hr -= Log_Dnorm_Trunc(target_disk[i]->centr->lonlat[j],
+                                    target_disk[i]->centr->cpy->lonlat[j],
+                                    1.*tree->mmod->rad,                                                         
+                                    0.0,
+                                    tree->mmod->lim->lonlat[j],&err);
+              
+              hr += Log_Dnorm_Trunc(target_disk[i]->centr->cpy->lonlat[j],
+                                    target_disk[i]->centr->lonlat[j],
+                                    1.*tree->mmod->rad,
+                                    0.0,
+                                    tree->mmod->lim->lonlat[j],&err);
+            }
+        }
+      else
+        {
+          For(j,tree->mmod->n_dim)
+            {
+              target_disk[i]->centr->lonlat[j] = 
+                Rnorm_Trunc(target_disk[i]->centr->lonlat[j],
+                            1.*tree->mmod->rad,
+                            0.0,
+                            tree->mmod->lim->lonlat[j],&err);
+              
+              hr -= Log_Dnorm_Trunc(target_disk[i]->centr->lonlat[j],
+                                    target_disk[i]->centr->cpy->lonlat[j],
+                                    1.*tree->mmod->rad,                                                         
+                                    0.0,
+                                    tree->mmod->lim->lonlat[j],&err);
+              
+              hr += Log_Dnorm_Trunc(target_disk[i]->centr->cpy->lonlat[j],
+                                    target_disk[i]->centr->lonlat[j],
+                                    1.*tree->mmod->rad,
+                                    0.0,
+                                    tree->mmod->lim->lonlat[j],&err);
+            }
+        }
+    }
+  
+  Free(permut);
+
+  new_glnL = PHYREX_Lk(tree);
+  tree->mmod->c_lnL = new_glnL;
+
+  ratio += (new_glnL - cur_glnL);
+  ratio += hr;
+  
+  ratio = EXP(ratio);
+  alpha = MIN(1.,ratio);
+  
+  /* Always accept move */
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+
+  u = Uni();
+  
+  /* printf("\n- Delete new_glnL: %f [%f] hr: %f u:%f alpha: %f",new_glnL,cur_glnL,hr,u,alpha); */
+
+  if(u > alpha) /* Reject */
+    {
+      /* printf("- Reject"); */
       
-      MIGREP_Get_Min_Max_Ldsk_Given_Disk(ldsk,&min_coord,&max_coord,tree);
+      For(i,n_move_disks) PHYREX_Restore_Geo_Coord(target_disk[i]->centr);
       
-      For(i,tree->mmod->n_dim) 
-        ldsk->coord->lonlat[i] = Uni() * (max_coord[i] - min_coord[i]) + min_coord[i];
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          new_glnL = PHYREX_Lk(tree);
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n. new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
+        {
+          tree->mmod->c_lnL = cur_glnL;
+        }
+    }
+  else
+    {
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_disk_multi]++;
+    }
+
+
+  Free(all_disks);
+  Free(target_disk);
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Move ldsk on landscape */ 
+#ifdef PHYREX
+void MCMC_PHYREX_Ldsk_Multi(t_tree *tree)
+{
+  phydbl u,alpha,ratio;
+  phydbl cur_glnL, new_glnL, hr, c, o, f;
+  t_dsk  *disk,**target_disk,**all_disks;
+  int i,j,block,n_all_disks,n_move_ldsk,*permut;
+  int err;
 
-      Free(min_coord);
-      Free(max_coord);
+  disk          = NULL;
+  new_glnL      = tree->mmod->c_lnL;
+  cur_glnL      = tree->mmod->c_lnL;
+  hr            = 0.0;
+  ratio         = 0.0;
+  block         = 100;
+  all_disks     = NULL;
+  o             = -1.;
+  c             = -1.;
+  f             = -1.;
+
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_ldsk_multi]++;
 
-      ldsk = ldsk->prev;
+  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  disk = tree->disk->prev;
+  n_all_disks = 0;
+  do
+    {
+      if(disk->ldsk != NULL)
+        {
+          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
+          all_disks[n_all_disks] = disk;
+          n_all_disks++;
+        }
+      disk = disk->prev;
     }
+  while(disk);
+
+  if(!n_all_disks) return;
   
-  new_lnL = MIGREP_Lk(tree);
-  ratio += (new_lnL - cur_lnL);
-  ratio += hr;
+  n_move_ldsk = Rand_Int(1,1+(int)(n_all_disks/5));
+  /* n_move_ldsk = n_all_disks; */
   
-  if(new_lnL < UNLIKELY + 0.1) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  target_disk = (t_dsk **)mCalloc(n_all_disks,sizeof(t_dsk *));
+
+  permut = Permutate(n_all_disks);
+
+  For(i,n_move_ldsk)
+    {
+      target_disk[i] = all_disks[permut[i]];
+      
+      PHYREX_Store_Geo_Coord(target_disk[i]->ldsk->coord);
+
+      For(j,tree->mmod->n_dim)
+        {
+          /* c: center; o: pos of direct ldsk ancestor */
+          c = target_disk[i]->centr->lonlat[j];
+          o = target_disk[i]->ldsk->prev ? target_disk[i]->ldsk->prev->coord->lonlat[j] : target_disk[i]->centr->lonlat[j];
+          f = target_disk[i]->ldsk->prev ? (2./3.) : (1.0);
+          
+          target_disk[i]->ldsk->coord->lonlat[j] =
+            Rnorm_Trunc((o+2.*c)/3.,
+                        1.*SQRT(f*tree->mmod->rad*tree->mmod->rad),
+                        0.0,
+                        tree->mmod->lim->lonlat[j],&err);
+          
+          
+          For(j,tree->mmod->n_dim) hr -= Log_Dnorm_Trunc(target_disk[i]->ldsk->coord->lonlat[j],
+                                                         (o+2.*c)/3.,
+                                                         1.*SQRT(f*tree->mmod->rad*tree->mmod->rad),
+                                                         0.0,
+                                                         tree->mmod->lim->lonlat[j],&err);
+          
+          For(j,tree->mmod->n_dim) hr += Log_Dnorm_Trunc(target_disk[i]->ldsk->coord->cpy->lonlat[j],
+                                                         (o+2.*c)/3.,
+                                                         1.*SQRT(f*tree->mmod->rad*tree->mmod->rad),
+                                                         0.0,
+                                                         tree->mmod->lim->lonlat[j],&err);
+        }
+    }
+
+  Free(permut);
+
+  new_glnL = PHYREX_Lk(tree);
+
+  ratio += (new_glnL - cur_glnL);
+  ratio += hr;
   
   ratio = EXP(ratio);
   alpha = MIN(1.,ratio);
   
   /* Always accept move */
-  if(tree->mcmc->always_yes == YES && new_lnL > UNLIKELY) alpha = 1.0;
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
 
   u = Uni();
   
-  /* printf("\n- Shift ldsk path %s new_lnL: %f [%f] hr: %f u:%f alpha: %f", */
-  /*        target_disk->id, */
-  /*        new_lnL,cur_lnL,hr,u,alpha); */
+  /* printf("\n- Move_ldsk %15f",new_glnL-cur_glnL); */
 
   if(u > alpha) /* Reject */
     {
       /* printf("- Reject"); */
-      ldsk = target_disk->ldsk;
-      For(i,n_coord_bkup)
+      
+      For(i,n_move_ldsk) PHYREX_Restore_Geo_Coord(target_disk[i]->ldsk->coord);
+
+      if(tree->mmod->safe_phyrex == YES)
         {
-          Free_Geo_Coord(ldsk->coord);
-          ldsk->coord = MIGREP_Copy_Geo_Coord(bkup_coord[i]);      
-          ldsk = ldsk->prev;
+          new_glnL = PHYREX_Lk(tree);
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n. new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
         }
-      
-      new_lnL = MIGREP_Lk(tree);
-      if(Are_Equal(new_lnL,cur_lnL,1.E-3) == NO) 
+      else
         {
-          PhyML_Printf("\n. new_lnL: %f cur_lnL: %f",new_lnL,cur_lnL);
-          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-        }      
+          tree->mmod->c_lnL = cur_glnL;
+        }
     }
   else
     {
-      For(i,n_coord_bkup) Free_Geo_Coord(bkup_coord[i]);
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_ldsk_multi]++;
     }
 
-  if(n_coord_bkup) Free(bkup_coord);
-
+   
+  Free(all_disks);
+  Free(target_disk);
 }
-#endif 
+#endif
 
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
+
+#ifdef PHYREX
+void MCMC_PHYREX_Ldsk_And_Disk(t_tree *tree)
+{
+  phydbl u,alpha,ratio;
+  phydbl cur_glnL, new_glnL, hr;
+  t_dsk  *disk,**target_disk,**all_disks;
+  int i,j,block,n_all_disks,n_move_ldsk,*permut;
+  int err;
+  phydbl cur_rad, new_rad;
+
+  disk          = NULL;
+  new_glnL      = tree->mmod->c_lnL;
+  cur_glnL      = tree->mmod->c_lnL;
+  hr            = 0.0;
+  ratio         = 0.0;
+  block         = 100;
+  all_disks     = NULL;
+  cur_rad       = tree->mmod->rad;
+  new_rad       = tree->mmod->rad;
+
+  tree->mcmc->run_move[tree->mcmc->num_move_phyrex_ldsk_and_disk]++;
+
+  new_rad = cur_rad * EXP(0.2*(Uni()-.5));
+  hr += LOG(new_rad/cur_rad);
+
+  if(new_rad > tree->mmod->max_rad) return;
+  if(new_rad < tree->mmod->min_rad) return;
+
+  tree->mmod->rad = new_rad;
+
+  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  disk = tree->disk->prev;
+  n_all_disks = 0;
+  do
+    {
+      if(disk->ldsk != NULL && disk->ldsk->n_next >= 1)
+        {
+          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
+          all_disks[n_all_disks] = disk;
+          n_all_disks++;
+        }
+      disk = disk->prev;
+    }
+  while(disk);
+
+  if(!n_all_disks) return;
+  
+  n_move_ldsk = Rand_Int(1,1+(int)(n_all_disks/5));
+  /* n_move_ldsk = n_all_disks; */
+  
+  target_disk = (t_dsk **)mCalloc(n_all_disks,sizeof(t_dsk *));
+
+  permut = Permutate(n_all_disks);
+
+  For(i,n_move_ldsk)
+    {
+      target_disk[i] = all_disks[permut[i]];
+      
+      PHYREX_Store_Geo_Coord(target_disk[i]->ldsk->coord);
+            
+      For(j,tree->mmod->n_dim)
+        target_disk[i]->ldsk->coord->lonlat[j] =
+        Rnorm_Trunc(target_disk[i]->centr->lonlat[j],
+                    1.*new_rad,
+                    0.0,
+                    tree->mmod->lim->lonlat[j],&err);
+      
+
+      For(j,tree->mmod->n_dim) hr -= Log_Dnorm_Trunc(target_disk[i]->ldsk->coord->lonlat[j],
+                                                     target_disk[i]->centr->lonlat[j],
+                                                     1.*new_rad,
+                                                     0.0,
+                                                     tree->mmod->lim->lonlat[j],&err);
+      
+      For(j,tree->mmod->n_dim) hr += Log_Dnorm_Trunc(target_disk[i]->ldsk->coord->cpy->lonlat[j],
+                                                     target_disk[i]->centr->lonlat[j],
+                                                     1.*cur_rad,
+                                                     0.0,
+                                                     tree->mmod->lim->lonlat[j],&err);
+    }
+
+
+  Free(permut);
+
+  new_glnL = PHYREX_Lk(tree);
+
+  ratio += (new_glnL - cur_glnL);
+  ratio += hr;
+  
+  ratio = EXP(ratio);
+  alpha = MIN(1.,ratio);
+  
+  /* Always accept move */
+  if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+
+  u = Uni();
+  
+  /* printf("\n- Move_ldsk %15f",new_glnL-cur_glnL); */
+
+  if(u > alpha) /* Reject */
+    {
+      /* printf("- Reject"); */
+      
+      tree->mmod->rad = cur_rad;
+
+      For(i,n_move_ldsk) PHYREX_Restore_Geo_Coord(target_disk[i]->ldsk->coord);
+      /* For(i,n_move_ldsk) PHYREX_Restore_Geo_Coord(target_disk[i]->centr); */
+
+      if(tree->mmod->safe_phyrex == YES)
+        {
+          new_glnL = PHYREX_Lk(tree);
+          if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+            {
+              PhyML_Printf("\n. new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+            }
+        }
+      else
+        {
+          tree->mmod->c_lnL = cur_glnL;
+        }
+    }
+  else
+    {
+      tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_ldsk_and_disk]++;
+    }
+   
+  Free(all_disks);
+  Free(target_disk);
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+#ifdef PHYREX
+void MCMC_PHYREX_Ldsk_Given_Disk(t_tree *tree)
+{
+  phydbl u,alpha,ratio,hr,o,c,f;
+  phydbl cur_glnL, new_glnL;
+  t_dsk  *disk,**all_disks;
+  int i,j,err,n_all_disks,block,n_move_ldsk,*permut;
+
+  block       = 100;
+  all_disks   = NULL;
+  n_all_disks = 0;
+  o           = -1.;
+  c           = -1.;
+  f           = -1.;
+
+  disk = tree->disk->prev;
+  do
+    {
+      if(disk->ldsk != NULL)
+        {
+          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
+          all_disks[n_all_disks] = disk;
+          n_all_disks++;
+        }
+      disk = disk->prev;
+    }
+  while(disk);
+
+  if(!n_all_disks) return;
+  
+  /* n_move_ldsk = Rand_Int(1,1+(int)(n_all_disks/5)); */
+  n_move_ldsk = n_all_disks;
+  
+  permut = Permutate(n_all_disks);
+
+  For(i,n_move_ldsk)
+    {
+      tree->mcmc->run_move[tree->mcmc->num_move_phyrex_ldsk_given_disk]++;
+      
+      disk = all_disks[permut[i]];
+            
+      hr          = 0.0;
+      ratio       = 0.0;
+      cur_glnL    = tree->mmod->c_lnL;
+      
+      new_glnL = cur_glnL;
+      new_glnL -= PHYREX_Lk_Range(disk,disk->ldsk->prev ? disk->ldsk->prev->disk : NULL,tree);
+      
+      PHYREX_Store_Geo_Coord(disk->ldsk->coord);
+                  
+      For(j,tree->mmod->n_dim)
+        {
+          /* c: center; o: pos of direct ldsk ancestor */
+          c = disk->centr->lonlat[j];
+          o = disk->ldsk->prev ? disk->ldsk->prev->coord->lonlat[j] : disk->centr->lonlat[j];
+          f = disk->ldsk->prev ? (2./3.) : (1.0);
+
+          disk->ldsk->coord->lonlat[j] =
+            Rnorm_Trunc((o+2.*c)/3.,
+                        1.*SQRT(f*tree->mmod->rad*tree->mmod->rad),
+                        0.0,
+                        tree->mmod->lim->lonlat[j],&err);
+        
+
+          hr -= Log_Dnorm_Trunc(disk->ldsk->coord->lonlat[j],
+                                (o+2.*c)/3.,
+                                1.*SQRT(f*tree->mmod->rad*tree->mmod->rad),
+                                0.0,
+                                tree->mmod->lim->lonlat[j],&err);
+          
+          hr += Log_Dnorm_Trunc(disk->ldsk->coord->cpy->lonlat[j],
+                                (o+2.*c)/3.,
+                                1.*SQRT(f*tree->mmod->rad*tree->mmod->rad),
+                                0.0,
+                                tree->mmod->lim->lonlat[j],&err);
+        }
+      
+      new_glnL += PHYREX_Lk_Range(disk,disk->ldsk->prev ? disk->ldsk->prev->disk : NULL,tree);
+      tree->mmod->c_lnL = new_glnL;
+      
+      ratio += (new_glnL - cur_glnL);
+      ratio += hr;
+      
+      ratio = EXP(ratio);
+      alpha = MIN(1.,ratio);
+      
+      u = Uni();
+      
+      if(u > alpha) /* Reject */
+        {
+          PHYREX_Restore_Geo_Coord(disk->ldsk->coord);
+          
+          if(tree->mmod->safe_phyrex == YES)
+            {
+              new_glnL = PHYREX_Lk(tree);
+              
+              if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n. disk->ldsk->prev: %p",disk->ldsk->prev);
+                  PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          else
+            {
+              tree->mmod->c_lnL = cur_glnL;
+            }
+        }
+      else
+        {
+          tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_ldsk_given_disk]++;
+        }
+    }
+
+  Free(permut);
+  Free(all_disks);
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+#ifdef PHYREX
+void MCMC_PHYREX_Disk_Given_Ldsk(t_tree *tree)
+{
+  phydbl u,alpha,ratio,hr;
+  phydbl cur_glnL, new_glnL;
+  t_dsk  *disk,**all_disks;
+  int i,j,n_all_disks,block,n_move_ldsk,*permut;
+
+  block       = 100;
+  all_disks   = NULL;
+  n_all_disks = 0;
+
+  disk = tree->disk->prev;
+  do
+    {
+      if(TRUE)
+        {
+          if(!n_all_disks) all_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+          else if(!(n_all_disks%block)) all_disks = (t_dsk **)mRealloc(all_disks,n_all_disks+block,sizeof(t_dsk *));
+          all_disks[n_all_disks] = disk;
+          n_all_disks++;
+        }
+      disk = disk->prev;
+    }
+  while(disk);
+
+  if(!n_all_disks) return;
+  
+  /* n_move_ldsk = Rand_Int(1,1+(int)(n_all_disks/10)); */
+  n_move_ldsk = n_all_disks;
+  
+  permut = Permutate(n_all_disks);
+
+  For(i,n_move_ldsk)
+    {
+      tree->mcmc->run_move[tree->mcmc->num_move_phyrex_disk_given_ldsk]++;
+      
+      disk = all_disks[permut[i]];
+      
+      hr          = 0.0;
+      ratio       = 0.0;
+      cur_glnL    = tree->mmod->c_lnL;
+      
+      new_glnL = cur_glnL;
+
+      if(disk->ldsk != NULL)
+        new_glnL -= PHYREX_Lk_Range(disk,disk->ldsk->prev ? disk->ldsk->prev->disk : NULL,tree);
+      else
+        new_glnL -= PHYREX_Lk_Range(disk,disk->prev,tree);
+
+      PHYREX_Store_Geo_Coord(disk->centr);
+
+      For(j,tree->mmod->n_dim) disk->centr->lonlat[j] = Uni()*tree->mmod->lim->lonlat[j];
+
+      if(disk->ldsk != NULL)
+        new_glnL += PHYREX_Lk_Range(disk,disk->ldsk->prev ? disk->ldsk->prev->disk : NULL,tree);
+      else
+        new_glnL += PHYREX_Lk_Range(disk,disk->prev,tree);
+      
+      tree->mmod->c_lnL = new_glnL;
+      
+      ratio += (new_glnL - cur_glnL);
+      ratio += hr;
+      
+      ratio = EXP(ratio);
+      alpha = MIN(1.,ratio);
+      
+      u = Uni();
+      
+      if(u > alpha) /* Reject */
+        {
+          PHYREX_Restore_Geo_Coord(disk->centr);
+          
+          if(tree->mmod->safe_phyrex == YES)
+            {
+              new_glnL = PHYREX_Lk(tree);
+              
+              if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                {
+                  PhyML_Printf("\n== disk->ldsk->prev: %p",disk->ldsk->prev);
+                  PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                }
+            }
+          else
+            {
+              tree->mmod->c_lnL = cur_glnL;
+            }
+        }
+      else
+        {
+          tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_disk_given_ldsk]++;
+        }
+    }
+
+  Free(permut);
+  Free(all_disks);
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+#ifdef PHYREX
+void MCMC_PHYREX_Indel_Hit_Serial(t_tree *tree)
+{
+  t_dsk *disk,*new_disk,*target_disk,*young_disk;
+  t_ldsk *young_ldsk, *old_ldsk, *new_ldsk;
+  int i,j,n_trials,dir_old_young,err;
+  phydbl ratio, u, alpha, hr, type;
+  phydbl cur_glnL, new_glnL;
+  phydbl log_one_on_T;
+  phydbl T,t,pindel;
+
+  cur_glnL     = tree->mmod->c_lnL;
+  new_glnL     = tree->mmod->c_lnL;
+  hr           = 0.0;
+  ratio        = 0.0;
+  type         = -1.0;
+  n_trials     = (int)(PHYREX_Total_Number_Of_Hit_Disks(tree)/10);
+  T            = PHYREX_Tree_Height(tree);
+  log_one_on_T = -LOG(FABS(T));
+  pindel       = 0.5;
+
+  disk = tree->disk->prev;
+
+  For(i,n_trials)
+    {
+      tree->mcmc->run_move[tree->mcmc->num_move_phyrex_indel_hit_serial]++;
+
+      t = Uni()*T;
+      disk = tree->disk->prev;
+      while(disk && disk->time > t) disk = disk->prev;
+                                                
+      assert(disk->next);
+      
+      cur_glnL = tree->mmod->c_lnL;
+      new_glnL = tree->mmod->c_lnL;
+      hr       = 0.0;
+      ratio    = 0.0;
+
+      type = Uni();
+      
+      if(type < pindel) /* Insert */
+        {
+          hr += LOG(FABS((t - disk->next->time)/T));
+          hr -= log_one_on_T;
+          
+          young_disk = disk->next;
+          assert(young_disk->n_ldsk_a);
+          
+          /* Which lineage is going to be hit ? */
+          hr -= LOG(1./young_disk->n_ldsk_a);
+
+          new_disk = PHYREX_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
+          PHYREX_Init_Disk_Event(new_disk,tree->mmod->n_dim,tree->mmod);
+          new_disk->time = t;
+          
+          young_ldsk = young_disk->ldsk_a[Rand_Int(0,young_disk->n_ldsk_a-1)];
+          old_ldsk   = young_ldsk->prev;
+
+          if(old_ldsk->disk->time > young_ldsk->disk->time) 
+            {
+              PhyML_Printf("\n== young_ldsk: %f",young_ldsk->disk->time);
+              PhyML_Printf("\n== old_ldsk: %f",old_ldsk->disk->time);
+              assert(FALSE);
+            }
+          
+          new_glnL -= PHYREX_Lk_Range(young_disk->prev,old_ldsk->disk,tree);
+          /* new_glnL -= PHYREX_Lk_Range(tree->disk->prev,NULL,tree); */
+
+          /* Direction from old to young ldsk */
+          dir_old_young = PHYREX_Get_Next_Direction(young_ldsk,old_ldsk);
+          assert(dir_old_young != -1);
+          
+          /* Make and initialize new ldsk */
+          new_ldsk = PHYREX_Make_Lindisk_Node(tree->mmod->n_dim);
+          PHYREX_Init_Lindisk_Node(new_ldsk,new_disk,tree->mmod->n_dim);
+          PHYREX_Make_Lindisk_Next(new_ldsk);
+          new_disk->ldsk = new_ldsk;
+          
+          /* Connect it */
+          new_ldsk->prev                = old_ldsk;
+          new_ldsk->next[0]             = young_ldsk;
+          young_ldsk->prev              = new_ldsk;  
+          old_ldsk->next[dir_old_young] = new_ldsk;
+          
+          /* Insert disk */
+          PHYREX_Insert_Disk(new_disk,tree);
+
+          For(j,tree->mmod->n_dim)
+            {
+              new_ldsk->coord->lonlat[j] = Rnorm_Trunc(0.5*(young_ldsk->coord->lonlat[j]+old_ldsk->coord->lonlat[j]),
+                                                       1.*tree->mmod->rad,
+                                                       0.0,tree->mmod->lim->lonlat[j],&err);
+              
+              hr -= Log_Dnorm_Trunc(new_ldsk->coord->lonlat[j],
+                                    0.5*(young_ldsk->coord->lonlat[j]+old_ldsk->coord->lonlat[j]),
+                                    1.*tree->mmod->rad,
+                                    0.0,tree->mmod->lim->lonlat[j],&err);
+            }
+          
+          /* Sample position of the center of new_disk */
+          For(j,tree->mmod->n_dim)
+            {
+              new_disk->centr->lonlat[j] = Rnorm_Trunc(new_ldsk->coord->lonlat[j],
+                                                       1.*tree->mmod->rad,
+                                                       0.0,tree->mmod->lim->lonlat[j],&err);
+
+              hr -= Log_Dnorm_Trunc(new_disk->centr->lonlat[j],
+                                    new_ldsk->coord->lonlat[j],
+                                    1.*tree->mmod->rad,
+                                    0.0,tree->mmod->lim->lonlat[j],&err);
+            }
+          
+
+          new_glnL += PHYREX_Lk_Range(young_disk->prev,old_ldsk->disk,tree);
+          tree->mmod->c_lnL = new_glnL;
+
+          ratio  = (new_glnL - cur_glnL);
+          ratio += hr;
+          
+          ratio = EXP(ratio);
+          alpha = MIN(1.,ratio);
+          
+          /* Always accept move */
+          if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+          
+          u = Uni();
+          
+          if(u > alpha) /* Reject */
+            {
+              PHYREX_Remove_Disk(new_disk);
+              Free_Disk(new_disk);             
+              Free_Ldisk(new_ldsk);
+              
+              old_ldsk->next[dir_old_young] = young_ldsk;
+              young_ldsk->prev = old_ldsk;
+
+              if(tree->mmod->safe_phyrex == YES)
+                {
+                  new_glnL = PHYREX_Lk(tree);
+                  if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                    {
+                      PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                    }
+                }
+              else
+                {
+                  PHYREX_Lk_Range(young_disk->prev,old_ldsk->disk,tree);
+                  tree->mmod->c_lnL = cur_glnL;
+                }
+            }
+          else
+            {
+              tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_indel_hit_serial]++;
+            }
+        }
+
+
+      else /* Remove disk */
+
+
+        {
+          if(disk->ldsk == NULL || (disk->ldsk != NULL && disk->ldsk->n_next > 1)) continue;
+
+          target_disk = disk;
+
+          old_ldsk   = target_disk->ldsk->prev;
+          young_ldsk = target_disk->ldsk->next[0];
+
+          dir_old_young = PHYREX_Get_Next_Direction(young_ldsk,old_ldsk);
+          assert(dir_old_young != -1);
+
+          /* Part of the Hastings ratio corresponding to the probability of selecting */
+          /* one of disk->n_ldsk_a to be hit */ 
+          hr += LOG(1./target_disk->next->n_ldsk_a);
+          
+          /* Density for position of the displaced ldsk */
+          For(j,tree->mmod->n_dim)
+            {
+              hr += Log_Dnorm_Trunc(target_disk->ldsk->coord->lonlat[j],
+                                    0.5*(young_ldsk->coord->lonlat[j]+old_ldsk->coord->lonlat[j]),
+                                    1.0*tree->mmod->rad,
+                                    0.0,
+                                    tree->mmod->lim->lonlat[j],&err);
+            }
+          
+          /* Density for position of the center of target_disk */
+          For(j,tree->mmod->n_dim)
+            {
+              hr += Log_Dnorm_Trunc(target_disk->centr->lonlat[j],
+                                    target_disk->ldsk->coord->lonlat[j],
+                                    1.0*tree->mmod->rad,
+                                    0.0,tree->mmod->lim->lonlat[j],&err);
+            }
+
+          new_glnL -= PHYREX_Lk_Range(target_disk,target_disk->ldsk->prev->disk,tree);
+          /* new_glnL -= PHYREX_Lk_Range(tree->disk->prev,NULL,tree); */
+
+          /* New connections between old_ldsk and young_ldsk */
+          old_ldsk->next[dir_old_young] = young_ldsk;
+          young_ldsk->prev              = old_ldsk;
+
+          hr -= LOG(FABS((target_disk->time - target_disk->next->time)/T));
+          hr += log_one_on_T;
+          
+          PHYREX_Remove_Disk(target_disk);
+          new_glnL += PHYREX_Lk_Range(target_disk->prev,target_disk->ldsk->prev->disk,tree);
+          tree->mmod->c_lnL = new_glnL;
+                              
+          ratio  = (new_glnL - cur_glnL);
+          ratio += hr;
+          
+          ratio = EXP(ratio);
+          alpha = MIN(1.,ratio);
+          
+          /* Always accept move */
+          if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+          
+          u = Uni();
+          
+          if(u > alpha) /* Reject */
+            {
+              PHYREX_Insert_Disk(target_disk,tree);
+              old_ldsk->next[dir_old_young] = target_disk->ldsk;
+              young_ldsk->prev              = target_disk->ldsk;
+              
+              if(tree->mmod->safe_phyrex == YES)
+                {
+                  new_glnL = PHYREX_Lk(tree);
+                  if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                    {
+                      PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                    }
+                }
+              else
+                {
+                  PHYREX_Lk_Range(target_disk->prev,target_disk->ldsk->prev->disk,tree);
+                  tree->mmod->c_lnL = cur_glnL;
+                }
+            }
+          else
+            {
+              Free_Disk(disk);
+              Free_Ldisk(disk->ldsk);
+              tree->mcmc->acc_move[tree->mcmc->num_move_phyrex_indel_hit_serial]++;
+            }
+        }
+    }
+  
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+#ifdef PHYREX
+void MCMC_PHYREX_Indel_Disk_Serial(t_tree *tree)
+{
+  t_dsk *disk,*new_disk;
+  int i,j,n_trials;
+  phydbl ratio, u, alpha, hr, type;
+  phydbl cur_glnL, new_glnL;
+  phydbl log_lk_centr,log_one_on_T;
+  phydbl T,t,pindel;
+
+  cur_glnL     = tree->mmod->c_lnL;
+  new_glnL     = tree->mmod->c_lnL;
+  hr           = 0.0;
+  ratio        = 0.0;
+  type         = -1.0;
+  n_trials     = (int)(PHYREX_Total_Number_Of_Intervals(tree)/2);
+  T            = PHYREX_Tree_Height(tree);
+  log_one_on_T = -LOG(FABS(T));
+  pindel       = 0.5;
+
+  log_lk_centr = 0.0;
+  For(j,tree->mmod->n_dim) log_lk_centr += LOG(1./tree->mmod->lim->lonlat[j]);
+
+  disk = tree->disk->prev;
+
+  For(i,n_trials)
+  /* do */
+    {
+      t = Uni()*T;
+      disk = tree->disk->prev;
+      while(disk && disk->time > t) disk = disk->prev;
+                                                
+      assert(disk->next);
+
+      /* prev_disk = disk->prev; */
+
+      cur_glnL = tree->mmod->c_lnL;
+      new_glnL = tree->mmod->c_lnL;
+      hr       = 0.0;
+      ratio    = 0.0;
+
+      type = Uni();
+      
+      if(type < pindel) /* Insert */
+        {
+          hr += LOG(FABS((t - disk->next->time)/T));
+          hr -= log_one_on_T;
+          hr -= log_lk_centr;
+          
+          new_glnL -= PHYREX_Lk_Range(disk,disk,tree);
+          new_disk = PHYREX_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
+          PHYREX_Init_Disk_Event(new_disk,tree->mmod->n_dim,tree->mmod);
+          new_disk->time = t;
+          PHYREX_Insert_Disk(new_disk,tree);
+
+          For(j,tree->mmod->n_dim) new_disk->centr->lonlat[j] = Uni()*tree->mmod->lim->lonlat[j];
+
+          new_glnL += PHYREX_Lk_Range(new_disk,disk,tree);
+          tree->mmod->c_lnL = new_glnL;
+          
+          /* new_glnL = PHYREX_Lk(tree); */
+                    
+          ratio  = (new_glnL - cur_glnL);
+          ratio += hr;
+          
+          ratio = EXP(ratio);
+          alpha = MIN(1.,ratio);
+          
+          /* Always accept move */
+          if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+          
+          u = Uni();
+          
+          if(u > alpha) /* Reject */
+            {
+              PHYREX_Remove_Disk(new_disk);
+              Free_Disk(new_disk);
+              
+              if(tree->mmod->safe_phyrex == YES)
+                {
+                  new_glnL = PHYREX_Lk(tree);
+                  if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                    {
+                      PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                    }
+                }
+              else
+                {
+                  tree->mmod->c_lnL = cur_glnL;
+                }
+            }
+        }
+      else /* Remove disk */
+        {
+          if(disk->ldsk != NULL) continue; /* Reject */
+
+          hr -= LOG(FABS((disk->time - disk->next->time)/T));
+          hr += log_one_on_T;
+          hr += log_lk_centr;
+
+          new_glnL -= PHYREX_Lk_Range(disk,disk->prev,tree);
+          PHYREX_Remove_Disk(disk);
+          new_glnL += PHYREX_Lk_Range(disk->prev,disk->prev,tree);
+          tree->mmod->c_lnL = new_glnL;
+                    
+
+          ratio  = (new_glnL - cur_glnL);
+          ratio += hr;
+          
+          ratio = EXP(ratio);
+          alpha = MIN(1.,ratio);
+          
+          /* Always accept move */
+          if(tree->mcmc->always_yes == YES && new_glnL > UNLIKELY) alpha = 1.0;
+          
+          u = Uni();
+          
+          if(u > alpha) /* Reject */
+            {
+              PHYREX_Insert_Disk(disk,tree);
+              
+              if(tree->mmod->safe_phyrex == YES)
+                {
+                  new_glnL = PHYREX_Lk(tree);
+                  if(Are_Equal(new_glnL,cur_glnL,1.E-3) == NO)
+                    {
+                      PhyML_Printf("\n== new_glnL: %f cur_glnL: %f",new_glnL,cur_glnL);
+                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                    }
+                }
+              else
+                {
+                  tree->mmod->c_lnL = cur_glnL;
+                }
+            }
+          else
+            {
+              Free_Disk(disk);
+            }
+        }
+    
+      /* disk = prev_disk; */
+    }
+  
+  /* while(disk->prev); */
+}
+#endif
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
 /*////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////*/
 /*////////////////////////////////////////////////////////////
diff --git a/src/mcmc.h b/src/mcmc.h
index b5c445d..e8baf3e 100644
--- a/src/mcmc.h
+++ b/src/mcmc.h
@@ -32,6 +32,7 @@ the GNU public licence. See http://www.opensource.org for details.
 #include "draw.h"
 #include "rates.h"
 #include "stats.h"
+#include "phyrex.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -41,7 +42,6 @@ void MCMC_Lexp(t_tree *tree);
 void MCMC_Print_Param(t_mcmc *mcmc, t_tree *tree);
 t_mcmc *MCMC_Make_MCMC_Struct();
 void MCMC_Free_MCMC(t_mcmc *mcmc);
-void MCMC_Init_MCMC_Struct(char *filename, option *io,t_mcmc *mcmc);
 void MCMC(t_tree *tree);
 void MCMC_Alpha(t_tree *tree);
 void MCMC_Randomize_Branch_Lengths(t_tree *tree);
@@ -151,20 +151,33 @@ void MCMC_GEO_Sigma(t_tree *mixt_tree);
 void MCMC_GEO_Tau(t_tree *mixt_tree);
 void MCMC_GEO_Loc(t_tree *tree);
 void MCMC_GEO_Dum(t_tree *mixt_tree);
-void MCMC_MIGREP_Lbda(t_tree *mixt_tree);
-void MCMC_MIGREP_Mu(t_tree *mixt_tree);
-void MCMC_MIGREP_Radius(t_tree *mixt_tree);
-void MCMC_MIGREP_Triplet(t_tree *tree);
-void MCMC_MIGREP_Delete_Disk(t_tree *tree);
-void MCMC_MIGREP_Insert_Disk(t_tree *tree);
-void MCMC_MIGREP_Move_Disk_Centre(t_tree *tree);
-void MCMC_MIGREP_Move_Disk_Updown(t_tree *tree);
-void MCMC_MIGREP_Swap_Disk(t_tree *tree);
-void MCMC_MIGREP_Insert_Hit(t_tree *tree);
-void MCMC_MIGREP_Delete_Hit(t_tree *tree);
-void MCMC_MIGREP_Move_Ldsk(t_tree *tree);
-void MCMC_MIGREP_Shift_Ldsk_To_Centre(t_tree *tree);
-void MCMC_MIGREP_Shift_Centre_To_Median(t_tree *tree);
-void MCMC_MIGREP_Shift_Ldsk_Path(t_tree *tree);
-
+void MCMC_PHYREX_Lbda(t_tree *mixt_tree);
+void MCMC_PHYREX_Mu(t_tree *mixt_tree);
+void MCMC_PHYREX_Radius(t_tree *mixt_tree);
+void MCMC_PHYREX_Triplet(t_tree *tree);
+void MCMC_PHYREX_Move_Disk_Updown(t_tree *tree);
+void MCMC_PHYREX_Swap_Disk(t_tree *tree);
+void MCMC_PHYREX_Prune_Regraft(t_tree *tree);
+void MCMC_PHYREX_Scale_Times(t_tree *tree);
+void MCMC_PHYREX_Ldscape_Limits(t_tree *tree);
+void MCMC_PHYREX_Indel_Disk(t_tree *tree);
+void MCMC_PHYREX_Delete_Disk(phydbl hr, int n_delete_disks, phydbl cur_lbda, phydbl cur_mu, phydbl cur_rad, t_tree *tree);
+void MCMC_PHYREX_Insert_Disk(phydbl hr, int n_delete_disks, phydbl cur_lbda, phydbl cur_mu, phydbl cur_rad, t_tree *tree);
+void MCMC_PHYREX_Indel_Hit(t_tree *tree);
+void MCMC_PHYREX_Insert_Hit(phydbl hr, int n_insert_disks, phydbl cur_rad, phydbl cur_mu, t_tree *tree);
+void MCMC_PHYREX_Delete_Hit(phydbl hr, int n_delete_disks, phydbl cur_rad, phydbl cur_mu, t_tree *tree);
+void MCMC_PHYREX_Simulate_Backward(t_tree *tree);
+void MCMC_Update_Mode(int move_num, t_mcmc *mcmc, t_tree *tree);
+void MCMC_PHYREX_Lineage_Traj(t_tree *tree);
+void MCMC_PHYREX_Lbda_Times(t_tree *tree);
+void MCMC_PHYREX_Delete_Disk_Serial(t_tree *tree);
+void MCMC_PHYREX_Insert_Disk_Serial(t_tree *tree);
+void MCMC_PHYREX_Indel_Disk_Serial(t_tree *tree);
+void MCMC_PHYREX_Simulate_Backward_Plus(t_tree *tree);
+void MCMC_PHYREX_Indel_Hit_Serial(t_tree *tree);
+void MCMC_PHYREX_Disk_Multi(t_tree *tree);
+void MCMC_PHYREX_Ldsk_Multi(t_tree *tree);
+void MCMC_PHYREX_Ldsk_Given_Disk(t_tree *tree);
+void MCMC_PHYREX_Disk_Given_Ldsk(t_tree *tree);
+void MCMC_PHYREX_Ldsk_And_Disk(t_tree *tree);
 #endif
diff --git a/src/mg.c b/src/mg.c
index 791b4e7..ae3b8fc 100644
--- a/src/mg.c
+++ b/src/mg.c
@@ -122,7 +122,7 @@ int PART_main(int argc, char **argv)
 	                                     treelist->tree[part]->io->state_len;
 
           Set_Both_Sides(YES,treelist->tree[part]);
-	  Connect_CSeqs_To_Nodes(cdata[part],treelist->tree[part]);
+	  Connect_CSeqs_To_Nodes(cdata[part],io->st->optionlist[part],treelist->tree[part]);
 	  Fill_Dir_Table(treelist->tree[part]);
 	  Update_Dirs(treelist->tree[part]);
 	  Make_Tree_4_Lk(treelist->tree[part],cdata[part],cdata[part]->init_len);
diff --git a/src/migrep.c b/src/migrep.c
deleted file mode 100644
index 8c11300..0000000
--- a/src/migrep.c
+++ /dev/null
@@ -1,1819 +0,0 @@
-/*
-
-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 that implement Etheridge and Barton's model of continuous-space
-   coalescent.
-*/
-
-#include "migrep.h"
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
-
-int MIGREP_Draw(GtkWidget *widget, cairo_t *cr, gpointer *data)
-{   
-  t_tree *tree;
-  phydbl h, w;
-  t_dsk *disk;
-  int i;
-
-  tree = (t_tree *)(data);
-  
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-
-  h = FABS(disk->time);
-  w = tree->mmod->lim->lonlat[1];
-
-  cairo_select_font_face(cr, "Courier",
-                         CAIRO_FONT_SLANT_NORMAL,
-                         CAIRO_FONT_WEIGHT_NORMAL);
-  
-  cairo_set_font_size(cr,0.03);
-  cairo_scale (cr,WINDOW_WIDTH/1.2,WINDOW_HEIGHT/1.2);
-  cairo_translate(cr,0.05,0.05);
-  cairo_set_source_rgb(cr,0,0,0);
-  cairo_set_line_width(cr,0.002);
-
-  while(disk->next) disk = disk->next;
-  do
-    {      
-      /* MIGREP_Update_Lindisk_List(disk->time,disk->ldsk_a,&(disk->n_ldsk_a),disk); */
-      MIGREP_Update_Lindisk_List(tree);
-
-      /* cairo_move_to(cr,0,FABS(disk->time)/h); */
-      /* cairo_show_text(cr,disk->id); */
-      /* cairo_stroke(cr); */
-
-      /* cairo_move_to(cr,disk->centr->lonlat[1]/w - mmod->rad/w,FABS(disk->time)/h); */
-      /* cairo_set_line_width(cr,0.004); */
-      /* cairo_set_source_rgba(cr, 1, 0, 0, 0.3); */
-      /* cairo_set_line_width(cr,0.002); */
-      /* cairo_line_to(cr,disk->centr->lonlat[1]/w + mmod->rad/w,FABS(disk->time)/h); */
-      /* cairo_stroke(cr); */
-      /* cairo_arc(cr,disk->centr->lonlat[1]/w,FABS(disk->time)/h,0.005,0.,2.*PI); */
-      /* cairo_stroke(cr); */
-      /* cairo_set_source_rgb(cr, 0, 0, 0); */
-          
-      For(i,disk->n_ldsk_a)
-        {
-          cairo_move_to(cr,disk->ldsk_a[i]->coord->lonlat[1]/w,FABS(disk->time)/h);
-          /* cairo_show_text(cr,disk->ldsk_a[i]->coord->id);  */
-          cairo_stroke(cr);
-          cairo_move_to(cr,disk->ldsk_a[i]->coord->lonlat[1]/w,FABS(disk->time)/h);
-          cairo_line_to(cr,disk->ldsk_a[i]->coord->lonlat[1]/w,FABS(disk->prev->time)/h);
-          cairo_stroke(cr);
-
-          if(disk->ldsk_a[i]->prev->disk == disk->prev)
-            {
-              cairo_line_to(cr,disk->ldsk_a[i]->coord->lonlat[1]/w,FABS(disk->prev->time)/h);
-              cairo_line_to(cr,disk->ldsk_a[i]->prev->coord->lonlat[1]/w,FABS(disk->prev->time)/h);
-              cairo_stroke(cr);
-            }
-
-          if(disk->ldsk_a[i]->is_coal && disk->ldsk_a[i]->disk == disk) 
-            {
-              cairo_set_source_rgba(cr, 0, 0.2, 0.8, 0.5);
-              cairo_arc(cr,disk->ldsk_a[i]->coord->lonlat[1]/w,FABS(disk->time)/h,0.01,0.,2.*PI);
-              cairo_fill(cr);
-              cairo_stroke(cr);
-              cairo_set_source_rgb(cr, 0, 0, 0);
-            }
-          else
-            {
-              cairo_set_source_rgba(cr, 0.2, 0.2, 0.2, 0.8);
-              cairo_arc(cr,disk->ldsk_a[i]->coord->lonlat[1]/w,FABS(disk->time)/h,0.005,0.,2.*PI);
-              cairo_fill(cr);
-              cairo_stroke(cr);
-              cairo_set_source_rgb(cr, 0, 0, 0);
-            }
-        }
-      disk = disk->prev;
-      if(disk->prev == NULL) break;
-    }while(1);
-
-  // Root disk
-  cairo_move_to(cr,disk->ldsk->coord->lonlat[1]/w,FABS(disk->time)/h);
-  cairo_show_text(cr,disk->ldsk->coord->id); 
-  cairo_arc(cr,disk->ldsk->coord->lonlat[1]/w,FABS(disk->time)/h,0.005,0.,2.*PI);
-  cairo_stroke (cr);
-
-  /* cairo_scale (cr,WINDOW_WIDTH,WINDOW_HEIGHT); */
-  /* cairo_set_source_rgb (cr, 0, 0, 0); */
-  /* cairo_move_to (cr, 0, 0); */
-  /* cairo_line_to (cr, 1, 1); */
-  /* cairo_move_to (cr, 1, 0); */
-  /* cairo_line_to (cr, 0, 1); */
-  /* cairo_set_line_width (cr, 0.2); */
-  /* cairo_stroke (cr); */
-  
-  /* cairo_rectangle (cr, 0, 0, 0.5, 0.5); */
-  /* cairo_set_source_rgba (cr, 1, 0, 0, 0.80); */
-  /* cairo_fill (cr); */
-  
-  /* cairo_rectangle (cr, 0, 0.5, 0.5, 0.5); */
-  /* cairo_set_source_rgba (cr, 0, 1, 0, 0.60); */
-  /* cairo_fill (cr); */
-  
-  /* cairo_rectangle (cr, 0.5, 0, 0.5, 0.5); */
-  /* cairo_set_source_rgba (cr, 0, 0, 1, 0.40); */
-  /* cairo_fill (cr); */
-  
-  /* /\* Set color for background *\/ */
-  /* cairo_set_source_rgb(cr, 1, 1, 1); */
-  /* /\* fill in the background color*\/ */
-  /* cairo_paint(cr); */
-  
-  /* /\* set color for rectangle *\/ */
-  /* cairo_set_source_rgb(cr, 0.42, 0.65, 0.80); */
-  /* /\* set the line width *\/ */
-  /* cairo_set_line_width(cr,6); */
-  /* /\* draw the rectangle's path beginning at 3,3 *\/ */
-  /* cairo_rectangle (cr, 3, 3, 100, 100); */
-  /* /\* stroke the rectangle's path with the chosen color so it's actually visible *\/ */
-  /* cairo_stroke(cr); */
-  
-  /* /\* draw circle *\/ */
-  /* cairo_set_source_rgb(cr, 0.17, 0.63, 0.12); */
-  /* cairo_set_line_width(cr,2); */
-  /* cairo_arc(cr, 150, 210, 20, 0, 2*G_PI); */
-  /* cairo_stroke(cr); */
-  
-  /* /\* draw horizontal line *\/ */
-  /* cairo_set_source_rgb(cr, 0.77, 0.16, 0.13); */
-  /* cairo_set_line_width(cr, 6); */
-  /* cairo_move_to(cr, 80,160); */
-  /* cairo_line_to(cr, 200, 160); */
-  /* cairo_stroke(cr); */
-  
-  /* /\* cairo_set_source_rgb(cr,1,1,0); *\/ */
-  /* /\* cairo_paint(cr); *\/ */
-  
-  return FALSE;
-}
-
-int MIGREP_Main(int argc, char *argv[])
-{
-  GtkWidget *window;
-  GtkWidget *draw_area;
-  pthread_t calc_tid;
-  t_tree *tree;
-  int seed;
-
-  seed = time(NULL);
-  /* seed = 1413426621; */
-  /* seed = 1413492392; */
-  /* seed = 1413497813; */
-  printf("\n# Seed: %d",seed); fflush(NULL);
-  /* seed = 1412394873; */
-  srand(seed);
-  tree = MIGREP_Simulate_Backward((int)atoi(argv[1]),10.,10.);
-
-  MIGREP_MCMC(tree);
-  Exit("\n");
-
-  /* gdk_threads_init(); */
-  /* gdk_threads_enter(); */
-  
-  gtk_init(&argc,&argv);
-  
-  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-  g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL);
-  gtk_container_set_border_width (GTK_CONTAINER (window),0);
-  
-  draw_area= gtk_drawing_area_new();
-  gtk_widget_set_size_request(draw_area,WINDOW_WIDTH,WINDOW_HEIGHT);
-  g_signal_connect(draw_area,"draw",G_CALLBACK(MIGREP_Draw),(gpointer)tree);
-  
-  gtk_container_add(GTK_CONTAINER(window),draw_area);
-
-  gtk_widget_show_all (window);
-
-  tree->draw_area = draw_area;
-
-  pthread_create(&calc_tid,NULL,(void *(*)(void *))MIGREP_MCMC,tree);
-    
-  gtk_main();
-  /* gdk_threads_leave(); */
-  
-  return 0;
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-// Simulate Etheridge-Barton model backward in time, following n_otu lineages
-// on a rectangle of dimension width x height
-// See Kelleher, Barton & Etheridge, Bioinformatics, 2013.
-t_tree *MIGREP_Simulate_Backward(int n_otu, phydbl width, phydbl height)
-{  
-  int i;
-  t_tree *tree;
-  int n_dim,n_lineages,n_lineages_new,n_disk,n_hit;
-  phydbl curr_t,dt_dsk;
-  t_migrep_mod *mmod;
-  t_dsk *disk;
-  t_ldsk **ldsk_a,**ldsk_a_tmp,*new_ldsk;
-  t_node *nd;
-
-  n_dim = 2; // 2-dimensional landscape
-
-  tree = Make_Tree_From_Scratch(n_otu,NULL);
-  nd   = Make_Node_Light(0);
-  disk = MIGREP_Make_Disk_Event(n_dim,n_otu);
-  MIGREP_Init_Disk_Event(disk,n_dim,NULL);
-  
-  // Allocate coordinates for all the tips first (will grow afterwards)
-  ldsk_a = (t_ldsk **)mCalloc(n_otu,sizeof(t_ldsk *));
-  For(i,n_otu) 
-    {
-      ldsk_a[i] = MIGREP_Make_Lindisk_Node(n_dim);
-      MIGREP_Init_Lindisk_Node(ldsk_a[i],disk,n_dim);
-    }
-
-  ldsk_a_tmp = (t_ldsk **)mCalloc(n_otu,sizeof(t_ldsk *));
-
-  /* Generate coordinates for the tip nodes (uniform distribution on the rectangle) */
-  For(i,n_otu)
-    {
-      ldsk_a[i]->coord->lonlat[0] = Uni()*width;  // longitude
-      ldsk_a[i]->coord->lonlat[1] = Uni()*height; // latitude
-      /* ldsk_a[i]->coord->lonlat[0] = (i+1.)/(n_otu+1.)*width;  // longitude */
-      /* ldsk_a[i]->coord->lonlat[1] = (i+1.)/(n_otu+1.)*height; // latitude */
-    }
-
-  /* Allocate migrep model */
-  mmod = MIGREP_Make_Migrep_Model(n_dim);
-  MIGREP_Init_Migrep_Mod(mmod,n_dim);
-  mmod->lim->lonlat[0] = width;
-  mmod->lim->lonlat[1] = height;
-  
-  /* First disk event (at time 0) */
-  disk->time             = 0.0;
-  disk->mmod             = mmod;
-  disk->centr->lonlat[0] = .5*width;
-  disk->centr->lonlat[1] = .5*height;      
-  disk->ldsk_a           = ldsk_a;
-  disk->n_ldsk_a         = n_otu;
-
-  /* Allocate and initialise for next event */
-  disk->prev = MIGREP_Make_Disk_Event(n_dim,n_otu);
-  MIGREP_Init_Disk_Event(disk->prev,n_dim,NULL);
-  disk->prev->next = disk;
-  
-  /* For(i,n_otu) */
-  /*   { */
-  /*     printf("\nx disk %s [%15f] %3d %s %15f %15f", */
-  /*            disk?disk->id:"xxx", */
-  /*            disk?disk->time:0.0, */
-  /*            i, */
-  /*            ldsk_a[i]->coord->id, */
-  /*            ldsk_a[i]->coord->lonlat[0], */
-  /*            ldsk_a[i]->coord->lonlat[1]); */
-  /*   } */
-
-  /* Move to it */
-  disk = disk->prev;
-
-  /* Initialize parameters of migrep model */
-  mmod->lbda = 0.4;
-  mmod->mu   = 0.8;
-  mmod->rad  = 2.0;
-  
-  curr_t      = 0.0;
-  dt_dsk     = 0.0;
-  n_lineages  = n_otu;
-  n_disk      = 0;
-  do
-    {
-      /* Time of next event */
-      dt_dsk = Rexp(mmod->lbda);
-      curr_t -= dt_dsk;
-      
-      /* Coordinates of next event */
-      disk->centr->lonlat[0] = Uni()*width;
-      disk->centr->lonlat[1] = Uni()*height;      
-
-      disk->time = curr_t;
-      disk->mmod = mmod;
-
-      /* printf("\n. Disk %s has %d lindisk nodes and %d disks under",disk->id,disk->n_ldsk_a,disk->n_disk_under); */
-
-      /* New lindisk (will not be used if no lineage is hit)  */
-      new_ldsk = MIGREP_Make_Lindisk_Node(n_dim);
-      MIGREP_Init_Lindisk_Node(new_ldsk,disk,n_dim);
-
-      /* Sample the location of new_ldsk uniformly in the disk. */
-      /* Takes into account the limits of the landscape */
-      MIGREP_Runif_Rectangle_Overlap(new_ldsk,disk,mmod);
-
-      n_hit          = 0;
-      n_lineages_new = 0;
-      For(i,n_lineages)
-        {
-          ldsk_a[i]->prev = NULL;
-
-          if(MIGREP_Is_In_Disk(ldsk_a[i]->coord,disk) == YES) 
-            {
-              if(Uni() < mmod->mu)
-                {
-                  /* printf("\n. Hit and die %s @ time %f. Center: %f %f Go to %f %f", */
-                  /*        ldsk_a[i]->coord->id, */
-                  /*        disk->time, */
-                  /*        disk->centr->lonlat[0], */
-                  /*        disk->centr->lonlat[1], */
-                  /*        new_ldsk->coord->lonlat[0], */
-                  /*        new_ldsk->coord->lonlat[1]); */
-                  
-                  MIGREP_Make_Lindisk_Next(new_ldsk);
-
-                  ldsk_a[i]->prev                    = new_ldsk;
-                  ldsk_a[i]->prev->is_hit            = YES;
-                  new_ldsk->next[new_ldsk->n_next-1] = ldsk_a[i]; 
-                  disk->ldsk                         = new_ldsk;
-
-                  n_hit++;
-
-                  if(n_hit == 1)
-                    {
-                      ldsk_a_tmp[n_lineages_new] = new_ldsk;
-                      n_lineages_new++;
-                    }
-                }
-            }
-          
-          if(ldsk_a[i]->prev == NULL)
-            {
-              ldsk_a[i]->prev = ldsk_a[i];
-              ldsk_a_tmp[n_lineages_new] = ldsk_a[i]->prev;
-              n_lineages_new++;
-            }          
-        }
-      
-      if((n_hit > 0) && (n_lineages_new != n_lineages - n_hit + 1))
-        {
-          PhyML_Printf("\n== Err. in file %s at line %d (function '%s') \n",__FILE__,__LINE__,__FUNCTION__);
-          Warn_And_Exit("");
-        }
-
-      if(n_hit > 0) n_lineages -= (n_hit-1);
-
-      if(n_hit > 1) // a coalescent event occurred
-        {
-          disk->nd          = nd;
-          new_ldsk->is_coal = YES;
-          /* PhyML_Printf("\n. Coalescent @ disk %s on ldsk %s",disk->id,disk->ldsk->coord->id); */
-        }
- 
-      ldsk_a = (t_ldsk **)mCalloc(n_otu,sizeof(t_ldsk *));
-      For(i,n_lineages) ldsk_a[i] = ldsk_a_tmp[i];
-      
-      /* For(i,n_lineages) */
-      /*   { */
-      /*     printf("\n. disk %s [%15f] %3d %s %15f %15f", */
-      /*            disk?disk->id:"xxx", */
-      /*            disk?disk->time:0.0, */
-      /*            i, */
-      /*            ldsk_a[i]->coord->id, */
-      /*            ldsk_a[i]->coord->lonlat[0], */
-      /*            ldsk_a[i]->coord->lonlat[1]); */
-      /*   } */
-
-      n_disk++;
-
-
-      if(n_lineages == 1) break;
-
-      disk->prev = MIGREP_Make_Disk_Event(n_dim,n_otu);
-      MIGREP_Init_Disk_Event(disk->prev,n_dim,NULL);
-      disk->prev->next = disk;
-      
-      disk = disk->prev;          
-    }
-  while(1);
-
-  while(disk->next) disk = disk->next;
-
-  tree->disk = disk;
-  tree->mmod = mmod;
-
-  /* while(disk->prev) */
-  /*   { */
-  /*     printf("\n<><><>"); */
-  /*     printf("\n disk %f %s",disk->time,disk->id); */
-  /*     For(i,disk->n_ldsk_a) */
-  /*       { */
-  /*         printf("\n. %s %f %f", */
-  /*            disk->ldsk_a[i]->coord->id, */
-  /*            disk->ldsk_a[i]->coord->lonlat[0], */
-  /*            disk->ldsk_a[i]->coord->lonlat[1]); */
-  /*       } */
-  /*     disk = disk->prev; */
-  /*   } */
-
-
-  MIGREP_Lk(tree);
-  /* Exit("\n"); */
-  /* MIGREP_MCMC(tree); */
-
-  return(tree);
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-/* Test whether coord is in disk. Will actually only works in disk */
-/* is a rectangle... */
-
-int MIGREP_Is_In_Disk(t_geo_coord *coord, t_dsk *disk)
-{
-  int i;
-  /* PhyML_Printf("\n<> disk %s %d",disk->id,disk->centr->dim); */
-
-  if(!disk->centr->dim) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-
-  For(i,disk->centr->dim)
-    {
-      /* PhyML_Printf("\n<> disk %s ldsk %s %f ctr: %f",disk->id,coord->id,coord->lonlat[i],disk->centr->lonlat[i]); */
-      if(FABS(coord->lonlat[i] - disk->centr->lonlat[i]) > disk->mmod->rad)
-        {
-          /* PhyML_Printf("  NO"); */
-          return(NO);
-        }
-    }
-  /* PhyML_Printf("  YES"); */
-  return(YES);
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
-phydbl MIGREP_Lk(t_tree *tree)
-{
-  phydbl lnL;
-  phydbl log_mu,log_one_mu;
-  int i,n_inter;
-  short int was_hit, n_hit;
-  t_migrep_mod *mmod;
-  t_dsk *disk;
-
-  mmod = tree->mmod;
-  disk = tree->disk;
-
-  if(disk->next)  Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  if(!disk->prev) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
-
-  log_mu     = LOG(mmod->mu);
-  log_one_mu = LOG(1. - mmod->mu);  
-  lnL        = 0.0;
-
-  MIGREP_Update_Lindisk_List(tree);
-
-  /* PhyML_Printf("\n\n. New likelihood call"); */
-  do
-    {
-      /* Likelihood for the disk center */
-      For(i,disk->mmod->n_dim) lnL -= LOG(disk->mmod->lim->lonlat[i]);
-
-      /* MIGREP_Update_Lindisk_List(disk->time,disk->ldsk_a,&(disk->n_ldsk_a),disk); */
-      
-      /* PhyML_Printf("\n. Likelihood - disk %s has %d lindisk nodes [%f] rad: %f",disk->id,disk->n_ldsk_a,lnL,mmod->rad); */
-      /* fflush(NULL); */
-
-      was_hit = NO;
-      n_hit   = 0;
-      
-      For(i,disk->n_ldsk_a)
-        {
-          was_hit = disk->ldsk_a[i]->prev->disk == disk->prev;
-          
-          if(was_hit == YES) n_hit++;
-          
-          if(was_hit == YES && !disk->prev->ldsk)
-            {
-              PhyML_Printf("\n== disk: %s disk->prev: %s",disk->id,disk->prev->id);
-              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-            }
-
-          if(MIGREP_Is_In_Disk(disk->ldsk_a[i]->coord,disk->prev) == YES) /* 'Departure' point is in disk */
-            {
-              if(was_hit == YES) /* was hit */
-                {
-                  /* PhyML_Printf("\n. %d/%d lindisk %s (@ %f) was hit and gave %s (@ %f)", */
-                  /*              i,disk->n_ldsk_a, */
-                  /*              disk->ldsk_a[i]->coord->id, */
-                  /*              disk->ldsk_a[i]->prev->coord->id, */
-                  /*              disk->ldsk_a[i]->coord->lonlat[0], */
-                  /*              disk->ldsk_a[i]->prev->coord->lonlat[0]); */
-                  if(MIGREP_Is_In_Disk(disk->ldsk_a[i]->prev->coord,disk->prev) == YES) /* 'Arrival' point is in disk */
-                    {
-                      lnL += log_mu;
-                    }
-                  else /* Landed outside the disk */
-                    {
-                      /* PhyML_Printf("\n. Landed outside"); */
-                      /* fflush(NULL); */
-                      mmod->c_lnL = UNLIKELY;
-                      return UNLIKELY;
-                    }
-                }
-              else /* was not hit */
-                {
-                  lnL += log_one_mu;
-                  /* PhyML_Printf("\n. %d/%d lindisk %s was not hit, ln: %f",i,disk->n_ldsk_a,disk->ldsk_a[i]->coord->id,lnL); */
-                }
-            }
-          else
-            {
-              /* PhyML_Printf("\n. %s was hit: %d %s %s %s lnL:%f",disk->ldsk_a[i]->coord->id,was_hit,disk->ldsk_a[i]->prev->disk->id,disk->prev->id,disk->id,lnL); */
-              /* has changed spatial coordinates but was outside disk  */
-              if(was_hit == YES)
-                {
-                  /* printf("\n. FAIL lindisk: %s [%.3f %.3f] prev: %s [%.3f %.3f] centr: [%.3f %.3f] rad: %.3f", */
-                  /*        disk->ldsk_a[i]->coord->id, */
-                  /*        disk->ldsk_a[i]->coord->lonlat[0], */
-                  /*        disk->ldsk_a[i]->coord->lonlat[1], */
-                  /*        disk->ldsk_a[i]->prev->coord->id, */
-                  /*        disk->ldsk_a[i]->prev->coord->lonlat[0], */
-                  /*        disk->ldsk_a[i]->prev->coord->lonlat[1], */
-                  /*        disk->prev->centr->lonlat[0], */
-                  /*        disk->prev->centr->lonlat[1], */
-                  /*        disk->mmod->rad); */
-                  /* fflush(NULL); */
-                  mmod->c_lnL = UNLIKELY;
-                  return UNLIKELY;
-                }
-            }
-        }
-      
-      /* a hit occurred */
-      if(n_hit >= 1) lnL -= MIGREP_Log_Dunif_Rectangle_Overlap(disk,mmod);
-    
-      disk = disk->prev;
-
-      if(!disk->prev) break;
-
-    }
-  while(1);
-  
-  n_inter = MIGREP_Total_Number_Of_Intervals(tree);
-
-  lnL += (n_inter)*LOG(mmod->lbda) + mmod->lbda*disk->time;
-  /* lnL -= LnGamma((phydbl)(n_inter)); */
-  
-  /* lnL += Dpois((phydbl)n_inter,-mmod->lbda*disk->time,YES); */
-
-  if(isinf(lnL) || isnan(lnL)) lnL = UNLIKELY;
-
-  mmod->c_lnL = lnL;
-
-  return(lnL);
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
-void MIGREP_MCMC(t_tree *tree)
-{
-  t_mcmc *mcmc;
-  int move;
-  phydbl u,min_rad;
-  t_dsk *disk;
-
-  mcmc = MCMC_Make_MCMC_Struct();
-  MCMC_Complete_MCMC(mcmc,tree);
-
-  tree->mcmc = mcmc;
-
-  mcmc->io               = NULL;
-  mcmc->is               = NO;
-  mcmc->use_data         = YES;
-  mcmc->run              = 0;
-  mcmc->sample_interval  = 1E+3;
-  mcmc->chain_len        = 1E+6;
-  mcmc->chain_len_burnin = 1E+5;
-  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      = 1;
-  mcmc->chain_len        = 1.E+9;
-  mcmc->sample_interval  = 5000;
-  
-  MIGREP_Lk(tree);
-  MIGREP_LnPrior_Radius(tree);
-
-  printf("\n# before rand lnL: %f",tree->mmod->c_lnL);
-  printf("\n# ninter: %d",MIGREP_Total_Number_Of_Intervals(tree));
-  printf("\n# ncoal: %d",MIGREP_Total_Number_Of_Coal_Disks(tree));
-  printf("\n# nhits: %d",MIGREP_Total_Number_Of_Hit_Disks(tree));
-
-  tree->mmod->lbda = Uni()*(tree->mmod->max_lbda - tree->mmod->min_lbda) + tree->mmod->min_lbda;
-  tree->mmod->mu   = Uni()*(tree->mmod->max_mu - tree->mmod->min_mu) + tree->mmod->min_mu;
-  tree->mmod->rad  = tree->mmod->max_rad;
-
-  /* gtk_widget_queue_draw(tree->draw_area); */
-  /* sleep(3); */
-
-  /* PhyML_Printf("\n"); */
-  /* /\* Randomization step *\/ */
-  /* mcmc->always_yes = YES; */
-  /* do */
-  /*   { */
-  /*     move = Rand_Int(0,5); */
-  /*     switch(move) */
-  /*       { */
-  /*       case 0: { MCMC_MIGREP_Insert_Disk(tree); break; } */
-  /*       case 1: { MCMC_MIGREP_Move_Disk_Centre(tree); break; } */
-  /*       case 2: { MCMC_MIGREP_Move_Disk_Updown(tree); break; } */
-  /*       case 3: { MCMC_MIGREP_Swap_Disk(tree); break; } */
-  /*       case 4: { MCMC_MIGREP_Insert_Hit(tree); break; } */
-  /*       } */
-  /*     mcmc->run++; */
-  /*     PhyML_Printf("\r. Randomization %5d/500",mcmc->run); */
-  /*   } */
-  /* while(mcmc->run < 500); */
-  /* mcmc->always_yes = NO; */
-  /* mcmc->run        = 0; */
-
-  MIGREP_Lk(tree);
-  printf("\n# after rand lnL: %f",tree->mmod->c_lnL);
-  printf("\n# ninter: %d",MIGREP_Total_Number_Of_Intervals(tree));
-  printf("\n# ncoal: %d",MIGREP_Total_Number_Of_Coal_Disks(tree));
-  printf("\n# nhits: %d",MIGREP_Total_Number_Of_Hit_Disks(tree));
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  printf("\n# root pos: %f %f",disk->ldsk->coord->lonlat[0],disk->ldsk->coord->lonlat[1]);
-
-  PhyML_Printf("\n %13s %13s %13s %13s %13s %13s %13s %13s %13s",
-               "lnL",
-               "lbda",
-               "mu",
-               "rad",
-               "nInt",
-               "nCoal",
-               "nHit",
-               "xRootLon",
-               "xRootLat");
-
-  /* gtk_widget_queue_draw(tree->draw_area); */
-  /* sleep(2); */
-
-  do
-    {
-      u = Uni();
-
-      For(move,tree->mcmc->n_moves) if(tree->mcmc->move_weight[move] > u) break;
-      
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_lbda"))
-        MCMC_MIGREP_Lbda(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_mu"))
-        MCMC_MIGREP_Mu(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_rad"))
-        MCMC_MIGREP_Radius(tree);
-
-      /* if(!strcmp(tree->mcmc->move_name[move],"migrep_triplet")) */
-      /*   MCMC_MIGREP_Triplet(tree); */
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_delete_disk"))
-        MCMC_MIGREP_Delete_Disk(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_insert_disk"))
-        MCMC_MIGREP_Insert_Disk(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_move_disk_ct"))
-        MCMC_MIGREP_Move_Disk_Centre(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_move_disk_ud"))
-        MCMC_MIGREP_Move_Disk_Updown(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_swap_disk"))
-        MCMC_MIGREP_Swap_Disk(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_delete_hit"))
-        MCMC_MIGREP_Delete_Hit(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_insert_hit"))
-        MCMC_MIGREP_Insert_Hit(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_move_ldsk"))
-        MCMC_MIGREP_Move_Ldsk(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_shift_ldsk_to_centre"))
-        MCMC_MIGREP_Shift_Ldsk_To_Centre(tree);
-
-      if(!strcmp(tree->mcmc->move_name[move],"migrep_shift_centr_to_median"))
-        MCMC_MIGREP_Shift_Centre_To_Median(tree);
-
-      tree->mcmc->run++;
-      MCMC_Get_Acc_Rates(tree->mcmc);
-      
-      if(!(tree->mcmc->run%tree->mcmc->sample_interval))
-        PhyML_Printf("\n %13f %13f %13f %13f %13d %13d %13d %13f %13f",
-                     tree->mmod->c_lnL,
-                     tree->mmod->lbda,
-                     tree->mmod->mu,
-                     tree->mmod->rad,
-                     MIGREP_Total_Number_Of_Intervals(tree),
-                     MIGREP_Total_Number_Of_Coal_Disks(tree),
-                     MIGREP_Total_Number_Of_Hit_Disks(tree),
-                     disk->ldsk->coord->lonlat[0],
-                     disk->ldsk->coord->lonlat[1]);
-    }
-  while(tree->mcmc->run < tree->mcmc->chain_len);
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
-phydbl MIGREP_Wrap_Lk(t_edge *b, t_tree *tree, supert_tree *stree)
-{
-  return MIGREP_Lk(tree);
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
-void MIGREP_New_Traj(t_dsk *start, t_dsk *end, t_tree *tree)
-{
-  t_dsk *disk;
-  int i,j;
-  int n_hit_up,n_hit_tot;
-  phydbl min_up, min_do;
-  phydbl max_up, max_do;
-
-
-
-  For(i,start->n_ldsk_a)
-    {      
-      /* printf("\n<><><>"); */
-
-      disk = end;
-      while(disk != start)
-        {
-          disk->ldsk_a[i]->min_coord = GEO_Make_Geo_Coord(disk->mmod->n_dim);
-          disk->ldsk_a[i]->max_coord = GEO_Make_Geo_Coord(disk->mmod->n_dim);                    
-          disk = disk->prev;
-        }
-
-      disk = end;
-      n_hit_tot = 0;
-      while(disk != start)
-        {
-          if(disk->ldsk_a[i]->is_hit == YES) n_hit_tot++;
-          disk = disk->prev;
-        }
-
-
-      /* printf("\n. n_hit_tot: %d",n_hit_tot); */
-      /* fflush(NULL); */
-
-      /* printf("\n. Start disk name: %s lindisk %s at %.2f [%.2f %.2f] end disk: %s lindisk %s at %.2f [%.2f %.2f]", */
-      /*        start->id, */
-      /*        start->ldsk_a[i]->coord->id, */
-      /*        start->time, */
-      /*        start->ldsk_a[i]->coord->lonlat[0], */
-      /*        start->ldsk_a[i]->coord->lonlat[1], */
-      /*        end->id, */
-      /*        end->ldsk_a[i]->coord->id, */
-      /*        end->time, */
-      /*        end->ldsk_a[i]->coord->lonlat[0], */
-      /*        end->ldsk_a[i]->coord->lonlat[1] */
-      /*        ); */
-      /* disk = end; */
-      /* while(disk != start) */
-      /*   { */
-      /*     printf("\n. %d %s %.2f %.2f", */
-      /*            i, */
-      /*            disk->ldsk_a[i]->coord->id, */
-      /*            disk->ldsk_a[i]->coord->lonlat[0], */
-      /*            disk->ldsk_a[i]->coord->lonlat[1]); */
-      /*     disk = disk->prev; */
-      /*   } */
-      
-      n_hit_up = 0;
-      disk = end;
-      while(disk->prev != start)
-        {
-          if(disk->ldsk_a[i]->is_hit == YES)
-            {              
-              n_hit_up++;
-
-              For(j,disk->mmod->n_dim)
-                {
-                  min_up = end->ldsk_a[i]->coord->lonlat[j] - n_hit_up * 2. * disk->mmod->rad;
-                  min_do = start->ldsk_a[i]->coord->lonlat[j] - (n_hit_tot - n_hit_up) * 2. * disk->mmod->rad;
-                  disk->ldsk_a[i]->prev->min_coord->lonlat[j] = 
-                    MAX(MAX(MAX(min_up,min_do),0.0),disk->prev->centr->lonlat[j] - disk->mmod->rad);
-
-                  max_up = end->ldsk_a[i]->coord->lonlat[j] + n_hit_up * 2. * disk->mmod->rad;
-                  max_do = start->ldsk_a[i]->coord->lonlat[j] + (n_hit_tot - n_hit_up) * 2. * disk->mmod->rad;
-                  disk->ldsk_a[i]->prev->max_coord->lonlat[j] = 
-                    MIN(MIN(MIN(max_up,max_do),disk->mmod->lim->lonlat[j]),disk->prev->centr->lonlat[j] + disk->mmod->rad);
-
-                  /* printf("\n. curr: %s min_up: %.2f min_do: %.2f max_up: %.2f max_do: %.2f %d %d start: %.2f [%.2f %.2f]", */
-                  /*        disk->ldsk_a[i]->prev->coord->id, */
-                  /*        min_up,min_do,max_up,max_do, */
-                  /*        n_hit_tot,n_hit_up, */
-                  /*        start->ldsk_a[i]->coord->lonlat[j], */
-                  /*        disk->ldsk_a[i]->prev->min_coord->lonlat[j], */
-                  /*        disk->ldsk_a[i]->prev->max_coord->lonlat[j]); */
-                }
-            }
-          disk = disk->prev;
-        }
-      
-      disk = end;
-      while(disk->prev != start)
-        {
-          if(disk->ldsk_a[i]->is_hit == YES)
-            {
-              For(j,disk->mmod->n_dim)
-                disk->ldsk_a[i]->prev->coord->lonlat[j] = 
-                Uni()*
-                (disk->ldsk_a[i]->prev->max_coord->lonlat[j]  -
-                 disk->ldsk_a[i]->prev->min_coord->lonlat[j]) +
-                disk->ldsk_a[i]->prev->min_coord->lonlat[j];
-            }
-          else
-            {
-              For(j,disk->mmod->n_dim)
-                disk->ldsk_a[i]->prev->coord->lonlat[j] = 
-                disk->ldsk_a[i]->coord->lonlat[j];
-            }
-
-          disk = disk->prev;
-        }
-      
-      disk = end;
-      while(disk != start)
-        {
-          Free_Geo_Coord(disk->ldsk_a[i]->min_coord);
-          Free_Geo_Coord(disk->ldsk_a[i]->max_coord);
-          disk = disk->prev;
-        }
-    }
-
-  /* gtk_widget_queue_draw(tree->draw_area); */
-  
-  /* For(i,start->n_ldsk_a) */
-  /*   { */
-  /*     printf("\n<><><>"); */
-  /*     disk = end; */
-  /*     while(disk != start) */
-  /*       { */
-  /*         printf("\nx %s %.2f %.2f centr: %.2f %.2f", */
-  /*                disk->ldsk_a[i]->coord->id, */
-  /*                disk->ldsk_a[i]->coord->lonlat[0], */
-  /*                disk->ldsk_a[i]->coord->lonlat[1], */
-  /*                disk->centr->lonlat[0], */
-  /*                disk->centr->lonlat[1]); */
-  /*         disk = disk->prev; */
-  /*       } */
-  /*     fflush(NULL); */
-  /*   } */
-  
-  /* MIGREP_Lk(tree); */
-  /* printf("\n. >> Lk: %f rad: %f",tree->mmod->c_lnL,tree->mmod->rad); */
-  /* sleep(5); */
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-void MIGREP_Remove_Disk(t_dsk *disk)
-{
-  t_dsk *prev;
-  t_dsk *next;
-
-  prev = disk->prev;
-  next = disk->next;
-
-  /* printf("\n. Remove disk %s (prev: %s next: %s)", */
-  /*        disk->id, */
-  /*        prev?prev->id:NULL, */
-  /*        next?next->id:NULL); fflush(NULL); */
-
-  if(prev == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  if(next == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
-  
-  prev->next = next;
-  next->prev = prev;
-
-  /* printf(" set %s->next to %s and %s->prev to %s", */
-  /*        prev->id,prev->next->id, */
-  /*        next->id,next->prev->id); fflush(NULL); */
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-/* Insert disk event. disk->prev and disk->next need to be set 
-   accordingly. 
-*/
-void MIGREP_Insert_Disk(t_dsk *disk)
-{
-
-  if(disk->prev == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
-  if(disk->next == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
-  if(disk->prev->time > disk->time) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  if(disk->next->time < disk->time) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-
-  /* printf("\n. Insert disk %s @ %f between %s and %s", */
-  /*        disk->id,disk->time, */
-  /*        disk->prev->id, */
-  /*        disk->next->id); */
-  /* fflush(NULL); */
-
-  disk->prev->next = disk;
-  disk->next->prev = disk;
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-t_ldsk *MIGREP_Prev_Coal_Lindisk(t_ldsk *t)
-{
-  if(t == NULL) return NULL;
-
-  if(t->is_coal == YES) 
-    {
-      return t;
-    }
-  else
-    {
-      return MIGREP_Prev_Coal_Lindisk(t->prev);
-    }
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
-t_ldsk *MIGREP_Next_Coal_Lindisk(t_ldsk *t)
-{
-  if(t == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
-
-  if(t->is_coal == YES || t->next == NULL) return t;
-  else
-    {
-      if(t->n_next > 1) // Should have t->is_coal = YES
-        {
-          PhyML_Printf("\n== Err. in file %s at line %d (function '%s') \n",__FILE__,__LINE__,__FUNCTION__);
-          Warn_And_Exit("");
-        }
-      return MIGREP_Next_Coal_Lindisk(t->next[0]);
-    }
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-/*  Generate a new trajectory, including disk event centers, between  
-    'y_ldsk' a ``young'' lindisk event and 'o_ldsk' an old one. 'y_ldsk 
-    and 'o_ldsk' remain unaffected. No disk events should be present    
-    between y_ldsk and o_ldsk: we need to generate some first. n_cur_disk
-    is the current number of disks between y_ldsk and o_ldsk.
-*/
-int MIGREP_One_New_Traj(t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y, t_dsk *xtra_dsk, int n_cur_disk, t_tree *tree)
-{
-  t_migrep_mod *mmod;
-  t_dsk *disk,**disk_new;
-  int i,n,K;
-  int min_n_disk,n_new_disk,n_disk;
-
-  mmod     = tree->mmod;
-  disk     = NULL;
-  disk_new = NULL;
-  K        = 2;
-
-  /* printf("\n# New traj from %s to %s",y_ldsk->coord->id,o_ldsk->coord->id); */
-  /* fflush(NULL); */
-
-  /* Minimum number of disks between y_ldsk and o_ldsk */
-  min_n_disk = 0;
-  For(i,mmod->n_dim)
-    {
-      /* PhyML_Printf("\n# y_ldsk %s : %f o_ldsk->disk->centr: %f rad: %f", */
-      /*              y_ldsk->coord->id, */
-      /*              y_ldsk->coord->lonlat[i], */
-      /*              o_ldsk->disk->centr->lonlat[i], */
-      /*              mmod->rad); */
-      if(y_ldsk->coord->lonlat[i] < o_ldsk->disk->centr->lonlat[i])
-        {
-          n_disk = 0;
-          while(y_ldsk->coord->lonlat[i] + (2*n_disk-1)*mmod->rad < o_ldsk->disk->centr->lonlat[i] - mmod->rad) n_disk++;
-          if(n_disk > min_n_disk) min_n_disk = n_disk;
-        }
-      else
-        {
-          n_disk = 0;
-          while(y_ldsk->coord->lonlat[i] - (2*n_disk-1)*mmod->rad > o_ldsk->disk->centr->lonlat[i] + mmod->rad) n_disk++;
-          if(n_disk > min_n_disk) min_n_disk = n_disk;
-        }
-      /* printf("  -- min_n_disk: %d",min_n_disk); */
-    }
-  
-  /* printf("\n# min_n_disk: %d cur_n_disk: %d",min_n_disk,n_cur_disk); */
-  /* fflush(NULL); */
-  
-  /* How many disks along the new path between y_ldsk and o_ldsk */
-  n_new_disk = Rand_Int(n_cur_disk-K,n_cur_disk+K);
-  if(n_new_disk < min_n_disk) n_new_disk = min_n_disk;
-
-  if(xtra_dsk != NULL) n_new_disk++;
-
-  /* printf("\n# Add n_new_disk: %d",n_new_disk); fflush(NULL); */
-  
-  if(n_new_disk > 0)
-    {
-      /* Make new disks to create a new path between ldsk_left and ldsk_up */
-      disk_new = (t_dsk **)mCalloc(n_new_disk,sizeof(t_dsk *));
-      For(i,n_new_disk-1)  disk_new[i] = MIGREP_Make_Disk_Event(mmod->n_dim,tree->n_otu);
-      if(xtra_dsk != NULL) disk_new[n_new_disk-1] = xtra_dsk;
-      else                 disk_new[n_new_disk-1] = MIGREP_Make_Disk_Event(mmod->n_dim,tree->n_otu);
-
-      For(i,n_new_disk)  MIGREP_Init_Disk_Event(disk_new[i],mmod->n_dim,mmod);
-
-      /* Times of these new disks. If xtra_dsk != NULL, then make sure you do not */
-      /* reset the time of that disk  */
-      n = (xtra_dsk != NULL) ? (n_new_disk-1) : (n_new_disk);
-      For(i,n)
-        disk_new[i]->time =
-        Uni()*(y_ldsk->disk->time - o_ldsk->disk->time) + o_ldsk->disk->time;       
-     
-      /* Insert these events */
-      For(i,n_new_disk)
-        {
-          if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-          disk = tree->disk;
-          while(disk->time > disk_new[i]->time) disk = disk->prev;
-          disk_new[i]->prev = disk;
-          disk_new[i]->next = disk->next;
-          MIGREP_Insert_Disk(disk_new[i]);
-        }
-            
-      /* For(i,n_new_disk) */
-      /*   { */
-      /*     printf("\n> disk_new: %f [%s]",disk_new[i]->time,disk_new[i]->id); fflush(NULL); */
-      /*   } */
-      
-      /* Add new lindisks to the new disk events */
-      For(i,n_new_disk)
-        {
-          disk_new[i]->ldsk = MIGREP_Make_Lindisk_Node(tree->mmod->n_dim);
-          MIGREP_Init_Lindisk_Node(disk_new[i]->ldsk,disk_new[i],tree->mmod->n_dim);
-          MIGREP_Make_Lindisk_Next(disk_new[i]->ldsk);
-          /* printf("\n# Add ldsk %s to %s",disk_new[i]->ldsk->coord->id,disk_new[i]->id); fflush(NULL); */
-        }
-      
-      /* Connect them */
-      MIGREP_Connect_Ldsk_Given_Disk(disk_new,n_new_disk,y_ldsk,o_ldsk,dir_o_y);
-
-      Free(disk_new);
-    }
-  else
-    {
-      o_ldsk->next[dir_o_y] = y_ldsk;
-      y_ldsk->prev          = o_ldsk;
-    }
- 
-  /* Generate a trajectory */
-  MIGREP_One_New_Traj_Given_Disk(y_ldsk,o_ldsk);  
-
-  return(n_new_disk);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-/* Generate a new trajectory, including disk event centers, between 
-  'y_ldsk' a ``young'' lindisk event and 'o_ldsk' an old one. 'y_ldsk 
-  and 'o_ldsk' remain unaffected. Disk events between these two ldsk 
-  should already be set. 
-*/
-void MIGREP_One_New_Traj_Given_Disk(t_ldsk *y_ldsk, t_ldsk *o_ldsk)
-{
-  int n_disk_btw;
-  t_ldsk *ldsk;
-  phydbl min, max;
-  int i,k;
-  phydbl rad;
-
-  /* Number of disks between y_ldsk and o_ldsk */
-  ldsk = y_ldsk;
-  n_disk_btw = 0;
-  while(ldsk->prev != o_ldsk)
-    {
-      n_disk_btw++;
-      ldsk = ldsk->prev;
-    }
-
-  if(n_disk_btw == 0) return;
-
-  /* printf("\n# Number of disks between %s and %s: %d",y_ldsk->coord->id,o_ldsk->coord->id,n_disk_btw); */
-  /* fflush(NULL); */
-
-  ldsk = y_ldsk;
-  rad  = ldsk->disk->mmod->rad;
-  k    = 0;
-  while(ldsk->prev != o_ldsk)
-    {
-      /* printf("\n## ldsk %s at %f disk: %s ",ldsk->coord->id,ldsk->disk->time,ldsk->disk->id); */
-      /* fflush(NULL); */
-
-      For(i,ldsk->disk->mmod->n_dim)
-        {
-          min = 
-            MAX(0.0,
-                MAX(ldsk->coord->lonlat[i] - 2.*rad,
-                    o_ldsk->disk->centr->lonlat[i] - rad*(2.*(n_disk_btw-k)-1.)));
-
-          max = 
-            MIN(ldsk->disk->mmod->lim->lonlat[i],
-                MIN(ldsk->coord->lonlat[i] + 2.*rad,
-                    o_ldsk->disk->centr->lonlat[i] + rad*(2.*(n_disk_btw-k)-1.)));
-          
-          /* printf("\n## ldsk %s max: %f min:%f cur: %f %f %f set to %f n_disk_btw: %d y_ldsk: %f o_ldsk: %f rad: %f", */
-          /*        ldsk->prev->coord->id, */
-          /*        max,min, */
-          /*        ldsk->coord->lonlat[i], */
-          /*        ldsk->coord->lonlat[i] + 2.*rad, */
-          /*        o_ldsk->disk->centr->lonlat[i] + rad*(2.*(n_disk_btw-k)-1.), */
-          /*        ldsk->prev->coord->lonlat[i],n_disk_btw, */
-          /*        y_ldsk->coord->lonlat[i], */
-          /*        o_ldsk->disk->centr->lonlat[i], */
-          /*        rad); */
-
-          if(max < min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-                
-          /* New coordinate for the lindisk */
-          ldsk->prev->coord->lonlat[i] = Uni()*(max - min) + min;
-
-          /* if(y_ldsk->coord->lonlat[i] < o_ldsk->coord->lonlat[i]) */
-          /*   { */
-          /*     ldsk->prev->coord->lonlat[i] = Rexp_Trunc(1.0,min,max); */
-
-          /*     if(ldsk->prev->coord->lonlat[i] < min+(max-min)/2.) */
-          /*       ldsk->prev->coord->lonlat[i] += 2.*FABS(ldsk->prev->coord->lonlat[i] - (min+(max-min)/2.)); */
-          /*     else */
-          /*       ldsk->prev->coord->lonlat[i] -= 2.*FABS(ldsk->prev->coord->lonlat[i] - (min+(max-min)/2.)); */
-          /*   } */
-          /* else */
-          /*   { */
-          /*     ldsk->prev->coord->lonlat[i] = Rexp_Trunc(1.0,min,max); */
-          /*   } */
-
-
-
-          /* New coordinate for the centre of the corresponding disk event */
-          max = MIN(ldsk->disk->mmod->lim->lonlat[i],MIN(ldsk->coord->lonlat[i],ldsk->prev->coord->lonlat[i]) + rad);
-          min = MAX(0.0,MAX(ldsk->coord->lonlat[i],ldsk->prev->coord->lonlat[i]) - rad);
-          ldsk->prev->disk->centr->lonlat[i] = Uni()*(max - min) + min;
-
-          /* printf("\n. Set disk for %s [%f] %s [%f] at [%f] max: %f min: %f %s", */
-          /*        ldsk->coord->id, */
-          /*        ldsk->coord->lonlat[i], */
-          /*        ldsk->prev->coord->id, */
-          /*        ldsk->prev->coord->lonlat[i], */
-          /*        ldsk->prev->disk->centr->lonlat[i],max,min, */
-          /*        o_ldsk->coord->id); */
-
-          /* ldsk->prev->disk->centr->lonlat[i] = ldsk->coord->lonlat[i]; */
-        }
-      ldsk = ldsk->prev;
-      k++;
-    }
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-phydbl MIGREP_Uniform_Path_Density(t_ldsk *y_ldsk, t_ldsk *o_ldsk)
-{
-  int n_disk_btw;
-  t_ldsk *ldsk;
-  phydbl min, max;
-  int i,k;
-  phydbl rad;
-  phydbl log_dens;
-
-  if(y_ldsk == o_ldsk) return .0;
-
-  /* Number of disks between y_ldsk and o_ldsk */
-  ldsk = y_ldsk;
-  n_disk_btw = 0;
-  while(ldsk->prev != o_ldsk)
-    {
-      n_disk_btw++;
-      ldsk = ldsk->prev;
-    }
-
-  if(n_disk_btw == 0) return(0.0);
-
-  /* printf("\n. Number of disks between %s and %s: %d",y_ldsk->coord->id,o_ldsk->coord->id,n_disk_btw); */
-  /* fflush(NULL); */
-
-  log_dens = 0.0;
-  ldsk     = y_ldsk;
-  rad      = ldsk->disk->mmod->rad;
-  k        = 0;
-  while(ldsk->prev != o_ldsk)
-    {
-      /* printf("\n. ldsk %s at %f disk: %s ",ldsk->coord->id,ldsk->disk->time,ldsk->disk->id); */
-      /* fflush(NULL); */
-
-      For(i,ldsk->disk->mmod->n_dim)
-        {
-          min = 
-            MAX(0.0,
-                MAX(ldsk->coord->lonlat[i] - 2.*rad,
-                    o_ldsk->disk->centr->lonlat[i] - rad*(2.*(n_disk_btw-k)-1.)));
-
-          max = 
-            MIN(ldsk->disk->mmod->lim->lonlat[i],
-                MIN(ldsk->coord->lonlat[i] + 2.*rad,
-                    o_ldsk->disk->centr->lonlat[i] + rad*(2.*(n_disk_btw-k)-1.)));
-
-          /* printf("\n+ ldsk %s max: %f min:%f",ldsk->coord->id,max,min); */
-
-          if(max < min) 
-            {
-              PhyML_Printf("\n== max: %f min: %f coord %d: %f",
-                           max,min,i,ldsk->coord->lonlat[i]);
-              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-            }
-
-          log_dens -= LOG(max - min);
-          /* log_dens += LOG(Dexp_Trunc(ldsk->prev->coord->lonlat[i],1.,min,max)); */
-
-          max = MIN(ldsk->disk->mmod->lim->lonlat[i],MIN(ldsk->coord->lonlat[i],ldsk->prev->coord->lonlat[i]) + rad);
-          min = MAX(0.0,MAX(ldsk->coord->lonlat[i],ldsk->prev->coord->lonlat[i]) - rad);
-          log_dens -= LOG(max - min);
-
-        }
-      ldsk = ldsk->prev;
-      k++;
-    }
-  log_dens -= k*LOG(y_ldsk->disk->time - o_ldsk->disk->time);
-  return(log_dens);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-/* Return the index of the 'next' element of 'old' that should be
-   used in order to reach 'young'. 
-*/
-int MIGREP_Get_Next_Direction(t_ldsk *young, t_ldsk *old)
-{
-  if(young->disk->time < old->disk->time)
-    {
-      PhyML_Printf("\n== young (%s) @ time %f; old (%s) @ time %f",
-                   young->coord->id,young->disk->time,
-                   old->coord->id,old->disk->time);
-      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
-    }
-
-  if(young == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
-
-  if(young->prev == old)
-    {
-      int i;
-      For(i,old->n_next) if(old->next[i] == young) return i;
-    }
-  else
-    {
-      return MIGREP_Get_Next_Direction(young->prev,old);
-    }
-  return(-1);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-/* void MIGREP_Update_Lindisk_List(phydbl time, t_ldsk **list, int *pos, t_dsk *disk) */
-/* { */
-/*   t_dsk *root_dsk; */
-
-/*   *pos = 0; */
-/*   root_dsk = disk; */
-/*   while(root_dsk->prev) root_dsk = root_dsk->prev; */
-/*   /\* printf("\n. root_dsk: %s",root_dsk?root_dsk->id:"xx"); *\/ */
-/*   MIGREP_Update_Lindisk_List_Pre(root_dsk->ldsk,time,list,pos); */
-/* } */
-
-/* /\*\//////////////////////////////////////////////////////////// */
-/* ////////////////////////////////////////////////////////////\*\/ */
-
-/* void MIGREP_Update_Lindisk_List_Pre(t_ldsk *ldsk, phydbl time, t_ldsk **list, int *pos) */
-/* { */
-/*   /\* printf("\n. time: %f pos: %d ldsk: %s disk: %s n_next: %d ldsk->disk->time: %f disk: %s", *\/ */
-/*   /\*        time, *\/ */
-/*   /\*        *pos, *\/ */
-/*   /\*        ldsk ? ldsk->coord->id : "xx", *\/ */
-/*   /\*        ldsk ? ldsk->disk->id : "zz", *\/ */
-/*   /\*        ldsk ? ldsk->n_next : -1, *\/ */
-/*   /\*        ldsk ? ldsk->disk->time : -1., *\/ */
-/*   /\*        ldsk ? ldsk->disk->id : "yy"); fflush(NULL); *\/ */
-
-/*   if(ldsk == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
-
-/*   if((ldsk->prev != NULL) && (ldsk->disk->time > time) && (ldsk->prev->disk->time < time)) */
-/*     { */
-/*       list[*pos] = ldsk; */
-/*       *pos = *pos + 1; */
-/*     } */
-/*   else if(Are_Equal(ldsk->disk->time,time,1.E-10)) */
-/*     { */
-/*       list[*pos] = ldsk; */
-/*       *pos = *pos + 1;       */
-/*     } */
-/*   else if(ldsk->disk->time < time) */
-/*     { */
-/*       int i; */
-/*       For(i,ldsk->n_next) */
-/*         MIGREP_Update_Lindisk_List_Pre(ldsk->next[i],time,list,pos);     */
-/*     } */
-/*   else Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
-    
-/* } */
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-void MIGREP_Update_Lindisk_List(t_tree *tree)
-{
-  MIGREP_Update_Lindisk_List_Pre(tree->disk->prev);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-void MIGREP_Update_Lindisk_List_Pre(t_dsk *disk)
-{
-  if(!disk) return;
-  else
-    {
-      int i;
-      disk->n_ldsk_a = 0;
-      For(i,disk->next->n_ldsk_a)
-        {
-          if(disk->next->ldsk_a[i]->prev != disk->ldsk)
-            {
-              disk->ldsk_a[disk->n_ldsk_a] = disk->next->ldsk_a[i];
-              disk->n_ldsk_a++;
-            }
-        }
-      
-      if(disk->ldsk) 
-        {
-          disk->ldsk_a[disk->n_ldsk_a] = disk->ldsk;
-          disk->n_ldsk_a++;          
-        }
-
-      if(disk->n_ldsk_a == 0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-      MIGREP_Update_Lindisk_List_Pre(disk->prev);    
-    }
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-
-/* Connect all the ldsk between y_ldsk (young ldsk) and o_ldsk (old ldsk).
-   The disk between y_ldsk and o_ldsk should have all been set already
-   Note: the disks in **disk are sorted in ascending order of their 
-   times
-*/
-
-void MIGREP_Connect_Ldsk_Given_Disk(t_dsk **disk, int n_disk, t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y)
-{
-  int i,j;
-  t_dsk *disk_tmp;
-
-  /* Sort these events by ascending order of their times */
-  For(i,n_disk-1)
-    {
-      for(j=i+1;j<n_disk;j++)
-        {
-          if(disk[j]->time > disk[i]->time)
-            {
-              disk_tmp = disk[i];
-              disk[i]  = disk[j];
-              disk[j]  = disk_tmp;
-            }
-        }
-    }
-
-
-  For(i,n_disk)
-    {
-      if(!i)
-        {
-          disk[i]->ldsk->next[0] = y_ldsk;
-          y_ldsk->prev           = disk[i]->ldsk;
-          /* printf("\n. connect %s to %s",disk[i]->ldsk->coord->id,y_ldsk->coord->id); fflush(NULL); */
-        }
-      else
-        {
-          disk[i]->ldsk->next[0] = disk[i-1]->ldsk;
-          disk[i-1]->ldsk->prev  = disk[i]->ldsk;
-          /* printf("\n. connect %s to %s",disk[i]->ldsk->coord->id,disk[i-1]->ldsk->coord->id); fflush(NULL); */
-        }
-    }
-  
-  /* printf("\n. connect %s next dir: %d [%d] to %s",o_ldsk->coord->id,dir_o_y,o_ldsk->n_next,disk[n_disk-1]->ldsk->coord->id); fflush(NULL); */
-  o_ldsk->next[dir_o_y]      = disk[n_disk-1]->ldsk;
-  disk[n_disk-1]->ldsk->prev = o_ldsk;
-
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-void MIGREP_Print_Struct(char sign, t_tree *tree)
-{
-  t_dsk *disk;
-  int i,j;
-  t_ldsk *ldisk;
-
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  do
-    {
-      printf("\n%c Disk: %s @ %7.3f has %3s on it is_coal? %2d rad: %f",
-             sign,
-             disk->id,
-             disk->time,disk->ldsk?disk->ldsk->coord->id:NULL,
-             disk->ldsk?disk->ldsk->is_coal:-1,
-             tree->mmod->rad); fflush(NULL);
-
-      /* MIGREP_Update_Lindisk_List(disk->time,disk->ldsk_a,&(disk->n_ldsk_a),disk); */
-      MIGREP_Update_Lindisk_List(tree);
-
-      For(i,disk->n_ldsk_a)
-        {
-          ldisk = disk->ldsk_a[i];
-
-          printf("\n%c ldisk: %s prev: %s",
-                 sign,
-                 ldisk->coord->id,
-                 ldisk->prev ? ldisk->prev->coord->id : NULL);
-
-          For(j,tree->mmod->n_dim) PhyML_Printf(" %f ",ldisk->coord->lonlat[j]);
-        }
-
-      disk = disk->next;      
-    }
-  while(disk);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-void MIGREP_Check_Struct(t_tree *tree)
-{
-  t_dsk *disk;
-  int i,j;
-  t_ldsk *ldisk;
-
-  disk = tree->disk;
-  while(disk->prev) disk = disk->prev;
-  do
-    {
-      /* MIGREP_Update_Lindisk_List(disk->time,disk->ldsk_a,&(disk->n_ldsk_a),disk); */
-      MIGREP_Update_Lindisk_List(tree);
-
-      For(i,disk->n_ldsk_a)
-        {
-          ldisk = disk->ldsk_a[i];
-          if(ldisk->prev != NULL)
-            {
-              For(j,tree->mmod->n_dim)
-                {
-                  if(FABS(ldisk->coord->lonlat[j] - 
-                          ldisk->prev->coord->lonlat[j]) > 2.*tree->mmod->rad)
-                    {
-                      MIGREP_Print_Struct('=',tree);
-                      PhyML_Printf("\n== %f %f %f",
-                                   ldisk->coord->lonlat[j], 
-                                   ldisk->prev->coord->lonlat[j],
-                                   2.*tree->mmod->rad);
-                      PhyML_Printf("\n== Radius: %f",tree->mmod->rad);
-                      PhyML_Printf("\n== Check ldsk %s",ldisk->coord->id);
-                      PhyML_Printf("\n== Centr: %f",ldisk->prev->disk->centr->lonlat[j]);
-                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-                    }
-                }
-            }
-        }
-
-      disk = disk->next;      
-    }
-  while(disk);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-t_geo_coord *MIGREP_Copy_Geo_Coord(t_geo_coord *ori)
-{
-  t_geo_coord *cpy;
-  int i;
-
-  cpy = GEO_Make_Geo_Coord(ori->dim);
-  cpy->dim = ori->dim;
-
-  For(i,ori->dim) cpy->lonlat[i] = ori->lonlat[i];
-  strcpy(cpy->id,ori->id);
-
-  return cpy;
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-int MIGREP_Total_Number_Of_Intervals(t_tree *tree)
-{
-  t_dsk *disk;
-  int n_intervals;
-
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-
-  disk = tree->disk;
-  n_intervals = 0;
-  while(disk->prev)
-    {
-      n_intervals++;
-      disk = disk->prev;
-    }
-  return(n_intervals);
-
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-int MIGREP_Total_Number_Of_Hit_Disks(t_tree *tree)
-{
-  t_dsk *disk;
-  int n_hit_disks;
-
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-
-  disk = tree->disk;
-  n_hit_disks = 0;
-  while(disk)
-    {
-      if(disk->ldsk) n_hit_disks++;
-      disk = disk->prev;
-    }
-  return(n_hit_disks);
-
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-int MIGREP_Total_Number_Of_Coal_Disks(t_tree *tree)
-{
-  t_dsk *disk;
-  int n_coal_disks;
-
-  if(tree->disk->next) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-  disk = tree->disk;
-  n_coal_disks = 0;
-  while(disk)
-    {
-      if(disk->ldsk && disk->ldsk->is_coal == YES) n_coal_disks++;
-      disk = disk->prev;
-    }
-
-  return(n_coal_disks);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-phydbl MIGREP_Log_Dunif_Rectangle_Overlap(t_dsk *disk, t_migrep_mod *mmod)
-{
-  phydbl up, down, left, rght;
-
-  up   = MIN(disk->centr->lonlat[0] + mmod->rad, mmod->lim->lonlat[0]);
-  down = MAX(disk->centr->lonlat[0] - mmod->rad, 0.0);
-  rght = MIN(disk->centr->lonlat[1] + mmod->rad, mmod->lim->lonlat[1]);
-  left = MAX(disk->centr->lonlat[1] - mmod->rad, 0.0);
-
-  /* printf("\n. disk %s up: %f down: %f rght: %f left: %f", */
-  /*        disk->id, */
-  /*        up,down,rght,left); */
-
-  return(LOG(up-down)+LOG(rght-left));
-
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/* Samples uniformly within a rectangle (with truncation for border) */
-/* and returns the corresponding log density */
-phydbl MIGREP_Runif_Rectangle_Overlap(t_ldsk *ldsk, t_dsk *disk, t_migrep_mod *mmod)
-{
-  phydbl up, down, left, rght;
-
-  up   = MIN(disk->centr->lonlat[0] + mmod->rad, mmod->lim->lonlat[0]);
-  down = MAX(disk->centr->lonlat[0] - mmod->rad, 0.0);
-  rght = MIN(disk->centr->lonlat[1] + mmod->rad, mmod->lim->lonlat[1]);
-  left = MAX(disk->centr->lonlat[1] - mmod->rad, 0.0);
-
-  ldsk->coord->lonlat[0] = Uni()*(up - down) + down;
-  ldsk->coord->lonlat[1] = Uni()*(rght - left) + left;
-
-  /* printf("\n. disk %s (%f %f) rad: %f up: %f down: %f rght: %f left: %f", */
-  /*        disk->id, */
-  /*        disk->centr->lonlat[0], */
-  /*        disk->centr->lonlat[1], */
-  /*        mmod->rad, */
-  /*        up,down,rght,left); */
-  return(LOG(up-down)+LOG(rght-left));
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-phydbl MIGREP_Wrap_Prior_Radius(t_edge *e, t_tree *tree, supert_tree *st)
-{
-  return MIGREP_LnPrior_Radius(tree);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-phydbl MIGREP_LnPrior_Radius(t_tree *tree)
-{
-  tree->mmod->c_ln_prior_rad = LOG(tree->mmod->prior_param_rad) - tree->mmod->prior_param_rad * tree->mmod->rad;
-  return(tree->mmod->c_ln_prior_rad);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-void MIGREP_Initial_Ldsk_Pos(t_tree *tree)
-{
-  t_dsk *disk;
-  int i,j;
-  phydbl mean;
-
-  disk = tree->disk->prev;
-
-  do
-    {
-      if(disk->ldsk)
-        {
-          For(i,tree->mmod->n_dim)
-            {
-              mean = 0.0;
-              For(j,disk->ldsk->n_next) mean += disk->ldsk->next[j]->coord->lonlat[i];
-              disk->ldsk->coord->lonlat[i] = mean / (phydbl)disk->ldsk->n_next;
-            }
-        }
-      disk = disk->prev;
-    }
-  while(disk);
-
-
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-
-phydbl MIGREP_Min_Radius(t_tree *tree)
-{
-  phydbl ori_rad, min_rad;
-
-  ori_rad = tree->mmod->rad;
-  tree->mmod->rad = tree->mmod->max_rad;
-  do
-    {
-      MIGREP_Lk(tree);
-      tree->mmod->rad -= 1.0;
-    }
-  while(tree->mmod->c_lnL > UNLIKELY + 0.1);
-
-  min_rad = tree->mmod->rad + 2.0;
-  tree->mmod->rad = ori_rad;
-  MIGREP_Lk(tree);
-  return(min_rad);
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/* Get the minimum and maximum values a ldsk can take, given the position of the disk centre */
-void MIGREP_Get_Min_Max_Ldsk_Given_Disk(t_ldsk *ldsk, phydbl **min, phydbl **max, t_tree *tree)
-{
-  phydbl *loc_min,*loc_max;
-  int i;
-
-  if(!ldsk->disk->next) return;
-
-  loc_min = (phydbl *)mCalloc(tree->mmod->n_dim, sizeof(phydbl));
-  loc_max = (phydbl *)mCalloc(tree->mmod->n_dim, sizeof(phydbl));
-
-  For(i,tree->mmod->n_dim)
-    {
-      loc_min[i] = ldsk->disk->centr->lonlat[i] - tree->mmod->rad;
-      loc_max[i] = ldsk->disk->centr->lonlat[i] + tree->mmod->rad;     
-    }
-
-  (*min) = loc_min;
-  (*max) = loc_max;
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/* Get the minimum and maximum values a disk centre can take, given the position of the ldsk */
-void MIGREP_Get_Min_Max_Disk_Given_Ldsk(t_dsk *disk, phydbl **min, phydbl **max, t_tree *tree)
-{
-  phydbl *loc_min,*loc_max;
-  int i,j;
-  phydbl tmp_min, tmp_max;
-
-  if(!disk->next) return;
-
-  loc_min = (phydbl *)mCalloc(tree->mmod->n_dim,sizeof(phydbl));
-  loc_max = (phydbl *)mCalloc(tree->mmod->n_dim,sizeof(phydbl));
-
-  if(!disk->ldsk)
-    {
-      For(i,tree->mmod->n_dim)
-        {
-          loc_min[i] = 0.0;
-          loc_max[i] = tree->mmod->lim->lonlat[i];
-        }
-    }
-  else
-    {
-      For(i,tree->mmod->n_dim)
-        {
-          tmp_min = +INFINITY;
-          tmp_max = -INFINITY;
-          For(j,disk->ldsk->n_next)
-            {
-              if(disk->ldsk->next[j]->coord->lonlat[i] < tmp_min) tmp_min = disk->ldsk->next[j]->coord->lonlat[i];
-              if(disk->ldsk->next[j]->coord->lonlat[i] > tmp_max) tmp_max = disk->ldsk->next[j]->coord->lonlat[i];
-            }
-
-          if(disk->ldsk->coord->lonlat[i] < tmp_min) tmp_min = disk->ldsk->coord->lonlat[i];
-          if(disk->ldsk->coord->lonlat[i] > tmp_max) tmp_max = disk->ldsk->coord->lonlat[i];
-
-          loc_min[i] = MAX(0.0,
-                           tmp_max - tree->mmod->rad);
-
-          loc_max[i] = MIN(tree->mmod->lim->lonlat[i], 
-                           tmp_min + tree->mmod->rad);
-                    
-          if(loc_max[i] < loc_min[i]) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
-        }
-    }
-
-  (*min) = loc_min;
-  (*max) = loc_max;
-}
-
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
-/*////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////*/
diff --git a/src/migrep.h b/src/migrep.h
deleted file mode 100644
index 21a558c..0000000
--- a/src/migrep.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-
-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 <config.h>
-
-#ifndef MIGREP_H
-#define MIGREP_H
-
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <pthread.h>
-#include "utilities.h"
-
-t_tree *MIGREP_Simulate_Backward(int n_otu, phydbl width, phydbl height);
-int MIGREP_Main(int argc, char **argv);
-phydbl MIGREP_Lk(t_tree *tree);
-phydbl MIGREP_Wrap_Lk(t_edge *b, t_tree *tree, supert_tree *stree);
-void MIGREP_MCMC(t_tree *tree);
-int MIGREP_Is_In_Disk(t_geo_coord *coord, t_dsk *disk);
-void MIGREP_New_Traj(t_dsk *start, t_dsk *end, t_tree *tree);
-int MIGREP_Draw(GtkWidget *widget, cairo_t *cr, gpointer *data);
-void MIGREP_Remove_Disk(t_dsk *disk);
-void MIGREP_Insert_Disk(t_dsk *disk);
-t_ldsk *MIGREP_Prev_Coal_Lindisk(t_ldsk *t);
-t_ldsk *MIGREP_Next_Coal_Lindisk(t_ldsk *t);
-int MIGREP_Get_Next_Direction(t_ldsk *young, t_ldsk *old);
-void MIGREP_One_New_Traj_Given_Disk(t_ldsk *s_ldsk, t_ldsk *e_ldsk);
-void MIGREP_Update_Lindisk_List(t_tree *tree);
-void MIGREP_Update_Lindisk_List_Pre(t_dsk *disk);
-/* void MIGREP_Update_Lindisk_List(phydbl time, t_ldsk **list, int *pos, t_dsk *disk); */
-/* void MIGREP_Update_Lindisk_List_Pre(t_ldsk *ldsk, phydbl time, t_ldsk **list, int *pos); */
-void MIGREP_Connect_Ldsk_Given_Disk(t_dsk **disk, int n_disk, t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y);
-void MIGREP_Print_Struct(char sign, t_tree *tree);
-phydbl MIGREP_Uniform_Path_Density(t_ldsk *y_ldsk, t_ldsk *o_ldsk);
-void MIGREP_Check_Struct(t_tree *tree);
-t_geo_coord *MIGREP_Copy_Geo_Coord(t_geo_coord *orig);
-int MIGREP_Total_Number_Of_Intervals(t_tree *tree);
-int MIGREP_Total_Number_Of_Coal_Disks(t_tree *tree);
-int MIGREP_Total_Number_Of_Hit_Disks(t_tree *tree);
-phydbl MIGREP_Log_Dunif_Rectangle_Overlap(t_dsk *disk, t_migrep_mod *mmod);
-phydbl MIGREP_Runif_Rectangle_Overlap(t_ldsk *ldsk, t_dsk *disk, t_migrep_mod *mod);
-int MIGREP_One_New_Traj(t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y, t_dsk *xtra_dsk, int n_cur_disk, t_tree *tree);
-phydbl MIGREP_Wrap_Prior_Radius(t_edge *e, t_tree *tree, supert_tree *st);
-phydbl MIGREP_LnPrior_Radius(t_tree *tree);
-void MIGREP_Initial_Ldsk_Pos(t_tree *tree);
-phydbl MIGREP_Min_Radius(t_tree *tree);
-void MIGREP_Get_Min_Max_Disk_Given_Ldsk(t_dsk *disk, phydbl **min, phydbl **max, t_tree *tree);
-void MIGREP_Get_Min_Max_Ldsk_Given_Disk(t_ldsk *ldsk, phydbl **min, phydbl **max, t_tree *tree);
-
-#endif
diff --git a/src/mixt.c b/src/mixt.c
index 6115493..5aa980a 100644
--- a/src/mixt.c
+++ b/src/mixt.c
@@ -1760,7 +1760,8 @@ void MIXT_Bootstrap(char *best_tree, xml_node *root)
       sprintf(xml_boot_file_name+strlen(xml_boot_file_name),"%d",pid);
       strcat(xml_boot_file_name,".xml");
 
-      out_attr = XML_Search_Attribute(root,"outputfile");
+      out_attr = XML_Search_Attribute(root,"output.file");
+      assert(out_attr);
       boot_out_file_name = (char *)mCalloc(T_MAX_NAME,sizeof(char));
       strcpy(boot_out_file_name,out_attr->value);
       s = XML_Get_Attribute_Value(root,"run.id");
@@ -1780,10 +1781,12 @@ void MIXT_Bootstrap(char *best_tree, xml_node *root)
           /*! Set the number of bootstrap repeats to 0
             in each generated XML file */
           boot_attr = XML_Search_Attribute(boot_root,"bootstrap");
+          assert(boot_attr);
           strcpy(boot_attr->value,"0");
 
           /*! Set the output file name for each bootstrap analysis */
-          boot_out_attr = XML_Search_Attribute(boot_root,"outputfile");
+          boot_out_attr = XML_Search_Attribute(boot_root,"output.file");
+          assert(boot_out_attr);
           buff = (char *)mCalloc(T_MAX_NAME,sizeof(char));
           strcpy(buff,boot_out_attr->value);
           Free(boot_out_attr->value);
@@ -1803,8 +1806,9 @@ void MIXT_Bootstrap(char *best_tree, xml_node *root)
               /*! Get the original sequence file name and the corresponding
                 attribute in the XML graph
               */
-              seqfile_attr    = NULL;
-              seqfile_attr    = XML_Search_Attribute(p_elem,"filename");
+              seqfile_attr = NULL;
+              seqfile_attr = XML_Search_Attribute(p_elem,"file.name");
+              assert(seqfile_attr);
 
               strcpy(orig_align,seqfile_attr->value);
 
@@ -1871,7 +1875,7 @@ void MIXT_Bootstrap(char *best_tree, xml_node *root)
             {
               p_elem = XML_Search_Node_Name("partitionelem",YES,p_elem);
               if(!p_elem) break;
-              seqfile_attr = XML_Search_Attribute(p_elem,"filename");
+              seqfile_attr = XML_Search_Attribute(p_elem,"file.name");
               /* unlink(seqfile_attr->value); */
             }
           while(p_elem);
@@ -1918,7 +1922,13 @@ phydbl MIXT_Get_Mean_Edge_Len(t_edge *mixt_b, t_tree *mixt_tree)
   n    = 0 ;
   do
     {
-      sum += b->l->v;
+      if(tree->is_mixt_tree == YES)
+        {
+          tree = tree->next;
+          b    = b->next;
+        }
+
+      sum += b->l->v * tree->mixt_tree->mod->br_len_mult->v;
       n++;
       b    = b->next;
       tree = tree->next;
@@ -1926,7 +1936,6 @@ phydbl MIXT_Get_Mean_Edge_Len(t_edge *mixt_b, t_tree *mixt_tree)
   while(b);
 
   return(sum / (phydbl)n);
-
 }
 
 //////////////////////////////////////////////////////////////
diff --git a/src/models.c b/src/models.c
index 0a1174e..a2eebd0 100644
--- a/src/models.c
+++ b/src/models.c
@@ -82,8 +82,6 @@ void PMat_K80(phydbl l, phydbl kappa, int pos, phydbl *Pij)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
-
 void PMat_TN93(phydbl l, t_mod *mod, int pos, phydbl *Pij)
 {
   int i,j;
@@ -279,50 +277,50 @@ void PMat_Empirical(phydbl l, t_mod *mod, int pos, phydbl *Pij)
   For (i,n)
     {
       For (j,n)
-    {
-      For(k,n)
         {
-          Pij[pos+mod->ns*i+j] += (uexpt[i*n+k] * V[k*n+j]);
+          For(k,n)
+            {
+              Pij[pos+mod->ns*i+j] += (uexpt[i*n+k] * V[k*n+j]);
+            }
+          /* 	  if(Pij[pos+mod->ns*i+j] < SMALL) Pij[pos+mod->ns*i+j] = SMALL; */
+          if(Pij[pos+mod->ns*i+j] < SMALL_PIJ) Pij[pos+mod->ns*i+j] = SMALL_PIJ;
         }
-/* 	  if(Pij[pos+mod->ns*i+j] < SMALL) Pij[pos+mod->ns*i+j] = SMALL; */
-      if(Pij[pos+mod->ns*i+j] < SMALL_PIJ) Pij[pos+mod->ns*i+j] = SMALL_PIJ;
-    }
-
+      
 #ifndef PHYML
       phydbl sum;
       sum = .0;
       For (j,n) sum += Pij[pos+mod->ns*i+j];
       if((sum > 1.+.0001) || (sum < 1.-.0001))
-    {
-      PhyML_Printf("\n");
-      PhyML_Printf("\n. Q\n");
-      For(i,n) { For(j,n) PhyML_Printf("%7.3f ",mod->eigen->q[i*n+j]); PhyML_Printf("\n"); }
-      PhyML_Printf("\n. U\n");
-      For(i,n) { For(j,n) PhyML_Printf("%7.3f ",U[i*n+j]); PhyML_Printf("\n"); }
-      PhyML_Printf("\n");
-      PhyML_Printf("\n. V\n");
-      For(i,n) { For(j,n) PhyML_Printf("%7.3f ",V[i*n+j]); PhyML_Printf("\n"); }
-      PhyML_Printf("\n");
-      PhyML_Printf("\n. Eigen\n");
-      For(i,n)  PhyML_Printf("%E ",expt[i]);
-      PhyML_Printf("\n");
-      PhyML_Printf("\n. Pij\n");
-      For(i,n) { For (j,n) PhyML_Printf("%f ",Pij[pos+mod->ns*i+j]); PhyML_Printf("\n"); }
-      PhyML_Printf("\n. sum = %f",sum);
-      if(mod->m4mod)
-        {
-          int i;
-          PhyML_Printf("\n. mod->m4mod->alpha = %f",mod->m4mod->alpha);
-          PhyML_Printf("\n. mod->m4mod->delta = %f",mod->m4mod->delta);
-          For(i,mod->m4mod->n_h)
         {
-          PhyML_Printf("\n. mod->m4mod->multipl[%d] = %f",i,mod->m4mod->multipl[i]);
-        }
+          PhyML_Printf("\n");
+          PhyML_Printf("\n. Q\n");
+          For(i,n) { For(j,n) PhyML_Printf("%7.3f ",mod->eigen->q[i*n+j]); PhyML_Printf("\n"); }
+          PhyML_Printf("\n. U\n");
+          For(i,n) { For(j,n) PhyML_Printf("%7.3f ",U[i*n+j]); PhyML_Printf("\n"); }
+          PhyML_Printf("\n");
+          PhyML_Printf("\n. V\n");
+          For(i,n) { For(j,n) PhyML_Printf("%7.3f ",V[i*n+j]); PhyML_Printf("\n"); }
+          PhyML_Printf("\n");
+          PhyML_Printf("\n. Eigen\n");
+          For(i,n)  PhyML_Printf("%E ",expt[i]);
+          PhyML_Printf("\n");
+          PhyML_Printf("\n. Pij\n");
+          For(i,n) { For (j,n) PhyML_Printf("%f ",Pij[pos+mod->ns*i+j]); PhyML_Printf("\n"); }
+          PhyML_Printf("\n. sum = %f",sum);
+          if(mod->m4mod)
+            {
+              int i;
+              PhyML_Printf("\n. mod->m4mod->alpha = %f",mod->m4mod->alpha);
+              PhyML_Printf("\n. mod->m4mod->delta = %f",mod->m4mod->delta);
+              For(i,mod->m4mod->n_h)
+                {
+                  PhyML_Printf("\n. mod->m4mod->multipl[%d] = %f",i,mod->m4mod->multipl[i]);
+                }
+            }
+          PhyML_Printf("\n. l=%f",l);
+          PhyML_Printf("\n. Err in file %s at line %d\n\n",__FILE__,__LINE__);
+          Warn_And_Exit("");
         }
-      PhyML_Printf("\n. l=%f",l);
-      PhyML_Printf("\n. Err in file %s at line %d\n\n",__FILE__,__LINE__);
-      Warn_And_Exit("");
-    }
 #endif
     }
 }
@@ -636,13 +634,11 @@ void Update_Qmat_Generic(phydbl *rr, phydbl *pi, int ns, phydbl *qmat)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Update_Qmat_GTR(phydbl *rr, phydbl *rr_val, int *rr_num, phydbl *pi, phydbl *qmat)
 {
   int i;
   phydbl mr;
 
-
   For(i,6) rr[i] = rr_val[rr_num[i]];
   For(i,6)
     if(rr[i] < 0.0)
@@ -652,10 +648,12 @@ void Update_Qmat_GTR(phydbl *rr, phydbl *rr_val, int *rr_num, phydbl *pi, phydbl
         Exit("");
       }
 
-  For(i,6) rr[i] /= rr[5];
+  For(i,6) rr[i] /= MAX(rr[5],RR_MIN);
   For(i,6) if(rr[i] < RR_MIN) rr[i] = RR_MIN;
   For(i,6) if(rr[i] > RR_MAX) rr[i] = RR_MAX;
 
+  For(i,6) if(isnan(rr[i])) Generic_Exit(__FILE__,__LINE__,__FUNCTION__); 
+
   qmat[0*4+1] = (rr[0]*pi[1]);
   qmat[0*4+2] = (rr[1]*pi[2]);
   qmat[0*4+3] = (rr[2]*pi[3]);
@@ -679,7 +677,7 @@ void Update_Qmat_GTR(phydbl *rr, phydbl *rr_val, int *rr_num, phydbl *pi, phydbl
 
   /* compute diagonal terms of Q and mean rate mr = l/t */
   mr = .0;
-  For (i,4) mr += pi[i] * (-qmat[i*4+i]);
+  For(i,4) mr += pi[i] * (-qmat[i*4+i]);
   For(i,16) qmat[i] /= mr;
 
   /* int j; */
@@ -768,9 +766,9 @@ void Translate_Custom_Mod_String(t_mod *mod)
       mod->r_mat->n_rr_per_cat->v[mod->r_mat->rr_num->v[j]]++;
     }
   
-  /*   PhyML_Printf("\n"); */
-  /*   For(i,6) PhyML_Printf("%d ",mod->rr_param_num[i]); */
-  /*   For(i,mod->n_diff_rr_param) PhyML_Printf("\n. Class %d size %d",i+1,mod->r_mat->n_rr_param_per_cat[i]); */
+    /* PhyML_Printf("\n"); */
+    /* For(i,6) PhyML_Printf("%d ",mod->r_mat->rr_num->v[i]); */
+    /* For(i,mod->r_mat->n_diff_rr) PhyML_Printf("\n. Class %d size %d",i+1,mod->r_mat->n_rr_per_cat->v[i]); */
 }
 
 //////////////////////////////////////////////////////////////
@@ -783,16 +781,15 @@ void Update_RAS(t_mod *mod)
   phydbl sum;
   int i;
 
-  if(mod->ras->free_mixt_rates == NO) DiscreteGamma(mod->ras->gamma_r_proba->v,
-                            mod->ras->gamma_rr->v,
-                            mod->ras->alpha->v,
-                            mod->ras->alpha->v,
-                            mod->ras->n_catg,
-                            mod->ras->gamma_median);
+  if(mod->ras->free_mixt_rates == NO) 
+    DiscreteGamma(mod->ras->gamma_r_proba->v,
+                  mod->ras->gamma_rr->v,
+                  mod->ras->alpha->v,
+                  mod->ras->alpha->v,
+                  mod->ras->n_catg,
+                  mod->ras->gamma_median);
   else
     {
-
-
       if(mod->ras->sort_rate_classes == YES)
         {
           Qksort(mod->ras->gamma_r_proba_unscaled->v,NULL,0,mod->ras->n_catg-1); // Unscaled class frequencies sorted in increasing order
@@ -880,7 +877,10 @@ void Update_Efrq(t_mod *mod)
               if(mod->e_frq->pi->v[i] > 0.99) mod->e_frq->pi->v[i]=0.99;
               sum += mod->e_frq->pi->v[i];
             }
-          For(i,mod->ns) mod->e_frq->pi->v[i]/=sum;
+          For(i,mod->ns) 
+            {
+              mod->e_frq->pi->v[i]/=sum;
+            }
         }
       while((sum > 1.01) || (sum < 0.99));
 
diff --git a/src/mpi_boot.c b/src/mpi_boot.c
index 1c01961..86e7a0e 100644
--- a/src/mpi_boot.c
+++ b/src/mpi_boot.c
@@ -207,7 +207,7 @@ fflush(stderr);
       
       if((boot_tree->mod->s_opt->random_input_tree) && (boot_tree->mod->s_opt->topo_search == SPR_MOVE)) Random_Tree(boot_tree);
 
-      Connect_CSeqs_To_Nodes(boot_data,boot_tree);
+      Connect_CSeqs_To_Nodes(boot_data,boot_tree->io,boot_tree);
       Share_Lk_Struct(tree,boot_tree);
       Share_Spr_Struct(tree,boot_tree);
       Share_Pars_Struct(tree,boot_tree);
@@ -420,7 +420,7 @@ void Print_Fp_Out_Lines_MPI(t_tree *tree, option *io, int n_data_set, char *boot
 
     strncat (s, "taxa\t", T_MAX_LINE);
 
-    strncat (s, "LOGlk     \t", T_MAX_LINE);
+    strncat (s, "loglk     \t", T_MAX_LINE);
 
     strncat (s, "gamma model\t", T_MAX_LINE);
 
diff --git a/src/mxml.h b/src/mxml.h
new file mode 100644
index 0000000..d020158
--- /dev/null
+++ b/src/mxml.h
@@ -0,0 +1,329 @@
+/*
+ * "$Id: mxml.h 427 2011-01-03 02:03:29Z mike $"
+ *
+ * Header file for Mini-XML, a small XML-like file parsing library.
+ *
+ * Copyright 2003-2011 by Michael R Sweet.
+ *
+ * These coded instructions, statements, and computer programs are the
+ * property of Michael R Sweet and are protected by Federal copyright
+ * law.  Distribution and use rights are outlined in the file "COPYING"
+ * which should have been included with this file.  If this file is
+ * missing or damaged, see the license at:
+ *
+ *     http://www.minixml.org/
+ */
+
+/*
+ * Prevent multiple inclusion...
+ */
+
+#ifndef _mxml_h_
+#  define _mxml_h_
+
+/*
+ * Include necessary headers...
+ */
+
+#  include <stdio.h>
+#  include <stdlib.h>
+#  include <string.h>
+#  include <ctype.h>
+#  include <errno.h>
+
+
+/*
+ * Constants...
+ */
+
+#  define MXML_TAB		8	/* Tabs every N columns */
+
+#  define MXML_NO_CALLBACK	0	/* Don't use a type callback */
+#  define MXML_INTEGER_CALLBACK	mxml_integer_cb
+					/* Treat all data as integers */
+#  define MXML_OPAQUE_CALLBACK	mxml_opaque_cb
+					/* Treat all data as opaque */
+#  define MXML_REAL_CALLBACK	mxml_real_cb
+					/* Treat all data as real numbers */
+#  define MXML_TEXT_CALLBACK	0	/* Treat all data as text */
+#  define MXML_IGNORE_CALLBACK	mxml_ignore_cb
+					/* Ignore all non-element content */
+
+#  define MXML_NO_PARENT	0	/* No prev for the node */
+
+#  define MXML_DESCEND		1	/* Descend when finding/walking */
+#  define MXML_NO_DESCEND	0	/* Don't descend when finding/walking */
+#  define MXML_DESCEND_FIRST	-1	/* Descend for first find */
+
+#  define MXML_WS_BEFORE_OPEN	0	/* Callback for before open tag */
+#  define MXML_WS_AFTER_OPEN	1	/* Callback for after open tag */
+#  define MXML_WS_BEFORE_CLOSE	2	/* Callback for before close tag */
+#  define MXML_WS_AFTER_CLOSE	3	/* Callback for after close tag */
+
+#  define MXML_ADD_BEFORE	0	/* Add node before specified node */
+#  define MXML_ADD_AFTER	1	/* Add node after specified node */
+#  define MXML_ADD_TO_PARENT	NULL	/* Add node relative to prev */
+
+
+/*
+ * Data types...
+ */
+
+typedef enum mxml_sax_event_e		/**** SAX event type. ****/
+{
+  MXML_SAX_CDATA,			/* CDATA node */
+  MXML_SAX_COMMENT,			/* Comment node */
+  MXML_SAX_DATA,			/* Data node */
+  MXML_SAX_DIRECTIVE,			/* Processing directive node */
+  MXML_SAX_ELEMENT_CLOSE,		/* Element closed */
+  MXML_SAX_ELEMENT_OPEN			/* Element opened */
+} mxml_sax_event_t;
+
+typedef enum mxml_type_e		/**** The XML node type. ****/
+{
+  MXML_IGNORE = -1,			/* Ignore/throw away node @since Mini-XML 2.3@ */
+  MXML_ELEMENT,				/* XML element with attributes */
+  MXML_INTEGER,				/* Integer value */
+  MXML_OPAQUE,				/* Opaque string */
+  MXML_REAL,				/* Real value */
+  MXML_TEXT,				/* Text fragment */
+  MXML_CUSTOM				/* Custom data @since Mini-XML 2.1@ */
+} mxml_type_t;
+
+typedef void (*mxml_custom_destroy_cb_t)(void *);
+					/**** Custom data destructor ****/
+
+typedef void (*mxml_error_cb_t)(const char *);  
+					/**** Error callback function ****/
+
+typedef struct mxml_attr_s		/**** An XML element attribute value. @private@ ****/
+{
+  char			*name;		/* Attribute name */
+  char			*value;		/* Attribute value */
+} mxml_attr_t;
+
+typedef struct mxml_element_s		/**** An XML element value. @private@ ****/
+{
+  char			*name;		/* Name of element */
+  int			num_attrs;	/* Number of attributes */
+  mxml_attr_t		*attrs;		/* Attributes */
+} mxml_element_t;
+
+typedef struct mxml_text_s		/**** An XML text value. @private@ ****/
+{
+  int			whitespace;	/* Leading whitespace? */
+  char			*string;	/* Fragment string */
+} mxml_text_t;
+
+typedef struct mxml_custom_s		/**** An XML custom value. @private@ ****/
+{
+  void			*data;		/* Pointer to (allocated) custom data */
+  mxml_custom_destroy_cb_t destroy;	/* Pointer to destructor function */
+} mxml_custom_t;
+
+typedef union mxml_value_u		/**** An XML node value. @private@ ****/
+{
+  mxml_element_t	element;	/* Element */
+  int			integer;	/* Integer number */
+  char			*opaque;	/* Opaque string */
+  double		real;		/* Real number */
+  mxml_text_t		text;		/* Text fragment */
+  mxml_custom_t		custom;		/* Custom data @since Mini-XML 2.1@ */
+} mxml_value_t;
+
+struct mxml_node_s			/**** An XML node. @private@ ****/
+{
+  mxml_type_t		type;		/* Node type */
+  struct mxml_node_s	*next;		/* Next node under same prev */
+  struct mxml_node_s	*prev;		/* Previous node under same prev */
+  struct mxml_node_s	*prev;	/* Parent node */
+  struct mxml_node_s	*next;		/* First next node */
+  struct mxml_node_s	*last_next;	/* Last next node */
+  mxml_value_t		value;		/* Node value */
+  int			ref_count;	/* Use count */
+  void			*user_data;	/* User data */
+};
+
+typedef struct mxml_node_s mxml_node_t;	/**** An XML node. ****/
+
+struct mxml_index_s			 /**** An XML node index. @private@ ****/
+{
+  char			*attr;		/* Attribute used for indexing or NULL */
+  int			num_nodes;	/* Number of nodes in index */
+  int			alloc_nodes;	/* Allocated nodes in index */
+  int			cur_node;	/* Current node */
+  mxml_node_t		**nodes;	/* Node array */
+};
+
+typedef struct mxml_index_s mxml_index_t;
+					/**** An XML node index. ****/
+
+typedef int (*mxml_custom_load_cb_t)(mxml_node_t *, const char *);
+					/**** Custom data load callback function ****/
+
+typedef char *(*mxml_custom_save_cb_t)(mxml_node_t *);  
+					/**** Custom data save callback function ****/
+
+typedef int (*mxml_entity_cb_t)(const char *);
+					/**** Entity callback function */
+
+typedef mxml_type_t (*mxml_load_cb_t)(mxml_node_t *);
+					/**** Load callback function ****/
+
+typedef const char *(*mxml_save_cb_t)(mxml_node_t *, int);
+					/**** Save callback function ****/
+
+typedef void (*mxml_sax_cb_t)(mxml_node_t *, mxml_sax_event_t, void *);  
+					/**** SAX callback function ****/
+
+
+/*
+ * C++ support...
+ */
+
+#  ifdef __cplusplus
+extern "C" {
+#  endif /* __cplusplus */
+
+/*
+ * Prototypes...
+ */
+
+extern void		mxmlAdd(mxml_node_t *prev, int where,
+			        mxml_node_t *next, mxml_node_t *node);
+extern void		mxmlDelete(mxml_node_t *node);
+extern void		mxmlElementDeleteAttr(mxml_node_t *node,
+			                      const char *name);
+extern const char	*mxmlElementGetAttr(mxml_node_t *node, const char *name);
+extern void		mxmlElementSetAttr(mxml_node_t *node, const char *name,
+			                   const char *value);
+extern void		mxmlElementSetAttrf(mxml_node_t *node, const char *name,
+			                    const char *format, ...)
+#    ifdef __GNUC__
+__attribute__ ((__format__ (__printf__, 3, 4)))
+#    endif /* __GNUC__ */
+;
+extern int		mxmlEntityAddCallback(mxml_entity_cb_t cb);
+extern const char	*mxmlEntityGetName(int val);
+extern int		mxmlEntityGetValue(const char *name);
+extern void		mxmlEntityRemoveCallback(mxml_entity_cb_t cb);
+extern mxml_node_t	*mxmlFindElement(mxml_node_t *node, mxml_node_t *top,
+			                 const char *name, const char *attr,
+					 const char *value, int descend);
+extern mxml_node_t	*mxmlFindPath(mxml_node_t *node, const char *path);
+extern const char	*mxmlGetCDATA(mxml_node_t *node);
+extern const void	*mxmlGetCustom(mxml_node_t *node);
+extern const char	*mxmlGetElement(mxml_node_t *node);
+extern mxml_node_t	*mxmlGetFirstChild(mxml_node_t *node);
+extern int		mxmlGetInteger(mxml_node_t *node);
+extern mxml_node_t	*mxmlGetLastChild(mxml_node_t *node);
+extern mxml_node_t	*mxmlGetNextSibling(mxml_node_t *node);
+extern const char	*mxmlGetOpaque(mxml_node_t *node);
+extern mxml_node_t	*mxmlGetParent(mxml_node_t *node);
+extern mxml_node_t	*mxmlGetPrevSibling(mxml_node_t *node);
+extern double		mxmlGetReal(mxml_node_t *node);
+extern int		mxmlGetRefCount(mxml_node_t *node);
+extern const char	*mxmlGetText(mxml_node_t *node, int *whitespace);
+extern mxml_type_t	mxmlGetType(mxml_node_t *node);
+extern void		*mxmlGetUserData(mxml_node_t *node);
+extern void		mxmlIndexDelete(mxml_index_t *ind);
+extern mxml_node_t	*mxmlIndexEnum(mxml_index_t *ind);
+extern mxml_node_t	*mxmlIndexFind(mxml_index_t *ind,
+			               const char *element,
+			               const char *value);
+extern int		mxmlIndexGetCount(mxml_index_t *ind);
+extern mxml_index_t	*mxmlIndexNew(mxml_node_t *node, const char *element,
+			              const char *attr);
+extern mxml_node_t	*mxmlIndexReset(mxml_index_t *ind);
+extern mxml_node_t	*mxmlLoadFd(mxml_node_t *top, int fd,
+			            mxml_type_t (*cb)(mxml_node_t *));
+extern mxml_node_t	*mxmlLoadFile(mxml_node_t *top, FILE *fp,
+			              mxml_type_t (*cb)(mxml_node_t *));
+extern mxml_node_t	*mxmlLoadString(mxml_node_t *top, const char *s,
+			                mxml_type_t (*cb)(mxml_node_t *));
+extern mxml_node_t	*mxmlNewCDATA(mxml_node_t *prev, const char *string);
+extern mxml_node_t	*mxmlNewCustom(mxml_node_t *prev, void *data,
+			               mxml_custom_destroy_cb_t destroy);
+extern mxml_node_t	*mxmlNewElement(mxml_node_t *prev, const char *name);
+extern mxml_node_t	*mxmlNewInteger(mxml_node_t *prev, int integer);
+extern mxml_node_t	*mxmlNewOpaque(mxml_node_t *prev, const char *opaque);
+extern mxml_node_t	*mxmlNewReal(mxml_node_t *prev, double real);
+extern mxml_node_t	*mxmlNewText(mxml_node_t *prev, int whitespace,
+			             const char *string);
+extern mxml_node_t	*mxmlNewTextf(mxml_node_t *prev, int whitespace,
+			              const char *format, ...)
+#    ifdef __GNUC__
+__attribute__ ((__format__ (__printf__, 3, 4)))
+#    endif /* __GNUC__ */
+;
+extern mxml_node_t	*mxmlNewXML(const char *version);
+extern int		mxmlRelease(mxml_node_t *node);
+extern void		mxmlRemove(mxml_node_t *node);
+extern int		mxmlRetain(mxml_node_t *node);
+extern char		*mxmlSaveAllocString(mxml_node_t *node,
+			        	     mxml_save_cb_t cb);
+extern int		mxmlSaveFd(mxml_node_t *node, int fd,
+			           mxml_save_cb_t cb);
+extern int		mxmlSaveFile(mxml_node_t *node, FILE *fp,
+			             mxml_save_cb_t cb);
+extern int		mxmlSaveString(mxml_node_t *node, char *buffer,
+			               int bufsize, mxml_save_cb_t cb);
+extern mxml_node_t	*mxmlSAXLoadFd(mxml_node_t *top, int fd,
+			               mxml_type_t (*cb)(mxml_node_t *),
+			               mxml_sax_cb_t sax, void *sax_data);
+extern mxml_node_t	*mxmlSAXLoadFile(mxml_node_t *top, FILE *fp,
+			                 mxml_type_t (*cb)(mxml_node_t *),
+			                 mxml_sax_cb_t sax, void *sax_data);
+extern mxml_node_t	*mxmlSAXLoadString(mxml_node_t *top, const char *s,
+			                   mxml_type_t (*cb)(mxml_node_t *),
+			                   mxml_sax_cb_t sax, void *sax_data);
+extern int		mxmlSetCDATA(mxml_node_t *node, const char *data);
+extern int		mxmlSetCustom(mxml_node_t *node, void *data,
+			              mxml_custom_destroy_cb_t destroy);
+extern void		mxmlSetCustomHandlers(mxml_custom_load_cb_t load,
+			                      mxml_custom_save_cb_t save);
+extern int		mxmlSetElement(mxml_node_t *node, const char *name);
+extern void		mxmlSetErrorCallback(mxml_error_cb_t cb);
+extern int		mxmlSetInteger(mxml_node_t *node, int integer);
+extern int		mxmlSetOpaque(mxml_node_t *node, const char *opaque);
+extern int		mxmlSetReal(mxml_node_t *node, double real);
+extern int		mxmlSetText(mxml_node_t *node, int whitespace,
+			            const char *string);
+extern int		mxmlSetTextf(mxml_node_t *node, int whitespace,
+			             const char *format, ...)
+#    ifdef __GNUC__
+__attribute__ ((__format__ (__printf__, 3, 4)))
+#    endif /* __GNUC__ */
+;
+extern int		mxmlSetUserData(mxml_node_t *node, void *data);
+extern void		mxmlSetWrapMargin(int column);
+extern mxml_node_t	*mxmlWalkNext(mxml_node_t *node, mxml_node_t *top,
+			              int descend);
+extern mxml_node_t	*mxmlWalkPrev(mxml_node_t *node, mxml_node_t *top,
+			              int descend);
+
+
+/*
+ * Semi-private functions...
+ */
+
+extern void		mxml_error(const char *format, ...);
+extern mxml_type_t	mxml_ignore_cb(mxml_node_t *node);
+extern mxml_type_t	mxml_integer_cb(mxml_node_t *node);
+extern mxml_type_t	mxml_opaque_cb(mxml_node_t *node);
+extern mxml_type_t	mxml_real_cb(mxml_node_t *node);
+
+
+/*
+ * C++ support...
+ */
+
+#  ifdef __cplusplus
+}
+#  endif /* __cplusplus */
+#endif /* !_mxml_h_ */
+
+
+/*
+ * End of "$Id: mxml.h 427 2011-01-03 02:03:29Z mike $".
+ */
diff --git a/src/nexus.c b/src/nexus.c
index b04d905..e0decc0 100644
--- a/src/nexus.c
+++ b/src/nexus.c
@@ -35,7 +35,7 @@ void Find_Nexus_Com(char *token, nexcom **found_com, nexparm **default_parm, nex
 
   if(*found_com && (*found_com)->nparm) *default_parm = (*found_com)->parm[0];
 
-  if(*found_com) PhyML_Printf("\n. Found command '%s'.\n",(*found_com)->name);
+  /* if(*found_com) PhyML_Printf("\n. Found command '%s'.\n",(*found_com)->name); */
 }
 
 //////////////////////////////////////////////////////////////
@@ -71,7 +71,7 @@ void Find_Nexus_Parm(char *token, nexparm **found_parm, nexcom *curr_com)
       if(!ndiff) { *found_parm = curr_com->parm[i]; break; }
     }
 
-  if(*found_parm) PhyML_Printf("\n. Found parameter '%s'.\n",(*found_parm)->name);
+  /* if(*found_parm) PhyML_Printf("\n. Found parameter '%s'.\n",(*found_parm)->name); */
 }
 
 //////////////////////////////////////////////////////////////
@@ -85,11 +85,11 @@ int Read_Nexus_Taxa(char *token, nexparm *curr_parm, option *io)
 
   do
     {
-      Get_Token(io->fp_in_tree,token);
+      Get_Token(io->fp_in_align,token);
       if(token[0] == ';') break;
     }while(strlen(token) > 0);
   
-  fseek(io->fp_in_tree,-1*sizeof(char),SEEK_CUR);
+  fseek(io->fp_in_align,-1*sizeof(char),SEEK_CUR);
 
   return 1;
 }
@@ -244,7 +244,7 @@ int Read_Nexus_Format(char *token, nexparm *curr_parm, option *io)
   strcpy(curr_parm->value,token);
 
 
-  printf("\n. >> %s",curr_parm->value);
+  /* printf("\n. >> %s",curr_parm->value); */
     
   if(!strcmp(curr_parm->name,"datatype"))
     {
@@ -293,15 +293,16 @@ int Read_Nexus_Format(char *token, nexparm *curr_parm, option *io)
 
   else if(!strcmp(curr_parm->name,"missing"))
     {
-      PhyML_Printf("\n== The 'missing' subcommand is not supported by PhyML. Sorry.\n");
+      PhyML_Printf("\n== The 'missing' subcommand is not supported by PhyML. Please remove it from the NEXUS file.");
+      PhyML_Printf("\n== Note that the characters 'X', '?' and '-' will be considered as indels by default."); 
       PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
       Exit("");
     }
 
   else if(!strcmp(curr_parm->name,"gap"))
     {
-      PhyML_Printf("\n== The 'gap' subcommand is not supported by PhyML. Sorry.\n");
-      PhyML_Printf("\n== But the characters 'X', '?' and '-' will be considered as indels by default.\n"); 
+      PhyML_Printf("\n== The 'gap' subcommand is not supported by PhyML. Please remove it from the NEXUS file.");
+      PhyML_Printf("\n== Note that the characters 'X', '?' and '-' will be considered as indels by default."); 
       PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
       Exit("");
     }
diff --git a/src/optimiz.c b/src/optimiz.c
index 6492273..6ddc17b 100644
--- a/src/optimiz.c
+++ b/src/optimiz.c
@@ -202,7 +202,7 @@ phydbl Generic_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol,
       Lk(NULL,tree);
       if(tree->c_lnL < init_lnL - tree->mod->s_opt->min_diff_lk_local)
         {
-          PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+          PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
           Warn_And_Exit("");
         }
       return tree->c_lnL;
@@ -241,7 +241,7 @@ phydbl Generic_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol,
       (*xmin) = FABS(u);
       fu = -Lk(NULL,tree);
 
-      PhyML_Printf("\n. iter=%d/%d param=%f LOGlk=%f",iter,BRENT_IT_MAX,*xmin,tree->c_lnL);
+      PhyML_Printf("\n. iter=%d/%d param=%f loglk=%f",iter,BRENT_IT_MAX,*xmin,tree->c_lnL);
 
 /*       if(fu <= fx) */
       if(fu < fx)
@@ -639,7 +639,7 @@ void Optimize_Br_Len_Serie(t_tree *tree)
       if(tree->c_lnL < lk_init - tree->mod->s_opt->min_diff_lk_local)
         {
           PhyML_Printf("\n== %f -- %f",lk_init,tree->c_lnL);
-          Warn_And_Exit("\n== Err. in Optimize_Br_Len_Serie_Post (variance)\n");
+          PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
         }
 
       if((tree->io->quiet)?(0):(tree->mod->s_opt->print))
@@ -680,9 +680,10 @@ void Optimize_Br_Len_Multiplier(t_tree *mixt_tree, int verbose)
   phydbl lk_init;
   t_tree *tree;
 
+
+
   tree = mixt_tree;
   
-
   do
     {      
       if(tree->mod->s_opt->opt_br_len_mult == YES)
@@ -708,7 +709,7 @@ void Optimize_Br_Len_Multiplier(t_tree *mixt_tree, int verbose)
   tree = mixt_tree;  
   do
     {      
-      if(verbose)
+      if(verbose && tree->mod->s_opt->opt_br_len_mult == YES)
         {
           Print_Lk(tree,"[Tree scale         ]");
           PhyML_Printf("[%10f]",tree->mod->br_len_mult->v);
@@ -761,7 +762,8 @@ void Optimize_Br_Len_Serie_Post(t_node *a, t_node *d, t_edge *b_fcus, t_tree *tr
       PhyML_Printf("\n== %f -- %f",lk_init,tree->c_lnL);
       PhyML_Printf("\n== Edge: %d",b_fcus->num);
       PhyML_Printf("\n== is_mixt_tree: %d",tree->is_mixt_tree);
-      Exit("\n== Err. in Optimize_Br_Len_Serie_Post\n");
+      PhyML_Printf("\n== Err. in file %s at line %d (function '%s') \n",__FILE__,__LINE__,__FUNCTION__);
+      Warn_And_Exit("");
     }
 
   if(d->tax) return;
@@ -902,93 +904,93 @@ void Optimiz_All_Free_Param(t_tree *tree, int verbose)
 
         }
 
-
+      
       if(tree->mod->s_opt->opt_cov_free_rates)
-    {
-      int rcat;
-
-      Switch_Eigen(YES,tree->mod);
-
-      For(rcat,tree->mod->m4mod->n_h)
         {
-/* 	      Optimize_Single_Param_Generic(tree,&(tree->mod->m4mod->multipl_unscaled[rcat]), */
-/* 					    .01,10., */
-/* 					    tree->mod->s_opt->min_diff_lk_local, */
-/* 					    tree->mod->s_opt->brent_it_max, */
-/* 					    tree->mod->s_opt->quickdirty); */
-
-          Generic_Brent_Lk(&(tree->mod->m4mod->multipl_unscaled[rcat]),
-                   0.1,100.,
-                   tree->mod->s_opt->min_diff_lk_local,
-                   tree->mod->s_opt->brent_it_max,
-                   tree->mod->s_opt->quickdirty,
-                   Wrap_Lk,NULL,tree,NULL,NO);
-
-          if(verbose)
-        {
-          Print_Lk(tree,"[Rel. subst. rate   ]");
-          PhyML_Printf("[%10f]",tree->mod->m4mod->multipl[rcat]);
-        }
-        }
-
-      For(rcat,tree->mod->m4mod->n_h)
-        {
-
-/*  	      Optimize_Single_Param_Generic(tree,&(tree->mod->m4mod->h_fq_unscaled[rcat]), */
-/* 					    .01,100., */
-/* 					    tree->mod->s_opt->min_diff_lk_local, */
-/* 					    tree->mod->s_opt->brent_it_max, */
-/* 					    tree->mod->s_opt->quickdirty); */
-
-          Generic_Brent_Lk(&(tree->mod->m4mod->h_fq_unscaled[rcat]),
-                   0.1,100.,
-                   tree->mod->s_opt->min_diff_lk_local,
-                   tree->mod->s_opt->brent_it_max,
-                   tree->mod->s_opt->quickdirty,
-                   Wrap_Lk,NULL,tree,NULL,NO);
-
-
-          if(verbose)
-        {
-          Print_Lk(tree,"[Subst. class freq  ]");
-          PhyML_Printf("[%10f]",tree->mod->m4mod->h_fq[rcat]);
-        }
+          int rcat;
+          
+          Switch_Eigen(YES,tree->mod);
+          
+          For(rcat,tree->mod->m4mod->n_h)
+            {
+              /* 	      Optimize_Single_Param_Generic(tree,&(tree->mod->m4mod->multipl_unscaled[rcat]), */
+              /* 					    .01,10., */
+              /* 					    tree->mod->s_opt->min_diff_lk_local, */
+              /* 					    tree->mod->s_opt->brent_it_max, */
+              /* 					    tree->mod->s_opt->quickdirty); */
+              
+              Generic_Brent_Lk(&(tree->mod->m4mod->multipl_unscaled[rcat]),
+                               0.1,100.,
+                               tree->mod->s_opt->min_diff_lk_local,
+                               tree->mod->s_opt->brent_it_max,
+                               tree->mod->s_opt->quickdirty,
+                               Wrap_Lk,NULL,tree,NULL,NO);
+              
+              if(verbose)
+                {
+                  Print_Lk(tree,"[Rel. subst. rate   ]");
+                  PhyML_Printf("[%10f]",tree->mod->m4mod->multipl[rcat]);
+                }
+            }
+          
+          For(rcat,tree->mod->m4mod->n_h)
+            {
+              
+              /*  	      Optimize_Single_Param_Generic(tree,&(tree->mod->m4mod->h_fq_unscaled[rcat]), */
+              /* 					    .01,100., */
+              /* 					    tree->mod->s_opt->min_diff_lk_local, */
+              /* 					    tree->mod->s_opt->brent_it_max, */
+              /* 					    tree->mod->s_opt->quickdirty); */
+              
+              Generic_Brent_Lk(&(tree->mod->m4mod->h_fq_unscaled[rcat]),
+                               0.1,100.,
+                               tree->mod->s_opt->min_diff_lk_local,
+                               tree->mod->s_opt->brent_it_max,
+                               tree->mod->s_opt->quickdirty,
+                               Wrap_Lk,NULL,tree,NULL,NO);
+              
+              
+              if(verbose)
+                {
+                  Print_Lk(tree,"[Subst. class freq  ]");
+                  PhyML_Printf("[%10f]",tree->mod->m4mod->h_fq[rcat]);
+                }
+            }
+          
+          Switch_Eigen(NO,tree->mod);
+          
         }
-
-      Switch_Eigen(NO,tree->mod);
-
-    }
-
+      
       if(tree->mod->s_opt->opt_cov_alpha)
-    {
-
-      Switch_Eigen(YES,tree->mod);
-
-/* 	  Optimize_Single_Param_Generic(tree,&(tree->mod->m4mod->ras->alpha), */
-/* 					.01,10., */
-/* 					tree->mod->s_opt->min_diff_lk_local, */
-/* 					tree->mod->s_opt->brent_it_max, */
-/* 					tree->mod->s_opt->quickdirty); */
-
-      Generic_Brent_Lk(&(tree->mod->m4mod->alpha),
-               0.01,10.,
-               tree->mod->s_opt->min_diff_lk_local,
-               tree->mod->s_opt->brent_it_max,
-               tree->mod->s_opt->quickdirty,
-               Wrap_Lk,NULL,tree,NULL,NO);
-
-
-      if(verbose)
         {
-          Print_Lk(tree,"[Alpha (covarion)   ]");
-          PhyML_Printf("[%10f]",tree->mod->m4mod->alpha);
+          
+          Switch_Eigen(YES,tree->mod);
+          
+          /* 	  Optimize_Single_Param_Generic(tree,&(tree->mod->m4mod->ras->alpha), */
+          /* 					.01,10., */
+          /* 					tree->mod->s_opt->min_diff_lk_local, */
+          /* 					tree->mod->s_opt->brent_it_max, */
+          /* 					tree->mod->s_opt->quickdirty); */
+          
+          Generic_Brent_Lk(&(tree->mod->m4mod->alpha),
+                           0.01,10.,
+                           tree->mod->s_opt->min_diff_lk_local,
+                           tree->mod->s_opt->brent_it_max,
+                           tree->mod->s_opt->quickdirty,
+                           Wrap_Lk,NULL,tree,NULL,NO);
+          
+          
+          if(verbose)
+            {
+              Print_Lk(tree,"[Alpha (covarion)   ]");
+              PhyML_Printf("[%10f]",tree->mod->m4mod->alpha);
+            }
+          
+          Switch_Eigen(NO,tree->mod);
+          
         }
-
-      Switch_Eigen(NO,tree->mod);
-
-    }
-
-
+      
+      
       /* Substitutions between nucleotides are considered to follow a
          GTR model */
       
@@ -996,21 +998,21 @@ void Optimiz_All_Free_Param(t_tree *tree, int verbose)
         {
           if(tree->mod->whichmodel == GTR || tree->mod->whichmodel == CUSTOM)
             {
-
+              
               Switch_Eigen(YES,tree->mod);
-
+              
               For(i,5) tree->mod->m4mod->o_rr[i] = LOG(tree->mod->m4mod->o_rr[i]);
-
+              
               failed = YES;
-
+              
               /* BFGS(tree,tree->mod->m4mod->o_rr,5,1.e-5,tree->mod->s_opt->min_diff_lk_local,1.e-5,NO,YES, */
               BFGS(tree,tree->mod->m4mod->o_rr,5,1.e-5,tree->mod->s_opt->min_diff_lk_local,1.e-5,YES,NO,
                    &Return_Abs_Lk,
                    &Num_Derivative_Several_Param,
                    &Lnsrch,&failed);
-
+              
               For(i,5) tree->mod->m4mod->o_rr[i] = EXP(tree->mod->m4mod->o_rr[i]);
-
+              
               For(i,5)
                 {
                   /* 	      Optimize_Single_Param_Generic(tree,&(tree->mod->m4mod->o_rr[i]), */
@@ -1099,18 +1101,21 @@ void BFGS(t_tree *tree,
   
   (*dfunc)(tree,p,n,step_size,logt,func,g,is_positive);
   
+  /* PhyML_Printf("\n. BFGS step_size: %f",step_size); */
+
   for (i=0;i<n;i++)
     {
       for (j=0;j<n;j++) hessin[i][j]=0.0;
       hessin[i][i]=1.0;
       xi[i] = -g[i];
       sum += p[i]*p[i];
+      /* PhyML_Printf("\n. BFGS x[%d]: %f p[i]: %f",i,xi[i],p[i]); */
     }
   
   stpmax=STPMX*MAX(SQRT(sum),(phydbl)n);
   for(its=1;its<=ITMAX;its++)
     {
-      /* PhyML_Printf("\n. BFGS -> %f\n",tree->c_lnL); */
+      /* PhyML_Printf("\n. BFGS -> %f stpmax: %f\n",tree->c_lnL,stpmax); */
       
       lnsrch(tree,n,p,fp,g,xi,pnew,&fret,stpmax,&check,logt,is_positive);
       
@@ -1461,27 +1466,29 @@ void BFGS_Nonaligned(t_tree *tree,
 #define TOLX 1.0e-7
 
 int Lnsrch(t_tree *tree, int n, phydbl *xold, phydbl fold,
-       phydbl *g, phydbl *p, phydbl *x,
-       phydbl *f, phydbl stpmax, int *check, int logt, int is_positive)
+           phydbl *g, phydbl *p, phydbl *x,
+           phydbl *f, phydbl stpmax, int *check, int logt, int is_positive)
 {
   int i;
   phydbl a,alam,alam2,alamin,b,disc,f2,fold2,rhs1,rhs2,slope,sum,temp,test,tmplam;
   phydbl *local_xold,*sign;
-
+  
   alam = alam2 = f2 = fold2 = tmplam = .0;
 
   local_xold = (phydbl *)mCalloc(n,sizeof(phydbl));
   sign       = (phydbl *)mCalloc(n,sizeof(phydbl));
 
   For(i,n) local_xold[i] = xold[i];
-
+  
   *check=0;
   for(sum=0.0,i=0;i<n;i++) sum += p[i]*p[i];
   sum=SQRT(sum);
-  if(sum > stpmax)
-    for(i=0;i<n;i++) p[i] *= stpmax/sum;
-  for(slope=0.0,i=0;i<n;i++)
-    slope += g[i]*p[i];
+  /* PhyML_Printf("\n. lnsrch sum: %f",sum); */
+  if(sum > stpmax) For(i,n) p[i] *= stpmax/sum;
+  /* For(i,n) PhyML_Printf("\n. lnsrch p[i]: %f",p[i]); */
+  slope=0.0;
+  For(i,n) slope += g[i]*p[i];
+  /* PhyML_Printf("\n. lnsrch slope: %f",slope); */
   test=0.0;
   for(i=0;i<n;i++)
     {
@@ -1492,61 +1499,65 @@ int Lnsrch(t_tree *tree, int n, phydbl *xold, phydbl fold,
   alam=1.0;
   for (;;)
     {
-      for(i=0;i<n;i++)
-    {
-      x[i]=local_xold[i]+alam*p[i];
-      xold[i] = x[i];
-    }
-
+      For(i,n)
+        {
+          x[i]=local_xold[i]+alam*p[i];
+          xold[i] = x[i];
+          /* PhyML_Printf("\n. lnsrch x[i]: %f",x[i]); */
+        }
+      
+      /* PhyML_Printf("\n. lnsrch loop slope: %f alam: %f alam2: %f",slope,alam,alam2); */
+      
       if(i==n)
-    {
+        {
           if(logt == YES) For(i,n) xold[i] = EXP(MIN(1.E+2,xold[i]));
           For(i,n) sign[i] = xold[i] < .0 ? -1. : 1.;
           if(is_positive == YES) For(i,n) xold[i] = FABS(xold[i]);
-      *f=Return_Abs_Lk(tree);
+          /* For(i,n) PhyML_Printf("\n. <<>> %f",xold[i]); */
+          *f=Return_Abs_Lk(tree);
           if(is_positive == YES) For(i,n) xold[i] *= sign[i];
           if(logt == YES) For(i,n) xold[i] = LOG(xold[i]);
-    }
+        }
       else *f=1.+fold+ALF*alam*slope;
       if (alam < alamin)
-    {
-      *check=1;
-      For(i,n) xold[i] = local_xold[i];
+        {
+          *check=1;
+          For(i,n) xold[i] = local_xold[i];
           if(is_positive == YES) For(i,n) xold[i] = FABS(xold[i]);
-      Free(local_xold);
-      Free(sign);
-      return 0;
-    }
+          Free(local_xold);
+          Free(sign);
+          return 0;
+        }
       else if (*f <= fold+ALF*alam*slope)
-    {
-      For(i,n) xold[i] = local_xold[i];
+        {
+          For(i,n) xold[i] = local_xold[i];
           if(is_positive == YES) For(i,n) xold[i] = FABS(xold[i]);
-      Free(local_xold);
+          Free(local_xold);
           Free(sign);
-      return 0;
-    }
-      else
-    {
-/* 	  if (alam == 1.0) */
-      if ((alam < 1.0+SMALL) && (alam > 1.0-SMALL))
-        tmplam = -slope/(2.0*(*f-fold-slope));
+          return 0;
+        }
       else
         {
-          rhs1 = *f-fold-alam*slope;
-          rhs2=f2-fold2-alam2*slope;
-          a=(rhs1/(alam*alam)-rhs2/(alam2*alam2))/(alam-alam2);
-          b=(-alam2*rhs1/(alam*alam)+alam*rhs2/(alam2*alam2))/(alam-alam2);
-          if (a < SMALL && a > -SMALL) tmplam = -slope/(2.0*b);
+          /* 	  if (alam == 1.0) */
+          if ((alam < 1.0+SMALL) && (alam > 1.0-SMALL))
+            tmplam = -slope/(2.0*(*f-fold-slope));
           else
-        {
-          disc=b*b-3.0*a*slope;
-          if (disc<0.0) tmplam = 0.5*alam;
-          else if(b <= 0.0) tmplam=(-b+SQRT(disc))/(3.0*a);
-          else tmplam = -slope/(b+SQRT(disc));
-        }
-          if (tmplam>0.5*alam) tmplam=0.5*alam;
+            {
+              rhs1 = *f-fold-alam*slope;
+              rhs2=f2-fold2-alam2*slope;
+              a=(rhs1/(alam*alam)-rhs2/(alam2*alam2))/(alam-alam2);
+              b=(-alam2*rhs1/(alam*alam)+alam*rhs2/(alam2*alam2))/(alam-alam2);
+              if (a < SMALL && a > -SMALL) tmplam = -slope/(2.0*b);
+              else
+                {
+                  disc=b*b-3.0*a*slope;
+                  if (disc<0.0) tmplam = 0.5*alam;
+                  else if(b <= 0.0) tmplam=(-b+SQRT(disc))/(3.0*a);
+                  else tmplam = -slope/(b+SQRT(disc));
+                }
+              if (tmplam>0.5*alam) tmplam=0.5*alam;
+            }
         }
-    }
       alam2=alam;
       f2 = *f;
       fold2=fold;
@@ -1818,7 +1829,7 @@ phydbl Dist_F_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, int n_iter_max,
       old_lnL = curr_lnL;
       fu = -Lk_Dist(F,FABS(u),mod);
       curr_lnL = -fu;
-/*       PhyML_Printf("param=%f LOGlk=%f\n",*param,fu); */
+/*       PhyML_Printf("param=%f loglk=%f\n",*param,fu); */
 
 /*       if(fu <= fx)  */
       if(fu < fx)
@@ -2007,7 +2018,7 @@ phydbl Missing_Dist_Brent(phydbl ax, phydbl bx, phydbl cx, phydbl tol, int n_ite
       u=(FABS(d) >= tol1 ? xx+d : xx+SIGN(tol1,d));
       fu = Least_Square_Missing_Dist_XY(x,y,FABS(u),mat);
 
-/*       PhyML_Printf("param=%f LOGlk=%f\n",u,fu); */
+/*       PhyML_Printf("param=%f loglk=%f\n",u,fu); */
 
 /*       if(fu <= fx)  */
       if(fu < fx)
@@ -2062,343 +2073,411 @@ void Opt_Missing_Dist(int x, int y, matrix *mat)
 
 int Optimiz_Alpha_And_Pinv(t_tree *mixt_tree, int verbose)
 {
-  t_tree *tree;
-  int    iter;
-  phydbl best_alpha, best_pinv, best_mult;
-  phydbl slope, intercept;
-  phydbl lk_b, lk_a;
-  phydbl f0,f1,f2,x0,x1,x2,x3;
-  phydbl pinv0, pinv1;
-  phydbl a, b, c;
-  phydbl fa, fb, fc;
-  phydbl K;
-  phydbl alpha0, alpha1;
-  phydbl best_lnL;
   scalar_dbl **alpha;
   int n_alpha;
+  t_tree *tree;
   int i;
 
   Switch_Eigen(NO,mixt_tree->mod);
 
-  alpha    = NULL;
-  n_alpha  = 0;
-  tree     = mixt_tree;
+  alpha   = NULL;
+  n_alpha = 0;
+  tree    = mixt_tree;
 
   do
     {
-      For(i,n_alpha) if(tree->mod->ras->alpha == alpha[i]) break;
-
-      if(i == n_alpha)
-    {
-      if(!alpha) alpha = (scalar_dbl **)mCalloc(1,sizeof(scalar_dbl *));
-      else       alpha = (scalar_dbl **)mRealloc(alpha,n_alpha+1,sizeof(scalar_dbl *));
-
-          alpha[n_alpha] = tree->mod->ras->alpha;
-      n_alpha++;
-
-      if((tree->mod->s_opt->opt_pinvar) && (tree->mod->s_opt->opt_alpha) && (tree->mod->ras->n_catg > 1))
-        {
-
-          lk_b     = UNLIKELY;
-          lk_a     = UNLIKELY;
-
-          /* PhyML_Printf("\n\n. %p Init lnL = %f alpha=%f pinv=%f", */
-              /*              tree, */
-              /*              mixt_tree->c_lnL, */
-              /*              tree->mod->ras->alpha, */
-              /*              tree->mod->ras->pinvar->v); */
-
-          /* Two (full) steps to compute  pinv_alpha_slope & pinv_alpha_intercept */
-
-          Set_Both_Sides(YES,mixt_tree);
-          Lk(NULL,mixt_tree);
-          lk_b = mixt_tree->c_lnL;
-
-          Optimize_Br_Len_Serie(mixt_tree);
-
-          Set_Both_Sides(NO,mixt_tree);
-
-          Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->alpha->v),0.01,100.,
-                        mixt_tree->mod->s_opt->min_diff_lk_local,
-                        mixt_tree->mod->s_opt->brent_it_max,
-                        mixt_tree->mod->s_opt->quickdirty);
-
-          Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->pinvar->v),.0001,0.9999,
-                        tree->mod->s_opt->min_diff_lk_local,
-                        tree->mod->s_opt->brent_it_max,
-                        tree->mod->s_opt->quickdirty);
-
-          pinv0  = tree->mod->ras->pinvar->v;
-          alpha0 = tree->mod->ras->alpha->v;
-          f0 = mixt_tree->c_lnL;
-
-          Set_Both_Sides(YES,mixt_tree);
-          Lk(NULL,mixt_tree);
-
-          Optimize_Br_Len_Serie(mixt_tree);
-
-          Set_Both_Sides(NO,mixt_tree);
-          Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->alpha->v),0.01,100.,
-                        tree->mod->s_opt->min_diff_lk_local,
-                        tree->mod->s_opt->brent_it_max,
-                        tree->mod->s_opt->quickdirty);
-
-          Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->pinvar->v),.0001,0.9999,
-                        tree->mod->s_opt->min_diff_lk_local,
-                        tree->mod->s_opt->brent_it_max,
-                        tree->mod->s_opt->quickdirty);
-
-          lk_a = mixt_tree->c_lnL;
-
-          pinv1  = tree->mod->ras->pinvar->v;
-          alpha1 = tree->mod->ras->alpha->v;
-          f1 = mixt_tree->c_lnL;
-          best_lnL = f1;
-
-          if(lk_a < lk_b - mixt_tree->mod->s_opt->min_diff_lk_local)
-        {
-          PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
-          Exit("\n");
-        }
-          else if(FABS(lk_a - lk_b) < mixt_tree->mod->s_opt->min_diff_lk_local)
-        {
-                  if(alpha) Free(alpha);
-          return 1;
-        }
-
-          Record_Br_Len(mixt_tree);
-          best_alpha = tree->mod->ras->alpha->v;
-          best_pinv  = tree->mod->ras->pinvar->v;
-          best_mult  = tree->mod->br_len_mult->v;
-
-          /* PhyML_Printf("\n\n. Init lnL after std opt = %f [%f] best_alpha=%f best_pinv=%f",mixt_tree->c_lnL,Lk(NULL,mixt_tree),best_alpha,best_pinv); */
-          /* PhyML_Printf("\n. Best_lnL = %f %d",best_lnL,tree->mod->ras->invar); */
-
-          slope     = (pinv1 - pinv0)/(alpha1 - alpha0);
-          intercept = pinv1 - slope * alpha1;
-
-
-              /* printf("\n. slope = %f pinv1=%f pinv0=%f alpha1=%f alpha0=%f", */
-              /*        slope,pinv1,pinv0,alpha1,alpha0); */
-
-
-          if((slope > 0.001) && (slope < 1./0.001))
+      if(tree->mod->s_opt->opt_alpha == YES && tree->mod->ras->n_catg > 1)
         {
-          /* PhyML_Printf("\n. pinv0 = %f, pinv1 = %f, alpha0 = %f, alpha1 = %f",pinv0,pinv1,alpha0,alpha1); */
-          /* PhyML_Printf("\n. slope = %f intercept = %f",slope,intercept); */
-
-          K = 0.381966;
+          For(i,n_alpha) if(tree->mod->ras->alpha == alpha[i]) break;
 
-          if(alpha1 < alpha0)
+          if(i == n_alpha)
             {
-              c  = alpha0;
-              b  = alpha1;
-              fc = f0;
-              fb = f1;
-
-              a = (0.1 < alpha1)?(0.1):(0.5*alpha1);
-              tree->mod->ras->alpha->v = a;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
+              if(!alpha) alpha = (scalar_dbl **)mCalloc(1,sizeof(scalar_dbl *));
+              else       alpha = (scalar_dbl **)mRealloc(alpha,n_alpha+1,sizeof(scalar_dbl *));
+              alpha[n_alpha] = tree->mod->ras->alpha;
+              n_alpha++;
 
-              Optimize_Br_Len_Serie(mixt_tree);
+              if(tree->mod->s_opt->opt_alpha == YES &&
+                 tree->mod->ras->free_mixt_rates == NO)
+                {
+                  if(tree->mod->ras->n_catg > 1)
+                    {
+                      Generic_Brent_Lk(&(tree->mod->ras->alpha->v),
+                                       tree->mod->ras->alpha->v/2.,100.,
+                                       tree->mod->s_opt->min_diff_lk_local,
+                                       tree->mod->s_opt->brent_it_max,
+                                       tree->mod->s_opt->quickdirty,
+                                       Wrap_Lk,NULL,mixt_tree,NULL,NO);
+                    }
+                  if(verbose)
+                    {
+                      Print_Lk(mixt_tree,"[Alpha              ]");
+                      PhyML_Printf("[%10f]",tree->mod->ras->alpha->v);
+                    }
+                }
 
-              fa = mixt_tree->c_lnL;
+              if(tree->mod->s_opt->opt_pinvar == YES &&
+                 tree->mod->ras->free_mixt_rates == NO)
+                {
+                  tree->mod->s_opt->skip_tree_traversal = YES;
 
-              iter = 0;
+                  Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->pinvar->v),.0001,0.9999,
+                                                tree->mod->s_opt->min_diff_lk_local,
+                                                tree->mod->s_opt->brent_it_max,
+                                                tree->mod->s_opt->quickdirty);
 
-              /* PhyML_Printf("\n. a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f (alpha=%f pinv=%f)",a,b,c,fa,fb,fc,tree->mod->ras->alpha->v,tree->mod->ras->pinvar->v); */
+                  tree->mod->s_opt->skip_tree_traversal = NO;
 
-              while(fa > fb)
-            {
-              a = a/5.;
-              tree->mod->ras->alpha->v = a;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
-              Optimize_Br_Len_Serie(mixt_tree);
-              fa = mixt_tree->c_lnL;
-              /* PhyML_Printf("\n1 a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f",a,b,c,fa,fb,fc); */
-              if(iter++ > 10)
-                            {
-                              if(alpha) Free(alpha);
-                              return 0;
-                            }
-            }
-            }
-          else
-            {
-              a  = alpha0;
-              b  = alpha1;
-              fa = f0;
-              fb = f1;
-
-              c = (alpha1 < 2.)?(2.0):(2.*alpha1);
-              tree->mod->ras->alpha->v = c;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
-              Optimize_Br_Len_Serie(mixt_tree);
-              fc = mixt_tree->c_lnL;
-
-              /* PhyML_Printf("\n. a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f (alpha=%f pinv=%f)",a,b,c,fa,fb,fc,tree->mod->ras->alpha->v,tree->mod->ras->pinvar->v); */
-
-              iter = 0;
-              while(fc > fb)
-            {
-              c = c*2.;
-              tree->mod->ras->alpha->v = c;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
-              Optimize_Br_Len_Serie(mixt_tree);
-              fc = mixt_tree->c_lnL;
-              /* PhyML_Printf("\n2 a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f",a,b,c,fa,fb,fc); */
-              if(iter++ > 10)
-                            {
-                              if(alpha) Free(alpha);
-                              return 0;
-                            }
-            }
+                  Print_Lk(mixt_tree,"[P-inv              ]");
+                  PhyML_Printf("[%10f]",tree->mod->ras->pinvar->v);
+                }
             }
+        }
+      tree = tree->next_mixt;
+    }
+  while(tree);
 
+  if(alpha) Free(alpha);
 
-          if(FABS(b - c) > FABS(a - b))
-            {
-              x0 = a; x1 = b; x3 = c;
-              x2 = b + K * FABS(b - c);
-
-              f0 = fa;
-              f1 = fb;
-              tree->mod->ras->alpha->v = x2;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
-              Optimize_Br_Len_Serie(mixt_tree);
-              f2 = mixt_tree->c_lnL;
-            }
-          else /* |b -c| < |a - b| */
-            {
-              x0 = a; x2 = b; x3 = c;
-              x1 = b - K * FABS(b - a);
-
-              f0 = fa;
-              f2 = fb;
-              tree->mod->ras->alpha->v = x1;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
-              Optimize_Br_Len_Serie(mixt_tree);
-              f1 = mixt_tree->c_lnL;
-            }
+  return 1;
 
-          iter = 0;
-          do
-            {
-              /* PhyML_Printf("\n. x0=%f, x1=%f, x2=%f, x3=%f, f0=%f, f1=%f, f2=%f, f3=%f", */
-              /* 	 x0,x1,x2,x3,f0,f1,f2,f3); */
 
-              if(f1 > f2)
-            {
-              x3 = x2;
-              x2 = x1;
-              x1 = x2 - K * FABS(x2 - x0);
-
-              f2 = f1;
-
-              tree->mod->ras->alpha->v = x1;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
-              Optimize_Br_Len_Serie(mixt_tree);
-              f1 = mixt_tree->c_lnL;
-              if(f1 > best_lnL)
-                {
-                  Record_Br_Len(mixt_tree);
-                  best_alpha = tree->mod->ras->alpha->v;
-                  best_pinv  = tree->mod->ras->pinvar->v;
-                  best_mult  = tree->mod->br_len_mult->v;
-                  /* PhyML_Printf("\n>.< New alpha=%f pinv=%f",best_alpha,best_pinv); */
-                }
-              /* PhyML_Printf("\n> f1=%f",f1); */
-            }
-              else /* f1 < f2 */
-            {
-              x0 = x1;
-              x1 = x2;
-              x2 = x2 + K * FABS(x3 - x2);
-
-              f0 = f1;
-              f1 = f2;
-
-              tree->mod->ras->alpha->v = x2;
-              tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept;
-              if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9;
-              if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001;
-              Set_Both_Sides(YES,mixt_tree);
-              Lk(NULL,mixt_tree);
-              Optimize_Br_Len_Serie(mixt_tree);
-              f2 = mixt_tree->c_lnL;
-              if(f2 > best_lnL)
-                {
-                  Record_Br_Len(mixt_tree);
-                  best_alpha = tree->mod->ras->alpha->v;
-                  best_pinv  = tree->mod->ras->pinvar->v;
-                  best_mult  = tree->mod->br_len_mult->v;
-                  /* PhyML_Printf("\n>o< New alpha=%f pinv=%f",best_alpha,best_pinv); */
-                }
-              /* PhyML_Printf("\n> f2=%f",f2); */
-            }
+  /* t_tree *tree; */
+  /* int    iter; */
+  /* phydbl best_alpha, best_pinv, best_mult; */
+  /* phydbl slope, intercept; */
+  /* phydbl lk_b, lk_a; */
+  /* phydbl f0,f1,f2,x0,x1,x2,x3; */
+  /* phydbl pinv0, pinv1; */
+  /* phydbl a, b, c; */
+  /* phydbl fa, fb, fc; */
+  /* phydbl K; */
+  /* phydbl alpha0, alpha1; */
+  /* phydbl best_lnL; */
+  /* scalar_dbl **alpha; */
+  /* int n_alpha; */
+  /* int i; */
 
-              if(FABS(f1 - f2) < 0.01) break;
+  /* Switch_Eigen(NO,mixt_tree->mod); */
 
-              iter++;
+  /* alpha    = NULL; */
+  /* n_alpha  = 0; */
+  /* tree     = mixt_tree; */
 
-            }while(iter < 100);
-        }
-          
-          tree->mod->ras->alpha->v  = best_alpha;
-          tree->mod->ras->pinvar->v = best_pinv;
-          tree->mod->br_len_mult->v = best_mult;
-          Restore_Br_Len(mixt_tree);
-          Set_Both_Sides(YES,mixt_tree);
-          Lk(NULL,mixt_tree);
+  /* do */
+  /*   { */
+  /*     For(i,n_alpha) if(tree->mod->ras->alpha == alpha[i]) break; */
 
-          if(verbose)
-            {
-              Print_Lk(mixt_tree,"[Alpha              ]");
-              PhyML_Printf("[%10f]",tree->mod->ras->alpha->v);
-              Print_Lk(mixt_tree,"[P-inv              ]");
-              PhyML_Printf("[%10f]",tree->mod->ras->pinvar->v);
-            }
-        }
-    }
+  /*     if(i == n_alpha) */
+  /*       { */
+  /*         if(!alpha) alpha = (scalar_dbl **)mCalloc(1,sizeof(scalar_dbl *)); */
+  /*         else       alpha = (scalar_dbl **)mRealloc(alpha,n_alpha+1,sizeof(scalar_dbl *)); */
+          
+  /*         alpha[n_alpha] = tree->mod->ras->alpha; */
+  /*         n_alpha++; */
 
-      tree = tree->next_mixt;
+  /*         if((tree->mod->s_opt->opt_pinvar) && (tree->mod->s_opt->opt_alpha) && (tree->mod->ras->n_catg > 1)) */
+  /*           {               */
+  /*             lk_b     = UNLIKELY; */
+  /*             lk_a     = UNLIKELY; */
+              
+  /*             /\* PhyML_Printf("\n\n. %p Init lnL = %f alpha=%f pinv=%f", *\/ */
+  /*             /\*              tree, *\/ */
+  /*             /\*              mixt_tree->c_lnL, *\/ */
+  /*             /\*              tree->mod->ras->alpha, *\/ */
+  /*             /\*              tree->mod->ras->pinvar->v); *\/ */
+              
+  /*             /\* Two (full) steps to compute  pinv_alpha_slope & pinv_alpha_intercept *\/ */
+              
+  /*             Set_Both_Sides(YES,mixt_tree); */
+  /*             Lk(NULL,mixt_tree); */
+  /*             lk_b = mixt_tree->c_lnL; */
+              
+  /*             Optimize_Br_Len_Serie(mixt_tree); */
+              
+  /*             Set_Both_Sides(NO,mixt_tree); */
+              
+  /*             Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->alpha->v),0.01,100., */
+  /*                                           mixt_tree->mod->s_opt->min_diff_lk_local, */
+  /*                                           mixt_tree->mod->s_opt->brent_it_max, */
+  /*                                           mixt_tree->mod->s_opt->quickdirty); */
+              
+  /*             Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->pinvar->v),.0001,0.9999, */
+  /*                                           tree->mod->s_opt->min_diff_lk_local, */
+  /*                                           tree->mod->s_opt->brent_it_max, */
+  /*                                           tree->mod->s_opt->quickdirty); */
+              
+  /*             pinv0  = tree->mod->ras->pinvar->v; */
+  /*             alpha0 = tree->mod->ras->alpha->v; */
+  /*             f0 = mixt_tree->c_lnL; */
+              
+  /*             Set_Both_Sides(YES,mixt_tree); */
+  /*             Lk(NULL,mixt_tree); */
+              
+  /*             Optimize_Br_Len_Serie(mixt_tree); */
+              
+  /*             Set_Both_Sides(NO,mixt_tree); */
+  /*             Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->alpha->v),0.01,100., */
+  /*                                           tree->mod->s_opt->min_diff_lk_local, */
+  /*                                           tree->mod->s_opt->brent_it_max, */
+  /*                                           tree->mod->s_opt->quickdirty); */
+              
+  /*             Optimize_Single_Param_Generic(mixt_tree,&(tree->mod->ras->pinvar->v),.0001,0.9999, */
+  /*                                           tree->mod->s_opt->min_diff_lk_local, */
+  /*                                           tree->mod->s_opt->brent_it_max, */
+  /*                                           tree->mod->s_opt->quickdirty); */
+              
+  /*             lk_a = mixt_tree->c_lnL; */
+              
+  /*             pinv1  = tree->mod->ras->pinvar->v; */
+  /*             alpha1 = tree->mod->ras->alpha->v; */
+  /*             f1 = mixt_tree->c_lnL; */
+  /*             best_lnL = f1; */
+              
+  /*             if(lk_a < lk_b - mixt_tree->mod->s_opt->min_diff_lk_local) */
+  /*               { */
+  /*                 PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__); */
+  /*                 Exit("\n"); */
+  /*               } */
+  /*             else if(FABS(lk_a - lk_b) < mixt_tree->mod->s_opt->min_diff_lk_local) */
+  /*               { */
+  /*                 if(alpha) Free(alpha); */
+  /*                 return 1; */
+  /*               } */
+              
+  /*             Record_Br_Len(mixt_tree); */
+  /*             best_alpha = tree->mod->ras->alpha->v; */
+  /*             best_pinv  = tree->mod->ras->pinvar->v; */
+  /*             best_mult  = tree->mod->br_len_mult->v; */
+              
+  /*             /\* PhyML_Printf("\n\n. Init lnL after std opt = %f [%f] best_alpha=%f best_pinv=%f",mixt_tree->c_lnL,Lk(NULL,mixt_tree),best_alpha,best_pinv); *\/ */
+  /*             /\* PhyML_Printf("\n. Best_lnL = %f %d",best_lnL,tree->mod->ras->invar); *\/ */
+              
+  /*             slope     = (pinv1 - pinv0)/(alpha1 - alpha0); */
+  /*             intercept = pinv1 - slope * alpha1; */
+              
+              
+  /*             /\* printf("\n. slope = %f pinv1=%f pinv0=%f alpha1=%f alpha0=%f", *\/ */
+  /*             /\*        slope,pinv1,pinv0,alpha1,alpha0); *\/ */
+              
+              
+  /*             if((slope > 0.001) && (slope < 1./0.001)) */
+  /*               { */
+  /*                 /\* PhyML_Printf("\n. pinv0 = %f, pinv1 = %f, alpha0 = %f, alpha1 = %f",pinv0,pinv1,alpha0,alpha1); *\/ */
+  /*                 /\* PhyML_Printf("\n. slope = %f intercept = %f",slope,intercept); *\/ */
+                  
+  /*                 K = 0.381966; */
+                  
+  /*                 if(alpha1 < alpha0) */
+  /*                   { */
+  /*                     c  = alpha0; */
+  /*                     b  = alpha1; */
+  /*                     fc = f0; */
+  /*                     fb = f1; */
+                      
+  /*                     a = (0.1 < alpha1)?(0.1):(0.5*alpha1); */
+  /*                     tree->mod->ras->alpha->v = a; */
+  /*                     tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                     if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                     if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                     Set_Both_Sides(YES,mixt_tree); */
+  /*                     Lk(NULL,mixt_tree); */
+                      
+  /*                     Optimize_Br_Len_Serie(mixt_tree); */
+                      
+  /*                     fa = mixt_tree->c_lnL; */
+                      
+  /*                     iter = 0; */
+                      
+  /*                     /\* PhyML_Printf("\n. a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f (alpha=%f pinv=%f)",a,b,c,fa,fb,fc,tree->mod->ras->alpha->v,tree->mod->ras->pinvar->v); *\/ */
+                      
+  /*                     while(fa > fb) */
+  /*                       { */
+  /*                         a = a/5.; */
+  /*                         tree->mod->ras->alpha->v = a; */
+  /*                         tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                         if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                         if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                         Set_Both_Sides(YES,mixt_tree); */
+  /*                         Lk(NULL,mixt_tree); */
+  /*                         Optimize_Br_Len_Serie(mixt_tree); */
+  /*                         fa = mixt_tree->c_lnL; */
+  /*                         /\* PhyML_Printf("\n1 a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f",a,b,c,fa,fb,fc); *\/ */
+  /*                         if(iter++ > 10) */
+  /*                           { */
+  /*                             if(alpha) Free(alpha); */
+  /*                             return 0; */
+  /*                           } */
+  /*                       } */
+  /*                   } */
+  /*                 else */
+  /*                   { */
+  /*                     a  = alpha0; */
+  /*                     b  = alpha1; */
+  /*                     fa = f0; */
+  /*                     fb = f1; */
+                      
+  /*                     c = (alpha1 < 2.)?(2.0):(2.*alpha1); */
+  /*                     tree->mod->ras->alpha->v = c; */
+  /*                     tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                     if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                     if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                     Set_Both_Sides(YES,mixt_tree); */
+  /*                     Lk(NULL,mixt_tree); */
+  /*                     Optimize_Br_Len_Serie(mixt_tree); */
+  /*                     fc = mixt_tree->c_lnL; */
+                      
+  /*                     /\* PhyML_Printf("\n. a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f (alpha=%f pinv=%f)",a,b,c,fa,fb,fc,tree->mod->ras->alpha->v,tree->mod->ras->pinvar->v); *\/ */
+                      
+  /*                     iter = 0; */
+  /*                     while(fc > fb) */
+  /*                       { */
+  /*                         c = c*2.; */
+  /*                         tree->mod->ras->alpha->v = c; */
+  /*                         tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                         if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                         if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                         Set_Both_Sides(YES,mixt_tree); */
+  /*                         Lk(NULL,mixt_tree); */
+  /*                         Optimize_Br_Len_Serie(mixt_tree); */
+  /*                         fc = mixt_tree->c_lnL; */
+  /*                         /\* PhyML_Printf("\n2 a=%f, b=%f, c=%f, fa=%f, fb=%f, fc=%f",a,b,c,fa,fb,fc); *\/ */
+  /*                         if(iter++ > 10) */
+  /*                           { */
+  /*                             if(alpha) Free(alpha); */
+  /*                             return 0; */
+  /*                           } */
+  /*                       } */
+  /*                   } */
+                  
+                  
+  /*                 if(FABS(b - c) > FABS(a - b)) */
+  /*                   { */
+  /*                     x0 = a; x1 = b; x3 = c; */
+  /*                     x2 = b + K * FABS(b - c); */
+                      
+  /*                     f0 = fa; */
+  /*                     f1 = fb; */
+  /*                     tree->mod->ras->alpha->v = x2; */
+  /*                     tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                     if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                     if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                     Set_Both_Sides(YES,mixt_tree); */
+  /*                     Lk(NULL,mixt_tree); */
+  /*                     Optimize_Br_Len_Serie(mixt_tree); */
+  /*                     f2 = mixt_tree->c_lnL; */
+  /*                   } */
+  /*                 else /\* |b -c| < |a - b| *\/ */
+  /*                   { */
+  /*                     x0 = a; x2 = b; x3 = c; */
+  /*                     x1 = b - K * FABS(b - a); */
+                      
+  /*                     f0 = fa; */
+  /*                     f2 = fb; */
+  /*                     tree->mod->ras->alpha->v = x1; */
+  /*                     tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                     if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                     if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                     Set_Both_Sides(YES,mixt_tree); */
+  /*                     Lk(NULL,mixt_tree); */
+  /*                     Optimize_Br_Len_Serie(mixt_tree); */
+  /*                     f1 = mixt_tree->c_lnL; */
+  /*                   } */
+                  
+  /*                 iter = 0; */
+  /*                 do */
+  /*                   { */
+  /*                     /\* PhyML_Printf("\n. x0=%f, x1=%f, x2=%f, x3=%f, f0=%f, f1=%f, f2=%f, f3=%f", *\/ */
+  /*                     /\* 	 x0,x1,x2,x3,f0,f1,f2,f3); *\/ */
+                      
+  /*                     if(f1 > f2) */
+  /*                       { */
+  /*                         x3 = x2; */
+  /*                         x2 = x1; */
+  /*                         x1 = x2 - K * FABS(x2 - x0); */
+                          
+  /*                         f2 = f1; */
+                          
+  /*                         tree->mod->ras->alpha->v = x1; */
+  /*                         tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                         if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                         if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                         Set_Both_Sides(YES,mixt_tree); */
+  /*                         Lk(NULL,mixt_tree); */
+  /*                         Optimize_Br_Len_Serie(mixt_tree); */
+  /*                         f1 = mixt_tree->c_lnL; */
+  /*                         if(f1 > best_lnL) */
+  /*                           { */
+  /*                             Record_Br_Len(mixt_tree); */
+  /*                             best_alpha = tree->mod->ras->alpha->v; */
+  /*                             best_pinv  = tree->mod->ras->pinvar->v; */
+  /*                             best_mult  = tree->mod->br_len_mult->v; */
+  /*                             /\* PhyML_Printf("\n>.< New alpha=%f pinv=%f",best_alpha,best_pinv); *\/ */
+  /*                           } */
+  /*                         /\* PhyML_Printf("\n> f1=%f",f1); *\/ */
+  /*                       } */
+  /*                     else /\* f1 < f2 *\/ */
+  /*                       { */
+  /*                         x0 = x1; */
+  /*                         x1 = x2; */
+  /*                         x2 = x2 + K * FABS(x3 - x2); */
+                          
+  /*                         f0 = f1; */
+  /*                         f1 = f2; */
+                          
+  /*                         tree->mod->ras->alpha->v = x2; */
+  /*                         tree->mod->ras->pinvar->v = slope * tree->mod->ras->alpha->v + intercept; */
+  /*                         if(tree->mod->ras->pinvar->v > 1.0) tree->mod->ras->pinvar->v = 0.9; */
+  /*                         if(tree->mod->ras->pinvar->v < 0.0) tree->mod->ras->pinvar->v = 0.001; */
+  /*                         Set_Both_Sides(YES,mixt_tree); */
+  /*                         Lk(NULL,mixt_tree); */
+  /*                         Optimize_Br_Len_Serie(mixt_tree); */
+  /*                         f2 = mixt_tree->c_lnL; */
+  /*                         if(f2 > best_lnL) */
+  /*                           { */
+  /*                             Record_Br_Len(mixt_tree); */
+  /*                             best_alpha = tree->mod->ras->alpha->v; */
+  /*                             best_pinv  = tree->mod->ras->pinvar->v; */
+  /*                             best_mult  = tree->mod->br_len_mult->v; */
+  /*                             /\* PhyML_Printf("\n>o< New alpha=%f pinv=%f",best_alpha,best_pinv); *\/ */
+  /*                           } */
+  /*                         /\* PhyML_Printf("\n> f2=%f",f2); *\/ */
+  /*                       } */
+                      
+  /*                     if(FABS(f1 - f2) < 0.01) break; */
+                      
+  /*                     iter++; */
+                      
+  /*                   }while(iter < 100); */
+  /*               } */
+              
+  /*             tree->mod->ras->alpha->v  = best_alpha; */
+  /*             tree->mod->ras->pinvar->v = best_pinv; */
+  /*             tree->mod->br_len_mult->v = best_mult; */
+  /*             Restore_Br_Len(mixt_tree); */
+  /*             Set_Both_Sides(YES,mixt_tree); */
+  /*             Lk(NULL,mixt_tree); */
+              
+  /*             if(verbose) */
+  /*               { */
+  /*                 Print_Lk(mixt_tree,"[Alpha              ]"); */
+  /*                 PhyML_Printf("[%10f]",tree->mod->ras->alpha->v); */
+  /*                 Print_Lk(mixt_tree,"[P-inv              ]"); */
+  /*                 PhyML_Printf("[%10f]",tree->mod->ras->pinvar->v); */
+  /*               } */
+  /*           } */
+  /*       } */
 
-    }
-  while(tree);
+  /*     tree = tree->next_mixt; */
 
-  /* PhyML_Printf("\n\n. Init lnL after golden opt = %f [%f] best_alpha=%f best_pinv=%f",tree->c_lnL,Lk(tree),best_alpha,best_pinv); */
+  /*   } */
+  /* while(tree); */
+  
+  /* /\* PhyML_Printf("\n\n. Init lnL after golden opt = %f [%f] best_alpha=%f best_pinv=%f",tree->c_lnL,Lk(tree),best_alpha,best_pinv); *\/ */
 
-  if(alpha) Free(alpha);
+  /* if(alpha) Free(alpha); */
 
-  return 1;
+  /* return 1; */
 }
 
 //////////////////////////////////////////////////////////////
@@ -2626,10 +2705,10 @@ void Opt_Node_Heights_Recurr_Pre(t_node *a, t_node *d, t_tree *tree)
       t_max -= tree->rates->min_dt;
 
       if(t_min > t_max)
-    {
-      PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
-      Exit("\n");
-    }
+        {
+          PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
+          Exit("\n");
+        }
 
       Generic_Brent_Lk(&(tree->rates->nd_t[d->num]),
                t_min,t_max,
@@ -2663,9 +2742,9 @@ void Optimize_RR_Params(t_tree *mixt_tree, int verbose)
   do
     {
       if(tree->next) tree = tree->next;
-
+      
       For(i,n_r_mat) if(tree->mod->r_mat == r_mat[i]) break;
-
+      
       if(i == n_r_mat) // tree->mod->r_mat was not found before
         {
           if(!r_mat) r_mat = (t_rmat **)mCalloc(1,sizeof(t_rmat *));
@@ -2695,6 +2774,7 @@ void Optimize_RR_Params(t_tree *mixt_tree, int verbose)
 
               For(i,tree->mod->r_mat->n_diff_rr) tree->mod->r_mat->rr_val->v[i] = EXP(tree->mod->r_mat->rr_val->v[i]);
               
+
               if(failed == YES)
                 {
                   For(i,tree->mod->r_mat->n_diff_rr)
@@ -2807,29 +2887,29 @@ void Optimize_Pinv(t_tree *mixt_tree, int verbose)
       For(i,n_pinv) if(tree->mod->ras->pinvar == pinv[i]) break;
 
       if(i == n_pinv)
-    {
-      if(!pinv) pinv = (scalar_dbl **)mCalloc(1,sizeof(scalar_dbl *));
-      else      pinv = (scalar_dbl **)mRealloc(pinv,n_pinv+1,sizeof(scalar_dbl *));
-      pinv[n_pinv] = tree->mod->ras->pinvar;
-      n_pinv++;
-
-      if(tree->mod->s_opt->opt_pinvar == YES && tree->mod->s_opt->opt_alpha == NO)
         {
-          Generic_Brent_Lk(&(tree->mod->ras->pinvar->v),
-                   0.0001,0.9999,
-                   tree->mod->s_opt->min_diff_lk_local,
-                   tree->mod->s_opt->brent_it_max,
-                   tree->mod->s_opt->quickdirty,
-                   Wrap_Lk,NULL,mixt_tree,NULL,NO);
-
-          if(verbose)
-        {
-          Print_Lk(mixt_tree,"[P-inv              ]");
-          PhyML_Printf("[%10f]",tree->mod->ras->pinvar->v);
-        }
+          if(!pinv) pinv = (scalar_dbl **)mCalloc(1,sizeof(scalar_dbl *));
+          else      pinv = (scalar_dbl **)mRealloc(pinv,n_pinv+1,sizeof(scalar_dbl *));
+          pinv[n_pinv] = tree->mod->ras->pinvar;
+          n_pinv++;
+          
+          if(tree->mod->s_opt->opt_pinvar == YES && tree->mod->s_opt->opt_alpha == NO)
+            {
+              Generic_Brent_Lk(&(tree->mod->ras->pinvar->v),
+                               0.0001,0.9999,
+                               tree->mod->s_opt->min_diff_lk_local,
+                               tree->mod->s_opt->brent_it_max,
+                               tree->mod->s_opt->quickdirty,
+                               Wrap_Lk,NULL,mixt_tree,NULL,NO);
+              
+              if(verbose)
+                {
+                  Print_Lk(mixt_tree,"[P-inv              ]");
+                  PhyML_Printf("[%10f]",tree->mod->ras->pinvar->v);
+                }
+            }
         }
-    }
-
+      
       tree = tree->next;
 
     }
@@ -3108,27 +3188,6 @@ void Optimize_Free_Rate_Weights(t_tree *tree, int fast, int verbose)
   phydbl lk_before, lk_after;
 
 
-  if(tree->mod->s_opt->first_opt_free_mixt_rates == YES)
-    {
-      /* tree->mod->s_opt->opt_alpha     = YES; */
-      /* tree->mod->s_opt->opt_pinvar    = NO; */
-      /* tree->mod->ras->free_mixt_rates = NO; */
-
-      /* Optimize_Alpha(tree,YES); */
-
-      /* For(i,tree->mod->ras->n_catg) */
-      /*   { */
-      /*     tree->mod->ras->gamma_r_proba_unscaled->v[i] = 1./(phydbl)tree->mod->ras->n_catg; */
-      /*     tree->mod->ras->gamma_rr_unscaled->v[i]      = tree->mod->ras->gamma_rr->v[i]; */
-      /*   } */
-
-      /* tree->mod->s_opt->opt_alpha                 = NO; */
-      /* tree->mod->ras->free_mixt_rates             = YES; */
-      /* tree->mod->s_opt->first_opt_free_mixt_rates = NO; */
-
-      /* Lk(NULL,tree); */
-    }
-
   lk_before = tree->c_lnL;
 
   /*! Only skip tree traversal when data is not partitionned */
@@ -3145,14 +3204,6 @@ void Optimize_Free_Rate_Weights(t_tree *tree, int fast, int verbose)
       For(i,2*tree->n_otu-1) tree->a_edges[i]->l->v /= (wm * tree->mod->ras->free_rate_mr->v);
     }
 
-  /* BFGS returns negative values sometimes: need to log-transform?... to do... */
-  /* int failed = NO; */
-  /* BFGS(tree,tree->mod->ras->gamma_r_proba_unscaled->v,tree->mod->ras->n_catg,1.e-5,tree->mod->s_opt->min_diff_lk_local,1.e-5,NO, */
-  /*      &Return_Abs_Lk, */
-  /*      &Num_Derivative_Several_Param, */
-  /*      &Lnsrch,&failed); */
-
-
   For(i,tree->mod->ras->n_catg-1)
     {
       Generic_Brent_Lk(&(tree->mod->ras->gamma_r_proba_unscaled->v[i]),
@@ -3186,19 +3237,6 @@ void Optimize_Free_Rate_Weights(t_tree *tree, int fast, int verbose)
     }
 
   if(verbose) Print_Lk(tree,"[Rate class freqs.  ]");
-
-  /* printf("\n. Before: %f after: %f",lk_before,lk_after); */
-  /* For(i,tree->mod->ras->n_catg) */
-  /*   { */
-  /*     printf("\n+ c %2d p: %15f r: %15f up: %15f ur: %5f", */
-  /*            i+1, */
-  /*            tree->mod->ras->gamma_r_proba->v[i], */
-  /*            tree->mod->ras->gamma_rr->v[i], */
-  /*            tree->mod->ras->gamma_r_proba_unscaled->v[i], */
-  /*            tree->mod->ras->gamma_rr_unscaled->v[i]); */
-  /*   } */
-  /* fflush(NULL); */
-
 }
 
 //////////////////////////////////////////////////////////////
@@ -3236,10 +3274,10 @@ void Optimize_State_Freqs(t_tree *mixt_tree, int verbose)
           failed = YES;
 
           BFGS(mixt_tree,tree->mod->e_frq->pi_unscaled->v,tree->mod->ns,1.e-5,tree->mod->s_opt->min_diff_lk_local,1.e-5,NO,YES,
-           &Return_Abs_Lk,
-           &Num_Derivative_Several_Param,
-           &Lnsrch,&failed);
-
+               &Return_Abs_Lk,
+               &Num_Derivative_Several_Param,
+               &Lnsrch,&failed);
+          
           if(failed == YES)
         {
           For(i,tree->mod->ns)
@@ -3276,41 +3314,34 @@ void Optimize_State_Freqs(t_tree *mixt_tree, int verbose)
 
 void Optimize_Rmat_Weights(t_tree *mixt_tree, int verbose)
 {
-  t_tree *tree;
   scalar_dbl *r_mat_weight;
 
   Switch_Eigen(NO,mixt_tree->mod);
 
   if(mixt_tree->is_mixt_tree == NO) return;
 
-  tree = mixt_tree;
-  do
+  r_mat_weight = mixt_tree->next->mod->r_mat_weight;
+  
+  if(mixt_tree->next->mod->s_opt->opt_rmat_weight == YES)
     {
-      if(tree->next && tree->next->mod->s_opt->opt_rmat_weight == YES)
+      do
         {
-          r_mat_weight = tree->next->mod->r_mat_weight;
-          do
+          Generic_Brent_Lk(&(r_mat_weight->v),
+                           0.,100.,
+                           mixt_tree->mod->s_opt->min_diff_lk_local,
+                           mixt_tree->mod->s_opt->brent_it_max,
+                           mixt_tree->mod->s_opt->quickdirty,
+                           Wrap_Lk,NULL,mixt_tree,NULL,NO);
+          
+          if(verbose)
             {
-              Generic_Brent_Lk(&(r_mat_weight->v),
-                               0.,100.,
-                               tree->mod->s_opt->min_diff_lk_local,
-                               tree->mod->s_opt->brent_it_max,
-                               tree->mod->s_opt->quickdirty,
-                               Wrap_Lk,NULL,mixt_tree,NULL,NO);
-
-              if(verbose)
-                {
-                  Print_Lk(mixt_tree,"[Rate mat. weights  ]");
-                }
-
-              r_mat_weight = r_mat_weight->next;
+              Print_Lk(mixt_tree,"[Rate mat. weights  ]");
             }
-          while(r_mat_weight);
+          
+          r_mat_weight = r_mat_weight->next;
         }
-      tree = tree->next_mixt;
-
+      while(r_mat_weight);
     }
-  while(tree);
 
   Switch_Eigen(NO,mixt_tree->mod);
 
@@ -3321,43 +3352,35 @@ void Optimize_Rmat_Weights(t_tree *mixt_tree, int verbose)
 
 void Optimize_Efrq_Weights(t_tree *mixt_tree, int verbose)
 {
-  t_tree *tree;
   scalar_dbl *e_frq_weight;
 
   Switch_Eigen(NO,mixt_tree->mod);
 
   if(mixt_tree->is_mixt_tree == NO) return;
 
-  tree = mixt_tree;
-  do
+  e_frq_weight = mixt_tree->next->mod->e_frq_weight;
+
+
+  if(mixt_tree->next->mod->s_opt->opt_efrq_weight == YES)
     {
-      if(tree->next && tree->next->mod->s_opt->opt_efrq_weight == YES)
+      do
         {
-
-          e_frq_weight = tree->next->mod->e_frq_weight;
-          do
+          Generic_Brent_Lk(&(e_frq_weight->v),
+                           0.,100.,
+                           mixt_tree->mod->s_opt->min_diff_lk_local,
+                           mixt_tree->mod->s_opt->brent_it_max,
+                           mixt_tree->mod->s_opt->quickdirty,
+                           Wrap_Lk,NULL,mixt_tree,NULL,NO);
+          
+          if(verbose)
             {
-              Generic_Brent_Lk(&(e_frq_weight->v),
-                               0.,100.,
-                               tree->mod->s_opt->min_diff_lk_local,
-                               tree->mod->s_opt->brent_it_max,
-                               tree->mod->s_opt->quickdirty,
-                               Wrap_Lk,NULL,mixt_tree,NULL,NO);
-
-              if(verbose)
-                {
-                  Print_Lk(mixt_tree,"[Equ. frq. weights  ]");
-                }
-
-              e_frq_weight = e_frq_weight->next;
+              Print_Lk(mixt_tree,"[Equ. frq. weights  ]");
             }
-          while(e_frq_weight);
+          
+          e_frq_weight = e_frq_weight->next;
         }
-
-      tree = tree->next_mixt;
-
+      while(e_frq_weight);
     }
-  while(tree);
 
   Switch_Eigen(NO,mixt_tree->mod);
 
diff --git a/src/phyrex.c b/src/phyrex.c
new file mode 100644
index 0000000..aea1700
--- /dev/null
+++ b/src/phyrex.c
@@ -0,0 +1,4173 @@
+/*
+
+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 that implement Etheridge and Barton's model of continuous-space
+   coalescent.
+*/
+
+#include "phyrex.h"
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int PHYREX_Main(int argc, char *argv[])
+{
+  return(PHYREX_Main_Estimate(argc,argv));
+  /* return(PHYREX_Main_Simulate(argc,argv)); */
+
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int PHYREX_Main_Estimate(int argc, char *argv[])
+{
+  t_tree *tree;
+  phydbl *res;
+  int n_dim,i;
+  t_dsk *disk;
+  option *io;
+  calign *cdata;
+  t_ldsk **ldsk_a;
+
+  n_dim = 2;
+
+  io = (option *)Get_Input(argc,argv);
+  assert(io);
+
+  Get_Seq(io);
+  assert(io->data);
+
+  Make_Model_Complete(io->mod);
+  Set_Model_Name(io->mod);
+  Print_Settings(io);
+
+  cdata = Compact_Data(io->data,io);
+  Free_Seq(io->data,cdata->n_otu);
+
+  tree = Make_Tree_From_Scratch(cdata->n_otu,cdata);
+  Connect_CSeqs_To_Nodes(cdata,io,tree);
+
+  tree->rates = RATES_Make_Rate_Struct(tree->n_otu);
+  RATES_Init_Rate_Struct(tree->rates,io->rates,tree->n_otu);
+  
+  /* Allocate migrep model */
+  tree->mmod = PHYREX_Make_Migrep_Model(n_dim);
+  PHYREX_Init_Migrep_Mod(tree->mmod,n_dim,10.0,10.0);
+
+  tree->data      = cdata;
+  tree->mod       = io->mod;
+  tree->io        = io;
+  tree->n_pattern = tree->data->crunch_len;
+
+  /* Allocate and initialise first disk event */
+  disk = PHYREX_Make_Disk_Event(n_dim,tree->n_otu);
+  PHYREX_Init_Disk_Event(disk,n_dim,NULL);
+  disk->time             = 0.0;
+  disk->mmod             = tree->mmod;
+  disk->n_ldsk_a         = tree->n_otu;  
+  tree->disk             = disk;
+
+  /* Allocate coordinates for all the tips first (will grow afterwards) */
+  ldsk_a = (t_ldsk **)mCalloc(tree->n_otu,sizeof(t_ldsk *));
+  For(i,tree->n_otu) 
+    {
+      ldsk_a[i] = PHYREX_Make_Lindisk_Node(n_dim);
+      PHYREX_Init_Lindisk_Node(ldsk_a[i],disk,n_dim);
+    }
+  
+  PHYREX_Read_Tip_Coordinates(ldsk_a,tree);
+
+  tree->disk->ldsk_a = ldsk_a;
+
+  /* Initialize parameters of migrep model */
+  tree->mmod->lbda  = Uni()*(0.3 - 0.05) + 0.05;
+  tree->mmod->mu    = Uni()*(1.0 - 0.3)  + 0.3;
+  tree->mmod->rad   = Uni()*(5.0 - 1.5)  + 1.5;
+  tree->mmod->sigsq = PHYREX_Update_Sigsq(tree);
+
+  /* Random genealogy */
+  PHYREX_Simulate_Backward_Core(NO,tree->disk,tree);
+
+  PHYREX_Ldsk_To_Tree(tree);  
+
+  Update_Ancestors(tree->n_root,tree->n_root->v[2],tree);
+  Update_Ancestors(tree->n_root,tree->n_root->v[1],tree);
+  RATES_Fill_Lca_Table(tree);
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+
+  tree->rates->bl_from_rt = YES;
+  tree->rates->clock_r    = 0.01 / FABS(disk->time);
+  tree->rates->model      = STRICTCLOCK;
+  RATES_Update_Cur_Bl(tree);
+
+  Init_Model(tree->data,io->mod,io);
+  Prepare_Tree_For_Lk(tree);
+  Init_P_Lk_Tips_Int(tree);
+  Init_P_Lk_Loc(tree);
+
+  res = PHYREX_MCMC(tree);
+
+  Free(res);  
+
+  return 0;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+int PHYREX_Main_Simulate(int argc, char *argv[])
+{
+  t_tree *tree;
+  phydbl *res;
+  int seed,pid,i;
+  char *s;
+  t_dsk *disk;
+  int n_otus, n_sites;
+
+  s = (char *)mCalloc(T_MAX_NAME,sizeof(char));
+
+  pid     = getpid();
+  seed    = pid;
+  n_otus  = (int)atoi(argv[1]);
+  n_sites = (int)atoi(argv[2]);
+
+  /* !!!!!!!!!!!!! */
+  /* seed = 9498; */
+  /* seed = 27351; */
+  /* seed = 359; */
+  /* seed = 1; */
+  /* seed = 10112; */
+  /* seed = 5818; */
+  /* seed = 16167; */
+  /* seed = 18885; */
+  /* seed = 22776; */
+  /* seed = 629; */
+  /* seed = 1; */
+  /* seed = 14493; */
+  /* seed = 15364; */
+  /* seed = 21414; */
+  /* seed = 13536; */
+  /* seed = 28366; */
+  /* seed = 20679; */
+  /* seed = 23661; */
+
+  printf("\n. seed: %d",seed);
+  srand(seed);
+  
+  tree = PHYREX_Simulate((int)atoi(argv[1]),(int)atoi(argv[2]),10.,10.,seed);
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+
+
+  strcpy(s,"phyrex_trees");
+  sprintf(s+strlen(s),".%d",tree->mod->io->r_seed);
+  tree->io->fp_out_tree = Openfile(s,WRITE);
+  strcpy(s,"phyrex_stats");
+  sprintf(s+strlen(s),".%d",tree->mod->io->r_seed);
+  tree->io->fp_out_stats = Openfile(s,WRITE);
+  strcpy(s,"phyrex_summary");
+  sprintf(s+strlen(s),".%d",tree->mod->io->r_seed);
+  tree->io->fp_out_summary = Openfile(s,WRITE);
+  strcpy(s,"phyrex_mtt");
+  sprintf(s+strlen(s),".%d.xml",tree->mod->io->r_seed);
+  PHYREX_Print_MultiTypeTree_Config_File(n_sites,s,tree);
+
+  res = PHYREX_MCMC(tree);
+
+  disk = tree->disk;
+  For(i,disk->n_ldsk_a) Free_Ldisk(disk->ldsk_a[i]);
+  while(disk->prev)
+    {
+      disk = disk->prev;
+      if(disk->next->ldsk != NULL) Free_Ldisk(disk->next->ldsk);
+      Free_Disk(disk->next);
+    }
+  
+  /* Root */
+  Free_Ldisk(disk->ldsk);
+  Free_Disk(disk);
+
+  RATES_Free_Rates(tree->rates);
+  MCMC_Free_MCMC(tree->mcmc);
+  Free_Mmod(tree->mmod);
+  Free_Spr_List(tree);
+  Free_Triplet(tree->triplet_struct);
+  Free_Tree_Pars(tree);
+  Free_Tree_Lk(tree);
+  Free_Input(tree->io);
+  Free_Optimiz(tree->mod->s_opt);
+  Free_Model_Complete(tree->mod);
+  Free_Model_Basic(tree->mod);
+  Free_Cseq(tree->data);
+  Free_Tree(tree);
+  Free(res);  
+  Free(s);
+
+  return 0;
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+// Simulate Etheridge-Barton model backwards in time, following n_otu lineages
+// on a rectangle of dimension width x height
+// See Kelleher, Barton & Etheridge, Bioinformatics, 2013.
+t_tree *PHYREX_Simulate(int n_otu, int n_sites, phydbl width, phydbl height, int r_seed)
+{  
+  t_tree *tree;
+  int n_dim;
+  t_phyrex_mod *mmod;
+  t_dsk *disk;
+  option *io;
+  t_mod *mod;
+  t_opt *s_opt;
+  calign *cdata;
+  /* phydbl max_mu, min_mu; */
+  /* phydbl max_rad, min_rad; */
+  /* phydbl min_rate, max_rate; */
+  /* phydbl min_lbda, max_lbda; */
+  phydbl min_neigh, max_neigh;
+  /* phydbl min_sigsq, max_sigsq; */
+  phydbl area, neigh;
+  phydbl T;
+  phydbl Ne,maxNe,minNe;
+
+  n_dim = 2; // 2-dimensional landscape
+  area  = width * height;
+
+  io    = (option *)Make_Input();
+  mod   = (t_mod *)Make_Model_Basic();
+  s_opt = (t_opt *)Make_Optimiz();
+
+  Set_Defaults_Input(io);
+  Set_Defaults_Model(mod);
+  Set_Defaults_Optimiz(s_opt);
+
+  io->mod      = mod;
+  mod->io      = io;
+  mod->s_opt   = s_opt;
+  io->r_seed   = r_seed;
+
+  io->n_otu    = n_otu;
+  io->init_len = 500; /* sequence length */
+
+  io->data = Make_Empty_Alignment(io);
+
+  Make_Model_Complete(io->mod);
+  Set_Model_Name(io->mod);
+
+  /* Print_Settings(io); */
+
+  io->colalias = NO;
+  cdata = Compact_Data(io->data,io);
+  Free_Seq(io->data,io->n_otu);
+
+  tree = Make_Tree_From_Scratch(n_otu,cdata);
+
+  Connect_CSeqs_To_Nodes(cdata,io,tree);
+  
+  tree->rates = RATES_Make_Rate_Struct(tree->n_otu);
+  RATES_Init_Rate_Struct(tree->rates,io->rates,tree->n_otu);
+  
+  tree->data      = cdata;
+  tree->mod       = mod;
+  tree->io        = io;
+  tree->n_pattern = tree->data->crunch_len;
+
+
+  /* Allocate migrep model */
+  mmod = PHYREX_Make_Migrep_Model(n_dim);
+  tree->mmod = mmod;
+  PHYREX_Init_Migrep_Mod(mmod,n_dim,width,height);
+
+
+  do
+    {
+      /* Effective population size */
+      minNe = 100.; maxNe = 5000.;
+      Ne = Uni() * (maxNe - minNe) + minNe;
+      
+      /* Neighborhood size */
+      max_neigh = 0.01*Ne; min_neigh = 0.001*Ne;
+      neigh = Uni()*(max_neigh - min_neigh)  + min_neigh;
+    }
+  while(neigh < 2.0);
+  
+  /* Death parameter */
+  mmod->mu = 2./neigh;
+
+  /* Theta (radius) */
+  tree->mmod->rad = Uni()*(4.0 - 1.5) + 1.5;
+
+  mmod->sigsq = neigh / (4.*PI*Ne/area);
+
+  tree->mmod->lbda = area * mmod->sigsq / (4.*PI*tree->mmod->mu*POW(tree->mmod->rad,4));
+
+  
+  /* mmod->lbda  = 0.04; */
+  /* mmod->mu    = 0.16; */
+  /* mmod->rad   = 2.75; */
+  /* neigh       = 2./mmod->mu; */
+  /* mmod->sigsq = PHYREX_Update_Sigsq(tree); */
+
+  PhyML_Printf("\n. lbda: %G mu: %G sigsq: %G rad: %G neigh: %G N: %G rhoe: %G",
+               mmod->lbda,
+               mmod->mu,
+               mmod->sigsq,
+               mmod->rad,
+               neigh,
+               area*neigh/(4*PI*mmod->sigsq),
+               neigh/(4.*PI*mmod->sigsq));
+  fflush(NULL);
+
+
+  /* PHYREX_Simulate_Backward_Core(YES,tree->disk,tree); */
+  mmod->sampl_area = PHYREX_Simulate_Forward_Core(n_sites,tree);
+    
+  PHYREX_Ldsk_To_Tree(tree);  
+
+  Update_Ancestors(tree->n_root,tree->n_root->v[2],tree);
+  Update_Ancestors(tree->n_root,tree->n_root->v[1],tree);
+  RATES_Fill_Lca_Table(tree);
+
+  /* min_rate = 1.E-5; */
+  /* max_rate = 1.E-4; */
+
+  T = PHYREX_Tree_Height(tree);
+
+  tree->rates->bl_from_rt = YES;
+  /* tree->rates->clock_r    = Uni()*(max_rate - min_rate) + min_rate; */
+  tree->rates->clock_r    = 0.01/FABS(T);
+  tree->rates->model      = STRICTCLOCK;
+
+  RATES_Update_Cur_Bl(tree);
+
+  Init_Model(cdata,mod,io);
+
+  tree->mod->ras->n_catg   = 1;
+  tree->mod->whichmodel    = HKY85;
+  tree->mod->kappa->v      = 4.0;
+    
+  Prepare_Tree_For_Lk(tree);
+  Evolve(tree->data,tree->mod,tree);
+
+  if(tree->mod->s_opt->greedy) Init_P_Lk_Tips_Double(tree);
+  else                         Init_P_Lk_Tips_Int(tree);
+  Init_P_Lk_Loc(tree);
+
+  disk = tree->disk->prev;
+  while(disk->prev) disk = disk->prev;
+
+  printf("\n. XXX %f %d %d %d %f %f %f %f %f %f\n",
+         disk->time,
+         PHYREX_Total_Number_Of_Intervals(tree),
+         PHYREX_Total_Number_Of_Coal_Disks(tree),
+         PHYREX_Total_Number_Of_Hit_Disks(tree),
+         disk->ldsk->coord->lonlat[0],
+         disk->ldsk->coord->lonlat[1],
+         mmod->lbda,  
+         mmod->mu,    
+         mmod->sigsq,
+         Nucleotide_Diversity(tree->data));
+
+  return(tree);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+// Simulate Etheridge-Barton model backwards in time, following n_otu lineages
+// on a rectangle of dimension width x height
+phydbl PHYREX_Simulate_Backward_Core(int new_loc, t_dsk *init_disk, t_tree *tree)
+{
+  t_dsk *disk;
+  t_ldsk *new_ldsk,**ldsk_a,**ldsk_a_tmp;
+  int i,j,n_disk,n_lineages,n_dim,n_hit,n_lineages_new,err;
+  phydbl dt_dsk,curr_t,prob_hit,u;
+  t_phyrex_mod *mmod;
+  phydbl lnL;
+
+  mmod  = tree->mmod;
+  n_dim = tree->mmod->n_dim;
+
+  if(new_loc == YES)
+    {
+      init_disk = PHYREX_Make_Disk_Event(n_dim,tree->n_otu);
+      PHYREX_Init_Disk_Event(init_disk,n_dim,NULL);
+      init_disk->time             = 0.0;
+      init_disk->mmod             = mmod;
+      init_disk->centr->lonlat[0] = .5*mmod->lim->lonlat[0];
+      init_disk->centr->lonlat[1] = .5*mmod->lim->lonlat[1];      
+      init_disk->n_ldsk_a         = tree->n_otu;  
+      tree->disk                  = init_disk;
+    }
+
+  if(new_loc == YES)
+    {      
+      For(i,tree->n_otu) 
+        {
+          char *s;
+          init_disk->ldsk_a[i] = PHYREX_Make_Lindisk_Node(n_dim);
+          PHYREX_Init_Lindisk_Node(init_disk->ldsk_a[i],init_disk,n_dim);
+          s = (char *)mCalloc(strlen(init_disk->ldsk_a[i]->coord->id)+1+20,sizeof(char));
+          strcpy(s,init_disk->ldsk_a[i]->coord->id);
+          strcat(s,"_deme0\0");
+          Free(init_disk->ldsk_a[i]->coord->id);
+          init_disk->ldsk_a[i]->coord->id = s;
+        }
+
+      /* PhyML_Printf("\n. WARNING: position of samples are not random."); */
+      /* Generate coordinates for the tip nodes (uniform distribution on the rectangle) */
+      For(i,tree->n_otu)
+        {
+          init_disk->ldsk_a[i]->coord->lonlat[0] = Uni()*tree->mmod->lim->lonlat[0]; // longitude
+          init_disk->ldsk_a[i]->coord->lonlat[1] = Uni()*tree->mmod->lim->lonlat[1]; // latitude
+          /* init_disk->ldsk_a[i]->coord->lonlat[0] = (i/(int)SQRT(tree->n_otu)+1)*tree->mmod->lim->lonlat[0]/(SQRT(tree->n_otu)+1); // longitude */
+          /* init_disk->ldsk_a[i]->coord->lonlat[1] = (i%(int)SQRT(tree->n_otu)+1)*tree->mmod->lim->lonlat[1]/(SQRT(tree->n_otu)+1); // latitude */
+        }
+    }
+
+
+  /* Allocate coordinates for all the tips first (will grow afterwards) */
+  ldsk_a = (t_ldsk **)mCalloc(tree->n_otu,sizeof(t_ldsk *));
+  For(i,tree->n_otu) ldsk_a[i] = init_disk->ldsk_a[i];
+  
+  /* Allocate and initialise for next event */
+  init_disk->prev = PHYREX_Make_Disk_Event(n_dim,tree->n_otu);
+  PHYREX_Init_Disk_Event(init_disk->prev,n_dim,NULL);
+  init_disk->prev->next = init_disk;
+
+  /* Move to it */
+  disk = init_disk->prev;
+
+  ldsk_a_tmp = (t_ldsk **)mCalloc(tree->n_otu,sizeof(t_ldsk *));
+
+  curr_t     = init_disk->time;
+  dt_dsk     = 0.0;
+  n_lineages = init_disk->n_ldsk_a;
+  n_disk     = 0;
+  lnL        = 0.0;
+  do
+    {      
+      /* Time of next event */
+      dt_dsk = Rexp(mmod->lbda);
+      curr_t -= dt_dsk;
+      
+      /* Coordinates of next event */
+      disk->centr->lonlat[0] = Uni()*mmod->lim->lonlat[0];
+      disk->centr->lonlat[1] = Uni()*mmod->lim->lonlat[1];      
+
+      /* Density for waiting time to next event */
+      lnL += (LOG(mmod->lbda) - mmod->lbda*dt_dsk);
+      
+      /* Uniform density for disk center */
+      For(j,mmod->n_dim) lnL -= LOG(mmod->lim->lonlat[j]);
+
+      disk->time = curr_t;
+      disk->mmod = mmod;
+
+      /* printf("\n. Disk %s has %d lindisk nodes and %d disks under",disk->id,disk->n_ldsk_a,disk->n_disk_under); */
+
+      /* New lindisk (will not be used if no lineage is hit)  */
+      new_ldsk = PHYREX_Make_Lindisk_Node(n_dim);
+      PHYREX_Init_Lindisk_Node(new_ldsk,disk,n_dim);
+
+      /* Sample the location of new_ldsk. */
+      /* Takes into account the limits of the landscape */
+      switch(mmod->name)
+        {
+        case PHYREX_UNIFORM: { PHYREX_Runif_Rectangle_Overlap(new_ldsk,disk,mmod); break; }
+        case PHYREX_NORMAL:  { PHYREX_Rnorm_Trunc(new_ldsk,disk,mmod); break; }
+        default : { Generic_Exit(__FILE__,__LINE__,__FUNCTION__); break; }
+        }
+
+      n_hit          = 0;
+      n_lineages_new = 0;
+      For(i,n_lineages)
+        {
+          ldsk_a[i]->prev = NULL;
+          
+          prob_hit = -1.;
+          switch(mmod->name)
+            {
+            case PHYREX_UNIFORM: 
+              { 
+                prob_hit = mmod->mu; 
+                break; 
+              }
+            case PHYREX_NORMAL:  
+              { 
+                prob_hit = LOG(mmod->mu);
+                For(j,mmod->n_dim) prob_hit += -POW(ldsk_a[i]->coord->lonlat[j] - disk->centr->lonlat[j],2)/(2.*POW(mmod->rad,2));
+                prob_hit = EXP(prob_hit);
+                break; 
+              }
+            }
+          
+          if(PHYREX_Is_In_Disk(ldsk_a[i]->coord,disk,mmod) == YES) 
+            {
+              u = Uni();
+              if(!(u > prob_hit))
+                {
+                  lnL += LOG(prob_hit);
+                  
+                  PHYREX_Make_Lindisk_Next(new_ldsk);
+
+                  ldsk_a[i]->prev                    = new_ldsk;
+                  new_ldsk->is_hit                   = YES;
+                  new_ldsk->next[new_ldsk->n_next-1] = ldsk_a[i]; 
+                  disk->ldsk                         = new_ldsk;
+
+                  n_hit++;
+
+                  if(n_hit == 1)
+                    {
+                      ldsk_a_tmp[n_lineages_new] = new_ldsk;
+                      n_lineages_new++;
+                    }
+                }
+              else
+                {
+                  lnL += LOG(1. - prob_hit);
+                }                
+            }
+          
+          if(ldsk_a[i]->prev == NULL) /* Lineage was not hit */
+            {              
+              ldsk_a_tmp[n_lineages_new] = ldsk_a[i];
+              n_lineages_new++;
+            }
+        }
+
+      if(n_hit >= 1)
+        {
+          phydbl log_dens_coal;
+          log_dens_coal = 0.0;
+          For(j,mmod->n_dim) log_dens_coal += Log_Dnorm_Trunc(new_ldsk->coord->lonlat[j],
+                                                              disk->centr->lonlat[j],
+                                                              mmod->rad,
+                                                              0.0,
+                                                              mmod->lim->lonlat[j],&err);
+          lnL += log_dens_coal;          
+        }      
+      
+      assert(!((n_hit > 0) && (n_lineages_new != n_lineages - n_hit + 1)));
+
+      if(n_hit > 0) n_lineages -= (n_hit-1);
+ 
+      if(n_hit == 0) Free_Ldisk(new_ldsk);
+      
+      n_disk++;
+
+      Free(ldsk_a);
+
+
+      if(n_lineages == 1) break;
+
+      ldsk_a = (t_ldsk **)mCalloc(tree->n_otu,sizeof(t_ldsk *));
+      For(i,n_lineages) ldsk_a[i] = ldsk_a_tmp[i];
+      
+      disk->prev = PHYREX_Make_Disk_Event(n_dim,tree->n_otu);
+      PHYREX_Init_Disk_Event(disk->prev,n_dim,NULL);
+      disk->prev->next = disk;
+      
+
+      disk = disk->prev;
+    }
+  while(1);
+
+  Free(ldsk_a_tmp);
+
+  return(lnL);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+// Simulate Etheridge-Barton model forwards in time, following n_otu lineages
+// on a rectangle of dimension width x height
+phydbl PHYREX_Simulate_Forward_Core(int n_sites, t_tree *tree)
+{
+  t_dsk *disk;
+  t_ldsk *new_ldsk,**ldsk_a_pop,**ldsk_a_samp,**ldsk_a_tmp,**ldsk_a_tips;
+  int i,j,n_disk,n_dim,n_otu,pop_size,parent_id,n_lineages,sample_size,n_poly,*permut;
+  phydbl dt_dsk,curr_t,sum,*parent_prob,prob_death,tree_height,max_x,max_y,trans_x,trans_y,area;
+  short int dies,n_remain;
+  t_phyrex_mod *mmod;
+  t_poly **poly;
+
+  mmod     = tree->mmod;
+  n_dim    = tree->mmod->n_dim;
+  n_otu    = tree->n_otu;
+  /* pop_size = (int)(tree->mmod->rho * tree->mmod->lim->lonlat[0] * tree->mmod->lim->lonlat[1]); */
+  pop_size = 100*n_otu;
+
+  parent_prob = (phydbl *)mCalloc(pop_size,sizeof(phydbl));
+
+  /* Allocate and initialise first disk event */
+  disk = PHYREX_Make_Disk_Event(n_dim,pop_size);
+  PHYREX_Init_Disk_Event(disk,n_dim,NULL);
+
+  /* Allocate coordinates for all the individuals in the population */
+  ldsk_a_pop = (t_ldsk **)mCalloc(pop_size,sizeof(t_ldsk *));
+  For(i,pop_size)
+    {
+      ldsk_a_pop[i] = PHYREX_Make_Lindisk_Node(n_dim);
+      PHYREX_Init_Lindisk_Node(ldsk_a_pop[i],disk,n_dim);
+    }
+
+  /* Generate coordinates for all individuals */
+  For(i,pop_size)
+    {
+      ldsk_a_pop[i]->coord->lonlat[0] = Uni()*tree->mmod->lim->lonlat[0]; // longitude
+      ldsk_a_pop[i]->coord->lonlat[1] = Uni()*tree->mmod->lim->lonlat[1]; // latitude
+    }
+
+  disk->prev = NULL;
+  curr_t = 0.0;
+  dt_dsk = 0.0;
+  n_disk = 0;
+  do
+    {
+      /* Coordinates of event */
+      disk->centr->lonlat[0] = Uni()*mmod->lim->lonlat[0];
+      disk->centr->lonlat[1] = Uni()*mmod->lim->lonlat[1];
+
+      /* Select one parent */
+      For(i,pop_size)
+        {
+          switch(mmod->name)
+            {
+            case PHYREX_UNIFORM:
+              {
+                if(PHYREX_Is_In_Disk(ldsk_a_pop[i]->coord,disk,mmod) == YES)
+                  parent_prob[i] = 1.0;
+                else
+                  parent_prob[i] = 0.0;
+                break;
+              }
+            case PHYREX_NORMAL:
+              {
+                parent_prob[i] = 0.0;
+                For(j,mmod->n_dim) parent_prob[i] += -POW(ldsk_a_pop[i]->coord->lonlat[j] - disk->centr->lonlat[j],2)/(2.*POW(mmod->rad,2));
+                parent_prob[i] = EXP(parent_prob[i]);
+                break;
+              }
+            }
+        }
+      sum = 0.0;
+      For(i,pop_size) sum += parent_prob[i];
+      For(i,pop_size) parent_prob[i] /= sum;
+      
+      parent_id  = Sample_i_With_Proba_pi(parent_prob,pop_size);
+      disk->ldsk = ldsk_a_pop[parent_id];
+      ldsk_a_pop[parent_id]->disk = disk;
+
+      /* printf("\n. Disk %s has %s on it",disk->id,ldsk_a_pop[parent_id]->coord->id); */
+
+      /* Which lineages die in that event? Each lineage that dies off is being replaced
+         with a new one which location is chosen randomly following the model */
+      For(i,pop_size)
+        {
+          prob_death = 0.0;
+          switch(mmod->name)
+            {
+            case PHYREX_UNIFORM:
+              {
+                if(PHYREX_Is_In_Disk(ldsk_a_pop[i]->coord,disk,mmod) == YES)
+                  prob_death = mmod->mu;
+                break;
+              }
+            case PHYREX_NORMAL:
+              {
+                prob_death = LOG(mmod->mu);
+                For(j,mmod->n_dim) prob_death += -POW(ldsk_a_pop[i]->coord->lonlat[j] - disk->centr->lonlat[j],2)/(2.*POW(mmod->rad,2));
+                prob_death = EXP(prob_death);
+                break;
+              }
+            }
+          
+          dies = NO;
+          if(Uni() < prob_death || i == parent_id) dies = YES; /* Note: parent always dies (not in the model...) */
+
+          if(dies == YES) /* Replace dead lineage with new one */
+            {
+
+              /* New lindisk */
+              new_ldsk = PHYREX_Make_Lindisk_Node(n_dim);
+              PHYREX_Init_Lindisk_Node(new_ldsk,disk,n_dim);
+          
+              /* Select new location for new lineage replacing the one that just died  */
+              switch(mmod->name)
+                {
+                case PHYREX_UNIFORM: { PHYREX_Runif_Rectangle_Overlap(new_ldsk,disk,mmod); break; }
+                case PHYREX_NORMAL:  { PHYREX_Rnorm_Trunc(new_ldsk,disk,mmod); break; }
+                }
+
+              /* Connect to parent */
+              new_ldsk->prev = disk->ldsk;
+
+              /* Replace dead individual (thus, number of birth == number of death) */
+              if(i != parent_id) Free_Ldisk(ldsk_a_pop[i]);
+              ldsk_a_pop[i] = new_ldsk;
+            }
+        }
+
+      disk->next = PHYREX_Make_Disk_Event(n_dim,n_otu);
+      PHYREX_Init_Disk_Event(disk->next,n_dim,NULL);
+      disk->next->prev = disk;      
+      disk = disk->next;
+      n_disk++;
+
+
+      /* Time of next event */
+      dt_dsk = Rexp(mmod->lbda);
+      curr_t += dt_dsk;
+
+      disk->time = curr_t;
+      disk->mmod = mmod;
+    }
+  while(n_disk < 100000);
+
+  For(i,pop_size) ldsk_a_pop[i]->disk = disk;
+
+  /* Allocate coordinates for all the tips first (will grow afterwards) */
+  ldsk_a_samp = (t_ldsk **)mCalloc(n_otu,sizeof(t_ldsk *));
+  ldsk_a_tips = (t_ldsk **)mCalloc(n_otu,sizeof(t_ldsk *));
+  ldsk_a_tmp  = (t_ldsk **)mCalloc(n_otu,sizeof(t_ldsk *));
+
+  /* Sample individuals (take the first n_otu ldsk within ldsk_a_pop array) */  
+  /* For(i,n_otu) ldsk_a_samp[i] = ldsk_a_pop[i]; */
+
+  n_poly = n_sites;
+
+  do
+    {
+      poly = (t_poly **)mCalloc(n_poly,sizeof(t_poly *));
+      For(i,n_poly) poly[i] = Rpoly(3); /* triangles */
+      For(i,n_poly)
+        {      
+          For(j,poly[i]->n_poly_vert) 
+            {
+              poly[i]->poly_vert[j]->lonlat[0] *= mmod->lim->lonlat[0]*0.5;
+              poly[i]->poly_vert[j]->lonlat[1] *= mmod->lim->lonlat[1]*0.5;
+            }
+          
+          max_x = 0.0;
+          max_y = 0.0;
+          For(j,poly[i]->n_poly_vert) 
+            {
+              if(poly[i]->poly_vert[j]->lonlat[0] > max_x) max_x = poly[i]->poly_vert[j]->lonlat[0];
+              if(poly[i]->poly_vert[j]->lonlat[1] > max_y) max_y = poly[i]->poly_vert[j]->lonlat[1];
+            }
+          
+          trans_x = Uni()*(mmod->lim->lonlat[0] - max_x);
+          trans_y = Uni()*(mmod->lim->lonlat[1] - max_y);
+          
+          For(j,poly[i]->n_poly_vert) 
+            {
+              poly[i]->poly_vert[j]->lonlat[0] += trans_x;
+              poly[i]->poly_vert[j]->lonlat[1] += trans_y;
+              PhyML_Printf("\n# Sampling == polygon %d vertex @ (%f; %f)",
+                           i,
+                           poly[i]->poly_vert[j]->lonlat[0],
+                           poly[i]->poly_vert[j]->lonlat[1]);
+            }
+        }
+      
+      For(i,n_otu) ldsk_a_samp[i] = NULL;
+
+      permut = Permutate(n_poly);
+
+      sample_size = 0;
+      For(i,pop_size)
+        {
+          For(j,n_poly)
+            {
+              if(Is_In_Polygon(ldsk_a_pop[i]->coord,poly[permut[j]]) == YES)
+                {
+                  char *s;
+                  int k;
+                  s = (char *)mCalloc((int)strlen(ldsk_a_pop[i]->coord->id)+1+20,sizeof(char));
+                  For(k,(int)strlen(ldsk_a_pop[i]->coord->id)+1+20) s[k]='\0';
+                  strcpy(s,ldsk_a_pop[i]->coord->id);
+                  Free(ldsk_a_pop[i]->coord->id);
+                  strcat(s,"_deme");
+                  sprintf(s+strlen(s),"%d",permut[j]);
+                  ldsk_a_pop[i]->coord->id = s;
+
+                  ldsk_a_samp[sample_size] = ldsk_a_pop[i];
+                  sample_size++;
+                  PhyML_Printf("\n@ Coord: %f %f %s",ldsk_a_samp[sample_size-1]->coord->lonlat[0],ldsk_a_samp[sample_size-1]->coord->lonlat[1],ldsk_a_pop[i]->coord->id);
+                  
+                  break;
+                }
+            }
+          if(sample_size == n_otu) break;
+        }
+
+      Free(permut);
+
+      area = Area_Of_Poly_Monte_Carlo(poly,n_poly,mmod->lim);
+      
+      For(j,n_poly) Free_Poly(poly[j]);
+      Free(poly);
+
+      if(i == pop_size)
+        {
+          PhyML_Printf("\n== Not enough individuals in polygon(s) (only %d found).",sample_size);
+          /* Generic_Exit(__FILE__,__LINE__,__FUNCTION__);       */
+        }
+      else break;    
+    }
+  while(1);
+      
+  For(i,n_otu) ldsk_a_tips[i] = ldsk_a_samp[i];
+  
+  tree->disk             = disk;
+  disk->ldsk_a           = ldsk_a_tips;
+  disk->mmod             = tree->mmod;
+  disk->centr->lonlat[0] = .5*tree->mmod->lim->lonlat[0];
+  disk->centr->lonlat[1] = .5*tree->mmod->lim->lonlat[1];      
+  disk->n_ldsk_a         = n_otu;  
+
+  int n_discs = 0;
+
+  n_lineages = n_otu;
+  do
+    {      
+      /* printf("\n [%s %f]",disk->id,disk->time); */
+
+      n_remain = 0;
+      For(i,n_lineages) 
+        {
+          /* printf(" %s",ldsk_a_samp[i]->coord->id); */
+
+          if((disk->prev->ldsk != NULL) && (disk->prev->ldsk == ldsk_a_samp[i]->prev)) /* Coalescent event is sampled */
+            {
+              /* printf("*"); */
+              PHYREX_Make_Lindisk_Next(disk->prev->ldsk);
+              disk->prev->ldsk->next[disk->prev->ldsk->n_next-1] = ldsk_a_samp[i];
+            }
+          else
+            {
+              ldsk_a_tmp[n_remain] = ldsk_a_samp[i];
+              n_remain++;
+            }
+        }
+
+      For(i,n_remain) ldsk_a_samp[i] = ldsk_a_tmp[i];
+      if((disk->prev->ldsk != NULL) && (disk->prev->ldsk->n_next > 0)) ldsk_a_samp[i] = disk->prev->ldsk;
+
+      if((disk->prev->ldsk != NULL) && (disk->prev->ldsk->n_next > 0))
+        {
+          n_lineages -= (disk->prev->ldsk->n_next);
+          n_lineages += 1;
+        }
+
+      if(n_lineages != n_remain+(disk->prev->ldsk && disk->prev->ldsk->n_next>0)?1:0) 
+        {
+          PhyML_Printf("\n== n_lineages: %d n_remain: %d n_next: %d",
+                       n_lineages,
+                       n_remain,
+                       disk->prev->ldsk->n_next);
+          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+        }
+
+      /* None of the sampled lineages was hit */
+      if((disk->prev->ldsk != NULL) && (disk->prev->ldsk->n_next == 0))
+        {
+          /* printf("\n. free %s @ %f",disk->ldsk->coord->id,disk->time); */
+          Free_Ldisk(disk->prev->ldsk);
+          disk->prev->ldsk = NULL;
+        }
+
+      disk = disk->prev;
+      
+      if(disk->prev == NULL)
+        {
+          PhyML_Printf("\n== # lineages left: %d",n_remain);
+          PhyML_Printf("\n== Sample has not coalesced completely.");
+          fflush(NULL);
+          Exit("\n");
+        }
+    }
+  while(n_lineages > 1);
+
+  /* For(i,n_otu) printf("\n> %s",tree->disk->ldsk_a[i]->coord->id); */
+
+  disk->prev = NULL;
+
+  disk = tree->disk;
+  tree_height = disk->time;
+  n_discs = 0;
+  while(disk)
+    {
+      disk->time -= tree_height;
+      disk = disk->prev;
+      n_discs++;
+    }
+
+  Free(ldsk_a_tmp);
+  Free(ldsk_a_samp);
+  Free(ldsk_a_pop);
+  Free(parent_prob);
+  
+  /* PHYREX_Print_Struct('#',tree); */
+  /* Exit("\n"); */
+
+  return(area);
+ 
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+/* Test whether coord is in disk. Will actually only works in disk */
+/* is a rectangle... */
+
+int PHYREX_Is_In_Disk(t_geo_coord *coord, t_dsk *disk, t_phyrex_mod *mmod)
+{
+  int i;
+
+  assert(disk->centr->dim);
+
+  if(mmod->name == PHYREX_UNIFORM)
+    {
+      For(i,disk->centr->dim)
+        {
+          if(FABS(coord->lonlat[i] - disk->centr->lonlat[i]) > disk->mmod->rad + 1.E-20)
+            {
+              return(NO);
+            }
+        }
+      return(YES);
+    }
+  else if(mmod->name == PHYREX_NORMAL)
+    {
+      return(YES);
+    }
+
+  return(-1);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl PHYREX_Lk(t_tree *tree)
+{
+  phydbl lnL;
+  phydbl log_lbda;
+  t_dsk *disk;
+  
+  assert(!tree->disk->next);
+  assert(tree->disk->prev);
+  
+  tree->mmod->c_lnL = 0.0;
+  log_lbda          = LOG(tree->mmod->lbda);
+
+  /* TO DO: create a proper PHYREX_LogPost() function */
+  tree->mmod->c_lnL += PHYREX_LnPrior_Radius(tree);
+  tree->mmod->c_lnL += PHYREX_LnPrior_Mu(tree);
+  tree->mmod->c_lnL += PHYREX_LnPrior_Lbda(tree);
+ 
+  if(isinf(tree->mmod->c_lnL) || isnan(tree->mmod->c_lnL)) 
+    {
+      tree->mmod->c_lnL = UNLIKELY;
+      return tree->mmod->c_lnL;
+    }
+
+  PHYREX_Update_Lindisk_List(tree);
+
+  disk = tree->disk->prev;
+  assert(disk);
+  do
+    {
+      lnL = PHYREX_Lk_Core(disk,tree);
+      lnL += log_lbda - tree->mmod->lbda * FABS(disk->time - disk->next->time);
+      tree->mmod->c_lnL += lnL;
+      disk->c_lnL = tree->mmod->c_lnL;
+      disk = disk->prev;
+    }
+  while(disk);
+
+  if(isinf(tree->mmod->c_lnL) || isnan(tree->mmod->c_lnL)) tree->mmod->c_lnL = UNLIKELY;
+
+  return(tree->mmod->c_lnL);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl PHYREX_Lk_Core(t_dsk *disk, t_tree *tree)
+{
+  phydbl lnL,log_prob_hit,log_mu,log_dens_coal;
+  int was_hit,i,j,k,err;
+  phydbl two_theta_two;
+
+  two_theta_two = 2.*POW(tree->mmod->rad,2);
+  lnL           = 0.0;
+  log_mu        = LOG(tree->mmod->mu);
+  was_hit       = (disk->ldsk != NULL);
+
+  For(i,disk->n_ldsk_a)
+    {
+      if(PHYREX_Is_In_Ldscape(disk->ldsk_a[i],tree->mmod) == NO) return(UNLIKELY);     
+
+      if(was_hit && disk->ldsk_a[i] == disk->ldsk)
+        {
+          For(k,disk->ldsk->n_next)
+            {              
+              log_prob_hit = log_mu;
+              For(j,tree->mmod->n_dim)
+                log_prob_hit += -POW(disk->ldsk->next[k]->coord->lonlat[j] - disk->centr->lonlat[j],2)/two_theta_two;
+
+              lnL += log_prob_hit;
+            }
+        }
+      else
+        {
+          log_prob_hit = log_mu;
+          For(j,tree->mmod->n_dim)
+            log_prob_hit += -POW(disk->ldsk_a[i]->coord->lonlat[j] - disk->centr->lonlat[j],2)/two_theta_two;
+          
+          lnL += LOG(1. - EXP(log_prob_hit));
+        }
+    }
+
+  /* a hit occurred */
+  if(was_hit == TRUE)
+    {
+      err = NO;
+      log_dens_coal = 0.0;
+      For(j,tree->mmod->n_dim) log_dens_coal += Log_Dnorm_Trunc(disk->ldsk->coord->lonlat[j],
+                                                                disk->centr->lonlat[j],
+                                                                tree->mmod->rad,
+                                                                0.0,
+                                                                tree->mmod->lim->lonlat[j],&err);
+      lnL += log_dens_coal;
+    }
+
+  /* Likelihood for the disk center */
+  For(i,disk->mmod->n_dim) lnL -= LOG(tree->mmod->lim->lonlat[i]);
+  
+  return(lnL);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl PHYREX_Lk_Range(t_dsk *young, t_dsk *old, t_tree *tree)
+{
+  t_dsk *disk;
+  phydbl lnL,log_lbda;
+  
+  assert(young);
+  assert(young->next);
+  
+  log_lbda = LOG(tree->mmod->lbda);
+
+  lnL  = 0.0;
+  disk = young;
+  do
+    {
+      PHYREX_Update_Lindisk_List_Core(disk,tree);
+      lnL += PHYREX_Lk_Core(disk,tree);
+      lnL += log_lbda - tree->mmod->lbda * FABS(disk->time - disk->next->time);
+      if(disk == old) break;
+      disk = disk->prev;
+    }
+  while(disk);
+
+  return(lnL);
+}
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl *PHYREX_MCMC(t_tree *tree)
+{
+  t_mcmc *mcmc;
+  int move,i,n_vars,burnin,true_ncoal,true_nint,true_nhits;
+  phydbl u;
+  t_dsk *disk;
+  FILE *fp_tree,*fp_stats,*fp_summary;
+  phydbl *res;
+  phydbl true_root_x, true_root_y,true_lbda,true_mu,true_sigsq,true_neigh,fst_neigh,diversity,true_rad,true_height,true_rhoe;
+  int adjust_len;
+
+  fp_tree    = tree->io->fp_out_tree;
+  fp_stats   = tree->io->fp_out_stats;
+  fp_summary = tree->io->fp_out_summary;
+
+  mcmc = MCMC_Make_MCMC_Struct();
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+
+  tree->mcmc = mcmc;
+
+  mcmc->io               = NULL;
+  mcmc->is               = NO;
+  mcmc->use_data         = YES;
+  mcmc->run              = 0;
+  mcmc->chain_len_burnin = 1E+5;
+  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      = 1;
+  mcmc->chain_len        = 1E+8;
+  mcmc->sample_interval  = 1E+3;  
+  mcmc->max_lag          = 1000;
+  mcmc->sample_size      = mcmc->chain_len/mcmc->sample_interval;
+  mcmc->sample_num       = 0;
+  adjust_len             = 1E+6;
+
+  MCMC_Complete_MCMC(mcmc,tree);
+
+  n_vars                 = 12;
+  true_root_x            = disk->ldsk->coord->lonlat[0];
+  true_root_y            = disk->ldsk->coord->lonlat[1];
+
+  res = (phydbl *)mCalloc(tree->mcmc->chain_len / tree->mcmc->sample_interval * n_vars,sizeof(phydbl));
+
+  PHYREX_Lk(tree);
+  Lk(NULL,tree);
+
+  true_lbda   = tree->mmod->lbda;
+  true_mu     = tree->mmod->mu;
+  true_sigsq  = tree->mmod->sigsq;
+  true_rad    = tree->mmod->rad;
+  true_neigh  = PHYREX_Neighborhood_Size(tree);
+  fst_neigh   = PHYREX_Neighborhood_Size_Regression(tree);
+  diversity   = Nucleotide_Diversity(tree->data);
+  true_ncoal  = PHYREX_Total_Number_Of_Coal_Disks(tree);
+  true_nint   = PHYREX_Total_Number_Of_Intervals(tree);
+  true_nhits  = PHYREX_Total_Number_Of_Hit_Disks(tree);
+  true_height = PHYREX_Tree_Height(tree);
+  true_rhoe   = PHYREX_Effective_Density(tree);
+
+  PhyML_Fprintf(fp_stats,"\n# before rand glnL: %f alnL: %f",tree->mmod->c_lnL,tree->c_lnL);
+  PhyML_Fprintf(fp_stats,"\n# ninter: %d",PHYREX_Total_Number_Of_Intervals(tree));
+  PhyML_Fprintf(fp_stats,"\n# ncoal: %d",PHYREX_Total_Number_Of_Coal_Disks(tree));
+  PhyML_Fprintf(fp_stats,"\n# nhits: %d",PHYREX_Total_Number_Of_Hit_Disks(tree));
+  PhyML_Fprintf(fp_stats,"\n# root pos: %f %f",true_root_x,true_root_y);
+  PhyML_Fprintf(fp_stats,"\n# root time: %f",disk->time);
+  PhyML_Fprintf(fp_stats,"\n# true lbda: %f",tree->mmod->lbda);
+  PhyML_Fprintf(fp_stats,"\n# true mu: %f",tree->mmod->mu);
+  PhyML_Fprintf(fp_stats,"\n# true rad: %f",PHYREX_Update_Radius(tree));
+  PhyML_Fprintf(fp_stats,"\n# true sigsq: %f",tree->mmod->sigsq);
+  PhyML_Fprintf(fp_stats,"\n# true neigh. size: %f",PHYREX_Neighborhood_Size(tree));
+  PhyML_Fprintf(fp_stats,"\n# fst-based estimate of neighborhood size: %f",PHYREX_Neighborhood_Size_Regression(tree));
+  PhyML_Fprintf(fp_stats,"\n# true pop. density: %f",true_rhoe);
+  PhyML_Fprintf(fp_stats,"\n# nucleotide diversity: %f",Nucleotide_Diversity(tree->data));
+  PhyML_Fprintf(fp_stats,"\n# length of a generation: %G time units",PHYREX_Generation_Length(tree));
+  PhyML_Fprintf(fp_stats,"\n# clock rate: %G subst. per time unit",tree->rates->clock_r);
+  PhyML_Fprintf(fp_stats,"\n# proportion of sampled area: %f",tree->mmod->sampl_area);
+
+  /* Starting parameter values */
+  tree->mmod->lbda = Uni()*(0.5 - 0.2) + 0.2;
+  tree->mmod->mu   = Uni()*(0.6 - 0.3) + 0.3;
+  tree->mmod->rad  = Uni()*(4.0 - 2.0) + 2.0;
+  PHYREX_Update_Sigsq(tree);
+
+  /* tree->mmod->lbda = Uni()*(0.50 - 0.20) + 0.20; */
+  /* tree->mmod->mu   = Uni()*(0.30 - 0.05) + 0.05; */
+  /* tree->mmod->rad  = Uni()*(3.00 - 1.00) + 1.00; */
+  /* PHYREX_Update_Sigsq(tree); */
+
+  /* MCMC_Randomize_Rate_Across_Sites(tree); */
+  MCMC_Randomize_Kappa(tree);
+
+  /* Random genealogy */
+  PHYREX_Simulate_Backward_Core(NO,tree->disk,tree);
+
+  PHYREX_Lk(tree);
+
+  Switch_Eigen(YES,tree->mod);
+  Lk(NULL,tree);
+  Switch_Eigen(NO,tree->mod);
+
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+
+  PhyML_Fprintf(fp_stats,"\n# after rand glnL: %f alnL: %f",tree->mmod->c_lnL,tree->c_lnL);
+  PhyML_Fprintf(fp_stats,"\n# ninter: %d",PHYREX_Total_Number_Of_Intervals(tree));
+  PhyML_Fprintf(fp_stats,"\n# ncoal: %d",PHYREX_Total_Number_Of_Coal_Disks(tree));
+  PhyML_Fprintf(fp_stats,"\n# nhits: %d",PHYREX_Total_Number_Of_Hit_Disks(tree));
+  PhyML_Fprintf(fp_stats,"\n# root pos: %f %f",true_root_x,true_root_y);
+  PhyML_Fprintf(fp_stats,"\n# root time: %f",disk->time);
+  PhyML_Fprintf(fp_stats,"\n# start lbda: %f",tree->mmod->lbda);
+  PhyML_Fprintf(fp_stats,"\n# start mu: %f",tree->mmod->mu);
+  PhyML_Fprintf(fp_stats,"\n# start rad: %f",tree->mmod->rad);
+  fflush(NULL);
+
+
+  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%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s",
+                "sample",
+                "lnP",
+                "alnL",
+                "glnL",
+                "lbda",
+                "modLbda",
+                "mu",
+                "modNeigh",
+                "sigsq",
+                "modSigsq",
+                "rad",
+                "neigh",
+                "rhoe",
+                "nInt",
+                "nCoal",
+                "nHit",
+                "rootTime",
+                "tstv",
+                "alpha",
+                "accLbda",
+                "accMu",
+                "accRad",
+                "accInDelDisk",
+                "accInDelHit",
+                "accScaleTime",
+                "accSPR",
+                "accPath",
+                "accSim",
+                "accLbdaTimes",
+                "accSimPlus",
+                "accIndelSerial",
+
+                "accLdskGivenDisk",
+                "accDiskGivenLdsk",
+                "accDiskAndLdsk",
+                "accLdskMulti",
+                "accDiskMulti",
+
+                "tuneLbda",
+                "tuneRad",
+                "tuneMu");
+
+  For(i,mcmc->n_moves) tree->mcmc->start_ess[i] = YES;
+
+  Set_Both_Sides(NO,tree);
+  mcmc->use_data   = YES; 
+  mcmc->always_yes = NO;
+  move             = -1;
+  do
+    {
+
+      /* tree->mcmc->adjust_tuning[i] = NO; */
+      if(mcmc->run > adjust_len) For(i,mcmc->n_moves) tree->mcmc->adjust_tuning[i] = NO;
+
+      if(tree->mmod->c_lnL < UNLIKELY + 0.1)
+        {
+          PhyML_Printf("\n== Move '%s' failed\n",tree->mcmc->move_name[move]);
+          assert(FALSE);
+        }
+
+      u = Uni();
+
+      For(move,tree->mcmc->n_moves) if(tree->mcmc->move_weight[move] > u-1.E-10) break;
+
+      assert(!(move == tree->mcmc->n_moves));
+
+      /* printf("\n. %10d %30s %f",tree->mcmc->run,tree->mcmc->move_name[move],tree->mmod->c_lnL); fflush(NULL); */
+      /* printf("\n. %10d %30s %f",tree->mcmc->run,tree->mcmc->move_name[move],PHYREX_Lk(tree)); */
+      
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_lbda"))
+        MCMC_PHYREX_Lbda(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_mu"))
+        MCMC_PHYREX_Mu(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_rad"))
+        MCMC_PHYREX_Radius(tree);
+
+      /* /\* if(!strcmp(tree->mcmc->move_name[move],"phyrex_sigsq")) *\/ */
+      /* /\*   MCMC_PHYREX_Sigsq(tree); *\/ */
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_indel_disk"))
+        MCMC_PHYREX_Indel_Disk(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_indel_hit"))
+        MCMC_PHYREX_Indel_Hit(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_move_disk_ud"))
+        MCMC_PHYREX_Move_Disk_Updown(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_swap_disk"))
+        MCMC_PHYREX_Swap_Disk(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_spr"))
+        MCMC_PHYREX_Prune_Regraft(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_scale_times"))
+        MCMC_PHYREX_Scale_Times(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_sim"))
+        MCMC_PHYREX_Simulate_Backward(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_sim_plus"))
+        MCMC_PHYREX_Simulate_Backward_Plus(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_traj"))
+        MCMC_PHYREX_Lineage_Traj(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_lbda_times"))
+        MCMC_PHYREX_Lbda_Times(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_disk_multi"))
+        MCMC_PHYREX_Disk_Multi(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_ldsk_multi"))
+        MCMC_PHYREX_Ldsk_Multi(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_ldsk_and_disk"))
+        MCMC_PHYREX_Ldsk_And_Disk(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_ldsk_given_disk"))
+        MCMC_PHYREX_Ldsk_Given_Disk(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_disk_given_ldsk"))
+        MCMC_PHYREX_Disk_Given_Ldsk(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_indel_disk_serial"))
+        MCMC_PHYREX_Indel_Disk_Serial(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"phyrex_indel_hit_serial"))
+        MCMC_PHYREX_Indel_Hit_Serial(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"kappa"))
+        MCMC_Kappa(tree);
+
+      if(!strcmp(tree->mcmc->move_name[move],"ras"))
+        MCMC_Rate_Across_Sites(tree);
+
+      /* /\* if(!strcmp(tree->mcmc->move_name[move],"phyrex_ldscape_lim")) *\/ */
+      /* /\*   MCMC_PHYREX_Ldscape_Limits(tree); *\/ */
+
+      tree->mcmc->run++;
+      MCMC_Get_Acc_Rates(tree->mcmc);
+      
+
+
+
+      if(!(tree->mcmc->run%tree->mcmc->sample_interval))
+        {
+          /* Lk(NULL,tree); */
+
+          /* RATES_Update_Cur_Bl(tree); */
+          /* char *s = Write_Tree(tree,NO); */
+          /* PhyML_Fprintf(fp_tree,"\n[%f %f] %s",s,tree->rates->nd_t[tree->n_root->num],tree->c_lnL); */
+          /* Free(s); */
+          /* fflush(NULL); */
+
+          disk = tree->disk;
+          while(disk->prev) disk = disk->prev;
+
+          PhyML_Fprintf(fp_stats,"\n%6d\t%9.1f\t%9.1f\t%9.1f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%G\t%6d\t%6d\t%6d\t%8.1f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%6.2f\t%G\t%G\t%G",
+                        tree->mcmc->run,
+                        tree->c_lnL+tree->mmod->c_lnL,
+                        tree->c_lnL,
+                        tree->mmod->c_lnL,
+                        tree->mmod->lbda,
+                        tree->mcmc->mode[tree->mcmc->num_move_phyrex_lbda],
+                        tree->mmod->mu,
+                        tree->mcmc->mode[tree->mcmc->num_move_phyrex_mu],
+                        PHYREX_Update_Sigsq(tree),
+                        tree->mcmc->mode[tree->mcmc->num_move_phyrex_sigsq],
+                        tree->mmod->rad,
+                        PHYREX_Neighborhood_Size(tree),
+                        PHYREX_Effective_Density(tree),
+                        PHYREX_Total_Number_Of_Intervals(tree),
+                        PHYREX_Total_Number_Of_Coal_Disks(tree),
+                        PHYREX_Total_Number_Of_Hit_Disks(tree),
+                        disk->time,
+                        tree->mod->kappa->v,
+                        tree->mod->ras->alpha->v,
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_lbda],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_mu],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_rad],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_indel_disk],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_indel_hit],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_scale_times],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_spr],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_traj],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_sim],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_lbda_times],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_sim_plus],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_indel_hit_serial],
+
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_ldsk_given_disk],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_disk_given_ldsk],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_ldsk_and_disk],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_ldsk_multi],
+                        tree->mcmc->acc_rate[tree->mcmc->num_move_phyrex_disk_multi],
+
+                        tree->mcmc->tune_move[tree->mcmc->num_move_phyrex_lbda],
+                        tree->mcmc->tune_move[tree->mcmc->num_move_phyrex_rad],
+                        tree->mcmc->tune_move[tree->mcmc->num_move_phyrex_mu]);
+
+          fflush(fp_stats);
+          
+          res[0 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = tree->mmod->lbda; 
+          res[1 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = tree->mmod->mu; 
+          res[2 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = PHYREX_Update_Sigsq(tree); 
+          res[3 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = PHYREX_Neighborhood_Size(tree);
+          res[4 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = tree->mmod->rad;
+          res[5 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = PHYREX_Total_Number_Of_Intervals(tree);
+          res[6 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = PHYREX_Total_Number_Of_Coal_Disks(tree);
+          res[7 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = PHYREX_Total_Number_Of_Hit_Disks(tree);
+          res[8 * tree->mcmc->chain_len / tree->mcmc->sample_interval +  tree->mcmc->run / tree->mcmc->sample_interval] = PHYREX_Effective_Density(tree);
+
+          MCMC_Copy_To_New_Param_Val(tree->mcmc,tree);
+          
+          For(i,tree->mcmc->n_moves) if(tree->mcmc->start_ess[i] == YES) MCMC_Update_Effective_Sample_Size(i,tree->mcmc,tree);
+          For(i,tree->mcmc->n_moves) MCMC_Update_Mode(i,tree->mcmc,tree);
+
+
+          burnin = (int)(0.5*(tree->mcmc->run / tree->mcmc->sample_interval));
+          
+          rewind(fp_summary);
+
+          PhyML_Fprintf(fp_summary,"\n# SampArea\t TrueLbda\t TrueMu\t TrueSig\t TrueRad\t TrueNeigh\t TrueRhoe\t Diversity\t TrueInt\t TrueCoal\t TrueHits\t RegNeigh\t TrueXroot\t TrueYroot\t TrueHeight\t Lbda5\t Lbda50\t Lbda95\t LbdaMod \t Mu5\t Mu50\t Mu95\t  MuMod \t Sig5\t Sig50\t Sig95\t SigMod \t Neigh5\t Neigh50\t Neigh95\t NeighMod \t Rad5\t Rad50\t Rad95\t Int5\t Int50\t Int95\t Coal5\t Coal50\t Coal95\t Hit5\t Hit50\t Hit95\t Rhoe5\t Rhoe50\t Rhoe95\t ESSLbda \t ESSMu \t ESSS [...]
+          
+          PhyML_Fprintf(fp_summary,"\n %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %d\t %d\t %d\t %f\t %f\t %f\t %f\t ",
+                        tree->mmod->sampl_area,
+                        true_lbda,
+                        true_mu,
+                        true_sigsq,
+                        true_rad,
+                        true_neigh,
+                        true_rhoe,
+                        diversity,
+                        true_nint,
+                        true_ncoal,
+                        true_nhits,
+                        fst_neigh,
+                        true_root_x,
+                        true_root_y,
+                        true_height);
+          
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t %f\t",
+                        /* Lbda5 */  Quantile(res+0*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* Lbda50 */ Quantile(res+0*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* Lbda95 */ Quantile(res+0*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975),
+                        /* LbdaMod*/ tree->mcmc->mode[tree->mcmc->num_move_phyrex_lbda]);
+          
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t %f\t",
+                        /* mu5 */   Quantile(res+1*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* mu50 */  Quantile(res+1*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* mu95 */  Quantile(res+1*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975),
+                        /* muMod */ 2./tree->mcmc->mode[tree->mcmc->num_move_phyrex_mu]);
+                    
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t %f\t",
+                        /* sig5 */   Quantile(res+2*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* sig50*/   Quantile(res+2*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* sig95*/   Quantile(res+2*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975),
+                        /* sigMod */ tree->mcmc->mode[tree->mcmc->num_move_phyrex_sigsq]);
+          
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t %f\t",
+                        /* Neigh5 */   Quantile(res+3*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* Neigh50*/   Quantile(res+3*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* Neigh95*/   Quantile(res+3*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975),
+                        /* NeighMod */ tree->mcmc->mode[tree->mcmc->num_move_phyrex_mu]);
+
+          
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t",
+                        /* Rad5 */  Quantile(res+4*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* Rad50 */ Quantile(res+4*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* Rad95 */ Quantile(res+4*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975));
+
+
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t",
+                        /* Int5 */  Quantile(res+5*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* Int50 */ Quantile(res+5*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* Int95 */ Quantile(res+5*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975));
+
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t",
+                        /* Coal5 */  Quantile(res+6*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* Coal50 */ Quantile(res+6*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* Coal95 */ Quantile(res+6*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975));
+
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t",
+                        /* Hit5 */  Quantile(res+7*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* Hit50 */ Quantile(res+7*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* Hit95 */ Quantile(res+7*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975));
+                    
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t",
+                        /* rhoe5 */  Quantile(res+8*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.025),
+                        /* rhoe50 */ Quantile(res+8*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.50),
+                        /* rhoe95 */ Quantile(res+8*tree->mcmc->chain_len / tree->mcmc->sample_interval+burnin,tree->mcmc->run / tree->mcmc->sample_interval+1-burnin,0.975));
+
+          PhyML_Fprintf(fp_summary,"%f\t %f\t %f\t",
+                        tree->mcmc->ess[tree->mcmc->num_move_phyrex_lbda],
+                        tree->mcmc->ess[tree->mcmc->num_move_phyrex_mu],  
+                        tree->mcmc->ess[tree->mcmc->num_move_phyrex_sigsq]);
+
+          PhyML_Fprintf(fp_summary,"%d\t",tree->mcmc->run);
+
+          PhyML_Fprintf(fp_summary,"\n\n");
+
+          fflush(NULL);
+                
+          tree->mcmc->sample_num++;
+        }
+
+
+
+      if(tree->mcmc->run > 2*adjust_len                            &&
+         tree->mcmc->sample_num > 1E+2                             &&
+         tree->mcmc->ess[tree->mcmc->num_move_phyrex_lbda]  > 100. &&
+         tree->mcmc->ess[tree->mcmc->num_move_phyrex_mu]    > 100. &&
+         tree->mcmc->ess[tree->mcmc->num_move_phyrex_sigsq] > 100.) break;
+
+      /* if(tree->mcmc->run > tree->mcmc->sample_interval           &&  */
+      /*    tree->mcmc->ess[tree->mcmc->num_move_phyrex_lbda]  > 1. && */
+      /*    tree->mcmc->ess[tree->mcmc->num_move_phyrex_mu]    > 1. && */
+      /*    tree->mcmc->ess[tree->mcmc->num_move_phyrex_sigsq] > 1.) break; */
+
+      (void)signal(SIGINT,MCMC_Terminate);
+    }
+  while(tree->mcmc->run < tree->mcmc->chain_len);
+
+  fclose(fp_tree);
+  fclose(fp_stats);
+  fclose(fp_summary);
+
+  return(res);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl PHYREX_Wrap_Lk(t_edge *b, t_tree *tree, supert_tree *stree)
+{
+  return PHYREX_Lk(tree);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+void PHYREX_New_Traj(t_dsk *start, t_dsk *end, t_tree *tree)
+{
+  t_dsk *disk;
+  int i,j;
+  int n_hit_up,n_hit_tot;
+  /* phydbl min_up, min_do; */
+  /* phydbl max_up, max_do; */
+
+
+
+  For(i,start->n_ldsk_a)
+    {      
+      /* printf("\n<><><>"); */
+
+      disk = end;
+      while(disk != start)
+        {
+          /* disk->ldsk_a[i]->min_coord = GEO_Make_Geo_Coord(disk->mmod->n_dim); */
+          /* disk->ldsk_a[i]->max_coord = GEO_Make_Geo_Coord(disk->mmod->n_dim);                     */
+          disk = disk->prev;
+        }
+
+      disk = end;
+      n_hit_tot = 0;
+      while(disk != start)
+        {
+          if(disk->ldsk_a[i]->is_hit == YES) n_hit_tot++;
+          disk = disk->prev;
+        }
+
+
+      /* printf("\n. n_hit_tot: %d",n_hit_tot); */
+      /* fflush(NULL); */
+
+      /* printf("\n. Start disk name: %s lindisk %s at %.2f [%.2f %.2f] end disk: %s lindisk %s at %.2f [%.2f %.2f]", */
+      /*        start->id, */
+      /*        start->ldsk_a[i]->coord->id, */
+      /*        start->time, */
+      /*        start->ldsk_a[i]->coord->lonlat[0], */
+      /*        start->ldsk_a[i]->coord->lonlat[1], */
+      /*        end->id, */
+      /*        end->ldsk_a[i]->coord->id, */
+      /*        end->time, */
+      /*        end->ldsk_a[i]->coord->lonlat[0], */
+      /*        end->ldsk_a[i]->coord->lonlat[1] */
+      /*        ); */
+      /* disk = end; */
+      /* while(disk != start) */
+      /*   { */
+      /*     printf("\n. %d %s %.2f %.2f", */
+      /*            i, */
+      /*            disk->ldsk_a[i]->coord->id, */
+      /*            disk->ldsk_a[i]->coord->lonlat[0], */
+      /*            disk->ldsk_a[i]->coord->lonlat[1]); */
+      /*     disk = disk->prev; */
+      /*   } */
+      
+      n_hit_up = 0;
+      disk = end;
+      while(disk->prev != start)
+        {
+          if(disk->ldsk_a[i]->is_hit == YES)
+            {              
+              n_hit_up++;
+
+              For(j,disk->mmod->n_dim)
+                {
+                  /* min_up = end->ldsk_a[i]->coord->lonlat[j] - n_hit_up * 2. * disk->mmod->rad; */
+                  /* min_do = start->ldsk_a[i]->coord->lonlat[j] - (n_hit_tot - n_hit_up) * 2. * disk->mmod->rad; */
+                  /* disk->ldsk_a[i]->prev->min_coord->lonlat[j] =  */
+                  /*   MAX(MAX(MAX(min_up,min_do),0.0),disk->prev->centr->lonlat[j] - disk->mmod->rad); */
+
+                  /* max_up = end->ldsk_a[i]->coord->lonlat[j] + n_hit_up * 2. * disk->mmod->rad; */
+                  /* max_do = start->ldsk_a[i]->coord->lonlat[j] + (n_hit_tot - n_hit_up) * 2. * disk->mmod->rad; */
+                  /* disk->ldsk_a[i]->prev->max_coord->lonlat[j] =  */
+                  /*   MIN(MIN(MIN(max_up,max_do),disk->mmod->lim->lonlat[j]),disk->prev->centr->lonlat[j] + disk->mmod->rad); */
+
+                  /* printf("\n. curr: %s min_up: %.2f min_do: %.2f max_up: %.2f max_do: %.2f %d %d start: %.2f [%.2f %.2f]", */
+                  /*        disk->ldsk_a[i]->prev->coord->id, */
+                  /*        min_up,min_do,max_up,max_do, */
+                  /*        n_hit_tot,n_hit_up, */
+                  /*        start->ldsk_a[i]->coord->lonlat[j], */
+                  /*        disk->ldsk_a[i]->prev->min_coord->lonlat[j], */
+                  /*        disk->ldsk_a[i]->prev->max_coord->lonlat[j]); */
+                }
+            }
+          disk = disk->prev;
+        }
+      
+      disk = end;
+      while(disk->prev != start)
+        {
+          if(disk->ldsk_a[i]->is_hit == YES)
+            {
+              /* For(j,disk->mmod->n_dim) */
+                /* disk->ldsk_a[i]->prev->coord->lonlat[j] =  */
+                /* Uni()* */
+                /* (disk->ldsk_a[i]->prev->max_coord->lonlat[j]  - */
+                /*  disk->ldsk_a[i]->prev->min_coord->lonlat[j]) + */
+                /* disk->ldsk_a[i]->prev->min_coord->lonlat[j]; */
+            }
+          else
+            {
+              For(j,disk->mmod->n_dim)
+                disk->ldsk_a[i]->prev->coord->lonlat[j] = 
+                disk->ldsk_a[i]->coord->lonlat[j];
+            }
+
+          disk = disk->prev;
+        }
+      
+      disk = end;
+      while(disk != start)
+        {
+          /* Free_Geo_Coord(disk->ldsk_a[i]->min_coord); */
+          /* Free_Geo_Coord(disk->ldsk_a[i]->max_coord); */
+          disk = disk->prev;
+        }
+    }
+
+  /* gtk_widget_queue_draw(tree->draw_area); */
+  
+  /* For(i,start->n_ldsk_a) */
+  /*   { */
+  /*     printf("\n<><><>"); */
+  /*     disk = end; */
+  /*     while(disk != start) */
+  /*       { */
+  /*         printf("\nx %s %.2f %.2f centr: %.2f %.2f", */
+  /*                disk->ldsk_a[i]->coord->id, */
+  /*                disk->ldsk_a[i]->coord->lonlat[0], */
+  /*                disk->ldsk_a[i]->coord->lonlat[1], */
+  /*                disk->centr->lonlat[0], */
+  /*                disk->centr->lonlat[1]); */
+  /*         disk = disk->prev; */
+  /*       } */
+  /*     fflush(NULL); */
+  /*   } */
+  
+  /* PHYREX_Lk(tree); */
+  /* printf("\n. >> Lk: %f rad: %f",tree->mmod->c_lnL,tree->mmod->rad); */
+  /* sleep(5); */
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Remove_Disk(t_dsk *disk)
+{
+  t_dsk *prev;
+  t_dsk *next;
+
+  prev = disk->prev;
+  next = disk->next;
+
+  assert(!(prev == NULL));
+  assert(!(next == NULL));    
+  
+  prev->next = next;
+  next->prev = prev;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Insert disk event based on its time. Insertion above the root is not permitted  
+*/
+void PHYREX_Insert_Disk(t_dsk *ins, t_tree *tree)
+{
+  t_dsk *disk;
+
+  assert(!(ins == NULL));
+  
+  disk = tree->disk->prev;  
+  while(disk != NULL && disk->time > ins->time) disk = disk->prev;
+
+  assert(!(disk == NULL));
+
+  ins->prev       = disk;
+  ins->next       = disk->next;
+  disk->next      = ins;
+  ins->next->prev = ins;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+t_ldsk *PHYREX_Prev_Coal_Lindisk(t_ldsk *t)
+{
+  if(t == NULL) return NULL;
+
+  if(t->n_next > 1) 
+    {
+      return t;
+    }
+  else
+    {
+      return PHYREX_Prev_Coal_Lindisk(t->prev);
+    }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+t_ldsk *PHYREX_Next_Coal_Lindisk(t_ldsk *t)
+{
+  assert(!(t == NULL)); 
+
+  if(t->n_next > 1 || t->next == NULL) return t;
+  else
+    {
+      if(t->n_next > 1) // Should have t->is_coal = YES
+        {
+          PhyML_Printf("\n== Err. in file %s at line %d (function '%s') \n",__FILE__,__LINE__,__FUNCTION__);
+          Warn_And_Exit("");
+        }
+      return PHYREX_Next_Coal_Lindisk(t->next[0]);
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/*  Generate a new trajectory, including disk event centers, between  
+    'y_ldsk' a ``young'' lindisk event and 'o_ldsk' an old one. 'y_ldsk 
+    and 'o_ldsk' remain unaffected. No disk events should be present    
+    between y_ldsk and o_ldsk: we need to generate some first. n_cur_disk
+    is the current number of disks between y_ldsk and o_ldsk.
+*/
+int PHYREX_One_New_Traj(t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y, t_dsk *xtra_dsk, int n_cur_disk, t_tree *tree)
+{
+  t_phyrex_mod *mmod;
+  t_dsk *disk,**disk_new;
+  int i,n,K;
+  int min_n_disk,n_new_disk,n_disk;
+
+  mmod     = tree->mmod;
+  disk     = NULL;
+  disk_new = NULL;
+  K        = 2;
+
+  /* printf("\n# New traj from %s to %s",y_ldsk->coord->id,o_ldsk->coord->id); */
+  /* fflush(NULL); */
+
+  /* Minimum number of disks between y_ldsk and o_ldsk */
+  min_n_disk = 0;
+  For(i,mmod->n_dim)
+    {
+      /* PhyML_Printf("\n# y_ldsk %s : %f o_ldsk->disk->centr: %f rad: %f", */
+      /*              y_ldsk->coord->id, */
+      /*              y_ldsk->coord->lonlat[i], */
+      /*              o_ldsk->disk->centr->lonlat[i], */
+      /*              mmod->rad); */
+      if(y_ldsk->coord->lonlat[i] < o_ldsk->disk->centr->lonlat[i])
+        {
+          n_disk = 0;
+          while(y_ldsk->coord->lonlat[i] + (2*n_disk-1)*mmod->rad < o_ldsk->disk->centr->lonlat[i] - mmod->rad) n_disk++;
+          if(n_disk > min_n_disk) min_n_disk = n_disk;
+        }
+      else
+        {
+          n_disk = 0;
+          while(y_ldsk->coord->lonlat[i] - (2*n_disk-1)*mmod->rad > o_ldsk->disk->centr->lonlat[i] + mmod->rad) n_disk++;
+          if(n_disk > min_n_disk) min_n_disk = n_disk;
+        }
+      /* printf("  -- min_n_disk: %d",min_n_disk); */
+    }
+  
+  /* printf("\n# min_n_disk: %d cur_n_disk: %d",min_n_disk,n_cur_disk); */
+  /* fflush(NULL); */
+  
+  /* How many disks along the new path between y_ldsk and o_ldsk */
+  n_new_disk = Rand_Int(n_cur_disk-K,n_cur_disk+K);
+  if(n_new_disk < min_n_disk) n_new_disk = min_n_disk;
+
+  if(xtra_dsk != NULL) n_new_disk++;
+
+  /* printf("\n# Add n_new_disk: %d",n_new_disk); fflush(NULL); */
+  
+  if(n_new_disk > 0)
+    {
+      /* Make new disks to create a new path between ldsk_left and ldsk_up */
+      disk_new = (t_dsk **)mCalloc(n_new_disk,sizeof(t_dsk *));
+      For(i,n_new_disk-1)  disk_new[i] = PHYREX_Make_Disk_Event(mmod->n_dim,tree->n_otu);
+      if(xtra_dsk != NULL) disk_new[n_new_disk-1] = xtra_dsk;
+      else                 disk_new[n_new_disk-1] = PHYREX_Make_Disk_Event(mmod->n_dim,tree->n_otu);
+
+      For(i,n_new_disk)  PHYREX_Init_Disk_Event(disk_new[i],mmod->n_dim,mmod);
+
+      /* Times of these new disks. If xtra_dsk != NULL, then make sure you do not */
+      /* reset the time of that disk  */
+      n = (xtra_dsk != NULL) ? (n_new_disk-1) : (n_new_disk);
+      For(i,n)
+        disk_new[i]->time =
+        Uni()*(y_ldsk->disk->time - o_ldsk->disk->time) + o_ldsk->disk->time;       
+     
+      /* Insert these events */
+      For(i,n_new_disk)
+        {
+          assert(!tree->disk->next);
+          disk = tree->disk;
+          while(disk->time > disk_new[i]->time) disk = disk->prev;
+          PHYREX_Insert_Disk(disk_new[i],tree);
+        }
+            
+      /* For(i,n_new_disk) */
+      /*   { */
+      /*     printf("\n> disk_new: %f [%s]",disk_new[i]->time,disk_new[i]->id); fflush(NULL); */
+      /*   } */
+      
+      /* Add new lindisks to the new disk events */
+      For(i,n_new_disk)
+        {
+          disk_new[i]->ldsk = PHYREX_Make_Lindisk_Node(tree->mmod->n_dim);
+          PHYREX_Init_Lindisk_Node(disk_new[i]->ldsk,disk_new[i],tree->mmod->n_dim);
+          PHYREX_Make_Lindisk_Next(disk_new[i]->ldsk);
+          /* printf("\n# Add ldsk %s to %s",disk_new[i]->ldsk->coord->id,disk_new[i]->id); fflush(NULL); */
+        }
+      
+      /* Connect them */
+      PHYREX_Connect_Ldsk_Given_Disk(disk_new,n_new_disk,y_ldsk,o_ldsk,dir_o_y);
+
+      Free(disk_new);
+    }
+  else
+    {
+      o_ldsk->next[dir_o_y] = y_ldsk;
+      y_ldsk->prev          = o_ldsk;
+    }
+ 
+  /* Generate a trajectory */
+  PHYREX_One_New_Traj_Given_Disk(y_ldsk,o_ldsk,tree);  
+
+  return(n_new_disk);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Generate a new trajectory, including disk event centers, between 
+  'y_ldsk' a ``young'' lindisk event and 'o_ldsk' an old one. 'y_ldsk 
+  and 'o_ldsk' remain unaffected. Disk events between these two ldsk 
+  should already be set. 
+*/
+void PHYREX_One_New_Traj_Given_Disk(t_ldsk *y_ldsk, t_ldsk *o_ldsk, t_tree *tree)
+{
+  int n_disk_btw;
+  t_ldsk *ldsk;
+  phydbl min, max;
+  phydbl *min_disk_coord, *max_disk_coord;
+  int i,k;
+  phydbl rad;
+
+
+  /* Number of disks between y_ldsk and o_ldsk */
+  ldsk = y_ldsk;
+  n_disk_btw = 0;
+  while(ldsk->prev != o_ldsk)
+    {
+      n_disk_btw++;
+      ldsk = ldsk->prev;
+    }
+
+  if(n_disk_btw == 0) return;
+
+  ldsk = y_ldsk;
+  rad  = ldsk->disk->mmod->rad;
+  k    = 0;
+  while(ldsk != o_ldsk)
+    {
+      if(!ldsk->disk->next) /* Don't change location at tip node */
+        {
+          ldsk = ldsk->prev;
+          continue;
+        }
+      
+      PHYREX_Store_Geo_Coord(ldsk->coord);
+      PHYREX_Store_Geo_Coord(ldsk->disk->centr);
+
+      For(i,tree->mmod->n_dim)
+        {
+          min = 
+            MAX(0.0,
+                MAX(ldsk->coord->lonlat[i] - 2.*rad,
+                    o_ldsk->disk->centr->lonlat[i] - rad*(2.*(n_disk_btw-k)-1.)));
+
+          max = 
+            MIN(ldsk->disk->mmod->lim->lonlat[i],
+                MIN(ldsk->coord->lonlat[i] + 2.*rad,
+                    o_ldsk->disk->centr->lonlat[i] + rad*(2.*(n_disk_btw-k)-1.)));
+          
+          assert(!(max < min));
+                
+          /* New coordinates for the lindisk */
+          ldsk->coord->lonlat[i] = Uni()*(max - min) + min;
+        }
+
+      /* New coordinate for the centre of the corresponding disk event */
+      PHYREX_Get_Min_Max_Disk_Given_Ldsk(ldsk->disk,&min_disk_coord,&max_disk_coord,tree);
+      For(i,tree->mmod->n_dim) ldsk->disk->centr->lonlat[i] = Uni()*(max_disk_coord[i] - min_disk_coord[i]) + min_disk_coord[i];
+      Free(min_disk_coord);
+      Free(max_disk_coord);
+
+      ldsk = ldsk->prev;
+      k++;
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Uniform_Path_Density(t_ldsk *y_ldsk, t_ldsk *o_ldsk, t_tree *tree)
+{
+  int n_disk_btw;
+  t_ldsk *ldsk;
+  phydbl min, max;
+  int i,k;
+  phydbl rad;
+  phydbl log_dens;
+  phydbl *min_disk_coord, *max_disk_coord;
+
+  if(y_ldsk == o_ldsk) return .0;
+
+  /* Number of disks between y_ldsk and o_ldsk */
+  ldsk = y_ldsk;
+  n_disk_btw = 0;
+  while(ldsk->prev != o_ldsk)
+    {
+      n_disk_btw++;
+      ldsk = ldsk->prev;
+    }
+
+  if(n_disk_btw == 0) return .0;
+
+  log_dens = 0.0;
+  ldsk     = y_ldsk;
+  rad      = ldsk->disk->mmod->rad;
+  k        = 0;
+  while(ldsk != o_ldsk)
+    {
+      if(!ldsk->disk->next)
+        {
+          ldsk = ldsk->prev;
+          continue;
+        }
+      
+      For(i,ldsk->disk->mmod->n_dim)
+        {
+          min = 
+            MAX(0.0,
+                MAX(ldsk->coord->lonlat[i] - 2.*rad,
+                    o_ldsk->disk->centr->lonlat[i] - rad*(2.*(n_disk_btw-k)-1.)));
+
+          max = 
+            MIN(ldsk->disk->mmod->lim->lonlat[i],
+                MIN(ldsk->coord->lonlat[i] + 2.*rad,
+                    o_ldsk->disk->centr->lonlat[i] + rad*(2.*(n_disk_btw-k)-1.)));
+
+          assert(!(max < min));
+
+          log_dens -= LOG(max - min);          
+        }
+
+      PHYREX_Get_Min_Max_Disk_Given_Ldsk(ldsk->disk,&min_disk_coord,&max_disk_coord,tree);
+      For(i,tree->mmod->n_dim) log_dens -= LOG(max_disk_coord[i] - min_disk_coord[i]);
+      Free(min_disk_coord);
+      Free(max_disk_coord);
+
+      ldsk = ldsk->prev;
+      k++;
+    }
+
+  return(log_dens);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Return the index of the 'next' element of 'old' that should be
+   used in order to reach 'young'. 
+*/
+int PHYREX_Get_Next_Direction(t_ldsk *young, t_ldsk *old)
+{
+  if(young->disk->time < old->disk->time)
+    {
+      PhyML_Printf("\n== young (%s) @ time %f; old (%s) @ time %f",
+                   young->coord->id,young->disk->time,
+                   old->coord->id,old->disk->time);
+      fflush(NULL);
+      return(-1);   
+    }
+  
+  assert(!(young == NULL));
+ 
+  if(young->prev == old)
+    {
+      int i;
+      For(i,old->n_next) if(old->next[i] == young) return i;
+    }
+  else
+    {
+      return PHYREX_Get_Next_Direction(young->prev,old);
+    }
+  return(-1);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* void PHYREX_Update_Lindisk_List(phydbl time, t_ldsk **list, int *pos, t_dsk *disk) */
+/* { */
+/*   t_dsk *root_dsk; */
+
+/*   *pos = 0; */
+/*   root_dsk = disk; */
+/*   while(root_dsk->prev) root_dsk = root_dsk->prev; */
+/*   /\* printf("\n. root_dsk: %s",root_dsk?root_dsk->id:"xx"); *\/ */
+/*   PHYREX_Update_Lindisk_List_Pre(root_dsk->ldsk,time,list,pos); */
+/* } */
+
+/* /\*\//////////////////////////////////////////////////////////// */
+/* ////////////////////////////////////////////////////////////\*\/ */
+
+/* void PHYREX_Update_Lindisk_List_Pre(t_ldsk *ldsk, phydbl time, t_ldsk **list, int *pos) */
+/* { */
+/*   /\* printf("\n. time: %f pos: %d ldsk: %s disk: %s n_next: %d ldsk->disk->time: %f disk: %s", *\/ */
+/*   /\*        time, *\/ */
+/*   /\*        *pos, *\/ */
+/*   /\*        ldsk ? ldsk->coord->id : "xx", *\/ */
+/*   /\*        ldsk ? ldsk->disk->id : "zz", *\/ */
+/*   /\*        ldsk ? ldsk->n_next : -1, *\/ */
+/*   /\*        ldsk ? ldsk->disk->time : -1., *\/ */
+/*   /\*        ldsk ? ldsk->disk->id : "yy"); fflush(NULL); *\/ */
+
+/*   if(ldsk == NULL) Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
+
+/*   if((ldsk->prev != NULL) && (ldsk->disk->time > time) && (ldsk->prev->disk->time < time)) */
+/*     { */
+/*       list[*pos] = ldsk; */
+/*       *pos = *pos + 1; */
+/*     } */
+/*   else if(Are_Equal(ldsk->disk->time,time,1.E-10)) */
+/*     { */
+/*       list[*pos] = ldsk; */
+/*       *pos = *pos + 1;       */
+/*     } */
+/*   else if(ldsk->disk->time < time) */
+/*     { */
+/*       int i; */
+/*       For(i,ldsk->n_next) */
+/*         PHYREX_Update_Lindisk_List_Pre(ldsk->next[i],time,list,pos);     */
+/*     } */
+/*   else Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
+    
+/* } */
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Update_Lindisk_List(t_tree *tree)
+{
+  PHYREX_Update_Lindisk_List_Pre(tree->disk->prev,tree);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Update_Lindisk_List_Pre(t_dsk *disk, t_tree *tree)
+{
+  if(!disk) return;
+  else
+    {
+      PHYREX_Update_Lindisk_List_Core(disk,tree);
+      PHYREX_Update_Lindisk_List_Pre(disk->prev,tree);    
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Update_Lindisk_List_Core(t_dsk *disk, t_tree *tree)
+{
+  int i;
+
+  if(!disk->next) return;
+
+  For(i,tree->n_otu) disk->ldsk_a[i] = NULL;
+
+  disk->n_ldsk_a = 0;
+  For(i,disk->next->n_ldsk_a)
+    {
+      if(disk->next->ldsk_a[i]->prev != disk->ldsk)
+        {
+          disk->ldsk_a[disk->n_ldsk_a] = disk->next->ldsk_a[i];
+          disk->n_ldsk_a++;
+        }
+    }
+  
+  if(disk->ldsk) 
+    {
+      disk->ldsk_a[disk->n_ldsk_a] = disk->ldsk;
+      disk->n_ldsk_a++;          
+    }
+  
+  /* if(disk->n_ldsk_a == 0 || disk->n_ldsk_a > tree->n_otu || (!disk->prev && disk->n_ldsk_a != 1))  */
+  if(disk->n_ldsk_a == 0 || disk->n_ldsk_a > tree->n_otu) 
+    {
+      PhyML_Printf("\n== disk %s %d %s",disk->id, disk->n_ldsk_a, disk->ldsk?disk->ldsk->coord->id:"xx");
+      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Connect all the ldsk between y_ldsk (young ldsk) and o_ldsk (old ldsk).
+   The disk between y_ldsk and o_ldsk should have all been set already
+   Note: the disks in **disk are sorted in ascending order of their 
+   times
+*/
+
+void PHYREX_Connect_Ldsk_Given_Disk(t_dsk **disk, int n_disk, t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y)
+{
+  int i,j;
+  t_dsk *disk_tmp;
+
+  /* Sort these events by ascending order of their times */
+  For(i,n_disk-1)
+    {
+      for(j=i+1;j<n_disk;j++)
+        {
+          if(disk[j]->time > disk[i]->time)
+            {
+              disk_tmp = disk[i];
+              disk[i]  = disk[j];
+              disk[j]  = disk_tmp;
+            }
+        }
+    }
+
+
+  For(i,n_disk)
+    {
+      if(!i)
+        {
+          disk[i]->ldsk->next[0] = y_ldsk;
+          y_ldsk->prev           = disk[i]->ldsk;
+          /* printf("\n. connect %s to %s",disk[i]->ldsk->coord->id,y_ldsk->coord->id); fflush(NULL); */
+        }
+      else
+        {
+          disk[i]->ldsk->next[0] = disk[i-1]->ldsk;
+          disk[i-1]->ldsk->prev  = disk[i]->ldsk;
+          /* printf("\n. connect %s to %s",disk[i]->ldsk->coord->id,disk[i-1]->ldsk->coord->id); fflush(NULL); */
+        }
+    }
+  
+  /* printf("\n. connect %s next dir: %d [%d] to %s",o_ldsk->coord->id,dir_o_y,o_ldsk->n_next,disk[n_disk-1]->ldsk->coord->id); fflush(NULL); */
+  o_ldsk->next[dir_o_y]      = disk[n_disk-1]->ldsk;
+  disk[n_disk-1]->ldsk->prev = o_ldsk;
+
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Print_Struct(char sign, t_tree *tree)
+{
+  t_dsk *disk;
+  int i,j;
+  t_ldsk *ldisk;
+
+  PHYREX_Update_Lindisk_List(tree);
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+  do
+    {
+      PhyML_Printf("\n%c Disk: %s @ %7.3f has %3s on it is_coal? %2d rad: %f coord ",
+             sign,
+             disk->id,
+             disk->time,disk->ldsk?disk->ldsk->coord->id:NULL,
+             disk->ldsk?disk->ldsk->n_next:-1,
+             tree->mmod->rad); fflush(NULL);
+      For(j,tree->mmod->n_dim) PhyML_Printf(" %f",disk->centr->lonlat[j]);
+      fflush(NULL);
+
+
+      For(i,disk->n_ldsk_a)
+        {
+          ldisk = disk->ldsk_a[i];
+
+          PhyML_Printf("\n%c ldisk: %s prev: %s",
+                       sign,
+                       ldisk->coord->id,
+                       ldisk->prev ? ldisk->prev->coord->id : NULL);
+          fflush(NULL);
+          
+          For(j,tree->mmod->n_dim) 
+            {
+              PhyML_Printf(" %f",ldisk->coord->lonlat[j]);
+              fflush(NULL);
+
+              if(FABS(ldisk->coord->lonlat[j] - ldisk->disk->centr->lonlat[j]) > 2.*tree->mmod->rad &&
+                 ldisk->disk->ldsk == ldisk) PhyML_Printf(" ! ");
+
+              if(ldisk->prev)
+                {
+                  if(ldisk->coord->lonlat[j] < ldisk->prev->disk->centr->lonlat[j] - tree->mmod->rad) PhyML_Printf(" #a ");
+                  if(ldisk->coord->lonlat[j] > ldisk->prev->disk->centr->lonlat[j] + tree->mmod->rad) PhyML_Printf(" #b ");
+                }
+
+              if(ldisk->next)
+                {
+                  if(ldisk->coord->lonlat[j] < ldisk->disk->centr->lonlat[j] - tree->mmod->rad) PhyML_Printf(" $a ");
+                  if(ldisk->coord->lonlat[j] > ldisk->disk->centr->lonlat[j] + tree->mmod->rad) PhyML_Printf(" $b ");
+                }
+            }
+        }
+
+      fflush(NULL);
+      disk = disk->next;      
+    }
+  while(disk);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Check_Struct(t_tree *tree)
+{
+  t_dsk *disk;
+  int i,j;
+  t_ldsk *ldisk;
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+  do
+    {
+      /* PHYREX_Update_Lindisk_List(disk->time,disk->ldsk_a,&(disk->n_ldsk_a),disk); */
+      PHYREX_Update_Lindisk_List(tree);
+
+      For(i,disk->n_ldsk_a)
+        {
+          ldisk = disk->ldsk_a[i];
+          if(ldisk->prev != NULL)
+            {
+              For(j,tree->mmod->n_dim)
+                {
+                  if(FABS(ldisk->coord->lonlat[j] - 
+                          ldisk->prev->coord->lonlat[j]) > 2.*tree->mmod->rad)
+                    {
+                      PHYREX_Print_Struct('=',tree);
+                      PhyML_Printf("\n== %f %f %f",
+                                   ldisk->coord->lonlat[j], 
+                                   ldisk->prev->coord->lonlat[j],
+                                   2.*tree->mmod->rad);
+                      PhyML_Printf("\n== Radius: %f",tree->mmod->rad);
+                      PhyML_Printf("\n== Check ldsk %s",ldisk->coord->id);
+                      PhyML_Printf("\n== Centr: %f",ldisk->prev->disk->centr->lonlat[j]);
+                      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+                    }
+                }
+            }
+        }
+
+      disk = disk->next;      
+    }
+  while(disk);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Store_Geo_Coord(t_geo_coord *t)
+{
+  int i;
+
+  For(i,t->dim) t->cpy->lonlat[i] = t->lonlat[i];  
+  t->cpy->dim = t->dim;
+  strcpy(t->cpy->id,t->id);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+
+void PHYREX_Restore_Geo_Coord(t_geo_coord *t)
+{
+  int i;
+
+  For(i,t->dim) t->lonlat[i] = t->cpy->lonlat[i];  
+  t->dim = t->cpy->dim;
+  strcpy(t->id,t->cpy->id);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int PHYREX_Total_Number_Of_Intervals(t_tree *tree)
+{
+  t_dsk *disk;
+  int n_intervals;
+
+  assert(!(tree->disk->next));
+
+  disk = tree->disk;
+  n_intervals = 0;
+  while(disk->prev)
+    {
+      n_intervals++;
+      disk = disk->prev;
+    }
+  return(n_intervals);
+
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int PHYREX_Total_Number_Of_Hit_Disks(t_tree *tree)
+{
+  t_dsk *disk;
+  int n_hit_disks;
+
+  assert(!(tree->disk->next));
+
+  disk = tree->disk;
+  n_hit_disks = 0;
+  while(disk)
+    {
+      if(disk->ldsk) n_hit_disks++;
+      disk = disk->prev;
+    }
+  return(n_hit_disks);
+
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int PHYREX_Total_Number_Of_Coal_Disks(t_tree *tree)
+{
+  t_dsk *disk;
+  int n_coal_disks;
+
+  assert(!(tree->disk->next));
+
+  disk = tree->disk;
+  n_coal_disks = 0;
+  while(disk)
+    {
+      if(disk->ldsk && disk->ldsk->n_next > 1) n_coal_disks++;
+      disk = disk->prev;
+    }
+
+  return(n_coal_disks);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Log_Dunif_Rectangle_Overlap(t_ldsk *ldsk, t_dsk *disk, t_phyrex_mod *mmod)
+{
+  phydbl up, down, left, rght;
+  phydbl log_dens;
+  /* phydbl main_mass,l; */
+
+  log_dens  = 0.0;
+  /* main_mass = 1. - mmod->soft_bound_area; */
+
+  up   = MIN(disk->centr->lonlat[0] + mmod->rad, mmod->lim->lonlat[0]);
+  down = MAX(disk->centr->lonlat[0] - mmod->rad, 0.0);
+  rght = MIN(disk->centr->lonlat[1] + mmod->rad, mmod->lim->lonlat[1]);
+  left = MAX(disk->centr->lonlat[1] - mmod->rad, 0.0);
+
+
+  /* l = main_mass / (.5*(1.-main_mass)*(up - down)); */
+  /* if(ldsk->coord->lonlat[0] < down)    log_dens += LOG(.5*(1.-main_mass)) + LOG(l) - l*(down - ldsk->coord->lonlat[0]); */
+  /* else if(ldsk->coord->lonlat[0] > up) log_dens += LOG(.5*(1.-main_mass)) + LOG(l) - l*(ldsk->coord->lonlat[0] - up); */
+  /* else log_dens += LOG(main_mass) - LOG(up - down); */
+
+  /* l = main_mass / (.5*(1.-main_mass)*(rght - left)); */
+  /* if(ldsk->coord->lonlat[1] < left)      log_dens += LOG(.5*(1.-main_mass)) + LOG(l) - l*(left - ldsk->coord->lonlat[1]); */
+  /* else if(ldsk->coord->lonlat[1] > rght) log_dens += LOG(.5*(1.-main_mass)) + LOG(l) - l*(ldsk->coord->lonlat[1] - rght); */
+  /* else log_dens += LOG(main_mass) - LOG(rght - left); */
+
+
+  if(ldsk->coord->lonlat[0] < down)  return UNLIKELY;
+  if(ldsk->coord->lonlat[0] > up)    return UNLIKELY;
+  if(ldsk->coord->lonlat[1] < left)  return UNLIKELY;
+  if(ldsk->coord->lonlat[1] > rght)  return UNLIKELY;
+
+  log_dens = -LOG(up-down)-LOG(rght-left);
+
+  return(log_dens);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Samples uniformly within a rectangle (with truncation for border) */
+/* and returns the corresponding log density */
+phydbl PHYREX_Runif_Rectangle_Overlap(t_ldsk *ldsk, t_dsk *disk, t_phyrex_mod *mmod)
+{
+  phydbl up, down, left, rght;
+
+  up   = MIN(disk->centr->lonlat[0] + mmod->rad, mmod->lim->lonlat[0]);
+  down = MAX(disk->centr->lonlat[0] - mmod->rad, 0.0);
+  rght = MIN(disk->centr->lonlat[1] + mmod->rad, mmod->lim->lonlat[1]);
+  left = MAX(disk->centr->lonlat[1] - mmod->rad, 0.0);
+
+  ldsk->coord->lonlat[0] = Uni()*(up - down) + down;
+  ldsk->coord->lonlat[1] = Uni()*(rght - left) + left;
+
+  /* printf("\n. disk %s (%f %f) rad: %f up: %f down: %f rght: %f left: %f", */
+  /*        disk->id, */
+  /*        disk->centr->lonlat[0], */
+  /*        disk->centr->lonlat[1], */
+  /*        mmod->rad, */
+  /*        up,down,rght,left); */
+  return(LOG(up-down)+LOG(rght-left));
+}
+ 
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+ 
+phydbl PHYREX_Rnorm_Trunc(t_ldsk *ldsk, t_dsk *disk, t_phyrex_mod *mmod)
+{
+  phydbl up, down, left, rght;
+  int err;
+
+  up   = mmod->lim->lonlat[0];
+  down = 0.0;
+  rght = mmod->lim->lonlat[1];
+  left = 0.0;
+
+  err = NO;
+  ldsk->coord->lonlat[0] = Rnorm_Trunc(disk->centr->lonlat[0],mmod->rad,down,up,&err);
+  ldsk->coord->lonlat[1] = Rnorm_Trunc(disk->centr->lonlat[1],mmod->rad,left,rght,&err);
+
+  return(0.0);
+  
+}
+ 
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Wrap_Prior_Radius(t_edge *e, t_tree *tree, supert_tree *st)
+{
+  return PHYREX_LnPrior_Radius(tree);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_LnPrior_Lbda(t_tree *tree)
+{
+  if(tree->mmod->lbda < tree->mmod->min_lbda) return UNLIKELY;
+  if(tree->mmod->lbda > tree->mmod->max_lbda) return UNLIKELY;
+
+  /* tree->mmod->c_ln_prior_lbda = */
+  /*   LOG(tree->mmod->prior_param_lbda) - */
+  /*   tree->mmod->prior_param_lbda*tree->mmod->lbda; */
+
+  /* tree->mmod->c_ln_prior_lbda -= LOG(EXP(-tree->mmod->prior_param_lbda*tree->mmod->min_lbda)- */
+  /*                                    EXP(-tree->mmod->prior_param_lbda*tree->mmod->max_lbda)); */
+
+  tree->mmod->c_ln_prior_lbda = -LOG(tree->mmod->max_lbda - tree->mmod->min_lbda);;
+
+  return(tree->mmod->c_ln_prior_lbda);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_LnPrior_Mu(t_tree *tree)
+{
+  if(tree->mmod->mu < tree->mmod->min_mu) return UNLIKELY;
+  if(tree->mmod->mu > tree->mmod->max_mu) return UNLIKELY;
+
+  tree->mmod->c_ln_prior_mu = -LOG(tree->mmod->max_mu - tree->mmod->min_mu);
+
+  /* tree->mmod->c_ln_prior_mu = -2.*LOG(tree->mmod->mu); */
+
+  return(tree->mmod->c_ln_prior_mu);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_LnPrior_Radius(t_tree *tree)
+{
+  if(tree->mmod->rad < tree->mmod->min_rad) return UNLIKELY;
+  if(tree->mmod->rad > tree->mmod->max_rad) return UNLIKELY;
+
+  /* tree->mmod->c_ln_prior_rad = */
+  /*   LOG(tree->mmod->prior_param_rad) - */
+  /*   tree->mmod->prior_param_rad*tree->mmod->rad; */
+
+  /* tree->mmod->c_ln_prior_rad -= LOG(EXP(-tree->mmod->prior_param_lbda*tree->mmod->min_rad)- */
+  /*                                   EXP(-tree->mmod->prior_param_lbda*tree->mmod->max_rad)); */
+
+  tree->mmod->c_ln_prior_rad = -LOG(tree->mmod->max_rad - tree->mmod->min_rad);
+
+  return(tree->mmod->c_ln_prior_rad);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_LnPrior_Sigsq(t_tree *tree)
+{
+  tree->mmod->c_ln_prior_sigsq = 
+    LOG(tree->mmod->prior_param_sigsq) - 
+    tree->mmod->prior_param_sigsq*tree->mmod->sigsq; 
+  return(tree->mmod->c_ln_prior_sigsq);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Initial_Ldsk_Pos(t_tree *tree)
+{
+  t_dsk *disk;
+  int i,j;
+  phydbl mean;
+
+  disk = tree->disk->prev;
+
+  do
+    {
+      if(disk->ldsk)
+        {
+          For(i,tree->mmod->n_dim)
+            {
+              mean = 0.0;
+              For(j,disk->ldsk->n_next) mean += disk->ldsk->next[j]->coord->lonlat[i];
+              disk->ldsk->coord->lonlat[i] = mean / (phydbl)disk->ldsk->n_next;
+            }
+        }
+      disk = disk->prev;
+    }
+  while(disk);
+
+
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Min_Radius(t_tree *tree)
+{
+  phydbl ori_rad, min_rad;
+
+  ori_rad = tree->mmod->rad;
+  tree->mmod->rad = tree->mmod->max_rad;
+  do
+    {
+      PHYREX_Lk(tree);
+      tree->mmod->rad -= 1.0;
+    }
+  while(tree->mmod->c_lnL > UNLIKELY + 0.1);
+
+  min_rad = tree->mmod->rad + 2.0;
+  tree->mmod->rad = ori_rad;
+  PHYREX_Lk(tree);
+  return(min_rad);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Get the minimum and maximum values a ldsk can take, given the position of the disk centre */
+void PHYREX_Get_Min_Max_Ldsk_Given_Disk(t_ldsk *ldsk, phydbl **min, phydbl **max, t_tree *tree)
+{
+  phydbl *loc_min,*loc_max;
+  int i;
+
+  if(!ldsk->disk->next) return;
+
+  loc_min = (phydbl *)mCalloc(tree->mmod->n_dim, sizeof(phydbl));
+  loc_max = (phydbl *)mCalloc(tree->mmod->n_dim, sizeof(phydbl));
+
+  For(i,tree->mmod->n_dim)
+    {
+      loc_min[i] = ldsk->disk->centr->lonlat[i] - tree->mmod->rad;
+      loc_max[i] = ldsk->disk->centr->lonlat[i] + tree->mmod->rad;     
+      
+      if(ldsk->prev)
+        {
+          loc_min[i] = MAX(loc_min[i],ldsk->prev->disk->centr->lonlat[i] - tree->mmod->rad);
+          loc_max[i] = MIN(loc_max[i],ldsk->prev->disk->centr->lonlat[i] + tree->mmod->rad);
+        }
+
+      loc_min[i] = MAX(0.0,loc_min[i]);
+      loc_max[i] = MIN(tree->mmod->lim->lonlat[i],loc_max[i]);
+    }
+
+  (*min) = loc_min;
+  (*max) = loc_max;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Get the minimum and maximum values a disk centre can take, given the position of the ldsk */
+void PHYREX_Get_Min_Max_Disk_Given_Ldsk(t_dsk *disk, phydbl **min, phydbl **max, t_tree *tree)
+{
+  phydbl *loc_min,*loc_max;
+  int i,j;
+  phydbl tmp_min, tmp_max;
+
+  if(!disk->next) return;
+
+  loc_min = (phydbl *)mCalloc(tree->mmod->n_dim,sizeof(phydbl));
+  loc_max = (phydbl *)mCalloc(tree->mmod->n_dim,sizeof(phydbl));
+
+  if(!disk->ldsk || tree->mmod->name == PHYREX_NORMAL)
+    {
+      For(i,tree->mmod->n_dim)
+        {
+          loc_min[i] = 0.0;
+          loc_max[i] = tree->mmod->lim->lonlat[i];
+        }
+    }
+  else
+    {
+      For(i,tree->mmod->n_dim)
+        {
+          tmp_min = +INFINITY;
+          tmp_max = -INFINITY;
+          For(j,disk->ldsk->n_next)
+            {
+              if(disk->ldsk->next[j]->coord->lonlat[i] < tmp_min) tmp_min = disk->ldsk->next[j]->coord->lonlat[i];
+              if(disk->ldsk->next[j]->coord->lonlat[i] > tmp_max) tmp_max = disk->ldsk->next[j]->coord->lonlat[i];
+            }
+
+          if(disk->ldsk->coord->lonlat[i] < tmp_min) tmp_min = disk->ldsk->coord->lonlat[i];
+          if(disk->ldsk->coord->lonlat[i] > tmp_max) tmp_max = disk->ldsk->coord->lonlat[i];
+
+          loc_min[i] = MAX(0.0,
+                           tmp_max - tree->mmod->rad);
+
+          loc_max[i] = MIN(tree->mmod->lim->lonlat[i],
+                           tmp_min + tree->mmod->rad);
+                    
+          assert(!(loc_max[i] < loc_min[i]));
+        }
+    }
+
+  (*min) = loc_min;
+  (*max) = loc_max;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Update_Disk_Ldsk_Subtree(t_ldsk *root_ldsk, t_tree *tree)
+{
+  int i;  
+  For(i,root_ldsk->n_next) PHYREX_Update_Disk_Ldsk_Subtree_Pre(root_ldsk,root_ldsk->next[i],root_ldsk,tree);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Update_Disk_Ldsk_Subtree_Pre(t_ldsk *old_ldsk, t_ldsk *young_ldsk, t_ldsk *root_ldsk, t_tree *tree)
+{  
+  if(!young_ldsk->disk->next) 
+    {
+      PHYREX_One_New_Traj_Given_Disk(young_ldsk,root_ldsk,tree);
+      return;
+    }
+  else
+    {
+      int i;
+      PHYREX_Update_Disk_Ldsk_Subtree_Pre(young_ldsk,young_ldsk->next[0],root_ldsk,tree);
+      if(young_ldsk->n_next > 1) 
+        {
+          for(i=1;i<young_ldsk->n_next;i++) PHYREX_Update_Disk_Ldsk_Subtree_Pre(young_ldsk,young_ldsk->next[i],young_ldsk,tree);
+        }
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Restore_Disk_Ldsk_Subtree(t_ldsk *root_ldsk, t_tree *tree)
+{
+  int i;  
+  For(i,root_ldsk->n_next) PHYREX_Restore_Disk_Ldsk_Subtree_Pre(root_ldsk,root_ldsk->next[i],tree);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Restore_Disk_Ldsk_Subtree_Pre(t_ldsk *old_ldsk, t_ldsk *young_ldsk, t_tree *tree)
+{  
+
+  if(!young_ldsk->disk->next) return;
+  else
+    {
+      int i;
+
+      PHYREX_Restore_Geo_Coord(young_ldsk->coord);
+      PHYREX_Restore_Geo_Coord(young_ldsk->disk->centr);
+
+      For(i,young_ldsk->n_next)
+        {
+          PHYREX_Restore_Disk_Ldsk_Subtree_Pre(young_ldsk,young_ldsk->next[i],tree);
+        }
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Proposal_Disk_Ldsk_Subtree(t_ldsk *root_ldsk, phydbl *logdens, t_tree *tree)
+{
+  int i;  
+  (*logdens) = 0.0;
+  For(i,root_ldsk->n_next) PHYREX_Proposal_Disk_Ldsk_Subtree_Pre(root_ldsk,root_ldsk->next[i],root_ldsk,logdens,tree);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Proposal_Disk_Ldsk_Subtree_Pre(t_ldsk *old_ldsk, t_ldsk *young_ldsk, t_ldsk *root_ldsk, phydbl *logdens, t_tree *tree)
+{  
+
+  if(!young_ldsk->disk->next) 
+    {
+      (*logdens) += PHYREX_Uniform_Path_Density(young_ldsk,root_ldsk,tree);  
+      return;
+    }
+  else
+    {
+      int i;
+      For(i,young_ldsk->n_next)
+        {
+          PHYREX_Proposal_Disk_Ldsk_Subtree_Pre(young_ldsk,young_ldsk->next[i],root_ldsk,logdens,tree);
+        }
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Update the tree structure given the whole set of ldsk events */
+/* Coalescent events involving multiple lineages are resolved using */
+/* very short internal edges */
+void PHYREX_Ldsk_To_Tree(t_tree *tree)
+{
+  int i,j;
+  t_dsk *disk;
+
+  /* Reset */
+  For(i,2*tree->n_otu-1) 
+    {
+      For(j,3) 
+        {
+          tree->a_nodes[i]->v[j] = NULL;
+          tree->a_nodes[i]->b[j] = NULL;
+        }
+    }
+
+  disk = tree->disk->prev;
+  while(disk) 
+    {
+      if(disk->ldsk) disk->ldsk->nd = NULL;
+      disk = disk->prev;
+    }
+
+  /* Connect tips */
+  For(i,tree->n_otu) 
+    {
+      tree->disk->ldsk_a[i]->nd = tree->a_nodes[i];
+      tree->a_nodes[i]->coord = tree->disk->ldsk_a[i]->coord;
+    }
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+  
+  tree->n_root = tree->a_nodes[2*tree->n_otu-2];
+  i = 2*tree->n_otu-3;
+  tree->num_curr_branch_available = 0;
+  PHYREX_Ldsk_To_Tree_Post(tree->n_root,disk->ldsk,&i,tree);
+
+  For(i,tree->n_otu) assert(!(tree->a_nodes[i]->v[0] == NULL));
+
+  For(i,3) 
+    if(tree->n_root->v[2]->v[i] == tree->n_root) 
+      { 
+        tree->n_root->v[2]->v[i] = tree->n_root->v[1]; 
+        break; 
+      }
+
+  For(i,3) 
+    if(tree->n_root->v[1]->v[i] == tree->n_root) 
+      { 
+        tree->n_root->v[1]->v[i] = tree->n_root->v[2]; 
+        break; 
+      }
+
+  Connect_Edges_To_Nodes_Serial(tree);
+  /* 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 = NULL;
+  For(i,2*tree->n_otu-3)
+    {
+      /* printf("\n %d %d",tree->a_edges[i]->left->num,tree->a_edges[i]->rght->num); */
+      if((tree->a_edges[i]->left == tree->n_root->v[1] && tree->a_edges[i]->rght == tree->n_root->v[2]) ||
+         (tree->a_edges[i]->left == tree->n_root->v[2] && tree->a_edges[i]->rght == tree->n_root->v[1]))
+        {        
+          tree->e_root = tree->a_edges[i];
+          break;
+        }
+    }
+  assert(!(tree->e_root == NULL));
+  
+  tree->n_root->b[1]  = tree->a_edges[2*tree->n_otu-3];
+  tree->n_root->b[2]  = tree->a_edges[2*tree->n_otu-2];
+
+  /* For(i,2*tree->n_otu-1) */
+  /*   { */
+  /*     printf("\n. * Edge %d %p", */
+  /*            tree->a_edges[i]->num, */
+  /*            tree->a_edges[i]); */
+  /*   } */
+  /* PhyML_Printf("\n. tree->n_root->b[1]: %p",tree->n_root->b[1]);  */
+  /* PhyML_Printf("\n. tree->n_root->b[2]: %p",tree->n_root->b[2]);  */
+  /* fflush(NULL); */
+  /* Exit("\n"); */
+}
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Ldsk_To_Tree_Post(t_node *a, t_ldsk *ldsk, int *available, t_tree *tree)
+{
+  assert(!(ldsk == NULL));
+  assert(!(a == NULL));
+
+  ldsk->nd = a;  
+  tree->rates->nd_t[a->num] = ldsk->disk->time;
+  a->coord = ldsk->coord;
+
+  if(!ldsk->next) return;
+  else
+    {
+      t_node *parent,*son;
+      int n_next;
+      t_ldsk *t;
+
+      parent       = a;
+      parent->v[1] = NULL;
+      parent->v[2] = NULL;
+      n_next       = 0;
+      do
+        {
+          t = ldsk->next[n_next]; 
+
+          /* if(t == NULL) */
+          /*   { */
+          /*     PhyML_Printf("\n. ldsk:%p ldsk->next:%p n_next:%d", */
+          /*                  ldsk,ldsk?ldsk->next:NULL,n_next); */
+          /*     Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
+          /*   } */
+
+          while(t->next && t->n_next == 1) t = t->next[0];
+         
+          if(t->nd == NULL) 
+            {
+              son = tree->a_nodes[*available];
+              (*available) = (*available)-1;
+            }
+          else
+            {
+              son = t->nd;
+            }
+                    
+          PHYREX_Ldsk_To_Tree_Post(son,t,available,tree);          
+
+          if(parent->v[2] != NULL && n_next >= 2) 
+            {
+              t_node *new_parent;
+              /* phydbl orig_l2; */
+
+              new_parent = tree->a_nodes[*available];
+              (*available) = (*available)-1;              
+
+              new_parent->v[0]       = parent;
+              new_parent->v[1]       = parent->v[2];
+              new_parent->v[2]       = son;
+
+              parent->v[2]           = new_parent;
+              son->v[0]              = new_parent;
+              new_parent->v[1]->v[0] = new_parent;
+              
+              /* printf("\n# connect %d to %d",parent->num,new_parent->num); */
+              /* printf("\n# connect %d to %d",new_parent->num,new_parent->v[1]->num); */
+              /* printf("\n# connect %d to %d",new_parent->num,new_parent->v[2]->num); */              
+              /* fflush(NULL); */
+              
+              tree->rates->nd_t[new_parent->num] = ldsk->disk->time;
+
+              parent = new_parent;
+            }
+          else
+            {
+              son->v[0] = parent;          
+              if(!parent->v[1]) parent->v[1] = son;
+              else              parent->v[2] = son;
+              
+              /* printf("\n. connect %d to %d",parent->num,son->num); */
+            }
+
+          n_next++;
+        }
+      while(n_next != ldsk->n_next);
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Remove_Lindisk_Next(t_ldsk *ldsk, t_ldsk *rm)
+{
+  t_ldsk **new_next;
+  int i,pos;
+
+  new_next = (t_ldsk **)mCalloc(ldsk->n_next-1+NEXT_BLOCK_SIZE,sizeof(t_ldsk *));
+
+  pos = 0;
+  For(i,ldsk->n_next)
+    {
+      if(ldsk->next[i] != rm)
+        {
+          new_next[pos] = ldsk->next[i];
+          pos++;
+        }
+    }
+
+  ldsk->n_next--;
+  Free(ldsk->next);
+  ldsk->next = new_next;
+  /* printf("\n. remove next for ldsk %s n_next set to %d",ldsk->coord->id,ldsk->n_next); */
+  /* fflush(NULL); */
+}  
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Returns the vector of average pairwise distances between ldsk on each disk */
+phydbl *PHYREX_Mean_Pairwise_Distance_Between_Lineage_Locations(t_tree *tree)
+{
+  phydbl *dist;
+  int block,n_disks,i,j, k;
+  t_dsk *disk;
+  
+  PHYREX_Update_Lindisk_List(tree);
+
+  dist = NULL;
+  block   = 100;
+  disk    = tree->disk;
+  n_disks = 0;
+  do
+    {
+      if(!n_disks) dist = (phydbl *)mCalloc(block,sizeof(phydbl));
+      else if(!(n_disks%block)) dist = (phydbl *)mRealloc(dist,n_disks+block,sizeof(phydbl));
+      
+      dist[n_disks] = 0.0;
+      For(i,disk->n_ldsk_a-1)
+        {
+          for(j=i+1;j<disk->n_ldsk_a;j++)
+            {
+              For(k,tree->mmod->n_dim)
+                {
+                  dist[n_disks] += FABS(disk->ldsk_a[i]->coord->lonlat[k] - disk->ldsk_a[j]->coord->lonlat[k]);
+                  printf("\n * %d %f %f %f",
+                         k,
+                         disk->ldsk_a[i]->coord->lonlat[k],
+                         disk->ldsk_a[j]->coord->lonlat[k],
+                         tree->mmod->lim->lonlat[k]);
+                }
+            }
+        }
+      dist[n_disks] /= (phydbl)(disk->n_ldsk_a * (disk->n_ldsk_a-1) / 2.);
+
+      printf("\n %d %f %f",disk->n_ldsk_a,disk->time,dist[n_disks]);
+
+      n_disks++;
+      disk = disk->prev;
+    }
+  while(disk->prev);
+
+  return(dist);
+
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Random_Select_Time_Between_Jumps(t_tree *tree)
+{
+  t_dsk  *disk,**valid_disks;
+  int n_valid_disks,block,select;
+  phydbl time;
+
+  valid_disks   = NULL;
+  disk          = NULL;
+  block         = 100;
+
+  assert(!(tree->disk->next));
+
+  disk = tree->disk->prev;
+  n_valid_disks = 0;
+  do
+    {
+      if(disk->ldsk != NULL && disk->prev != NULL)
+        {
+          if(!n_valid_disks) valid_disks = (t_dsk **)mCalloc(block,sizeof(t_dsk *));
+          else if(!(n_valid_disks%block)) valid_disks = (t_dsk **)mRealloc(valid_disks,n_valid_disks+block,sizeof(t_dsk *));
+          valid_disks[n_valid_disks] = disk;
+          n_valid_disks++;
+        }
+      disk = disk->prev;
+    }
+  while(disk->prev);
+
+  if(!n_valid_disks) return -1.0;
+
+  select = Rand_Int(0,n_valid_disks-1);
+
+  time = valid_disks[select]->time - valid_disks[select]->ldsk->prev->disk->time;
+  
+  Free(valid_disks);
+
+  return(time);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int PHYREX_Is_In_Ldscape(t_ldsk *ldsk, t_phyrex_mod *mmod)
+{
+  int j;
+  For(j,mmod->n_dim) if(ldsk->coord->lonlat[j] > mmod->lim->lonlat[j] ||
+                        ldsk->coord->lonlat[j] < 0.0) return NO;
+  return YES;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Mean_Time_Between_Events(t_tree *tree)
+{
+  int n_inter;
+  phydbl T;
+
+  n_inter = PHYREX_Total_Number_Of_Intervals(tree);  
+  T = -tree->rates->nd_t[tree->n_root->num];
+  return((phydbl)(T/n_inter));
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Uses the regression technique described in Barton et al. TPB (2013)
+   to estimate the size of the neighborhood when the population evolve
+   according to a spatial Lambda-Fleming-Viot process.
+*/
+phydbl PHYREX_Neighborhood_Size_Regression(t_tree *tree)
+{
+  int i,j,pair;
+  t_node *anc;
+  phydbl *dist,min_dist;
+  phydbl QA,Qr,*fst,fst0,fst_min_dist;
+  phydbl cov_fst_dist,var_dist,slope;
+  phydbl eps;
+
+  eps = 1.E-10;
+
+  QA = Mean_Identity(tree->data);
+
+  fst  = (phydbl *)mCalloc(tree->n_otu*(tree->n_otu-1)/2,sizeof(phydbl));
+  dist = (phydbl *)mCalloc(tree->n_otu*(tree->n_otu-1)/2,sizeof(phydbl));
+
+  pair = 0;
+  fst0 = 0.0;
+  For(i,tree->n_otu-1)
+    {
+      fst_min_dist = 0.0;
+      min_dist = MDBL_MAX;
+      for(j=i+1;j<tree->n_otu;j++)
+        {
+          anc = Find_Lca_Pair_Of_Nodes(tree->a_nodes[i],tree->a_nodes[j],tree);
+          if(anc == NULL) 
+            {
+              PhyML_Printf("\n. %s",Write_Tree(tree,NO));
+              PhyML_Printf("\n. %s %s",tree->a_nodes[i]->name,tree->a_nodes[j]->name);
+              Generic_Exit(__FILE__,__LINE__,__FUNCTION__);            
+            }
+          
+          dist[pair] = Euclidean_Dist(tree->a_nodes[i]->coord,tree->a_nodes[j]->coord);
+          dist[pair] = LOG(dist[pair]);
+
+          Qr = Pairwise_Identity(i,j,tree->data);
+          fst[pair] = (Qr-QA)/(1.-QA);
+
+          if(dist[pair] < min_dist)
+            {
+              min_dist     = dist[pair];
+              fst_min_dist = fst[pair];
+            }
+
+          pair++;
+        }
+      fst0 += fst_min_dist;
+    }
+
+  fst0 /= (phydbl)(tree->n_otu);
+
+  cov_fst_dist = Covariance(dist,fst,pair);
+  var_dist = Variance(dist,pair);
+
+  slope = cov_fst_dist / var_dist;
+
+  Free(dist);
+  Free(fst);
+
+  return((fst0-1.+eps)/(slope+eps));
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Rand_Pairs_Coal_Times_Dist(t_tree *tree)
+{
+  t_node *anc;
+  phydbl dist;
+  int i, j;
+
+  i = Rand_Int(0,tree->n_otu-1);
+  j = Rand_Int(0,tree->n_otu-1);
+
+  if(i == j) PhyML_Printf("\nxxWxx 0.0 0.0");
+  else
+    {
+
+      anc = Find_Lca_Pair_Of_Nodes(tree->a_nodes[i],tree->a_nodes[j],tree);
+      if(anc == NULL) 
+        {
+          PhyML_Printf("\n. %s",Write_Tree(tree,NO));
+          PhyML_Printf("\n. %s %s",tree->a_nodes[i]->name,tree->a_nodes[j]->name);
+          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);            
+        }
+      
+      PhyML_Printf("\nxxWxx %12f",tree->rates->nd_t[anc->num]);
+      dist = Euclidean_Dist(tree->a_nodes[i]->coord,tree->a_nodes[j]->coord);
+      PhyML_Printf(" %f",dist);
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Generation_Length(t_tree *tree)
+{
+  return(1./(2.*tree->mmod->mu*POW(tree->mmod->rad,2)*PI*PHYREX_Rate_Per_Unit_Area(tree)));
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Neighborhood_Size(t_tree *tree)
+{
+  switch(tree->mmod->name)
+    {
+    case PHYREX_UNIFORM: { return(1./tree->mmod->mu); break; }
+    case PHYREX_NORMAL:  { return(2./tree->mmod->mu); break; }
+    }
+  return(-1.);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Update_Sigsq(t_tree *tree)
+{  
+  switch(tree->mmod->name)
+    {
+    case PHYREX_UNIFORM: { return(-1.0); break;}
+    case PHYREX_NORMAL:  
+      { 
+        return(4.*PI*
+               PHYREX_Rate_Per_Unit_Area(tree) *
+               POW(tree->mmod->rad,4)*
+               tree->mmod->mu); 
+        break; 
+      }
+    }
+  return(-1.);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Update_Radius(t_tree *tree)
+{
+  switch(tree->mmod->name)
+    {
+    case PHYREX_UNIFORM: { return(-1.0); break;}
+    case PHYREX_NORMAL:  
+      { 
+        return(POW(tree->mmod->sigsq/(PHYREX_Rate_Per_Unit_Area(tree)*4.*PI*tree->mmod->mu),0.25));
+        break; 
+      }
+    }
+  return(-1.);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Sample_Rad_From_Prior(t_tree *tree)
+{
+  phydbl u,h,w,lbda,mu,b,a;
+
+  h    = tree->mmod->lim->lonlat[0];
+  w    = tree->mmod->lim->lonlat[1];
+  lbda = tree->mmod->lbda;
+  mu   = tree->mmod->mu;
+  a    = tree->mmod->min_sigsq;
+  b    = tree->mmod->max_sigsq;
+
+  u = Uni();
+
+  return(POW(((b-a)*u+a)*h*w/(4.*PI*lbda*mu),0.25));
+
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Read_Tip_Coordinates(t_ldsk **ldsk_a, t_tree *tree)
+{
+  char *s;
+  FILE *fp;
+  int i,*done,found_sw,found_ne;
+  phydbl sw_lon, sw_lat,  ne_lon, ne_lat;
+
+  s    = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+  fp   = tree->io->fp_in_coord;
+  done = (int *)mCalloc(tree->n_otu,sizeof(int));
+
+  found_sw = NO;
+  found_ne = NO;
+
+  For(i,tree->n_otu) done[i] = NO;
+
+  do
+    {
+      if(fscanf(fp,"%s",s) == EOF) break;
+      For(i,strlen(s)) if(s[i] == '#') break; /* skip comment */
+      if(i != strlen(s)) continue;
+      
+      For(i,tree->n_otu) if(strstr(tree->a_nodes[i]->name,s)) break;
+      
+      if(i != tree->n_otu) /* Found a match */
+        {
+          if(fscanf(fp,"%lf",&(ldsk_a[i]->coord->lonlat[0])) == EOF) break;
+          if(fscanf(fp,"%lf",&(ldsk_a[i]->coord->lonlat[1])) == EOF) break;          
+          done[i] = YES;
+        }
+      else
+        {
+          if(!strcmp(s,"|SouthWest|") || !strcmp(s,"|southwest|") || !strcmp(s,"|Southwest|"))
+            {
+              found_sw = YES;
+              if(fscanf(fp,"%lf",&(sw_lon)) == EOF) break;
+              if(fscanf(fp,"%lf",&(sw_lat)) == EOF) break;              
+            }
+          else if(!strcmp(s,"|NorthEast|") || !strcmp(s,"|northeast|") || !strcmp(s,"|Northeast|"))
+            {
+              found_ne = YES;
+              if(fscanf(fp,"%lf",&(ne_lon)) == EOF) break;
+              if(fscanf(fp,"%lf",&(ne_lat)) == EOF) break;
+            }
+        }
+    }
+  while(1);
+  
+  if(found_ne == NO)
+    {
+      PhyML_Printf("\n== Could not find coordinates for northernmost  point.");
+      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+    }
+
+  if(found_sw == NO)
+    {
+      PhyML_Printf("\n== Could not find coordinates for southernmost point.");
+      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+    }
+
+  For(i,tree->n_otu) 
+    if(done[i] == NO) 
+      {
+        PhyML_Printf("\n== Could not find coordinates for '%s'.",tree->a_nodes[i]->name);
+        Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+      }
+
+  For(i,tree->n_otu) 
+    {
+      ldsk_a[i]->coord->lonlat[0] -= sw_lon;
+      ldsk_a[i]->coord->lonlat[1] -= sw_lat;
+
+      ldsk_a[i]->coord->lonlat[0] /= (ne_lon - sw_lon);
+      ldsk_a[i]->coord->lonlat[1] /= (ne_lat - sw_lat);
+
+      ldsk_a[i]->coord->lonlat[0] *= tree->mmod->lim->lonlat[0];
+      ldsk_a[i]->coord->lonlat[1] *= tree->mmod->lim->lonlat[1];
+
+      PhyML_Printf("\n. Scaled coordinates of '%-50s': %12f\t %12f",
+                   tree->a_nodes[i]->name,
+                   ldsk_a[i]->coord->lonlat[0],
+                   ldsk_a[i]->coord->lonlat[1]);
+    }
+
+  Free(s);
+  Free(done);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Rate_Per_Unit_Area(t_tree *tree)
+{
+  int i;
+  phydbl denom;
+
+  denom = tree->mmod->lim->lonlat[0];
+  
+  for(i=1;i<tree->mmod->n_dim;i++) denom *= tree->mmod->lim->lonlat[i];
+  
+  return(tree->mmod->lbda / denom);
+
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Tree_Height(t_tree *tree)
+{
+  t_dsk *disk;
+
+  disk = tree->disk;
+  while(disk && disk->prev) disk = disk->prev;
+
+  return(disk->time);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int PHYREX_Random_Insert_Ldsk_In_Next_List(t_ldsk *ins, t_ldsk *where)
+{
+  int size, pos, i, *rk;
+  t_ldsk **next_cpy;
+
+  size = where->n_next;
+
+  rk = (int *)mCalloc(size,sizeof(int));
+  next_cpy = (t_ldsk **)mCalloc(size,sizeof(t_ldsk *));
+
+  For(i,size) next_cpy[i] = where->next[i];
+
+  pos  = Rand_Int(0,size);
+
+  For(i,size)
+    {
+      if(i < pos) rk[i] = i;
+      else        rk[i] = i+1;
+    }
+
+  PHYREX_Make_Lindisk_Next(where);
+  
+  For(i,size) where->next[rk[i]] = next_cpy[i];
+  
+  where->next[pos]= ins;
+
+
+  Free(rk);
+  Free(next_cpy);
+
+  return pos;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Insert_Ldsk_In_Next_List(t_ldsk *ins, int pos, t_ldsk *where)
+{
+  int size, i, *rk;
+  t_ldsk **next_cpy;
+
+  size = where->n_next;
+
+  rk = (int *)mCalloc(size,sizeof(int));
+  next_cpy = (t_ldsk **)mCalloc(size,sizeof(t_ldsk *));
+
+  For(i,size) next_cpy[i] = where->next[i];
+
+  For(i,size)
+    {
+      if(i < pos) rk[i] = i;
+      else        rk[i] = i+1;
+    }
+
+  PHYREX_Make_Lindisk_Next(where);
+  
+  For(i,size) where->next[rk[i]] = next_cpy[i];
+  
+  where->next[pos]= ins;
+
+  Free(rk);
+  Free(next_cpy);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+t_ldsk *PHYREX_Remove_Path(t_ldsk *beg, t_ldsk *end, int *pos_end, t_tree *tree)
+{
+  t_ldsk *ldsk;
+  int dir_end_beg;
+
+  dir_end_beg = PHYREX_Get_Next_Direction(beg,end);
+  *pos_end = dir_end_beg;
+  PHYREX_Remove_Lindisk_Next(end,end->next[dir_end_beg]);
+
+  if(beg->prev == end) return NULL;
+  
+  /* PhyML_Printf("\n- rm beg: %12f %12f %12f %s", */
+  /*              beg->coord->lonlat[0],beg->coord->lonlat[1],beg->disk->time, */
+  /*              beg->coord->id); */
+  /* PhyML_Printf("\n- rm end: %12f %12f %12f %s", */
+  /*              end->coord->lonlat[0],end->coord->lonlat[1],end->disk->time, */
+  /*              end->coord->id); */
+
+  ldsk = beg->prev;
+  while(1)
+    {
+      PHYREX_Remove_Disk(ldsk->disk);
+      /* PhyML_Printf("\n- rm %12f %12f %s",ldsk->coord->lonlat[0],ldsk->coord->lonlat[1],ldsk->coord->id); */
+      if(ldsk->prev == end) break;
+      ldsk = ldsk->prev;
+    }
+  
+  ldsk->prev = NULL;
+  ldsk = beg->prev;
+  beg->prev = NULL;
+
+  return(ldsk);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Insert_Path(t_ldsk *beg, t_ldsk *end, t_ldsk *path, int pos, t_tree *tree)
+{
+  t_ldsk *ldsk;
+
+  assert(!(path == beg || path == end));
+
+  if(path == NULL) 
+    {
+      beg->prev = end;      
+
+      /* printf("\n. in (beg-end) %12f %12f %12f %12f %s %s", */
+      /*        beg->coord->lonlat[0], */
+      /*        beg->coord->lonlat[1], */
+      /*        end->coord->lonlat[0], */
+      /*        end->coord->lonlat[1], */
+      /*        beg->coord->id,end->coord->id); */
+
+      /* PHYREX_Insert_Ldsk_In_Next_List(beg,end->n_next,end); */
+      PHYREX_Insert_Ldsk_In_Next_List(beg,pos,end);
+    }
+  else
+    {
+
+      /* printf("\n. in beg %12f %12f %12f %s", */
+      /*        beg->coord->lonlat[0], */
+      /*        beg->coord->lonlat[1], */
+      /*        beg->disk->time, */
+      /*        beg->coord->id); */
+
+      /* printf("\n. in end %12f %12f %12f %s", */
+      /*        end->coord->lonlat[0], */
+      /*        end->coord->lonlat[1], */
+      /*        end->disk->time, */
+      /*        end->coord->id); */
+      
+      ldsk = path;
+      while(1)
+        {
+          PHYREX_Insert_Disk(ldsk->disk,tree);
+          /* printf("\n+ in %12f %12f %12f %s", */
+          /*        ldsk->coord->lonlat[0], */
+          /*        ldsk->coord->lonlat[1], */
+          /*        ldsk->disk->time, */
+          /*        ldsk->coord->id); */
+          if(ldsk->prev == NULL) break;
+          ldsk = ldsk->prev;
+        }
+      
+      beg->prev = path;
+      ldsk->prev = end;
+      path->next[0] = beg;
+
+      /* PHYREX_Insert_Ldsk_In_Next_List(ldsk,end->n_next,end); */
+      PHYREX_Insert_Ldsk_In_Next_List(ldsk,pos,end);
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Effective_Density(t_tree *tree)
+{
+  return(PHYREX_Neighborhood_Size(tree)/(4.*PI*PHYREX_Update_Sigsq(tree)));
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+t_ldsk *PHYREX_Generate_Path(t_ldsk *beg, t_ldsk *end, phydbl cur_n_evt, phydbl sd, t_tree *tree)
+{
+  int n_evt,i,j,swap,err;
+  phydbl dt,*time,dum,mode;
+  t_ldsk *path,**ldsk_a;
+  t_dsk *disk;
+
+  dt = FABS(beg->disk->time - end->disk->time);
+
+  /* How many hit events ? */
+  if(cur_n_evt < .0)
+    /* Not sure that rate is ok when considering landscape with boundaries... */
+    n_evt = Rpois(dt*2.*PHYREX_Rate_Per_Unit_Area(tree)*PI*POW(sd,2)*tree->mmod->mu); 
+  else
+    n_evt = Rpois(cur_n_evt);
+
+
+  if(n_evt <= 0) return(NULL);
+
+  time   = (phydbl *)mCalloc(n_evt,sizeof(phydbl));
+  ldsk_a = (t_ldsk **)mCalloc(n_evt,sizeof(t_ldsk *));
+
+  For(i,n_evt) time[i] =  beg->disk->time - FABS(Uni()*(end->disk->time - beg->disk->time));
+
+  /* Invert time direction */
+  For(i,n_evt) time[i] = -time[i];
+  
+  /* Bubble sort time in ascending order */
+  do
+    {
+      swap = NO;
+      For(i,n_evt-1) 
+        {
+          if(time[i+1] < time[i])
+            {
+              swap = YES;
+              dum       = time[i+1];
+              time[i+1] = time[i];
+              time[i]   = dum;
+            }
+        }
+    }while(swap == YES);
+
+  
+  For(i,n_evt)
+    {
+      ldsk_a[i] = PHYREX_Make_Lindisk_Node(tree->mmod->n_dim);
+      disk = PHYREX_Make_Disk_Event(tree->mmod->n_dim,tree->n_otu);
+      PHYREX_Init_Lindisk_Node(ldsk_a[i],disk,tree->mmod->n_dim);
+      PHYREX_Make_Lindisk_Next(ldsk_a[i]);
+      PHYREX_Init_Disk_Event(disk,tree->mmod->n_dim,tree->mmod);
+      disk->ldsk = ldsk_a[i];
+      disk->time = -time[i];      
+      /* printf("\n. Generate ldsk %s",ldsk_a[i]->coord->id); */
+    }
+
+  For(i,n_evt-1) ldsk_a[i]->prev = ldsk_a[i+1];
+  ldsk_a[i]->prev = NULL;
+
+  for(i=1;i<n_evt;i++) ldsk_a[i]->next[0] = ldsk_a[i-1];
+  ldsk_a[0]->next[0] = NULL;
+
+  path = ldsk_a[0];
+
+  /* Generate path */
+  For(i,tree->mmod->n_dim)
+    {
+      For(j,n_evt)
+        {
+          if(j == 0)
+            mode = (end->coord->lonlat[i] - beg->coord->lonlat[i])/(n_evt+1.) + beg->coord->lonlat[i];          
+          else
+            mode = (end->coord->lonlat[i] - ldsk_a[j-1]->coord->lonlat[i])/(n_evt+1.-j) + ldsk_a[j-1]->coord->lonlat[i];          
+
+          ldsk_a[j]->coord->lonlat[i] = Rnorm_Trunc(mode,
+                                                    sd,
+                                                    0.0,
+                                                    tree->mmod->lim->lonlat[i],&err);
+          
+
+          /* ldsk_a[j]->coord->lonlat[i] = Uni()*tree->mmod->lim->lonlat[i]; */
+          /* ldsk_a[j]->coord->lonlat[i] = mode; */
+
+          ldsk_a[j]->disk->centr->lonlat[i] = Rnorm_Trunc(ldsk_a[j]->coord->lonlat[i],
+                                                          sd,
+                                                          0.0,
+                                                          tree->mmod->lim->lonlat[i],&err);
+
+          /* ldsk_a[j]->disk->centr->lonlat[i] = Uni()*tree->mmod->lim->lonlat[i]; */
+          /* ldsk_a[j]->disk->centr->lonlat[i] = ldsk_a[j]->coord->lonlat[i]; */
+        }
+    }
+
+
+  /* For(j,n_evt) PhyML_Printf("\n. in %12f %12f",ldsk_a[j]->coord->lonlat[0],ldsk_a[j]->coord->lonlat[1]); */
+
+
+  Free(ldsk_a);
+  Free(time);
+
+  return(path);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Path_Logdensity(t_ldsk *beg, t_ldsk *end, phydbl cur_n_evt, phydbl sd, t_tree *tree)
+{
+  int i,j,err,n_evt;
+  t_ldsk *ldsk;
+  phydbl lnDens,mode,rate;
+
+  lnDens = 0.0;
+  mode   = 0.0;
+
+  n_evt = 0;
+  ldsk = beg->prev;
+  while(ldsk != end)
+    {
+      n_evt++;
+      ldsk = ldsk->prev;
+      assert(ldsk != NULL);
+    }
+
+  For(i,tree->mmod->n_dim)
+    {     
+      j    = 0;
+      ldsk = beg;
+      while(ldsk->prev != end)
+        {
+          assert(!(ldsk == NULL));
+          
+          mode = (end->coord->lonlat[i] - ldsk->coord->lonlat[i])/(n_evt+1.-j) + ldsk->coord->lonlat[i];          
+
+          lnDens += Log_Dnorm_Trunc(ldsk->prev->coord->lonlat[i],
+                                    mode,
+                                    sd,
+                                    0.0,
+                                    tree->mmod->lim->lonlat[i],&err);
+
+          /* lnDens += LOG(1./tree->mmod->lim->lonlat[i]); */
+
+          lnDens += Log_Dnorm_Trunc(ldsk->prev->disk->centr->lonlat[i],
+                                    ldsk->prev->coord->lonlat[i],
+                                    sd,
+                                    0.0,
+                                    tree->mmod->lim->lonlat[i],&err);
+
+          /* lnDens += LOG(1./tree->mmod->lim->lonlat[i]); */
+
+          ldsk = ldsk->prev;
+          j++;
+        }
+    }
+
+  if(cur_n_evt < 0)
+    rate = 2.*PHYREX_Rate_Per_Unit_Area(tree)*PI*POW(sd,2)*tree->mmod->mu*FABS(end->disk->time - beg->disk->time);
+  else
+    rate = cur_n_evt;
+
+  lnDens += Dpois(n_evt,rate,YES);
+  lnDens += (n_evt) * LOG(1./FABS(end->disk->time - beg->disk->time));
+  lnDens += LnFact(n_evt);
+
+  return(lnDens);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Time_Tree_Length(t_tree *tree)
+{
+  phydbl len;
+  int i;
+  t_dsk *disk;
+
+  disk = tree->disk;
+  while(disk->prev) disk = disk->prev;
+
+  len = 0.0;
+  For(i,disk->ldsk->n_next) PHYREX_Time_Tree_Length_Pre(disk->ldsk,disk->ldsk->next[i],&len,tree);
+  
+  assert(!(isnan(len) || isinf(len)));
+
+  return(len);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Time_Tree_Length_Pre(t_ldsk *a, t_ldsk *d, phydbl *len, t_tree *tree)
+{
+  int i;
+
+  (*len) += FABS(a->disk->time - d->disk->time);
+  
+  if(d->disk->next == NULL) return;
+  else
+    For(i,d->n_next) PHYREX_Time_Tree_Length_Pre(d,d->next[i],len,tree);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int PHYREX_Is_On_Path(t_ldsk *target, t_ldsk *beg, t_ldsk *end)
+{
+  t_ldsk *ldsk;
+
+  if(target == beg || target == end) return NO;
+
+  assert(!(beg->disk->time < end->disk->time));
+
+  ldsk = beg->prev; 
+  while(ldsk != end)
+    {
+      if(ldsk == target) return YES;
+      ldsk = ldsk->prev;
+      assert(!(ldsk == NULL));
+    }
+  return NO;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int PHYREX_Path_Len(t_ldsk *beg, t_ldsk *end)
+{
+  t_ldsk *ldsk;
+  int len;
+
+  len = 0;
+  ldsk = beg;
+  while(ldsk != end)
+    {
+      len++;
+      ldsk = ldsk->prev;
+    }
+  len++;
+  return len;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Print_Disk_Lk(t_tree *tree)
+{
+  t_dsk *disk;
+
+  PHYREX_Update_Lindisk_List(tree);
+
+  disk = tree->disk->prev;
+
+  do
+    {
+      PhyML_Printf("\n. Disk: %p time: %12f lk: %12f cumlk: %12f",
+                   disk,
+                   disk->time,
+                   PHYREX_Lk_Core(disk,tree),
+                   disk->c_lnL);
+      
+      disk = disk->prev;
+    }
+  while(disk->prev);
+  
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+t_ldsk *PHYREX_Find_Lca_Pair_Of_Ldsk(t_ldsk *n1, t_ldsk *n2, t_tree *tree)
+{
+  t_ldsk **list1, **list2, *lca;
+  int len1, len2;
+
+  assert(n1);
+  assert(n2);
+
+  if(n1 == n2) return(n1);
+
+  PHYREX_Get_List_Of_Ancestors(n1,&list1,&len1,tree);
+  PHYREX_Get_List_Of_Ancestors(n2,&list2,&len2,tree);
+  
+  len1 = len1-1;
+  len2 = len2-1;
+
+  /* printf("\n. len1: %d len2: %d",len1,len2); fflush(NULL); */
+  /* printf("\n. %f %f %d %d [%f %f]", */
+  /*        list1[1]->disk->time, */
+  /*        list2[1]->disk->time, */
+  /*        len1,len2, */
+  /*        n1->disk->time, */
+  /*        n2->disk->time); */
+         
+  assert(list1[len1] == list2[len2]);
+
+
+  do
+    {
+      if((len1 < 0 || len2 < 0) || (list1[len1] != list2[len2])) break;
+      len1--;
+      len2--;
+    }
+  while(len1 && len2);
+  
+
+  lca = list1[len1+1];
+
+  Free(list1);
+  Free(list2);
+  
+  assert(lca);
+
+  return(lca);
+  
+} 
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Get_List_Of_Ancestors(t_ldsk *start, t_ldsk ***list, int *len, t_tree *tree)
+{
+  int block,i;
+  t_ldsk *ldsk;
+
+  assert(start);
+  block = 100;
+
+  *list = (t_ldsk **)mCalloc(block,sizeof(t_ldsk *));
+  
+  ldsk = start;
+  i = 0;
+  do
+    {
+      (*list)[i] = ldsk;
+      if(!(i%block)) *list = (t_ldsk **)mRealloc(*list,i+block,sizeof(t_ldsk *));
+      i++;
+      ldsk = ldsk->prev;
+    }
+  while(ldsk);
+
+  (*len) = i;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Dist_To_Lca(t_ldsk *d, t_ldsk *lca)
+{
+  return(FABS(d->disk->time - lca->disk->time));      
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl PHYREX_Dist_Between_Two_Ldsk(t_ldsk *n1,  t_ldsk *n2, t_tree *tree)
+{
+  t_ldsk *lca;
+
+  lca = PHYREX_Find_Lca_Pair_Of_Ldsk(n1,n2,tree);
+
+  return(PHYREX_Dist_To_Lca(n1,lca)+PHYREX_Dist_To_Lca(n2,lca));
+}
+
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+void PHYREX_Print_MultiTypeTree_Config_File(int n_sites, char *filename, t_tree *tree)
+{
+  int i, j, n_demes;
+  char *s,**deme_names;
+  FILE *fp;
+
+
+  fp = Openfile(filename,WRITE);
+  assert(fp);
+
+  deme_names = (char **)mCalloc(n_sites,sizeof(char *));
+
+  n_demes = 0;
+  For(i,tree->n_otu)
+    {
+      s = strrchr(tree->a_nodes[i]->coord->id,'_');
+      For(j,n_demes) if(!strcmp(s+1,deme_names[j])) break;
+      if(j == n_demes)
+        {
+          deme_names[n_demes] = (char *)mCalloc(strlen(s+1)+1,sizeof(char));
+          strcpy(deme_names[n_demes],s+1);
+          n_demes++;
+        }
+    }
+
+  // n_demes is the number of non-empty sampling sites 
+
+
+  PhyML_Fprintf(fp,"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
+  PhyML_Fprintf(fp,"\n<beast beautitemplate='MultiTypeTree' beautistatus='' namespace=\"beast.core:beast.evolution.alignment:beast.evolution.tree.coalescent:beast.core.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood\" version=\"2.0\">");
+
+  PhyML_Fprintf(fp,"\n<data id=\"h3n2\" name=\"alignment\">");
+
+
+  For(i,tree->n_otu)
+    {
+      PhyML_Fprintf(fp,"\n<sequence id=\"%s\" taxon=\"%s\" totalcount=\"4\" value=\"%s\"/>",
+                   tree->a_nodes[i]->coord->id,
+                   tree->a_nodes[i]->coord->id,
+                   tree->a_nodes[i]->c_seq->state);
+    }
+
+  PhyML_Fprintf(fp,"\n</data>");
+
+  PhyML_Fprintf(fp,"\n<map name=\"Uniform\" >beast.math.distributions.Uniform</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"Exponential\" >beast.math.distributions.Exponential</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"LogNormal\" >beast.math.distributions.LogNormalDistributionModel</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"Normal\" >beast.math.distributions.Normal</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"Beta\" >beast.math.distributions.Beta</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"Gamma\" >beast.math.distributions.Gamma</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"LaplaceDistribution\" >beast.math.distributions.LaplaceDistribution</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"prior\" >beast.math.distributions.Prior</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"InverseGamma\" >beast.math.distributions.InverseGamma</map>");
+  PhyML_Fprintf(fp,"\n<map name=\"OneOnX\" >beast.math.distributions.OneOnX</map>");
+
+
+  PhyML_Fprintf(fp,"\n<run id=\"mcmc\" spec=\"MCMC\" chainLength=\"1000000000\">");
+  PhyML_Fprintf(fp,"\n<state id=\"state\" storeEvery=\"10000\">");
+  PhyML_Fprintf(fp,"\n<stateNode id=\"Tree.t:h3n2\" spec=\"beast.evolution.tree.StructuredCoalescentMultiTypeTree\">");
+  PhyML_Fprintf(fp,"\n<migrationModel id=\"migModelInit.t:h3n2\" spec=\"beast.evolution.tree.MigrationModel\">");
+
+
+  s = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+  For(i,n_demes*(n_demes-1)) strcat(s,"1.0 ");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.0\" dimension=\"%d\" estimate=\"false\" name=\"rateMatrix\">%s</parameter>",n_demes*(n_demes-1),s);
+  Free(s);
+
+  s = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+  For(i,n_demes) strcat(s,"1.0 ");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.01\" dimension=\"%d\" estimate=\"false\" name=\"popSizes\">%s</parameter>",n_demes,s);
+  Free(s);
+
+  PhyML_Fprintf(fp,"\n</migrationModel>");
+
+  PhyML_Fprintf(fp,"\n<typeTrait id=\"typeTraitSet.t:h3n2\" spec=\"beast.evolution.tree.TraitSet\" traitname=\"type\" value=\"");
+
+  For(i,tree->n_otu)
+    {
+      s = strchr(tree->a_nodes[i]->coord->id,'_');
+      PhyML_Fprintf(fp,"%s=%s",
+                   tree->a_nodes[i]->coord->id,
+                   s+1);
+
+      if(i < tree->n_otu-1) PhyML_Fprintf(fp,",");
+      else PhyML_Fprintf(fp,"\">");
+    }
+
+  PhyML_Fprintf(fp,"\n<taxa id=\"TaxonSet.0\" spec=\"TaxonSet\">");
+  PhyML_Fprintf(fp,"\n<alignment idref=\"h3n2\"/>");
+  PhyML_Fprintf(fp,"\n</taxa>");
+  PhyML_Fprintf(fp,"\n</typeTrait>");
+  PhyML_Fprintf(fp,"\n<taxonset idref=\"TaxonSet.0\"/>");
+  PhyML_Fprintf(fp,"\n</stateNode>");
+  PhyML_Fprintf(fp,"\n<parameter id=\"kappa.s:h3n2\" lower=\"0.0\" name=\"stateNode\">2.0</parameter>");
+
+  s = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+  For(i,n_demes) strcat(s,"1.0 ");
+  PhyML_Fprintf(fp,"\n<parameter id=\"popSizes.t:h3n2\" dimension=\"%d\" name=\"stateNode\">%s</parameter>",n_demes,s);
+  Free(s);
+
+  s = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+  For(i,n_demes*(n_demes-1)) strcat(s,"1.0 ");
+  PhyML_Fprintf(fp,"\n<parameter id=\"rateMatrix.t:h3n2\" dimension=\"%d\" name=\"stateNode\">%s</parameter>",n_demes*(n_demes-1),s);
+  Free(s);
+
+
+  PhyML_Fprintf(fp,"\n<parameter id=\"freqParameter.s:h3n2\" dimension=\"4\" lower=\"0.0\" name=\"stateNode\" upper=\"1.0\">0.25</parameter>");
+  PhyML_Fprintf(fp,"\n</state>");
+
+
+  PhyML_Fprintf(fp,"\n<distribution id=\"posterior\" spec=\"util.CompoundDistribution\">");
+  PhyML_Fprintf(fp,"\n<distribution id=\"prior\" spec=\"util.CompoundDistribution\">");
+  PhyML_Fprintf(fp,"\n<prior id=\"KappaPrior.s:h3n2\" name=\"distribution\" x=\"@kappa.s:h3n2\">");
+  PhyML_Fprintf(fp,"\n<LogNormal id=\"LogNormalDistributionModel.0\" name=\"distr\">");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.02\" estimate=\"false\" name=\"M\">1.0</parameter>");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.03\" estimate=\"false\" name=\"S\">1.25</parameter>");
+  PhyML_Fprintf(fp,"\n</LogNormal>");
+  PhyML_Fprintf(fp,"\n</prior>");
+
+  PhyML_Fprintf(fp,"\n<prior id=\"popSizesPrior.t:h3n2\" name=\"distribution\" x=\"@popSizes.t:h3n2\">");
+  PhyML_Fprintf(fp,"\n<LogNormal id=\"LogNormalDistributionModel.01\" name=\"distr\">");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.04\" estimate=\"false\" name=\"M\">1.0</parameter>");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.05\" estimate=\"false\" lower=\"0.0\" name=\"S\" upper=\"5.0\">1.25</parameter>");
+  PhyML_Fprintf(fp,"\n</LogNormal>");
+  PhyML_Fprintf(fp,"\n</prior>");
+
+  PhyML_Fprintf(fp,"\n<prior id=\"rateMatrixPrior.t:h3n2\" name=\"distribution\" x=\"@rateMatrix.t:h3n2\">");
+  PhyML_Fprintf(fp,"\n<LogNormal id=\"LogNormalDistributionModel.02\" name=\"distr\">");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.06\" estimate=\"false\" name=\"M\">1.0</parameter>");
+  PhyML_Fprintf(fp,"\n<parameter id=\"RealParameter.07\" estimate=\"false\" lower=\"0.0\" name=\"S\" upper=\"5.0\">1.25</parameter>");
+  PhyML_Fprintf(fp,"\n</LogNormal>");
+  PhyML_Fprintf(fp,"\n</prior>");
+
+  PhyML_Fprintf(fp,"\n<distribution id=\"structuredCoalescent.t:h3n2\" spec=\"multitypetree.distributions.StructuredCoalescentTreeDensity\" multiTypeTree=\"@Tree.t:h3n2\">");
+  PhyML_Fprintf(fp,"\n<migrationModel id=\"migModel.t:h3n2\" spec=\"beast.evolution.tree.MigrationModel\" popSizes=\"@popSizes.t:h3n2\" rateMatrix=\"@rateMatrix.t:h3n2\">");
+  PhyML_Fprintf(fp,"\n</migrationModel>");
+  PhyML_Fprintf(fp,"\n</distribution>");
+
+  PhyML_Fprintf(fp,"\n<distribution id=\"likelihood\" spec=\"util.CompoundDistribution\">");
+  PhyML_Fprintf(fp,"\n<distribution id=\"treeLikelihood.h3n2\" spec=\"TreeLikelihood\" data=\"@h3n2\" tree=\"@Tree.t:h3n2\">");
+  PhyML_Fprintf(fp,"\n<siteModel id=\"SiteModel.s:h3n2\" spec=\"SiteModel\">");
+  PhyML_Fprintf(fp,"\n<parameter id=\"mutationRate.s:h3n2\" estimate=\"false\" name=\"mutationRate\">1.0</parameter>");
+  PhyML_Fprintf(fp,"\n<parameter id=\"gammaShape.s:h3n2\" estimate=\"false\" name=\"shape\">1.0</parameter>");
+  PhyML_Fprintf(fp,"\n<parameter id=\"proportionInvariant.s:h3n2\" estimate=\"false\" lower=\"0.0\" name=\"proportionInvariant\" upper=\"1.0\">0.0</parameter>");
+  PhyML_Fprintf(fp,"\n<substModel id=\"hky.s:h3n2\" spec=\"HKY\" kappa=\"@kappa.s:h3n2\">");
+  PhyML_Fprintf(fp,"\n<frequencies id=\"estimatedFreqs.s:h3n2\" spec=\"Frequencies\" frequencies=\"@freqParameter.s:h3n2\"/>");
+  PhyML_Fprintf(fp,"\n</substModel>");
+  PhyML_Fprintf(fp,"\n</siteModel>");
+  PhyML_Fprintf(fp,"\n<branchRateModel id=\"StrictClock.c:h3n2\" spec=\"beast.evolution.branchratemodel.StrictClockModel\">");
+  PhyML_Fprintf(fp,"\n<parameter id=\"clockRate.c:h3n2\" estimate=\"false\" name=\"clock.rate\">%G</parameter>",1.0);
+  PhyML_Fprintf(fp,"\n</branchRateModel>");
+  PhyML_Fprintf(fp,"\n</distribution>");
+  PhyML_Fprintf(fp,"\n</distribution>");
+  PhyML_Fprintf(fp,"\n</distribution>");
+  PhyML_Fprintf(fp,"\n</distribution>");
+  PhyML_Fprintf(fp,"\n");
+  PhyML_Fprintf(fp,"\n<operator id=\"STX.t:h3n2\" spec=\"multitypetree.operators.TypedSubtreeExchange\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" weight=\"10.0\"/>");
+  PhyML_Fprintf(fp,"\n<operator id=\"TWB.t:h3n2\" spec=\"multitypetree.operators.TypedWilsonBalding\" alpha=\"0.2\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" weight=\"10.0\"/>");
+  PhyML_Fprintf(fp,"\n<operator id=\"NR.t:h3n2\" spec=\"multitypetree.operators.NodeRetype\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" weight=\"10.0\"/>");
+  PhyML_Fprintf(fp,"\n<operator id=\"NSR1.t:h3n2\" spec=\"multitypetree.operators.NodeShiftRetype\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" rootOnly=\"true\" weight=\"10.0\"/>");
+  PhyML_Fprintf(fp,"\n<operator id=\"NSR2.t:h3n2\" spec=\"multitypetree.operators.NodeShiftRetype\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" noRoot=\"true\" weight=\"10.0\"/>");
+  PhyML_Fprintf(fp,"<operator id=\"MTU.t:h3n2\" spec=\"multitypetree.operators.MultiTypeUniform\" includeRoot=\"true\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" weight=\"10.0\"/>\n");
+  PhyML_Fprintf(fp,"<operator id=\"MTTS.t:h3n2\" spec=\"multitypetree.operators.MultiTypeTreeScale\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" scaleFactor=\"0.98\" useOldTreeScaler=\"true\" weight=\"10.0\"/>\n");
+  PhyML_Fprintf(fp,"\n<operator id=\"MTTUpDown.t:h3n2\" spec=\"multitypetree.operators.MultiTypeTreeScale\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\" scaleFactor=\"0.98\" useOldTreeScaler=\"true\" weight=\"10.0\">");
+  PhyML_Fprintf(fp,"\n<parameter idref=\"popSizes.t:h3n2\"/>");
+  PhyML_Fprintf(fp,"\n</operator>");
+  PhyML_Fprintf(fp,"\n<operator id=\"KappaScaler.s:h3n2\" spec=\"ScaleOperator\" parameter=\"@kappa.s:h3n2\" scaleFactor=\"0.5\" weight=\"0.1\"/>");
+  PhyML_Fprintf(fp,"\n<operator id=\"popSizesScaler.t:h3n2\" spec=\"ScaleOperator\" parameter=\"@popSizes.t:h3n2\" scaleFactor=\"0.8\" weight=\"1.0\"/>");
+  PhyML_Fprintf(fp,"\n<operator id=\"rateMatrixScaler.t:h3n2\" spec=\"ScaleOperator\" parameter=\"@rateMatrix.t:h3n2\" scaleFactor=\"0.8\" weight=\"1.0\"/>");
+  PhyML_Fprintf(fp,"\n<operator id=\"FrequenciesExchanger.s:h3n2\" spec=\"DeltaExchangeOperator\" delta=\"0.01\" weight=\"0.1\">");
+  PhyML_Fprintf(fp,"\n<parameter idref=\"freqParameter.s:h3n2\"/>");
+  PhyML_Fprintf(fp,"\n</operator>");
+  PhyML_Fprintf(fp,"\n");
+  PhyML_Fprintf(fp,"\n<logger id=\"tracelog\" fileName=\"$(filebase).log\" logEvery=\"10000\">");
+  PhyML_Fprintf(fp,"\n<log idref=\"likelihood\"/>");
+  PhyML_Fprintf(fp,"\n<log idref=\"prior\"/>");
+  PhyML_Fprintf(fp,"\n<log idref=\"treeLikelihood.h3n2\"/>");
+  PhyML_Fprintf(fp,"\n<log id=\"treeHeight.t:h3n2\" spec=\"beast.evolution.tree.TreeHeightLogger\" tree=\"@Tree.t:h3n2\"/>");
+  /* PhyML_Fprintf(fp,"\n<log id=\"treeLength.t:h3n2\" spec=\"multitypetree.util.TreeLengthLogger\" tree=\"@Tree.t:h3n2\"/>"); */
+  /* PhyML_Fprintf(fp,"\n<log id=\"changeCounts.t:h3n2\" spec=\"multitypetree.util.TypeChangeCounts\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\"/>"); */
+  /* PhyML_Fprintf(fp,"\n<log id=\"rootTypeLogger.t:h3n2\" spec=\"multitypetree.util.TreeRootTypeLogger\" multiTypeTree=\"@Tree.t:h3n2\"/>"); */
+  PhyML_Fprintf(fp,"\n<log id=\"migModelLogger.t:h3n2\" spec=\"multitypetree.util.MigrationModelLogger\" migrationModel=\"@migModel.t:h3n2\" multiTypeTree=\"@Tree.t:h3n2\"/>");
+  PhyML_Fprintf(fp,"\n</logger>");
+  PhyML_Fprintf(fp,"\n");
+  PhyML_Fprintf(fp,"\n<logger id=\"screenlog\" logEvery=\"50000\">");
+  PhyML_Fprintf(fp,"\n<log id=\"ESS.0\" spec=\"util.ESS\" arg=\"@posterior\"/>");
+  PhyML_Fprintf(fp,"\n<log idref=\"likelihood\"/>");
+  PhyML_Fprintf(fp,"\n</logger>");
+  PhyML_Fprintf(fp,"\n");
+  PhyML_Fprintf(fp,"\n</run>");
+  PhyML_Fprintf(fp,"\n</beast>");
+  
+  For(i,n_demes) Free(deme_names[i]);
+  Free(deme_names);
+
+  fclose(fp);
+}
+
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
diff --git a/src/phyrex.h b/src/phyrex.h
new file mode 100644
index 0000000..5e9409f
--- /dev/null
+++ b/src/phyrex.h
@@ -0,0 +1,113 @@
+/*
+
+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 <config.h>
+
+#ifndef PHYREX_H
+#define PHYREX_H
+
+#include "utilities.h"
+
+int PHYREX_Main(int argc, char **argv);
+int PHYREX_Main_Simulate(int argc, char **argv);
+int PHYREX_Main_Estimate(int argc, char **argv);
+t_tree *PHYREX_Simulate(int n_otu, int n_sites, phydbl width, phydbl height, int r_seed);
+phydbl PHYREX_Lk(t_tree *tree);
+phydbl PHYREX_Wrap_Lk(t_edge *b, t_tree *tree, supert_tree *stree);
+phydbl *PHYREX_MCMC(t_tree *tree);
+int PHYREX_Is_In_Disk(t_geo_coord *coord, t_dsk *disk, t_phyrex_mod *mmod);
+void PHYREX_New_Traj(t_dsk *start, t_dsk *end, t_tree *tree);
+void PHYREX_Remove_Disk(t_dsk *disk);
+void PHYREX_Insert_Disk(t_dsk *ins, t_tree *tree);
+t_ldsk *PHYREX_Prev_Coal_Lindisk(t_ldsk *t);
+t_ldsk *PHYREX_Next_Coal_Lindisk(t_ldsk *t);
+int PHYREX_Get_Next_Direction(t_ldsk *young, t_ldsk *old);
+void PHYREX_Update_Lindisk_List(t_tree *tree);
+void PHYREX_Update_Lindisk_List_Pre(t_dsk *disk, t_tree *tree);
+/* void PHYREX_Update_Lindisk_List(phydbl time, t_ldsk **list, int *pos, t_dsk *disk); */
+/* void PHYREX_Update_Lindisk_List_Pre(t_ldsk *ldsk, phydbl time, t_ldsk **list, int *pos); */
+void PHYREX_Connect_Ldsk_Given_Disk(t_dsk **disk, int n_disk, t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y);
+void PHYREX_Print_Struct(char sign, t_tree *tree);
+phydbl PHYREX_Uniform_Path_Density(t_ldsk *y_ldsk, t_ldsk *o_ldsk, t_tree *tree);
+void PHYREX_Check_Struct(t_tree *tree);
+void PHYREX_Store_Geo_Coord(t_geo_coord *t);
+void PHYREX_Restore_Geo_Coord(t_geo_coord *t);
+int PHYREX_Total_Number_Of_Intervals(t_tree *tree);
+int PHYREX_Total_Number_Of_Coal_Disks(t_tree *tree);
+int PHYREX_Total_Number_Of_Hit_Disks(t_tree *tree);
+phydbl PHYREX_Log_Dunif_Rectangle_Overlap(t_ldsk *ldsk, t_dsk *disk, t_phyrex_mod *mmod);
+phydbl PHYREX_Runif_Rectangle_Overlap(t_ldsk *ldsk, t_dsk *disk, t_phyrex_mod *mod);
+int PHYREX_One_New_Traj(t_ldsk *y_ldsk, t_ldsk *o_ldsk, int dir_o_y, t_dsk *xtra_dsk, int n_cur_disk, t_tree *tree);
+phydbl PHYREX_Wrap_Prior_Radius(t_edge *e, t_tree *tree, supert_tree *st);
+phydbl PHYREX_LnPrior_Radius(t_tree *tree);
+void PHYREX_Initial_Ldsk_Pos(t_tree *tree);
+phydbl PHYREX_Min_Radius(t_tree *tree);
+void PHYREX_Get_Min_Max_Disk_Given_Ldsk(t_dsk *disk, phydbl **min, phydbl **max, t_tree *tree);
+void PHYREX_Get_Min_Max_Ldsk_Given_Disk(t_ldsk *ldsk, phydbl **min, phydbl **max, t_tree *tree);
+void PHYREX_One_New_Traj_Given_Disk(t_ldsk *y_ldsk, t_ldsk *o_ldsk, t_tree *tree);
+void PHYREX_Update_Disk_Ldsk_Subtree(t_ldsk *root_ldsk, t_tree *tree);
+void PHYREX_Update_Disk_Ldsk_Subtree_Pre(t_ldsk *old_ldsk, t_ldsk *young_ldsk, t_ldsk *root_ldsk, t_tree *tree);
+void PHYREX_Restore_Disk_Ldsk_Subtree(t_ldsk *root_ldsk, t_tree *tree);
+void PHYREX_Restore_Disk_Ldsk_Subtree_Pre(t_ldsk *old_ldsk, t_ldsk *young_ldsk, t_tree *tree);
+void PHYREX_Proposal_Disk_Ldsk_Subtree(t_ldsk *root_ldsk, phydbl *logdens, t_tree *tree);
+void PHYREX_Proposal_Disk_Ldsk_Subtree_Pre(t_ldsk *old_ldsk, t_ldsk *young_ldsk, t_ldsk *root_ldsk, phydbl *logdens, t_tree *tree);
+phydbl PHYREX_LnPrior_Lbda(t_tree *tree);
+phydbl PHYREX_LnPrior_Mu(t_tree *tree);
+void PHYREX_Ldsk_To_Tree(t_tree *tree);
+void PHYREX_Ldsk_To_Tree_Post(t_node *a, t_ldsk *ldsk, int *available, t_tree *tree);
+phydbl PHYREX_Rnorm_Trunc(t_ldsk *ldsk, t_dsk *disk, t_phyrex_mod *mod);
+void PHYREX_Remove_Lindisk_Next(t_ldsk *ldsk, t_ldsk *rm);
+phydbl PHYREX_Simulate_Backward_Core(int new_loc, t_dsk *init_disk, t_tree *tree);
+phydbl *PHYREX_Mean_Pairwise_Distance_Between_Lineage_Locations(t_tree *tree);
+phydbl PHYREX_Random_Select_Time_Between_Jumps(t_tree *tree);
+phydbl PHYREX_Simulate_Forward_Core(int n_sites, t_tree *tree);
+int PHYREX_Is_In_Ldscape(t_ldsk *ldsk, t_phyrex_mod *mmod);
+void PHYREX_Update_Lindisk_List_Core(t_dsk *disk, t_tree *tree);
+phydbl PHYREX_Mean_Time_Between_Events(t_tree *tree);
+void PHYREX_All_Pairs_Coal_Times_Dist(t_tree *tree);
+void PHYREX_Rand_Pairs_Coal_Times_Dist(t_tree *tree);
+phydbl PHYREX_Neighborhood_Size_Regression(t_tree *tree);
+phydbl PHYREX_Neighborhood_Size(t_tree *tree);
+phydbl PHYREX_Update_Radius(t_tree *tree);
+phydbl PHYREX_Update_Sigsq(t_tree *tree);
+void PHYREX_Read_Tip_Coordinates(t_ldsk **ldsk_a, t_tree *tree);
+phydbl PHYREX_Sample_Rad_From_Prior(t_tree *tree);
+void MCMC_PHYREX_Sigsq(t_tree *tree);
+phydbl PHYREX_LnPrior_Sigsq(t_tree *tree);
+phydbl PHYREX_Rate_Per_Unit_Area(t_tree *tree);
+phydbl PHYREX_Tree_Height(t_tree *tree);
+int PHYREX_Random_Insert_Ldsk_In_Next_List(t_ldsk *ins, t_ldsk *where);
+void PHYREX_Insert_Ldsk_In_Next_List(t_ldsk *ins, int pos, t_ldsk *where);
+t_ldsk *PHYREX_Remove_Path(t_ldsk *beg, t_ldsk *end, int *pos_end, t_tree *tree);
+void PHYREX_Insert_Path(t_ldsk *beg, t_ldsk *end, t_ldsk *path, int pos, t_tree *tree);
+t_ldsk *PHYREX_Generate_Path(t_ldsk *beg, t_ldsk *end, phydbl n_evt, phydbl sd, t_tree *tree);
+phydbl PHYREX_Path_Logdensity(t_ldsk *beg, t_ldsk *end, phydbl cur_n_evt, phydbl sd, t_tree *tree);
+phydbl PHYREX_Time_Tree_Length(t_tree *tree);
+void PHYREX_Time_Tree_Length_Pre(t_ldsk *a, t_ldsk *d, phydbl *len, t_tree *tree);
+int PHYREX_Is_On_Path(t_ldsk *target, t_ldsk *beg, t_ldsk *end);
+int PHYREX_Path_Len(t_ldsk *beg, t_ldsk *end);
+phydbl PHYREX_Lk_Core(t_dsk *disk, t_tree *tree);
+void PHYREX_Print_Disk_Lk(t_tree *tree);
+phydbl PHYREX_Lk_Core_Bis(t_dsk *disk, t_tree *tree);
+t_ldsk *PHYREX_Find_Lca_Pair_Of_Ldsk(t_ldsk *n1, t_ldsk *n2, t_tree *tree);
+void PHYREX_Get_List_Of_Ancestors(t_ldsk *start, t_ldsk ***list, int *len, t_tree *tree);
+phydbl PHYREX_Dist_To_Lca(t_ldsk *d, t_ldsk *lca);
+phydbl PHYREX_Dist_Between_Two_Ldsk(t_ldsk *n1,  t_ldsk *n2, t_tree *tree);
+phydbl PHYREX_Lk_Range(t_dsk *young, t_dsk *old, t_tree *tree);
+void PHYREX_Print_MultiTypeTree_Config_File(int n_sites, char *filename, t_tree *tree);
+phydbl PHYREX_Effective_Density(t_tree *tree);
+phydbl PHYREX_Generation_Length(t_tree *tree);
+
+
+
+
+#endif
diff --git a/src/rates.c b/src/rates.c
index e518977..6a2926b 100644
--- a/src/rates.c
+++ b/src/rates.c
@@ -2378,7 +2378,6 @@ void RATES_Posterior_Time_Root(t_tree *tree)
 void RATES_Update_Cur_Bl(t_tree *tree)
 {
   RATES_Update_Norm_Fact(tree);
-
   RATES_Update_Cur_Bl_Pre(tree->n_root,tree->n_root->v[2],NULL,tree);
   RATES_Update_Cur_Bl_Pre(tree->n_root,tree->n_root->v[1],NULL,tree);
   
@@ -2429,7 +2428,6 @@ void RATES_Update_Cur_Bl(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void RATES_Update_Cur_Bl_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree)
 {
   phydbl dt,rr,cr,ra,rd,ta,td,nu;
@@ -2461,6 +2459,7 @@ void RATES_Update_Cur_Bl_Pre(t_node *a, t_node *d, t_edge *b, t_tree *tree)
 
       tree->rates->cur_l[d->num] = dt*rr*cr;
       
+
       if(tree->rates->model == GUINDON)
 	{
 	  phydbl m,v;
@@ -2755,7 +2754,6 @@ void RATES_Variance_Mu_Pre(t_node *a, t_node *d, t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void RATES_Fill_Lca_Table(t_tree *tree)
 {
   int i,j;
diff --git a/src/simu.c b/src/simu.c
index e362c51..57e9f87 100644
--- a/src/simu.c
+++ b/src/simu.c
@@ -335,30 +335,30 @@ void Make_N_Swap(t_tree *tree,t_edge **b, int beg, int end)
        tree);
 
       if(!Check_Topo_Constraints(tree,tree->io->cstr_tree))
-    {
-      /* Undo this swap as it violates one of the topological constraints
-         defined in the input constraint tree
-      */
-      Swap(b[i]->nni->swap_node_v2->v[tree->t_dir[b[i]->nni->swap_node_v2->num*dim+b[i]->nni->swap_node_v1->num]],
-           b[i]->nni->swap_node_v2,
-           b[i]->nni->swap_node_v3,
-           b[i]->nni->swap_node_v3->v[tree->t_dir[b[i]->nni->swap_node_v3->num*dim+b[i]->nni->swap_node_v4->num]],
-           tree);
-    }
-
+        {
+          /* Undo this swap as it violates one of the topological constraints
+             defined in the input constraint tree
+          */
+          Swap(b[i]->nni->swap_node_v2->v[tree->t_dir[b[i]->nni->swap_node_v2->num*dim+b[i]->nni->swap_node_v1->num]],
+               b[i]->nni->swap_node_v2,
+               b[i]->nni->swap_node_v3,
+               b[i]->nni->swap_node_v3->v[tree->t_dir[b[i]->nni->swap_node_v3->num*dim+b[i]->nni->swap_node_v4->num]],
+               tree);
+        }
+      
       if(tree->n_root)
-    {
-      tree->n_root->v[2] = tree->e_root->left;
-      tree->n_root->v[1] = tree->e_root->rght;
-    }
-
+        {
+          tree->n_root->v[2] = tree->e_root->left;
+          tree->n_root->v[1] = tree->e_root->rght;
+        }
+      
       orig = b[i];
       do
-    {
-      b[i]->l->v = b[i]->nni->best_l;
-      if(b[i]->next) b[i] = b[i]->next;
-      else            b[i] = b[i]->next;
-    }
+        {
+          b[i]->l->v = b[i]->nni->best_l;
+          if(b[i]->next) b[i] = b[i]->next;
+          else            b[i] = b[i]->next;
+        }
       while(b[i]);
       b[i] = orig;
 
diff --git a/src/spr.c b/src/spr.c
index 553dcc4..f3771ca 100644
--- a/src/spr.c
+++ b/src/spr.c
@@ -3297,9 +3297,12 @@ void Spr_Subtree(t_edge *b, t_node *link, t_tree *tree)
               /* printf("\n. 2"); fflush(NULL); */
               /* if(!Check_Lk_At_Given_Edge(YES,tree)) Exit("\n"); */
 
-              accept_prob = exp((tree->spr_list[best_move]->lnL - tree->best_lnL)/tree->annealing_temp);
-              u = Uni();
-              if(!(u > accept_prob)) apply_move = YES;
+              if(best_move > -1)
+                {
+                  accept_prob = exp((tree->spr_list[best_move]->lnL - tree->best_lnL)/tree->annealing_temp);
+                  u = Uni();
+                  if(!(u > accept_prob)) apply_move = YES;
+                }
                 
               /* if((best_move > -1) && (tree->spr_list[best_move]->lnL > tree->best_lnL + tree->mod->s_opt->min_diff_lk_move)) */
               if((best_move > -1) && (apply_move == YES))
@@ -3860,6 +3863,7 @@ int Evaluate_List_Of_Regraft_Pos_Triple(t_spr **spr_list, int list_size, t_tree
       Exit("\n");
     }
 
+
   recorded = NO;
   For(i,list_size)
     {
@@ -4634,7 +4638,6 @@ void Spr_Pars(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void SPR_Shuffle(t_tree *mixt_tree)
 {
   phydbl lk_old;
@@ -4646,6 +4649,7 @@ void SPR_Shuffle(t_tree *mixt_tree)
   /*! Get the number of classes in each mixture */
   orig_catg = MIXT_Get_Number_Of_Classes_In_All_Mixtures(mixt_tree);
 
+
   /*! Set the number of rate classes to (at most) 2.
     ! Propagate this to every mixture tree in the analysis
   */
diff --git a/src/stats.c b/src/stats.c
index e3814be..742b188 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -95,7 +95,7 @@ int Rand_Int(int min, int max)
 /*   return (int)FLOOR(u); */
 
   int u;
-  if(max < min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  /* if(max < min) Generic_Exit(__FILE__,__LINE__,__FUNCTION__); */
   u = rand();
   return (u%(max+1-min)+min);
 
@@ -154,23 +154,192 @@ phydbl Ahrensdietergamma(phydbl alpha)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 phydbl Rgamma(phydbl shape, phydbl scale)
 {
-  int i;
-  phydbl x1 = 0.;
-  phydbl delta = shape;
-  if (shape>=1.) 
-    {
-      int k = (int)FLOOR(shape);
-      delta = shape - k;
-      phydbl u = 1.;
-      for (i=0; i<k; i++)
-	u *= Uni();
-      x1 = -LOG(u);
-    }
-  phydbl x2 = Ahrensdietergamma(delta);
-  return (x1 + x2)*scale;
+  /* Code below is stolen from R sources. Thanks to the R team! */
+  /* References:
+     [1] Shape parameter a >= 1.  Algorithm GD in:
+
+	  Ahrens, J.H. and Dieter, U. (1982).
+	  Generating gamma variates by a modified
+	  rejection technique.
+	  Comm. ACM, 25, 47-54.
+
+
+    [2] Shape parameter 0 < a < 1. Algorithm GS in:
+
+	  Ahrens, J.H. and Dieter, U. (1974).
+	  Computer methods for sampling from gamma, beta,
+	  poisson and binomial distributions.
+	  Computing, 12, 223-246.
+  */
+
+
+  double a = (double)shape;
+  /* Constants : */
+  const static double sqrt32 = 5.656854;
+  const static double exp_m1 = 0.36787944117144232159;/* exp(-1) = 1/e */
+
+  /* Coefficients q[k] - for q0 = sum(q[k]*a^(-k))
+   * Coefficients a[k] - for q = q0+(t*t/2)*sum(a[k]*v^k)
+   * Coefficients e[k] - for exp(q)-1 = sum(e[k]*q^k)
+   */
+  const static double q1 = 0.04166669;
+  const static double q2 = 0.02083148;
+  const static double q3 = 0.00801191;
+  const static double q4 = 0.00144121;
+  const static double q5 = -7.388e-5;
+  const static double q6 = 2.4511e-4;
+  const static double q7 = 2.424e-4;
+  
+  const static double a1 = 0.3333333;
+  const static double a2 = -0.250003;
+  const static double a3 = 0.2000062;
+  const static double a4 = -0.1662921;
+  const static double a5 = 0.1423657;
+  const static double a6 = -0.1367177;
+  const static double a7 = 0.1233795;
+  
+  /* State variables [FIXME for threading!] :*/
+  static double aa = 0.;
+  static double aaa = 0.;
+  static double s, s2, d;    /* no. 1 (step 1) */
+  static double q0, b, si, c;/* no. 2 (step 4) */
+  
+  double e, p, q, r, t, u, v, w, x, ret_val;
+  
+  if(a < 0.0 || scale <= 0.0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  
+  if (a < 1.) 
+    { /* GS algorithm for parameters a < 1 */
+      if(a == 0) return 0.;
+      e = 1.0 + exp_m1 * a;
+      for(;;) 
+        {
+          p = e * Uni();
+          if (p >= 1.0) 
+            {
+              x = -LOG((e - p) / a);
+              if (Rexp(1.) >= (1.0 - a) * LOG(x))
+                break;
+	    } 
+          else 
+            {
+              x = EXP(LOG(p) / a);
+              if (Rexp(1.) >= x)
+                break;
+	    }
+	}
+      return scale * x;
+    }
+
+    /* --- a >= 1 : GD algorithm --- */
+
+    /* Step 1: Recalculations of s2, s, d if a has changed */
+    if (a != aa) 
+      {
+	aa = a;
+	s2 = a - 0.5;
+	s = SQRT(s2);
+	d = sqrt32 - s * 12.0;
+      }
+    /* Step 2: t = standard normal deviate,
+               x = (s,1/2) -normal deviate. */
+
+    /* immediate acceptance (i) */
+    t = Rnorm(0.0,1.0);
+    x = s + 0.5 * t;
+    ret_val = x * x;
+    if (t >= 0.0) return scale * ret_val;
+
+    /* Step 3: u = 0,1 - uniform sample. squeeze acceptance (s) */
+    u = Uni();
+    if (d * u <= t * t * t) return scale * ret_val;
+
+    /* Step 4: recalculations of q0, b, si, c if necessary */
+
+    if (a != aaa) 
+      {
+	aaa = a;
+	r = 1.0 / a;
+	q0 = ((((((q7 * r + q6) * r + q5) * r + q4) * r + q3) * r
+	       + q2) * r + q1) * r;
+        
+	/* Approximation depending on size of parameter a */
+	/* The constants in the expressions for b, si and c */
+	/* were established by numerical experiments */
+        
+	if (a <= 3.686) 
+          {
+            b = 0.463 + s + 0.178 * s2;
+            si = 1.235;
+            c = 0.195 / s - 0.079 + 0.16 * s;
+          } 
+        else if (a <= 13.022) 
+          {
+            b = 1.654 + 0.0076 * s2;
+            si = 1.68 / s + 0.275;
+	    c = 0.062 / s + 0.024;
+          } 
+        else 
+          {
+            b = 1.77;
+            si = 0.75;
+	    c = 0.1515 / s;
+          }
+      }
+
+    /* Step 5: no quotient test if x not positive */
+    if (x > 0.0) 
+      {
+	/* Step 6: calculation of v and quotient q */
+	v = t / (s + s);
+	if (FABS(v) <= 0.25)
+          q = q0 + 0.5 * t * t * ((((((a7 * v + a6) * v + a5) * v + a4) * v
+                                    + a3) * v + a2) * v + a1) * v;
+	else
+          q = q0 - s * t + 0.25 * t * t + (s2 + s2) * log(1.0 + v);
+        
+        
+	/* Step 7: quotient acceptance (q) */
+	if (LOG(1.0 - u) <= q)
+          return scale * ret_val;
+      }
+    
+    for(;;) 
+      {
+	/* Step 8: e = standard exponential deviate
+	 *	u =  0,1 -uniform deviate
+	 *	t = (b,si)-double exponential (laplace) sample */
+	e = Rexp(1.0);
+	u = Uni();
+	u = u + u - 1.0;
+	if (u < 0.0)
+	    t = b - si * e;
+	else
+	    t = b + si * e;
+	/* Step	 9:  rejection if t < tau(1) = -0.71874483771719 */
+	if (t >= -0.71874483771719) {
+	    /* Step 10:	 calculation of v and quotient q */
+	    v = t / (s + s);
+	    if (FABS(v) <= 0.25)
+		q = q0 + 0.5 * t * t *
+		    ((((((a7 * v + a6) * v + a5) * v + a4) * v + a3) * v
+		      + a2) * v + a1) * v;
+	    else
+		q = q0 - s * t + 0.25 * t * t + (s2 + s2) * LOG(1.0 + v);
+	    /* Step 11:	 hat acceptance (h) */
+	    /* (if q not positive go to step 8) */
+	    if (q > 0.0) {
+		w = EXP(q)-1.0;
+		/* if t is rejected sample again at step 8 */
+		if (c * FABS(u) <= w * EXP(e - 0.5 * t * t))
+		    break;
+	    }
+	}
+    } /* repeat .. until  `t' is accepted */
+    x = s + 0.5 * t;
+    return scale * x * x;
 }
 
 //////////////////////////////////////////////////////////////
@@ -307,18 +476,20 @@ phydbl Rnorm_Trunc_Inverse(phydbl mean, phydbl sd, phydbl min, phydbl max, int *
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 phydbl Rnorm_Trunc(phydbl mean, phydbl sd, phydbl min, phydbl max, int *error)
 {
 
-  phydbl ret_val,eps;
-  int iter;
-  phydbl z;
+  phydbl ret_val;
+  phydbl z, q, u, a;
   phydbl z_min,z_max;
+  int n_max_iter,n_iter;
+  int algo;
+
+  z          = 0.0;
+  *error     = NO;
+  ret_val    = INFINITY;
+  n_max_iter = 100000;
 
-  z      = 0.0;
-  *error = NO;
-  
   if(sd < 1.E-100)
     {
       PhyML_Printf("\n. Small variance detected in Rnorm_Trunc.");
@@ -338,63 +509,100 @@ phydbl Rnorm_Trunc(phydbl mean, phydbl sd, phydbl min, phydbl max, int *error)
   z_min = (min - mean)/sd;
   z_max = (max - mean)/sd;
 
-  eps = (z_max-z_min)/1E+6;
-
-  /* Damien and Walker (2001) method */
-  phydbl y,slice_min,slice_max;
-
-/*   if((z_min < -10.) && (z_max > +10.)) /\* cdf < 1.E-6, we should be safe. *\/ */
-/*     { */
-/*       z = Rnorm(0.0,1.0); */
-/*     } */
-/*   else */
-/*     { */
-
-
-      iter = 0;
-      do
-	{
-	  y   = Uni()*EXP(-(z*z)/2.);
-	  slice_min = MAX(z_min,-SQRT(-2.*LOG(y)));
-	  slice_max = MIN(z_max, SQRT(-2.*LOG(y)));
-	  z   = Uni()*(slice_max - slice_min) + slice_min;
-	  iter++;
-	  if(iter > 1000) break;
-	}
-      while(slice_max < slice_min || iter < 10);
-
-      if(iter > 1000)
-	{
-	  PhyML_Printf("\n. Too many iterations in Rnorm_Trunc...");
-	  *error = 1;
-	}
+  if(z_min < 0.0 && z_max > 0 && (z_max - z_min > SQRT(2*PI)))
+    {
+      algo = 0;
+    }
+  if((z_min > 0.0 || Are_Equal(z_min,0.0,1.E-10)) && z_max > z_min + 2.*SQRT(EXP(1.0))/(z_min + SQRT(z_min*z_min+4.)) * EXP((z_min*z_min - z_min*SQRT(z_min*z_min+4.))/4.))
+    {
+      algo = 1;
+    }
+  else if((z_max < 0.0 || Are_Equal(z_max,0.0,1.E-10)) && -z_min > -z_max + 2.*SQRT(EXP(1.0))/(-z_max + SQRT(z_max*z_max+4.)) * EXP((z_max*z_max - (-z_max)*SQRT(z_max*z_max+4.))/4.))
+    {
+      algo = 2;
+    }
+  else
+    {
+      algo = 3;
+    }
 
-/*     } */
 
-  /* Inverson method */
-/*   phydbl cdf_min, cdf_max; */
-/*   if((z_min < -10.) && (z_max > +10.)) /\* cdf < 1.E-6, we should be safe. *\/ */
-/*     { */
-/*       z = Rnorm(0.0,1.0); */
-/*     } */
-/*   else */
-/*     { */
-/* /\*       Simple inversion method. Seems to work well. Needs more thorough testing though... *\/ */
-/*       cdf_min = Pnorm(z_min,0.0,1.0); */
-/*       cdf_max = Pnorm(z_max,0.0,1.0); */
-/*       u = cdf_min + (cdf_max-cdf_min) * Uni(); */
-/*       z = PointNormal(u); */
-/*     } */
+  switch(algo)
+    {
+    case 0:
+      {
+        n_iter = 0;
+        do 
+          { 
+            z = Rnorm(0.0,1.0); 
+            n_iter++;
+            if(n_iter > n_max_iter)
+              {
+                PhyML_Printf("\n== Too many iterations in Rnorm_Trunc()");
+                *error = YES; 
+              }
+          }
+        while(z < z_min || z > z_max);
+        break;
+      }
+    case 1:
+      {
+        n_iter = 0;
+        do
+          {
+            a = (z_min + SQRT(z_min*z_min+4.))/2.;
+            q = Rexp(a) + z_min;
+            u = Uni();
+            n_iter++;
+            if(n_iter > n_max_iter)
+              {
+                PhyML_Printf("\n== Too many iterations in Rnorm_Trunc()");
+                *error = YES; 
+              }
+          }while(u > EXP(-POW(q-a,2)/2.));
+        z = q;
+        break;
+      }
+    case 2:
+      {
+        n_iter = 0;
+        do
+          {
+            a = (-z_max + SQRT(z_max*z_max+4.))/2.;
+            q = Rexp(a) - z_max;
+            u = Uni();
+            n_iter++;
+            if(n_iter > n_max_iter)
+              {
+                PhyML_Printf("\n== Too many iterations in Rnorm_Trunc()");
+                *error = YES; 
+              }
+          }while(u > EXP(-POW(q-a,2)/2.));
+        z = -q;
+        break;
+      }
+    case 3:
+      {
+        n_iter = 0;
+        do
+          {
+            z = Uni()*(z_max - z_min) + z_min;
+            if(z_min < 0.0 && z_max > 0.0) q = EXP(-z*z/2.);
+            else if (z_max < 0.0) q = EXP((z_max*z_max-z*z)/2.);
+            else q = EXP((z_min*z_min-z*z)/2.);
+            u = Uni();
+            n_iter++;
+            if(n_iter > n_max_iter)
+              {
+                PhyML_Printf("\n== Too many iterations in Rnorm_Trunc()");
+                *error = YES; 
+              }
+          }while(u > q); 
+        break;
+      }
 
+    default: Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
 
-   if((z < z_min-eps) || (z > z_max+eps))
-    {
-      *error = YES;
-      PhyML_Printf("\n. Numerical precision issue detected in Rnorm_Trunc.");
-      PhyML_Printf("\n. z = %f",z);
-      PhyML_Printf("\n. mean=%f sd=%f z_min=%f z_max=%f min=%f max=%f",mean,sd,z_min,z_max,min,max);
-      ret_val = (max - min)/2.;
-      Exit("\n");
     }
 
   ret_val = z*sd+mean;
@@ -462,6 +670,254 @@ phydbl *Rnorm_Multid_Trunc(phydbl *mean, phydbl *cov, phydbl *min, phydbl *max,
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
+/* Inversion method for sampling from Geometric distibution */
+phydbl Rgeom(phydbl p)
+{
+  phydbl x,u;
+
+  u = Uni();
+  if(u < SMALL) return(0.0);
+  x = LOG(u) / LOG(1. - p);
+  
+  return(CEIL(x));  
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl Dgeom(phydbl k, phydbl p, int logit)
+{
+  phydbl prob;
+
+  if(k < 1.) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  if(p > 1.-SMALL)
+    {
+      if(logit == YES) return(-INFINITY);
+      else return(0.0);
+    }
+
+  if(logit == YES)
+    prob = (k - 1.)*LOG(1. - p) + LOG(p);
+  else
+    prob = POW(1.-p,k-1.)*p;
+
+  return(prob);
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl Pgeom(phydbl k, phydbl p)
+{
+
+  if(k < 1.) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  if(p > 1.-SMALL) return(0.0);
+
+  return(1. - POW((1. - p),k));
+
+}
+
+
+/*
+ * Random variates from the Poisson distribution. Completely stolen from R code.
+ *
+ * REFERENCE
+ *
+ * Ahrens, J.H. and Dieter, U. (1982).
+ * Computer generation of Poisson deviates
+ * from modified normal distributions.
+ * ACM Trans. Math. Software 8, 163-179.
+ */
+phydbl Rpois(phydbl mmu)
+{
+  double mu = (double)mmu;
+  
+  double a0	= -0.5;
+  double a1	= 0.3333333;
+  double a2	= -0.2500068;
+  double a3	= 0.2000118;
+  double a4	= -0.1661269;
+  double a5	= 0.1421878;
+  double a6	= -0.1384794;
+  double a7	= 0.1250060;
+  double one_7	= 0.1428571428571428571;
+  double one_12	= 0.0833333333333333333;
+  double one_24	= 0.0416666666666666667;
+
+  /* Factorial Table (0:9)! */
+  const static double fact[10] =
+    {
+      1., 1., 2., 6., 24., 120., 720., 5040., 40320., 362880.
+    };
+  /* These are static --- persistent between calls for same mu : */
+  static int l, m;
+  static double b1, b2, c, c0, c1, c2, c3;
+  static double pp[36], p0, p, q, s, d, omega;
+  static double big_l;/* integer "w/o overflow" */
+  static double muprev = 0., muprev2 = 0.;/*, muold = 0.*/
+  /* Local Vars [initialize some for -Wall]: */
+  double del, difmuk= 0., E= 0., fk= 0., fx, fy, g, px, py, t, u= 0., v, x;
+  double pois = -1.;
+  int k, kflag, big_mu, new_big_mu = FALSE;
+  
+  if (isnan(mu) || mu < 0.0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  if (mu <= 0.) return 0.;
+
+  big_mu = mu >= 10.;
+  if(big_mu) new_big_mu = FALSE;
+  if (!(big_mu && mu == muprev)) {/* maybe compute new persistent par.s */
+    if (big_mu) 
+      {
+        new_big_mu = TRUE;
+        /* Case A. (recalculation of s,d,l because mu has changed):
+         * The poisson probabilities pk exceed the discrete normal
+         * probabilities fk whenever k >= m(mu).
+         */
+        muprev = mu;
+        s = sqrt(mu);
+        d = 6. * mu * mu;
+        big_l = floor(mu - 1.1484);
+        /* = an upper bound to m(mu) for all mu >= 10.*/
+      }
+    else 
+      { 
+        /* Small mu ( < 10) -- not using normal approx. */
+        /* Case B. (start new table and calculate p0 if necessary) */
+        /*muprev = 0.;-* such that next time, mu != muprev ..*/
+        if (mu != muprev) 
+          {
+            muprev = mu;
+            m = MAX(1, (int) mu);
+            l = 0; /* pp[] is already ok up to pp[l] */
+            q = p0 = p = exp(-mu);
+          }
+        for(;;) 
+          {
+            /* Step U. uniform sample for inversion method */
+            u = Uni();
+            if (u <= p0) return 0.;
+            /* Step T. table comparison until the end pp[l] of the
+               pp-table of cumulative poisson probabilities
+               (0.458 > ~= pp[9](= 0.45792971447) for mu=10 ) */
+            if (l != 0) 
+              {
+                for (k = (u <= 0.458) ? 1 : MIN(l, m); k <= l; k++) if (u <= pp[k]) return((phydbl)k);
+                if (l == 35) /* u > pp[35] */
+                  continue;
+              }
+            /* Step C. creation of new poisson
+               probabilities p[l..] and their cumulatives q =: pp[k] */
+            l++;
+            for (k = l; k <= 35; k++) 
+              {
+                p *= mu / k;
+                q += p;
+                pp[k] = q;
+                if (u <= q) 
+                  {
+                    l = k;
+                    return((phydbl)k);
+                  }
+              }
+            l = 35;
+          } /* end(repeat) */
+      }/* mu < 10 */
+  } /* end {initialize persistent vars} */
+  /* Only if mu >= 10 : ----------------------- */
+  /* Step N. normal sample */
+  g = mu + s * Rnorm(0.0,1.0);/* norm_rand() ~ N(0,1), standard normal */
+  if (g >= 0.) 
+    {
+      pois = floor(g);
+      /* Step I. immediate acceptance if pois is large enough */
+      if (pois >= big_l)
+        return((phydbl)pois);
+      /* Step S. squeeze acceptance */
+      fk = pois;
+      difmuk = mu - fk;
+      u = Uni(); /* ~ U(0,1) - sample */
+      if (d * u >= difmuk * difmuk * difmuk)
+        return((phydbl)pois);
+    }
+  /* Step P. preparations for steps Q and H.
+     (recalculations of parameters if necessary) */
+  if (new_big_mu || mu != muprev2) {
+    /* Careful! muprev2 is not always == muprev
+       because one might have exited in step I or S
+    */
+    muprev2 = mu;
+    omega = M_1_SQRT_2PI / s;
+    /* The quantities b1, b2, c3, c2, c1, c0 are for the Hermite
+     * approximations to the discrete normal probabilities fk. */
+    b1 = one_24 / mu;
+    b2 = 0.3 * b1 * b1;
+    c3 = one_7 * b1 * b2;
+    c2 = b2 - 15. * c3;
+    c1 = b1 - 6. * b2 + 45. * c3;
+    c0 = 1. - b1 + 3. * b2 - 15. * c3;
+    c = 0.1069 / mu; /* guarantees majorization by the 'hat'-function. */
+  }
+  if (g >= 0.) {
+    /* 'Subroutine' F is called (kflag=0 for correct return) */
+    kflag = 0;
+    goto Step_F;
+  }
+  for(;;) 
+    {
+      /* Step E. Exponential Sample */
+      E = Rexp(1.0); /* ~ Exp(1) (standard exponential) */
+      /* sample t from the laplace 'hat'
+         (if t <= -0.6744 then pk < fk for all mu >= 10.) */
+      u = 2. * Uni() - 1.;
+      /* t = 1.8 + fsign(E, u); */
+      t = 1.8 + ((u >= 0.0) ? fabs(E) : -fabs(E));
+      if (t > -0.6744)
+        {
+          pois = floor(mu + s * t);
+          fk = pois;
+          difmuk = mu - fk;
+          /* 'subroutine' F is called (kflag=1 for correct return) */
+          kflag = 1;
+        Step_F: /* 'subroutine' F : calculation of px,py,fx,fy. */
+          if (pois < 10) { /* use factorials from table fact[] */
+            px = -mu;
+            py = pow(mu, pois) / fact[(int)pois];
+          }
+          else {
+            /* Case pois >= 10 uses polynomial approximation
+               a0-a7 for accuracy when advisable */
+            del = one_12 / fk;
+            del = del * (1. - 4.8 * del * del);
+            v = difmuk / fk;
+            if (fabs(v) <= 0.25)
+              px = fk * v * v * (((((((a7 * v + a6) * v + a5) * v + a4) *
+                                    v + a3) * v + a2) * v + a1) * v + a0)
+                - del;
+            else /* |v| > 1/4 */
+              px = fk * log(1. + v) - difmuk - del;
+            py = M_1_SQRT_2PI / sqrt(fk);
+          }
+          x = (0.5 - difmuk) / s;
+          x *= x;/* x^2 */
+          fx = -0.5 * x;
+          fy = omega * (((c3 * x + c2) * x + c1) * x + c0);
+          if (kflag > 0) {
+            /* Step H. Hat acceptance (E is repeated on rejection) */
+            if (c * fabs(u) <= py * exp(px + E) - fy * exp(fx + E))
+              break;
+          } else
+            /* Step Q. Quotient acceptance (rare case) */
+            if (fy - u * fy <= py * exp(px - fx))
+              break;
+        }/* t > -.67.. */
+    }
+  return((phydbl)pois);
+}
+
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
 
 /* DENSITIES / PROBA */
 //////////////////////////////////////////////////////////////
@@ -501,7 +957,6 @@ phydbl Dnorm(phydbl x, phydbl mean, phydbl sd)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 phydbl Log_Dnorm(phydbl x, phydbl mean, phydbl sd, int *err)
 {
   phydbl dens;
@@ -510,7 +965,6 @@ phydbl Log_Dnorm(phydbl x, phydbl mean, phydbl sd, int *err)
 
   x = (x-mean)/sd;
   
-  /* dens = -(phydbl)LOG_SQRT_2_PI - x*x*0.5 - LOG(sd); */
   dens = -(phydbl)LOG(SQRT(2.*PI)) - x*x*0.5 - LOG(sd);
 
   if(dens < -BIG)
@@ -522,15 +976,16 @@ phydbl Log_Dnorm(phydbl x, phydbl mean, phydbl sd, int *err)
   return dens;
 }
 
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
 
 phydbl Log_Dnorm_Trunc(phydbl x, phydbl mean, phydbl sd, phydbl lo, phydbl up, int *err)
 {
   phydbl log_dens;
   phydbl cdf_up, cdf_lo;
 
+  if(x < lo || x > up) return -230.;
+
   *err = NO;
   cdf_lo = cdf_up = 0.0;
 
@@ -695,7 +1150,35 @@ phydbl Bivariate_Normal_Density(phydbl x, phydbl y, phydbl mux, phydbl muy, phyd
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
+// E(X) = n(1-p)/p ; V(X) = n(1-p)/p^2
+phydbl Dnbinom(phydbl x, phydbl n, phydbl p, int logit)
+{
 
+  phydbl lnDens = LnGamma(x+n) - LnGamma(n) - LnFact(x) + n*LOG(p) + x*LOG(1.-p);
+
+  if(logit == TRUE)
+    {
+      return(lnDens);
+    }
+  else
+    {
+      return(EXP(lnDens));
+    }
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl Rnbinom(phydbl n, phydbl p)
+{
+  phydbl y,x;
+  y = Rgamma(n,(1.-p)/p);
+  x = Rpois(y);
+  return(x);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
 
 phydbl Dgamma_Moments(phydbl x, phydbl mean, phydbl var)
 {
@@ -804,12 +1287,11 @@ phydbl Dpois(phydbl x, phydbl param, int logit)
 
   if(x < .0) 
     {
-      PhyML_Printf("\n== x = %f",x);
-      PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
-      Warn_And_Exit("");
-    }
+      if(logit == YES) return(-INFINITY);
+      else return 0.0;
+   }
 
-  v = x * LOG(param) - param - LnGamma(x+1);
+  v = x * LOG(param) - param - Factln(x);
   if(logit == YES) return v;
   else
     {
@@ -1284,7 +1766,6 @@ phydbl Bico(int n, int k)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 phydbl Factln(int n)
 {
   static phydbl a[101];
@@ -1473,8 +1954,8 @@ phydbl LnFact(int n)
   int i;
   phydbl res;
 
-  res = 0;
-  for(i=2;i<=n;i++) res += LOG(i);
+  res = .0;
+  for(i=2;i<n+1;i++) res += LOG((phydbl)i);
   
   return(res);
 }
@@ -1500,7 +1981,13 @@ int Choose(int n, int k)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
+phydbl LnChoose(int n, int k)
+{
+  return(LnFact(n) - LnFact(k) - LnFact(n-k));
+}
 
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
 
 phydbl *Covariance_Matrix(t_tree *tree)
 {
@@ -4386,6 +4873,7 @@ int Sample_i_With_Proba_pi(phydbl *pi, int len)
 
   if(i == len)
     {
+      For(i,len) printf("\n== idx:%d prob:%g",i,pi[i]);
       PhyML_Printf("\n== Len = %d",len);
       PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
       Exit("\n");
@@ -4471,7 +4959,7 @@ phydbl Inverse_Truncated_Normal(phydbl y, phydbl mu, phydbl sigma, phydbl lim_in
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 // Returns a vector with a permutation of all the integer from 0
-// to len-1.
+// to len-1. Fisher-Yates algorithm.
 
 int *Permutate(int len)
 {
@@ -4484,7 +4972,7 @@ int *Permutate(int len)
 
   For(i,len)
     {
-      pos = Rand_Int(0,len-1);
+      pos = Rand_Int(i,len-1);
       
       tmp    = x[i];
       x[i]   = x[pos];
@@ -4564,13 +5052,33 @@ phydbl Weighted_Mean(phydbl *x, phydbl *w, int l)
   int i;
   phydbl wm;
   wm = .0;
-  For(i,l) wm += x[i]*w[i];
+  if(w) For(i,l) wm += x[i]*w[i];
+  else  
+    {
+      For(i,l) wm += x[i];
+      wm /= (phydbl)l;
+    }
   return(wm);
 }
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
+phydbl Variance(phydbl *x, int l)
+{
+  phydbl mean,sum;
+  int i;
+
+  mean = Weighted_Mean(x,NULL,l);
+  sum = 0.0;
+  For(i,l) sum += x[i]*x[i];
+  
+  return(sum/l - mean*mean);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
 int Sum_Bits(int value, int range)
 {
   int i;
@@ -4643,6 +5151,12 @@ int *Random_Permut(int n)
   int i,j;
   int tmp;
 
+  if(n < 3) 
+    {
+      PhyML_Printf("\n== Number of vertices in a polygon has to be at least 3.");
+      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+    }
+    
   permut = (int *)mCalloc(n,sizeof(int));
 
   For(i,n) permut[i] = i;
@@ -4658,9 +5172,291 @@ int *Random_Permut(int n)
   return(permut);
 }
 
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+/* Generate a random polygon with n vertices. Each point lies in [0,1] */
+t_poly *Rpoly(int n)
+{
+  t_poly *p;
+  int i;
+
+  p = (t_poly *)Make_Poly(n);  
+  p->n_poly_vert = n;
+  
+  For(i,n)
+    {
+      p->poly_vert[i]->lonlat[0] = Uni();
+      p->poly_vert[i]->lonlat[1] = Uni();
+    }
+  
+  return(p);
+}
+
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
+
+phydbl Area_Of_Poly_Monte_Carlo(t_poly **poly, int n_poly, t_geo_coord *lim)
+{
+  int n_hit,n_trials,trial,i;
+  t_geo_coord *point;
+
+  point = (t_geo_coord *)GEO_Make_Geo_Coord(2);
+
+  n_trials = 1E+7;
+  trial = 0;
+  n_hit = 0;
+  do
+    {
+      point->lonlat[0] = Uni()*lim->lonlat[0];
+      point->lonlat[1] = Uni()*lim->lonlat[1];
+      For(i,n_poly) if(Is_In_Polygon(point,poly[i]) == YES) { n_hit++; break; }
+      trial++;
+    }
+  while(trial < n_trials);
+
+  Free_Geo_Coord(point);
+
+  return((phydbl)(n_hit)/n_trials);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+int Is_In_Polygon(t_geo_coord *point, t_poly *poly)
+{
+  int i,j;
+  phydbl x,y,x1,y1,x2,y2;
+  phydbl x_intersect;
+  short int is_in;
+
+  /* Coordinates of the point to test */
+  x = point->lonlat[0];
+  y = point->lonlat[1];
+
+  j = poly->n_poly_vert-1;
+  is_in = NO;
+  For(i,poly->n_poly_vert)
+    {
+      /* Edge of polygon goes from (x1,y1) to (x2,y2) */
+      x1 = poly->poly_vert[i]->lonlat[0];
+      y1 = poly->poly_vert[i]->lonlat[1];
+      x2 = poly->poly_vert[j]->lonlat[0];
+      y2 = poly->poly_vert[j]->lonlat[1];
+
+      j = i;
+
+      /* Shoot an horizontal ray to the right. Find out if
+         this ray hits the polygon edge */
+      if((y1 < y && y2 > y) || (y2 < y && y1 > y))
+        {
+          /* Coordinates along X-axis of the intersection between ray and edge */
+          x_intersect = (y-y1)/(y1-y2)*(x1-x2)+x1;  
+          if(x_intersect > x) /* Intersection is on the righthand side */
+            is_in = (is_in == YES)?NO:YES;
+        }
+    }
+
+  return is_in;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Modified Bessel function of the first kind. Stolen from Numerical Recipes in C. */
+phydbl Bessi0(phydbl x)
+{
+  phydbl ax,ans;
+  phydbl y;
+
+  if ((ax=fabs(x)) < 3.75) 
+    {
+      y=x/3.75;
+      y*=y;
+      ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492+y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
+    } 
+  else 
+    {
+      y=3.75/ax;
+      ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1+y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2+y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1+y*0.392377e-2))))))));
+    }
+
+  return ans;
+}
+
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Modified Bessel function of the second kind (degree 0). Stolen from Numerical Recipes in C. */
+phydbl Bessk0(phydbl x)
+{
+  phydbl y,ans;
+
+  if (x <= 2.0) 
+    {
+      y=x*x/4.0;
+      ans=(-log(x/2.0)*Bessi0(x))+(-0.57721566+y*(0.42278420+y*(0.23069756+y*(0.3488590e-1+y*(0.262698e-2+y*(0.10750e-3+y*0.74e-5))))));
+    } 
+  else 
+    {
+      y=2.0/x;
+      ans=(exp(-x)/sqrt(x))*(1.25331414+y*(-0.7832358e-1+y*(0.2189568e-1+y*(-0.1062446e-1+y*(0.587872e-2+y*(-0.251540e-2+y*0.53208e-3))))));
+    }
+
+  return ans;
+}
+
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl Euclidean_Dist(t_geo_coord *x, t_geo_coord *y)
+{
+  int i;
+  phydbl dist;
+  
+  if(x->dim != y->dim) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
+  
+  dist = 0.0;
+  For(i,x->dim) dist += POW(x->lonlat[i]-y->lonlat[i],2);
+
+  return(SQRT(dist));
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Return the ranks of elements in x */
+int *Ranks(phydbl *x, int len)
+{
+  int *rk,tmp;
+  int i,swap;
+
+  rk = (int *)mCalloc(len,sizeof(int));
+
+  For(i,len) rk[i] = i;
+
+  do
+    {
+      swap = NO;
+      For(i,len-1) 
+        {
+          if(x[rk[i]] > x[rk[i+1]])
+            {
+              swap  = YES; 
+              tmp   = rk[i];
+              rk[i] = rk[i+1];
+              rk[i+1] = tmp;
+            }
+        }
+    }
+  while(swap == YES);
+
+  return(rk);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl *Brownian_Bridge_Generate(phydbl start, phydbl end, phydbl var, phydbl beg_time, phydbl end_time, int n_steps, phydbl *time)
+{
+  phydbl *state,end_brown;
+  int i;
 
+  if(n_steps == 0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  if(beg_time > end_time) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+  For(i,n_steps-1) if(!(time[i+1] > time[i])) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
 
+  state = Brownian_Generate(var,n_steps,beg_time,time);
+  end_brown = Rnorm(state[n_steps-1],SQRT((time[n_steps-1] - end_time)*var));
 
+  For(i,n_steps)
+    {
+      state[i] = state[i] - (time[i]/end_time) * end_brown;
+      state[i] = start + (end - start)/end_time * time[i] + state[i];
+    }
 
+  
+  return(state);
+}
 
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
 
+phydbl *Brownian_Generate(phydbl var, int n_steps, phydbl beg_time, phydbl *time)
+{
+  phydbl *state;
+  int i;
+
+  if(n_steps == 0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+
+  state = (phydbl *)mCalloc(n_steps,sizeof(phydbl));
+
+  state[0] = Rnorm(0.0,SQRT((time[0] - beg_time)*var));
+
+  for(i=1;i<n_steps;i++)
+    {
+      state[i] = Rnorm(state[i-1],SQRT((time[i]-time[i-1])*var));
+      if(time[i] < time[i-1]) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+    }
+
+  return(state);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl *Random_Walk_Bridged_Generate(phydbl start, phydbl end, phydbl var, int n_steps)
+{
+  phydbl *state,end_walk;
+  int i;
+
+  if(n_steps == 0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+
+  state = Random_Walk_Generate(var,n_steps);
+  end_walk = Rnorm(state[n_steps-1],SQRT(var));
+
+  For(i,n_steps)
+    {
+      state[i] = state[i] - ((phydbl)(i+1.)/n_steps) * end_walk;
+      state[i] = start + (end - start)/n_steps * (i+1.) + state[i];
+    }
+  
+  return(state);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl *Random_Walk_Generate(phydbl var, int n_steps)
+{
+  phydbl *state;
+  int i;
+
+  if(n_steps == 0) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+
+  state = (phydbl *)mCalloc(n_steps,sizeof(phydbl));
+
+  state[0] = Rnorm(0.0,SQRT(var));
+
+  for(i=1;i<n_steps;i++) state[i] = Rnorm(state[i-1],SQRT(var));
+
+  return(state);
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl Reflected(phydbl x, phydbl down, phydbl up)
+{
+  phydbl ref;
+  
+  ref = x;
+  do
+    {
+      if(ref > up)   ref = up   - (ref  -  up);
+      if(ref < down) ref = down + (down - ref);
+    }while(!(ref < up && ref > down));
+
+  return(ref);
+}
diff --git a/src/stats.h b/src/stats.h
index ef572be..472fbde 100644
--- a/src/stats.h
+++ b/src/stats.h
@@ -50,6 +50,7 @@ phydbl Dgamma_Moments(phydbl x, phydbl mean, phydbl var);
 phydbl Dgamma(phydbl x, phydbl shape, phydbl scale);
 phydbl LnFact(int n);
 int    Choose(int n, int k);
+phydbl LnChoose(int n, int k);
 phydbl Ppois(phydbl x, phydbl param);
 phydbl Dexp(phydbl x, phydbl param);
 phydbl Dpois(phydbl x, phydbl param, int logit);
@@ -110,5 +111,29 @@ void Random_String(char *s, int len);
 int *Random_Permut(int n);
 phydbl Dexp_Trunc(phydbl x, phydbl lambda, phydbl left, phydbl rght);
 phydbl Rexp_Trunc(phydbl lambda, phydbl left, phydbl rght);
+t_poly *Rpoly(int n);
+phydbl Area_Of_Poly_Monte_Carlo(t_poly **poly, int n_poly, t_geo_coord *lim);
+int Is_In_Polygon(t_geo_coord *point, t_poly *poly);
+phydbl Variance(phydbl *x, int l);
+phydbl Bessi0(phydbl x);
+phydbl Bessk0(phydbl x);
+phydbl Euclidean_Dist(t_geo_coord *x, t_geo_coord *y);
+int *Ranks(phydbl *x, int len);
+phydbl Rpois(phydbl mmu);
+phydbl Rgeom(phydbl p);
+phydbl Dgeom(phydbl k, phydbl p, int logit);
+phydbl Pgeom(phydbl k, phydbl p);
+phydbl *Brownian_Bridge_Generate(phydbl start, phydbl end, phydbl var, phydbl beg_time, phydbl end_time, int n_steps, phydbl *time);
+phydbl *Brownian_Generate(phydbl var, int n_steps, phydbl beg_time, phydbl *time);
+phydbl Brownian_Bridge_Logdensity(phydbl start, phydbl end, phydbl *state, phydbl var, phydbl end_time, int n_steps, phydbl *time);
+phydbl Reflected(phydbl x, phydbl down, phydbl up);
+phydbl *Random_Walk_Generate(phydbl var, int n_steps);
+phydbl *Random_Walk_Bridged_Generate(phydbl start, phydbl end, phydbl var, int n_steps);
+phydbl Dnbinom(phydbl x, phydbl n, phydbl p, int logit);
+phydbl Rnbinom(phydbl n, phydbl p);
+
+
+
+
 
 #endif
diff --git a/src/times.c b/src/times.c
index ef8de2b..b6ce7b4 100644
--- a/src/times.c
+++ b/src/times.c
@@ -792,7 +792,7 @@ phydbl TIMES_Lk_Yule_Joint(t_tree *tree)
 
   t = tree->rates->nd_t;
   ts = tree->rates->time_slice_lims;
-  tr = tree->rates->t_ranked;
+  tr = tree->rates->t_rank;
   lbda = tree->rates->birth_rate;
 
   TIMES_Update_Node_Ordering(tree);
@@ -803,7 +803,7 @@ phydbl TIMES_Lk_Yule_Joint(t_tree *tree)
 
   sumdt = .0;
   n = 1;
-  For(i,2*tree->n_otu-2) // t[tr[0]] is the oldest node, t[tr[1]], the second oldest and so on...
+  For(i,2*tree->n_otu-2) // t[tr[0]] is the time of the oldest node, t[tr[1]], the second oldest and so on...
     {
 
       For(j,tree->n_otu)
@@ -821,8 +821,8 @@ phydbl TIMES_Lk_Yule_Joint(t_tree *tree)
 
       if(n<1)
 	{
-	  PhyML_Printf("\n. i=%d tr[i]=%f",i,t[tr[i]]);
-	  PhyML_Printf("\n. Err in file %s at line %d\n",__FILE__,__LINE__);
+	  PhyML_Printf("\n== i=%d tr[i]=%f",i,t[tr[i]]);
+	  PhyML_Printf("\n== Err. in file %s at line %d\n",__FILE__,__LINE__);
 	  Exit("\n");
 	}
 
@@ -965,7 +965,7 @@ phydbl TIMES_Lk_Times(t_tree *tree)
   
   #ifdef PHYTIME
   tree->rates->c_lnL_times =  TIMES_Lk_Yule_Order(tree);
-  #elif SERGEII
+  #elif INVITEE
   /* tree->rates->c_lnL_times = TIMES_Calib_Cond_Prob(tree); */
   /* tree->rates->c_lnL_times =  TIMES_Lk_Yule_Order(tree); */
 
@@ -1435,12 +1435,12 @@ void TIMES_Update_Node_Ordering(t_tree *tree)
       swap = NO;
       For(i,2*tree->n_otu-2)
 	{
-	  if(t[tree->rates->t_ranked[i]] > t[tree->rates->t_ranked[i+1]]) // Sort in ascending order
+	  if(t[tree->rates->t_rank[i]] > t[tree->rates->t_rank[i+1]]) // Sort in ascending order
 	    {
 	      swap = YES;
-	      buff                       = tree->rates->t_ranked[i];
-	      tree->rates->t_ranked[i]   = tree->rates->t_ranked[i+1];
-	      tree->rates->t_ranked[i+1] = buff;
+	      buff                       = tree->rates->t_rank[i];
+	      tree->rates->t_rank[i]   = tree->rates->t_rank[i+1];
+	      tree->rates->t_rank[i+1] = buff;
 	    }	    
 	}
     }
@@ -1448,7 +1448,7 @@ void TIMES_Update_Node_Ordering(t_tree *tree)
 
   /* For(i,2*tree->n_otu-1) */
   /*   { */
-  /*     printf("\n. ..... %f",t[tree->rates->t_ranked[i]]); */
+  /*     printf("\n. ..... %f",t[tree->rates->t_rank[i]]); */
   /*   } */
 }
 
@@ -1532,7 +1532,6 @@ void TIMES_Record_Prior_Times(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void TIMES_Reset_Prior_Times(t_tree *tree)
 {
   int i;
@@ -1631,4 +1630,6 @@ phydbl TIMES_Lk_Yule_Order_Root_Cond(t_tree *tree)
   return(loglk);
 }
 
+//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
 
diff --git a/src/utilities.c b/src/utilities.c
index 379e57c..7ea9267 100644
--- a/src/utilities.c
+++ b/src/utilities.c
@@ -73,7 +73,7 @@ void Unroot_Tree(char **subtrees)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void Make_Edge_Dirs(t_edge *b, t_node *a, t_node *d, t_tree *tree)
+void Set_Edge_Dirs(t_edge *b, t_node *a, t_node *d, t_tree *tree)
 {
   int i;
 
@@ -327,6 +327,8 @@ calign *Compact_Data(align **data, option *io)
 
   cdata_tmp->obs_pinvar = (phydbl)n_invar/data[0]->len;
 
+  cdata_tmp->io = io;
+
   n_sites = 0;
   For(i,cdata_tmp->crunch_len) n_sites += cdata_tmp->wght[i];
   if(n_sites != data[0]->len / io->state_len) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
@@ -459,33 +461,31 @@ calign *Compact_Cdata(calign *data, option *io)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Traverse_Prefix_Tree(int site, int seqnum, int *patt_num, int *n_patt, align **data, option *io, pnode *n)
 {
   if(seqnum == io->n_otu-1)
     {
       n->weight++;
       if(n->weight == 1)
-    {
-      n->num = *n_patt;
-      (*n_patt) += 1;
-    }
+        {
+          n->num = *n_patt;
+          (*n_patt) += 1;
+        }
       (*patt_num) = n->num;
       return;
     }
   else
     {
       int next_state;
-
+      
       next_state = -1;
       next_state = Assign_State_With_Ambiguity(data[seqnum+1]->state+site,
-                           io->datatype,
-                           io->state_len);
-
+                                               io->datatype,
+                                               io->state_len);
+      
       if(!n->next[next_state]) n->next[next_state] = Create_Pnode(T_MAX_ALPHABET);
       Traverse_Prefix_Tree(site,seqnum+1,patt_num,n_patt,data,io,n->next[next_state]);
     }
-
 }
 
 //////////////////////////////////////////////////////////////
@@ -578,7 +578,7 @@ void Get_Base_Freqs(calign *data)
   data->b_frq[0] = fA;
   data->b_frq[1] = fC;
   data->b_frq[2] = fG;
-  data->b_frq[3] = fT;
+  data->b_frq[3] = fT;  
 }
 
 //////////////////////////////////////////////////////////////
@@ -720,8 +720,46 @@ void Swap_Nodes_On_Edges(t_edge *e1, t_edge *e2, int swap, t_tree *tree)
   Connect_One_Edge_To_Two_Nodes(e2->left,e2->rght,e2,tree);
 }
 
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* As opposed to Connect_Edges_To_Nodes_Recur, the ordering of 
+   edges connected to tips changes does not depend on the topology
+*/
+void Connect_Edges_To_Nodes_Serial(t_tree *tree)
+{
+  int i,j;
+
+  /* Reset */
+  For(i,2*tree->n_otu-1) For(j,3) tree->a_nodes[i]->b[j] = NULL;
+
+  tree->num_curr_branch_available = 0;
+  
+  For(i,tree->n_otu)
+    {
+      if(!tree->a_nodes[i]->tax) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+
+      Connect_One_Edge_To_Two_Nodes(tree->a_nodes[i],
+                                    tree->a_nodes[i]->v[0],
+                                    tree->a_edges[tree->num_curr_branch_available],
+                                    tree);
+      if(tree->n_otu == 2) break;
+    }
+
+  for(i=tree->n_otu;i<2*tree->n_otu-2;i++)
+    {
+      if(tree->a_nodes[i] == tree->n_root) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+
+      For(j,3) 
+        if(!tree->a_nodes[i]->b[j])
+          Connect_One_Edge_To_Two_Nodes(tree->a_nodes[i],
+                                        tree->a_nodes[i]->v[j],
+                                        tree->a_edges[tree->num_curr_branch_available],
+                                        tree);
+    }
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
 
 void Connect_Edges_To_Nodes_Recur(t_node *a, t_node *d, t_tree *tree)
 {
@@ -730,7 +768,10 @@ void Connect_Edges_To_Nodes_Recur(t_node *a, t_node *d, t_tree *tree)
   Connect_One_Edge_To_Two_Nodes(a,d,tree->a_edges[tree->num_curr_branch_available],tree);
 
   if(d->tax) return;
-  else For(i,3) if(d->v[i] != a) Connect_Edges_To_Nodes_Recur(d,d->v[i],tree);
+  else 
+    For(i,3) 
+      if(d->v[i] != a) /* Don't add d->b[i] != tree->e_root condition here since tree is not wired yet... */ 
+        Connect_Edges_To_Nodes_Recur(d,d->v[i],tree);
 }
 
 //////////////////////////////////////////////////////////////
@@ -739,18 +780,15 @@ void Connect_Edges_To_Nodes_Recur(t_node *a, t_node *d, t_tree *tree)
 void Connect_One_Edge_To_Two_Nodes(t_node *a, t_node *d, t_edge *b, t_tree *tree)
 {
   int i,dir_a_d,dir_d_a;
-
+    
   dir_a_d = -1;
   For(i,3) if(a->v[i] == d) {dir_a_d = i; break;}
 
   dir_d_a = -1;
   For(i,3) if(d->v[i] == a) {dir_d_a = i; break;}
 
-  if(dir_a_d == -1 || dir_d_a == -1)
-    {
-      PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
-      Warn_And_Exit("");
-    }
+  if(dir_a_d == -1) Generic_Exit(__FILE__,__LINE__,__FUNCTION__); 
+  if(dir_d_a == -1) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
 
   a->b[dir_a_d] = b;
   d->b[dir_d_a] = b;
@@ -763,8 +801,8 @@ void Connect_One_Edge_To_Two_Nodes(t_node *a, t_node *d, t_edge *b, t_tree *tree
   tree->num_curr_branch_available += 1;
 
   (b->left == a)?
-    (Make_Edge_Dirs(b,a,d,tree)):
-    (Make_Edge_Dirs(b,d,a,tree));
+    (Set_Edge_Dirs(b,a,d,tree)):
+    (Set_Edge_Dirs(b,d,a,tree));
 
   b->l->v                    = a->l[b->l_r];
   if(a->tax) b->l->v         = a->l[b->r_l];
@@ -799,7 +837,6 @@ void Update_Dirs(t_tree *tree)
           b->r_v2 = buff;
         }
     }
-
 }
 
 //////////////////////////////////////////////////////////////
@@ -822,11 +859,9 @@ void *mCalloc(int nb, size_t size)
 
   if((allocated = calloc((size_t)nb,size)) != NULL)
 /*   if((allocated = malloc((size_t)nb*(size_t)size)) != NULL) */
-    {
-      return allocated;
-    }
+    return allocated;
   else
-    Exit("\n== Err: low memory\n");
+    Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
 
   return NULL;
 }
@@ -912,48 +947,46 @@ void Qksort_Int(int *A, int *B, int ilo, int ihi)
 
         if(B)
           {
-        tempEntry = B[ulo];
-        B[ulo]    = B[uhi];
-        B[uhi]    = tempEntry;
+            tempEntry = B[ulo];
+            B[ulo]    = B[uhi];
+            B[uhi]    = tempEntry;
           }
-
-
-
+        
         // After the swap, A[ulo] <= pivot.
-        if (A[ulo] < pivot) {
-        // Swap entries at indices ieq and ulo.
-        tempEntry = A[ieq];
-        A[ieq] = A[ulo];
-        A[ulo] = tempEntry;
-
-
-        if(B)
+        if (A[ulo] < pivot) 
           {
-            tempEntry = B[ieq];
-            B[ieq] = B[ulo];
-            B[ulo] = tempEntry;
-          }
-
+            // Swap entries at indices ieq and ulo.
+            tempEntry = A[ieq];
+            A[ieq] = A[ulo];
+            A[ulo] = tempEntry;
+            
 
-        // After the swap, A[ieq] < pivot, so we need to change
-        // ieq.
-        ieq++;
-        // We also need to change ulo, but we also need to do
-        // that when A[ulo] = pivot, so we do it after this if
-        // statement.
-        }
+            if(B)
+              {
+                tempEntry = B[ieq];
+                B[ieq] = B[ulo];
+                B[ulo] = tempEntry;
+              }
+            
+            
+            // After the swap, A[ieq] < pivot, so we need to change
+            // ieq.
+            ieq++;
+            // We also need to change ulo, but we also need to do
+            // that when A[ulo] = pivot, so we do it after this if
+            // statement.
+          }
         // Once again, we can reduce the size of the unpartitioned
         // region and try again.
         ulo++;
-    }
+      }
     }
     // Now, all entries from index ilo to ieq - 1 are less than the pivot
     // and all entries from index uhi to ihi + 1 are greater than the
     // pivot.  So we have two regions of the array that can be sorted
     // recursively to put all of the entries in order.
     Qksort_Int(A, B, ilo, ieq - 1);
-    Qksort_Int(A, B, uhi + 1, ihi);
-
+    Qksort_Int(A, B, uhi + 1, ihi);    
 }
 
 //////////////////////////////////////////////////////////////
@@ -1938,12 +1971,6 @@ void Update_SubTree_Partial_Lk(t_edge *b_fcus, t_node *a, t_node *d, t_tree *tre
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
-
 void Copy_Seq_Names_To_Tip_Labels(t_tree *tree, calign *data)
 {
   int i;
@@ -2010,7 +2037,7 @@ calign *Copy_Cseq(calign *ori, option *io)
   new->clean_len          = ori->clean_len;
   new->crunch_len         = ori->crunch_len;
   new->n_otu              = ori->n_otu;
-
+  new->io                 = ori->io;
 
   For(i,n_otu) Free(sp_names[i]);
   Free(sp_names);
@@ -2542,7 +2569,6 @@ int Assign_State(char *c, int datatype, int stepsize)
 
 char Reciproc_Assign_State(int i_state, int datatype)
 {
-
   if(datatype == NT)
     {
       i_state = i_state%4;
@@ -2614,88 +2640,88 @@ int Assign_State_With_Ambiguity(char *c, int datatype, int stepsize)
   if(datatype == NT)
     {
       For(i,stepsize)
-    {
-      switch(c[i])
-        {
-        case 'A' : {state[i]= 0;  break;}
-        case 'C' : {state[i]= 1;  break;}
-        case 'G' : {state[i]= 2;  break;}
-        case 'T' : {state[i]= 3;  break;}
-        case 'U' : {state[i]= 3;  break;}
-        case 'M' : {state[i]= 4;  break;}
-        case 'R' : {state[i]= 5;  break;}
-        case 'W' : {state[i]= 6;  break;}
-        case 'S' : {state[i]= 7;  break;}
-        case 'Y' : {state[i]= 8;  break;}
-        case 'K' : {state[i]= 9;  break;}
-        case 'B' : {state[i]=10;  break;}
-        case 'D' : {state[i]=11;  break;}
-        case 'H' : {state[i]=12;  break;}
-        case 'V' : {state[i]=13;  break;}
-        case 'N' : case 'X' : case '?' : case 'O' : case '-' : {state[i]=T_MAX_ALPHABET-1;  break;}
-        default :
-          {
-        PhyML_Printf("\n. Unknown character state : '%c'\n",c[i]);
-        Warn_And_Exit("\n. Init failed (data type supposed to be DNA)\n");
-        break;
-          }
+        {
+          switch(c[i])
+            {
+            case 'A' : {state[i]= 0;  break;}
+            case 'C' : {state[i]= 1;  break;}
+            case 'G' : {state[i]= 2;  break;}
+            case 'T' : {state[i]= 3;  break;}
+            case 'U' : {state[i]= 3;  break;}
+            case 'M' : {state[i]= 4;  break;}
+            case 'R' : {state[i]= 5;  break;}
+            case 'W' : {state[i]= 6;  break;}
+            case 'S' : {state[i]= 7;  break;}
+            case 'Y' : {state[i]= 8;  break;}
+            case 'K' : {state[i]= 9;  break;}
+            case 'B' : {state[i]=10;  break;}
+            case 'D' : {state[i]=11;  break;}
+            case 'H' : {state[i]=12;  break;}
+            case 'V' : {state[i]=13;  break;}
+            case 'N' : case 'X' : case '?' : case 'O' : case '-' : {state[i]=T_MAX_ALPHABET-1;  break;}
+            default :
+              {
+                PhyML_Printf("\n== Unknown character state : '%c'\n",c[i]);
+                Warn_And_Exit("\n== Init failed (data type supposed to be DNA)\n");
+                break;
+              }
+            }
+          return (stepsize>1)?(state[0]*16+state[1]*4+state[2]):(state[0]);
         }
-      return (stepsize>1)?(state[0]*16+state[1]*4+state[2]):(state[0]);
-    }
     }
   else if(datatype == AA)
     {
       switch(c[0])
-    {
-    case 'A' : {state[0]= 0; break;}
-    case 'R' : {state[0]= 1; break;}
-    case 'N' : {state[0]= 2; break;}
-    case 'D' : {state[0]= 3; break;}
-    case 'C' : {state[0]= 4; break;}
-    case 'Q' : {state[0]= 5; break;}
-    case 'E' : {state[0]= 6; break;}
-    case 'G' : {state[0]= 7; break;}
-    case 'H' : {state[0]= 8; break;}
-    case 'I' : {state[0]= 9; break;}
-    case 'L' : {state[0]=10; break;}
-    case 'K' : {state[0]=11; break;}
-    case 'M' : {state[0]=12; break;}
-    case 'F' : {state[0]=13; break;}
-    case 'P' : {state[0]=14; break;}
-    case 'S' : {state[0]=15; break;}
-    case 'T' : {state[0]=16; break;}
-    case 'W' : {state[0]=17; break;}
-    case 'Y' : {state[0]=18; break;}
-    case 'V' : {state[0]=19; break;}
-    case 'B' : {state[0]= 2; break;}
-    case 'Z' : {state[0]= 5; break;}
-    case 'X' : case '?' : case '-' : {state[0]=T_MAX_ALPHABET-1; break;}
-    default  :
-      {
-        PhyML_Printf("\n. Unknown character state : %c\n",state[0]);
-        Warn_And_Exit("\n. Init failed (data type supposed to be amino-acids)\n");
-        break;
-      }
-    }
+        {
+        case 'A' : {state[0]= 0; break;}
+        case 'R' : {state[0]= 1; break;}
+        case 'N' : {state[0]= 2; break;}
+        case 'D' : {state[0]= 3; break;}
+        case 'C' : {state[0]= 4; break;}
+        case 'Q' : {state[0]= 5; break;}
+        case 'E' : {state[0]= 6; break;}
+        case 'G' : {state[0]= 7; break;}
+        case 'H' : {state[0]= 8; break;}
+        case 'I' : {state[0]= 9; break;}
+        case 'L' : {state[0]=10; break;}
+        case 'K' : {state[0]=11; break;}
+        case 'M' : {state[0]=12; break;}
+        case 'F' : {state[0]=13; break;}
+        case 'P' : {state[0]=14; break;}
+        case 'S' : {state[0]=15; break;}
+        case 'T' : {state[0]=16; break;}
+        case 'W' : {state[0]=17; break;}
+        case 'Y' : {state[0]=18; break;}
+        case 'V' : {state[0]=19; break;}
+        case 'B' : {state[0]= 2; break;}
+        case 'Z' : {state[0]= 5; break;}
+        case 'X' : case '?' : case '-' : {state[0]=T_MAX_ALPHABET-1; break;}
+        default  :
+          {
+            PhyML_Printf("\n== Unknown character state : %c\n",state[0]);
+            Warn_And_Exit("\n== Init failed (data type supposed to be amino-acids)\n");
+            break;
+          }
+        }
       return state[0];
     }
   else if(datatype == GENERIC)
     {
       if(Is_Ambigu(c,GENERIC,stepsize)) state[0] = T_MAX_ALPHABET-1;
       else
-    {
-      char format[6];
-      sprintf(format,"%%%dd",stepsize);
-      if(!sscanf(c,format,state))
         {
-          PhyML_Printf("\n== Error reading character. Was expecting an integer, got '%c' instead.\n",c[0]);
-          PhyML_Printf("\n== Err in file %s at line %d (function '%s')\n",__FILE__,__LINE__,__FUNCTION__);
-          Warn_And_Exit("");
+          char format[6];
+          sprintf(format,"%%%dd",stepsize);
+          if(!sscanf(c,format,state))
+            {
+              PhyML_Printf("\n== Error reading character. Was expecting an integer, got '%c' instead.\n",c[0]);
+              PhyML_Printf("\n== Err. in file %s at line %d (function '%s')\n",__FILE__,__LINE__,__FUNCTION__);
+              Warn_And_Exit("");
+            }
         }
-    }
       return state[0];
     }
-
+  
   return -1;
 }
 
@@ -2823,7 +2849,7 @@ void Bootstrap(t_tree *tree)
 
       if((boot_tree->mod->s_opt->random_input_tree) && (boot_tree->mod->s_opt->topo_search == SPR_MOVE)) Random_Tree(boot_tree);
 
-      Connect_CSeqs_To_Nodes(boot_data,boot_tree);
+      Connect_CSeqs_To_Nodes(boot_data,tree->io,boot_tree);
 
       Check_Br_Lens(boot_tree);
       Share_Lk_Struct(tree,boot_tree);
@@ -2838,7 +2864,6 @@ void Bootstrap(t_tree *tree)
       Init_P_Pars_Tips(boot_tree);
       Br_Len_Not_Involving_Invar(boot_tree);
 
-
       if(boot_tree->io->do_alias_subpatt)
         {
           MIXT_Set_Alias_Subpatt(YES,boot_tree);
@@ -2970,8 +2995,8 @@ void Getstring_Stdin(char *s)
 //////////////////////////////////////////////////////////////
 
 phydbl Num_Derivatives_One_Param(phydbl (*func)(t_tree *tree), t_tree *tree,
-                 phydbl f0, phydbl *param, int which, int n_param, phydbl stepsize, int logt,
-                 phydbl *err, int precise, int is_positive)
+                                 phydbl f0, phydbl *param, int which, int n_param, phydbl stepsize, int logt,
+                                 phydbl *err, int precise, int is_positive)
 {
   int i,j;
   phydbl errt,fac,hh,**a,ans,*sign;
@@ -3030,56 +3055,56 @@ phydbl Num_Derivatives_One_Param(phydbl (*func)(t_tree *tree), t_tree *tree,
 
       *err=1e30;
       for(i=1;i<n_iter;i++)
-    {
-      hh /= 1.4;
-
-      /*       param[which]   = param[which]+hh; */
-      /*       a[0][i]  = (*func)(tree); */
-      /*       param[which]   = param[which]-2*hh; */
-      /*       a[0][i] -= (*func)(tree); */
-      /*       a[0][i] /= (2.0*hh); */
-      /*       param[which]   = param[which]+hh; */
-
-      param[which]   = param[which]+hh;
-
+        {
+          hh /= 1.4;
+          
+          /*       param[which]   = param[which]+hh; */
+          /*       a[0][i]  = (*func)(tree); */
+          /*       param[which]   = param[which]-2*hh; */
+          /*       a[0][i] -= (*func)(tree); */
+          /*       a[0][i] /= (2.0*hh); */
+          /*       param[which]   = param[which]+hh; */
+          
+          param[which]   = param[which]+hh;
+          
           if(logt == YES) For(j,n_param) param[j] = EXP(MIN(1.E+2,param[j]));
           For(i,n_param) sign[i] = param[i] > .0 ? 1. : -1.;
           if(is_positive == YES) For(i,n_param) param[i] = FABS(param[i]);
-      a[0][i]  = (*func)(tree);
+          a[0][i]  = (*func)(tree);
           if(is_positive == YES) For(i,n_param) param[i] *= sign[i];
           if(logt == YES) For(j,n_param) param[j] = LOG(param[j]);
-
-      /*   param[which]   = param[which]-2*hh; */
-      /*   a[0][i] -= (*func)(tree); */
-      /*   a[0][i] /= (2.0*hh); */
-      /*   param[which]   = param[which]+hh; */
-      a[0][i]  -= f0;
-      a[0][i]  /= hh;
-      param[which]   = param[which]-hh;
-
-
-      fac=1.4*1.4;
-      for (j=1;j<=i;j++)
-        {
-          a[j][i]=(a[j-1][i]*fac-a[j-1][i-1])/(fac-1.0);
-          fac=1.4*1.4*fac;
-
-          errt=MAX(FABS(a[j][i]-a[j-1][i]),FABS(a[j][i]-a[j-1][i-1]));
-
-          if (errt <= *err)
-        {
-          *err=errt;
-          ans=a[j][i];
-        }
+          
+          /*   param[which]   = param[which]-2*hh; */
+          /*   a[0][i] -= (*func)(tree); */
+          /*   a[0][i] /= (2.0*hh); */
+          /*   param[which]   = param[which]+hh; */
+          a[0][i]  -= f0;
+          a[0][i]  /= hh;
+          param[which]   = param[which]-hh;
+          
+          
+          fac=1.4*1.4;
+          for (j=1;j<=i;j++)
+            {
+              a[j][i]=(a[j-1][i]*fac-a[j-1][i-1])/(fac-1.0);
+              fac=1.4*1.4*fac;
+              
+              errt=MAX(FABS(a[j][i]-a[j-1][i]),FABS(a[j][i]-a[j-1][i-1]));
+              
+              if (errt <= *err)
+                {
+                  *err=errt;
+                  ans=a[j][i];
+                }
+            }
+          
+          if(FABS(a[i][i]-a[i-1][i-1]) >= 2.0*(*err)) break;
         }
-
-      if(FABS(a[i][i]-a[i-1][i-1]) >= 2.0*(*err)) break;
-    }
     }
   For(i,11) Free(a[i]);
   Free(a);
   Free(sign);
-
+  
   return ans;
 }
 
@@ -3219,20 +3244,21 @@ int Num_Derivative_Several_Param(t_tree *tree, phydbl *param, int n_param, phydb
 
   For(i,n_param)
     {
+      /* For(j,tree->mod->r_mat->n_diff_rr) PhyML_Printf("\n. 00%d %f",i,tree->mod->r_mat->rr_val->v[j]); */
       derivatives[i] = Num_Derivatives_One_Param(func,
-                         tree,
-                         f0,
-                         param,
+                                                 tree,
+                                                 f0,
+                                                 param,
                                                  i,
                                                  n_param,
-                         stepsize,
+                                                 stepsize,
                                                  logt,
-                         &err,
-                         0,
+                                                 &err,
+                                                 0,
                                                  is_positive
-                         );
+                                                 );
     }
-
+  
   Free(sign);
 
   return 1;
@@ -4156,7 +4182,7 @@ int Are_Compatible(char *statea, char *stateb, int stepsize, int datatype)
                   }
                 default :
                   {
-                    PhyML_Printf("\n== Err. in Are_Compatible\n");
+                    PhyML_Printf("\n== Err. in Are_Compatible.");
                     PhyML_Printf("\n== Please check that characters `%c` and `%c`",a,b);
                     PhyML_Printf("\n== correspond to existing nucleotides.\n");
                     Warn_And_Exit("\n");
@@ -4410,7 +4436,7 @@ int Are_Compatible(char *statea, char *stateb, int stepsize, int datatype)
           }
         default :
           {
-            PhyML_Printf("\n== Err. in Are_Compatible\n");
+            PhyML_Printf("\n== Err. in Are_Compatible.");
             PhyML_Printf("\n== Please check that characters `%c` and `%c`",a,b);
             PhyML_Printf("\n== correspond to existing amino-acids.\n");
             Warn_And_Exit("\n");
@@ -4829,8 +4855,8 @@ void Prune_Subtree(t_node *a, t_node *d, t_edge **target, t_edge **residual, t_t
     }
 
   (v1 == b1->left)?
-    (Make_Edge_Dirs(b1,v1,v2,tree)):
-    (Make_Edge_Dirs(b1,v2,v1,tree));
+    (Set_Edge_Dirs(b1,v1,v2,tree)):
+    (Set_Edge_Dirs(b1,v2,v1,tree));
 
   if(target)   (*target)   = b1;
   if(residual) (*residual) = b2;
@@ -5027,9 +5053,9 @@ void Graft_Subtree(t_edge *target, t_node *link, t_edge *residual, t_tree *tree)
   if(residual->l->onoff == ON)
     residual->l->v = target->l->v;
 
-  Make_Edge_Dirs(target,target->left,target->rght,tree);
-  Make_Edge_Dirs(residual,residual->left,residual->rght,tree);
-  Make_Edge_Dirs(b_up,b_up->left,b_up->rght,tree);
+  Set_Edge_Dirs(target,target->left,target->rght,tree);
+  Set_Edge_Dirs(residual,residual->left,residual->rght,tree);
+  Set_Edge_Dirs(b_up,b_up->left,b_up->rght,tree);
 
   /* if(tree->n_root) */
   /*   { */
@@ -6213,19 +6239,19 @@ void Check_Memory_Amount(t_tree *tree)
 
       char answer;
       if((!tree->io->quiet) && (tree->io->mem_question == YES))
-    {
-      PhyML_Printf("\n. Do you really want to proceed? [Y/n] ");
-      if(scanf("%c", &answer))
-        {
-          if(answer == '\n') answer = 'Y';
-          else if(answer == 'n' || answer == 'N') Warn_And_Exit("\n");
-          else getchar();
-        }
-      else
         {
-          Warn_And_Exit("\n\n");
+          PhyML_Printf("\n. Do you really want to proceed? [Y/n] ");
+          if(scanf("%c", &answer))
+            {
+              if(answer == '\n') answer = 'Y';
+              else if(answer == 'n' || answer == 'N') Warn_And_Exit("\n");
+              else getchar();
+            }
+          else
+            {
+              Warn_And_Exit("\n\n");
+            }
         }
-    }
 #endif
     }
   else if(((phydbl)nbytes/(1.E+06)) > 100.)
@@ -6374,7 +6400,6 @@ void Update_Root_Pos(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Add_Root(t_edge *target, t_tree *tree)
 {
   t_edge *b1, *b2;
@@ -6410,7 +6435,7 @@ void Add_Root(t_edge *target, t_tree *tree)
   if(tree->n_root_pos > -1.0)
     {
       if(tree->n_root_pos < 1.E-6 &&  tree->n_root_pos > -1.E-6)
-    printf("\n. WARNING: you put the root at a weird position...");
+        printf("\n. WARNING: you put the root at a weird position...");
 
 /*       tree->n_root->l[0] = tree->e_root->l->v * (tree->n_root_pos/(1.+tree->n_root_pos)); */
 /*       tree->n_root->l[1] = tree->e_root->l->v - tree->n_root->l[0]; */
@@ -6503,18 +6528,20 @@ void Add_Root(t_edge *target, t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Update_Ancestors(t_node *a, t_node *d, t_tree *tree)
 {
+
   if(a == tree->n_root) a->anc = NULL;
+
   d->anc = a;
+
   if(d->tax) return;
   else
     {
       int i;
       For(i,3)
-    if((d->v[i] != d->anc) && (d->b[i] != tree->e_root))
-      Update_Ancestors(d,d->v[i],tree);
+        if((d->v[i] != a) && (d->b[i] != tree->e_root))
+          Update_Ancestors(d,d->v[i],tree);
     }
 }
 
@@ -6522,7 +6549,7 @@ void Update_Ancestors(t_node *a, t_node *d, t_tree *tree)
 //////////////////////////////////////////////////////////////
 
 /* Generate a random unrooted tree with 'n_otu' OTUs */
-#if (defined PHYTIME || defined SERGEII)
+#if (defined PHYTIME || defined INVITEE)
 t_tree *Generate_Random_Tree_From_Scratch(int n_otu, int rooted)
 {
   t_tree *tree;
@@ -6691,28 +6718,28 @@ t_tree *Generate_Random_Tree_From_Scratch(int n_otu, int rooted)
   Fill_Dir_Table(tree);
   Update_Dirs(tree);
 
-
+  
   /* Add root */
   if(rooted)
     {
       For(i,2*tree->n_otu-3)
-    {
-      if(((tree->a_edges[i]->left == root->v[1]) || (tree->a_edges[i]->rght == root->v[1])) &&
-         ((tree->a_edges[i]->left == root->v[2]) || (tree->a_edges[i]->rght == root->v[2])))
         {
-          Add_Root(tree->a_edges[i],tree);
-          break;
+          if(((tree->a_edges[i]->left == root->v[1]) || (tree->a_edges[i]->rght == root->v[1])) &&
+             ((tree->a_edges[i]->left == root->v[2]) || (tree->a_edges[i]->rght == root->v[2])))
+            {
+              Add_Root(tree->a_edges[i],tree);
+              break;
+            }
         }
     }
-    }
   /* Or not... */
   else
     {
       Free_Node(root);
     }
-
+  
   RATES_Random_Branch_Lengths(tree);
-
+  
   Free(available_nodes);
   Free(connected);
   Free(nonconnected);
@@ -6810,16 +6837,15 @@ void Evolve(calign *data, t_mod *mod, t_tree *tree)
   phydbl *orig_l;
   /* phydbl shape,scale,var,mean; */
   int switch_to_yes;
-
-
+  
   orig_l = (phydbl *)mCalloc(2*tree->n_otu-3,sizeof(phydbl));
   For(i,2*tree->n_otu-3) orig_l[i] = tree->a_edges[i]->l->v;
 
   data->n_otu = tree->n_otu;
+  data->io    = tree->io;
 
   if(mod->use_m4mod) tree->write_labels = YES;
 
-
   Set_Br_Len_Var(tree);
 
   switch_to_yes = NO;
@@ -6829,14 +6855,16 @@ void Evolve(calign *data, t_mod *mod, t_tree *tree)
       /* tree->mod->gamma_mgf_bl = NO; */
     }
 
+
   For(site,data->init_len)
     {
+      Set_Model_Parameters(mod);
 
       /* Pick the rate class */
       root_state = root_rate_class = -1;
       root_rate_class = Pick_State(mod->ras->n_catg,mod->ras->gamma_r_proba->v);
 
-
+ 
       /* /\* Get the change probability matrices *\/ */
       /* For(i,2*tree->n_otu-3) */
       /*   { */
@@ -6850,33 +6878,29 @@ void Evolve(calign *data, t_mod *mod, t_tree *tree)
 
       /*   } */
 
-      Set_Model_Parameters(mod);
-
       For(i,2*tree->n_otu-3) Update_PMat_At_Given_Edge(tree->a_edges[i],tree);
 
-
       /* Pick the root nucleotide/aa */
       root_state = Pick_State(mod->ns,mod->e_frq->pi->v);
       data->c_seq[0]->state[site] = Reciproc_Assign_State(root_state,tree->io->datatype);
 
-
       /* tree->a_nodes[0] is considered as the root t_node */
       Evolve_Recur(tree->a_nodes[0],
-           tree->a_nodes[0]->v[0],
-           tree->a_nodes[0]->b[0],
-           root_state,
-           root_rate_class,
-           site,
-           data,
-           mod,
-           tree);
+                   tree->a_nodes[0]->v[0],
+                   tree->a_nodes[0]->b[0],
+                   root_state,
+                   root_rate_class,
+                   site,
+                   data,
+                   mod,
+                   tree);
 
 /*       PhyML_Printf("%s\n",Write_Tree(tree,NO)); */
 
       data->wght[site] = 1;
     }
   data->crunch_len = data->init_len;
-  Print_CSeq(stdout,NO,data);
+  /* Print_CSeq(stdout,NO,data); */
   For(i,2*tree->n_otu-3) tree->a_edges[i]->l->v = orig_l[i];
   Free(orig_l);
 
@@ -6940,68 +6964,67 @@ void Evolve_Recur(t_node *a, t_node *d, t_edge *b, int a_state, int r_class, int
     {
       int i;
       For(i,3)
-    if(d->v[i] != a)
-      Evolve_Recur(d,d->v[i],d->b[i],
-               d_state,r_class,site_num,gen_data,
-               mod,tree);
+        if(d->v[i] != a)
+          Evolve_Recur(d,d->v[i],d->b[i],
+                       d_state,r_class,site_num,gen_data,
+                       mod,tree);
     }
 }
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Site_Diversity(t_tree *tree)
 {
   int i,j,k,ns;
   int *div,sum;
-
+  
   ns = tree->mod->ns;
-
+  
   div = (int *)mCalloc(ns,sizeof(int));
-
+  
   Site_Diversity_Post(tree->a_nodes[0],tree->a_nodes[0]->v[0],tree->a_nodes[0]->b[0],tree);
   Site_Diversity_Pre (tree->a_nodes[0],tree->a_nodes[0]->v[0],tree->a_nodes[0]->b[0],tree);
-
+  
   For(i,2*tree->n_otu-3)
     {
       For(j,ns)
-    {
-      tree->a_edges[i]->div_post_pred_left[j] = 0;
-      tree->a_edges[i]->div_post_pred_rght[j] = 0;
-    }
+        {
+          tree->a_edges[i]->div_post_pred_left[j] = 0;
+          tree->a_edges[i]->div_post_pred_rght[j] = 0;
+        }
     }
-
+  
   For(i,tree->n_pattern)
     {
       For(j,2*tree->n_otu-3)
-    {
-      Binary_Decomposition(tree->a_edges[j]->ui_l[i],div,ns);
-      sum = 0;
-      For(k,ns) sum += div[k];
-      tree->a_edges[j]->div_post_pred_left[sum-1] += tree->data->wght[i];
-
-      Binary_Decomposition(tree->a_edges[j]->ui_r[i],div,ns);
-      sum = 0;
-      For(k,ns) sum += div[k];
-      tree->a_edges[j]->div_post_pred_rght[sum-1] += tree->data->wght[i];
-    }
+        {
+          Binary_Decomposition(tree->a_edges[j]->ui_l[i],div,ns);
+          sum = 0;
+          For(k,ns) sum += div[k];
+          tree->a_edges[j]->div_post_pred_left[sum-1] += tree->data->wght[i];
+          
+          Binary_Decomposition(tree->a_edges[j]->ui_r[i],div,ns);
+          sum = 0;
+          For(k,ns) sum += div[k];
+          tree->a_edges[j]->div_post_pred_rght[sum-1] += tree->data->wght[i];
+        }
     }
-
-/*   For(j,2*tree->n_otu-3) */
-/*     { */
-/*       PhyML_Printf("\n. Edge %4d   div_left = %4d %4d %4d %4d -- div_rght = %4d %4d %4d %4d", */
-/* 	     j, */
-/* 	     tree->a_edges[j]->div_post_pred_left[0], */
-/* 	     tree->a_edges[j]->div_post_pred_left[1], */
-/* 	     tree->a_edges[j]->div_post_pred_left[2], */
-/* 	     tree->a_edges[j]->div_post_pred_left[3], */
-/* 	     tree->a_edges[j]->div_post_pred_rght[0], */
-/* 	     tree->a_edges[j]->div_post_pred_rght[1], */
-/* 	     tree->a_edges[j]->div_post_pred_rght[2], */
-/* 	     tree->a_edges[j]->div_post_pred_rght[3]); */
-/*     } */
-
+  
+  /*   For(j,2*tree->n_otu-3) */
+  /*     { */
+  /*       PhyML_Printf("\n. Edge %4d   div_left = %4d %4d %4d %4d -- div_rght = %4d %4d %4d %4d", */
+  /* 	     j, */
+  /* 	     tree->a_edges[j]->div_post_pred_left[0], */
+  /* 	     tree->a_edges[j]->div_post_pred_left[1], */
+  /* 	     tree->a_edges[j]->div_post_pred_left[2], */
+  /* 	     tree->a_edges[j]->div_post_pred_left[3], */
+  /* 	     tree->a_edges[j]->div_post_pred_rght[0], */
+  /* 	     tree->a_edges[j]->div_post_pred_rght[1], */
+  /* 	     tree->a_edges[j]->div_post_pred_rght[2], */
+  /* 	     tree->a_edges[j]->div_post_pred_rght[3]); */
+  /*     } */
+  
   Free(div);
 }
 
@@ -7017,9 +7040,9 @@ void Site_Diversity_Post(t_node *a, t_node *d, t_edge *b, t_tree *tree)
       int i;
 
       For(i,3)
-    if(d->v[i] != a)
-      Site_Diversity_Post(d,d->v[i],d->b[i],tree);
-
+        if(d->v[i] != a)
+          Site_Diversity_Post(d,d->v[i],d->b[i],tree);
+      
       Subtree_Union(d,b,tree);
     }
 }
@@ -7112,14 +7135,14 @@ void Binary_Decomposition(int value, int *bit_vect, int size)
   for(i=size-1;i>=0;i--)
     {
       if(value - cumul < (int)POW(2,i))
-    {
-      bit_vect[i] = 0;
-    }
+        {
+          bit_vect[i] = 0;
+        }
       else
-    {
-      bit_vect[i] = 1;
-      cumul += (int)POW(2,i);
-    }
+        {
+          bit_vect[i] = 1;
+          cumul += (int)POW(2,i);
+        }
     }
 }
 
@@ -7129,7 +7152,7 @@ void Binary_Decomposition(int value, int *bit_vect, int size)
 
 void Print_Diversity_Header(FILE *fp, t_tree *tree)
 {
-/*   PhyML_Fprintf(fp,"t_edge side mean\n");  */
+  /*   PhyML_Fprintf(fp,"t_edge side mean\n");  */
   PhyML_Fprintf(fp,"t_edge side diversity count\n");
 }
 
@@ -7536,7 +7559,6 @@ t_tree *Dist_And_BioNJ(calign *cdata, t_mod *mod, option *io)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Add_BioNJ_Branch_Lengths(t_tree *tree, calign *cdata, t_mod *mod)
 {
   matrix *mat;
@@ -7544,7 +7566,7 @@ void Add_BioNJ_Branch_Lengths(t_tree *tree, calign *cdata, t_mod *mod)
   PhyML_Printf("\n");
   PhyML_Printf("\n. Computing branch length estimates...\n");
 
-  Connect_CSeqs_To_Nodes(cdata,tree);
+  Connect_CSeqs_To_Nodes(cdata,mod->io,tree);
   mat = ML_Dist(cdata,mod);
   mat->tree = tree;
   mat->method = 0;
@@ -7576,7 +7598,7 @@ char *Bootstrap_From_String(char *s_tree, calign *cdata, t_mod *mod, option *io)
   tree->data        = cdata;
   tree->n_pattern   = tree->data->crunch_len;
 
-  Connect_CSeqs_To_Nodes(cdata,tree);
+  Connect_CSeqs_To_Nodes(cdata,io,tree);
   if(tree->mod->s_opt->random_input_tree) Random_Tree(tree);
   Fill_Dir_Table(tree);
   Update_Dirs(tree);
@@ -7599,6 +7621,10 @@ char *Bootstrap_From_String(char *s_tree, calign *cdata, t_mod *mod, option *io)
 #endif
 
   Free(s_tree);
+
+  Rescale_Br_Len_Multiplier_Tree(tree);
+  Br_Len_Involving_Invar(tree);
+
   s_tree = Write_Tree(tree,NO);
 
   Free_Spr_List(tree);
@@ -7634,7 +7660,7 @@ char *aLRT_From_String(char *s_tree, calign *cdata, t_mod *mod, option *io)
   tree->data        = cdata;
   tree->n_pattern   = tree->data->crunch_len;
 
-  Connect_CSeqs_To_Nodes(cdata,tree);
+  Connect_CSeqs_To_Nodes(cdata,io,tree);
   if(tree->mod->s_opt->random_input_tree) Random_Tree(tree);
   Fill_Dir_Table(tree);
   Update_Dirs(tree);
@@ -7679,7 +7705,7 @@ char *aLRT_From_String(char *s_tree, calign *cdata, t_mod *mod, option *io)
 
 void Prepare_Tree_For_Lk(t_tree *tree)
 {
-  Connect_CSeqs_To_Nodes(tree->data,tree);
+  Connect_CSeqs_To_Nodes(tree->data,tree->io,tree);
   Fill_Dir_Table(tree);
   Update_Dirs(tree);
   Make_Tree_4_Pars(tree,tree->data,tree->data->init_len);
@@ -7809,6 +7835,8 @@ t_node *Find_Lca_Pair_Of_Nodes(t_node *n1, t_node *n2, t_tree *tree)
   t_node **list1, **list2, *lca;
   int size1, size2;
 
+  if(n1 == n2) return(n1);
+
   if(!tree->n_root)
     {
       PhyML_Printf("\n. The tree must be rooted in this function.");
@@ -7834,6 +7862,11 @@ t_node *Find_Lca_Pair_Of_Nodes(t_node *n1, t_node *n2, t_tree *tree)
   Free(list1);
   Free(list2);
 
+  if(lca == NULL)
+    {
+      PhyML_Printf("\n. %s",Write_Tree(tree,NO));
+      Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+    }
   return lca;
 }
 
@@ -7863,31 +7896,36 @@ t_node *Find_Lca_Clade(t_node **node_list, int node_list_size, t_tree *tree)
       if(!Get_List_Of_Ancestors(node_list[i],list[i],size+i,tree))
         {
           For(i,node_list_size) PhyML_Printf("\n== %s",node_list[i]->name);
-          PhyML_Printf("\n== Err in file %s at line %d\n",__FILE__,__LINE__);
-          Exit("\n");
+          Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    
         }
     }
-  do
-    {
-      For(i,node_list_size-1)
-    if(list[i][size[i]] != list[i+1][size[i+1]])
-      break;
-
-      if(i != node_list_size-1) break;
 
-      For(i,node_list_size)
+  if(node_list_size > 1)
+    {
+      do
+        {
+          For(i,node_list_size-1)
+            if(list[i][size[i]] != list[i+1][size[i+1]])
+              break;
+          
+          if(i != node_list_size-1) break;
+          
+          For(i,node_list_size)
+            {
+              size[i]--;
+              if(size[i] == 1) break; // We have reached the tip corresponding to node_list[i]
+            }
+          
+          if(node_list_size == 1) break;
+          
+        }while(1);
+      lca = list[0][size[0]+1];
+    }
+  else
     {
-      size[i]--;
-      if(size[i] == 1) break; // We have reached the tip corresponding to node_list[i]
+      lca = node_list[0];
     }
-
-      if(node_list_size == 1) break;
-
-    }while(1);
-
-
-  lca = list[0][size[0]+1];
-
+  
   For(i,node_list_size) Free(list[i]);
   Free(list);
   Free(size);
@@ -7902,17 +7940,17 @@ t_node *Find_Lca_Clade(t_node **node_list, int node_list_size, t_tree *tree)
 int Get_List_Of_Ancestors(t_node *ref_node, t_node **list, int *size, t_tree *tree)
 {
   t_node *n;
-
-  *size = 1;
+  
   n = ref_node;
-  list[0] = n;
+  list[0] = n;  
+  *size = 1;
 
   if(!n)
     {
       PhyML_Printf("\n== There seems to be a problem with the calibration file.\n");
       return 0;
     }
-
+  
   while(n != tree->n_root)
     {
       n = n->anc;
@@ -7921,8 +7959,8 @@ int Get_List_Of_Ancestors(t_node *ref_node, t_node **list, int *size, t_tree *tr
           PhyML_Printf("\n== n->anc has not been set properly (call Update_Ancestors first...)\n");
           return 0;
         }
-      *size = *size+1;
       list[*size] = n;
+      *size = *size+1;
     }
   return 1;
 }
@@ -7930,7 +7968,6 @@ int Get_List_Of_Ancestors(t_node *ref_node, t_node **list, int *size, t_tree *tr
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 int Edge_Num_To_Node_Num(int edge_num, t_tree *tree)
 {
   int node_num;
@@ -7953,13 +7990,11 @@ void Time_To_Branch(t_tree *tree)
   tree->n_root->l[1] = tree->rates->nd_t[tree->n_root->v[1]->num] - tree->rates->nd_t[tree->n_root->num];
   tree->n_root->l[2] = tree->rates->nd_t[tree->n_root->v[1]->num] - tree->rates->nd_t[tree->n_root->num];
   tree->e_root->l->v = tree->n_root->l[1] + tree->n_root->l[2];
-
 }
 
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
 void Time_To_Branch_Pre(t_node *a, t_node *d, t_tree *tree)
 {
   int i;
@@ -7971,8 +8006,8 @@ void Time_To_Branch_Pre(t_node *a, t_node *d, t_tree *tree)
   else
     {
       For(i,3)
-    if((d->v[i] != a) && (d->b[i] != tree->e_root))
-      Time_To_Branch_Pre(d,d->v[i],tree);
+        if((d->v[i] != a) && (d->b[i] != tree->e_root))
+          Time_To_Branch_Pre(d,d->v[i],tree);
     }
 }
 
@@ -8076,15 +8111,16 @@ int Find_Clade(char **tax_name_list, int list_size, t_tree *tree)
   For(i,list_size)
     {
       For(j,tree->n_otu)
-    {
-      if(!strcmp(tax_name_list[i],tree->a_nodes[j]->name))
         {
-          tax_num_list[i] = tree->a_nodes[j]->num;
-          tax_node_list[i] = tree->a_nodes[j];
-          n_matches++;
+          if(!strcmp(tax_name_list[i],tree->a_nodes[j]->name))
+            {
+              tax_num_list[i] = tree->a_nodes[j]->num;
+              tax_node_list[i] = tree->a_nodes[j];
+              n_matches++;
               break;
+            }
         }
-    }
+      
       if(j == tree->n_otu)
         {
           PhyML_Printf("\n== Problem with the calibration file.");
@@ -8419,6 +8455,11 @@ void Set_Model_Name(t_mod *mod)
     strcpy(mod->modelname->s, "HIVb");
     break;
       }
+    case AB:
+      {
+    strcpy(mod->modelname->s, "AB");
+    break;
+      }
     case CUSTOMAA:
       {
     strcpy(mod->modelname->s, "Custom");
@@ -8540,6 +8581,11 @@ void Get_Best_Root_Position(t_tree *tree)
 
   if(has_outgrp == YES)
     {
+      Free_Edge_Lk_Rght(tree->a_edges[2*tree->n_otu-3]);
+      Free_Edge_Lk_Rght(tree->a_edges[2*tree->n_otu-2]);
+      Free_Edge_Pars_Rght(tree->a_edges[2*tree->n_otu-3]);
+      Free_Edge_Pars_Rght(tree->a_edges[2*tree->n_otu-2]);
+
       eps = 1.E-10;
       s = s_max = 0.0;
       For(i,2*tree->n_otu-2)
@@ -8554,8 +8600,7 @@ void Get_Best_Root_Position(t_tree *tree)
                   best_edge = tree->a_nodes[i]->b[j];
                 }
             }
-        }
-      
+        }      
       Add_Root(best_edge,tree);
     }
 }
@@ -8573,29 +8618,29 @@ void Get_Best_Root_Position_Post(t_node *a, t_node *d, int *has_outgrp, t_tree *
   if(d->tax)
     {
       if(strstr(d->name,"*"))
-    {
-      *has_outgrp = YES;
-      /* PhyML_Printf("\n. Found outgroup taxon: %s",d->name); */
-      d->s_ingrp[0]  = 0;
-      d->s_outgrp[0] = 1;
-    }
+        {
+          *has_outgrp = YES;
+          /* PhyML_Printf("\n. Found outgroup taxon: %s",d->name); */
+          d->s_ingrp[0]  = NO;
+          d->s_outgrp[0] = YES;
+        }
       else
-    {
-      d->s_ingrp[0]  = 1;
-      d->s_outgrp[0] = 0;
-    }
+        {
+          d->s_ingrp[0]  = YES;
+          d->s_outgrp[0] = NO;
+        }
       return;
     }
   else
     {
       int i;
-
+      
       For(i,3)
-    if(d->v[i] != a && (d->b[i] != tree->e_root))
-      Get_Best_Root_Position_Post(d,d->v[i],has_outgrp,tree);
-
+        if(d->v[i] != a && (d->b[i] != tree->e_root))
+          Get_Best_Root_Position_Post(d,d->v[i],has_outgrp,tree);
+      
       Get_OutIn_Scores(a,d);
-
+      
     }
 }
 
@@ -9504,32 +9549,6 @@ void Get_Edge_Binary_Coding_Number(t_tree *tree)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-
-void Make_Ancestral_Seq(t_tree *tree)
-{
-  int i;
-  char **sp_names;
-
-  sp_names = (char **)mCalloc(tree->n_otu,sizeof(char *));
-  For(i,tree->n_otu-1)
-    {
-      sp_names[i] = (char *)mCalloc(10,sizeof(char));
-      sprintf(sp_names[i],"anc%d",i+tree->n_otu);
-    }
-
-  tree->anc_data = Make_Cseq(tree->n_otu-1,
-                 tree->data->init_len,
-                 tree->mod->io->state_len,
-                 tree->data->init_len,
-                 sp_names);
-
-  For(i,tree->n_otu-1) Free(sp_names[i]);
-  Free(sp_names);
-}
-
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
-
 void Make_MutMap(t_tree *tree)
 {
   // (# of edges) X (# of sites) X (# mutation types: A<->C A<->G A<->T C<->G C<->T G<->T)
@@ -9622,37 +9641,34 @@ char *To_Upper_String(char *in)
 //////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////
 
-void Connect_CSeqs_To_Nodes(calign *cdata, t_tree *tree)
+void Connect_CSeqs_To_Nodes(calign *cdata, option *io, t_tree *tree)
 {
   int i,j,n_otu_tree,n_otu_cdata;
-
+  
   n_otu_tree  = tree->n_otu;
   n_otu_cdata = cdata->n_otu;
-
-  if((n_otu_tree != n_otu_cdata) && (tree->io->fp_in_constraint_tree == NULL))
+  
+  if((n_otu_tree != n_otu_cdata) && (io->fp_in_constraint_tree == NULL))
     {
       PhyML_Printf("\n== Number of taxa in the tree: %d, number of sequences: %d.",n_otu_tree,n_otu_cdata);
       Warn_And_Exit("\n== The number of tips in the tree is not the same as the number of sequences\n");
     }
-
+  
   For(i,MAX(n_otu_tree,n_otu_cdata))
     {
       For(j,MIN(n_otu_tree,n_otu_cdata))
-        {
-          if(!strcmp(tree->a_nodes[i]->name,cdata->c_seq[j]->name))
-            break;
+        {          
+          if(!strcmp(tree->a_nodes[i]->name,cdata->c_seq[j]->name)) break;
         }
       
       if(j==MIN(n_otu_tree,n_otu_cdata))
         {
           PhyML_Printf("\n== Taxon '%s' was not found in sequence file '%s'.\n",
                        tree->a_nodes[i]->name,
-                       tree->io->in_align_file);
+                       io->in_align_file);
           Exit("\n");
-        }
-      
-      tree->a_nodes[i]->c_seq = cdata->c_seq[j];
-
+        }      
+      tree->a_nodes[i]->c_seq = cdata->c_seq[j];      
     }
 }
 
@@ -9989,7 +10005,7 @@ void Set_P_Lk_One_Side(phydbl **Pij, phydbl **p_lk,  int **sum_scale, t_node *d,
 */
 
 void Set_All_P_Lk(t_node **n_v1, t_node **n_v2,
-                                 phydbl **p_lk   , int **sum_scale   , int **p_lk_loc,
+                  phydbl **p_lk   , int **sum_scale   , int **p_lk_loc,
                   phydbl **Pij1, phydbl **p_lk_v1, int **sum_scale_v1,
                   phydbl **Pij2, phydbl **p_lk_v2, int **sum_scale_v2,
                   t_node *d, t_edge *b, t_tree *tree
@@ -10445,15 +10461,13 @@ void Build_Distrib_Number_Of_Diff_States_Under_Model(t_tree *tree)
       Free_Model_Complete(tree->mod);
       Free_Model_Basic(tree->mod);
       
-
       tree->mod  = Copy_Model(orig_mod);
       tree->data = Copy_Cseq(orig_data,tree->io);
 
-
       tree->mod->io    = orig_mod->io;
       tree->mod->s_opt = orig_mod->s_opt;
 
-      Connect_CSeqs_To_Nodes(tree->data,tree);
+      Connect_CSeqs_To_Nodes(tree->data,tree->io,tree);
 
       iter++;
     }
@@ -10867,7 +10881,138 @@ phydbl Get_Lk(t_tree *tree)
 
 }
 
-//////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+align **Make_Empty_Alignment(option *io)
+{
+  int i;
+  char *line;
+  align **data;
+
+  line   = (char *)mCalloc(T_MAX_LINE,sizeof(char));
+  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));
+      data[i]->state = (char *)mCalloc(io->init_len*io->state_len+1,sizeof(char));
+
+      data[i]->is_ambigu = NULL;
+      data[i]->len = 0;
+      
+      Random_String(data[i]->name,5);
+
+      while(data[i]->len < io->init_len * io->state_len)
+        {
+          data[i]->state[data[i]->len] = 'X';
+          data[i]->len++;
+        }
+    }
+
+  For(i,io->n_otu) data[i]->state[data[i]->len] = '\0';
+
+  Free(line);
+
+  return data;
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+/* Mean observed frequency of difference between the n(n-1)/2 pairs of sequences */
+phydbl Mean_Identity(calign *data)
+{
+  int i,j,n;
+  phydbl tot_idt;
+  
+  n = data->n_otu;
+  
+  tot_idt = 0.0;
+  For(i,n-1)
+    {
+      for(j=i+1; j<n; j++)
+        {
+          tot_idt += Pairwise_Identity(i,j,data);
+        }
+    }
+
+  return(tot_idt / (phydbl)(n*(n-1.)/2.));
+}
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+/* Observed frequency of difference for the (i,j)-pair of sequences */
+phydbl Pairwise_Identity(int i, int j, calign *data)
+{
+  int k;
+  phydbl div,p,d;
+  
+  div = 0.0;
+  For(k,data->crunch_len) if(data->c_seq[i]->state[k] == data->c_seq[j]->state[k]) div += (phydbl)data->wght[k];
 
+  /* observed proportion of identity */
+  p = 1. - div / (phydbl)data->init_len;
 
+  d = 0.0;
+  if(data->io->datatype == NT)
+    {
+      if(p > 3./4.) return 0.25;
+      else
+        {
+          /* Jukes & Cantor distance */
+          d = -(3./4.)*LOG(1. - 4./3.*p);
+        }
+    }
+  else if(data->io->datatype == AA)
+    {
+      if(p > 19./20.) return 1./20.;
+      else
+        {
+          /* Jukes & Cantor distance */
+          d = -(19./20.)*LOG(1. - 20./19.*p);
+        }
+    }
+  else Generic_Exit(__FILE__,__LINE__,__FUNCTION__);
+
+  return(EXP(-d));
+}
+
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl Fst(int i, int j, calign *data)
+{
+  phydbl FA, Fr;
+
+  FA = Mean_Identity(data);
+  Fr = Pairwise_Identity(i,j,data);
+
+  return((Fr-FA)/(1-FA));
+}
+
+
+/*////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////*/
+
+phydbl Nucleotide_Diversity(calign *data)
+{
+
+  int i,j,n;
+  phydbl pair_div;
+  
+  n = data->n_otu;
+  
+  pair_div = 0.0;
+  For(i,n-1)
+    {
+      for(j=i+1; j<n; j++)
+        {
+          pair_div += 1. - Pairwise_Identity(i,j,data);
+        }
+    }
+
+  return(pair_div / (phydbl)(n*(n-1.)/2.));
+}
diff --git a/src/utilities.h b/src/utilities.h
index 49fafa3..7f7cd5f 100644
--- a/src/utilities.h
+++ b/src/utilities.h
@@ -26,12 +26,9 @@ the GNU public licence. See http://www.opensource.org for details.
 #include <limits.h>
 #include <errno.h>
 #include <float.h>
+#include <assert.h>
 #include <stdbool.h>
 
-#ifdef MIGREP
-#include <gtk/gtk.h>
-#endif
-
 extern int n_sec1;
 extern int n_sec2;
 
@@ -81,6 +78,12 @@ static inline int isinf_ld (long double x) { return isnan (x - x); }
 #define CT 4
 #define GT 5
 
+#ifndef M_1_SQRT_2PI
+#define M_1_SQRT_2PI	0.398942280401432677939946059934	/* 1/sqrt(2pi) */
+#endif
+
+
+
 #define T_MAX_MCMC_MOVE_NAME 500
 
 #define WINDOW_WIDTH  800
@@ -89,6 +92,9 @@ static inline int isinf_ld (long double x) { return isnan (x - x); }
 #define RR_MIN 0.01
 #define RR_MAX 200.0
 
+#define PHYREX_UNIFORM 0
+#define PHYREX_NORMAL  1
+
 #define MCMC_MOVE_RANDWALK_UNIFORM       0
 #define MCMC_MOVE_LOG_RANDWALK_UNIFORM   1
 #define MCMC_MOVE_RANDWALK_NORMAL        2
@@ -166,12 +172,17 @@ static inline int isinf_ld (long double x) { return isnan (x - x); }
 #define INTERFACE_TOPO_SEARCH    3
 #define INTERFACE_BRANCH_SUPPORT 4
 
+#define LEFT 0
+#define RGHT 1
+
+
 #ifndef INFINITY
 #define INFINITY HUGE
 #endif
 
 #define  N_MAX_OPTIONS        100
 
+#define NEXT_BLOCK_SIZE        50
 
 #define  T_MAX_FILE           200
 #define  T_MAX_LINE       2000000
@@ -248,7 +259,7 @@ static inline int isinf_ld (long double x) { return isnan (x - x); }
 #define FLU       24
 #define CUSTOMAA  25
 #define LG        26
-
+#define AB        27
 // Amino acid ordering:
 // Ala Arg Asn Asp Cys Gln Glu Gly His Ile Leu Lys Met Phe Pro Ser Thr Trp Tyr Val
 
@@ -444,8 +455,7 @@ typedef struct __Node {
   int                                rank;
   int                            rank_max;
 
-
-  struct __Lineage_Loc       *lineage_loc; /*! Spatial coordinates */
+  struct __Geo_Coord               *coord;
 
 }t_node;
 
@@ -577,7 +587,6 @@ typedef struct __Tree{
   struct __Edge                     **a_edges; /*! array of edges */
   struct __Model                         *mod; /*! substitution model */
   struct __Calign                       *data; /*! sequences */
-  struct __Calign                   *anc_data; /*! ancestral sequences */
   struct __Tree                         *next; /*! set to NULL by default. Used for mixture models */
   struct __Tree                         *prev; /*! set to NULL by default. Used for mixture models */
   struct __Tree                    *next_mixt; /*! set to NULL by default. Used for mixture models */
@@ -682,9 +691,6 @@ typedef struct __Tree{
   int                                  b_inst; /*! The BEAGLE instance id associated with this tree. */
 #endif
 
-#ifdef MIGREP
-  GtkWidget                        *draw_area;
-#endif
 }t_tree;
 
 /*!********************************************************/
@@ -806,19 +812,20 @@ typedef struct __Align {
 
 typedef struct __Calign {
   struct __Align **c_seq;             /*! compressed sequences      */
+  struct __Option    *io;             /*! input/output */
   phydbl          *b_frq;             /*! observed state frequencies */
   short int       *invar;             /*! < 0 -> polymorphism observed */
   int              *wght;             /*! # of each site in c_align */
   short int      *ambigu;             /*! ambigu[i]=1 is one or more of the sequences at site
-                    i display an ambiguous character */
+                                        i display an ambiguous character */
   phydbl      obs_pinvar;
   int              n_otu;             /*! number of taxa */
   int          clean_len;             /*! uncrunched sequences lenghts without gaps */
   int         crunch_len;             /*! crunched sequences lengths */
   int           init_len;             /*! length of the uncompressed sequences */
   int          *sitepatt;             /*! this array maps the position of the patterns in the
-                       compressed alignment to the positions in the uncompressed
-                       one */
+                                        compressed alignment to the positions in the uncompressed
+                                        one */
   int             format;             /*! 0 (default): PHYLIP. 1: NEXUS. */
 }calign;
 
@@ -932,7 +939,7 @@ typedef struct __Model {
 
   int                   whichmodel;
   int                  is_mixt_mod;
-
+  int                    augmented;
   int                           ns; /*! number of states (4 for ADN, 20 for AA) */
 
   int                    bootstrap; /*! Number of bootstrap replicates (0 : no bootstrap analysis is launched) */
@@ -1039,12 +1046,18 @@ typedef struct __Option { /*! mostly used in 'help.c' */
   char                  *out_lk_file; /*! name of the file in which the likelihood of the model is written */
   FILE                    *fp_out_lk;
 
+  char             *out_summary_file; /*! name of the file in which summary statistics are written */
+  FILE               *fp_out_summary;
+
   char                  *out_ps_file; /*! name of the file in which tree(s) is(are) written */
   FILE                    *fp_out_ps;
 
   char           *out_ancestral_file; /*! name of the file containing the ancestral sequences */
   FILE             *fp_out_ancestral; /*! pointer to the file containing the ancestral sequences */
 
+  char                *in_coord_file; /*! name of input file containing coordinates */
+  FILE                  *fp_in_coord; /*! pointer to the file containing coordinates */
+
   char                     *out_file; /*! name of the output file */
 
   char              *clade_list_file;
@@ -1085,6 +1098,7 @@ typedef struct __Option { /*! mostly used in 'help.c' */
   char                    **alphabet;
   int                         codpos;
   int                         mutmap;
+  int                        use_xml;
 
   char              **long_tax_names;
   char             **short_tax_names;
@@ -1365,7 +1379,7 @@ typedef struct __T_Rate {
   phydbl     *t_prior_max;
   phydbl     *t_floor;
   phydbl     *t_mean;
-  int        *t_ranked;
+  int        *t_rank; /* rank of nodes, e.g., tree->nd_a[tree->rates->t_rank[0]] is the oldest node */
   phydbl     *mean_l;
   phydbl     *cov_l;
   phydbl     *grad_l; /* gradient */
@@ -1466,20 +1480,29 @@ typedef struct __Tmcmc {
   int num_move_geo_dum;
   int num_move_geo_updown_tau_lbda;
   int num_move_geo_updown_lbda_sigma;
-  int num_move_migrep_lbda;
-  int num_move_migrep_mu;
-  int num_move_migrep_rad;
-  int num_move_migrep_insert_disk;
-  int num_move_migrep_delete_disk;  
-  int num_move_migrep_move_disk_ct;
-  int num_move_migrep_move_disk_ud;
-  int num_move_migrep_swap_disk;
-  int num_move_migrep_delete_hit;
-  int num_move_migrep_insert_hit;
-  int num_move_migrep_move_ldsk;
-  int num_move_migrep_ldsk_ct;
-  int num_move_migrep_shift_ct_med;
-  int num_move_migrep_triplet;
+  int num_move_phyrex_lbda;
+  int num_move_phyrex_mu;
+  int num_move_phyrex_rad;
+  int num_move_phyrex_indel_disk;
+  int num_move_phyrex_move_disk_ct;
+  int num_move_phyrex_move_disk_ud;
+  int num_move_phyrex_swap_disk;
+  int num_move_phyrex_indel_hit;
+  int num_move_phyrex_spr;
+  int num_move_phyrex_scale_times;
+  int num_move_phyrex_ldscape_lim;
+  int num_move_phyrex_sigsq;
+  int num_move_phyrex_sim;
+  int num_move_phyrex_traj;
+  int num_move_phyrex_lbda_times;
+  int num_move_phyrex_indel_disk_serial;
+  int num_move_phyrex_sim_plus;
+  int num_move_phyrex_indel_hit_serial;
+  int num_move_phyrex_ldsk_and_disk;
+  int num_move_phyrex_ldsk_multi;
+  int num_move_phyrex_disk_multi;
+  int num_move_phyrex_ldsk_given_disk;
+  int num_move_phyrex_disk_given_ldsk;
 
   int nd_t_digits;
   int *monitor;
@@ -1508,20 +1531,18 @@ typedef struct __Tmcmc {
   int chain_len_burnin;
   int print_every;
   int is_burnin;
+  int max_lag;
 
   phydbl max_tune;
   phydbl min_tune;
-
-  phydbl *old_param_val;
-  phydbl *new_param_val;
-
-  phydbl *sum_val;
-  phydbl *sum_valsq;
-  phydbl *sum_curval_nextval;
+  
+  phydbl *sampled_val;
+  int sample_size;
+  int sample_num;
   phydbl *ess;
-  phydbl *first_val;
   int    *ess_run;
   int    *start_ess;
+  phydbl *mode;
   int always_yes; /* Always accept proposed move (as long as log-likelihood > UNLIKELY) */
   int is; /* Importance sampling? Yes or NO */
 }t_mcmc;
@@ -1652,32 +1673,51 @@ typedef struct __Phylogeo{
   phydbl            min_dum;
   phydbl            max_dum;
 
-
+  
 }t_geo;
 
 /*!********************************************************/
 // Structure for the Etheridge-Barton migration/reproduction model
 typedef struct __Migrep_Model{
+  int                           name;
   int                          n_dim;
 
   phydbl                        lbda; // rate at which events occur
   phydbl                    min_lbda; // min of rate at which events occur
   phydbl                    max_lbda; // max of rate at which events occur
+  phydbl            prior_param_lbda; // parameter of the parameter for the prior on lbda
 
   phydbl                          mu; // per-capita and per event death probability
   phydbl                      min_mu; // min of per-capita and per event death probability
   phydbl                      max_mu; // max of per-capita and per event death probability
+  phydbl              prior_param_mu; // parameter of the parameter for the prior on mu
 
   phydbl                         rad; // radius of the migrep disk 
   phydbl                     min_rad; // min of radius of the migrep disk 
   phydbl                     max_rad; // max of radius of the migrep disk 
-  phydbl             prior_param_rad; // parameter of the parameter for the exponential prior on radius
+  phydbl             prior_param_rad; // parameter of the parameter for the prior on radius
+  int                     update_rad;
+
+  phydbl                       sigsq; // parent to offspring distance variance (i.e., gene flow) parameter. 
+  phydbl                   min_sigsq; // min 
+  phydbl                   max_sigsq; // max  
+  phydbl           prior_param_sigsq; // parameter of the parameter for the prior 
+
+  phydbl                         rho; // intensity parameter of the Poisson point processs
 
   phydbl                       c_lnL; // current value of log-likelihood 
-  phydbl              c_ln_prior_rad; // current value of log prior for the exponential prior on radius
+  phydbl              c_ln_prior_rad; // current value of log prior for the prior on radius
+  phydbl             c_ln_prior_lbda; // current value of log prior for the prior on lbda
+  phydbl               c_ln_prior_mu; // current value of log prior for the prior on mu
+  phydbl            c_ln_prior_sigsq; // current value of log prior for the prior on sigsq=4.pi.lbda.mu.rad^4
+
+  int                    safe_phyrex;
+  phydbl             soft_bound_area;
 
   struct __Geo_Coord            *lim; // max longitude and lattitude (the min are both set to zero)                       
-}t_migrep_mod;
+
+  phydbl                  sampl_area;
+}t_phyrex_mod;
 
 /*!********************************************************/
 
@@ -1691,15 +1731,17 @@ typedef struct __Disk_Event{
   struct __Lindisk_Node         *ldsk;
   struct __Migrep_Model         *mmod;
   char                            *id;
-  struct __Node                   *nd;
+  phydbl                        c_lnL;
 }t_dsk;
 
 /*!********************************************************/
 
 typedef struct __Geo_Coord{
-  phydbl *lonlat; // longitude-latitude vector
-  int        dim;
-  char       *id;
+  phydbl             *lonlat; /* longitude-latitude vector */
+  int                    dim;
+  char                   *id;
+  struct __Geo_Coord    *cpy; /* keep a copy of this coordinate */
+
 }t_geo_coord;
 
 /*!********************************************************/
@@ -1709,22 +1751,35 @@ typedef struct __Lindisk_Node{
   struct __Lindisk_Node  **next;
   struct __Lindisk_Node   *prev;
   struct __Geo_Coord     *coord; 
-  struct __Geo_Coord *min_coord; 
-  struct __Geo_Coord *max_coord; 
   struct __Geo_Coord *cpy_coord; 
   short int              is_hit;
-  short int             is_coal;
   int                    n_next;
+  struct __Node             *nd;
 }t_ldsk;
 
 /*!********************************************************/
+
+typedef struct __Polygon{
+  struct __Geo_Coord **poly_vert; /* array of polygon vertex coordinates */
+  int n_poly_vert; /* number of vertices */
+}t_poly;
+
+/*!********************************************************/
+/*!********************************************************/
+/*!********************************************************/
+/*!********************************************************/
+/*!********************************************************/
 /*!********************************************************/
 
+
+
+
+
 void Unroot_Tree(char **subtrees);
 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 Make_Edge_Dirs(t_edge *b,t_node *a,t_node *d,t_tree *tree);
+void Set_Edge_Dirs(t_edge *b,t_node *a,t_node *d,t_tree *tree);
 void Init_NNI(nni *a_nni);
 void Init_Nexus_Format(nexcom **com);
 void Restrict_To_Coding_Position(align **data,option *io);
@@ -1942,7 +1997,7 @@ void Init_Vect_Int(int len,vect_int *p);
 char *To_Lower_String(char *in);
 phydbl String_To_Dbl(char *string);
 char *To_Upper_String(char *in);
-void Connect_CSeqs_To_Nodes(calign *cdata, t_tree *tree);
+void Connect_CSeqs_To_Nodes(calign *cdata, option *io, t_tree *tree);
 void Switch_Eigen(int state, t_mod *mod);
 void Joint_Proba_States_Left_Right(phydbl *Pij, phydbl *p_lk_left, phydbl *p_lk_rght,
                    vect_dbl *pi, int scale_left, int scale_rght,
@@ -1985,6 +2040,12 @@ int Number_Of_Diff_States_One_Site(int site, t_tree *tree);
 void Number_Of_Diff_States_One_Site_Post(t_node *a, t_node *d, t_edge *b, int site, t_tree *tree);
 int Number_Of_Diff_States_One_Site_Core(t_node *a, t_node *d, t_edge *b, int site, t_tree *tree);
 phydbl Get_Lk(t_tree *tree);
+align **Make_Empty_Alignment(option *io);
+void Connect_Edges_To_Nodes_Serial(t_tree *tree);
+phydbl Mean_Identity(calign *data);
+phydbl Pairwise_Identity(int i, int j, calign *data);
+phydbl Fst(int i, int j, calign *data);
+phydbl Nucleotide_Diversity(calign *data);
 
 
 #include "xml.h"
@@ -2010,8 +2071,8 @@ phydbl Get_Lk(t_tree *tree);
 #include "geo.h"
 #endif
 
-#ifdef MIGREP
-#include "migrep.h"
+#ifdef PHYREX
+#include "phyrex.h"
 #endif
 
 #ifdef MPI
diff --git a/src/xml.c b/src/xml.c
index 4b2ea51..6ae9712 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -700,14 +700,14 @@ int XML_Validate_Attr_Int(char *target, int num, ...)
   char *sc_target;
   
   sc_target = To_Lower_String(target);
-
+  
   va_start(args,num);           
-  For(i,num+1)
+  For(i,num)
     {
       s = va_arg(args, char *); 
-      sc_s = To_Lower_String(s);
+      sc_s = To_Lower_String(s);      
       if(!strcmp(sc_s,sc_target)) 
-        {
+        {          
           Free(sc_s);
           break;
         }
@@ -715,7 +715,7 @@ int XML_Validate_Attr_Int(char *target, int num, ...)
     }
   va_end(args);
 
-  if(i == num+1) 
+  if(i == num) 
     {
       i = -1;
       PhyML_Printf("\n== Attribute value '%s' is not valid",target);
diff --git a/version b/version
new file mode 100644
index 0000000..d42f346
--- /dev/null
+++ b/version
@@ -0,0 +1 @@
+396:449M

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/phyml.git



More information about the debian-med-commit mailing list