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 for using visualise with indiv refine ref-db #261

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Changes from 1 commit
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
17 changes: 13 additions & 4 deletions PopPUNK/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,23 @@ def joinClusterDicts(d1, d2):
d1 (dict of dicts)
d1 with d2 appended
"""
if d1.keys() != d2.keys():
matching_cols = set(d1.keys()).intersection(d2.keys())
if len(matching_cols) == 0:
sys.stderr.write("Cluster columns not compatible\n")
johnlees marked this conversation as resolved.
Show resolved Hide resolved
sys.stderr.write(f"{d1.keys()} {d2.keys()}\n")
sys.exit(1)

missing_cols = []
for column in d1.keys():
# Combine dicts: https://stackoverflow.com/a/15936211
d1[column] = \
dict(chain.from_iterable(d.items() for d in (d1[column], d2[column])))
if column in matching_cols:
# Combine dicts: https://stackoverflow.com/a/15936211
d1[column] = \
dict(chain.from_iterable(d.items() for d in (d1[column], d2[column])))
else:
missing_cols.append(column)

for missing in missing_cols:
del d1[missing]

return d1

Expand Down