Skip to content

Commit c1012a6

Browse files
committed
add helper function for reverse complement one-hot encodings
1 parent ec5b3c6 commit c1012a6

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

enformer_pytorch/data.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ def seq_indices_to_one_hot(t, padding = -1):
7070
out = out.masked_fill(is_padding[..., None], 0.25)
7171
return out
7272

73+
# augmentations
74+
75+
def one_hot_reverse_complement(one_hot):
76+
*_, n, d = one_hot.shape
77+
assert d == 4, 'must be one hot encoding with last dimension equal to 4'
78+
return torch.flip(one_hot, (-1, -2))
79+
7380
# processing bed files
7481

7582
class FastaInterval():

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
name = 'enformer-pytorch',
55
packages = find_packages(exclude=[]),
66
include_package_data = True,
7-
version = '0.2.11',
7+
version = '0.2.12',
88
license='MIT',
99
description = 'Enformer - Pytorch',
1010
author = 'Phil Wang',

0 commit comments

Comments
 (0)