From 44c8a27ffa2852caa69436b5333a1b354f41ebb8 Mon Sep 17 00:00:00 2001 From: John Lees Date: Mon, 27 Jan 2025 15:30:56 +0000 Subject: [PATCH] Remove debugging prints --- PopPUNK/network.py | 81 -------------------------------------------- PopPUNK/sketchlib.py | 2 -- 2 files changed, 83 deletions(-) diff --git a/PopPUNK/network.py b/PopPUNK/network.py index 054f4307..6e9b4d7a 100644 --- a/PopPUNK/network.py +++ b/PopPUNK/network.py @@ -16,7 +16,6 @@ from multiprocessing import Pool import pickle import graph_tool.all as gt -import pp_sketchlib # Load GPU libraries try: @@ -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), @@ -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 diff --git a/PopPUNK/sketchlib.py b/PopPUNK/sketchlib.py index 3e1b8685..29c0445a 100644 --- a/PopPUNK/sketchlib.py +++ b/PopPUNK/sketchlib.py @@ -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,