Skip to content
Browse files

Merge pull request #307 from nextstrain/setrecursionlimit

augur/ set recursion limit from env variable
  • Loading branch information...
rneher committed Jul 3, 2019
2 parents 108053e + 6fc3f61 commit 6df41336cbab766ef5d7e7115ea2f409b25ede1b
Showing with 26 additions and 4 deletions.
  1. +5 −3 augur/
  2. +1 −1 augur/
  3. +19 −0 docs/envvars.rst
  4. +1 −0 docs/usage.rst
@@ -3,15 +3,17 @@

import argparse
import re
from sys import exit
import re, os, sys
from types import SimpleNamespace
from . import parse, filter, align, tree, refine, ancestral
from . import traits, translate, mask, titers, frequencies, export
from . import validate, sequence_traits, clades, version
from . import reconstruct_sequences, lbi, distance
from .utils import first_line

recursion_limit = os.environ.get("AUGUR_RECURSION_LIMIT")
if recursion_limit:

@@ -93,7 +95,7 @@ def add_version_alias(parser):
class run_version_command(argparse.Action):
def __call__(self, *args, **kwargs):
opts = SimpleNamespace()
exit( )
sys.exit( )

return parser.add_argument(
@@ -178,7 +178,7 @@ def build_iqtree(aln_file, out_file, substitution_model="GTR", clean_up=True, nt
run_shell_command(cmd, raise_errors = True)
T =".treefile", 'newick')
shutil.copyfile(tmp_aln_file+".treefile", out_file)
for n in T.get_terminals():
for n in T.find_clades(terminal=True): ='_X_X_','/').replace('_Y_Y_','|').replace("_X_Y_","(").replace("_Y_X_",")")
#this allows the user to check intermediate output, as tree.nwk will be
if clean_up:
@@ -0,0 +1,19 @@
Environment variables

Augur's behaviour can be globally modified by the values of some specific environment variables.
These can be especially useful in the context of an entire pipeline or workflow which uses Augur, as the environment variables can be set once for all Augur commands at the start of the pipeline.

If set to a non-empty value, all JSON output produced by Augur will be minified by omitting indentation and newlines.

Minifying the JSON will substantially reduce file sizes, which is helpful for large, deeply nested trees.

If set to a non-empty value, the Python recursion limit will be set to the given value early in Augur's execution by calling :func:`sys.setrecursionlimit`.

Generally there is no need to set this environment variable.
You may need to if you find yourself encountering :class:`RecursionError` while processing a very unbalanced tree.
@@ -7,3 +7,4 @@ Using Augur


0 comments on commit 6df4133

Please sign in to comment.
You can’t perform that action at this time.