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

frequencies: Initialize variables in proper scope #1413

Merged
merged 3 commits into from
Feb 14, 2024
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
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## __NEXT__

### Bug Fixes

* frequencies: Fixed a bug introduced in 24.2.0 that prevented `--method diffusion` from working alongside `--tree`. [#1412][] (@victorlin)

[#1412]: https://github.com/nextstrain/augur/issues/1412

## 24.2.0 (12 February 2024)

Expand Down
18 changes: 9 additions & 9 deletions augur/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ def run(args):
stiffness = args.stiffness
inertia = args.inertia

if args.method == "kde":
# For KDE
weights = None
weights_attribute = None

if args.method == "kde" and args.weights:
# Load weights if they have been provided.
if args.weights:
with open_file(args.weights, "r") as fh:
weights = json.load(fh)

weights_attribute = args.weights_attribute
else:
weights = None
weights_attribute = None
with open_file(args.weights, "r") as fh:
weights = json.load(fh)

weights_attribute = args.weights_attribute

if args.tree:
tree = Phylo.read(args.tree, 'newick')
Expand Down
114 changes: 114 additions & 0 deletions tests/functional/frequencies/cram/diffusion.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
Setup

$ source "$TESTDIR"/_setup.sh

Calculate diffusion-based tip frequencies from a refined tree.

$ ${AUGUR} frequencies \
> --method diffusion \
> --tree "$TESTDIR/../data/tree.nwk" \
> --metadata "$TESTDIR/../data/metadata.tsv" \
> --pivot-interval 3 \
> --output tip-frequencies.json > /dev/null

$ cat tip-frequencies.json
{
"BRA/2016/FC_6706": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"COL/FLR_00008/2015": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"Colombia/2016/ZC204Se": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"DOM/2016/BB_0183": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"EcEs062_16": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"HND/2016/HU_ME59": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"PAN/CDC_259359_V1_V3/2015": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"PRVABC59": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"VEN/UF_1/2016": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"ZKC2/2016": {
"global": [
0.1,
0.1,
0.1,
0.1
]
},
"counts": {
"global": [
0,
5,
5,
0
]
},
"generated_by": {
"program": "augur",
"version": ".*" (re)
},
"pivots": [
2015.7521,
2016.0041,
2016.2527,
2016.5014
]
} (no-eol)
Loading