Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-hot encode in parallel #31

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading