Skip to content

Commit

Permalink
Remove debugging prints
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlees committed Jan 27, 2025
1 parent 72e18d8 commit 44c8a27
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 83 deletions.
81 changes: 0 additions & 81 deletions PopPUNK/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from multiprocessing import Pool
import pickle
import graph_tool.all as gt
import pp_sketchlib

# Load GPU libraries
try:
Expand Down Expand Up @@ -1196,8 +1195,6 @@ def construct_network_from_assignments(rlist, qlist, assignments, within_label =
weights = process_weights(distMat, weights_type)

# Convert edge indices to tuples
# TODO remove this print
print(f"{len(assignments)} assignments {len(rlist)} refs {len(qlist)} queries\n")
connections = poppunk_refine.generateTuples(assignments,
within_label,
self = (rlist == qlist),
Expand Down Expand Up @@ -2092,81 +2089,3 @@ def remove_non_query_components(G, rlist, qlist, use_gpu = False):
query_subgraph = gt.GraphView(G, vfilt=query_filter)

return query_subgraph, pruned_names

def generate_network_from_distances(mode,
model,
core_distMat = None,
acc_distMat = None,
sparse_mat = None,
previous_mst = None,
combined_seq = None,
rlist = None,
old_rlist = None,
distance_type = 'core',
threads = 1,
gpu_graph = False):
"""
Generates a network from a distance matrix.
Args:
mode (str)
Whether a core or sparse distance matrix is being analysed
model (ClusterFit or LineageFit)
A fitted model object
coreMat (numpy.array)
NxN array of core distances for N sequences
accMat (numpy.array)
NxN array of accessory distances for N sequences
sparse_mat (scipy or cupyx sparse matrix)
Sparse matrix of kNN from lineage fit
previous_mst (str or graph object)
Path of file containing existing network, or already-loaded
graph object
combined_seq (list)
Ordered list of isolate names
rlist (list)
List of reference sequence labels
old_rlist (list)
List of reference sequence labels for previous MST
distance_type (str)
Whether to use core or accessory distances for MST calculation
or dense network weighting
threads (int)
Number of threads to use in calculations
use_gpu (bool)
Whether to use GPUs for network construction
Returns:
G (graph)
The resulting network
pruned_names (list)
The labels of the sequences in the pruned network
"""
if mode == 'sparse':
G = generate_mst_from_sparse_input(sparse_mat,
rlist,
old_rlist = old_rlist,
previous_mst = previous_mst,
gpu_graph = gpu_graph)
elif mode == 'dense':
# Get distance matrix
complete_distMat = \
np.hstack((pp_sketchlib.squareToLong(core_distMat, threads).reshape(-1, 1),
pp_sketchlib.squareToLong(acc_distMat, threads).reshape(-1, 1)))
# Identify short distances and use these to extend the model
indivAssignments = model.assign(complete_distMat)
G = construct_network_from_assignments(combined_seq,
combined_seq,
indivAssignments,
model.within_label,
distMat = complete_distMat,
weights_type = distance_type,
use_gpu = gpu_graph,
summarise = False)
if gpu_graph:
G = cugraph.minimum_spanning_tree(G, weight='weights')

else:
sys.stderr.write('Unknown network mode - expect dense or sparse\n')

return G
2 changes: 0 additions & 2 deletions PopPUNK/sketchlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,6 @@ def queryDatabase(rNames, qNames, dbPrefix, queryPrefix, klist, self = True, num

# Calls to library
query_db = queryPrefix + "/" + os.path.basename(queryPrefix)
# TODO remove this print
print(f"{len(rNames)} refs {len(qNames)} queries\n")
distMat = pp_sketchlib.queryDatabase(ref_db_name=ref_db,
query_db_name=query_db,
rList=rNames,
Expand Down

0 comments on commit 44c8a27

Please sign in to comment.