{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " 2.841473 seconds (29.15 M allocations: 760.187 MiB, 13.26% gc time, 23.18% compilation time)\n", "861.983010 seconds (3.91 G allocations: 351.983 GiB, 7.58% gc time, 1.66% compilation time)\n", "The answer is correct.\n", "The answer is correct.\n" ] } ], "source": [ "# importing the example model and the sparseQFCA module\n", "using sparseQFCA, JSON, SparseArrays, DelimitedFiles\n", "@time open(\"iMM1415.json\") do f\n", " dict = JSON.parse(f);\n", " data = dict[\"reactions\"];\n", " global name = [(data[i])[\"name\"] for i in 1:length(data)];\n", " global lower_bound = [(data[i])[\"lower_bound\"] for i in 1:length(data)];\n", " global upper_bound = [(data[i])[\"upper_bound\"] for i in 1:length(data)];\n", " global gene_reaction_rule = [(data[i])[\"gene_reaction_rule\"] for i in 1:length(data)];\n", " metabolites = [(data[i])[\"metabolites\"] for i in 1:length(data)];\n", " id = [((dict[\"metabolites\"])[i])[\"id\"] for i in 1:length(dict[\"metabolites\"])];\n", " S = Matrix{Float64}(undef, length(id), length(metabolites));\n", " for i in 1:length(metabolites)\n", " for j in 1:length(id)\n", " S[j, i] = get(metabolites[i], id[j], 0)\n", " end\n", " end\n", " global S = sparse(S);\n", "end\n", "@assert typeof(S) == SparseMatrixCSC{Float64,Int64}\n", "rev = readdlm(\"rev.csv\", header = false)[:, 1] .== 1\n", "@assert typeof(rev) == BitArray{1}\n", "# finding all the flux coupling relations among the reactions\n", "certificates, blocked, fctable = @time QFCA(S, rev)\n", "println(\"The answer is $(all((readdlm(\"blocked.csv\", header = false) .== 1) .== blocked) ? \"correct\" : \"wrong\").\")\n", "println(\"The answer is $(all(readdlm(\"fctable.csv\", header = false) .== fctable) ? \"correct\" : \"wrong\").\")\n", "open(\"certificates.txt\", \"w\") do io\n", " writedlm(io, certificates)\n", "end" ] } ], "metadata": { "kernelspec": { "display_name": "Julia 1.7.2", "language": "julia", "name": "julia-1.7" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.7.2" } }, "nbformat": 4, "nbformat_minor": 2 }