-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add positions argument to alphabet extractors
- Loading branch information
Showing
6 changed files
with
27 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Extracts an alphabet for each position of sequences with same length. | ||
Structures derived from this type have to implement the following method: | ||
`(::CustomAlphabetExtractor)(sequences::AbstractVector{Vector{Char}}, positions::AbstractVector{Int})` | ||
This method should return an alphabet from `sequences` for each position in `positions` as a subtype of `AbstractVector{Set{Char}}`. | ||
This method can assume that `sequences` have the same length. | ||
To extract alphabets at all positions, the following call can be used: | ||
`(::CustomAlphabetExtractor)(sequences::AbstractVector{Vector{Char}})` | ||
""" | ||
abstract type AbstractAlphabetExtractor end | ||
|
||
(ae::AbstractAlphabetExtractor)(sequences::AbstractVector{Vector{Char}}) = ae(sequences, collect(eachindex(sequences[1]))) |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
include("abstract_alphabet_extractor.jl") | ||
include("alphabet_extractor.jl") |
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
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 |
---|---|---|
@@ -1,14 +1,19 @@ | ||
@testset "alphabet_extractor.jl" begin | ||
ae = DESilico.AlphabetExtractor() | ||
@test typeof(ae) == DESilico.AlphabetExtractor | ||
|
||
parents = [ | ||
['A', 'A', 'A'], | ||
['A', 'B', 'C'], | ||
] | ||
|
||
alphabets = ae(parents) | ||
@test length(alphabets) == 3 | ||
@test alphabets[1] == Set(['A']) | ||
@test alphabets[2] == Set(['A', 'B']) | ||
@test alphabets[3] == Set(['A', 'C']) | ||
|
||
alphabets = ae(parents, [3, 1]) | ||
@test length(alphabets) == 2 | ||
@test alphabets[1] == Set(['A', 'C']) | ||
@test alphabets[2] == Set(['A']) | ||
end |