Skip to content

Commit

Permalink
Merge pull request #1413: frequencies: Initialize variables in proper…
Browse files Browse the repository at this point in the history
… scope
  • Loading branch information
victorlin committed Feb 14, 2024
2 parents 704fca7 + 313924b commit c53b0e9
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 9 deletions.
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)

0 comments on commit c53b0e9

Please sign in to comment.