[med-svn] [maffilter] 02/08: New upstream version 1.2.1

Andreas Tille tille at debian.org
Thu Jun 22 07:45:16 UTC 2017


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

tille pushed a commit to branch master
in repository maffilter.

commit 9a5e284b273b09d8d8bb24aa2698069bb4ee0b14
Author: Andreas Tille <tille at debian.org>
Date:   Thu Jun 22 08:51:58 2017 +0200

    New upstream version 1.2.1
---
 AUTHORS.txt => AUTHORS                             |   0
 CMakeLists.txt                                     | 277 +++-----
 COPYING.txt                                        | 506 ---------------
 ChangeLog                                          |  44 +-
 INSTALL.txt => INSTALL                             |   2 +-
 LICENSE                                            | 674 ++++++++++++++++++++
 MafFilter/CMakeLists.txt                           |  23 +-
 MafFilter/MafFilter.cpp                            | 605 ++++++++++++++++--
 MafFilter/SystemCallMafIterator.cpp                |  84 +++
 MafFilter/SystemCallMafIterator.h                  | 110 ++++
 MafFilter/TreeBuildingSystemCallMafIterator.cpp    |  82 +++
 MafFilter/TreeBuildingSystemCallMafIterator.h      | 115 ++++
 buildBin.sh                                        |   7 +
 doc/CMakeLists.txt                                 |  80 ++-
 doc/maffilter.texi                                 | 695 +++++++++++++++++----
 ...projected.chr22.subset.nogap.cleaned_aln.maf.gz | Bin 0 -> 13206362 bytes
 examples/UCSC46ways/MafFilter.bpp                  |   2 +-
 examples/UCSC46ways/README                         |   1 +
 ...Mgraminicolav2.FrozenGeneCatalog20080910.gff.gz | Bin 0 -> 809905 bytes
 examples/Ztritici/tba_refIPO323.maf.gz             | Bin 0 -> 60513136 bytes
 maffilter.spec                                     |  66 +-
 man/CMakeLists.txt                                 |  47 +-
 man/{maffilter.1.txt => maffilter.1}               |   2 +-
 23 files changed, 2470 insertions(+), 952 deletions(-)

diff --git a/AUTHORS.txt b/AUTHORS
similarity index 100%
rename from AUTHORS.txt
rename to AUTHORS
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ab07947..b9be832 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,8 +3,8 @@
 # Created: 27/04/2010
 
 # Global parameters
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(maffilter C CXX)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+PROJECT(maffilter CXX)
 
 IF(NOT CMAKE_BUILD_TYPE)
   SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
@@ -12,40 +12,9 @@ IF(NOT CMAKE_BUILD_TYPE)
       FORCE)
 ENDIF()
 
-SET(CMAKE_CXX_FLAGS "-Wall -Weffc++ -Wshadow")
-IF(NOT NO_VIRTUAL_COV)
-  SET(NO_VIRTUAL_COV FALSE CACHE BOOL
-      "Disable covariant return type with virtual inheritance, for compilers that do not support it."
-      FORCE)
-ENDIF()
-
-IF(NO_VIRTUAL_COV)
-  MESSAGE("-- Covariant return with virtual inheritance disabled.")
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_VIRTUAL_COV=1")
-ENDIF()
-
-IF(NOT NO_DEP_CHECK)
-  SET(NO_DEP_CHECK FALSE CACHE BOOL
-      "Disable dependencies check for building distribution only."
-      FORCE)
-ENDIF(NOT NO_DEP_CHECK)
-
-IF(NOT DOC_COMPRESS)
-  SET(DOC_COMPRESS gzip CACHE STRING
-      "Set program for compressing documentation."
-      FORCE)
-ENDIF(NOT DOC_COMPRESS)
-
-IF(NOT DOC_COMPRESS_EXT)
-  SET(DOC_COMPRESS_EXT gz CACHE STRING
-      "Set extension of compressed documentation."
-      FORCE)
-ENDIF(NOT DOC_COMPRESS_EXT)
+SET(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Weffc++ -Wshadow")
 
 
-IF(NO_DEP_CHECK)
-  MESSAGE("-- Dependencies checking disabled. Only distribution can be built.")
-ELSE(NO_DEP_CHECK)
 
 #static linkage?
 IF(NOT BUILD_STATIC)
@@ -55,73 +24,60 @@ IF(NOT BUILD_STATIC)
 ENDIF()
 IF(BUILD_STATIC)
   MESSAGE("-- Static linkage requested.")
-  SET(CMAKE_CXX_FLAGS "-static -static-libgcc ${CMAKE_CXX_FLAGS}")
+  SET (CMAKE_CXX_FLAGS "-static -static-libgcc ${CMAKE_CXX_FLAGS}")
 ENDIF()
 
-#build info?
-IF(NOT DEFINED INFO)
-  SET(INFO UNIX)
-ENDIF(NOT DEFINED INFO)
+# Check compression program
+# COMPRESS_PROGRAM controls the choice of program
+# COMPRESS_EXT can be used to override the file extension
+if (NOT COMPRESS_PROGRAM)
+  set (COMPRESS_PROGRAM gzip CACHE STRING "Set program for compressing documentation" FORCE)
+endif ()
+find_program (COMPRESS_BIN NAMES ${COMPRESS_PROGRAM} DOC "${COMPRESS_PROGRAM} compression program")
+if (NOT COMPRESS_BIN)
+  message (STATUS "${COMPRESS_PROGRAM} program not found, text doc will not be compressed")
+else ()
+  # Deduce COMPRESS_EXT for known compression programs if not set
+  if (NOT COMPRESS_EXT)
+    if (${COMPRESS_PROGRAM} STREQUAL "gzip")
+      set (COMPRESS_EXT "gz")
+    elseif (${COMPRESS_PROGRAM} STREQUAL "bzip2")
+      set (COMPRESS_EXT "bz2")
+    else ()
+      set (COMPRESS_EXT "${COMPRESS_PROGRAM}") # Default: program name (works for xz/lzma)
+    endif ()
+  endif ()
+  # Generate command line args (always add -c to output compressed file to stdout)
+  if (${COMPRESS_PROGRAM} STREQUAL "gzip")
+    # -n for no timestamp in files (reproducible builds)
+    set (COMPRESS_ARGS -c -n)
+  else ()
+    set (COMPRESS_ARGS -c)
+  endif ()
+  message (STATUS "Found ${COMPRESS_BIN} compression program, using file extension .${COMPRESS_EXT}")
+endif ()
+
+# Find dependencies (add install directory to search)
+if (CMAKE_INSTALL_PREFIX)
+  set (CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" ${CMAKE_PREFIX_PATH})
+endif (CMAKE_INSTALL_PREFIX)
+
+include (GNUInstallDirs)
+find_package (bpp-phyl-omics 2.0.0 REQUIRED)
 
-#build man pages?
-IF(NOT DEFINED MAN)
-  SET(MAN UNIX)
-ENDIF(NOT DEFINED MAN)
-
-#find executables for documentation
-IF(MAN)
-  FIND_PROGRAM(NROFF_EXE NAMES nroff)
-  IF(NROFF_EXE)
-    MESSAGE("-- Found nroff here: ${NROFF_EXE}")
-    MESSAGE("   Adding targets: man")
-
-    ADD_CUSTOM_TARGET(man
-      ALL
-      COMMAND cp maffilter.1.txt maffilter.1
-      COMMAND ${DOC_COMPRESS} -f maffilter.1
-      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/man
-      )
-    SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "man/maffilter.1.${DOC_COMPRESS_EXT}")
-  ELSE()
-    MESSAGE(FATAL_ERROR "Program nroff required but not found.")
-  ENDIF()
-ENDIF(MAN)
-
-IF(INFO)
-  FIND_PROGRAM(MAKEINFO_EXE NAMES makeinfo)
-  IF(MAKEINFO_EXE)
-    MESSAGE("-- Found makeinfo here: ${MAKEINFO_EXE}")
-    MESSAGE("   Adding targets: info, html")
- 
-    SET(ADD_INFO_TO "ALL")
-    MESSAGE("   Adding target info to target all")
-    
-    ADD_CUSTOM_TARGET(info
-      ${ADD_INFO_TO}
-      COMMAND ${MAKEINFO_EXE} maffilter.texi
-      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc
-      )
-
-    ADD_CUSTOM_TARGET(html
-      COMMAND ${MAKEINFO_EXE} --html --css-ref=http://www.w3.org/StyleSheets/Core/Steely maffilter.texi
-      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc
-      )
-  ELSE(MAKEINFO_EXE)
-    MESSAGE(FATAL_ERROR p"Program makeinfo required but not found.")
-  ENDIF(MAKEINFO_EXE)
-ENDIF(INFO)
+#Find boost libraries
+SET(Boost_USE_STATIC_LIBS ${BUILD_STATIC})
+SET(Boost_USE_MULTITHREADED ON)
+FIND_PACKAGE( Boost 1.34.0 COMPONENTS iostreams )
 
-FIND_PROGRAM(PDFTEX_EXE NAMES pdftex)
-IF(PDFTEX_EXE)
-  MESSAGE("-- Found pdftex here: ${PDFTEX_EXE}")
-  MESSAGE("   Adding target: pdf")
+IF(Boost_FOUND)
+  INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
+  SET(LIBS ${LIBS} ${Boost_LIBRARIES})
+  MESSAGE("-- Boost libraries found here:")
+  MESSAGE("   includes: ${Boost_INCLUDE_DIRS}")
+  MESSAGE("   dynamic libraries: ${Boost_LIBRARIES}")
+ENDIF()
 
-  ADD_CUSTOM_TARGET(pdf
-    COMMAND ${PDFTEX_EXE} maffilter.texi
-    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc
-    )
-  SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "doc/maffilter.pdf;doc/maffilter.aux;doc/maffilter.cp;doc/maffilter.fn;doc/maffilter.info;doc/maffilter.ky;doc/maffilter.log;doc/maffilter.pg;doc/maffilter.toc;doc/maffilter.tp;doc/maffilter.vr")
-ENDIF(PDFTEX_EXE)
 
 #here is a useful function:
 MACRO(IMPROVED_FIND_LIBRARY OUTPUT_LIBS lib_name include_to_find)
@@ -163,121 +119,65 @@ IF(CMAKE_INSTALL_PREFIX)
   SET(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" ${CMAKE_PREFIX_PATH})
 ENDIF(CMAKE_INSTALL_PREFIX)
 
-#Find the libraries. The order is very important for static linkage, it won't
-#link if you change it!
-IMPROVED_FIND_LIBRARY(LIBS bpp-phyl-omics Bpp/Seq/Io/Maf/AbstractDistanceEstimationMafIterator.h)
-IMPROVED_FIND_LIBRARY(LIBS bpp-phyl Bpp/Phyl/Tree.h)
-IMPROVED_FIND_LIBRARY(LIBS bpp-seq-omics Bpp/Seq/Feature/SequenceFeature.h)
-IMPROVED_FIND_LIBRARY(LIBS bpp-seq Bpp/Seq/Alphabet/Alphabet.h)
-IMPROVED_FIND_LIBRARY(LIBS bpp-core Bpp/Clonable.h)
-
-#Find boost libraries
-SET(Boost_USE_STATIC_LIBS ${BUILD_STATIC})
-SET(Boost_USE_MULTITHREADED ON)
-FIND_PACKAGE( Boost 1.34.0 COMPONENTS iostreams )
-
-IF(Boost_FOUND)
-  INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
-  SET(LIBS ${LIBS} ${Boost_LIBRARIES})
-  MESSAGE("-- Boost found: ${Boost_INCLUDE_DIRS}")
-ENDIF()
 
 # Find the zlib installation
-FIND_PACKAGE(ZLIB REQUIRED)
-IF(ZLIB_FOUND)
-  INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
-  SET(LIBS ${LIBS} ${ZLIB_LIBRARIES})
-  MESSAGE("-- Zlib found: ${ZLIB_INCLUDE_DIR}")
-ENDIF()
+IMPROVED_FIND_LIBRARY(LIBS z zlib.h)
+#This does not work with static linkage!!!
+#FIND_PACKAGE(ZLIB REQUIRED)
+#IF(ZLIB_FOUND)
+#  INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
+#  SET(LIBS ${LIBS} ${ZLIB_LIBRARIES})
+#  MESSAGE("-- Zlib found here:")
+#  MESSAGE("   includes: ${ZLIB_INCLUDE_DIR}")
+#  MESSAGE("   libraries: ${ZLIB_LIBRARIES}")
+#ENDIF()
 
 # Find the bz2 installation
-FIND_PACKAGE(BZip2 REQUIRED)
-IF(BZIP2_FOUND)
-  INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
-  SET(LIBS ${LIBS} ${BZIP2_LIBRARIES})
-  MESSAGE("-- BZip2 found: ${BZIP2_INCLUDE_DIR}")
-ENDIF()
+IMPROVED_FIND_LIBRARY(LIBS bz2 bzlib.h)
+#This does not work with static linkage!!!
+#FIND_PACKAGE(BZip2 REQUIRED)
+#IF(BZIP2_FOUND)
+#  INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
+#  SET(LIBS ${LIBS} ${BZIP2_LIBRARIES})
+#  MESSAGE("-- BZip2 found here:")
+#  MESSAGE("   includes: ${BZIP2_INCLUDE_DIR}")
+#  MESSAGE("   libraries: ${BZIP2_LIBRARIES}")
+#ENDIF()
 
 # Subdirectories
 ADD_SUBDIRECTORY(MafFilter)
 ADD_SUBDIRECTORY(doc)
 ADD_SUBDIRECTORY(man)
 
-ENDIF(NO_DEP_CHECK)
-
 # Packager
 SET(CPACK_PACKAGE_NAME "maffilter")
-SET(CPACK_PACKAGE_VENDOR "Julien Dutheil")
-SET(CPACK_PACKAGE_VERSION "1.1.0")
+SET(CPACK_PACKAGE_VENDOR "Julien Y. Dutheil")
+SET(CPACK_PACKAGE_VERSION "1.2.1")
 SET(CPACK_PACKAGE_VERSION_MAJOR "1")
-SET(CPACK_PACKAGE_VERSION_MINOR "1")
-SET(CPACK_PACKAGE_VERSION_PATCH "0-1")
+SET(CPACK_PACKAGE_VERSION_MINOR "2")
+SET(CPACK_PACKAGE_VERSION_PATCH "1")
 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Filtering of genome alignment in the Multiple Alignment Format (MAF)")
-SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
-SET(CPACK_RESOURCE_FILE_AUTHORS "${CMAKE_SOURCE_DIR}/AUTHORS.txt")
-SET(CPACK_RESOURCE_FILE_INSTALL "${CMAKE_SOURCE_DIR}/INSTALL.txt")
+SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
+SET(CPACK_RESOURCE_FILE_AUTHORS "${CMAKE_SOURCE_DIR}/AUTHORS")
+SET(CPACK_RESOURCE_FILE_INSTALL "${CMAKE_SOURCE_DIR}/INSTALL")
 SET(CPACK_SOURCE_GENERATOR "TGZ")
-SET(CPACK_SOURCE_IGNORE_FILES
- "CMakeFiles"
- "Makefile"
- "_CPack_Packages"
- "CMakeCache.txt"
- ".*\\\\.cmake"
- ".*\\\\.git"
- ".*\\\\.gz"
- ".*\\\\.zip"
- ".*\\\\.deb"
- ".*\\\\.rpm"
- ".*\\\\.dmg"
- ".*\\\\.sh"
- ".*\\\\..*\\\\.swp"
- ".*stamp"
- "\\\\.sh"
- "\\\\..*\\\\.swp"
- "MafFilter/\\\\..*"
- "man/.*\\\\.1.${DOC_COMPRESS_EXT}"
- "debian/tmp"
- "debian/maffilter/"
- "debian/maffilter\\\\.substvars"
- "debian/maffilter\\\\.debhelper"
- "debian/debhelper\\\\.log"
- "install_manifest.txt"
- "DartConfiguration.tcl"
- ${CPACK_SOURCE_IGNORE_FILES}
-)
-IF (MACOS)
-  SET(CPACK_GENERATOR "Bundle")
-ENDIF()
+# /!\ This assumes that an external build is used
+SET(CPACK_SOURCE_IGNORE_FILES 
+       "/build/" 
+       "/examples/" 
+       "/\\\\.git/" 
+       "/\\\\.gitignore" 
+       ${CPACK_SOURCE_IGNORE_FILES}
+       )
 
 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 SET(CPACK_DEBSOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.orig")
 INCLUDE(CPack)
 
 #This adds the 'dist' target
-add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
-# 'clean' is not (yet) a first class target. However, we need to clean the directories before building the sources:
-IF("${CMAKE_GENERATOR}" MATCHES "Make")
-  ADD_CUSTOM_TARGET(make_clean
-    COMMAND ${CMAKE_MAKE_PROGRAM} clean
-    WORKING_DIRECTORY ${CMAKE_CURRENT_DIR}
-  )
-  ADD_DEPENDENCIES(dist make_clean)
-
-  ADD_CUSTOM_TARGET(make_clean_man
-    COMMAND rm -f *.${DOC_COMPRESS_EXT}
-    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/man
-  )
-  ADD_DEPENDENCIES(dist make_clean_man)
-ENDIF()
+ADD_CUSTOM_TARGET(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
 
-IF(NOT NO_DEP_CHECK)
 IF (UNIX)
-#This creates deb packages:
-ADD_CUSTOM_TARGET(origdist COMMAND cp ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz ../${CPACK_DEBSOURCE_PACKAGE_FILE_NAME}.tar.gz)
-ADD_DEPENDENCIES(origdist dist)
-ADD_CUSTOM_TARGET(deb dpkg-buildpackage -uc -us -i${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz)
-ADD_DEPENDENCIES(deb origdist)
-ADD_DEPENDENCIES(deb info man)
 
 #This creates rpm packages:
 ADD_CUSTOM_TARGET(rpm rpmbuild -ta ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz)
@@ -285,4 +185,3 @@ ADD_DEPENDENCIES(rpm dist info man)
 
 ENDIF(UNIX)
 
-ENDIF(NOT NO_DEP_CHECK)
diff --git a/COPYING.txt b/COPYING.txt
deleted file mode 100644
index d424827..0000000
--- a/COPYING.txt
+++ /dev/null
@@ -1,506 +0,0 @@
-CeCILL FREE SOFTWARE LICENSE AGREEMENT
-
-
-    Notice
-
-This Agreement is a Free Software license agreement that is the result
-of discussions between its authors in order to ensure compliance with
-the two main principles guiding its drafting:
-
-    * firstly, compliance with the principles governing the distribution
-      of Free Software: access to source code, broad rights granted to
-      users,
-    * secondly, the election of a governing law, French law, with which
-      it is conformant, both as regards the law of torts and
-      intellectual property law, and the protection that it offers to
-      both authors and holders of the economic rights over software.
-
-The authors of the CeCILL (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre])
-license are:
-
-Commissariat à l'Energie Atomique - CEA, a public scientific, technical
-and industrial research establishment, having its principal place of
-business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France.
-
-Centre National de la Recherche Scientifique - CNRS, a public scientific
-and technological establishment, having its principal place of business
-at 3 rue Michel-Ange, 75794 Paris cedex 16, France.
-
-Institut National de Recherche en Informatique et en Automatique -
-INRIA, a public scientific and technological establishment, having its
-principal place of business at Domaine de Voluceau, Rocquencourt, BP
-105, 78153 Le Chesnay cedex, France.
-
-
-    Preamble
-
-The purpose of this Free Software license agreement is to grant users
-the right to modify and redistribute the software governed by this
-license within the framework of an open source distribution model.
-
-The exercising of these rights is conditional upon certain obligations
-for users so as to preserve this status for all subsequent redistributions.
-
-In consideration of access to the source code and the rights to copy,
-modify and redistribute granted by the license, users are provided only
-with a limited warranty and the software's author, the holder of the
-economic rights, and the successive licensors only have limited liability.
-
-In this respect, the risks associated with loading, using, modifying
-and/or developing or reproducing the software by the user are brought to
-the user's attention, given its Free Software status, which may make it
-complicated to use, with the result that its use is reserved for
-developers and experienced professionals having in-depth computer
-knowledge. Users are therefore encouraged to load and test the
-suitability of the software as regards their requirements in conditions
-enabling the security of their systems and/or data to be ensured and,
-more generally, to use and operate it in the same conditions of
-security. This Agreement may be freely reproduced and published,
-provided it is not altered, and that no provisions are either added or
-removed herefrom.
-
-This Agreement may apply to any or all software for which the holder of
-the economic rights decides to submit the use thereof to its provisions.
-
-
-    Article 1 - DEFINITIONS
-
-For the purpose of this Agreement, when the following expressions
-commence with a capital letter, they shall have the following meaning:
-
-Agreement: means this license agreement, and its possible subsequent
-versions and annexes.
-
-Software: means the software in its Object Code and/or Source Code form
-and, where applicable, its documentation, "as is" when the Licensee
-accepts the Agreement.
-
-Initial Software: means the Software in its Source Code and possibly its
-Object Code form and, where applicable, its documentation, "as is" when
-it is first distributed under the terms and conditions of the Agreement.
-
-Modified Software: means the Software modified by at least one
-Contribution.
-
-Source Code: means all the Software's instructions and program lines to
-which access is required so as to modify the Software.
-
-Object Code: means the binary files originating from the compilation of
-the Source Code.
-
-Holder: means the holder(s) of the economic rights over the Initial
-Software.
-
-Licensee: means the Software user(s) having accepted the Agreement.
-
-Contributor: means a Licensee having made at least one Contribution.
-
-Licensor: means the Holder, or any other individual or legal entity, who
-distributes the Software under the Agreement.
-
-Contribution: means any or all modifications, corrections, translations,
-adaptations and/or new functions integrated into the Software by any or
-all Contributors, as well as any or all Internal Modules.
-
-Module: means a set of sources files including their documentation that
-enables supplementary functions or services in addition to those offered
-by the Software.
-
-External Module: means any or all Modules, not derived from the
-Software, so that this Module and the Software run in separate address
-spaces, with one calling the other when they are run.
-
-Internal Module: means any or all Module, connected to the Software so
-that they both execute in the same address space.
-
-GNU GPL: means the GNU General Public License version 2 or any
-subsequent version, as published by the Free Software Foundation Inc.
-
-Parties: mean both the Licensee and the Licensor.
-
-These expressions may be used both in singular and plural form.
-
-
-    Article 2 - PURPOSE
-
-The purpose of the Agreement is the grant by the Licensor to the
-Licensee of a non-exclusive, transferable and worldwide license for the
-Software as set forth in Article 5 hereinafter for the whole term of the
-protection granted by the rights over said Software. 
-
-
-    Article 3 - ACCEPTANCE
-
-3.1 The Licensee shall be deemed as having accepted the terms and
-conditions of this Agreement upon the occurrence of the first of the
-following events:
-
-    * (i) loading the Software by any or all means, notably, by
-      downloading from a remote server, or by loading from a physical
-      medium;
-    * (ii) the first time the Licensee exercises any of the rights
-      granted hereunder.
-
-3.2 One copy of the Agreement, containing a notice relating to the
-characteristics of the Software, to the limited warranty, and to the
-fact that its use is restricted to experienced users has been provided
-to the Licensee prior to its acceptance as set forth in Article 3.1
-hereinabove, and the Licensee hereby acknowledges that it has read and
-understood it.
-
-
-    Article 4 - EFFECTIVE DATE AND TERM
-
-
-      4.1 EFFECTIVE DATE
-
-The Agreement shall become effective on the date when it is accepted by
-the Licensee as set forth in Article 3.1.
-
-
-      4.2 TERM
-
-The Agreement shall remain in force for the entire legal term of
-protection of the economic rights over the Software.
-
-
-    Article 5 - SCOPE OF RIGHTS GRANTED
-
-The Licensor hereby grants to the Licensee, who accepts, the following
-rights over the Software for any or all use, and for the term of the
-Agreement, on the basis of the terms and conditions set forth hereinafter.
-
-Besides, if the Licensor owns or comes to own one or more patents
-protecting all or part of the functions of the Software or of its
-components, the Licensor undertakes not to enforce the rights granted by
-these patents against successive Licensees using, exploiting or
-modifying the Software. If these patents are transferred, the Licensor
-undertakes to have the transferees subscribe to the obligations set
-forth in this paragraph.
-
-
-      5.1 RIGHT OF USE
-
-The Licensee is authorized to use the Software, without any limitation
-as to its fields of application, with it being hereinafter specified
-that this comprises:
-
-   1. permanent or temporary reproduction of all or part of the Software
-      by any or all means and in any or all form.
-
-   2. loading, displaying, running, or storing the Software on any or
-      all medium.
-
-   3. entitlement to observe, study or test its operation so as to
-      determine the ideas and principles behind any or all constituent
-      elements of said Software. This shall apply when the Licensee
-      carries out any or all loading, displaying, running, transmission
-      or storage operation as regards the Software, that it is entitled
-      to carry out hereunder.
-
-
-      5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS
-
-The right to make Contributions includes the right to translate, adapt,
-arrange, or make any or all modifications to the Software, and the right
-to reproduce the resulting software.
-
-The Licensee is authorized to make any or all Contributions to the
-Software provided that it includes an explicit notice that it is the
-author of said Contribution and indicates the date of the creation thereof.
-
-
-      5.3 RIGHT OF DISTRIBUTION
-
-In particular, the right of distribution includes the right to publish,
-transmit and communicate the Software to the general public on any or
-all medium, and by any or all means, and the right to market, either in
-consideration of a fee, or free of charge, one or more copies of the
-Software by any means.
-
-The Licensee is further authorized to distribute copies of the modified
-or unmodified Software to third parties according to the terms and
-conditions set forth hereinafter.
-
-
-        5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION
-
-The Licensee is authorized to distribute true copies of the Software in
-Source Code or Object Code form, provided that said distribution
-complies with all the provisions of the Agreement and is accompanied by:
-
-   1. a copy of the Agreement,
-
-   2. a notice relating to the limitation of both the Licensor's
-      warranty and liability as set forth in Articles 8 and 9,
-
-and that, in the event that only the Object Code of the Software is
-redistributed, the Licensee allows future Licensees unhindered access to
-the full Source Code of the Software by indicating how to access it, it
-being understood that the additional cost of acquiring the Source Code
-shall not exceed the cost of transferring the data.
-
-
-        5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE
-
-When the Licensee makes a Contribution to the Software, the terms and
-conditions for the distribution of the resulting Modified Software
-become subject to all the provisions of this Agreement.
-
-The Licensee is authorized to distribute the Modified Software, in
-source code or object code form, provided that said distribution
-complies with all the provisions of the Agreement and is accompanied by:
-
-   1. a copy of the Agreement,
-
-   2. a notice relating to the limitation of both the Licensor's
-      warranty and liability as set forth in Articles 8 and 9,
-
-and that, in the event that only the object code of the Modified
-Software is redistributed, the Licensee allows future Licensees
-unhindered access to the full source code of the Modified Software by
-indicating how to access it, it being understood that the additional
-cost of acquiring the source code shall not exceed the cost of
-transferring the data.
-
-
-        5.3.3 DISTRIBUTION OF EXTERNAL MODULES
-
-When the Licensee has developed an External Module, the terms and
-conditions of this Agreement do not apply to said External Module, that
-may be distributed under a separate license agreement.
-
-
-        5.3.4 COMPATIBILITY WITH THE GNU GPL
-
-The Licensee can include a code that is subject to the provisions of one
-of the versions of the GNU GPL in the Modified or unmodified Software,
-and distribute that entire code under the terms of the same version of
-the GNU GPL.
-
-The Licensee can include the Modified or unmodified Software in a code
-that is subject to the provisions of one of the versions of the GNU GPL,
-and distribute that entire code under the terms of the same version of
-the GNU GPL.
-
-
-    Article 6 - INTELLECTUAL PROPERTY
-
-
-      6.1 OVER THE INITIAL SOFTWARE
-
-The Holder owns the economic rights over the Initial Software. Any or
-all use of the Initial Software is subject to compliance with the terms
-and conditions under which the Holder has elected to distribute its work
-and no one shall be entitled to modify the terms and conditions for the
-distribution of said Initial Software.
-
-The Holder undertakes that the Initial Software will remain ruled at
-least by this Agreement, for the duration set forth in Article 4.2.
-
-
-      6.2 OVER THE CONTRIBUTIONS
-
-The Licensee who develops a Contribution is the owner of the
-intellectual property rights over this Contribution as defined by
-applicable law.
-
-
-      6.3 OVER THE EXTERNAL MODULES
-
-The Licensee who develops an External Module is the owner of the
-intellectual property rights over this External Module as defined by
-applicable law and is free to choose the type of agreement that shall
-govern its distribution.
-
-
-      6.4 JOINT PROVISIONS
-
-The Licensee expressly undertakes:
-
-   1. not to remove, or modify, in any manner, the intellectual property
-      notices attached to the Software;
-
-   2. to reproduce said notices, in an identical manner, in the copies
-      of the Software modified or not.
-
-The Licensee undertakes not to directly or indirectly infringe the
-intellectual property rights of the Holder and/or Contributors on the
-Software and to take, where applicable, vis-à-vis its staff, any and all
-measures required to ensure respect of said intellectual property rights
-of the Holder and/or Contributors.
-
-
-    Article 7 - RELATED SERVICES
-
-7.1 Under no circumstances shall the Agreement oblige the Licensor to
-provide technical assistance or maintenance services for the Software.
-
-However, the Licensor is entitled to offer this type of services. The
-terms and conditions of such technical assistance, and/or such
-maintenance, shall be set forth in a separate instrument. Only the
-Licensor offering said maintenance and/or technical assistance services
-shall incur liability therefor.
-
-7.2 Similarly, any Licensor is entitled to offer to its licensees, under
-its sole responsibility, a warranty, that shall only be binding upon
-itself, for the redistribution of the Software and/or the Modified
-Software, under terms and conditions that it is free to decide. Said
-warranty, and the financial terms and conditions of its application,
-shall be subject of a separate instrument executed between the Licensor
-and the Licensee.
-
-
-    Article 8 - LIABILITY
-
-8.1 Subject to the provisions of Article 8.2, the Licensee shall be
-entitled to claim compensation for any direct loss it may have suffered
-from the Software as a result of a fault on the part of the relevant
-Licensor, subject to providing evidence thereof.
-
-8.2 The Licensor's liability is limited to the commitments made under
-this Agreement and shall not be incurred as a result of in particular:
-(i) loss due the Licensee's total or partial failure to fulfill its
-obligations, (ii) direct or consequential loss that is suffered by the
-Licensee due to the use or performance of the Software, and (iii) more
-generally, any consequential loss. In particular the Parties expressly
-agree that any or all pecuniary or business loss (i.e. loss of data,
-loss of profits, operating loss, loss of customers or orders,
-opportunity cost, any disturbance to business activities) or any or all
-legal proceedings instituted against the Licensee by a third party,
-shall constitute consequential loss and shall not provide entitlement to
-any or all compensation from the Licensor.
-
-
-    Article 9 - WARRANTY
-
-9.1 The Licensee acknowledges that the scientific and technical
-state-of-the-art when the Software was distributed did not enable all
-possible uses to be tested and verified, nor for the presence of
-possible defects to be detected. In this respect, the Licensee's
-attention has been drawn to the risks associated with loading, using,
-modifying and/or developing and reproducing the Software which are
-reserved for experienced users.
-
-The Licensee shall be responsible for verifying, by any or all means,
-the suitability of the product for its requirements, its good working
-order, and for ensuring that it shall not cause damage to either persons
-or properties.
-
-9.2 The Licensor hereby represents, in good faith, that it is entitled
-to grant all the rights over the Software (including in particular the
-rights set forth in Article 5).
-
-9.3 The Licensee acknowledges that the Software is supplied "as is" by
-the Licensor without any other express or tacit warranty, other than
-that provided for in Article 9.2 and, in particular, without any warranty 
-as to its commercial value, its secured, safe, innovative or relevant
-nature.
-
-Specifically, the Licensor does not warrant that the Software is free
-from any error, that it will operate without interruption, that it will
-be compatible with the Licensee's own equipment and software
-configuration, nor that it will meet the Licensee's requirements.
-
-9.4 The Licensor does not either expressly or tacitly warrant that the
-Software does not infringe any third party intellectual property right
-relating to a patent, software or any other property right. Therefore,
-the Licensor disclaims any and all liability towards the Licensee
-arising out of any or all proceedings for infringement that may be
-instituted in respect of the use, modification and redistribution of the
-Software. Nevertheless, should such proceedings be instituted against
-the Licensee, the Licensor shall provide it with technical and legal
-assistance for its defense. Such technical and legal assistance shall be
-decided on a case-by-case basis between the relevant Licensor and the
-Licensee pursuant to a memorandum of understanding. The Licensor
-disclaims any and all liability as regards the Licensee's use of the
-name of the Software. No warranty is given as regards the existence of
-prior rights over the name of the Software or as regards the existence
-of a trademark.
-
-
-    Article 10 - TERMINATION
-
-10.1 In the event of a breach by the Licensee of its obligations
-hereunder, the Licensor may automatically terminate this Agreement
-thirty (30) days after notice has been sent to the Licensee and has
-remained ineffective.
-
-10.2 A Licensee whose Agreement is terminated shall no longer be
-authorized to use, modify or distribute the Software. However, any
-licenses that it may have granted prior to termination of the Agreement
-shall remain valid subject to their having been granted in compliance
-with the terms and conditions hereof.
-
-
-    Article 11 - MISCELLANEOUS
-
-
-      11.1 EXCUSABLE EVENTS
-
-Neither Party shall be liable for any or all delay, or failure to
-perform the Agreement, that may be attributable to an event of force
-majeure, an act of God or an outside cause, such as defective
-functioning or interruptions of the electricity or telecommunications
-networks, network paralysis following a virus attack, intervention by
-government authorities, natural disasters, water damage, earthquakes,
-fire, explosions, strikes and labor unrest, war, etc.
-
-11.2 Any failure by either Party, on one or more occasions, to invoke
-one or more of the provisions hereof, shall under no circumstances be
-interpreted as being a waiver by the interested Party of its right to
-invoke said provision(s) subsequently.
-
-11.3 The Agreement cancels and replaces any or all previous agreements,
-whether written or oral, between the Parties and having the same
-purpose, and constitutes the entirety of the agreement between said
-Parties concerning said purpose. No supplement or modification to the
-terms and conditions hereof shall be effective as between the Parties
-unless it is made in writing and signed by their duly authorized
-representatives.
-
-11.4 In the event that one or more of the provisions hereof were to
-conflict with a current or future applicable act or legislative text,
-said act or legislative text shall prevail, and the Parties shall make
-the necessary amendments so as to comply with said act or legislative
-text. All other provisions shall remain effective. Similarly, invalidity
-of a provision of the Agreement, for any reason whatsoever, shall not
-cause the Agreement as a whole to be invalid.
-
-
-      11.5 LANGUAGE
-
-The Agreement is drafted in both French and English and both versions
-are deemed authentic.
-
-
-    Article 12 - NEW VERSIONS OF THE AGREEMENT
-
-12.1 Any person is authorized to duplicate and distribute copies of this
-Agreement.
-
-12.2 So as to ensure coherence, the wording of this Agreement is
-protected and may only be modified by the authors of the License, who
-reserve the right to periodically publish updates or new versions of the
-Agreement, each with a separate number. These subsequent versions may
-address new issues encountered by Free Software.
-
-12.3 Any Software distributed under a given version of the Agreement may
-only be subsequently distributed under the same version of the Agreement
-or a subsequent version, subject to the provisions of Article 5.3.4.
-
-
-    Article 13 - GOVERNING LAW AND JURISDICTION
-
-13.1 The Agreement is governed by French law. The Parties agree to
-endeavor to seek an amicable solution to any disagreements or disputes
-that may arise during the performance of the Agreement.
-
-13.2 Failing an amicable solution within two (2) months as from their
-occurrence, and unless emergency proceedings are necessary, the
-disagreements or disputes shall be referred to the Paris Courts having
-jurisdiction, by the more diligent Party.
-
-
-Version 2.0 dated 2006-09-05.
-
diff --git a/ChangeLog b/ChangeLog
index 6d350f2..246a761 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,45 @@
-31/03/15 -*- Version 1.1.0-1 -*-
-* Removed .all includes to enable compilation by homebrew.
+18/05/17 -*- Version 1.2.0 -*-
+
+13/04/17 Julien Dutheil
+* Possibility to allow for dots in maf alignments (treated as gaps)
+* VCF output can included non-variable sites (experimental)
+* Added support for tree-based filtering
+
+04/06/16 Julien Dutheil
+* Alignment filters now accept frequencies as maximum amount of gaps.
+
+23/06/16 Julien Dutheil
+* Possibility to count characters for a selection of species only.
+
+18/06/16 Julien Dutheil
+* Added call to external tree reconstruction program.
+
+26/04/16 Julien Dutheil
+* Added distance matrix output.
+* Added RemoveEmptySequences filter.
+
+09/02/16 Julien Dutheil
+* Features in BedGraph format are now supported.
+* New LiftOver filter.
+
+18/12/15 Julien Dutheil
+* SequenceStatistics can now write in compressed file.
+
+10/12/15 Julien Dutheil
+* Added PLINK export filter.
+
+22/11/15 Julien Dutheil
+* Fixed bug in FeatureFilter in case two features are exactly consecutive.
+
+20/10/15 Julien Dutheil
+* Added Tajima's pi to diversity statistics.
+
+13/01/15 Julien Dutheil
+* More options for OutputAlignments (output file names).
+
+09/01/15 Julien Dutheil
+* Add formatting options (sequence names) for trees and distance matrices.
+* ML parameter estimation outputs parameter names in terminal.
 
 26/09/14 -*- Version 1.1.0 -*-
 
diff --git a/INSTALL.txt b/INSTALL
similarity index 88%
rename from INSTALL.txt
rename to INSTALL
index 7f0d53a..8eccbf1 100644
--- a/INSTALL.txt
+++ b/INSTALL
@@ -1,7 +1,7 @@
 This software needs cmake >= 2.6 to build.
 
 The dependencies include:
-- Bio++ libraries: bpp-core, seq, phyls, seq-omics and phyl-omics
+- Bio++ libraries: bpp-core, seq, phyl, seq-omics and phyl-omics
 - The boost-iostreams library.
 
 After installing cmake, run it with the following command:
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..9cecc1d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  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
+them 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 prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  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.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  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.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     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
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    {one line to give the program's name and a brief idea of what it does.}
+    Copyright (C) {year}  {name of author}
+
+    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 3 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    {project}  Copyright (C) {year}  {fullname}
+    This program 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, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU 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.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/MafFilter/CMakeLists.txt b/MafFilter/CMakeLists.txt
index 905e112..830805a 100644
--- a/MafFilter/CMakeLists.txt
+++ b/MafFilter/CMakeLists.txt
@@ -2,12 +2,21 @@
 # Author: Julien Dutheil
 # Created: 27/04/2010
 
-ADD_EXECUTABLE(maffilter MafFilter.cpp OutputAsFeaturesMafIterator.cpp)
-TARGET_LINK_LIBRARIES(maffilter ${LIBS} ${Boost_LIBRARIES})
-SET_TARGET_PROPERTIES(maffilter PROPERTIES LINK_SEARCH_END_STATIC ${BUILD_STATIC})
-
-# Install progs
-INSTALL(TARGETS
+ADD_EXECUTABLE(maffilter MafFilter.cpp OutputAsFeaturesMafIterator.cpp SystemCallMafIterator.cpp TreeBuildingSystemCallMafIterator.cpp)
+set (maffilter-targets
   maffilter
-  DESTINATION bin)
+  )
+
+foreach (target ${maffilter-targets})
+  # Link (static or shared)
+  if (BUILD_STATIC)
+    target_link_libraries (${target} ${BPP_LIBS_STATIC})
+    target_link_libraries (${target} ${LIBS})
+    set_target_properties (${target} LINK_SEARCH_END_STATIC TRUE)
+  else (BUILD_STATIC)
+    target_link_libraries (${target} ${BPP_LIBS_SHARED})
+    target_link_libraries (${target} ${LIBS})
+  endif (BUILD_STATIC)
+endforeach (target)
 
+install (TARGETS ${maffilter-targets} DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/MafFilter/MafFilter.cpp b/MafFilter/MafFilter.cpp
index ac05d28..0d95720 100644
--- a/MafFilter/MafFilter.cpp
+++ b/MafFilter/MafFilter.cpp
@@ -45,6 +45,8 @@ knowledge of the CeCILL license and that you accept its terms.
 using namespace std;
 
 #include "OutputAsFeaturesMafIterator.h"
+#include "SystemCallMafIterator.h"
+#include "TreeBuildingSystemCallMafIterator.h"
 
 //From boost:
 #include <boost/iostreams/device/file.hpp>
@@ -63,49 +65,61 @@ using namespace boost::iostreams;
 #include <Bpp/Seq/SequenceWithQuality.h>
 #include <Bpp/Seq/Io/BppOSequenceStreamReaderFormat.h>
 #include <Bpp/Seq/Io/BppOAlignmentWriterFormat.h>
+#include <Bpp/Seq/Io/BppOAlignmentReaderFormat.h>
 #include <Bpp/Seq/Container/SiteContainerTools.h>
 
 // From bpp-seq-omics and bpp-phyl-omics:
 #include <Bpp/Seq/Io/Maf/MafParser.h>
-#include <Bpp/Seq/Io/Maf/OutputMafIterator.h>
 #include <Bpp/Seq/Io/Maf/SequenceStreamToMafIterator.h>
 #include <Bpp/Seq/Io/Maf/SequenceFilterMafIterator.h>
 #include <Bpp/Seq/Io/Maf/OrphanSequenceFilterMafIterator.h>
 #include <Bpp/Seq/Io/Maf/BlockMergerMafIterator.h>
-#include <Bpp/Seq/Io/Maf/ConcatenateMafIterator.h>
-#include <Bpp/Seq/Io/Maf/FullGapFilterMafIterator.h>
-#include <Bpp/Seq/Io/Maf/AlignmentFilterMafIterator.h>
-#include <Bpp/Seq/Io/Maf/EntropyFilterMafIterator.h>
-#include <Bpp/Seq/Io/Maf/MaskFilterMafIterator.h>
-#include <Bpp/Seq/Io/Maf/QualityFilterMafIterator.h>
-#include <Bpp/Seq/Io/Maf/FeatureFilterMafIterator.h>
 #include <Bpp/Seq/Io/Maf/BlockLengthMafIterator.h>
 #include <Bpp/Seq/Io/Maf/BlockSizeMafIterator.h>
 #include <Bpp/Seq/Io/Maf/ChromosomeMafIterator.h>
+#include <Bpp/Seq/Io/Maf/ConcatenateMafIterator.h>
+#include <Bpp/Seq/Io/Maf/RemoveEmptySequencesMafIterator.h>
 #include <Bpp/Seq/Io/Maf/DuplicateFilterMafIterator.h>
+#include <Bpp/Seq/Io/Maf/FeatureFilterMafIterator.h>
+#include <Bpp/Seq/Io/Maf/QualityFilterMafIterator.h>
+#include <Bpp/Seq/Io/Maf/MaskFilterMafIterator.h>
+#include <Bpp/Seq/Io/Maf/EntropyFilterMafIterator.h>
+#include <Bpp/Seq/Io/Maf/OutputMafIterator.h>
+#include <Bpp/Seq/Io/Maf/AlignmentFilterMafIterator.h>
+#include <Bpp/Seq/Io/Maf/PlinkOutputMafIterator.h>
+#include <Bpp/Seq/Io/Maf/SequenceLDhotOutputMafIterator.h>
+#include <Bpp/Seq/Io/Maf/CoordinateTranslatorMafIterator.h>
+#include <Bpp/Seq/Io/Maf/CoordinatesOutputMafIterator.h>
+#include <Bpp/Seq/Io/Maf/FullGapFilterMafIterator.h>
+#include <Bpp/Seq/Io/Maf/FilterTreeMafIterator.h>
+#include <Bpp/Seq/Io/Maf/OutputTreeMafIterator.h>
+#include <Bpp/Seq/Io/Maf/OutputAlignmentMafIterator.h>
+#include <Bpp/Seq/Io/Maf/OutputDistanceMatrixMafIterator.h>
+#include <Bpp/Seq/Io/Maf/VcfOutputMafIterator.h>
+#include <Bpp/Seq/Io/Maf/MsmcOutputMafIterator.h>
 #include <Bpp/Seq/Io/Maf/SequenceStatisticsMafIterator.h>
 #include <Bpp/Seq/Io/Maf/FeatureExtractorMafIterator.h>
 #include <Bpp/Seq/Io/Maf/WindowSplitMafIterator.h>
-#include <Bpp/Seq/Io/Maf/OutputAlignmentMafIterator.h>
-#include <Bpp/Seq/Io/Maf/CoordinatesOutputMafIterator.h>
-#include <Bpp/Seq/Io/Maf/VcfOutputMafIterator.h>
 #include <Bpp/Seq/Io/Maf/CountDistanceEstimationMafIterator.h>
 #include <Bpp/Seq/Io/Maf/MaximumLikelihoodDistanceEstimationMafIterator.h>
-#include <Bpp/Seq/Io/Maf/IterationListener.h>
-#include <Bpp/Seq/Io/Maf/CountClustersMafStatistics.h>
-#include <Bpp/Seq/Io/Maf/MaximumLikelihoodModelFitMafStatistics.h>
 #include <Bpp/Seq/Io/Maf/DistanceBasedPhylogenyReconstructionMafIterator.h>
 #include <Bpp/Seq/Io/Maf/TreeManipulationMafIterators.h>
-#include <Bpp/Seq/Io/Maf/OutputTreeMafIterator.h>
+#include <Bpp/Seq/Io/Maf/MafStatistics.h>
+#include <Bpp/Seq/Io/Maf/CountClustersMafStatistics.h>
+#include <Bpp/Seq/Io/Maf/MaximumLikelihoodModelFitMafStatistics.h>
+#include <Bpp/Seq/Io/Maf/IterationListener.h>
 #include <Bpp/Seq/Feature/Gff/GffFeatureReader.h>
 #include <Bpp/Seq/Feature/Gtf/GtfFeatureReader.h>
+#include <Bpp/Seq/Feature/Bed/BedGraphFeatureReader.h>
 
 // From bpp-phyl:
-#include <Bpp/Phyl/OptimizationTools.h>
+#include <Bpp/Phyl/Distance/DistanceEstimation.h>
 #include <Bpp/Phyl/Distance/NeighborJoining.h>
 #include <Bpp/Phyl/Distance/BioNJ.h>
 #include <Bpp/Phyl/Io/BppOSubstitutionModelFormat.h>
 #include <Bpp/Phyl/Io/BppORateDistributionFormat.h>
+#include <Bpp/Phyl/Io/BppOTreeReaderFormat.h>
+#include <Bpp/Phyl/OptimizationTools.h>
 #include <Bpp/Phyl/App/PhylogeneticsApplicationTools.h>
 
 using namespace bpp;
@@ -125,9 +139,9 @@ void help()
 int main(int args, char** argv)
 {
   cout << "******************************************************************" << endl;
-  cout << "*                  MAF Filter, version 1.1.0                     *" << endl;
+  cout << "*                  MAF Filter, version 1.2.1                     *" << endl;
   cout << "* Author: J. Dutheil                        Created on  10/09/10 *" << endl;
-  cout << "*                                           Last Modif. 26/09/14 *" << endl;
+  cout << "*                                           Last Modif. 09/06/17 *" << endl;
   cout << "******************************************************************" << endl;
   cout << endl;
 
@@ -145,6 +159,7 @@ int main(int args, char** argv)
     string inputFile = ApplicationTools::getAFilePath("input.file", maffilter.getParams(), true, true);
     string inputFormat = ApplicationTools::getStringParameter("input.format", maffilter.getParams(), "Maf", "", true, false);
     string compress = ApplicationTools::getStringParameter("input.file.compression", maffilter.getParams(), "none");
+    string inputDot = ApplicationTools::getStringParameter("input.dots", maffilter.getParams(), "error", "", true, false);
 
     filtering_istream stream;
     if (compress == "none") {
@@ -163,9 +178,23 @@ int main(int args, char** argv)
     StlOutputStream log(new ofstream(logFile.c_str(), ios::out));
 
     MafIterator* currentIterator;
+
     if (inputFormat == "Maf") {
-      currentIterator = new MafParser(&stream, true);
+      short dotOption = MafParser::DOT_ERROR;
+      if (inputDot == "as_gaps") {
+        ApplicationTools::displayResult("Maf 'dotted' alignment input", string("converted to gaps"));
+        dotOption = MafParser::DOT_ASGAP;
+      } else if (inputDot == "as_unresolved") {
+        ApplicationTools::displayResult("Maf 'dotted' alignment input", string("converted to unresolved"));
+        dotOption = MafParser::DOT_ASUNRES;
+      }
+
+      bool checkSize = ApplicationTools::getBooleanParameter("input.check_sequence_size", maffilter.getParams(), true, "", true, false);
+      if (!checkSize)
+        ApplicationTools::displayBooleanResult("Check size of sequences", false);
+      currentIterator = new MafParser(&stream, true, checkSize, dotOption);
     } else {
+      if (inputDot == "as_gaps") throw Exception("'dot_as_gaps' option only available with Maf input.");
       BppOSequenceStreamReaderFormat reader;
       ISequenceStream* seqStream = reader.read(inputFormat);
       map<string, string> cmdArgs(reader.getUnparsedArguments());
@@ -181,7 +210,7 @@ int main(int args, char** argv)
     vector<MafIterator*> its;
     its.push_back(currentIterator);
     vector<filtering_ostream*> ostreams;
-    for (unsigned int a = 0; a < actions.size(); a++) {
+    for (size_t a = 0; a < actions.size(); a++) {
       string cmdName;
       map<string, string> cmdArgs;
       KeyvalTools::parseProcedure(actions[a], cmdName, cmdArgs);
@@ -273,8 +302,11 @@ int main(int args, char** argv)
       // +---------------------+
       else if (cmdName == "Concatenate") {
         unsigned int minimumSize = ApplicationTools::getParameter<unsigned int>("minimum_size", cmdArgs, 0);
+        string ref = ApplicationTools::getStringParameter("ref_species", cmdArgs, "", "", true, 2);
         ApplicationTools::displayResult("-- Minimum final block size", minimumSize);
-        ConcatenateMafIterator* iterator = new ConcatenateMafIterator(currentIterator, minimumSize);
+        if (ref != "")
+          ApplicationTools::displayResult("-- Reference species", ref);
+        ConcatenateMafIterator* iterator = new ConcatenateMafIterator(currentIterator, minimumSize, ref);
         iterator->setLogStream(&log);
         iterator->setVerbose(verbose);
         currentIterator = iterator;
@@ -306,18 +338,31 @@ int main(int args, char** argv)
           throw Exception("At least one species should be provided for command 'AlnFilter'.");
         unsigned int ws = ApplicationTools::getParameter<unsigned int>("window.size", cmdArgs, 10);
         unsigned int st = ApplicationTools::getParameter<unsigned int>("window.step", cmdArgs, 5);
-        unsigned int gm = ApplicationTools::getParameter<unsigned int>("max.gap", cmdArgs, 0);
+        bool relative   = ApplicationTools::getBooleanParameter("relative", cmdArgs, false);
+        unsigned int gm = 0;
+        double rm = 0;
+        if (relative)
+          rm = ApplicationTools::getDoubleParameter("max.gap", cmdArgs, 0);
+        else
+          gm = ApplicationTools::getParameter<unsigned int>("max.gap", cmdArgs, 0);
         double em       = ApplicationTools::getParameter<double>("max.ent", cmdArgs, 0); //Default means no entropy threshold
         bool missingAsGap = ApplicationTools::getParameter<bool>("missing_as_gap", cmdArgs, false);
         string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, false, false);
         bool trash = outputFile == "none";
         ApplicationTools::displayResult("-- Window size", ws);
         ApplicationTools::displayResult("-- Window step", st);
-        ApplicationTools::displayResult("-- Max. gaps allowed in Window", gm);
+        if (relative)
+          ApplicationTools::displayResult("-- Max. gaps allowed in Window", TextTools::toString(rm * 100) + "%");
+        else 
+          ApplicationTools::displayResult("-- Max. gaps allowed in Window", gm);
         ApplicationTools::displayResult("-- Max. total entropy in Window", em);
         ApplicationTools::displayBooleanResult("-- Missing sequence replaced by gaps", missingAsGap);
         ApplicationTools::displayBooleanResult("-- Output removed blocks", !trash);
-        AlignmentFilterMafIterator* iterator = new AlignmentFilterMafIterator(currentIterator, species, ws, st, gm, em, !trash, missingAsGap);
+        AlignmentFilterMafIterator* iterator;
+        if (relative)
+          iterator = new AlignmentFilterMafIterator(currentIterator, species, ws, st, rm, em, !trash, missingAsGap);
+        else
+          iterator = new AlignmentFilterMafIterator(currentIterator, species, ws, st, gm, em, !trash, missingAsGap);
         iterator->setLogStream(&log);
         iterator->setVerbose(verbose);
         its.push_back(iterator);
@@ -365,18 +410,31 @@ int main(int args, char** argv)
           throw Exception("At least one species should be provided for command 'AlnFilter2'.");
         unsigned int ws = ApplicationTools::getParameter<unsigned int>("window.size", cmdArgs, 10);
         unsigned int st = ApplicationTools::getParameter<unsigned int>("window.step", cmdArgs, 5);
-        unsigned int gm = ApplicationTools::getParameter<unsigned int>("max.gap", cmdArgs, 0);
+        bool relative   = ApplicationTools::getBooleanParameter("relative", cmdArgs, false);
+        unsigned int gm = 0;
+        double rm = 0;
+        if (relative)
+          rm = ApplicationTools::getDoubleParameter("max.gap", cmdArgs, 0);
+        else
+          gm = ApplicationTools::getParameter<unsigned int>("max.gap", cmdArgs, 0);
         unsigned int pm = ApplicationTools::getParameter<unsigned int>("max.pos", cmdArgs, 0);
         bool missingAsGap = ApplicationTools::getParameter<bool>("missing_as_gap", cmdArgs, false);
         string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, false, false);
         bool trash = outputFile == "none";
         ApplicationTools::displayResult("-- Window size", ws);
         ApplicationTools::displayResult("-- Window step", st);
-        ApplicationTools::displayResult("-- Max. gaps allowed per position", gm);
+        if (relative)
+          ApplicationTools::displayResult("-- Max. gaps allowed per position", TextTools::toString(rm * 100) + "%");
+        else 
+          ApplicationTools::displayResult("-- Max. gaps allowed per position", gm);
         ApplicationTools::displayResult("-- Max. gap positions allowed", pm);
         ApplicationTools::displayBooleanResult("-- Missing sequence replaced by gaps", missingAsGap);
         ApplicationTools::displayBooleanResult("-- Output removed blocks", !trash);
-        AlignmentFilter2MafIterator* iterator = new AlignmentFilter2MafIterator(currentIterator, species, ws, st, gm, pm, !trash, missingAsGap);
+        AlignmentFilter2MafIterator* iterator;
+        if (relative)
+          iterator = new AlignmentFilter2MafIterator(currentIterator, species, ws, st, rm, pm, !trash, missingAsGap);
+        else
+          iterator = new AlignmentFilter2MafIterator(currentIterator, species, ws, st, gm, pm, !trash, missingAsGap);
         iterator->setLogStream(&log);
         iterator->setVerbose(verbose);
         its.push_back(iterator);
@@ -618,19 +676,21 @@ int main(int args, char** argv)
         } else
           throw Exception("Bad input incompression format: " + compress);
         featureStream.push(file_source(featureFile));
-        auto_ptr<FeatureReader> ftReader;
+        unique_ptr<FeatureReader> ftReader;
         SequenceFeatureSet featuresSet;
         if (featureFormat == "GFF") {
           ftReader.reset(new GffFeatureReader(featureStream));
         } else if (featureFormat == "GTF") {
           ftReader.reset(new GtfFeatureReader(featureStream));
-        } else
+        } else if (featureFormat == "BedGraph") {
+          ftReader.reset(new BedGraphFeatureReader(featureStream));
+         } else
           throw Exception("Unsupported feature format: " + featureFormat);
         if (featureType.size() == 1 && featureType[0] == "all")
           ftReader->getAllFeatures(featuresSet);
         else {
           for (size_t i = 0; i < featureType.size(); ++i) {
-            ApplicationTools::displayResult("-- Extract features of type", featureType[i]);
+            ApplicationTools::displayResult("-- Filter features of type", featureType[i]);
             ftReader->getFeaturesOfType(featureType[i], featuresSet);
           }
         }
@@ -744,6 +804,72 @@ int main(int args, char** argv)
       }
 
 
+      // +---------------------------+
+      // | Empty sequences filtering |
+      // +---------------------------+
+      else if (cmdName == "RemoveEmptySequences") {
+        bool unresolvedAsGaps = ApplicationTools::getBooleanParameter("unresolved_as_gaps", cmdArgs, "");
+        ApplicationTools::displayBooleanResult("-- Unresolved as gaps", unresolvedAsGaps);
+        RemoveEmptySequencesMafIterator* iterator = new RemoveEmptySequencesMafIterator(currentIterator, unresolvedAsGaps);
+        iterator->setLogStream(&log);
+        iterator->setVerbose(verbose);
+        currentIterator = iterator;
+        its.push_back(iterator);
+      }
+
+      
+      // +----------------+
+      // | Tree filtering |
+      // +----------------+
+      else if (cmdName == "TreeFilter") {
+        string treeProperty = ApplicationTools::getStringParameter("tree", cmdArgs, "none");
+        double maxBrLen = ApplicationTools::getDoubleParameter("max_brlen", cmdArgs, 0.1);
+        
+        ApplicationTools::displayResult("-- Max. branch length", maxBrLen);
+        string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, false, false);
+        bool trash = outputFile == "none";
+        FilterTreeMafIterator* iterator = new FilterTreeMafIterator(currentIterator, treeProperty, maxBrLen, !trash);
+        iterator->setLogStream(&log);
+        iterator->setVerbose(verbose);
+        its.push_back(iterator);
+
+        if (!trash) {
+          compress = ApplicationTools::getStringParameter("compression", cmdArgs, "none");
+          filtering_ostream* out = new filtering_ostream;
+          if (compress == "none") {
+          } else if (compress == "gzip") {
+            out->push(gzip_compressor());
+          } else if (compress == "zip") {
+            out->push(zlib_compressor());
+          } else if (compress == "bzip2") {
+            out->push(bzip2_compressor());
+          } else
+            throw Exception("Bad output compression format: " + compress);
+          out->push(file_sink(outputFile));
+          ostreams.push_back(out);
+          ApplicationTools::displayResult("-- File compression for removed blocks", compress);
+
+          //Now build an adaptor for retrieving the trashed blocks:
+          TrashIteratorAdapter* trashIt = new TrashIteratorAdapter(iterator);
+          //Add an output iterator:
+          OutputMafIterator* outIt = new OutputMafIterator(trashIt, out);
+          //And then synchronize the two iterators:
+          MafIteratorSynchronizer* syncIt = new MafIteratorSynchronizer(iterator, outIt);
+          //Returns last iterator:
+          currentIterator = syncIt;
+          //Keep track of all those iterators:
+          its.push_back(trashIt);
+          its.push_back(syncIt);
+        } else {
+          //We only get the remaining blocks here:
+          currentIterator = iterator;
+        }
+      }
+
+
+
+
+
       // +---------------------+
       // | Sequence statistics |
       // +---------------------+
@@ -768,7 +894,9 @@ int main(int args, char** argv)
           } else if (statName == "AlnScore") {
             mafStat = new AlignmentScoreMafStatistics();
           } else if (statName == "BlockCounts") {
-            mafStat = new CharacterCountsMafStatistics(&AlphabetTools::DNA_ALPHABET);
+            vector<string> species = ApplicationTools::getVectorParameter<string>("species", statArgs, ',', "", "", false, true);
+            string suffix = ApplicationTools::getStringParameter("suffix", statArgs, "");
+            mafStat = new CharacterCountsMafStatistics(&AlphabetTools::DNA_ALPHABET, species, suffix);
           } else if (statName == "PairwiseDivergence") {
             string sp1 = ApplicationTools::getStringParameter("species1", statArgs, "");
             string sp2 = ApplicationTools::getStringParameter("species2", statArgs, "");
@@ -808,23 +936,38 @@ int main(int args, char** argv)
             mafStat = new CountClustersMafStatistics(treeProperty, threshold);
             statDesc = " / " + treeProperty;
           } else if (statName == "ModelFit") {
-            SubstitutionModel* model = PhylogeneticsApplicationTools::getSubstitutionModel(&AlphabetTools::DNA_ALPHABET, 0, 0, statArgs, "", true, false);
-            ApplicationTools::displayResult("-- Substitution model", model->getName());
-            string freqDescription = ApplicationTools::getStringParameter("root_freq", statArgs, "None");
-            FrequenciesSet* rootFreqs = 0;
-            if (freqDescription != "None") {
-              rootFreqs = PhylogeneticsApplicationTools::getFrequenciesSet(
-                  &AlphabetTools::DNA_ALPHABET, 0, freqDescription, 0, vector<double>(), 0);
-              ApplicationTools::displayResult("-- Root frequencies", rootFreqs->getName());
+            unique_ptr<SubstitutionModel> model;
+            unique_ptr<SubstitutionModelSet> modelSet;
+            unique_ptr<FrequenciesSet> rootFreqs;
+
+            string modelType = ApplicationTools::getStringParameter("model_type", statArgs, "Homogeneous");
+            if (modelType == "Homogeneous") {
+              model.reset(PhylogeneticsApplicationTools::getSubstitutionModel(&AlphabetTools::DNA_ALPHABET, 0, 0, statArgs, "", true, true));
+              ApplicationTools::displayResult("-- Substitution model", model->getName());
+              string freqDescription = ApplicationTools::getStringParameter("root_freq", statArgs, "None");
+              if (freqDescription != "None") {
+                rootFreqs.reset(PhylogeneticsApplicationTools::getFrequenciesSet(
+                    &AlphabetTools::DNA_ALPHABET, 0, freqDescription, 0, vector<double>(), 0));
+                ApplicationTools::displayResult("-- Root frequencies", rootFreqs->getName());
+              }
+            } else if (modelType == "Nonhomogeneous") {
+              modelSet.reset(PhylogeneticsApplicationTools::getSubstitutionModelSet(&AlphabetTools::DNA_ALPHABET, 0, 0, statArgs, "", true, true));
+            } else {
+              throw Exception("Unknown model type: " + modelType + ". Must be either Homogeneous or Nonhomogeneous.");
             }
-            DiscreteDistribution* rDist = PhylogeneticsApplicationTools::getRateDistribution(statArgs, "", true, false);
+            
+            unique_ptr<DiscreteDistribution> rDist(PhylogeneticsApplicationTools::getRateDistribution(statArgs, "", true, false));
             ApplicationTools::displayResult("-- Rate distribution", rDist->getName());
             string treeProperty = ApplicationTools::getStringParameter("tree", statArgs, "none");
             vector<string> parametersOutput = ApplicationTools::getVectorParameter<string>("parameters_output", statArgs, ',', "");
             vector<string> fixedParametersNames = ApplicationTools::getVectorParameter<string>("fixed_parameters", statArgs, ',', "");
             ParameterList fixedParameters;
             if (fixedParametersNames.size() > 0) {
-              ParameterList parameters = model->getParameters();
+              ParameterList parameters;
+              if (modelSet.get())
+                parameters = modelSet->getParameters();
+              else
+                parameters = model->getParameters();
               parameters.addParameters(rDist->getParameters());
               fixedParameters = parameters.subList(fixedParametersNames);
             }
@@ -834,8 +977,23 @@ int main(int args, char** argv)
             ApplicationTools::displayResult("-- Max. frequency of gaps", propGapsToKeep);
             bool gapsAsUnresolved = ApplicationTools::getBooleanParameter("gaps_as_unresolved", statArgs, true);
             ApplicationTools::displayBooleanResult("-- Gaps as unresolved", gapsAsUnresolved);
-            mafStat = new MaximumLikelihoodModelFitMafStatistics(model, rDist, dynamic_cast<NucleotideFrequenciesSet*>(rootFreqs), treeProperty, parametersOutput,
-                fixedParameters, reestimateBrLen, propGapsToKeep, gapsAsUnresolved);
+            bool useClock = ApplicationTools::getBooleanParameter("global_clock", statArgs, false);
+            ApplicationTools::displayBooleanResult("-- Use a global molecular clock", useClock);
+            bool reparametrize = ApplicationTools::getBooleanParameter("reparametrize", statArgs, false);
+            ApplicationTools::displayBooleanResult("-- Reparametrization", reparametrize);
+            if (treeProperty == "none") {
+              unique_ptr<Tree> tree(PhylogeneticsApplicationTools::getTree(statArgs, "", "", true, false)); 
+              if (modelSet.get()) {
+                mafStat = new MaximumLikelihoodModelFitMafStatistics(modelSet.release(), rDist.release(), tree.release(), parametersOutput,
+                    fixedParameters, reestimateBrLen, propGapsToKeep, gapsAsUnresolved, useClock, reparametrize);
+              } else {
+                mafStat = new MaximumLikelihoodModelFitMafStatistics(model.release(), rDist.release(), dynamic_cast<NucleotideFrequenciesSet*>(rootFreqs.release()), tree.release(), parametersOutput,
+                    fixedParameters, reestimateBrLen, propGapsToKeep, gapsAsUnresolved, useClock, reparametrize);
+              }
+            } else {
+              mafStat = new MaximumLikelihoodModelFitMafStatistics(model.release(), rDist.release(), dynamic_cast<NucleotideFrequenciesSet*>(rootFreqs.release()), treeProperty, parametersOutput,
+                  fixedParameters, reestimateBrLen, propGapsToKeep, gapsAsUnresolved, useClock, reparametrize);
+            }
           } else {
             throw Exception("Unknown statistic: " + statName);
           }
@@ -845,8 +1003,25 @@ int main(int args, char** argv)
 
         //Get output file:
         string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, true, false);
+        compress = ApplicationTools::getStringParameter("compression", cmdArgs, "none");
         ApplicationTools::displayResult("-- Output file", outputFile);
-        StlOutputStream* output = new StlOutputStream(new ofstream(outputFile.c_str(), ios::out));
+        filtering_ostream* out = new filtering_ostream;
+        if (compress == "none") {
+        } else if (compress == "gzip") {
+          out->push(gzip_compressor());
+        } else if (compress == "zip") {
+          out->push(zlib_compressor());
+        } else if (compress == "bzip2") {
+          out->push(bzip2_compressor());
+        } else
+          throw Exception("Bad output compression format: " + compress);
+        out->push(file_sink(outputFile));
+        ostreams.push_back(out);
+        //ostreams.push_back(out);
+        ApplicationTools::displayResult("-- File compression", compress);
+        //StlOutputStream* output = new StlOutputStream(new ofstream(outputFile.c_str(), ios::out));
+        StlOutputStream* output = new StlOutputStream(out);
+
         SequenceStatisticsMafIterator* iterator = new SequenceStatisticsMafIterator(currentIterator, statistics);
         
         if (cmdArgs.find("reference") != cmdArgs.end()) {
@@ -874,8 +1049,8 @@ int main(int args, char** argv)
         string featureFormat = ApplicationTools::getStringParameter("feature.format", cmdArgs, "GFF");
         vector<string> featureType = ApplicationTools::getVectorParameter<string>("feature.type", cmdArgs, ',', "all");
         if (featureType.size() == 0)
-          throw Exception("At least one feature should be provided for command 'FeatureFilter'.");
-        ApplicationTools::displayResult("-- Features to remove", featureFile + " (" + featureFormat + ")");
+          throw Exception("At least one feature should be provided for command 'ExtractFeature'.");
+        ApplicationTools::displayResult("-- Features to extract", featureFile + " (" + featureFormat + ")");
         ApplicationTools::displayResult("-- Features are for species", refSpecies);
         ApplicationTools::displayBooleanResult("-- Features are strand-aware", !ignoreStrand);
         ApplicationTools::displayBooleanResult("-- Extract incomplete features", !completeOnly);
@@ -891,13 +1066,15 @@ int main(int args, char** argv)
         } else
           throw Exception("Bad input incompression format: " + compress);
         featureStream.push(file_source(featureFile));
-        auto_ptr<FeatureReader> ftReader;
+        unique_ptr<FeatureReader> ftReader;
         SequenceFeatureSet featuresSet;
         if (featureFormat == "GFF") {
           ftReader.reset(new GffFeatureReader(featureStream));
         } else if (featureFormat == "GTF") {
           ftReader.reset(new GtfFeatureReader(featureStream));
-        } else
+        } else if (featureFormat == "BedGraph") {
+          ftReader.reset(new BedGraphFeatureReader(featureStream));
+         } else
           throw Exception("Unsupported feature format: " + featureFormat);
         if (featureType.size() == 1 && featureType[0] == "all")
           ftReader->getAllFeatures(featuresSet);
@@ -908,7 +1085,7 @@ int main(int args, char** argv)
           }
         }
         ApplicationTools::displayResult("-- Total number of features", featuresSet.getNumberOfFeatures());
-        FeatureExtractor* iterator = new FeatureExtractor(currentIterator, refSpecies, featuresSet, completeOnly, ignoreStrand);
+        FeatureExtractorMafIterator* iterator = new FeatureExtractorMafIterator(currentIterator, refSpecies, featuresSet, completeOnly, ignoreStrand);
         iterator->setLogStream(&log);
         iterator->setVerbose(verbose);
         its.push_back(iterator);
@@ -939,8 +1116,11 @@ int main(int args, char** argv)
           splitOption = WindowSplitMafIterator::ADJUST;
         else throw Exception("Unvalid alignment option for WindowSplit: " + splitOptionStr);
         ApplicationTools::displayResult("-- Alignment option", splitOptionStr);
+        bool keepSmallBlocks = ApplicationTools::getBooleanParameter("keep_small_blocks", cmdArgs, false);
+        if (splitOptionStr == "adjust")
+          ApplicationTools::displayBooleanResult("-- Keep small blocks", keepSmallBlocks);
 
-        WindowSplitMafIterator* iterator = new WindowSplitMafIterator(currentIterator, preferredSize, splitOption);
+        WindowSplitMafIterator* iterator = new WindowSplitMafIterator(currentIterator, preferredSize, splitOption, keepSmallBlocks);
         iterator->setLogStream(&log);
         currentIterator = iterator;
         its.push_back(iterator);
@@ -970,8 +1150,10 @@ int main(int args, char** argv)
           ApplicationTools::displayResult("-- Gap option", gapOption);
           bool unresolvedAsGap = ApplicationTools::getBooleanParameter("unresolved_as_gap", cmdArgs, "no");
           ApplicationTools::displayBooleanResult("-- Unresolved as gaps", unresolvedAsGap);
+          bool extendedSeqNames = ApplicationTools::getBooleanParameter("extended_names", cmdArgs, true);
+          ApplicationTools::displayBooleanResult("-- Use extended names in matrix", extendedSeqNames);
 
-          CountDistanceEstimationMafIterator* iterator = new CountDistanceEstimationMafIterator(currentIterator, gapOption, unresolvedAsGap);
+          CountDistanceEstimationMafIterator* iterator = new CountDistanceEstimationMafIterator(currentIterator, gapOption, unresolvedAsGap, extendedSeqNames);
           ApplicationTools::displayResult("-- Block-wise matrices are registered as", iterator->getPropertyName());
           iterator->setLogStream(&log);
           currentIterator = iterator;
@@ -995,11 +1177,14 @@ int main(int args, char** argv)
           ApplicationTools::displayResult("-- Max. frequency of gaps", propGapsToKeep);
           ApplicationTools::displayBooleanResult("-- Gaps as unresolved", gapsAsUnresolved);
           
+          bool extendedSeqNames = ApplicationTools::getBooleanParameter("extended_names", cmdArgs, true);
+          ApplicationTools::displayBooleanResult("-- Use extended names in matrix", extendedSeqNames);
+          
           BppOSubstitutionModelFormat modelReader(BppOSubstitutionModelFormat::DNA, false, false, true, true, 1);
-          auto_ptr<SubstitutionModel> model(modelReader.read(&AlphabetTools::DNA_ALPHABET, modelDesc, 0, true));
+          unique_ptr<SubstitutionModel> model(modelReader.read(&AlphabetTools::DNA_ALPHABET, modelDesc, 0, true));
           BppORateDistributionFormat rdistReader(true);
-          auto_ptr<DiscreteDistribution> rdist(rdistReader.read(rdistDesc, true)); 
-          auto_ptr<DistanceEstimation> distEst(new DistanceEstimation(model.release(), rdist.release()));
+          unique_ptr<DiscreteDistribution> rdist(rdistReader.read(rdistDesc, true)); 
+          unique_ptr<DistanceEstimation> distEst(new DistanceEstimation(model.release(), rdist.release()));
           
           OutputStream* profiler =
             (prPath == "none") ? 0 :
@@ -1021,7 +1206,8 @@ int main(int args, char** argv)
             ApplicationTools::displayResult("-- Optimization messages in", mhPath);
           distEst->getOptimizer()->setMessageHandler(messenger);
 
-          MaximumLikelihoodDistanceEstimationMafIterator* iterator = new MaximumLikelihoodDistanceEstimationMafIterator(currentIterator, distEst.release(), propGapsToKeep, gapsAsUnresolved, paramOpt);
+          MaximumLikelihoodDistanceEstimationMafIterator* iterator = new MaximumLikelihoodDistanceEstimationMafIterator(currentIterator,
+              distEst.release(), propGapsToKeep, gapsAsUnresolved, paramOpt, extendedSeqNames);
           ApplicationTools::displayResult("-- Block-wise matrices are registered as", iterator->getPropertyName());
           iterator->setLogStream(&log);
           iterator->setVerbose(verbose);
@@ -1065,6 +1251,40 @@ int main(int args, char** argv)
 
 
 
+      // +-----------------------------------+
+      // | External phylogeny reconstruction |
+      // +-----------------------------------+
+      else if (cmdName == "ExternalTreeBuilding") {
+        string name = ApplicationTools::getStringParameter("name", cmdArgs, "external");
+        
+        string programInputFile = ApplicationTools::getAFilePath("input.file", cmdArgs, true, false);
+        string programInputFormat = ApplicationTools::getStringParameter("input.format", cmdArgs, "Fasta");
+        BppOAlignmentWriterFormat bppoWriter(1);
+        OAlignment* alnWriter(bppoWriter.read(programInputFormat));
+
+        string programOutputFile = ApplicationTools::getAFilePath("output.file", cmdArgs, true, false);
+        string programOutputFormat = ApplicationTools::getStringParameter("output.format", cmdArgs, "Newick");
+        BppOTreeReaderFormat bppoReader(1);
+        ITree* treeReader(bppoReader.read(programOutputFormat));
+
+        string propertyName = ApplicationTools::getStringParameter("property_name", cmdArgs, "ExternalTree");
+        ApplicationTools::displayResult("-- Registering block-wise trees to", propertyName);
+
+        string command = ApplicationTools::getStringParameter("call", cmdArgs, "echo \"TODO: implement wrapper!\"");
+        
+        ApplicationTools::displayResult("-- External call (tree building)", name);
+        ApplicationTools::displayResult("   Command", command);
+
+        TreeBuildingSystemCallMafIterator* iterator = new TreeBuildingSystemCallMafIterator(currentIterator, alnWriter, programInputFile, treeReader, programOutputFile, command, propertyName);
+
+        iterator->setLogStream(&log);
+        currentIterator = iterator;
+        its.push_back(iterator);
+      }
+
+
+
+
       // +-------------------+
       // | Phylogeny rooting |
       // +-------------------+
@@ -1139,13 +1359,20 @@ int main(int args, char** argv)
         ApplicationTools::displayResult("-- Output alignment file" + string(multipleFiles ? "s" : ""), outputFile);
         bool mask = ApplicationTools::getBooleanParameter("mask", cmdArgs, true);
         ApplicationTools::displayBooleanResult("-- Output mask", mask);
+        bool coords = ApplicationTools::getBooleanParameter("coordinates", cmdArgs, true);
+        ApplicationTools::displayBooleanResult("-- Output coordinates", coords);
+        bool header = ApplicationTools::getBooleanParameter("ldhat_header", cmdArgs, false);
+        ApplicationTools::displayBooleanResult("-- Output header line", header);
+         string reference = ApplicationTools::getStringParameter("reference", cmdArgs, "", "", true, 1);
+        if (reference != "")
+          ApplicationTools::displayResult("-- Reference species", reference);
         
         OutputAlignmentMafIterator* iterator; 
         BppOAlignmentWriterFormat bppoWriter(1);
         string description = ApplicationTools::getStringParameter("format", cmdArgs, "Clustal");
         OAlignment* oAln = bppoWriter.read(description);
         if (multipleFiles) {
-          iterator = new OutputAlignmentMafIterator(currentIterator, outputFile, oAln, mask);
+          iterator = new OutputAlignmentMafIterator(currentIterator, outputFile, oAln, mask, coords, header, reference);
         } else {
           compress = ApplicationTools::getStringParameter("compression", cmdArgs, "none");
           filtering_ostream* out = new filtering_ostream;
@@ -1161,7 +1388,7 @@ int main(int args, char** argv)
           out->push(file_sink(outputFile));
           ostreams.push_back(out);
           ApplicationTools::displayResult("-- File compression", compress);
-          iterator = new OutputAlignmentMafIterator(currentIterator, out, oAln, mask);
+          iterator = new OutputAlignmentMafIterator(currentIterator, out, oAln, mask, coords, header, reference);
         }
         currentIterator = iterator;
         its.push_back(iterator);
@@ -1231,7 +1458,126 @@ int main(int args, char** argv)
         for (size_t i = 0; i < genotypes.size(); ++i) {
           ApplicationTools::displayResult("-- Adding genotype info for", genotypes[i]);
         }
-        VcfOutputMafIterator* iterator = new VcfOutputMafIterator(currentIterator, out, reference, genotypes);
+        
+        bool outputAll = ApplicationTools::getBooleanParameter("all", cmdArgs, false);
+        ApplicationTools::displayBooleanResult("-- Output non-variable positions", outputAll);
+
+        VcfOutputMafIterator* iterator = new VcfOutputMafIterator(currentIterator, out, reference, genotypes, outputAll);
+
+        iterator->setLogStream(&log);
+        iterator->setVerbose(verbose);
+        currentIterator = iterator;
+        its.push_back(iterator);
+      }
+
+
+
+      // +-------------+
+      // | MSMC output |
+      // +-------------+
+      else if (cmdName == "MsmcOutput") {
+        string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, true, false);
+        compress = ApplicationTools::getStringParameter("compression", cmdArgs, "none");
+        ApplicationTools::displayResult("-- Output file", outputFile);
+        filtering_ostream* out = new filtering_ostream;
+        if (compress == "none") {
+        } else if (compress == "gzip") {
+          out->push(gzip_compressor());
+        } else if (compress == "zip") {
+          out->push(zlib_compressor());
+        } else if (compress == "bzip2") {
+          out->push(bzip2_compressor());
+        } else
+          throw Exception("Bad output compression format: " + compress);
+        out->push(file_sink(outputFile));
+        ostreams.push_back(out);
+        ApplicationTools::displayResult("-- File compression", compress);
+
+        string reference = ApplicationTools::getStringParameter("reference", cmdArgs, "");
+        if (reference == "")
+          throw Exception("A reference sequence should be provided for filter 'MsmcOutput'.");
+        ApplicationTools::displayResult("-- Reference sequence", reference);
+        
+        vector<string> species = ApplicationTools::getVectorParameter<string>("genotypes", cmdArgs, ',', "");
+        if (species.size() < 2)
+          throw Exception("MsmcOutput: at least two genomes are necessary to call SNPs.");
+        MsmcOutputMafIterator* iterator = new MsmcOutputMafIterator(currentIterator, out, species, reference);
+
+        iterator->setLogStream(&log);
+        iterator->setVerbose(verbose);
+        currentIterator = iterator;
+        its.push_back(iterator);
+      }
+
+
+
+      // +--------------+
+      // | PLINK output |
+      // +--------------+
+      else if (cmdName == "PlinkOutput") {
+        string outputPedFile = ApplicationTools::getAFilePath("ped_file", cmdArgs, true, false);
+        string outputMapFile = ApplicationTools::getAFilePath("map_file", cmdArgs, true, false);
+        compress = ApplicationTools::getStringParameter("compression", cmdArgs, "none");
+        ApplicationTools::displayResult("-- Output Ped file", outputPedFile);
+        ApplicationTools::displayResult("-- Output Map file", outputMapFile);
+        filtering_ostream* outPed = new filtering_ostream;
+        filtering_ostream* outMap = new filtering_ostream;
+        if (compress == "none") {
+        } else if (compress == "gzip") {
+          outPed->push(gzip_compressor());
+          outMap->push(gzip_compressor());
+        } else if (compress == "zip") {
+          outPed->push(zlib_compressor());
+          outMap->push(zlib_compressor());
+        } else if (compress == "bzip2") {
+          outPed->push(bzip2_compressor());
+          outMap->push(bzip2_compressor());
+        } else
+          throw Exception("Bad output compression format: " + compress);
+        outPed->push(file_sink(outputPedFile));
+        outMap->push(file_sink(outputMapFile));
+        ostreams.push_back(outPed);
+        ostreams.push_back(outMap);
+        ApplicationTools::displayResult("-- File compression", compress);
+
+        string reference = ApplicationTools::getStringParameter("reference", cmdArgs, "");
+        if (reference == "")
+          throw Exception("A reference sequence should be provided for filter 'PlinkOutput'.");
+        ApplicationTools::displayResult("-- Reference sequence", reference);
+        
+        bool map3 = ApplicationTools::getBooleanParameter("map3", cmdArgs, false);
+        ApplicationTools::displayBooleanResult("-- Ouput map3 file", map3);
+
+        vector<string> species = ApplicationTools::getVectorParameter<string>("genotypes", cmdArgs, ',', "");
+        if (species.size() < 2)
+          throw Exception("PlinkOutput: at least two genomes are necessary to call SNPs.");
+        PlinkOutputMafIterator* iterator = new PlinkOutputMafIterator(currentIterator, outPed, outMap, species, reference, map3);
+
+        iterator->setLogStream(&log);
+        iterator->setVerbose(verbose);
+        currentIterator = iterator;
+        its.push_back(iterator);
+      }
+
+
+
+      // +----------------------+
+      // | SequenceLDhot output |
+      // +----------------------+
+      else if (cmdName == "SequenceLDhotOutput") {
+        string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, true, false);
+        ApplicationTools::displayResult("-- Output file", outputFile);
+
+        string reference = ApplicationTools::getStringParameter("reference", cmdArgs, "");
+        if (!TextTools::isEmpty(reference))
+          ApplicationTools::displayResult("-- Reference sequence", reference);
+        else
+          reference = "";
+        
+        bool completeOnly = ApplicationTools::getBooleanParameter("complete_only", cmdArgs, true);
+        ApplicationTools::displayBooleanResult("-- Use only complete sites", completeOnly);
+
+        SequenceLDhotOutputMafIterator* iterator = new SequenceLDhotOutputMafIterator(currentIterator, outputFile, completeOnly, reference);
 
         iterator->setLogStream(&log);
         iterator->setVerbose(verbose);
@@ -1267,10 +1613,13 @@ int main(int args, char** argv)
           throw Exception("At least one species should be provided for filter 'OutputCoordinates'.");
         ApplicationTools::displayResult("-- Output coordinates for", TextTools::toString(species.size()) + " species");
         
+        bool includeSrcSize = ApplicationTools::getBooleanParameter("output_src_size", cmdArgs, true);
+        ApplicationTools::displayBooleanResult("-- Output src size", includeSrcSize);
+        
         for (size_t i = 0; i < species.size(); ++i) {
           ApplicationTools::displayResult("-- Output coordinates for species", species[i]);
         }
-        CoordinatesOutputMafIterator* iterator = new CoordinatesOutputMafIterator(currentIterator, out, species);
+        CoordinatesOutputMafIterator* iterator = new CoordinatesOutputMafIterator(currentIterator, out, species, includeSrcSize);
 
         iterator->setLogStream(&log);
         iterator->setVerbose(verbose);
@@ -1281,6 +1630,72 @@ int main(int args, char** argv)
 
 
 
+      // +------------------------+
+      // | Coordinates conversion |
+      // +------------------------+
+      else if (cmdName == "LiftOver") {
+        //Input
+        string refSpecies    = ApplicationTools::getStringParameter("ref_species", cmdArgs, "none");
+        string targetSpecies = ApplicationTools::getStringParameter("target_species", cmdArgs, "none");
+        string featureFile   = ApplicationTools::getAFilePath("feature.file", cmdArgs, false, false);
+        string featureFormat = ApplicationTools::getStringParameter("feature.format", cmdArgs, "GFF");
+        ApplicationTools::displayResult("-- Features to lift over", featureFile + " (" + featureFormat + ")");
+        ApplicationTools::displayResult("-- from species", refSpecies);
+        ApplicationTools::displayResult("-- to species", targetSpecies);
+        compress = ApplicationTools::getStringParameter("feature.file.compression", cmdArgs, "none");
+        filtering_istream featureStream;
+        if (compress == "none") {
+        } else if (compress == "gzip") {
+          featureStream.push(gzip_decompressor());
+        } else if (compress == "zip") {
+          featureStream.push(zlib_decompressor());
+        } else if (compress == "bzip2") {
+          featureStream.push(bzip2_decompressor());
+        } else
+          throw Exception("Bad input incompression format: " + compress);
+        featureStream.push(file_source(featureFile));
+        unique_ptr<FeatureReader> ftReader;
+        SequenceFeatureSet featuresSet;
+        if (featureFormat == "GFF") {
+          ftReader.reset(new GffFeatureReader(featureStream));
+        } else if (featureFormat == "GTF") {
+          ftReader.reset(new GtfFeatureReader(featureStream));
+        } else if (featureFormat == "BedGraph") {
+          ftReader.reset(new BedGraphFeatureReader(featureStream));
+        } else
+          throw Exception("Unsupported feature format: " + featureFormat);
+        ftReader->getAllFeatures(featuresSet);
+        ApplicationTools::displayResult("-- Total number of features", featuresSet.getNumberOfFeatures());
+        
+        //Output
+        string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, true, false);
+        compress = ApplicationTools::getStringParameter("compression", cmdArgs, "none");
+        ApplicationTools::displayResult("-- Output file", outputFile);
+        filtering_ostream* out = new filtering_ostream;
+        if (compress == "none") {
+        } else if (compress == "gzip") {
+          out->push(gzip_compressor());
+        } else if (compress == "zip") {
+          out->push(zlib_compressor());
+        } else if (compress == "bzip2") {
+          out->push(bzip2_compressor());
+        } else
+          throw Exception("Bad output compression format: " + compress);
+        out->push(file_sink(outputFile));
+        ostreams.push_back(out);
+        ApplicationTools::displayResult("-- File compression", compress);
+        
+        //Iterator initialization:
+        CoordinateTranslatorMafIterator* iterator = new CoordinateTranslatorMafIterator(currentIterator, refSpecies, targetSpecies, featuresSet, *out);
+        iterator->setLogStream(&log);
+        iterator->setVerbose(verbose);
+        its.push_back(iterator);
+
+        currentIterator = iterator;
+      }
+
+
+
       // +--------------+
       // | Output trees |
       // +--------------+
@@ -1303,14 +1718,82 @@ int main(int args, char** argv)
         ApplicationTools::displayResult("-- File compression", compress);
         string treeProperty = ApplicationTools::getStringParameter("tree", cmdArgs, "none");
         ApplicationTools::displayResult("-- Tree to write", treeProperty);
-        OutputTreeMafIterator* iterator = new OutputTreeMafIterator(currentIterator, out, treeProperty);
+        bool stripNames = ApplicationTools::getBooleanParameter("strip_names", cmdArgs, false);
+        ApplicationTools::displayBooleanResult("-- Strip names", stripNames);
+
+        OutputTreeMafIterator* iterator = new OutputTreeMafIterator(currentIterator, out, treeProperty, !stripNames);
         currentIterator = iterator;
         its.push_back(iterator);
       }
     
+
+
+
+      // +--------------------------+
+      // | Output Distance matrices |
+      // +--------------------------+
+      else if (cmdName == "OutputDistanceMatrices") {
+        string outputFile = ApplicationTools::getAFilePath("file", cmdArgs, true, false);
+        compress = ApplicationTools::getStringParameter("compression", cmdArgs, "none");
+        ApplicationTools::displayResult("-- Output matrix file", outputFile);
+        filtering_ostream* out = new filtering_ostream;
+        if (compress == "none") {
+        } else if (compress == "gzip") {
+          out->push(gzip_compressor());
+        } else if (compress == "zip") {
+          out->push(zlib_compressor());
+        } else if (compress == "bzip2") {
+          out->push(bzip2_compressor());
+        } else
+          throw Exception("Bad output compression format: " + compress);
+        out->push(file_sink(outputFile));
+        ostreams.push_back(out);
+        ApplicationTools::displayResult("-- File compression", compress);
+        string distProperty = ApplicationTools::getStringParameter("distance", cmdArgs, "none");
+        ApplicationTools::displayResult("-- Matrix to write", distProperty);
+        bool stripNames = ApplicationTools::getBooleanParameter("strip_names", cmdArgs, false);
+        ApplicationTools::displayBooleanResult("-- Strip names", stripNames);
+
+        OutputDistanceMatrixMafIterator* iterator = new OutputDistanceMatrixMafIterator(currentIterator, out, distProperty, !stripNames);
+        currentIterator = iterator;
+        its.push_back(iterator);
+      }
+    
+
+
+
+      // +--------------------------+
+      // | External program wrapper |
+      // +--------------------------+
+      else if (cmdName == "SystemCall") {
+        string name = ApplicationTools::getStringParameter("name", cmdArgs, "external");
+
+        string programInputFile = ApplicationTools::getAFilePath("input.file", cmdArgs, true, false);
+        string programInputFormat = ApplicationTools::getStringParameter("input.format", cmdArgs, "Fasta");
+        BppOAlignmentWriterFormat bppoWriter(1);
+        OAlignment* alnWriter(bppoWriter.read(programInputFormat));
+
+        string programOutputFile = ApplicationTools::getAFilePath("output.file", cmdArgs, true, false);
+        string programOutputFormat = ApplicationTools::getStringParameter("output.format", cmdArgs, "Fasta");
+        BppOAlignmentReaderFormat bppoReader(1);
+        IAlignment* alnReader(bppoReader.read(programOutputFormat));
+
+        string command = ApplicationTools::getStringParameter("call", cmdArgs, "echo \"TODO: implement wrapper!\"");
+        
+        ApplicationTools::displayResult("-- External call", name);
+        ApplicationTools::displayResult("   Command", command);
+
+        SystemCallMafIterator* iterator = new SystemCallMafIterator(currentIterator, alnWriter, programInputFile, alnReader, programOutputFile, command);
+
+        iterator->setLogStream(&log);
+        iterator->setVerbose(verbose);
+        currentIterator = iterator;
+        its.push_back(iterator);
+      }
+
+
       else 
         throw Exception("Unknown filter: " + cmdName);
-
     }
 
     //Now loop over the last iterator and that's it!
diff --git a/MafFilter/SystemCallMafIterator.cpp b/MafFilter/SystemCallMafIterator.cpp
new file mode 100644
index 0000000..749afbb
--- /dev/null
+++ b/MafFilter/SystemCallMafIterator.cpp
@@ -0,0 +1,84 @@
+//
+// File: SystemCallMafIterator.cpp
+// Authors: Julien Dutheil
+// Created: Tue Sep 29 2015
+//
+
+/*
+Copyright or © or Copr. Julien Y. Dutheil, (2015)
+
+This software is a computer program whose purpose is to provide classes
+for sequences analysis.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#include "SystemCallMafIterator.h"
+
+using namespace bpp;
+using namespace std;
+
+MafBlock* SystemCallMafIterator::analyseCurrentBlock_() throw (Exception) {
+  currentBlock_ = iterator_->nextBlock();
+  if (! currentBlock_)
+    return 0;
+  unique_ptr<AlignedSequenceContainer> aln(currentBlock_->getAlignment().clone());
+  
+  //We translate sequence names to avoid compatibility issues
+  vector<string> names(aln->getNumberOfSequences());
+  for (size_t i = 0; i < names.size(); ++i) {
+    names[i] = "seq" + TextTools::toString(i);
+  }
+  aln->setSequencesNames(names);
+  
+  //Write sequences to file:
+  alnWriter_->writeAlignment(inputFile_, *aln, true);
+
+  //Call the external program:
+  int rc = system(call_.c_str());
+  if (rc) throw Exception("SystemCallMafIterator::analyseCurrentBlock_(). System call exited with non-zero status.");
+
+  //Then read and assign the realigned sequences:
+  unique_ptr<SiteContainer> result(alnReader_->readAlignment(outputFile_, &AlphabetTools::DNA_ALPHABET));
+  vector<MafSequence*> tmp;
+  for (size_t i = 0; i < currentBlock_->getNumberOfSequences(); ++i) {
+    MafSequence* mseq = currentBlock_->getSequence(i).cloneMeta();
+    //NB: we discard any putative score associated to this sequence.
+    string name = "seq" + TextTools::toString(i);
+    mseq->setContent(dynamic_cast<const BasicSequence&>(result->getSequence(name)).toString()); //NB shall we use getContent here?
+    tmp.push_back(mseq);
+  }
+  currentBlock_->getAlignment().clear();
+  for (size_t i = 0; i < tmp.size(); ++i) {
+    currentBlock_->getAlignment().addSequence(*tmp[i], false);
+    delete tmp[i];
+  }
+
+  //Done:
+  return currentBlock_;
+}
+
diff --git a/MafFilter/SystemCallMafIterator.h b/MafFilter/SystemCallMafIterator.h
new file mode 100644
index 0000000..472f5fb
--- /dev/null
+++ b/MafFilter/SystemCallMafIterator.h
@@ -0,0 +1,110 @@
+//
+// File: SystemCallMafIterator.h
+// Authors: Julien Dutheil
+// Created: Tue Sep 29 2015
+//
+
+/*
+Copyright or © or Copr. Julien Y. Dutheil, (2015)
+
+This software is a computer program whose purpose is to provide classes
+for sequences analysis.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _SYSTEMCALLMAFITERATOR_H_
+#define _SYSTEMCALLMAFITERATOR_H_
+
+#include <Bpp/Seq/Io/Maf/MafIterator.h>
+#include <Bpp/Seq/Io/ISequence.h>
+#include <Bpp/Seq/Io/OSequence.h>
+
+//From the STL:
+#include <iostream>
+#include <string>
+#include <memory>
+
+namespace bpp {
+
+/**
+ * @brief This iterator calls an external program on each block.
+ */
+class SystemCallMafIterator:
+  public AbstractFilterMafIterator
+{
+  private:
+    std::unique_ptr<OAlignment> alnWriter_;
+    std::string inputFile_;
+    std::unique_ptr<IAlignment> alnReader_;
+    std::string outputFile_;
+    std::string call_;
+
+  public:
+    SystemCallMafIterator(
+        MafIterator* iterator,
+        OAlignment* alnWriter,
+        const std::string& inputFile,
+        IAlignment* alnReader,
+        const std::string& outputFile,
+        const std::string& callCmd) :
+      AbstractFilterMafIterator(iterator),
+          alnWriter_(alnWriter),
+          inputFile_(inputFile),
+          alnReader_(alnReader),
+          outputFile_(outputFile),
+          call_(callCmd)
+    {}
+
+  private:
+    SystemCallMafIterator(const SystemCallMafIterator& iterator) :
+      AbstractFilterMafIterator(0),
+      alnWriter_(),
+      inputFile_(iterator.inputFile_),
+      alnReader_(),
+      outputFile_(iterator.outputFile_),
+      call_(iterator.call_)
+    {}
+    
+    SystemCallMafIterator& operator=(const SystemCallMafIterator& iterator)
+    {
+      inputFile_ = iterator.inputFile_;
+      outputFile_ = iterator.outputFile_;
+      call_ = iterator.call_;
+      return *this;
+    }
+
+
+  public:
+    MafBlock* analyseCurrentBlock_() throw (Exception);
+
+};
+
+} // namespace bpp.
+
+#endif //_SYSTEMCALLMAFITERATOR_H_
+
diff --git a/MafFilter/TreeBuildingSystemCallMafIterator.cpp b/MafFilter/TreeBuildingSystemCallMafIterator.cpp
new file mode 100644
index 0000000..952554b
--- /dev/null
+++ b/MafFilter/TreeBuildingSystemCallMafIterator.cpp
@@ -0,0 +1,82 @@
+//
+// File: TreeBuildingSystemCallMafIterator.cpp
+// Authors: Julien Dutheil
+// Created: Sat Jun 18 2016
+//
+
+/*
+Copyright or © or Copr. Julien Y. Dutheil, (2016)
+
+This software is a computer program whose purpose is to provide classes
+for sequences analysis.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#include "TreeBuildingSystemCallMafIterator.h"
+
+// From bpp-phyl
+#include "Bpp/Phyl/TreeTemplate.h"
+
+using namespace bpp;
+using namespace std;
+
+MafBlock* TreeBuildingSystemCallMafIterator::analyseCurrentBlock_() throw (Exception) {
+  currentBlock_ = iterator_->nextBlock();
+  if (! currentBlock_)
+    return 0;
+  unique_ptr<AlignedSequenceContainer> aln(currentBlock_->getAlignment().clone());
+  
+  //We translate sequence names to avoid compatibility issues
+  vector<string> names(aln->getNumberOfSequences());
+  map<string, string> nameIndex;
+  for (size_t i = 0; i < names.size(); ++i) {
+    names[i] = "seq" + TextTools::toString(i);
+    nameIndex[names[i]] = currentBlock_->getSequence(i).getName();
+  }
+  aln->setSequencesNames(names);
+  
+  //Write sequences to file:
+  alnWriter_->writeAlignment(inputFile_, *aln, true);
+
+  //Call the external program:
+  int rc = system(call_.c_str());
+  if (rc) throw Exception("TreeBuildingSystemCallMafIterator::analyseCurrentBlock_(). System call exited with non-zero status.");
+
+  //Then read the generated tree and assign sequence names:
+  unique_ptr< Tree > result(treeReader_->read(outputFile_));
+  unique_ptr< TreeTemplate<Node> > tree(new TreeTemplate<Node>(*result));
+  vector<Node*> leaves = tree->getLeaves();
+  for (size_t i = 0; i < leaves.size(); ++i) {
+    leaves[i]->setName(nameIndex[leaves[i]->getName()]);
+  }
+  currentBlock_->setProperty(propertyName_, tree.release());
+
+  //Done:
+  return currentBlock_;
+}
+
diff --git a/MafFilter/TreeBuildingSystemCallMafIterator.h b/MafFilter/TreeBuildingSystemCallMafIterator.h
new file mode 100644
index 0000000..e93a94a
--- /dev/null
+++ b/MafFilter/TreeBuildingSystemCallMafIterator.h
@@ -0,0 +1,115 @@
+//
+// File: TreeBuildingSystemCallMafIterator.h
+// Authors: Julien Dutheil
+// Created: Sat Jun 18 2016
+//
+
+/*
+Copyright or © or Copr. Julien Y. Dutheil, (2016)
+
+This software is a computer program whose purpose is to provide classes
+for sequences analysis.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef _TREEBUILDINGSYSTEMCALLMAFITERATOR_H_
+#define _TREEBUILDINGSYSTEMCALLMAFITERATOR_H_
+
+#include <Bpp/Seq/Io/Maf/MafIterator.h>
+#include <Bpp/Phyl/Io/IoTree.h>
+#include <Bpp/Seq/Io/OSequence.h>
+
+//From the STL:
+#include <iostream>
+#include <string>
+#include <memory>
+
+namespace bpp {
+
+/**
+ * @brief This iterator calls an external program on each block.
+ */
+class TreeBuildingSystemCallMafIterator:
+  public AbstractFilterMafIterator
+{
+  private:
+    std::unique_ptr<OAlignment> alnWriter_;
+    std::string inputFile_;
+    std::unique_ptr<ITree> treeReader_;
+    std::string outputFile_;
+    std::string call_;
+    std::string propertyName_;
+
+  public:
+    TreeBuildingSystemCallMafIterator(
+        MafIterator* iterator,
+        OAlignment* alnWriter,
+        const std::string& inputFile,
+        ITree* treeReader,
+        const std::string& outputFile,
+        const std::string& callCmd,
+        const std::string& propertyName) :
+      AbstractFilterMafIterator(iterator),
+          alnWriter_(alnWriter),
+          inputFile_(inputFile),
+          treeReader_(treeReader),
+          outputFile_(outputFile),
+          call_(callCmd),
+          propertyName_(propertyName)
+    {}
+
+  private:
+    TreeBuildingSystemCallMafIterator(const TreeBuildingSystemCallMafIterator& iterator) :
+      AbstractFilterMafIterator(0),
+      alnWriter_(),
+      inputFile_(iterator.inputFile_),
+      treeReader_(),
+      outputFile_(iterator.outputFile_),
+      call_(iterator.call_),
+      propertyName_(iterator.propertyName_)
+    {}
+    
+    TreeBuildingSystemCallMafIterator& operator=(const TreeBuildingSystemCallMafIterator& iterator)
+    {
+      inputFile_ = iterator.inputFile_;
+      outputFile_ = iterator.outputFile_;
+      call_ = iterator.call_;
+      propertyName_ = iterator.propertyName_;
+      return *this;
+    }
+
+
+  public:
+    MafBlock* analyseCurrentBlock_() throw (Exception);
+
+};
+
+} // namespace bpp.
+
+#endif //_TREEBUILDINGSYSTEMCALLMAFITERATOR_H_
+
diff --git a/buildBin.sh b/buildBin.sh
new file mode 100755
index 0000000..6fa30da
--- /dev/null
+++ b/buildBin.sh
@@ -0,0 +1,7 @@
+#! /bin/sh
+arch=`uname -m`
+version=1.1.99-1
+
+strip MafFilter/maffilter
+tar cvzf maffilter-${arch}-bin-static-${version}.tar.gz MafFilter/maffilter
+
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 82410f0..2260250 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,7 +1,75 @@
-# CMake script for GenomeTools
-# Author: Julien Dutheil
-# Created: 09/09/2012
+# CMake script for MafFilter
+# Authors:
+#   Julien Dutheil
+#   Francois Gindraud (2017)
+# Created: 22/08/2009
 
-IF(INFO)
-  INSTALL(FILES maffilter.info DESTINATION share/info)
-ENDIF(INFO)
+# Builds info, html, pdf doc.
+# Info doc is built and install as part of "all" if makeinfo is found.
+# Html doc is proposed as a "html" optional target if makeinfo is found.
+# Pdf doc is proposed as a "pdf" optional target if makeinfo AND texi2dvi are found.
+
+find_program (MAKEINFO NAMES makeinfo texi2any DOC "makeinfo doc generator program")
+if (NOT MAKEINFO)
+  message (STATUS "makeinfo program not found: 'info' and 'html' target disabled (builds info/html doc)")
+else (NOT MAKEINFO)
+  message (STATUS "Found makeinfo as '${MAKEINFO}': 'info' and 'html' target enabled (builds info/html doc)")
+
+  set (input ${CMAKE_CURRENT_SOURCE_DIR}/maffilter.texi)
+
+  # Build and install info page
+  set (output ${CMAKE_CURRENT_BINARY_DIR}/maffilter.info)
+  add_custom_command (
+    OUTPUT ${output}
+    COMMAND ${MAKEINFO} --no-split -o ${output} ${input}
+    DEPENDS ${input}
+    COMMENT "Generating info page"
+    VERBATIM
+    )
+
+  # Install, and have "info" built with "all" (install needs the file to be built)
+  if (NOT COMPRESS_BIN)
+    # Install uncompressed info page
+    install (FILES ${output} DESTINATION ${CMAKE_INSTALL_INFODIR})
+    add_custom_target (info ALL DEPENDS ${output})
+  else ()
+    # Compress and install compressed file
+    set (compressed_ouput ${output}.${COMPRESS_EXT})
+    add_custom_command (
+      OUTPUT ${compressed_ouput}
+      COMMAND ${COMPRESS_BIN} ${COMPRESS_ARGS} ${output} > ${compressed_ouput}
+      DEPENDS ${output}
+      COMMENT "Compressing info page"
+      VERBATIM
+      )
+    install (FILES ${compressed_ouput} DESTINATION ${CMAKE_INSTALL_INFODIR})
+    add_custom_target (info ALL DEPENDS ${compressed_ouput})
+  endif ()
+
+  # Also provide a "html" target that builds html doc (not installed, and not part of "all").
+  set (output ${CMAKE_CURRENT_BINARY_DIR}/maffilter.html)
+  set (makeinfo-css "http://www.w3.org/StyleSheets/Core/Steely")
+  add_custom_command (
+    OUTPUT ${output}
+    COMMAND ${MAKEINFO} --html --css-ref=${makeinfo-css} --no-split -o ${output} ${input}
+    DEPENDS ${input}
+    COMMENT "Generating html doc"
+    VERBATIM
+    )
+  add_custom_target (html DEPENDS ${output})
+
+  # Provide a "pdf" target that builds pdf doc (not installed, not part of "all").
+  find_program (TEXIDVI NAMES texi2dvi)
+  if (TEXIDVI)
+    message (STATUS "Found texi2dvi: 'pdf' target enabled (builds pdf doc)")
+    set (output ${CMAKE_CURRENT_BINARY_DIR}/maffilter.pdf)
+    add_custom_command (
+      OUTPUT ${output}
+      COMMAND ${MAKEINFO} --pdf --Xopt=--clean -o ${output} ${input}
+      DEPENDS ${input}
+      COMMENT "Generating pdf doc"
+      VERBATIM
+      )
+    add_custom_target (pdf DEPENDS ${output})
+  endif ()
+endif ()
diff --git a/doc/maffilter.texi b/doc/maffilter.texi
index 8ef78b4..90e6c8f 100644
--- a/doc/maffilter.texi
+++ b/doc/maffilter.texi
@@ -1,8 +1,8 @@
 \input texinfo   @c -*-texinfo-*-
 @c %**start of header
 @setfilename maffilter.info
- at settitle MafFilter Manual 1.1.0
- at c documentencoding UTF-8
+ at settitle MafFilter Manual 1.2.1
+ at c @documentencoding UTF-8
 @afourpaper
 @dircategory Science Biology Genetics
 @direntry
@@ -12,15 +12,15 @@
 
 
 @copying
-This is the manual of MafFilter, version 1.1.0.
+This is the manual of MafFilter, version 1.2.1.
 
-Copyright @copyright{} 2014 Julien Y. Dutheil
+Copyright @copyright{} 2017 Julien Y. Dutheil
 @end copying
 
 @titlepage
 @title MafFilter Manual
 @author Julien Dutheil
- at author @email{julien.dutheil@@univ-montp2.fr}
+ at author @email{dutheil@@evolbio.mpg.de}
 
 
 @c The following two commands start the copyright page.
@@ -37,89 +37,101 @@ Copyright @copyright{} 2014 Julien Y. Dutheil
 @top The MafFilter Manual
 
 @insertcopying
- at end ifnottex
 
 @menu
-* Introduction::                
-* Filters::                     
+* Introduction::
+* Filters::
 
 @detailmenu
  --- The Detailed Node Listing ---
 
 Introduction
 
-* Description::                 
-* Run::                         
-* General::                     
+* Description::
+* Run::
+* General::
 
 Filters
 
-* Extracting::                  
-* Cleaning::                    
-* Analyzing::                   
-* Exporting::                   
+* Extracting::
+* Cleaning::
+* Analyzing::
+* Exporting::
+* Miscelaneous::
 
 Extracting data
 
-* Subset::                      
-* SelectOrphans::               
-* Merge::                       
-* Concatenate::                 
-* ExtractFeature::              
-* SelectChr::                   
-* WindowSplit::                 
+* Subset::
+* SelectOrphans::
+* Merge::
+* Concatenate::
+* ExtractFeature::
+* SelectChr::
+* WindowSplit::
 
 Cleaning alignment blocks
 
-* MinBlockLength::              
-* MinBlockSize::                
-* XFullGap::                    
-* AlnFilter::                   
-* AlnFilter2::                  
-* EntropyFilter::               
-* MaskFilter::                  
-* QualFilter::                  
-* FeatureFilter::               
+* MinBlockLength::
+* MinBlockSize::
+* XFullGap::
+* RemoveEmptySequences::
+* AlnFilter::
+* AlnFilter2::
+* EntropyFilter::
+* MaskFilter::
+* QualFilter::
+* FeatureFilter::
 
 Statistical analysis
 
-* Descriptive::                 
-* Phylogenetics::               
+* Descriptive::
+* Phylogenetics::
 
 Arguments:
 
-* BlockSize::                   
-* BlockLength::                 
-* SequenceLength::              
-* AlnScore::                    
-* BlockCounts::                 
-* PairwiseDivergence::          
-* SiteStatistics::              
-* FourSpeciesSitePatternCounts::  
-* SiteFrequencySpectrum::       
-* PolymorphismStatistics::      
-* DiversityStatistics::         
-* CountClusters::               
-* ModelFit::                    
+* BlockSize::
+* BlockLength::
+* SequenceLength::
+* AlnScore::
+* BlockCounts::
+* PairwiseDivergence::
+* SiteStatistics::
+* FourSpeciesSitePatternCounts::
+* SiteFrequencySpectrum::
+* PolymorphismStatistics::
+* DiversityStatistics::
+* CountClusters::
+* ModelFit::
 
 Phylogenetics
 
-* DistanceEstimation::          
-* DistanceBasedPhylogeny::      
-* NewOutgroup::                 
-* DropSpecies::                 
+* DistanceEstimation::
+* DistanceBasedPhylogeny::
+* NewOutgroup::
+* DropSpecies::
+* TreeFilter::
 
 Exporting blocks and data
 
-* Output::                      
-* OutputAlignments::            
-* VcfOutput::                   
-* OutputCoordinates::           
-* OutputTrees::                 
+* Output::
+* OutputAlignments::
+* VcfOutput::
+* MsmcOutput::
+* PlinkOutput::
+* OutputCoordinates::
+* OutputTrees::
+* OutputDistanceMatrices::
+
+Miscelaneous filters
+
+* LiftOver::
+* SystemCall::
 
 @end detailmenu
 @end menu
 
+ at end ifnottex
+
 @c ------------------------------------------------------------------------------------------------------------------
 
 @node Introduction, Filters, Top, Top
@@ -140,9 +152,9 @@ This manual intends to provide an exhaustive description of the options used in
 
          
 @menu
-* Description::                 
-* Run::                         
-* General::                     
+* Description::
+* Run::
+* General::
 @end menu
 
 @node Description, Run, Introduction, Introduction
@@ -289,6 +301,13 @@ Fasta files can be compressed in the same way as MAF files.
 The sequence names are expected to be of the form Species:Chromosome:start:strand:length, with possible empty fields.
 Coordinates are expected to be 0-based (that is, the first nucleotide is position 0). However, passing the @command{zero_based=no} argument to the format name will assume that the first nucleotide is position 1.
 
+ at item input.dots=@{error|as_gaps|as_unresolved@}
+If set to @command{as_gaps}, dotted characters in sequences will be converted to gaps and treated as such in any further step of the analysis, including output to files. If set to @command{as_unresolved}, dots will be converted to 'N'.
+
+ at item input.check_sequence_size=@{boolean@}
+Tell if sequence sizes are consistent (default: true). An error will be returned in case of inconsistency.
+Desabling size check can be useful in combination with input.dots=as_gaps. In case of inconsistency, a warning will be displayed unless verbose is set to false.
+
 @item output.log=@{path@}
 The file where to write log messages.
 
@@ -306,23 +325,24 @@ The next section present all available filters and their corresponding arguments
 @c ------------------------------------------------------------------------------------------------------------------
 
 @menu
-* Extracting::                  
-* Cleaning::                    
-* Analyzing::                   
-* Exporting::                   
+* Extracting::
+* Cleaning::
+* Analyzing::
+* Exporting::
+* Miscelaneous::
 @end menu
 
 @node Extracting, Cleaning, Filters, Filters
 @section Extracting data
 
 @menu
-* Subset::                      
-* SelectOrphans::               
-* Merge::                       
-* Concatenate::                 
-* ExtractFeature::              
-* SelectChr::                   
-* WindowSplit::                 
+* Subset::
+* SelectOrphans::
+* Merge::
+* Concatenate::
+* ExtractFeature::
+* SelectChr::
+* WindowSplit::
 @end menu
 
 @c ------------------------------------------------------------------------------------------------------------------
@@ -468,7 +488,7 @@ The @command{Concatenate} filter fuses consecutive blocks until the concatenated
 @example
 maf.filter=                                 \
     [...],
-    Concatenate(minimum_size=10000),        \
+    Concatenate(minimum_size=10000, ref_species=Hsapiens), \
     [...]
 @end example
 @end cartouche
@@ -480,6 +500,9 @@ maf.filter=                                 \
 @item minimum_size=@{int@}
 The minimum size for the blocks to be reached.
 
+ at item ref_species=@{string@}
+If given, only blocks with identical chromosome tags in the reference species will be merged.
+
 @end table
 
 @c ------------------------------------------------------------------------------------------------------------------
@@ -495,7 +518,7 @@ The features to extract are typically provided via a GFF file.
 @cartouche
 @example
 maf.filter=                                 \
-    [...]z
+    [...]
     ExtractFeature(                         \
         ref_species=species1,               \
         feature.file=species1.gff3.gz,      \
@@ -522,8 +545,8 @@ The file where the features are described.
 @item feature.file.compression=@{none|gzip|zip|bzip2@}
 Compression format for the feature file.
 
- at item feature.format=@{GFF|GTF@}
-Format for the feature file, currently GFF (v3.0) or GTF only.
+ at item feature.format=@{GFF|GTF|BedGraph@}
+Format for the feature file, currently GFF (v3.0), GTF or BedGraph.
 
 @item feature.type=@{all|(list)@}
 Specifies which type of feature should be extracted from the feature file, if several are available.
@@ -587,7 +610,8 @@ maf.filter=                                 \
     [...],
     WindowSplit(                            \
         preferred_size=1000,                \
-        align=center),                      \
+        align=center,                       \
+        keep_small_blocks=no),              \
     [...]
 @end example
 @end cartouche
@@ -602,7 +626,12 @@ The preferred size for the output windows.
 @item align=@{ragged_left|ragged_right|center|adjust@}
 Specifies how to align windows on the block:
 
+ at item keep_small_blocks = @{boolean@}
+Tell if blocks with an original size smaller that the window size should be kept (and untouched).
+This option only works if the align option is set to adjust. The combination of "align=adjust" and "keep_small_blocks=yes" allows to ensure that blocks do not exceed a given size, without losing any data.
+
 @table @command
+
 @item ragged_left
 @verbatim
 Block   |----------------------------|
@@ -639,15 +668,16 @@ In the last case, the windows will have at least the specified size, but might b
 @c ------------------------------------------------------------------------------------------------------------------
 
 @menu
-* MinBlockLength::              
-* MinBlockSize::                
-* XFullGap::                    
-* AlnFilter::                   
-* AlnFilter2::                  
-* EntropyFilter::               
-* MaskFilter::                  
-* QualFilter::                  
-* FeatureFilter::               
+* MinBlockLength::
+* MinBlockSize::
+* XFullGap::
+* RemoveEmptySequences::
+* AlnFilter::
+* AlnFilter2::
+* EntropyFilter::
+* MaskFilter::
+* QualFilter::
+* FeatureFilter::
 @end menu
 
 @node MinBlockLength, MinBlockSize, Cleaning, Cleaning
@@ -704,7 +734,7 @@ The minimum size.
 
 @c ------------------------------------------------------------------------------------------------------------------
 
- at node XFullGap, AlnFilter, MinBlockSize, Cleaning
+ at node XFullGap, RemoveEmptySequences, MinBlockSize, Cleaning
 @subsection Exclude full gap columns
 
 Remove gap-only columns from blocks. This does not modify coordinates and might be necessary after a @command{Subset} filter.
@@ -732,7 +762,34 @@ A coma separated, within parentheses, list of species. Any column containing a g
 
 @c ------------------------------------------------------------------------------------------------------------------
 
- at node AlnFilter, AlnFilter2, XFullGap, Cleaning
+ at node RemoveEmptySequences, AlnFilter, XFullGap, Cleaning
+ at subsection Remove empty sequences
+
+The @command{RemoveEmptySequences} filter remove sequences containing only gap (or unresolved characters) in each block.
+
+ at heading Synopsis:
+
+ at cartouche
+ at example
+maf.filter=                                 \
+    [...],
+    RemoveEmptySequences(unresolved_as_gaps=yes),        \
+    [...]
+ at end example
+ at end cartouche
+
+ at heading Arguments:
+
+ at table @command
+
+ at item unresolved_as_gaps=@{boolean@}
+Tell if unresolved characters count as "empty" as well.
+
+ at end table
+
+ at c ------------------------------------------------------------------------------------------------------------------
+
+ at node AlnFilter, AlnFilter2, RemoveEmptySequences, Cleaning
 @subsection Alignment filtering
 
 Split alignment blocks by removing regions with ambiguous alignments.
@@ -754,6 +811,7 @@ maf.filter=                                 \
         max.gap=9,                          \
         max.ent=0.2,                        \
         missing_as_gap=yes,                 \
+        relative=no,                        \
         file=data.trash_aln.maf.gz,         \
         compression=gzip),                  \
     [...]
@@ -773,14 +831,17 @@ The width, in bp, of the sliding window.
 @item window.step=@{int>0@}
 The step by which the window is moved, in bp.
 
- at item max.gap=@{int>0@}
-The maximum number of gaps allowed in each window.
+ at item relative=@{boolean@}
+Tell if maximum amount of gap is relative (that is, as a proportion of the total amount of character in each window).
+
+ at item max.gap=@{int>0|1>double>0@}
+The maximum number of gaps allowed in each window (if relative is set to no), or the maximum proportion of gaps (if relative is set to yes)
 
 @item max.ent=@{float@}
 The maximum entropy allowed in each window.
 
 @item missing_as_gap=@{yes/no@}
-Tell if unresolved characters should be counted as gaps.
+Tell if missing sequences should be considered as gaps.
 
 @item file=@{none|@{path@}@}
 An optional file were removed alignment parts will be stored, in the MAF format.
@@ -819,6 +880,7 @@ maf.filter=                                 \
         window.step=1,                      \
         max.gap=1,                          \
         max.pos=1,                          \
+        relative=no,                        \
         missing_as_gap=yes,                 \
         file=data.trash_aln.maf.gz,         \
         compression=gzip),                  \
@@ -839,14 +901,17 @@ The width, in bp, of the sliding window.
 @item window.step=@{int>0@}
 The step by which the window is moved, in bp.
 
- at item max.gap=@{int>0@}
-The maximum number of gaps allowed in each site.
+ at item relative=@{boolean@}
+Tell if maximum amount of gap is relative (that is, as a proportion of the total amount of character in each site).
+
+ at item max.gap=@{int>0|1>double>0@}
+The maximum number of gaps allowed in each site (if relative is set to no), or the maximum proportion of gaps (if relative is set to yes)
 
 @item max.pos=@{int>0@}
 The maximum number of positions with gaps (``indel events'').
 
 @item missing_as_gap=@{yes/no@}
-Tell if unresolved characters should be counted as gaps.
+Tell if missing sequences should be considered as gaps.
 
 @item file=@{none|@{path@}@}
 An optional file were removed alignment parts will be stored, in the MAF format.
@@ -1060,8 +1125,8 @@ The file where the features are described.
 @item feature.file.compression=@{none|gzip|zip|bzip2@}
 Compression format for the feature file.
 
- at item feature.format=@{GFF|GTF@}
-Format for the feature file, currently GFF (v3.0) or GTF only.
+ at item feature.format=@{GFF|GTF|BedGraph@}
+Format for the feature file, currently GFF (v3.0), GTF or BedGraph.
 
 @item feature.type=@{all|(list)@}
 Specifies which type of feature should be extracted from the feature file, if several are available.
@@ -1087,8 +1152,8 @@ Compression format for output file (if file != none).
 @section Statistical analysis
 
 @menu
-* Descriptive::                 
-* Phylogenetics::               
+* Descriptive::
+* Phylogenetics::
 @end menu
 
 @node Descriptive, Phylogenetics, Analyzing, Analyzing
@@ -1114,7 +1179,8 @@ maf.filter=                                 \
             AlnScore,                       \
             BlockCounts),                   \
         ref_species=species1,               \
-        file=data.statistics.csv),          \
+        file=data.statistics.csv,           \
+        compression=none),                  \
     [...]
 @end example
 @end cartouche
@@ -1132,25 +1198,28 @@ The species to use to report block coordinates in the output file. For block whe
 @item file=@{path@}
 A file path for the output file.
 
+ at item compression=@{none|gzip|zip|bzip2@}
+Compression format for output file.
+
 @end table
 
 The statistics to compute take the form of functions (just like filters themselves), which can potentially take arguments.
 Here is the list of currently available statistical functions:
 
 @menu
-* BlockSize::                   
-* BlockLength::                 
-* SequenceLength::              
-* AlnScore::                    
-* BlockCounts::                 
-* PairwiseDivergence::          
-* SiteStatistics::              
-* FourSpeciesSitePatternCounts::  
-* SiteFrequencySpectrum::       
-* PolymorphismStatistics::      
-* DiversityStatistics::         
-* CountClusters::               
-* ModelFit::                    
+* BlockSize::
+* BlockLength::
+* SequenceLength::
+* AlnScore::
+* BlockCounts::
+* PairwiseDivergence::
+* SiteStatistics::
+* FourSpeciesSitePatternCounts::
+* SiteFrequencySpectrum::
+* PolymorphismStatistics::
+* DiversityStatistics::
+* CountClusters::
+* ModelFit::
 @end menu
 
 @node BlockSize, BlockLength, Descriptive, Descriptive
@@ -1204,7 +1273,15 @@ The @command{AlnScore} statistics reports the alignment score associated to the
 @subsubsection Character frequencies
 The @command{BlockCounts} statistics reports the count of each character found in the block.
 
-(No argument)
+Note: this statistics does not work in case of duplicated sequences (multiple hits from the same chromosome / scaffold / contig).
+
+ at heading Arguments:
+ at table @command
+ at item species=@{list@}
+A list of species to be considered in the counts calculations. If no species is given, all sequences are used.
+ at item suffix=@{string@}
+An (optional) suffix to append to the statistics name. Useful in case the statistics should be computed for several species independently.
+ at end table
 
 @node PairwiseDivergence, SiteStatistics, BlockCounts, Descriptive
 @subsubsection Pairwise divergence
@@ -1248,6 +1325,14 @@ Number of sites without gap,
 @item
 Number of complete sites (no gap, no unresolved character),
 @item
+Number of complete sites with only one state (constant sites),
+ at item
+Number of complete sites with only two states (biallelic sites),
+ at item
+Number of complete sites with only three states (triallelic sites),
+ at item
+Number of complete sites with all four states (quadriallelic sites),
+ at item
 Number of parsimony-informative sites.
 @end itemize
 The statistics are computed for a given subset of species (typically forming a ingroup).
@@ -1313,7 +1398,7 @@ First species to consider (resp. second, third and fourth).
 @node SiteFrequencySpectrum, PolymorphismStatistics, FourSpeciesSitePatternCounts, Descriptive
 @subsubsection Site frequency spectrum
 The @command{SiteFrequencySpectrum} computes the site frequency spectrum for each block.
-Only ``doubletons'' sites are considered, that is, positions in the alignment with only two states.
+Only positions in the alignment with only two states are considered.
 The proportions of doubletons are then computed by bins.
 Lets consider the following example with 7 sequences:
 @verbatim
@@ -1441,6 +1526,10 @@ Note that the ``species'' terminology relates to multispecies alignments, as ori
 Number of seggregating sites,
 @item
 Watterson's theta.
+ at item
+Tajima's pi (average pairwise dissimilarity).
+ at item
+Tajima's D.
 @end itemize
 
 @heading Synopsis:
@@ -1453,7 +1542,7 @@ maf.filter=                                   \
         statistics=(\                         \
             [...],                                                    
             DiversityStatistics(              \
-                ingroup=(samp1, samp2, samp3),\
+                ingroup=(samp1,samp2,samp3)), \
             [...]),                           \
         ref_species=samp1,                    \
         file=data.statistics.csv),            \
@@ -1555,11 +1644,17 @@ All nucleotide models can be used.
 @item rate_distribution=@{string@}
 The distribution for rates across sites. See the Bio++ Program Suite manual for all available distributions.
 
- at item root_freqs=@{None|Full|GC@}
+ at item root_freq=@{None|Full|GC@}
 Allow root frequencies to be different (non-stationary model). Root frequencies can be fully parametrized, or parametrized with GC content.
 
- at item tree=@{string@}
-The property name under which trees are stored for each block.
+ at item tree=@{string|none@}
+The property name under which trees are stored for each block. If set to ``none'', then an input file should be given.
+
+ at item tree.file=@{path@}[tree=none]
+Path for tree file, in case no property is set.
+
+ at item tree.format=@{Newick|Nhx@}[tree=none]
+Format for tree file, in case no property is set.
 
 @item parameters_output=@{list@}
 A list of parameter names to output as statistics.
@@ -1576,6 +1671,12 @@ The maximum proportion of gaps for a site to be included in the analysis.
 @item gaps_as_unresolved=@{yes/no@}
 Tell if remaining gaps should be converted to 'N' before likelihood computation. This should be 'yes' unless you specify a substitution model which explicitely allows for gaps.
 
+ at item global_clock=@{yes/no@}
+Assume a global clock for branch lengths.
+
+ at item reparametrize=@{yes/no@}
+Transform parameters to remove constraints (can improve optimization, but is usually slower).
+
 @end table
 
 @c ------------------------------------------------------------------------------------------------------------------
@@ -1586,10 +1687,11 @@ Tell if remaining gaps should be converted to 'N' before likelihood computation.
 @c ------------------------------------------------------------------------------------------------------------------
 
 @menu
-* DistanceEstimation::          
-* DistanceBasedPhylogeny::      
-* NewOutgroup::                 
-* DropSpecies::                 
+* DistanceEstimation::
+* DistanceBasedPhylogeny::
+* NewOutgroup::
+* DropSpecies::
+* TreeFilter::
 @end menu
 
 @node DistanceEstimation, DistanceBasedPhylogeny, Phylogenetics, Phylogenetics
@@ -1606,7 +1708,8 @@ maf.filter=                                 \
     DistanceEstimation(                     \
         method=count,                       \
         gap_option=no_double_gap,           \
-        unresolved_as_gap=no),               \
+        unresolved_as_gap=no,               \
+        extended_names=yes),                \
     [...]
 @end example
 or
@@ -1621,7 +1724,8 @@ maf.filter=                                 \
         max_freq_gaps=0.33,                 \
         gaps_as_unresolved=yes,             \
         profiler=none,                      \
-        message_handler=none),              \
+        message_handler=none,               \
+        extended_names=yes),                \
     [...]
 @end example
 @end cartouche
@@ -1651,6 +1755,8 @@ For each pairwise comparison, any gap-containing position is ignored. This is th
 @item unresolved_as_gap=@{yes|no@}
 Tell is unresolved characters should be treated as gaps (usually in order to be ignored).
 
+ at item extended_names=@{boolean@}
+Tell if sequence coordinates should be included in the sequence names stored in the output matrix.
 @end table
 
 Further arguments for the ML method:
@@ -1784,7 +1890,7 @@ A rooted tree.
 
 @c ------------------------------------------------------------------------------------------------------------------
 
- at node DropSpecies,  , NewOutgroup, Phylogenetics
+ at node DropSpecies, TreeFilter, NewOutgroup, Phylogenetics
 @subsubsection Remove a species from a tree
 
 The @command{DropSpecies} removes a leaf from a tree.
@@ -1822,19 +1928,63 @@ An edited tree.
 @end table
 
 @c ------------------------------------------------------------------------------------------------------------------
+
+ at node TreeFilter,  , DropSpecies, Phylogenetics
+ at subsubsection Filter blocks based on their associated trees
+
+The @command{TreeFilter} (experimental) filters blocks based on their associated trees. Currently, filter is only performed based on the branch lengths.
+
+ at heading Synopsis:
+
+ at cartouche
+ at example
+maf.filter=                                 \
+    [...],
+    TreeFilter(                             \
+        tree=BioNJ,                         \
+        max_brlen=0.01,                     \
+        file=data.trash_tree.maf.gz,        \
+        compression=gzip),                  \
+    [...]
+ at end example
+ at end cartouche
+
+ at heading Arguments:
+
+ at table @command
+
+ at item tree=@{string@}
+The tag name of the tree to analyse.
+
+ at item max_brlen=@{float>0@}
+Branch length threshold: any block with a tree containing at least one branch lenght longer than the given threshold will be filtered out.
+
+ at item file=@{none|@{path@}@}
+An optional file were removed alignment parts will be stored, in the MAF format.
+This can be helpful for visual inspection and fine tuning of the filter parameters.
+
+ at item compression=@{none|gzip|zip|bzip2@}
+Compression format for output file (if file != none).
+
+ at end table
+
+ at c ------------------------------------------------------------------------------------------------------------------
 @c ------------------------------------------------------------------------------------------------------------------
 @c ------------------------------------------------------------------------------------------------------------------
 @c ------------------------------------------------------------------------------------------------------------------
 @c ------------------------------------------------------------------------------------------------------------------
- at node Exporting,  , Analyzing, Filters
+ at node Exporting, Miscelaneous, Analyzing, Filters
 @section Exporting blocks and data
 
 @menu
-* Output::                      
-* OutputAlignments::            
-* VcfOutput::                   
-* OutputCoordinates::           
-* OutputTrees::                 
+* Output::
+* OutputAlignments::
+* VcfOutput::
+* MsmcOutput::
+* PlinkOutput::
+* OutputCoordinates::
+* OutputTrees::
+* OutputDistanceMatrices::
 @end menu
 
 @node Output, OutputAlignments, Exporting, Exporting
@@ -1876,7 +2026,7 @@ Tell if sequences should be masked (if a mask annotation is available), or if ma
 @subsection Write alignment blocks to an external alignment file.
 
 The @command{OutputAlignments} filter writes all blocks to an external alignment file, potentially losing some information such as coordinates and scores.
-Sequence names will be formated following the Ensembl convention.
+Sequence names will be formated following the Ensembl convention when coordinates are available.
 
 @heading Synopsis:
 
@@ -1888,7 +2038,8 @@ maf.filter=                                 \
         file=data.filtered.aln,             \
         compression=none,                   \
         format=Clustal,                     \
-        mask=no),                           \
+        mask=no,                            \
+        coordinates=yes),                   \
     [...]
 @end example
 @end cartouche
@@ -1898,6 +2049,7 @@ maf.filter=                                 \
 @table @command
 @item file=@{none|@{path@}@}
 A file path where to write alignment blocks. If the file name contains the %i code, one alignment file per block will be generated, where %i will be replaced by the block index.
+In addition to the %i special code, additional variables can be used (in combination with %i, in order to avoid putative identical file names): chromosome number (%c), begin (%b) and end (%e) of reference sequence.
 
 @item format=@{string@}
 One of the alignment format supported by Bio++ (this includes Fasta, Mase and Clustal, see the Bio++ Program suite reference manual for a complete list of formats and options).
@@ -1908,11 +2060,21 @@ Compression format for output file.
 @item mask=@{yes|no@}
 Tell if sequences should be masked (if a mask annotation is available), or if masking information should be ignored.
 
+ at item coordinates=@{yes|no@}
+Tell if coordinates of sequences should be written in the header of each sequence (followinf Ensembl syntax).
+If set to no, or if sequences have no coordinates, only the species name will be used as a sequence name.
+
+ at item ldhat_header=@{yes|no@}
+Tell if a header line should be added for each file, in order to be used with the LDhat convert program. This line contains the nimber of sequences, the sequence lengths, and the number 1 (for haploid).
+
+ at item reference=@{string@}
+The name of reference sequence, which will only be used when %c, %b or %e codes are used in file names. In case a block does not contain a sequence for the reference species, "ChrNA", "StartNA" and "StopNA" tags will be used.
+
 @end table
 
 @c ------------------------------------------------------------------------------------------------------------------
 
- at node VcfOutput, OutputCoordinates, OutputAlignments, Exporting
+ at node VcfOutput, MsmcOutput, OutputAlignments, Exporting
 @subsection Call SNPs from alignment blocks and export to VCF file
 
 The @command{VcfOutput} filter call SNPs from each block and output them to a VCF file.
@@ -1928,7 +2090,8 @@ maf.filter=                                 \
         file=snp.vcf.gz,                    \
         compression=gzip,                   \
         reference=Ref,                      \
-        genotypes=(sample1,sample2)),       \
+        genotypes=(sample1,sample2),        \
+        all=no),                            \
     [...]
 @end example
 @end cartouche
@@ -1947,14 +2110,112 @@ A species name corresponding to the sequence to use as reference.
 
 @item genotypes=@{list of species@}
 A list of species for which genotypes informations should be written. If not, void, a 'FORMAT' column will be added to the output, as well as oneextra column per species to genotype.
-If the species is not present in this particular, or if a N or Gap is present, adot ('.') will be written in the column.
+If the species is not present in this particular, or if a N or Gap is present, a dot ('.') will be written in the column.
 Please note that species should be unique in each block, otherwise an error will occur.
 
+ at item all=@{boolean@}
+If set to 'yes', also output non-variable positions in the VCF file.
+
 @end table
 
 @c ------------------------------------------------------------------------------------------------------------------
 
- at node OutputCoordinates, OutputTrees, VcfOutput, Exporting
+ at node MsmcOutput, PlinkOutput, VcfOutput, Exporting
+ at subsection Export segregating sites to MSMC format
+
+The @command{MsmcOutput} filter calls all segregating sites and export them to the MSMC format,
+to be used with the MSMC program @uref{https://github.com/stschiff/msmc} (Multiple Sequentially Markovian Coalescent).
+Sites with gap or unresolved characters are not called.
+
+ at heading Synopsis:
+
+ at cartouche
+ at example
+maf.filter=                                 \
+    [...],
+    MsmcOutput(                             \
+        file=snp.msmc,                      \
+        compression=none,                   \
+        reference=Ref,                      \
+        genotypes=(sample1,sample2)),       \
+    [...]
+ at end example
+ at end cartouche
+
+ at heading Arguments:
+
+ at table @command
+ at item file=@{none|@{path@}@}
+A file path for the output MSMC file.
+
+ at item compression=@{none|gzip|zip|bzip2@}
+Compression format for output file.
+
+ at item reference=@{species name@}
+A species name corresponding to the sequence to use as reference.
+
+ at item genotypes=@{list of species@}
+A list of species for which seggregating sites should be called. It might not contain the reference species, which is then only used for coordinates output.
+Blocks with do not contain all species will not be called, as well as block not contianing the reference species. Note that the alignment has to be projected
+againt the reference species, otherwise an error will be reported.
+
+ at end table
+
+ at c ------------------------------------------------------------------------------------------------------------------
+
+ at node PlinkOutput, OutputCoordinates, MsmcOutput, Exporting
+ at subsection Export segregating sites to PLINK format
+
+The @command{PlinkOutput} filter calls all biallelic segregating sites and export them to the PLINK format,
+creating on Ped file and one Map file.
+Sites with gap or unresolved characters are not called.
+
+ at heading Synopsis:
+
+ at cartouche
+ at example
+maf.filter=                                 \
+    [...],
+    PlinkOutput(                            \
+        ped_file=snp.ped,                   \
+        map_file=snp.map,                   \
+        compression=none,                   \
+        reference=Ref,                      \
+        genotypes=(sample1,sample2),        \
+        map3=no)                            \
+    [...]
+ at end example
+ at end cartouche
+
+ at heading Arguments:
+
+ at table @command
+ at item ped_file=@{none|@{path@}@}
+A file path for the output Ped file.
+
+ at item map_file=@{none|@{path@}@}
+A file path for the output Map file.
+
+ at item compression=@{none|gzip|zip|bzip2@}
+Compression format for output file.
+
+ at item reference=@{species name@}
+A species name corresponding to the sequence to use as reference.
+
+ at item genotypes=@{list of species@}
+A list of species for which seggregating sites should be called. It might not contain the reference species, which is then only used for coordinates output.
+Blocks with do not contain all species will not be called, as well as block not contianing the reference species. Note that the alignment has to be projected
+againt the reference species, otherwise an error will be reported.
+
+ at item map3=@{boolean@}
+Tell if genetic distance column should be ommitted in the Map file. The resulting file should be sued together with the --map3 option in PLINK.
+If set to no, then a 0 genetic distance is written.
+
+ at end table
+
+ at c ------------------------------------------------------------------------------------------------------------------
+
+ at node OutputCoordinates, OutputTrees, PlinkOutput, Exporting
 @subsection Output coordinates of a set of species for each block.
 
 The @command{OutputCoordinates} takes as input a list of species and output the coordinates of each of the corresponding sequences in each block.
@@ -1969,7 +2230,8 @@ maf.filter=                                 \
     OutputCoordinates(                      \
         file=coordinates.txt.gz,            \
         compression=gzip,                   \
-        species=(species1,species2))        \
+        species=(species1,species2),        \
+        output_src_size=yes)                \
     [...]
 @end example
 @end cartouche
@@ -1986,12 +2248,14 @@ Compression format for output file.
 @item species=@{list of species@}
 A list of species for which coodinates should be written.
 
+ at item output_src_size=@{boolean@}
+Tell if the size of source sequences should be output.
+
 @end table
 
 @c ------------------------------------------------------------------------------------------------------------------
 
-
- at node OutputTrees,  , OutputCoordinates, Exporting
+ at node OutputTrees, OutputDistanceMatrices, OutputCoordinates, Exporting
 @subsection Write trees to a file.
 
 The @command{OutputTrees} filter writes trees associated to blocks to a file, in the Newick format. All trees will be stored in the same file, one per line.
@@ -2022,10 +2286,167 @@ A file path where to write trees, in the Newick format.
 @item compression=@{none|gzip|zip|bzip2@}
 Compression format for output file.
 
+ at item strip_names=@{boolean@}
+Tell if leaf names should be stripped. If so, all text after the first dot will be deleted.
+This is useful to get rid of the sequence coordinates.
+The option will have no effect in case the names do not contain coordinates.
+
 @end table
 
 @c ------------------------------------------------------------------------------------------------------------------
 
+ at node OutputDistanceMatrices,  , OutputTrees, Exporting
+ at subsection Write distance matrices to a file.
+
+The @command{OutputDistanceMatrices} filter writes distance matrices associated to blocks to a file, in the Phylip format.
+All matrices will be stored in the same file, one after the other.
+
+ at heading Synopsis:
+
+ at cartouche
+ at example
+maf.filter=                                 \
+    [...],
+    OutputDistanceMatrices(                 \
+        distance=MLdistance,                \
+        file=data.distmat.ph,               \
+        compression=gzip),                  \
+    [...]
+ at end example
+ at end cartouche
+
+ at heading Arguments:
+
+ at table @command
+ at item distance=@{string@}
+The tag used to store previously computed distance matrices.
+
+ at item file=@{none|@{path@}@}
+A file path where to write distance matrices, in the Phylip format.
+
+ at item compression=@{none|gzip|zip|bzip2@}
+Compression format for output file.
+
+ at item strip_names=@{boolean@}
+Tell if sequence names should be stripped. If so, all text after the first dot will be deleted.
+This is useful to get rid of the sequence coordinates.
+The option will have no effect in case the names do not contain coordinates.
+
+ at end table
+
+ at c ------------------------------------------------------------------------------------------------------------------
+
+ at node Miscelaneous,  , Exporting, Filters
+ at section Miscelaneous filters
+
+ at menu
+* LiftOver::
+* SystemCall::
+ at end menu
+
+
+ at c ------------------------------------------------------------------------------------------------------------------
+
+ at node LiftOver, SystemCall, Miscelaneous, Miscelaneous
+ at subsection Convert coordinates from one genome to another
+
+The @command{LiftOver} mimmics the behavior of the famous UCSC liftover utility.
+Features are read from any supported format, and a convertion table is generated for all features included in the alignment.
+
+ at heading Synopsis:
+
+ at cartouche
+ at example
+maf.filter=                                 \
+    [...]
+    LiftOver(                               \
+        ref_species=species1,               \
+        target_species=species2,            \
+        feature.file=species1.gff3.gz,      \
+        feature.file.compression=gzip,      \
+        feature.format=GFF,                 \
+        file=sp1_to_sp2.tln,                \
+        compression=none),                  \
+    [...]
+ at end example
+ at end cartouche
+
+ at heading Arguments:
+
+ at table @command
+
+ at item ref_species=@{string@}
+The name of the species for which the coordinates of the features are provided.
+
+ at item target_species=@{string@}
+The name of the species to which the coordinates of the features should be converted.
+
+ at item feature.file=@{path@}
+The file where the features are described.
+
+ at item feature.file.compression=@{none|gzip|zip|bzip2@}
+Compression format for the feature file.
+
+ at item feature.format=@{GFF|GTF|BedGraph@}
+Format for the feature file, currently GFF (v3.0), GTF or BedGraph.
+
+ at item compression=@{none|gzip|zip|bzip2@}
+Compression format for output file.
+
+ at end table
+
+ at c ------------------------------------------------------------------------------------------------------------------
+
+ at node SystemCall,  , LiftOver, Miscelaneous
+ at subsection Call an external program on each block.
+
+The @command{SystemCall} filter runs an external program on each block.
+For each block, the alignment is written to a temporary file, whose name and format can be specified.
+This input file is then read by the external program. The called program is expected to generate results in the form of an alignment with the same sequence names, so that it can be read by maffilter.
+In most case, the external program will be a wrapper script.
+ at heading Synopsis:
+
+ at cartouche
+ at example
+maf.filter=                                 \
+    [...],
+    SystemCall(                             \
+        name=myextprog,                     \
+        input.file=tmp.fa,                  \
+        input.format=Fasta,                 \
+        call=myscript.sh,                   \
+        output.file=output.fa,              \
+        output.format=Fasta),               \
+    [...]
+ at end example
+ at end cartouche
+
+ at heading Arguments:
+
+ at table @command
+ at item name=@{string@}
+A label to use, might be useful in case several tools are called.
+
+ at item input.file=@{none|@{path@}@}
+A file path where to write the block alignment, to be used as input by the external program.
+
+ at item input.format=@{string@}
+Alignment format for input file.
+
+ at item output.file=@{none|@{path@}@}
+A file path where to read the processed block alignment, output by the external program.
+
+ at item output.format=@{string@}
+Alignment format for output file.
+
+ at item call=@{string@}
+The system call to run external program.
+
+ at end table
+
+
+ at c ------------------------------------------------------------------------------------------------------------------
+
 @c end of document
 
 @c @node Index,  , Reference, Top
diff --git a/examples/Gorilla/Compara.epo_5_catarrhini_hsap-projected.chr22.subset.nogap.cleaned_aln.maf.gz b/examples/Gorilla/Compara.epo_5_catarrhini_hsap-projected.chr22.subset.nogap.cleaned_aln.maf.gz
new file mode 100644
index 0000000..a92485e
Binary files /dev/null and b/examples/Gorilla/Compara.epo_5_catarrhini_hsap-projected.chr22.subset.nogap.cleaned_aln.maf.gz differ
diff --git a/examples/UCSC46ways/MafFilter.bpp b/examples/UCSC46ways/MafFilter.bpp
index 2667960..658c1d0 100755
--- a/examples/UCSC46ways/MafFilter.bpp
+++ b/examples/UCSC46ways/MafFilter.bpp
@@ -1,6 +1,6 @@
 CHR=1
 DATA=chr$(CHR)
-input.file=/mnt/dd3/jdutheil/Data/Genomes/UCSC_46ways/maf/$(DATA).maf.gz
+input.file=/mnt/data1/jdutheil/Data/Genomes/UCSC_46ways/maf/$(DATA).maf.gz
 input.file.compression=gzip
 input.format=Maf
 output.log=$(DATA).maffilter.log
diff --git a/examples/UCSC46ways/README b/examples/UCSC46ways/README
index 1dfd3ce..6a98292 100644
--- a/examples/UCSC46ways/README
+++ b/examples/UCSC46ways/README
@@ -1,4 +1,5 @@
 # Created on 13/11/12 by jdutheil
+# Last update 20/06/16 by jdutheil
 
 This example file parses the 46-ways vertebrate alignment from UCSC.
 The data are not included in this folder because of size.
diff --git a/examples/Ztritici/Mgraminicolav2.FrozenGeneCatalog20080910.gff.gz b/examples/Ztritici/Mgraminicolav2.FrozenGeneCatalog20080910.gff.gz
new file mode 100644
index 0000000..9056657
Binary files /dev/null and b/examples/Ztritici/Mgraminicolav2.FrozenGeneCatalog20080910.gff.gz differ
diff --git a/examples/Ztritici/tba_refIPO323.maf.gz b/examples/Ztritici/tba_refIPO323.maf.gz
new file mode 100644
index 0000000..709cb6b
Binary files /dev/null and b/examples/Ztritici/tba_refIPO323.maf.gz differ
diff --git a/maffilter.spec b/maffilter.spec
index c36925e..7656822 100644
--- a/maffilter.spec
+++ b/maffilter.spec
@@ -1,5 +1,5 @@
 %define _basename maffilter
-%define _version 1.1.0
+%define _version 1.2.1
 %define _release 1
 %define _prefix /usr
 
@@ -10,36 +10,41 @@ Version: %{_version}
 Release: %{_release}
 License: CECILL-2.0
 Vendor: The Bio++ Project
-Source: http://biopp.univ-montp2.fr/repos/sources/maffilter/%{_basename}-%{_version}.tar.gz
+Source: %{_basename}-%{_version}.tar.gz
 Summary: The Multiple Alignment Format file processor
 Group: Productivity/Scientific/Other
 
-Requires: libbpp-phyl-omics1 = 2.2.0
-Requires: libbpp-seq-omics1 = 2.2.0
-Requires: libbpp-phyl9 = 2.2.0
-Requires: libbpp-seq9 = 2.2.0
-Requires: libbpp-core2 = 2.2.0
+Requires: libbpp-phyl-omics2 = 2.3.1
+Requires: libbpp-seq-omics2 = 2.3.1
+Requires: libbpp-phyl11 = 2.3.1
+Requires: libbpp-seq11 = 2.3.1
+Requires: libbpp-core3 = 2.3.1
 Requires: zlib
-Requires: libbz2
 
 BuildRoot: %{_builddir}/%{_basename}-root
-BuildRequires: cmake >= 2.6.0
-BuildRequires: gcc-c++ >= 4.0.0
+BuildRequires: cmake >= 2.8.11
+BuildRequires: gcc-c++ >= 4.7.0
 BuildRequires: groff
 BuildRequires: texinfo >= 4.0.0
-BuildRequires: libbpp-core2 = 2.2.0
-BuildRequires: libbpp-core-devel = 2.2.0
-BuildRequires: libbpp-seq9 = 2.2.0
-BuildRequires: libbpp-seq-devel = 2.2.0
-BuildRequires: libbpp-phyl9 = 2.2.0
-BuildRequires: libbpp-phyl-devel = 2.2.0
-BuildRequires: libbpp-seq-omics1 = 2.2.0
-BuildRequires: libbpp-seq-omics-devel = 2.2.0
-BuildRequires: libbpp-phyl-omics1 = 2.2.0
-BuildRequires: libbpp-phyl-omics-devel = 2.2.0
+BuildRequires: libbpp-core3 = 2.3.1
+BuildRequires: libbpp-core-devel = 2.3.1
+BuildRequires: libbpp-seq11 = 2.3.1
+BuildRequires: libbpp-seq-devel = 2.3.1
+BuildRequires: libbpp-phyl11 = 2.3.1
+BuildRequires: libbpp-phyl-devel = 2.3.1
+BuildRequires: libbpp-seq-omics2 = 2.3.1
+BuildRequires: libbpp-seq-omics-devel = 2.3.1
+BuildRequires: libbpp-phyl-omics2 = 2.3.1
+BuildRequires: libbpp-phyl-omics-devel = 2.3.1
 BuildRequires: zlib-devel
-BuildRequires: libbz2-devel
 
+%if 0%{?fedora} >= 22
+Requires: bzip2-libs
+BuildRequires: bzip2-devel
+%else
+Requires: libbz2
+BuildRequires: libbz2-devel
+%endif
 
 AutoReq: yes
 AutoProv: yes
@@ -82,21 +87,10 @@ Many filters are available, from alignment cleaning to phylogeny reconstruction
 %setup -q
 
 %build
-CFLAGS="-I%{_prefix}/include $RPM_OPT_FLAGS"
-CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=%{_prefix}"
-if [ %{_lib} == 'lib64' ] ; then
-  CMAKE_FLAGS="$CMAKE_FLAGS -DLIB_SUFFIX=64"
-fi
-if [ %{zipext} == 'lzma' ] ; then
-  CMAKE_FLAGS="$CMAKE_FLAGS -DDOC_COMPRESS=lzma -DDOC_COMPRESS_EXT=lzma"
-fi
-if [ %{zipext} == 'xz' ] ; then
-  CMAKE_FLAGS="$CMAKE_FLAGS -DDOC_COMPRESS=xz -DDOC_COMPRESS_EXT=xz"
-fi
-
+CFLAGS="$RPM_OPT_FLAGS"
+CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=%{_prefix} -DCOMPRESS_PROGRAM=%{compress_program}"
 cmake $CMAKE_FLAGS .
 make
-make info
 
 %install
 make DESTDIR=$RPM_BUILD_ROOT install
@@ -110,11 +104,13 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-,root,root)
-%doc AUTHORS.txt COPYING.txt INSTALL.txt ChangeLog
+%doc AUTHORS LICENSE INSTALL ChangeLog
 %{_prefix}/bin/maffilter
 %{_prefix}/share/man/man1/maffilter.1.%{zipext}
 %{_prefix}/share/info/maffilter.info.%{zipext}
 
 %changelog
+* Fri Jun 09 2017 Julien Dutheil <dutheil at evolbio.mpg.de> 1.2.1-1
+* Wed May 24 2017 Julien Dutheil <dutheil at evolbio.mpg.de> 1.2.0-1
 * Fri Sep 26 2014 Julien Dutheil <julien.dutheil at univ-montp2.fr> 1.1.0-1
 - Initial spec file.
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
index dc7d0bb..3781d67 100644
--- a/man/CMakeLists.txt
+++ b/man/CMakeLists.txt
@@ -1,7 +1,42 @@
-# CMake script for GenomeTools
-# Author: Julien Dutheil
-# Created: 09/09/2012
+# CMake script for the CoMap package.
+# Authors:
+#   Julien Dutheil
+#   Francois gindraud (2017)
+# Created: 22/08/2009
 
-IF(MAN)
-  INSTALL(FILES maffilter.1.gz DESTINATION share/man/man1)
-ENDIF(MAN)
+# Build manpages.
+# In practice, they are just compressed from the text files using COMPRESS_PROGRAM
+# Manpages are built and installed as part of "all" if a COMPRESS_PROGRAM is found.
+
+# Take all manpages files in the directory
+file (GLOB manpage_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.1)
+
+if (NOT COMPRESS_BIN)
+  # Just install manpages from source
+  foreach (manpage_file ${manpage_files})
+    install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${manpage_file} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+  endforeach (manpage_file)
+else ()
+  # Create a list of manpage targets
+  set (manpage-targets)
+
+  foreach (manpage_file ${manpage_files})
+    # Compress manpage, install, add to manpage target list
+    set (input ${CMAKE_CURRENT_SOURCE_DIR}/${manpage_file})
+    set (output ${CMAKE_CURRENT_BINARY_DIR}/${manpage_file}.${COMPRESS_EXT})
+    add_custom_command (
+      OUTPUT ${output}
+      COMMAND ${COMPRESS_BIN} ${COMPRESS_ARGS} ${input} > ${output}
+      DEPENDS ${input}
+      COMMENT "Compressing manpage ${manpage_file}"
+      VERBATIM
+      )
+    install (FILES ${output} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+    list (APPEND manpage-targets ${output})
+    unset (input)
+    unset (output)
+  endforeach (manpage_file)
+
+  # Add target "man", built with "all" (needed because install will fail if not built).
+  add_custom_target (man ALL DEPENDS ${manpage-targets})
+endif ()
diff --git a/man/maffilter.1.txt b/man/maffilter.1
similarity index 90%
rename from man/maffilter.1.txt
rename to man/maffilter.1
index d2e2087..565bac0 100644
--- a/man/maffilter.1.txt
+++ b/man/maffilter.1
@@ -18,7 +18,7 @@ maffilter applies a series of post-processing filter to an input MAF file.
 
 .SH OPTIONS
 
-You should refer to 'info maffilter' or to the online manual of testnh for a complete list of available options.
+You should refer to 'info maffilter' or to the online manual of maffilter for a complete list of available options.
 
 .TP 5
 

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



More information about the debian-med-commit mailing list