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

AUTO-TUNE fixes #38

Merged
merged 5 commits into from
Mar 17, 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
13 changes: 4 additions & 9 deletions hivclustering/networkbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import csv
import argparse
import operator
import sys
import datetime
import time
Expand All @@ -11,14 +10,8 @@
import json
import hppy as hy
import re
from math import log10, floor, sqrt, exp, log
from math import sqrt, exp, log
from hivclustering import *
from functools import partial
import multiprocessing
import hppy as hy
from operator import itemgetter



run_settings = None
uds_settings = None
Expand Down Expand Up @@ -692,7 +685,9 @@ def network_report (threshold, network, max_clusters = [0]):
if len (rec) > 1:
suggested_span = max (rec, key = lambda x: x[0])[0] - min (rec, key = lambda x: x[0])[0]
mean_diff = sum ([k[1] - profile[i-1][1] for i,k in enumerate(profile[1:])]) / (len (profile)-1)
if (suggested_span / mean_diff < log (len (profile))):
if mean_diff == 0.0:
pass
elif (suggested_span / mean_diff < log (len (profile))):
run_settings.threshold = rec[0][0]

if run_settings.threshold is None:
Expand Down
9 changes: 6 additions & 3 deletions scripts/hivnetworkannotate
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ import_settings = arguments.parse_args()

results_json = json.load (import_settings.network)

root_trace_results = False

if('trace_results' in results_json.keys()):
root_trace_results = True

Expand Down Expand Up @@ -143,6 +145,7 @@ else: # TSV import
raise "Invalid field to index on (%s)" % import_settings.index

to_import = {}

try:
for line in csv_reader:
to_import [line[index_on]] = {}
Expand Down Expand Up @@ -172,7 +175,7 @@ for n, values in to_import.items():
for k, val in values.items():
if k in field_transformations:
store_this = field_transformations[k] (val)
if store_this is not None:
if store_this is not None and node_dict is not None:
node_dict[field_names[k]] = store_this
if node_id in uninjected_set[field_names[k]]:
uninjected_set[field_names[k]].remove (node_id)
Expand All @@ -197,7 +200,7 @@ if inject_missing_value:
if import_settings.inplace and import_settings.network is not sys.stdin:
import_settings.output = open (import_settings.network.name, "w")

if 'Settings' in network_json and 'compact_json' in network_json['Settings']:
if 'Settings' in network_json and 'compact_json' in network_json['Settings'] and network_json['Settings']['compact_json']:
ht_compress_network_json (network_json)

# Return with trace_results key
Expand All @@ -208,4 +211,4 @@ else:
to_return = network_json


json.dump(to_return, import_settings.output, separators=(',', ':'))
json.dump(to_return, import_settings.output, indent=2, separators=(',', ':'))
4 changes: 3 additions & 1 deletion scripts/hivnetworkcsv
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def make_hiv_network():


cluster_summary_info = None

prior_network_subclusters = None

if settings().prior is not None:
try:
existing_nodes = {} # node ID -> cluster ID
Expand Down Expand Up @@ -617,5 +618,6 @@ def make_hiv_network():
return network

if __name__ == '__main__':
__spec__ = None
make_hiv_network()