Skip to content

Commit

Permalink
add --ml_method to bypass modelfinder in IQtree (too slow) and update…
Browse files Browse the repository at this point in the history
… test to use this
  • Loading branch information
Jon Palmer committed Jun 16, 2022
1 parent 1597d3b commit 8a01320
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion funannotate/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, prog):
help='Pre-computed ProteinOrtho POFF')
parser.add_argument('--ml_method', default='iqtree',
choices=['raxml', 'iqtree'], help='ML method')
parser.add_argument('--ml_model', help='IQtree ML model (default: modelfinder)')
parser.add_argument('-d', '--database',
help='Path to funannotate database, $FUNANNOTATE_DB')
parser.add_argument('--no-progress', dest='progress', action='store_false',
Expand Down Expand Up @@ -1232,7 +1233,8 @@ def __init__(self, prog):
lib.log.info("Inferring phylogeny using RAxML")
folder = os.path.join(args.out, 'protortho')
lib.ortho2phylogeny(folder, sco_final, args.num_orthos, busco, args.cpus, args.bootstrap,
phylogeny, outgroup, outgroup_species, outgroup_name, sc_buscos, args.ml_method)
phylogeny, outgroup, outgroup_species, outgroup_name, sc_buscos,
args.ml_method, model=args.ml_model)
with open(os.path.join(args.out, 'phylogeny.html'), 'w') as output:
output.write(lib.HEADER)
output.write(lib.PHYLOGENY)
Expand Down
1 change: 1 addition & 0 deletions funannotate/funannotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@
--outgroup Name of species to use for ML outgroup. Default: no outgroup
--proteinortho Proteinortho POFF results. in TSV format.
--ml_method Maxmimum Liklihood method: Default: iqtree [raxml,iqtree]
--ml_model Substitution model for IQtree. Default: modelfinder
--no-progress Do not print progress to stdout for long sub jobs
""".format(package_name, __version__)

Expand Down
9 changes: 7 additions & 2 deletions funannotate/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from contextlib import contextmanager
from importlib.util import module_for_loader
from Bio import BiopythonWarning
import os
import uuid
Expand Down Expand Up @@ -8284,7 +8285,9 @@ def fasta2dict(Fasta):
return answer


def ortho2phylogeny(folder, df, num, dict, cpus, bootstrap, tmpdir, outgroup, sp_file, name, sc_buscos, ml_method):
def ortho2phylogeny(folder, df, num, dict, cpus, bootstrap, tmpdir,
outgroup, sp_file, name, sc_buscos, ml_method,
model=False):
import pylab
from Bio import Phylo
from Bio.Phylo.Consensus import get_support
Expand Down Expand Up @@ -8353,7 +8356,9 @@ def ortho2phylogeny(folder, df, num, dict, cpus, bootstrap, tmpdir, outgroup, sp
cmd = ['iqtree', '-s', 'phylogeny.trimal.phylip', '-nt', 'AUTO',
'-ntmax', str(cpus), '-seed', '12345', '-bb', '1000']
if outgroup:
cmd = cmd + ['-o', name]
cmd += ['-o', name]
if model:
cmd += ['-m', model]
runSubprocess(cmd, tmpdir, log)
treefile = os.path.join(tmpdir, 'phylogeny.trimal.phylip.treefile')
best = Phylo.read(treefile, 'newick')
Expand Down
2 changes: 1 addition & 1 deletion funannotate/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def runCompareTest(args):
# run predict
runCMD(['funannotate', 'compare',
'-i', input1, input2, input3,
'-o', 'compare', '--cpus', str(args.cpus),
'-o', 'compare', '--cpus', str(args.cpus), '--ml_model', 'LG+G4',
'--outgroup', 'botrytis_cinerea.dikarya'], tmpdir)
print("#########################################################")
# check results
Expand Down

0 comments on commit 8a01320

Please sign in to comment.