Skip to content

Commit

Permalink
add iqtree
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfangs committed Jan 10, 2019
1 parent c00de11 commit 8c946dc
Show file tree
Hide file tree
Showing 9 changed files with 461 additions and 181 deletions.
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PhySpeTree: automatically reconstructing phylogenetic species tree

|PyPI version| |Docs| |License|

**PhySpeTree is implemented in Python 2.7, designed for Linux system.**
**PhySpeTree is implemented in Python language (supports Python2.7+ and Python3+), designed for Linux systems.**

**Documents**: `PhySpeTree documentation <https://yangfangs.github.io/physpetools>`_.

Expand Down Expand Up @@ -226,6 +226,13 @@ Here is an example of setting RAxML advanced options by `--raxml_p`:
Set FastTree advance parameters,
please see `FastTree <http://www.microbesonline.org/fasttree/>`_.

--iqtree
Reconstruct phylogenetic tree by iqtree.

--iqtree_p
Set iqtree advance parameters,
please see `IQ-TREE <http://www.iqtree.org/doc/>`_.

build
^^^^^^^^^^^^^^^^^^^^

Expand Down
9 changes: 9 additions & 0 deletions docs/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ The default option:

> Set FastTree advanced parameters, please see [FastTree Helps](http://www.microbesonline.org/fasttree/).

**--iqtree**

> Reconstruct species tree by iqtree.
**--iqtree_p**

> Set iqtree advanced parameters, please see [IQ-TREE](http://www.microbesonline.org/fasttree/).
## build

The `build` module is used to reconstruct species trees with manually prepared sequences. Advanced options are the same as `autobuild` module.
Expand Down
7 changes: 7 additions & 0 deletions physpetool/phylotree/buildtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from physpetool.phylotree.doclustalw import doclustalw_file, doclustalw
from physpetool.phylotree.dofasttree import doFastTree
from physpetool.phylotree.dogblocks import dogblocks
from physpetool.phylotree.doiqtree import doiqtree
from physpetool.phylotree.domafft import domafft_file, domafft
from physpetool.phylotree.domuscle import domuscle_file, domuscle
from physpetool.phylotree.doraxml import doraxml
Expand All @@ -55,6 +56,7 @@ def build_hcp(in_put, out_put,
args_trimal, args_trimal_p,
args_raxml, args_raxml_p,
args_fasttree, args_fasttree_p,
args_iqtree,args_iqtree_p,
args_thread):
'''reconstruct phylogenetic tree by hcp method'''
out_retrieve = in_put
Expand All @@ -78,6 +80,8 @@ def build_hcp(in_put, out_put,
# reconstruct tree
if args_fasttree:
doFastTree(out_f2p, out_put, args_fasttree_p, args_thread)
elif args_iqtree:
doiqtree(out_f2p, out_put, args_iqtree_p, args_thread)
elif args_raxml:
doraxml(out_f2p, out_put, args_raxml_p, args_thread)

Expand All @@ -90,6 +94,7 @@ def build_srna(in_put, out_put,
args_trimal, args_trimal_p,
args_raxml, args_raxml_p,
args_fasttree, args_fasttree_p,
args_iqtree,args_iqtree_p,
args_thread):
'''reconstruct phylogenetic tree by ssu rna method'''
out_retrieve = in_put
Expand All @@ -113,6 +118,8 @@ def build_srna(in_put, out_put,
if args_fasttree:
args_fasttree_p_add = "-nt " + args_fasttree_p.lstrip()
doFastTree(out_f2p, out_put, args_fasttree_p_add, args_thread)
elif args_iqtree:
doiqtree(out_f2p, out_put, args_iqtree_p, args_thread)
elif args_raxml:
if args_raxml_p == raxmlpara_pro:
args_raxml_p = raxmlpara_dna
Expand Down
57 changes: 57 additions & 0 deletions physpetool/phylotree/doiqtree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# ########################## Copyrights and License #############################
# #
# Copyright 2016 Yang Fang <[email protected]> #
# #
# This file is part of PhySpeTree. #
# https://xiaofeiyangyang.github.io/physpetools/ #
# #
# PhySpeTree is free software: you can redistribute it and/or modify it under #
# the terms of the GNU Lesser General Public License as published by the Free #
# Software Foundation, either version 3 of the License, or (at your option) #
# any later version. #
# #
# PhySpeTree is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
# details. #
# #
# You should have received a copy of the GNU Lesser General Public License #
# along with PhySpeTree. If not, see <http://www.gnu.org/licenses/>. #
# #
# ###############################################################################
"""
function to call iqtree and iqtree reconstruct tree.
"""
import os

import subprocess

from physpetool.phylotree.log import getLogging
from physpetool.softwares.path import getlocalpath

logdoiqtree = getLogging('iqtree')


def doiqtree(inputfile, outputfile, iqtreepara, thread):
# Use FASTA format build tree
# input_fasta = inputfile.replace('.phy', '')
iqtreePath = getlocalpath()
thread_to_str = str(thread)
out_tree_name = os.path.join(outputfile, "iqtree.tree")
if not os.path.exists(outputfile):
os.mkdir(outputfile)
if thread_to_str is '1':
cmd = iqtreePath + "/iqtree " + "-s " + inputfile + " -pre " + out_tree_name + iqtreepara
subprocess.call(cmd, shell=True)
else:
# set the threads
cmd = iqtreePath + "/iqtree " + "-s " + inputfile + " -pre " + out_tree_name + " -nt " + thread_to_str + iqtreepara
subprocess.call(cmd, shell=True)
logdoiqtree.info("Phylogenetic species tree reconstructed by iqtree was completed")


if __name__ == '__main__':
doiqtree("/home/yangfang/PhySpeTree/iqtree-1.6.9-Linux/example.phy",
"/home/yangfang/PhySpeTree/iqtree-1.6.9-Linux/test/",
" -m MF", "1"
)
21 changes: 21 additions & 0 deletions physpetool/physpe/autobuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"""
from physpetool.phylotree.doclustalw import doclustalw_file, doclustalw
from physpetool.phylotree.dofasttree import doFastTree
from physpetool.phylotree.doiqtree import doiqtree
from physpetool.phylotree.domafft import domafft, domafft_file
from physpetool.phylotree.domuscle import domuscle_file, domuscle
from physpetool.phylotree.dogblocks import dogblocks
Expand Down Expand Up @@ -120,6 +121,10 @@ def start_args(input):
default=False, help='Reconstruct phylogenetic tree by FastTree.')
advance_args.add_argument('--fasttree_p', action='store', dest='fasttree_parameter',
default='', help='Set FastTree advance parameters. ')
advance_args.add_argument('--iqtree', action='store_true', dest='iqtree',
default=False, help='Reconstruct phylogenetic tree by iqtree.')
advance_args.add_argument('--iqtree_p', action='store', dest='iqtree_parameter',
default='', help='Set iqtree advance parameters. ')


def starting(args):
Expand Down Expand Up @@ -156,6 +161,7 @@ def starting(args):
args.trimal, args.trimal_parameter,
args.raxml, args.raxml_parameter,
args.fasttree, args.fasttree_parameter,
args.iqtree, args.iqtree_parameter,
args.thread)

# Reconstruct phylogenetic tree by extend highly conserved proteins.
Expand All @@ -169,6 +175,7 @@ def starting(args):
args.trimal, args.trimal_parameter,
args.raxml, args.raxml_parameter,
args.fasttree, args.fasttree_parameter,
args.iqtree, args.iqtree_parameter,
args.thread, args.extenddata)

# Reconstruct phylogenetic tree by extend ssu rna method.
Expand All @@ -182,6 +189,7 @@ def starting(args):
args.trimal, args.trimal_parameter,
args.raxml, args.raxml_parameter,
args.fasttree, args.fasttree_parameter,
args.iqtree, args.iqtree_parameter,
args.thread, args.extenddata)
# Reconstruct phylogenetic tree by highly conserved proteins.
elif args.HCP:
Expand All @@ -194,6 +202,7 @@ def starting(args):
args.trimal, args.trimal_parameter,
args.raxml, args.raxml_parameter,
args.fasttree, args.fasttree_parameter,
args.iqtree, args.iqtree_parameter,
args.thread)

def starting_hcp(in_put, out_put,
Expand All @@ -204,6 +213,7 @@ def starting_hcp(in_put, out_put,
args_trimal, args_trimal_p,
args_raxml, args_raxml_p,
args_fasttree, args_fasttree_p,
args_iqtree,args_iqtree_p,
args_thread):
'''reconstruct phylogenetic tree by hcp method'''
hcp_input, recovery_dic = checkKeggOrganism(in_put)
Expand All @@ -230,6 +240,8 @@ def starting_hcp(in_put, out_put,
# reconstruct tree
if args_fasttree:
doFastTree(out_f2p, out_put, args_fasttree_p, args_thread)
elif args_iqtree:
doiqtree(out_f2p, out_put, args_iqtree_p, args_thread)
elif args_raxml:
doraxml(out_f2p, out_put, args_raxml_p, args_thread)

Expand All @@ -242,6 +254,7 @@ def starting_srna(in_put, out_put,
args_trimal, args_trimal_p,
args_raxml, args_raxml_p,
args_fasttree, args_fasttree_p,
args_iqtree,args_iqtree_p,
args_thread):
'''reconstruct phylogenetic tree by ssu rna method'''
ssu_input,recovery_dic = checkSilvaOrganism(in_put)
Expand Down Expand Up @@ -270,6 +283,8 @@ def starting_srna(in_put, out_put,
if args_fasttree:
args_fasttree_p_add = "-nt " + args_fasttree_p.lstrip()
doFastTree(out_f2p, out_put, args_fasttree_p_add, args_thread)
elif args_iqtree:
doiqtree(out_f2p, out_put, args_iqtree_p, args_thread)
elif args_raxml:
if args_raxml_p is raxmlpara_pro:
args_raxml_p = raxmlpara_dna
Expand All @@ -284,6 +299,7 @@ def starting_ehcp(in_put, out_put,
args_trimal, args_trimal_p,
args_raxml, args_raxml_p,
args_fasttree, args_fasttree_p,
args_iqtree,args_iqtree_p,
args_thread, args_extenddata):
'''reconstruct phylogenetic tree by ehcp method'''
hcp_input, recovery_dic = checkKeggOrganism(in_put)
Expand Down Expand Up @@ -319,6 +335,8 @@ def starting_ehcp(in_put, out_put,
# reconstruct tree
if args_fasttree:
doFastTree(out_f2p, out_put, args_fasttree_p, args_thread)
elif args_iqtree:
doiqtree(out_f2p, out_put, args_iqtree_p, args_thread)
elif args_raxml:
doraxml(out_f2p, out_put, args_raxml_p, args_thread)

Expand All @@ -331,6 +349,7 @@ def starting_esrna(in_put, out_put,
args_trimal, args_trimal_p,
args_raxml, args_raxml_p,
args_fasttree, args_fasttree_p,
args_iqtree,args_iqtree_p,
args_thread, args_extenddata):
'''reconstruct phylogenetic tree by ssu rna extend method'''
extend_check = checkFile(args_extenddata)
Expand Down Expand Up @@ -366,6 +385,8 @@ def starting_esrna(in_put, out_put,
if args_fasttree:
args_fasttree_p_add = "-nt " + args_fasttree_p.lstrip()
doFastTree(out_f2p, out_put, args_fasttree_p_add, args_thread)
elif args_iqtree:
doiqtree(out_f2p, out_put, args_iqtree_p, args_thread)
elif args_raxml:
if args_raxml_p is raxmlpara_pro:
args_raxml_p = raxmlpara_dna
Expand Down
6 changes: 6 additions & 0 deletions physpetool/physpe/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def start_args(input):
default=False, help='Reconstruct phylogenetic tree by FastTree.')
advance_args.add_argument('--fasttree_p', action='store', dest='fasttree_parameter',
default='', help='Set FastTree advance parameters. ')
advance_args.add_argument('--iqtree', action='store_true', dest='iqtree',
default=False, help='Reconstruct phylogenetic tree by iqtree.')
advance_args.add_argument('--iqtree_p', action='store', dest='iqtree_parameter',
default='', help='Set iqtree advance parameters. ')


def starting(args):
Expand Down Expand Up @@ -127,6 +131,7 @@ def starting(args):
args.trimal, args.trimal_parameter,
args.raxml, args.raxml_parameter,
args.fasttree, args.fasttree_parameter,
args.iqtree, args.iqtree_parameter,
args.thread)
elif args.HCP:
setlogdir(out_put)
Expand All @@ -138,4 +143,5 @@ def starting(args):
args.trimal, args.trimal_parameter,
args.raxml, args.raxml_parameter,
args.fasttree, args.fasttree_parameter,
args.iqtree, args.iqtree_parameter,
args.thread)
Binary file added physpetool/softwares/iqtree
Binary file not shown.
Loading

0 comments on commit 8c946dc

Please sign in to comment.