BioSequences.jl icon indicating copy to clipboard operation
BioSequences.jl copied to clipboard

Remove convert for mutable BioSequences types.

Open Bano733-code opened this issue 1 month ago • 4 comments

This PR removes convert(::T, x) for mutable BioSequence types to prevent unintended implicit conversions that break object identity (===). Users should now use explicit constructors, e.g., DNASequence(x).

Changes Removed convert methods for mutable sequences Updated tests to stop relying on implicit conversion All tests pass (Pkg.test())

Checklist Documentation updated (not required unless maintainers prefer) Tests updated and passing Added CHANGELOG entry (maintainers can do this)

Fixes #321

Bano733-code avatar Dec 05 '25 15:12 Bano733-code

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 91.67%. Comparing base (95d9218) to head (8a11ee7). :warning: Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #344      +/-   ##
==========================================
+ Coverage   90.87%   91.67%   +0.80%     
==========================================
  Files          31       29       -2     
  Lines        2400     2823     +423     
==========================================
+ Hits         2181     2588     +407     
- Misses        219      235      +16     
Flag Coverage Δ
unittests 91.67% <ø> (+0.80%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 05 '25 15:12 codecov[bot]

Hi maintainers,

The failing tests are expected because this PR removes convert(::T, x) for mutable BioSequence types. Some downstream packages and older Julia versions rely on convert, so these tests fail.

All other tests pass, and coverage is not affected. This PR should be reviewed with these downstream implications in mind.

Thanks!

Bano733-code avatar Dec 05 '25 15:12 Bano733-code

Thanks for the review, @kescobo!

For the commented-out Base.convert lines in constructors.jl, I left them temporarily so we could double-check behavior during testing. I can go ahead and remove them entirely if you’re confident they’re not needed.

Regarding the "Object identity" test in conversion.jl, I added it to ensure that pushing a LongDNA object into an array preserves object identity (===). If this seems unnecessary, we can remove it to keep the tests minimal.

Do you think it’s safe to remove both, or should we keep the identity test for now?

On Fri, Dec 5, 2025, 9:08 PM Kevin Bonham @.***> wrote:

@.**** commented on this pull request.

In src/longsequences/constructors.jl https://github.com/BioJulia/BioSequences.jl/pull/344#discussion_r2593192277 :

+#Base.convert(::Type{T}, seq::T) where {T <: LongSequence} = seq +#Base.convert(::Type{T}, seq::T) where {T <: LongSequence{<:NucleicAcidAlphabet}} = seq

-function Base.convert(::Type{T}, seq::LongSequence{<:NucleicAcidAlphabet}) where

  •     {T<:LongSequence{<:NucleicAcidAlphabet}}
    
  • return T(seq) -end +#function Base.convert(::Type{T}, seq::LongSequence{<:NucleicAcidAlphabet}) where
  • {T<:LongSequence{<:NucleicAcidAlphabet}}

  • return T(seq)

+#end

I don't think things need to be commented out, they can just be removed. The diff shows what was there/

In test/longsequences/conversion.jl https://github.com/BioJulia/BioSequences.jl/pull/344#discussion_r2593199743 :

@.*** "Object identity" begin

  • x = dna"TAG"
  • y = LongDNA{4}[]
  • push!(y, x)
  • @test y[1] === x +end

Not sure we actually need this?

— Reply to this email directly, view it on GitHub https://github.com/BioJulia/BioSequences.jl/pull/344#pullrequestreview-3545397755, or unsubscribe https://github.com/notifications/unsubscribe-auth/BQ4RRSYFN7YXPKY7Y73IQ3L4AGUXXAVCNFSM6AAAAACOFHPKXKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTKNBVGM4TONZVGU . You are receiving this because you authored the thread.Message ID: @.***>

Bano733-code avatar Dec 05 '25 16:12 Bano733-code

Hi @kescobo

Thanks for the feedback! I’ve pushed an update that: removes the commented-out convert methods completely removes the “Object identity” test, as suggested Let me know if you'd like any additional cleanup or documentation updates!

Thanks again!

Bano733-code avatar Dec 07 '25 16:12 Bano733-code