Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alignment filename assumptions #1206

Merged
merged 4 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

* filter, frequencies, refine, parse: Previously, ambiguous dates in the future had a limit of today's date imposed on the upper value but not the lower value. It is now imposed on the lower value as well. [#1171][] (@victorlin)
* refine: `--year-bounds` was ignored in versions 9.0.0 through 20.0.0. It now works. [#1136][] (@victorlin)
* tree: Input alignment filenames which do not end in `.fasta` are now properly handled when using IQ-TREE. Previously their contents were overwritten first by `augur tree` itself (resulting in truncation) and then by the log output of IQ-TREE (resulting in an error). Thanks to Jon Bråte for reporting this bug. [#1206][] (@tsibley)

[#728]: https://github.com/nextstrain/augur/pull/728
[#812]: https://github.com/nextstrain/augur/pull/812
Expand All @@ -32,6 +33,7 @@
[#1196]: https://github.com/nextstrain/augur/pull/1196
[#1200]: https://github.com/nextstrain/augur/pull/1200
[#1203]: https://github.com/nextstrain/augur/pull/1203
[#1206]: https://github.com/nextstrain/augur/pull/1206
[`pandas.read_csv()`]: https://pandas.pydata.org/pandas-docs/version/1.5/reference/api/pandas.read_csv.html

## 21.1.0 (14 March 2023)
Expand Down
6 changes: 3 additions & 3 deletions augur/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def random_string(n):


# IQ-tree messes with taxon names. Hence remove offending characters, reinstaniate later
tmp_aln_file = aln_file.replace(".fasta", "-delim.fasta")
log_file = tmp_aln_file.replace(".fasta", ".iqtree.log")
tmp_aln_file = str(Path(aln_file).with_name(Path(aln_file).stem + "-delim.fasta"))
log_file = str(Path(tmp_aln_file).with_suffix(".iqtree.log"))
num_seqs = 0
with open(tmp_aln_file, 'w', encoding='utf-8') as ofile, open(aln_file, encoding='utf-8') as ifile:
for line in ifile:
Expand All @@ -264,7 +264,7 @@ def random_string(n):

if substitution_model.lower() != "auto":
call = [iqtree, "-ntmax", str(nthreads), "-s", shquote(tmp_aln_file),
"-m", substitution_model, tree_builder_args, ">", log_file]
"-m", shquote(substitution_model), tree_builder_args, ">", shquote(log_file)]
else:
call = [iqtree, "-ntmax", str(nthreads), "-s", shquote(tmp_aln_file), tree_builder_args, ">", shquote(log_file)]

Expand Down
11 changes: 11 additions & 0 deletions tests/functional/tree.t
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ Since the following custom arguments are incompatible with the default IQ-TREE a
> --override-default-args \
> --output "$TMP/tree_raw.nwk" > /dev/null

Build a tree with an input file that doesn't end in .fasta, and ensure it's not overwritten.

$ ${AUGUR} tree \
> --alignment tree/aligned.fa \
> --method iqtree \
> --output "$TMP/tree_raw.nwk" \
> --nthreads 1 > /dev/null

$ sha256sum tree/aligned.fa
169a9f5f70b94e26a2c4ab2b3180d4b463112581438515557a9797adc834863d tree/aligned.fa

Clean up tree log files.

$ rm -f tree/*.log
Expand Down
Loading