Skip to content

Commit fb4e4d3

Browse files
authored
Merge pull request #267 from LCSB-BioCore/mk-supertype
convert the yuge union into a relatively nice supertype match
2 parents faae560 + 2631113 commit fb4e4d3

File tree

3 files changed

+34
-61
lines changed

3 files changed

+34
-61
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
version:
17-
- '1.6' # Oldest supported version of SBML.jl
17+
- '1.10' # LTS
1818
- '1' # This is always the latest stable release in the 1.X series
1919
- 'nightly'
2020
os:
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
version: ${{ matrix.version }}
3131
arch: ${{ matrix.arch }}
32-
- uses: julia-actions/cache@v1
32+
- uses: julia-actions/cache@v2
3333
- uses: julia-actions/julia-buildpkg@latest
3434
- run: |
3535
git config --global user.name Tester

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: julia-actions/setup-julia@latest
19-
- uses: julia-actions/cache@v1
19+
- uses: julia-actions/cache@v2
2020
- name: Install dependencies
2121
run: julia --color=yes --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
2222
- name: Build and deploy

src/structs.jl

Lines changed: 31 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
"""
33
$(TYPEDEF)
44
5+
Common supertype for all SBML.jl objects.
6+
"""
7+
abstract type SBMLObject end
8+
9+
"""
10+
$(TYPEDEF)
11+
512
Part of a measurement unit definition that corresponds to the SBML definition
613
of `Unit`. For example, the unit "per square megahour", Mh^(-2), is written as:
714
@@ -16,7 +23,7 @@ built from multiple `UnitPart`s. See also [`SBML.UnitDefinition`](@ref).
1623
# Fields
1724
$(TYPEDFIELDS)
1825
"""
19-
Base.@kwdef struct UnitPart
26+
Base.@kwdef struct UnitPart <: SBMLObject
2027
kind::String
2128
exponent::Int
2229
scale::Int
@@ -33,7 +40,7 @@ vector of [`SBML.UnitPart`](@ref)s. See the definition of field `units` in
3340
# Fields
3441
$(TYPEDFIELDS)
3542
"""
36-
Base.@kwdef struct UnitDefinition
43+
Base.@kwdef struct UnitDefinition <: SBMLObject
3744
name::Maybe{String} = nothing
3845
unit_parts::Vector{UnitPart}
3946
end
@@ -43,7 +50,7 @@ $(TYPEDEF)
4350
4451
Abstract type for all kinds of gene product associations
4552
"""
46-
abstract type GeneProductAssociation end
53+
abstract type GeneProductAssociation <: SBMLObject end
4754

4855
"""
4956
$(TYPEDEF)
@@ -82,9 +89,11 @@ struct GPAOr <: GeneProductAssociation
8289
end
8390

8491
"""
92+
$(TYPEDEF)
93+
8594
A simplified representation of MathML-specified math AST
8695
"""
87-
abstract type Math end
96+
abstract type Math <: SBMLObject end
8897

8998
"""
9099
$(TYPEDEF)
@@ -186,7 +195,7 @@ qualifier, a list of resources, and possibly nested CV terms.
186195
# Fields
187196
$(TYPEDFIELDS)
188197
"""
189-
Base.@kwdef struct CVTerm
198+
Base.@kwdef struct CVTerm <: SBMLObject
190199
biological_qualifier::Maybe{Symbol} = nothing
191200
model_qualifier::Maybe{Symbol} = nothing
192201
resource_uris::Vector{String} = []
@@ -202,7 +211,7 @@ units and constantness information.
202211
# Fields
203212
$(TYPEDFIELDS)
204213
"""
205-
Base.@kwdef struct Parameter
214+
Base.@kwdef struct Parameter <: SBMLObject
206215
name::Maybe{String} = nothing
207216
value::Maybe{Float64} = nothing
208217
units::Maybe{String} = nothing
@@ -222,7 +231,7 @@ SBML Compartment with sizing information.
222231
# Fields
223232
$(TYPEDFIELDS)
224233
"""
225-
Base.@kwdef struct Compartment
234+
Base.@kwdef struct Compartment <: SBMLObject
226235
name::Maybe{String} = nothing
227236
constant::Maybe{Bool} = nothing
228237
spatial_dimensions::Maybe{Int} = nothing
@@ -243,7 +252,7 @@ SBML SpeciesReference.
243252
# Fields
244253
$(TYPEDFIELDS)
245254
"""
246-
Base.@kwdef struct SpeciesReference
255+
Base.@kwdef struct SpeciesReference <: SBMLObject
247256
id::Maybe{String} = nothing
248257
species::String
249258
stoichiometry::Maybe{Float64} = nothing
@@ -261,7 +270,7 @@ unit names), and objective coefficient (`oc`). Also may contains `notes` and
261270
# Fields
262271
$(TYPEDFIELDS)
263272
"""
264-
Base.@kwdef struct Reaction
273+
Base.@kwdef struct Reaction <: SBMLObject
265274
name::Maybe{String} = nothing
266275
reactants::Vector{SpeciesReference} = []
267276
products::Vector{SpeciesReference} = []
@@ -283,7 +292,7 @@ $(TYPEDEF)
283292
284293
Abstract type representing SBML rules.
285294
"""
286-
abstract type Rule end
295+
abstract type Rule <: SBMLObject end
287296

288297
"""
289298
$(TYPEDEF)
@@ -331,7 +340,7 @@ SBML constraint.
331340
# Fields
332341
$(TYPEDFIELDS)
333342
"""
334-
struct Constraint
343+
struct Constraint <: SBMLObject
335344
math::Math
336345
message::String
337346
end
@@ -345,7 +354,7 @@ identifier, `formula`, `charge`, and additional `notes` and `annotation`.
345354
# Fields
346355
$(TYPEDFIELDS)
347356
"""
348-
Base.@kwdef struct Species
357+
Base.@kwdef struct Species <: SBMLObject
349358
name::Maybe{String} = nothing
350359
compartment::String
351360
boundary_condition::Maybe{Bool} = nothing
@@ -372,7 +381,7 @@ Gene product metadata.
372381
# Fields
373382
$(TYPEDFIELDS)
374383
"""
375-
Base.@kwdef struct GeneProduct
384+
Base.@kwdef struct GeneProduct <: SBMLObject
376385
label::String
377386
name::Maybe{String} = nothing
378387
metaid::Maybe{String} = nothing
@@ -390,7 +399,7 @@ Custom function definition.
390399
# Fields
391400
$(TYPEDFIELDS)
392401
"""
393-
Base.@kwdef struct FunctionDefinition
402+
Base.@kwdef struct FunctionDefinition <: SBMLObject
394403
name::Maybe{String} = nothing
395404
metaid::Maybe{String} = nothing
396405
body::Maybe{Math} = nothing
@@ -406,7 +415,7 @@ $(TYPEDEF)
406415
# Fields
407416
$(TYPEDFIELDS)
408417
"""
409-
Base.@kwdef struct EventAssignment
418+
Base.@kwdef struct EventAssignment <: SBMLObject
410419
variable::String
411420
math::Maybe{Math} = nothing
412421
end
@@ -417,7 +426,7 @@ $(TYPEDEF)
417426
# Fields
418427
$(TYPEDFIELDS)
419428
"""
420-
Base.@kwdef struct Trigger
429+
Base.@kwdef struct Trigger <: SBMLObject
421430
persistent::Bool
422431
initial_value::Bool
423432
math::Maybe{Math} = nothing
@@ -429,7 +438,7 @@ $(TYPEDEF)
429438
# Fields
430439
$(TYPEDFIELDS)
431440
"""
432-
Base.@kwdef struct Objective
441+
Base.@kwdef struct Objective <: SBMLObject
433442
type::String
434443
flux_objectives::Dict{String,Float64} = Dict()
435444
end
@@ -440,7 +449,7 @@ $(TYPEDEF)
440449
# Fields
441450
$(TYPEDFIELDS)
442451
"""
443-
Base.@kwdef struct Event
452+
Base.@kwdef struct Event <: SBMLObject
444453
use_values_from_trigger_time::Bool
445454
name::Maybe{String} = nothing
446455
trigger::Maybe{Trigger} = nothing
@@ -453,7 +462,7 @@ $(TYPEDEF)
453462
# Fields
454463
$(TYPEDFIELDS)
455464
"""
456-
Base.@kwdef struct Member
465+
Base.@kwdef struct Member <: SBMLObject
457466
id::Maybe{String} = nothing
458467
metaid::Maybe{String} = nothing
459468
name::Maybe{String} = nothing
@@ -471,7 +480,7 @@ $(TYPEDEF)
471480
# Fields
472481
$(TYPEDFIELDS)
473482
"""
474-
Base.@kwdef struct Group
483+
Base.@kwdef struct Group <: SBMLObject
475484
metaid::Maybe{String} = nothing
476485
kind::Maybe{String} = nothing
477486
name::Maybe{String} = nothing
@@ -494,7 +503,7 @@ identifiers.
494503
# Fields
495504
$(TYPEDFIELDS)
496505
"""
497-
Base.@kwdef struct Model
506+
Base.@kwdef struct Model <: SBMLObject
498507
parameters::Dict{String,Parameter} = Dict()
499508
units::Dict{String,UnitDefinition} = Dict()
500509
compartments::Dict{String,Compartment} = Dict()
@@ -531,40 +540,4 @@ end
531540
# Use this to regenerate the Union contents moreless automatically:
532541
#
533542
# sed -ne 's/.*\<struct \([A-Z][A-Za-z0-9]*\)\>.*/\1,/p' src/structs.jl
534-
Base.Broadcast.broadcastable(
535-
x::T,
536-
) where {
537-
T<:Union{
538-
UnitPart,
539-
UnitDefinition,
540-
GPARef,
541-
GPAAnd,
542-
GPAOr,
543-
MathVal,
544-
MathIdent,
545-
MathConst,
546-
MathTime,
547-
MathAvogadro,
548-
MathApply,
549-
MathLambda,
550-
CVTerm,
551-
Parameter,
552-
Compartment,
553-
SpeciesReference,
554-
Reaction,
555-
AlgebraicRule,
556-
AssignmentRule,
557-
RateRule,
558-
Constraint,
559-
Species,
560-
GeneProduct,
561-
FunctionDefinition,
562-
EventAssignment,
563-
Trigger,
564-
Objective,
565-
Event,
566-
Member,
567-
Group,
568-
Model,
569-
},
570-
} = Ref(x)
543+
Base.Broadcast.broadcastable(x::SBMLObject) = Ref(x)

0 commit comments

Comments
 (0)