Skip to content

Commit

Permalink
fix docs + format + add SBO warning
Browse files Browse the repository at this point in the history
  • Loading branch information
stelmo committed May 13, 2023
1 parent 744bed5 commit 6eccfdd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 44 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@ open("my_e_coli_core_report.json", "w") do io
end
```
See the function documentation for additional test configuration, and several
performance gotchas and notes about MEMOTE compability.
See the function documentation for additional test configuration information.
Note, the tests implemented here are significantly more conservative than in the
original Memote. In particular, no heuristics are used to guess reactions types,
e.g. biomass, atp maintenance, transporters, exchanges, etc. Only [SBO
annotations](https://github.com/EBI-BioModels/SBO/blob/master/SBO_OBO.obo) are
used for this purpose, because only they are standardized. Consequently, all
tests that rely on properly annotated reactions will fail here if this is not
incorporated in a model.
The implementation in FBCModelTests.jl is mostly authored by
St. Elmo Wilken ([@stelmo](https://github.com/stelmo))
Expand Down
8 changes: 4 additions & 4 deletions docs/src/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ Pages = ["src/memote/checks/Consistency.jl"]
### Metabolite checks

```@autodocs
Modules = [FBCModelTests.Memote.Metabolite]
Pages = ["src/memote/checks/Metabolite.jl"]
Modules = [FBCModelTests.Memote.Metabolites]
Pages = ["src/memote/checks/Metabolites.jl"]
```

### Reaction checks

```@autodocs
Modules = [FBCModelTests.Memote.Reaction]
Pages = ["src/memote/checks/Reaction.jl"]
Modules = [FBCModelTests.Memote.Reactions]
Pages = ["src/memote/checks/Reactions.jl"]
```

### GPRAssociation checks
Expand Down
10 changes: 5 additions & 5 deletions src/memote/checks/Consistency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ $(TYPEDSIGNATURES)
Determines if the model is stoichiometrically consistent. Note, stoichiometric
consistency does not guarantee that mass balances must hold in the model. A more
robust check is [`reactions_mass_unbalanced`](@ref), but this works if not all
metabolites have mass assigned to them.
Based on Gevorgyan, Albert, Mark G. Poolman, and David A. Fell. "Detection of
stoichiometric inconsistencies in biomolecular models." Bioinformatics (2008).
Optionally ignore some reactions in this analysis by adding reaction IDs to
robust check is to ensure that each reaction is mass balanced, but this only
works if all metabolites have masses assigned to them. Test based on Gevorgyan,
Albert, Mark G. Poolman, and David A. Fell. "Detection of stoichiometric
inconsistencies in biomolecular models." Bioinformatics (2008). Optionally
ignore some reactions in this analysis by adding reaction IDs to
`config.consistency.consistency_ignored_reactions`.
"""
function model_is_consistent(
Expand Down
2 changes: 2 additions & 0 deletions src/memote/checks/Energy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import ..Config
"""
$(TYPEDSIGNATURES)
NOTE: this test is currently skipped and will appear as `broken` in the output.
Attempts to detect if the `model` contains any erroneous energy generating
cycles by closing all exchange reactions and using flux balance analysis to
maximize the sum of fluxes through a set of energy dissipating reactions. The
Expand Down
33 changes: 23 additions & 10 deletions src/memote/frontend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,30 @@ function run_tests(
@testset "Has SBO annotated metabolic reactions" begin
@test any(is_metabolic_reaction(model, rid) for rid in reactions(model))
end
@testset "Has SBO annotationed transport reactions" begin
@testset "Has SBO annotated transport reactions" begin
@test any(is_transport_reaction(model, rid) for rid in reactions(model))
end
@testset "Has SBO annotated biomass reactions" begin
@test any(is_biomass_reaction(model, rid) for rid in reactions(model))
end
@testset "Has SBO annotated exchange reactions" begin
@test any(is_exchange_reaction(model, rid) for rid in reactions(model))
end
@testset "Has SBO annotated atp maintenance reactions" begin
@test any(
is_atp_maintenance_reaction(model, rid) for rid in reactions(model)
)
end
end

@testset "Reactions" begin
@testset "Any annotations" begin
@testset "Any annotations present" begin
for rid in reactions(model)
@test Annotation.is_annotated_reaction(model, rid)
end
end

@testset "At most $(config.annotation.maximum_missing_databases) missing cross-references" begin
@testset "At most $(config.annotation.maximum_missing_databases) missing cross-references per entry" begin
for rid in reactions(model)
@test length(
Annotation.findall_unannotated_reaction_databases(
Expand All @@ -78,7 +90,7 @@ function run_tests(
) <= config.annotation.maximum_missing_databases
end
end
@testset "At most $(config.annotation.maximum_nonconformal_references) recognizable cross-references" begin
@testset "At most $(config.annotation.maximum_nonconformal_references) recognizable cross-references per entry" begin
for rid in reactions(model)
@test length(
Annotation.findall_nonconformal_reaction_annotations(
Expand All @@ -92,13 +104,13 @@ function run_tests(
end

@testset "Metabolites" begin
@testset "Any annotations" begin
@testset "Any annotations present" begin
for mid in metabolites(model)
@test Annotation.is_annotated_metabolite(model, mid)
end
end

@testset "At most $(config.annotation.maximum_missing_databases) missing cross-references" begin
@testset "At most $(config.annotation.maximum_missing_databases) missing cross-references per entry" begin
for mid in metabolites(model)
@test length(
Annotation.findall_unannotated_metabolite_databases(
Expand All @@ -109,7 +121,7 @@ function run_tests(
) <= config.annotation.maximum_missing_databases
end
end
@testset "At most $(config.annotation.maximum_nonconformal_references) recognizable cross-references" begin
@testset "At most $(config.annotation.maximum_nonconformal_references) recognizable cross-references per entry" begin
for mid in metabolites(model)
@test length(
Annotation.findall_nonconformal_metabolite_annotations(
Expand All @@ -124,13 +136,13 @@ function run_tests(


@testset "Genes" begin
@testset "Any annotations" begin
@testset "Any annotations present" begin
for gid in genes(model)
@test Annotation.is_annotated_gene(model, gid)
end
end

@testset "At most $(config.annotation.maximum_missing_databases) missing cross-references" begin
@testset "At most $(config.annotation.maximum_missing_databases) missing cross-references per entry" begin
for gid in genes(model)
@test length(
Annotation.findall_unannotated_gene_databases(
Expand All @@ -141,7 +153,7 @@ function run_tests(
) <= config.annotation.maximum_missing_databases
end
end
@testset "At most $(config.annotation.maximum_nonconformal_references) recognizable cross-references" begin
@testset "At most $(config.annotation.maximum_nonconformal_references) recognizable cross-references per entry" begin
for gid in genes(model)
@test length(
Annotation.findall_nonconformal_gene_annotations(
Expand Down Expand Up @@ -305,4 +317,5 @@ function run_tests(
end
end
end
return testres
end
37 changes: 14 additions & 23 deletions test/memote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ using FBCModelTests.Memote.Consistency
using FBCModelTests.Memote.Energy
using FBCModelTests.Memote.GPRAssociation
using FBCModelTests.Memote.Network
using FBCModelTests.Memote.Utils
using FBCModelTests.Memote.Reactions
using FBCModelTests.Memote.Metabolites

@testset "Front-end" begin
result = @testset CountTests "Testing a model that _should_ be OK" begin
Memote.run_tests(model_file["e_coli_core.json"], GLPK.Optimizer)
end

@test result.passes == 1781
@test result.fails == 11
@test result.errs == 0
@test result.passes == 1783
@test result.fails == 12
@test result.errs == 1

# @testset "Report can be written successfully as JSON" begin
# r = Memote.generate_report(model_file["e_coli_core.json"], GLPK.Optimizer)
Expand Down Expand Up @@ -132,26 +133,19 @@ end
end

@testset "Metabolite" begin
@test isempty(
FBCModelTests.Memote.Metabolites.metabolites_duplicated_in_compartment(model),
)
@test isempty(FBCModelTests.Memote.Metabolites.find_orphan_metabolites(model))
@test isempty(FBCModelTests.Memote.Metabolites.find_deadend_metabolites(model))
@test isempty(FBCModelTests.Memote.Metabolites.find_disconnected_metabolites(model))
@test isempty(Metabolites.metabolites_duplicated_in_compartment(model))
@test isempty(Metabolites.find_orphan_metabolites(model))
@test isempty(Metabolites.find_deadend_metabolites(model))
@test isempty(Metabolites.find_disconnected_metabolites(model))

negative_model = convert(StandardModel, deepcopy(model))
dup = deepcopy(negative_model.metabolites["atp_c"])
dup.id = "atp_dup"
add_metabolite!(negative_model, dup)
@test "atp_dup" in
FBCModelTests.Memote.Metabolites.metabolites_duplicated_in_compartment(
negative_model,
)
@test !isempty(FBCModelTests.Memote.Metabolites.find_orphan_metabolites(iJN746))
@test !isempty(FBCModelTests.Memote.Metabolites.find_deadend_metabolites(iJN746))
@test !isempty(
FBCModelTests.Memote.Metabolites.find_disconnected_metabolites(negative_model),
)
@test "atp_dup" in Metabolites.metabolites_duplicated_in_compartment(negative_model)
@test !isempty(Metabolites.find_orphan_metabolites(iJN746))
@test !isempty(Metabolites.find_deadend_metabolites(iJN746))
@test !isempty(Metabolites.find_disconnected_metabolites(negative_model))
end

@testset "Network" begin
Expand Down Expand Up @@ -179,10 +173,7 @@ end
end

@testset "Reactions" begin
@test issetequal(
FBCModelTests.Memote.Reactions.duplicate_reactions(model),
["FRD7", "SUCDi"],
) # TODO should be empty, will be broken once #785 in COBREXA gets fixed
@test issetequal(Reactions.duplicate_reactions(model), ["FRD7", "SUCDi"]) # TODO should be empty, will be broken once #785 in COBREXA gets fixed

@test !Reactions.model_has_atpm_reaction(model)
@test Reactions.reaction_is_charge_balanced(model, "ENO")
Expand Down

0 comments on commit 6eccfdd

Please sign in to comment.