bio-ex / bio_ex_sequence

Sequence types, protocols, and reference implementations
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add an `annotate` method and an `Annotation` struct to the `Sequence` space #7

Open pcapel opened 7 months ago

pcapel commented 7 months ago

Basically the title, but the way I envision this is essentially:

defmodule Annotation do
  defstruct note: "", start: 0, end: 0, color: ""
end

Which is then part of the sequences, and can be manipulated with the annotate style functions, such as:

alias Bio.Sequence, as: Seq
Seq.DnaStrand("ttaggattagttg")
|> Seq.annotate("super primer", color: "red", start: 0)

%Bio.Sequence.DnaStrand{
    sequence: ~c"ttaggattagttg", 
    annotations: [%Annotation{note: "super primer", start: 0, end: 13, color: "red"}]
}

Something like that.

pcapel commented 7 months ago

The first thought is, how do you update the annotations? They should probably have an identifier. I would imagine a UUIDv7. That would be auto-generated. But then we start to really beg the question of integration with Ecto (imo), since this is getting weirdly close to e.g. changesets and Schema.