-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from aertslab/util_reverse_comp
reverse complement utility func & docs
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
hot_encoding_to_sequence, | ||
one_hot_encode_sequence, | ||
read_bigwig_region, | ||
reverse_complement, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import numpy as np | ||
|
||
from crested.utils import ( | ||
hot_encoding_to_sequence, | ||
one_hot_encode_sequence, | ||
reverse_complement, | ||
) | ||
|
||
|
||
def test_reverse_complement_string(): | ||
assert reverse_complement("ACGT") == "ACGT" | ||
assert reverse_complement("TGCA") == "TGCA" | ||
assert reverse_complement("AAGGTTCC") == "GGAACCTT" | ||
|
||
|
||
def test_reverse_complement_list_of_strings(): | ||
assert reverse_complement(["ACGT", "TGCA"]) == ["ACGT", "TGCA"] | ||
assert reverse_complement(["AAGGTTCC", "CCGGAATT"]) == ["GGAACCTT", "AATTCCGG"] | ||
|
||
|
||
def test_reverse_complement_one_hot_encoded_array(): | ||
seq_1 = "ACGTA" | ||
seq_1_one_hot = one_hot_encode_sequence(seq_1) | ||
seq_1_rev = reverse_complement(seq_1) | ||
seq_1_rev_one_hot = one_hot_encode_sequence(seq_1_rev) | ||
|
||
np.testing.assert_array_equal(reverse_complement(seq_1_one_hot), seq_1_rev_one_hot) | ||
|
||
seq_2 = "AAGGTTCC" | ||
seq_2_rev = "GGAACCTT" | ||
seq_2_one_hot = one_hot_encode_sequence(seq_2, expand_dim=False) | ||
seq_2_rev_one_hot = reverse_complement(seq_2_one_hot) | ||
seq_2_seq_reversed = hot_encoding_to_sequence(seq_2_rev_one_hot) | ||
|
||
assert seq_2_seq_reversed == seq_2_rev |