Skip to content

Commit

Permalink
pass cores to distance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
adraismawur committed Aug 25, 2023
1 parent 62a185d commit bf06fe9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions bigscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ def callback(tasks_done):

logging.info(mix_bin)

create_bin_network_edges(mix_bin, mix_network, run.comparison.alignment_mode)
create_bin_network_edges(
mix_bin, mix_network, run.comparison.alignment_mode, run.cores
)

mix_network.generate_families_cutoff("dist", 0.3)

Expand Down Expand Up @@ -241,7 +243,9 @@ def callback(tasks_done):

logging.info(bin)

create_bin_network_edges(bin, bin_network, run.comparison.alignment_mode)
create_bin_network_edges(
bin, bin_network, run.comparison.alignment_mode, run.cores
)

bin_network.generate_families_cutoff("dist", 0.3)

Expand Down
11 changes: 6 additions & 5 deletions src/comparison/legacy_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@


def create_bin_network_edges(
bin: BGCBin, network: BSNetwork, alignment_mode: str
bin: BGCBin, network: BSNetwork, alignment_mode: str, cores: int
): # pragma no cover
logging.info("Using %d cores for distance calculation", cores)
# first step is to calculate the Jaccard of all pairs. This is pretty fast, but
# could be optimized by multiprocessing for very large bins
logging.info("Calculating Jaccard for %d pairs", bin.num_pairs())

related_pairs = calculate_jaccard_multiprocess(bin, network)
related_pairs = calculate_jaccard_multiprocess(bin, network, cores)

# any pair that had a jaccard of 0 are put into the network and should not be
# processed again. If there are no more pairs left, leave the workflow
Expand All @@ -43,7 +44,7 @@ def create_bin_network_edges(

logging.info("Performing LCS for %d pairs with Jaccard > 0", len(related_pairs))
pairs_need_expand, pairs_no_expand = get_lcs_multiprocess(
related_pairs, alignment_mode
related_pairs, alignment_mode, cores
)

if len(pairs_need_expand) > 0:
Expand Down Expand Up @@ -82,14 +83,14 @@ def create_bin_network_edges(
"Calculating score for %d pairs that were reset or did not need expansion",
len(pairs_no_expand),
)
calculate_scores_multiprocess(bin, pairs_no_expand, network)
calculate_scores_multiprocess(bin, pairs_no_expand, network, cores)

if len(expanded_pairs) > 0:
logging.info(
"Calculating score for %d pairs that were expanded",
len(expanded_pairs),
)
calculate_scores_multiprocess(bin, expanded_pairs, network)
calculate_scores_multiprocess(bin, expanded_pairs, network, cores)


def get_lcs_worker_method(
Expand Down

0 comments on commit bf06fe9

Please sign in to comment.