Skip to content

Commit

Permalink
Merge pull request #31 from calico/thread-1hot
Browse files Browse the repository at this point in the history
1-hot encode in parallel
  • Loading branch information
davek44 authored May 10, 2024
2 parents f8a374b + 68469bf commit d53d397
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 d53d397

Please sign in to comment.