Skip to content

Commit

Permalink
Update mutagenizer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
evanseitz committed Apr 3, 2024
1 parent 6090263 commit 9820ef8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions squid/mutagenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ def swap_elements(x, t):
# mutagenize each sequence based on number of mutations; i.e., samples from alphabet pool
one_hot = np.zeros(shape=(num_sim, L, A))
for i, num_mut in enumerate(tqdm(num_muts, desc="Mutagenesis")):
options_list = choice(alphabet_pool, size=num_mut, replace=True) # sample 'num_mut' characters from alphabet_pool with replacement
mut_seq = ''.join(swap_elements(seq, options_list))
one_hot[i,:,:] = seq2twohot(mut_seq)
if i == 0:
one_hot[i,:,:] = seq2twohot(''.join(seq))
else:
options_list = choice(alphabet_pool, size=num_mut, replace=True) # sample 'num_mut' characters from alphabet_pool with replacement
mut_seq = ''.join(swap_elements(seq, options_list))
one_hot[i,:,:] = seq2twohot(mut_seq)

return one_hot

Expand Down

0 comments on commit 9820ef8

Please sign in to comment.