neherlab / treetime

Maximum likelihood inference of time stamped phylogenies and ancestral reconstruction
MIT License
224 stars 55 forks source link

New crash when running without alignment #250

Closed theosanderson closed 1 year ago

theosanderson commented 1 year ago

Hello,

As part of some benchmarking I run:

treetime --dates tree_dates.tsv --tree distance_tree.nwk --sequence-length 1000 --keep-root --keep-polytomies

In 0.9.6 this runs without any error messages. In 0.10.1 I think it still works, but after outputting some files it crashes with:

--- tree saved in nexus format as  
         2023-07-28-0010_treetime/timetree.nexus

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/bin/treetime", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/__main__.py", line 21, in main
    return_code = params.func(params)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/argument_parser.py", line 233, in toplevel
    timetree(params)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/wrappers.py", line 332, in timetree
    return run_timetree(myTree, params, outdir)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/wrappers.py", line 480, in run_timetree
    export_sequences_and_tree(myTree, basename, is_vcf, params.zero_based,
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/CLI_io.py", line 185, in export_sequences_and_tree
    auspice = create_auspice_json(tt, timetree=timetree, confidence=confidence)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/CLI_io.py", line 295, in create_auspice_json
    n_json["children"].append(node_to_json(c, n_json["node_attrs"]["div"]))
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/CLI_io.py", line 280, in node_to_json
    j["branch_attrs"]["mutations"] = {"nuc": [f"{a}{pos+1}{d}" for a,pos,d in n.mutations if d in "ACGT-"]}
  File "/opt/homebrew/Caskroom/miniconda/base/envs/new/lib/python3.10/site-packages/treetime/treeanc.py", line 33, in mutations
    elif (not node.tt.reconstructed_tip_sequences) and node.name in node.tt.data.aln:
TypeError: argument of type 'NoneType' is not iterable

No pressure from me to fix, just flagging in case helpful.

corneliusroemer commented 1 year ago

Thanks for reporting! ~Would it be possible to provide the input/output files for easier debugging? That'd be fab!~ Never mind, this should be reproducible with example/test files ;)

I can reproduce in the treetime repo running:

 treetime --dates test/treetime_examples/data/ebola/ebola.metadata.csv --tree test/treetime_examples/data/ebola/ebola.nwk --sequence-length 1000