Skip to content
Commits on Source (10)
......@@ -14,9 +14,9 @@
# Linux example usages:
#----------------------
# cmake <source_dir> (sequential version)
# cmake -DIQTREE_FLAGS="omp" <source_dir> (OpenMP version)
# cmake -DIQTREE_FLAGS="m32" <source_dir> (32-bit sequential version)
# cmake -DIQTREE_FLAGS="m32 omp" <source_dir> (32-bit OpenMP version)
# cmake <source_dir> (OpenMP version)
# cmake -DIQTREE_FLAGS="m32-single" <source_dir> (32-bit sequential version)
# cmake -DIQTREE_FLAGS="m32" <source_dir> (32-bit OpenMP version)
#
# To compile with CLANG on Linux:
# export CC=/usr/bin/clang
......@@ -26,18 +26,19 @@
#
# Mac OSX example usages:
#------------------------
# cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ <source_dir> (sequential version)
#
# To build OpenMP version one needs to download Clang version 3.7 or later (as of November 2015)
# Then assuming clang3.7 and clang++3.7 are the newly built compilers, then:
# cmake -DCMAKE_C_COMPILER=clang3.7 -DCMAKE_CXX_COMPILER=clang++3.7 -DIQTREE_FLAGS="omp" <source_dir> (OpenMP version)
# cmake -DCMAKE_C_COMPILER=clang3.7 -DCMAKE_CXX_COMPILER=clang++3.7 <source_dir> (OpenMP version)
#
# cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DIQTREE_FLAGS=single <source_dir> (sequential version)
#
# Compile OpenMP version: cmake -DIQTREE_FLAGS=omp ....
# Compile OpenMP version: cmake ....
# Compile 32-bit version: cmake -DIQTREE_FLAGS=m32 ....
# Compile static version: cmake -DIQTREE_FLAGS=static ....
# Compile static OpenMP version: cmake -DIQTREE_FLAGS="omp static" ....
# Compile static OpenMP version: cmake -DIQTREE_FLAGS="static" ....
#NOTE: Static linking with clang windows: make a symlink libgcc_eh.a to libgcc.a (administrator required)
# C:\TDM-GCC-64\lib\gcc\x86_64-w64-mingw32\5.1.0>mklink libgcc_eh.a libgcc.a
......@@ -49,8 +50,8 @@ project(iqtree)
add_definitions(-DIQ_TREE)
# The version number.
set (iqtree_VERSION_MAJOR 1)
set (iqtree_VERSION_MINOR 5)
set (iqtree_VERSION_PATCH "5")
set (iqtree_VERSION_MINOR 6)
set (iqtree_VERSION_PATCH "1")
set(BUILD_SHARED_LIBS OFF)
......@@ -153,7 +154,8 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
# use libc++ per default in MacOS
if (APPLE AND CMAKE_BUILD_TYPE MATCHES "Release")
if (APPLE)
SET(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
......@@ -252,9 +254,9 @@ endif()
# configure OpenMP/PThreads compilation
# change the executable name if compiled for OpenMP parallel version
##################################################################
if (IQTREE_FLAGS MATCHES "omp")
if (NOT IQTREE_FLAGS MATCHES "single")
message("OpenMP : Yes")
SET(EXE_SUFFIX "${EXE_SUFFIX}-omp")
#SET(EXE_SUFFIX "${EXE_SUFFIX}-omp")
add_definitions(-D_USE_PTHREADS)
if (MSVC)
add_definitions(/MT)
......@@ -366,8 +368,9 @@ elseif (IQTREE_FLAGS MATCHES "avx") # AVX instruction set
set(COMBINED_FLAGS "${COMBINED_FLAGS} ${AVX_FLAGS}")
#SET(EXE_SUFFIX "${EXE_SUFFIX}-avx")
elseif (NOT IQTREE_FLAGS MATCHES "nosse") #SSE intruction set
if (IQTREE_FLAGS MATCHES "512")
if (IQTREE_FLAGS MATCHES "KNL")
message("Vectorization : SSE3/AVX/AVX2/AVX-512")
add_definitions(-D__AVX512KNL)
else()
message("Vectorization : SSE3/AVX/AVX2")
endif()
......@@ -449,103 +452,69 @@ include_directories("${PROJECT_BINARY_DIR}")
#include_directories("${PROJECT_BINARY_DIR}/zlib-1.2.7")
if (NOT IQTREE_FLAGS MATCHES "nozlib")
find_package(ZLIB)
endif()
if(ZLIB_FOUND)
message ("Using system zlib")
include_directories(${ZLIB_INCLUDE_DIRS})
else(ZLIB_FOUND)
message ("Using own zlib-1.2.7")
include_directories("${PROJECT_BINARY_DIR}/zlib-1.2.7" "${PROJECT_SOURCE_DIR}/zlib-1.2.7")
add_subdirectory(zlib-1.2.7)
endif(ZLIB_FOUND)
##################################################################
# subdirectories containing necessary libraries for the build
##################################################################
add_subdirectory(pll)
add_subdirectory(ncl)
add_subdirectory(nclextra)
add_subdirectory(utils)
add_subdirectory(pda)
add_subdirectory(lbfgsb)
add_subdirectory(whtest)
add_subdirectory(sprng)
#add_subdirectory(zlib-1.2.7)
add_subdirectory(vectorclass)
LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
if (NOT EIGEN3_INCLUDE_DIR)
find_package(Eigen3)
if(EIGEN3_FOUND)
include_directories(${EIGEN3_INCLUDE_DIR})
endif(EIGEN3_FOUND)
if(NOT EIGEN3_FOUND)
message(FATAL_ERROR "Eigen3 library not found. Either install it or rerun cmake with -DEIGEN3_INCLUDE_DIR=<installed_eigen3_dir>")
endif()
endif()
add_definitions("-I${EIGEN3_INCLUDE_DIR} -DUSE_EIGEN3")
add_subdirectory(model)
add_subdirectory(gsl)
add_subdirectory(alignment)
add_subdirectory(tree)
##################################################################
# the main executable
##################################################################
add_library(kernelsse phylokernelsse.cpp)
add_library(kernelsse tree/phylokernelsse.cpp)
if (NOT BINARY32 AND NOT IQTREE_FLAGS MATCHES "novx")
add_library(kernelavx phylotreeavx.cpp)
add_library(kernelfma phylokernelfma.cpp)
if (IQTREE_FLAGS MATCHES "512")
add_library(kernelavx512 phylokernelavx512.cpp)
add_definitions(-DINCLUDE_AVX512)
add_library(kernelavx tree/phylotreeavx.cpp)
add_library(kernelfma tree/phylokernelfma.cpp)
if (IQTREE_FLAGS MATCHES "KNL")
add_library(kernelavx512 tree/phylokernelavx512.cpp)
endif()
endif()
if (IQTREE_FLAGS MATCHES "mpi")
add_library(mympi TreeCollection.cpp ObjectStream.cpp)
add_library(mympi utils/TreeCollection.cpp utils/ObjectStream.cpp)
endif()
add_executable(iqtree
alignment.cpp alignment.h
alignmentpairwise.cpp alignmentpairwise.h
circularnetwork.cpp circularnetwork.h
eigendecomposition.cpp eigendecomposition.h
greedy.cpp greedy.h
gss.cpp gss.h
gurobiwrapper.cpp gurobiwrapper.h
gzstream.cpp gzstream.h
hashsplitset.cpp hashsplitset.h
iqtree.cpp iqtree.h
maalignment.cpp maalignment.h
matree.cpp matree.h
mexttree.cpp mexttree.h
mpdablock.cpp mpdablock.h
msetsblock.cpp msetsblock.h
msplitsblock.cpp msplitsblock.h
modelsblock.cpp modelsblock.h
mtree.cpp mtree.h
mtreeset.cpp mtreeset.h
ncbitree.cpp ncbitree.h
ngs.cpp ngs.h
node.cpp node.h
optimization.cpp optimization.h
parsmultistate.cpp parsmultistate.h
pattern.cpp pattern.h
pda.cpp
pdnetwork.cpp pdnetwork.h
pdtree.cpp pdtree.h
pdtreeset.cpp pdtreeset.h
phyloanalysis.cpp phyloanalysis.h
phylonode.cpp phylonode.h
phylosupertree.cpp phylosupertree.h
phylotree.cpp phylotree.h
phylotreesse.cpp phylokernelnew.h
phylotreepars.cpp
pruning.cpp pruning.h
quartet.cpp
split.cpp split.h
splitgraph.cpp splitgraph.h
splitset.cpp splitset.h
stoprule.cpp stoprule.h
superalignment.cpp superalignment.h
superalignmentpairwise.cpp superalignmentpairwise.h
supernode.cpp supernode.h
tinatree.cpp tinatree.h
tools.cpp tools.h
whtest_wrapper.cpp whtest_wrapper.h
lpwrapper.c lpwrapper.h
pllnni.cpp pllnni.h
phylosupertreeplen.cpp phylosupertreeplen.h
phylotesting.cpp phylotesting.h
ecopd.cpp ecopd.h
ecopdmtreeset.cpp ecopdmtreeset.h
graph.cpp graph.h
candidateset.cpp candidateset.h
checkpoint.cpp checkpoint.h
constrainttree.cpp constrainttree.h
MPIHelper.cpp MPIHelper.h
memslot.cpp memslot.h
main/main.cpp
main/phyloanalysis.cpp
main/phyloanalysis.h
main/phylotesting.cpp
main/phylotesting.h
)
if(Backtrace_FOUND)
......@@ -553,30 +522,16 @@ if(Backtrace_FOUND)
target_link_libraries(iqtree ${Backtrace_LIBRARY})
endif(Backtrace_FOUND)
if (NOT IQTREE_FLAGS MATCHES "nozlib")
find_package(ZLIB)
endif()
if(ZLIB_FOUND)
message ("Using system zlib")
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(iqtree ${ZLIB_LIBRARIES})
else(ZLIB_FOUND)
message ("Using own zlib-1.2.7")
include_directories("${PROJECT_BINARY_DIR}/zlib-1.2.7" "${PROJECT_SOURCE_DIR}/zlib-1.2.7")
add_subdirectory(zlib-1.2.7)
target_link_libraries(iqtree zlibstatic)
endif(ZLIB_FOUND)
if (NOT IQTREE_FLAGS MATCHES "avx" AND NOT IQTREE_FLAGS MATCHES "fma")
if (NOT IQTREE_FLAGS MATCHES "nosse")
set_target_properties(iqtree ncl lbfgsb whtest sprng vectorclass model PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
set_target_properties(iqtree ncl nclextra utils pda lbfgsb whtest sprng vectorclass model alignment tree PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
endif()
set_target_properties(kernelsse pll PROPERTIES COMPILE_FLAGS "${SSE_FLAGS}")
if (NOT BINARY32 AND NOT IQTREE_FLAGS MATCHES "novx")
set_target_properties(kernelavx pllavx PROPERTIES COMPILE_FLAGS "${AVX_FLAGS}")
set_target_properties(kernelfma PROPERTIES COMPILE_FLAGS "${FMA_FLAGS}")
if (IQTREE_FLAGS MATCHES "512")
if (IQTREE_FLAGS MATCHES "KNL")
set_target_properties(kernelavx512 PROPERTIES COMPILE_FLAGS "${AVX512_FLAGS}")
endif()
endif()
......@@ -598,7 +553,7 @@ if (IQTREE_FLAGS MATCHES "libcxx")
endif()
set(THREAD_LIB "")
if (IQTREE_FLAGS MATCHES "omp")
if (NOT IQTREE_FLAGS MATCHES "single")
link_directories(${PROJECT_SOURCE_DIR}/lib)
if (MSVC)
if (BINARY32)
......@@ -612,9 +567,9 @@ if (IQTREE_FLAGS MATCHES "omp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${PROJECT_SOURCE_DIR}/libmac")
elseif(CLANG AND WIN32)
if (BINARY32)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${PROJECT_SOURCE_DIR}/lib32 libiomp5md.dll")
target_link_libraries(iqtree ${PROJECT_SOURCE_DIR}/lib32/libiomp5md.dll)
else()
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${PROJECT_SOURCE_DIR}/lib libiomp5md.dll")
target_link_libraries(iqtree ${PROJECT_SOURCE_DIR}/lib/libiomp5md.dll)
endif()
# set(THREAD_LIB "ompstatic")
endif()
......@@ -626,7 +581,7 @@ if (IQTREE_FLAGS MATCHES "omp")
endif()
# basic linking librararies
target_link_libraries(iqtree pll ncl lbfgsb whtest sprng vectorclass model gsl ${PLATFORM_LIB} ${STD_LIB} ${THREAD_LIB} ${ATOMIC_LIB})
target_link_libraries(iqtree pll ncl nclextra utils pda lbfgsb whtest sprng vectorclass model gsl alignment tree ${PLATFORM_LIB} ${STD_LIB} ${THREAD_LIB} ${ATOMIC_LIB})
if (NOT IQTREE_FLAGS MATCHES "nosse")
target_link_libraries(iqtree kernelsse)
......@@ -643,7 +598,7 @@ endif()
# SSE, AVX etc. libraries
if (NOT BINARY32 AND NOT IQTREE_FLAGS MATCHES "novx")
target_link_libraries(iqtree pllavx kernelavx kernelfma)
if (IQTREE_FLAGS MATCHES "512")
if (IQTREE_FLAGS MATCHES "KNL")
target_link_libraries(iqtree kernelavx512)
endif()
endif()
......@@ -653,7 +608,7 @@ endif()
set_target_properties(iqtree PROPERTIES OUTPUT_NAME "iqtree${EXE_SUFFIX}")
# strip the release build
if (CMAKE_BUILD_TYPE STREQUAL "Release" AND (GCC OR CLANG)) # strip is not necessary for MSVC
if (CMAKE_BUILD_TYPE STREQUAL "Release" AND (GCC OR CLANG) AND NOT APPLE) # strip is not necessary for MSVC
if (WIN32)
ADD_CUSTOM_COMMAND(TARGET iqtree POST_BUILD COMMAND strip $<TARGET_FILE:iqtree>)
elseif (NOT APPLE)
......@@ -682,10 +637,11 @@ install (TARGETS iqtree DESTINATION bin)
install (FILES "${PROJECT_SOURCE_DIR}/example/models.nex" DESTINATION .)
install (FILES "${PROJECT_SOURCE_DIR}/example/example.phy" DESTINATION .)
install (FILES "${PROJECT_SOURCE_DIR}/example/example.nex" DESTINATION .)
install (FILES "${PROJECT_SOURCE_DIR}/example/example.cf" DESTINATION .)
if (WIN32)
install (FILES "${BINARY_DIR}/iqtree${EXE_SUFFIX}-click.exe" DESTINATION bin)
if (EXE_SUFFIX MATCHES "omp" AND MSVC)
if (NOT IQTREE_FLAGS MATCHES "single" AND MSVC)
if (BINARY32)
install(FILES "${PROJECT_SOURCE_DIR}/lib32/pthreadVC2.dll" DESTINATION bin)
install(FILES "${PROJECT_SOURCE_DIR}/lib32/libiomp5md.dll" DESTINATION bin)
......@@ -697,7 +653,7 @@ if (WIN32)
# install(FILES "${PROJECT_SOURCE_DIR}/lib/pthreadGC2_64.dll" DESTINATION bin)
endif()
if (EXE_SUFFIX MATCHES "omp" AND CLANG)
if (NOT IQTREE_FLAGS MATCHES "single" AND CLANG)
if (BINARY32)
install(FILES "${PROJECT_SOURCE_DIR}/lib32/libiomp5md.dll" DESTINATION bin)
else()
......@@ -712,7 +668,7 @@ endif()
##############################################################
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR "${iqtree_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${iqtree_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${iqtree_VERSION_PATCH}")
......@@ -742,8 +698,8 @@ if (BINARY32)
set (SYSTEM_NAME "${SYSTEM_NAME}32")
endif()
if (IQTREE_FLAGS MATCHES "512")
set (SYSTEM_NAME "${SYSTEM_NAME}512")
if (IQTREE_FLAGS MATCHES "KNL")
set (SYSTEM_NAME "${SYSTEM_NAME}KNL")
endif()
set(CPACK_PACKAGE_FILE_NAME
......
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<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 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
......@@ -16,7 +16,7 @@ Key features of IQ-TREE
* __Efficient search algorithm__: Fast and effective stochastic algorithm to reconstruct phylogenetic trees by maximum likelihood. IQ-TREE compares favorably to RAxML and PhyML in terms of likelihood while requiring similar amount of computing time ([Nguyen et al., 2015]).
* __Ultrafast bootstrap__: An ultrafast bootstrap approximation (UFBoot) to assess branch supports. UFBoot is 10 to 40 times faster than RAxML rapid bootstrap and obtains less biased support values ([Minh et al., 2013]).
* __Ultrafast model selection__: An ultrafast and automatic model selection (ModelFinder) which is 10 to 100 times faster than jModelTest and ProtTest. ModelFinder also finds best-fit partitioning scheme like PartitionFinder.
* __Ultrafast model selection__: An ultrafast and automatic model selection (ModelFinder) which is 10 to 100 times faster than jModelTest and ProtTest. ModelFinder also finds best-fit partitioning scheme like PartitionFinder ([Kalyaanamoorthy et al., 2017]).
* __Phylogenetic testing__: Several fast branch tests like SH-aLRT and aBayes test ([Anisimova et al., 2011]) and tree topology tests like the approximately unbiased (AU) test ([Shimodaira, 2002]).
......@@ -25,6 +25,8 @@ The strength of IQ-TREE is the availability of a wide variety of phylogenetic mo
* __Common models__: All [common substitution models](http://www.iqtree.org/doc/Substitution-Models) for DNA, protein, codon, binary and morphological data with [rate heterogeneity among sites](http://www.iqtree.org/doc/Substitution-Models/#rate-heterogeneity-across-sites) and [ascertainment bias correction](http://www.iqtree.org/doc/Substitution-Models/#ascertainment-bias-correction) for e.g. SNP data.
* __[Partition models](http://www.iqtree.org/doc/Complex-Models/#partition-models)__: Allowing individual models for different genomic loci (e.g. genes or codon positions), mixed data types, mixed rate heterogeneity types, linked or unlinked branch lengths between partitions.
* __Mixture Models__: [fully customizable mixture models](http://www.iqtree.org/doc/Complex-Models/#mixture-models) and [empirical protein mixture models](http://www.iqtree.org/doc/Substitution-Models/#protein-models) and.
* __Polymorphism-aware models (PoMo)__: <http://www.iqtree.org/doc/Polymorphism-Aware-Models>
IQ-TREE web service
-------------------
......@@ -46,19 +48,35 @@ _The average response time is one working day._
Citations
---------
To cite IQ-TREE please use:
When using ModelFinder please cite:
* S. Kalyaanamoorthy, B.Q. Minh, T.K.F. Wong, A. von Haeseler, L.S. Jermiin (2017) ModelFinder: Fast model selection for accurate phylogenetic estimates. *Nat. Methods*, 14:587-589. <https://doi.org/10.1038/nmeth.4285>
When performing tree reconstruction please cite:
* L.-T. Nguyen, H.A. Schmidt, A. von Haeseler, and B.Q. Minh (2015) IQ-TREE: A fast and effective stochastic algorithm for estimating maximum likelihood phylogenies. *Mol. Biol. Evol.*, 32, 268-274. [DOI: 10.1093/molbev/msu300](http://dx.doi.org/10.1093/molbev/msu300)
* L.-T. Nguyen, H.A. Schmidt, A. von Haeseler, and B.Q. Minh (2015) IQ-TREE: A fast and effective stochastic algorithm for estimating maximum likelihood phylogenies. *Mol. Biol. Evol.*, 32, 268-274. <https://doi.org/10.1093/molbev/msu300>
For the ultrafast bootstrap (UFBoot) please cite:
* B.Q. Minh, M.A.T. Nguyen, and A. von Haeseler (2013) Ultrafast approximation for phylogenetic bootstrap. *Mol. Biol. Evol.*, 30:1188-1195. [DOI: 10.1093/molbev/mst024](http://dx.doi.org/10.1093/molbev/mst024)
* D.T. Hoang, O. Chernomor, A. von Haeseler, B.Q. Minh, and L.S. Vinh (2017) UFBoot2: Improving the ultrafast bootstrap approximation. *Mol. Biol. Evol.*, in press. <https://doi.org/10.1093/molbev/msx281>
When using posterior mean site frequency model (PMSF) please cite:
* H.C. Wang, B.Q. Minh, S. Susko, A.J. Roger (in press) Modeling site heterogeneity with posterior mean site frequency profiles accelerates accurate phylogenomic estimation. *Syst. Biol.* <https://doi.org/10.1093/sysbio/syx068>
When using partition models please cite:
* O. Chernomor, A. von Haeseler, B.Q. Minh (2016) Terrace aware data structure for phylogenomic inference from supermatrices. *Syst. Biol.*, 65:997-1008. <https://doi.org/10.1093/sysbio/syw037>
When using polymorphism-aware models please cite:
* D. Schrempf, B.Q. Minh, N. De Maio, A. von Haeseler, C. Kosiol (2016) Reversible polymorphism-aware phylogenetic models and their application to tree inference. *J. Theor. Biol.*, 407:362-370. <https://doi.org/10.1016/j.jtbi.2016.07.042>
#### Credits and Acknowledgements
Some parts of the code were taken from the following packages/libraries: [Phylogenetic likelihood library](http://www.libpll.org), [TREE-PUZZLE](http://www.tree-puzzle.de),
[BIONJ](http://dx.doi.org/10.1093/oxfordjournals.molbev.a025808), [Nexus Class Libary](http://dx.doi.org/10.1093/bioinformatics/btg319), [Eigen library](http://eigen.tuxfamily.org/),
[SPRNG library](http://www.sprng.org), [Zlib library](http://www.zlib.net), gzstream library, [vectorclass library](http://www.agner.org/optimize/), [GNU scientific library](https://www.gnu.org/software/gsl/).
[SPRNG library](http://www.sprng.org), [Zlib library](http://www.zlib.net), [gzstream library](http://www.cs.unc.edu/Research/compgeom/gzstream/), [vectorclass library](http://www.agner.org/optimize/), [GNU scientific library](https://www.gnu.org/software/gsl/).
IQ-TREE was partially funded by the [Austrian Science Fund - FWF](http://www.fwf.ac.at/) (grant no. I 760-B17 from 2012-2015 and and I 2508-B29 from 2016-2019) and the [University of Vienna](https://www.univie.ac.at/) (Initiativkolleg I059-N).
......@@ -66,6 +84,7 @@ IQ-TREE was partially funded by the [Austrian Science Fund - FWF](http://www.fwf
[Anisimova et al., 2011]: http://dx.doi.org/10.1093/sysbio/syr041
[Guindon et al., 2010]: http://dx.doi.org/10.1093/sysbio/syq010
[Kalyaanamoorthy et al., 2017]: https://doi.org/10.1038/nmeth.4285
[Minh et al., 2013]: http://dx.doi.org/10.1093/molbev/mst024
[Nguyen et al., 2015]: http://dx.doi.org/10.1093/molbev/msu300
[Shimodaira, 2002]: http://dx.doi.org/10.1080/10635150290069913
add_library(alignment
pattern.cpp
pattern.h
alignment.cpp
alignment.h
alignmentpairwise.cpp
alignmentpairwise.h
maalignment.cpp
maalignment.h
superalignment.cpp
superalignment.h
superalignmentpairwise.cpp
superalignmentpairwise.h
superalignmentpairwiseplen.cpp
superalignmentpairwiseplen.h
)
target_link_libraries(alignment ncl gsl)
......@@ -16,11 +16,19 @@
#include <bitset>
#include "pattern.h"
#include "ncl/ncl.h"
#include "tools.h"
#include "utils/tools.h"
// IMPORTANT: refactor STATE_UNKNOWN
//const char STATE_UNKNOWN = 126;
const char STATE_INVALID = 127;
// TODO DS: This seems like a significant restriction.
/* PoMo: STATE_INVALID is not handled in PoMo. Set STATE_INVALID to
127 to remove warning about comparison to char in alignment.cpp.
This is important if the maximum N will be increased above 21
because then the state space is larger than 127 and we have to
think about something else. */
/* const unsigned char STATE_INVALID = 255; */
const unsigned char STATE_INVALID = 127;
const int NUM_CHAR = 256;
const double MIN_FREQUENCY = 0.0001;
const double MIN_FREQUENCY_DIFF = 0.00001;
......@@ -28,18 +36,28 @@ const double MIN_FREQUENCY_DIFF = 0.00001;
typedef bitset<NUM_CHAR> StateBitset;
enum SeqType {
SEQ_DNA, SEQ_PROTEIN, SEQ_BINARY, SEQ_MORPH, SEQ_MULTISTATE, SEQ_CODON, SEQ_UNKNOWN
SEQ_DNA, SEQ_PROTEIN, SEQ_BINARY, SEQ_MORPH, SEQ_MULTISTATE, SEQ_CODON, SEQ_POMO, SEQ_UNKNOWN
};
#ifdef USE_HASH_MAP
struct hashPattern {
size_t operator()(const vector<StateType> &sp) const {
size_t sum = 0;
for (Pattern::const_iterator it = sp.begin(); it != sp.end(); it++)
sum = (*it) + (sum << 6) + (sum << 16) - sum;
return sum;
}
};
typedef unordered_map<string, int> StringIntMap;
typedef unordered_map<string, double> StringDoubleHashMap;
typedef unordered_map<string, int> PatternIntMap;
typedef unordered_map<vector<StateType>, int, hashPattern> PatternIntMap;
typedef unordered_map<uint32_t, uint32_t> IntIntMap;
#else
typedef map<string, int> StringIntMap;
typedef map<string, double> StringDoubleHashMap;
typedef map<string, int> PatternIntMap;
typedef map<vector<StateType>, int> PatternIntMap;
typedef map<uint32_t, uint32_t> IntIntMap;
#endif
/**
......@@ -95,6 +113,20 @@ public:
void computeConst(Pattern &pat);
void printSiteInfoHeader(ostream& out, const char* filename, bool partition = false);
/**
Print all site information to a stream
@param out output stream
@param part_id partition ID, negative to omit
*/
void printSiteInfo(ostream &out, int part_id);
/**
Print all site information to a file
@param filename output file name
*/
virtual void printSiteInfo(const char* filename);
/**
* add const patterns into the alignment
* @param freq_const_pattern comma-separated list of const pattern frequencies
......@@ -134,6 +166,18 @@ public:
*/
int readFasta(char *filename, char *sequence_type);
/**
* Read the alignment in counts format (PoMo).
*
* TODO: Allow noninformative sites (where no base is present).
*
* @param filename file name
* @param sequence_type sequence type (i.e., "CF10")
*
* @return 1 on success, 0 on failure
*/
int readCountsFormat(char *filename, char *sequence_type);
/**
read the alignment in CLUSTAL format
@param filename file name
......@@ -162,8 +206,9 @@ public:
UINT *pars_lower_bound;
/** order pattern by number of character states and return in ptn_order
@param pat_type either PAT_INFORMATIVE or 0
*/
virtual void orderPatternByNumChars();
virtual void orderPatternByNumChars(int pat_type);
/**
* un-group site-patterns, i.e., making #sites = #patterns and pattern frequency = 1 for all patterns
......@@ -412,6 +457,14 @@ public:
*/
virtual void createBootstrapAlignment(int *pattern_freq, const char *spec = NULL, int *rstream = NULL);
/**
Diep: This is for UFBoot2-Corr
Initialize "this" alignment as a bootstrap alignment
@param aln: the reference to the original alignment
@new_pattern_freqs: the frequencies of patterns to be present in bootstrap aln
*/
void buildFromPatternFreq(Alignment & aln, IntVector new_pattern_freqs);
/**
create a gap masked alignment from an input alignment. Gap patterns of masked_aln
will be superimposed into aln to create the current alignment object.
......@@ -530,6 +583,18 @@ public:
*/
virtual void computeStateFreq(double *state_freq, size_t num_unknown_states = 0);
int convertPomoState(int state);
/**
* Compute the absolute frequencies of the different states.
* Helpful for models with many states (e.g., PoMo) to check the
* abundancy of states in the data.
*
* @param abs_state_freq (OUT) assumed to be at least of size
* num_states.
*/
void computeAbsoluteStateFreq(unsigned int *abs_state_freq);
/**
compute empirical state frequencies for each sequence
@param freq_per_sequence (OUT) state frequencies for each sequence, of size num_states*num_freq
......@@ -594,7 +659,7 @@ public:
/** either SEQ_BINARY, SEQ_DNA, SEQ_PROTEIN, SEQ_MORPH, or SEQ_CODON */
SeqType seq_type;
char STATE_UNKNOWN;
StateType STATE_UNKNOWN;
/**
number of states
......@@ -611,9 +676,15 @@ public:
*/
double frac_invariant_sites;
/** number of informative sites */
/** number of parsimony informative sites */
int num_informative_sites;
/** number of variant sites */
int num_variant_sites;
/** number of sites used for parsimony computation, can be informative or variant */
int num_parsimony_sites;
/**
* map from 64 codon to non-stop codon index
*/
......@@ -631,6 +702,24 @@ public:
*/
char *genetic_code;
/**
* Virtual population size for PoMo model
*/
int virtual_pop_size;
// TODO DS: Maybe change default to SAMPLING_WEIGHTED_HYPER.
/// The sampling method (defaults to SAMPLING_WEIGHTED_BINOM).
SamplingType pomo_sampling_method;
/** BQM: 2015-07-06,
for PoMo data: map from state ID to pair of base1 and base2
represented in the high 16-bit and the low 16-bit of uint32_t
for base1, bit0-1 is used to encode the base (A,G,C,T) and the remaining 14 bits store the count
same interpretation for base2
*/
vector<uint32_t> pomo_sampled_states;
IntIntMap pomo_sampled_states_index; // indexing, to quickly find if a PoMo-2-state is already present
vector<vector<int> > seq_states; // state set for each sequence in the alignment
/* for site-specific state frequency model with Huaichun, Edward, Andrew */
......@@ -658,7 +747,6 @@ public:
*/
void buildSeqStates(bool add_unobs_const = false);
/** Added by MA
Compute the probability of this alignment according to the multinomial distribution with parameters determined by the reference alignment
@param refAlign the reference alignment
......@@ -690,12 +778,17 @@ public:
/**
get the appearance for a state, helpful for ambigious states
For nucleotides, the appearances of A, and C are 1000 and 0100,
respectively. If a state is ambiguous, more than one 1 will show up.
The appearance of the unknown state is 1111.
@param state the state index
@param state_app (OUT) state appearance
*/
void getAppearance(char state, double *state_app);
void getAppearance(StateType state, double *state_app);
void getAppearance(char state, StateBitset &state_app);
void getAppearance(StateType state, StateBitset &state_app);
/**
* read site specific state frequency vectors from a file to create corresponding model
......
......@@ -18,7 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "alignmentpairwise.h"
#include "phylosupertree.h"
#include "tree/phylosupertree.h"
AlignmentPairwise::AlignmentPairwise()
: Alignment(), Optimization()
......@@ -44,8 +44,8 @@ AlignmentPairwise::AlignmentPairwise(PhyloTree *atree, int seq1, int seq2) : Ali
memset(pair_freq, 0, sizeof(double)*total_size);
int i = 0;
for (Alignment::iterator it = tree->aln->begin(); it != tree->aln->end(); it++, i++) {
int state1 = (*it)[seq_id1];
int state2 = (*it)[seq_id2];
int state1 = tree->aln->convertPomoState((*it)[seq_id1]);
int state2 = tree->aln->convertPomoState((*it)[seq_id2]);
addPattern(state1, state2, it->frequency, tree->getRate()->getPtnCat(i));
/*
if (state1 < num_states && state2 < num_states)
......@@ -57,8 +57,8 @@ AlignmentPairwise::AlignmentPairwise(PhyloTree *atree, int seq1, int seq2) : Ali
pair_freq = new double[num_states * num_states];
memset(pair_freq, 0, sizeof(double) * num_states * num_states);
for (Alignment::iterator it = tree->aln->begin(); it != tree->aln->end(); it++) {
int state1 = (*it)[seq_id1];
int state2 = (*it)[seq_id2];
int state1 = tree->aln->convertPomoState((*it)[seq_id1]);
int state2 = tree->aln->convertPomoState((*it)[seq_id2]);
addPattern(state1, state2, it->frequency);
/* if (state1 < num_states && state2 < num_states)
pair_freq[state1 * num_states + state2] += it->frequency;*/
......@@ -271,7 +271,7 @@ void AlignmentPairwise::computeFuncDerv(double value, double &df, double &ddf) {
}
}
for (i = 0; i < trans_size; i++)
if (pair_freq[i] > Params::getInstance().min_branch_length && sum_trans[i] > 0) {
if (pair_freq[i] > Params::getInstance().min_branch_length && sum_trans[i] > 0.0) {
// lh -= pair_freq[i] * log(sum_trans[i]);
double d1 = sum_derv1[i] / sum_trans[i];
df -= pair_freq[i] * d1;
......@@ -298,10 +298,15 @@ double AlignmentPairwise::optimizeDist(double initial_dist, double &d2l) {
if (!tree->getModelFactory() || !tree->getRate()) return dist;
double negative_lh, ferror;
double max_genetic_dist = MAX_GENETIC_DIST;
if (tree->aln->seq_type == SEQ_POMO) {
int N = tree->aln->virtual_pop_size;
max_genetic_dist *= N*N;
}
if (tree->optimize_by_newton) // Newton-Raphson method
dist = minimizeNewton(Params::getInstance().min_branch_length, dist, MAX_GENETIC_DIST, Params::getInstance().min_branch_length, d2l);
dist = minimizeNewton(Params::getInstance().min_branch_length, dist, max_genetic_dist, Params::getInstance().min_branch_length, d2l);
else // Brent method
dist = minimizeOneDimen(Params::getInstance().min_branch_length, dist, MAX_GENETIC_DIST, Params::getInstance().min_branch_length, &negative_lh, &ferror);
dist = minimizeOneDimen(Params::getInstance().min_branch_length, dist, max_genetic_dist, Params::getInstance().min_branch_length, &negative_lh, &ferror);
return dist;
}
......
......@@ -20,8 +20,8 @@
#ifndef ALIGNMENTPAIRWISE_H
#define ALIGNMENTPAIRWISE_H
#include "optimization.h"
#include "phylotree.h"
#include "utils/optimization.h"
#include "tree/phylotree.h"
/**
Pairwise alignment
......
......@@ -72,7 +72,8 @@ void MaAlignment::readLogLL(char *fileName)
logLL[patIndex] = _logllVec[i];
else
if ( logLL[patIndex] != _logllVec[i] )
outError("Conflicting between the likelihoods reported for pattern", (*this)[i]);
// outError("Conflicting between the likelihoods reported for pattern", (*this)[i]);
outError("Conflicting between the likelihoods reported for pattern");
}
// int npat = getNPattern();
// cout << "Number of patterns: " << npat << endl;
......
......@@ -10,10 +10,10 @@
//
//
#include "pattern.h"
#include "alignment.h"
#include "alignment/alignment.h"
Pattern::Pattern()
: string()
: vector<StateType>()
{
frequency = 0;
// is_const = false;
......@@ -24,7 +24,7 @@ Pattern::Pattern()
}
Pattern::Pattern(const Pattern &pat)
: string(pat)
: vector<StateType>(pat)
{
frequency = pat.frequency;
// is_const = pat.is_const;
......
......@@ -14,18 +14,23 @@
#include <iostream>
#include <string>
#include <vector>
#include <stdint.h>
using namespace std;
const int PAT_CONST = 1; // const site pattern, e.g. AAAAAA, CC-C-CCCC
const int PAT_INVARIANT = 2; // invariant site pattern, including const patterns and e.g., GS--G-GGG (S = G/C)
const int PAT_INFORMATIVE = 4; // parsimony informative sites
const int PAT_VARIANT = 8; // variant site pattern
typedef uint32_t StateType;
/**
Site-patterns in a multiple sequence alignment
@author BUI Quang Minh, Steffen Klaere, Arndt von Haeseler <minh.bui@univie.ac.at>
*/
class Pattern : public string
class Pattern : public vector<StateType>
{
public:
/**
......
......@@ -19,9 +19,9 @@
***************************************************************************/
#include <stdarg.h>
#include "phylotree.h"
#include "tree/phylotree.h"
#include "superalignment.h"
#include "phylosupertree.h"
#include "tree/phylosupertree.h"
SuperAlignment::SuperAlignment() : Alignment() {
max_num_states = 0;
......@@ -77,7 +77,7 @@ void SuperAlignment::buildPattern() {
int nseq = getNSeq();
for (site = 0; site < nsite; site++) {
Pattern pat;
pat.append(nseq, 0);
pat.resize(nseq, 0);
for (seq = 0; seq < nseq; seq++)
pat[seq] = (taxa_index[seq][site] >= 0)? 1 : 0;
addPattern(pat, site);
......@@ -90,7 +90,7 @@ void SuperAlignment::buildPattern() {
void SuperAlignment::linkSubAlignment(int part) {
assert(taxa_index.size() == getNSeq());
ASSERT(taxa_index.size() == getNSeq());
int nseq = getNSeq(), seq;
vector<bool> checked;
checked.resize(partitions[part]->getNSeq(), false);
......@@ -108,18 +108,18 @@ void SuperAlignment::linkSubAlignment(int part) {
}
// sanity check that all seqnames in partition must be present in superalignment
for (seq = 0; seq < checked.size(); seq++) {
assert(checked[seq]);
ASSERT(checked[seq]);
}
}
void SuperAlignment::extractSubAlignment(Alignment *aln, IntVector &seq_id, int min_true_char, int min_taxa, IntVector *kept_partitions) {
assert(aln->isSuperAlignment());
ASSERT(aln->isSuperAlignment());
SuperAlignment *saln = (SuperAlignment*)aln;
int i;
IntVector::iterator it;
for (it = seq_id.begin(); it != seq_id.end(); it++) {
assert(*it >= 0 && *it < aln->getNSeq());
ASSERT(*it >= 0 && *it < aln->getNSeq());
seq_names.push_back(aln->getSeqName(*it));
}
......@@ -291,6 +291,19 @@ void SuperAlignment::getPatternFreq(IntVector &pattern_freq) {
}
}
void SuperAlignment::printSiteInfo(const char* filename) {
try {
ofstream out(filename);
printSiteInfoHeader(out, filename, true);
int id = 1;
for (auto it = partitions.begin(); it != partitions.end(); it++, id++)
(*it)->printSiteInfo(out, id);
out.close();
} catch (...) {
outError(ERR_WRITE_OUTPUT, filename);
}
}
void SuperAlignment::createBootstrapAlignment(Alignment *aln, IntVector* pattern_freq, const char *spec) {
ASSERT(aln->isSuperAlignment());
Alignment::copyAlignment(aln);
......@@ -302,26 +315,33 @@ void SuperAlignment::createBootstrapAlignment(Alignment *aln, IntVector* pattern
partitions.resize(super_aln->partitions.size(), NULL);
int i, ptn;
for (i = 0; i < super_aln->partitions.size(); i++) {
// get a random gene
int part = random_int(super_aln->partitions.size());
// ptn_freq stores pattern frequency of bootstrap aln
IntVector ptn_freq;
if (strncmp(spec,"GENESITE",8) == 0) {
// resample sites of this gene
super_aln->partitions[part]->createBootstrapAlignment(ptn_freq);
ASSERT(ptn_freq.size() == super_aln->partitions[part]->size());
} else {
// copy ptn_freq from this gene
for (ptn = 0; ptn < super_aln->partitions[part]->size(); ptn++)
ptn_freq.push_back(super_aln->partitions[part]->at(ptn).frequency);
}
if (!partitions[part]) {
// allocate the partition
partitions[part] = new Alignment;
if (strncmp(spec,"GENESITE",8) == 0) {
partitions[part]->createBootstrapAlignment(super_aln->partitions[part]);
} else
partitions[part]->copyAlignment(super_aln->partitions[part]);
for (ptn = 0; ptn < super_aln->partitions[part]->size(); ptn++)
partitions[part]->at(ptn).frequency = ptn_freq[ptn];
} else {
Alignment *newaln;
if (strncmp(spec,"GENESITE",8) == 0) {
Alignment *newaln = new Alignment;
newaln->createBootstrapAlignment(super_aln->partitions[part]);
} else
newaln = super_aln->partitions[part];
// increase frequency if already existed
for (ptn = 0; ptn < super_aln->partitions[part]->size(); ptn++)
partitions[part]->at(ptn).frequency += newaln->at(ptn).frequency;
if (strncmp(spec,"GENESITE",8) == 0)
delete newaln;
partitions[part]->at(ptn).frequency += ptn_freq[ptn];
}
}
......@@ -458,11 +478,11 @@ double SuperAlignment::computeDist(int seq1, int seq2) {
double x = 1.0 - (z * obs_dist);
if (x <= 0) {
/* string str = "Too long distance between two sequences ";
str += getSeqName(seq1);
str += " and ";
str += getSeqName(seq2);
outWarning(str);*/
// string str = "Too long distance between two sequences ";
// str += getSeqName(seq1);
// str += " and ";
// str += getSeqName(seq2);
// outWarning(str);
return MAX_GENETIC_DIST;
}
......@@ -547,7 +567,7 @@ void SuperAlignment::printSubAlignments(Params &params, vector<PartitionInfo> &p
vector<Alignment*>::iterator pit;
string filename;
int part;
assert(part_info.size() == partitions.size());
ASSERT(part_info.size() == partitions.size());
for (pit = partitions.begin(), part = 0; pit != partitions.end(); pit++, part++) {
if (params.aln_output)
filename = params.aln_output;
......@@ -582,12 +602,13 @@ double SuperAlignment::computeMissingData() {
}
Alignment *SuperAlignment::concatenateAlignments(IntVector &ids) {
Alignment *SuperAlignment::concatenateAlignments(set<int> &ids) {
string union_taxa;
int nsites = 0, nstates = 0, i;
int nsites = 0, nstates = 0;
set<int>::iterator it;
SeqType sub_type = SEQ_UNKNOWN;
for (i = 0; i < ids.size(); i++) {
int id = ids[i];
for (it = ids.begin(); it != ids.end(); it++) {
int id = *it;
ASSERT(id >= 0 && id < partitions.size());
if (nstates == 0) nstates = partitions[id]->num_states;
if (sub_type == SEQ_UNKNOWN) sub_type = partitions[id]->seq_type;
......@@ -596,16 +617,18 @@ Alignment *SuperAlignment::concatenateAlignments(IntVector &ids) {
if (nstates != partitions[id]->num_states)
outError("Cannot concatenate sub-alignments of different #states");
string taxa_set = getPattern(id);
string taxa_set;
Pattern taxa_pat = getPattern(id);
taxa_set.insert(taxa_set.begin(), taxa_pat.begin(), taxa_pat.end());
nsites += partitions[id]->getNSite();
if (i == 0) union_taxa = taxa_set; else {
if (it == ids.begin()) union_taxa = taxa_set; else {
for (int j = 0; j < union_taxa.length(); j++)
if (taxa_set[j] == 1) union_taxa[j] = 1;
}
}
Alignment *aln = new Alignment;
for (i = 0; i < union_taxa.length(); i++)
for (int i = 0; i < union_taxa.length(); i++)
if (union_taxa[i] == 1) {
aln->seq_names.push_back(getSeqName(i));
}
......@@ -614,19 +637,21 @@ Alignment *SuperAlignment::concatenateAlignments(IntVector &ids) {
aln->site_pattern.resize(nsites, -1);
aln->clear();
aln->pattern_index.clear();
aln->STATE_UNKNOWN = partitions[ids[0]]->STATE_UNKNOWN;
aln->genetic_code = partitions[ids[0]]->genetic_code;
aln->STATE_UNKNOWN = partitions[*ids.begin()]->STATE_UNKNOWN;
aln->genetic_code = partitions[*ids.begin()]->genetic_code;
if (aln->seq_type == SEQ_CODON) {
aln->codon_table = new char[aln->num_states];
memcpy(aln->codon_table, partitions[ids[0]]->codon_table, aln->num_states);
memcpy(aln->codon_table, partitions[*ids.begin()]->codon_table, aln->num_states);
aln->non_stop_codon = new char[strlen(aln->genetic_code)];
memcpy(aln->non_stop_codon, partitions[ids[0]]->non_stop_codon, strlen(aln->genetic_code));
memcpy(aln->non_stop_codon, partitions[*ids.begin()]->non_stop_codon, strlen(aln->genetic_code));
}
int site = 0;
for (i = 0; i < ids.size(); i++) {
int id = ids[i];
string taxa_set = getPattern(id);
for (it = ids.begin(); it != ids.end(); it++) {
int id = *it;
string taxa_set;
Pattern taxa_pat = getPattern(id);
taxa_set.insert(taxa_set.begin(), taxa_pat.begin(), taxa_pat.end());
for (Alignment::iterator it = partitions[id]->begin(); it != partitions[id]->end(); it++) {
Pattern pat;
int part_seq = 0;
......@@ -638,7 +663,7 @@ Alignment *SuperAlignment::concatenateAlignments(IntVector &ids) {
}
pat.push_back(ch);
}
assert(part_seq == partitions[id]->getNSeq());
ASSERT(part_seq == partitions[id]->getNSeq());
aln->addPattern(pat, site, (*it).frequency);
// IMPORTANT BUG FIX FOLLOW
int ptnindex = aln->pattern_index[pat];
......@@ -653,15 +678,25 @@ Alignment *SuperAlignment::concatenateAlignments(IntVector &ids) {
return aln;
}
Alignment *SuperAlignment::concatenateAlignments() {
set<int> ids;
for (int i = 0; i < partitions.size(); i++)
ids.insert(i);
return concatenateAlignments(ids);
}
void SuperAlignment::countConstSite() {
num_informative_sites = 0;
num_variant_sites = 0;
max_num_states = 0;
frac_const_sites = 0;
frac_invariant_sites = 0;
num_parsimony_sites = 0;
size_t nsites = 0;
for (vector<Alignment*>::iterator it = partitions.begin(); it != partitions.end(); it++) {
(*it)->countConstSite();
num_informative_sites += (*it)->num_informative_sites;
num_variant_sites += (*it)->num_variant_sites;
if ((*it)->num_states > max_num_states)
max_num_states = (*it)->num_states;
nsites += (*it)->getNSite();
......@@ -672,18 +707,23 @@ void SuperAlignment::countConstSite() {
frac_invariant_sites /= nsites;
}
void SuperAlignment::orderPatternByNumChars() {
void SuperAlignment::orderPatternByNumChars(int pat_type) {
const int UINT_BITS = sizeof(UINT)*8;
int maxi = (num_informative_sites+UINT_BITS-1)/UINT_BITS;
if (pat_type == PAT_INFORMATIVE)
num_parsimony_sites = num_informative_sites;
else
num_parsimony_sites = num_variant_sites;
int maxi = (num_parsimony_sites+UINT_BITS-1)/UINT_BITS;
pars_lower_bound = new UINT[maxi+1];
memset(pars_lower_bound, 0, (maxi+1)*sizeof(UINT));
int part, nseq = getNSeq(), npart = partitions.size();
int part, nseq = getNSeq();
// compute ordered_pattern
ordered_pattern.clear();
UINT sum_scores[npart];
// UINT sum_scores[npart];
for (part = 0; part != partitions.size(); part++) {
partitions[part]->orderPatternByNumChars();
partitions[part]->orderPatternByNumChars(pat_type);
// partial_partition
for (vector<Pattern>::iterator pit = partitions[part]->ordered_pattern.begin(); pit != partitions[part]->ordered_pattern.end(); pit++) {
Pattern pattern(*pit);
......@@ -695,7 +735,7 @@ void SuperAlignment::orderPatternByNumChars() {
pattern[j] = partitions[part]->STATE_UNKNOWN;
ordered_pattern.push_back(pattern);
}
sum_scores[part] = partitions[part]->pars_lower_bound[0];
// sum_scores[part] = partitions[part]->pars_lower_bound[0];
}
// TODO compute pars_lower_bound (lower bound of pars score for remaining patterns)
}
......@@ -39,10 +39,10 @@ struct PartitionInfo {
//DoubleVector nni1_score; // log-likelihood for 1st NNI for every branch
//DoubleVector nni2_score; // log-likelihood for 2nd NNI for every branch
DoubleVector cur_brlen; // current branch lengths
vector<DoubleVector> cur_brlen; // current branch lengths
//DoubleVector opt_brlen; // optimized branch lengths for every branch
DoubleVector nni1_brlen; // branch length for 1st NNI for every branch
DoubleVector nni2_brlen; // branch length for 2nd NNI for every branch
vector<DoubleVector> nni1_brlen; // branch length for 1st NNI for every branch
vector<DoubleVector> nni2_brlen; // branch length for 2nd NNI for every branch
//double *mem_ptnlh; // total memory allocated for all pattern likelihood vectors
double *cur_ptnlh; // current pattern likelihoods of the tree
......@@ -102,6 +102,12 @@ public:
*/
virtual void getPatternFreq(IntVector &pattern_freq);
/**
Print all site information to a file
@param filename output file name
*/
virtual void printSiteInfo(const char* filename);
/**
extract sub-alignment of a sub-set of sequences
......@@ -236,7 +242,7 @@ public:
/** order pattern by number of character states and return in ptn_order
*/
virtual void orderPatternByNumChars();
virtual void orderPatternByNumChars(int pat_type);
/**
actual partition alignments
......@@ -256,7 +262,13 @@ public:
* @param ids IDs of sub-alignments
* @return concatenated alignment
*/
Alignment *concatenateAlignments(IntVector &ids);
Alignment *concatenateAlignments(set<int> &ids);
/**
* concatenate all alignments
* @return concatenated alignment
*/
Alignment *concatenateAlignments();
};
......
......@@ -22,7 +22,7 @@
#include "alignmentpairwise.h"
#include "superalignment.h"
#include "phylosupertree.h"
#include "tree/phylosupertree.h"
/**
@author BUI Quang Minh <minh.bui@univie.ac.at>
......
//
// superalignmentpairwiseplen.cpp
// iqtree
//
// Created by Olga on 04/05/17.
//
//
#include <stdio.h>
#include "superalignmentpairwiseplen.h"
/**********************************************************
* class SuperAlignmentPairwisePlen
**********************************************************/
SuperAlignmentPairwisePlen::SuperAlignmentPairwisePlen(PhyloSuperTreePlen *atree, int seq1, int seq2)
: SuperAlignmentPairwise((PhyloSuperTree*) atree, seq1, seq2)
{
part_info = &(atree->part_info);
}
double SuperAlignmentPairwisePlen::computeFunction(double value) {
int part = 0;
double lh = 0.0;
for (vector<AlignmentPairwise*>::iterator it = partitions.begin(); it != partitions.end(); it++, part++) {
lh += (*it)->computeFunction(part_info->at(part).part_rate*value);
}
return lh;
}
void SuperAlignmentPairwisePlen::computeFuncDerv(double value, double &df, double &ddf) {
int part = 0;
// double lh = 0.0;
df = 0.0;
ddf = 0.0;
for (vector<AlignmentPairwise*>::iterator it = partitions.begin(); it != partitions.end(); it++, part++) {
double d1, d2;
(*it)->computeFuncDerv(part_info->at(part).part_rate*value, d1, d2);
df += part_info->at(part).part_rate*d1;
ddf += part_info->at(part).part_rate*part_info->at(part).part_rate*d2;
}
// return lh;
}
SuperAlignmentPairwisePlen::~SuperAlignmentPairwisePlen()
{}
//
// superalignmentpairwiseplen.h
// iqtree
//
// Created by Olga on 04/05/17.
//
//
#ifndef iqtree_superalignmentpairwiseplen_h
#define iqtree_superalignmentpairwiseplen_h
#include "tree/phylosupertreeplen.h"
#include "superalignmentpairwise.h"
class SuperAlignmentPairwisePlen : public SuperAlignmentPairwise {
public:
/**
constructor
*/
SuperAlignmentPairwisePlen();
/**
construct the pairwise alignment from two sequences of a multiple alignment
@param aln input multiple alignment
@param seq_id1 ID of the first sequence
@param seq_id2 ID of the second sequence
*/
SuperAlignmentPairwisePlen(PhyloSuperTreePlen *atree, int seq1, int seq2);
~SuperAlignmentPairwisePlen();
/**
compute the likelihood for a distance between two sequences. Used for the ML optimization of the distance.
@param value x-value of the function
@return log-likelihood
*/
virtual double computeFunction(double value);
/**
This function calculate f(value), first derivative f'(value) and 2nd derivative f''(value).
used by Newton raphson method to minimize the function.
@param value x-value of the function
@param df (OUT) first derivative
@param ddf (OUT) second derivative
@return f(value) of function f you want to minimize
*/
virtual void computeFuncDerv(double value, double &df, double &ddf);
/**
partition information
*/
vector<PartitionInfo>* part_info;
};
#endif
#!/bin/sh -e
CURDIR=`pwd`
if [ -d /usr/share/doc/iqtree/examples ] ; then
EXAMPLEDIR=/usr/share/doc/iqtree/examples
else
EXAMPLEFILE=`find $CURDIR -name example.phy | head -n 1`
EXAMPLEDIR=`dirname $EXAMPLEFILE`
fi
pkg=iqtree
if [ "$ADTTMP" = "" ] ; then
ADTTMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
fi
cd $ADTTMP
cp -a $EXAMPLEDIR/example.phy* $EXAMPLEDIR/example.nex* .
find . -name "*.gz" -exec gunzip \{\} \;
PATHTOEXE=`which iqtree`
if [ "$PATHTOEXE" = "" ] ; then
PATHTOEXE=`find $CURDIR -name iqtree -type f -executable`
fi
#if [ "$PATHTOEXE" = "" ] ; then
# PATHTOEXE=`find $CURDIR -name iqtree -type l`
#fi
echo "Executing tests using $PATHTOEXE ..."
time $PATHTOEXE -s example.phy
time $PATHTOEXE -s example.phy -pre myprefix
time $PATHTOEXE -s example.phy -nni1
time $PATHTOEXE -s example.phy -m TEST
time $PATHTOEXE -s example.phy -m TIM+I+G
time $PATHTOEXE -s example.phy -m TESTONLY
time $PATHTOEXE -s example.phy -m TIM+I+G -bb 1000
time $PATHTOEXE -s example.phy -m TIM+I+G -b 100
time $PATHTOEXE -s example.phy -m TIM+I+G -alrt 1000
time $PATHTOEXE -s example.phy -m TIM+I+G -lbp 1000
time $PATHTOEXE -s example.phy -m TIM+I+G -alrt 1000 -lbp 1000
time $PATHTOEXE -s example.phy -m TIM+I+G -bb 1000 -alrt 1000 -lbp 1000
time $PATHTOEXE -s example.phy -sp example.nex
time $PATHTOEXE-omp -s example.phy -omp 2
if [ $(nproc) -ge 3 ] ; then
time $PATHTOEXE-omp -s example.phy -omp 3
fi
if [ -e example.treels ] ; then
time $PATHTOEXE -s example.phy -z example.treels
time $PATHTOEXE -s example.phy -z example.treels -n 1
time $PATHTOEXE -s example.phy -z example.treels -n 1 -zb 1000
time $PATHTOEXE -s example.phy -z example.treels -n 1 -zb 1000 -zw
fi
time $PATHTOEXE -s example.phy -m 010010+G
if [ -e mymodel ] ; then
time $PATHTOEXE -s example.phy -m mymodel+G
fi
time $PATHTOEXE -s example.phy -m 'TN{2.0,3.0}+G8{0.5}+I{0.15}'
time $PATHTOEXE -s example.phy -m GTR+G+Fo
../tests/run-unit-test
\ No newline at end of file