Skip to content

Commit

Permalink
1-hot encode in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
davek44 committed May 9, 2024
1 parent 69e46af commit 68469bf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/baskerville/snps.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,20 @@ def score_write(ref_preds, alt_preds, si):
si = 0

with concurrent.futures.ThreadPoolExecutor() as executor:
for sc in tqdm(snp_clusters):
snp_1hot_list = sc.get_1hots(genome_open)
# initialize 1 hot encoding
sc0 = snp_clusters[0]
s1l = executor.submit(sc0.get_1hots, genome_open)

for ci, sc in enumerate(tqdm(snp_clusters)):
# pull latest 1 hot encoding
snp_1hot_list = s1l.result()
ref_1hot = np.expand_dims(snp_1hot_list[0], axis=0)

# submit next 1 hot encoding
if ci + 1 < len(snp_clusters):
sc1 = snp_clusters[ci + 1]
s1l = executor.submit(sc1.get_1hots, genome_open)

# predict reference
ref_preds = []
for shift in options.shifts:
Expand Down

0 comments on commit 68469bf

Please sign in to comment.