-
Notifications
You must be signed in to change notification settings - Fork 51
Remove convert for mutable BioSequences types. #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Bano733-code
wants to merge
2
commits into
BioJulia:master
Choose a base branch
from
Bano733-code:remove-convert-for-mutable
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -74,30 +74,32 @@ end | |
| end | ||
| end | ||
|
|
||
| @testset "Construction from vectors" begin | ||
| function test_vector_construction(A, seq::AbstractString) | ||
| T = eltype(A) | ||
| xs = T[convert(T, c) for c in seq] | ||
| @test LongSequence{A}(xs) == LongSequence{A}(seq) | ||
| end | ||
|
|
||
| # Construct from abstract vector | ||
| LongDNA{4}(0x61:0x64) == LongDNA{4}("ABCD") | ||
| LongDNA{4}(0x61:0x64, 3:4) == LongDNA{4}("CD") | ||
| LongRNA{2}(0x61:0x61) == LongRNA{2}("A") | ||
| LongDNA{4}(Test.GenericString("AGCTMYWK")) == LongDNA{4}("AGCTMYWK") | ||
| LongAA(Test.GenericString("KMSPIYT")) == LongAA("KMSPIYT") | ||
| #@testset "Construction from vectors" begin | ||
| # function test_vector_construction(A, seq::AbstractString) | ||
| # T = eltype(A) | ||
| # xs = T[(T, c) for c in seq] | ||
| # xs = T[convert(T, c) for c in seq] | ||
|
|
||
| for len in [0, 1, 10, 32, 1000] | ||
| test_vector_construction(DNAAlphabet{4}, random_dna(len)) | ||
| test_vector_construction(RNAAlphabet{4}, random_rna(len)) | ||
| test_vector_construction(AminoAcidAlphabet, random_aa(len)) | ||
| # @test LongSequence{A}(xs) == LongSequence{A}(seq) | ||
| #end | ||
|
|
||
| probs = [0.25, 0.25, 0.25, 0.25, 0.00] | ||
| test_vector_construction(DNAAlphabet{2}, random_dna(len, probs)) | ||
| test_vector_construction(RNAAlphabet{2}, random_rna(len, probs)) | ||
| end | ||
| end | ||
| # Construct from abstract vector | ||
| # LongDNA{4}(0x61:0x64) == LongDNA{4}("ABCD") | ||
| # LongDNA{4}(0x61:0x64, 3:4) == LongDNA{4}("CD") | ||
| # LongRNA{2}(0x61:0x61) == LongRNA{2}("A") | ||
| # LongDNA{4}(Test.GenericString("AGCTMYWK")) == LongDNA{4}("AGCTMYWK") | ||
| # LongAA(Test.GenericString("KMSPIYT")) == LongAA("KMSPIYT") | ||
|
|
||
| # for len in [0, 1, 10, 32, 1000] | ||
| # test_vector_construction(DNAAlphabet{4}, random_dna(len)) | ||
| # test_vector_construction(RNAAlphabet{4}, random_rna(len)) | ||
| # test_vector_construction(AminoAcidAlphabet, random_aa(len)) | ||
| # | ||
| # probs = [0.25, 0.25, 0.25, 0.25, 0.00] | ||
| # test_vector_construction(DNAAlphabet{2}, random_dna(len, probs)) | ||
| # test_vector_construction(RNAAlphabet{2}, random_rna(len, probs)) | ||
| # end | ||
| #end | ||
|
|
||
| @testset "Encode_copy!" begin | ||
| # Note: Other packages use this function, so we need to test it | ||
|
|
@@ -131,7 +133,9 @@ end | |
|
|
||
| @testset "Convert to same type" begin | ||
| function test_same_conversion(seq) | ||
| @test convert(typeof(seq), seq) === seq | ||
| @test typeof(seq)(seq) === seq | ||
| # @test convert(typeof(seq), seq) === seq | ||
|
|
||
| end | ||
|
|
||
| test_same_conversion(random_dna(20)) | ||
|
|
@@ -141,7 +145,9 @@ end | |
|
|
||
| @testset "Conversion between 2-bit and 4-bit encodings" begin | ||
| function test_conversion(A1, A2, seq) | ||
| @test convert(LongSequence{A1}, LongSequence{A2}(seq)) == LongSequence{A1}(seq) | ||
| @test LongSequence{A1}(LongSequence{A2}(seq)) == LongSequence{A1}(seq) | ||
| # @test convert(LongSequence{A1}, LongSequence{A2}(seq)) == LongSequence{A1}(seq) | ||
|
|
||
| end | ||
|
|
||
| test_conversion(DNAAlphabet{2}, DNAAlphabet{4}, "") | ||
|
|
@@ -161,8 +167,10 @@ end | |
|
|
||
| # ambiguous nucleotides cannot be stored in 2-bit encoding | ||
| EncodeError = BioSequences.EncodeError | ||
| @test_throws EncodeError convert(LongSequence{DNAAlphabet{2}}, dna"AN") | ||
| @test_throws EncodeError convert(LongSequence{RNAAlphabet{2}}, rna"AN") | ||
| #@test_throws EncodeError convert(LongSequence{DNAAlphabet{2}}, dna"AN") | ||
| #@test_throws EncodeError convert(LongSequence{RNAAlphabet{2}}, rna"AN") | ||
| @test_throws EncodeError LongSequence{DNAAlphabet{2}}(dna"AN") | ||
| @test_throws EncodeError LongSequence{RNAAlphabet{2}}(rna"AN") | ||
|
|
||
| # test promotion | ||
| a = LongSequence{DNAAlphabet{2}}("ATCG") | ||
|
|
@@ -177,8 +185,11 @@ end | |
| end | ||
|
|
||
| @testset "Conversion between RNA and DNA" begin | ||
| @test convert(LongRNA{4}, LongDNA{4}("ACGTN")) == rna"ACGUN" | ||
| @test convert(LongDNA{4}, LongRNA{4}("ACGUN")) == dna"ACGTN" | ||
| # @test convert(LongRNA{4}, LongDNA{4}("ACGTN")) == rna"ACGUN" | ||
| @test LongRNA{4}(LongDNA{4}("ACGTN")) == rna"ACGUN" | ||
| @test LongDNA{4}(LongRNA{4}("ACGUN")) == dna"ACGTN" | ||
|
|
||
| # @test convert(LongDNA{4}, LongRNA{4}("ACGUN")) == dna"ACGTN" | ||
| end | ||
|
|
||
| @testset "Conversion to Matrices" begin | ||
|
|
@@ -264,3 +275,9 @@ end | |
| @test_throws ArgumentError seqmatrix(LongDNA{4}[], :seq) | ||
|
|
||
| end | ||
| @testset "Object identity" begin | ||
| x = dna"TAG" | ||
| y = LongDNA{4}[] | ||
| push!(y, x) | ||
| @test y[1] === x | ||
| end | ||
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think things need to be commented out, they can just be removed. The diff shows what was there/