From 09f397aa3aa8c1d1d83c6caf8437c748cefd6920 Mon Sep 17 00:00:00 2001 From: Jakob Nybo Nissen Date: Mon, 3 Mar 2025 11:22:24 +0100 Subject: [PATCH] Do not suggest convert in Rosalind example It was probably an API mistake to allow `convert`ing between mutable, heap- allocated sequences. This is because `convert` is called implicit in Julia, and converting sequences: * Is slow compared to converting integers, causing unexpected allocations * Creates a new, mutable struct with a separate object identity. This can lead to nasty bugs when mutating the original sequence suddenly seems to have no effect, because the observed sequence is actually a distinct copy. --- docs/src/rosalind/02-rna.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/rosalind/02-rna.md b/docs/src/rosalind/02-rna.md index 274d6a7..ea9ad4e 100644 --- a/docs/src/rosalind/02-rna.md +++ b/docs/src/rosalind/02-rna.md @@ -55,7 +55,7 @@ As always, there are lots of ways you *could* do this. This function won't hanndle poorly formatted sequences, for example. Or rather, it will handle them, even though it shouldn't: -### Approach 2 - BioSequences `convert()` +### Approach 2 - BioSequences `LongRNA` As you might expect, `BioSequences.jl` has a way to do this as well. `BioSequences.jl` doesn't just use a `String` to represent sequences, @@ -70,7 +70,7 @@ using BioSequences dna_seq = LongDNA{2}(input_dna) -simple_transcribe(seq::LongDNA{N}) where N = convert(LongRNA{N}, seq) +simple_transcribe(seq::LongDNA{N}) where N = LongRNA{N}(seq) rna_seq = simple_transcribe(dna_seq) ```