Skip to content

Commit 81cda1f

Browse files
Refactor OpenReadingFrameInterval struct to enforce invariants and add missing abstract type definition
1 parent 4d71ffc commit 81cda1f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/types.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export ORFI, OpenReadingFrameInterval
44
export features, sequence, source, finder, frame
55
export groupname, strand, STRAND_BOTH, STRAND_NEG, STRAND_POS, STRAND_NA
66

7+
# abstract type GeneFinderMethod end # This should've been defined here
8+
79
"""
810
struct ORFI{N,F} <: AbstractGenomicInterval{F}
911
@@ -45,14 +47,18 @@ A partial instance `ORFI`
4547
ORFI{NaiveFinder}(1:33, '+', 1)
4648
```
4749
"""
48-
struct OpenReadingFrameInterval{N,F} <: AbstractGenomicInterval{F} #GenomicFeatures
50+
struct OpenReadingFrameInterval{N,F<:GeneFinderMethod} <: AbstractGenomicInterval{F} #GenomicFeatures
4951
groupname::String
5052
first::Int64
5153
last::Int64
5254
strand::Strand
5355
frame::Int8
5456
seq::LongSubSeq{DNAAlphabet{N}}
5557
features::NamedTuple
58+
59+
# todo: add an inner construct to enforce invariants (e.g. frame in (1, 2, 3)) as an outer construct doesn't allow for this
60+
# @assert frame in (1, 2, 3) "Invalid frame value. Frame must be 1, 2, or 3."
61+
# frame in (1, 2, 3) || throw(ArgumentError("The source sequence of the ORFI and the given sequence are different"))
5662
end
5763

5864
function OpenReadingFrameInterval{N,F}(
@@ -65,8 +71,6 @@ function OpenReadingFrameInterval{N,F}(
6571
seq::LongSubSeq{DNAAlphabet{N}},
6672
features::NamedTuple # ::Dict{Symbol,Any} or # ::@NamedTuple{score::Float64, rbs::Any} or @NamedTuple{Vararg{typeof(...)}} NTuple?
6773
) where {N,F<:GeneFinderMethod}
68-
# @assert frame in (1, 2, 3) "Invalid frame value. Frame must be 1, 2, or 3."
69-
# frame in (1, 2, 3) || throw(ArgumentError("The source sequence of the ORFI and the given sequence are different"))
7074
return ORFI{N,F}(groupname, first, last, strand, frame, seq, features) #finder seq schemes
7175
end
7276

0 commit comments

Comments
 (0)