-
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.
Loading status checks…
Define AlphabetExtractor type
Showing
8 changed files
with
83 additions
and
31 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Creates complete alphabet of all seen symbols at each position in provided sequences. | ||
AlphabetExctractor() | ||
Constructs `AlphabetExtractor`. | ||
""" | ||
struct AlphabetExctractor <: AbstractAlphabetExtractor end | ||
|
||
function (::AlphabetExctractor)(sequences::AbstractVector{Vector{Char}}) | ||
alphabets = Vector{Set{Char}}(undef, length(sequences[1])) | ||
for position in 1:length(sequences[1]) | ||
symbols = Vector{Char}(undef, length(sequences)) | ||
for (p, parent) in enumerate(sequences) | ||
symbols[p] = parent[position] | ||
end | ||
alphabets[position] = Set(symbols) | ||
end | ||
return alphabets | ||
end |
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 @@ | ||
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@testset "alphabet_extractor.jl" begin | ||
ae = DESilico.AlphabetExctractor() | ||
@test typeof(ae) == DESilico.AlphabetExctractor | ||
|
||
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']) | ||
end |
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